From: Leonardo Florez-Valencia Date: Wed, 13 Apr 2016 23:54:49 +0000 (-0500) Subject: ... X-Git-Tag: v0.1~190 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=2b1c1e57470677097b0b554ffdbd6970951c41ef;p=cpPlugins.git ... --- diff --git a/lib/cpPlugins/ProcessObject.cxx b/lib/cpPlugins/ProcessObject.cxx index d93fd18..136b45c 100644 --- a/lib/cpPlugins/ProcessObject.cxx +++ b/lib/cpPlugins/ProcessObject.cxx @@ -1,6 +1,7 @@ #include #include #include +#include // ------------------------------------------------------------------------- cpPlugins::Parameters* cpPlugins::ProcessObject:: @@ -235,8 +236,22 @@ Update( ) { 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 diff --git a/lib/cpPlugins/Workspace.cxx b/lib/cpPlugins/Workspace.cxx index 9476679..7ba11d1 100644 --- a/lib/cpPlugins/Workspace.cxx +++ b/lib/cpPlugins/Workspace.cxx @@ -152,6 +152,21 @@ RemoveFilter( const std::string& name ) { } +// ------------------------------------------------------------------------- +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( ) diff --git a/lib/cpPlugins/Workspace.h b/lib/cpPlugins/Workspace.h index c450063..d99831b 100644 --- a/lib/cpPlugins/Workspace.h +++ b/lib/cpPlugins/Workspace.h @@ -78,6 +78,7 @@ namespace cpPlugins 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( ); diff --git a/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx b/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx new file mode 100644 index 0000000..d5f8df8 --- /dev/null +++ b/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx @@ -0,0 +1,67 @@ +#include "NoInteractiveSeedWidget.h" + +#include +#include +#include +#include + +// ------------------------------------------------------------------------- +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$ diff --git a/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.h b/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.h new file mode 100644 index 0000000..9319879 --- /dev/null +++ b/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.h @@ -0,0 +1,44 @@ +#ifndef __CPPLUGINSWIDGETS__NOINTERACTIVESEEDWIDGET__H__ +#define __CPPLUGINSWIDGETS__NOINTERACTIVESEEDWIDGET__H__ + +#include +#include + +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$