#include <cpPlugins/ProcessObject.h>
#include <cpPlugins/ParametersQtDialog.h>
#include <itkProcessObject.h>
+#include <chrono>
// -------------------------------------------------------------------------
cpPlugins::Parameters* cpPlugins::ProcessObject::
{
if( this->m_LastExecutionTime < this->GetMTime( ) || need_to_update )
{
+ std::cout
+ << "cpPlugins: Updating \""
+ << this->GetClassName( ) << ":" << this->GetClassCategory( )
+ << "\"... ";
+ std::cout.flush( );
+ long start =
+ std::chrono::duration_cast< std::chrono::milliseconds >(
+ std::chrono::system_clock::now( ).time_since_epoch( )
+ ).count( );
r = this->_GenerateData( );
+ long end =
+ std::chrono::duration_cast< std::chrono::milliseconds >(
+ std::chrono::system_clock::now( ).time_since_epoch( )
+ ).count( );
this->m_LastExecutionTime = this->GetMTime( );
+ std::cout << "done in " << ( ( end - start ) / 1000 ) << "ms!" << std::endl;
} // fi
{
}
+// -------------------------------------------------------------------------
+void cpPlugins::Workspace::
+SetParameter( const std::string& name, const std::string& value )
+{
+ std::vector< std::string > tokens;
+ cpPlugins::TokenizeString( tokens, name, "@" );
+
+ if( this->HasFilter( tokens[ 1 ] ) )
+ {
+ auto filter = this->GetFilter( tokens[ 1 ] );
+ filter->GetParameters( )->SetString( tokens[ 0 ], value );
+
+ } // fi
+}
+
// -------------------------------------------------------------------------
vtkRenderWindowInteractor* cpPlugins::Workspace::
GetSingleInteractor( )
const std::string& old_name, const std::string& new_name
);
void RemoveFilter( const std::string& name );
+ void SetParameter( const std::string& name, const std::string& value );
// Widgets management
vtkRenderWindowInteractor* GetSingleInteractor( );
--- /dev/null
+#include "NoInteractiveSeedWidget.h"
+
+#include <cpPlugins/Image.h>
+#include <cpExtensions/DataStructures/ImageIndexesContainer.h>
+#include <itkSimpleDataObjectDecorator.h>
+#include <itkSimpleDataObjectDecorator.hxx>
+
+// -------------------------------------------------------------------------
+cpPluginsWidgets::NoInteractiveSeedWidget::
+NoInteractiveSeedWidget( )
+ : Superclass( )
+{
+ this->_AddInput( "ReferenceImage" );
+ this->_AddOutput< cpPlugins::DataObject >( "Output" );
+ this->m_Parameters.ConfigureAsString( "Text" );
+ this->m_Parameters.SetString( "Text", "" );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsWidgets::NoInteractiveSeedWidget::
+~NoInteractiveSeedWidget( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPluginsWidgets::NoInteractiveSeedWidget::
+_GenerateData( )
+{
+ auto image = this->GetInputData( "ReferenceImage" );
+ std::string r = cpPlugin_Image_Demangle_Dim( _GD0, image, 3 );
+ if( r != "" ) r = cpPlugin_Image_Demangle_Dim( _GD0, image, 2 );
+ return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+std::string cpPluginsWidgets::NoInteractiveSeedWidget::
+_GD0( _TImage* image )
+{
+ typedef
+ cpExtensions::DataStructures::ImageIndexesContainer< _TImage::ImageDimension >
+ _TContainer;
+
+ if( image != NULL )
+ {
+ auto container = this->_CreateITK< _TContainer >( );
+ std::string info = this->m_Parameters.GetString( "Text" );
+
+ std::istringstream str( info );
+ double x, y, z;
+ str >> x >> y >> z;
+ typename _TImage::PointType seed;
+ seed[ 0 ] = x;
+ seed[ 1 ] = y;
+ seed[ 2 ] = z;
+ typename _TImage::IndexType idx;
+ if( image->TransformPhysicalPointToIndex( seed, idx ) )
+ container->Get( ).push_back( idx );
+ container->SetReferenceImage( image );
+ this->GetOutputData( "Output" )->SetITK( container );
+ return( "" );
+ }
+ else
+ return( "Widgets::NoInteractiveSeedWidget: Input image dimension not supported." );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINSWIDGETS__NOINTERACTIVESEEDWIDGET__H__
+#define __CPPLUGINSWIDGETS__NOINTERACTIVESEEDWIDGET__H__
+
+#include <plugins/cpPluginsWidgets/cpPluginsWidgets_Export.h>
+#include <cpPlugins/BaseWidget.h>
+
+namespace cpPluginsWidgets
+{
+ /**
+ */
+ class cpPluginsWidgets_EXPORT NoInteractiveSeedWidget
+ : public cpPlugins::BaseWidget
+ {
+ public:
+ typedef NoInteractiveSeedWidget Self;
+ typedef cpPlugins::BaseWidget Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( NoInteractiveSeedWidget, cpPlugins::BaseWidget );
+ cpPlugins_Id_Macro( NoInteractiveSeedWidget, Widgets );
+
+ protected:
+ NoInteractiveSeedWidget( );
+ virtual ~NoInteractiveSeedWidget( );
+
+ virtual std::string _GenerateData( ) ITK_OVERRIDE;
+
+ template< class _TImage >
+ inline std::string _GD0( _TImage* image );
+
+ private:
+ // Purposely not implemented
+ NoInteractiveSeedWidget( const Self& );
+ Self& operator=( const Self& );
+ };
+
+} // ecapseman
+
+#endif // __CPPLUGINSWIDGETS__NOINTERACTIVESEEDWIDGET__H__
+
+// eof - $RCSfile$