From b445d953049ba15290197549dcd4e31367e3c8a5 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Thu, 31 Mar 2016 19:10:24 -0500 Subject: [PATCH] More plugins added --- appli/PipelineEditor/PipelineEditor.cxx | 399 ++---------------- appli/PipelineEditor/PipelineEditor.h | 39 +- appli/examples/plugins/CMakeLists.txt | 2 +- cmake/cpPluginsConfig.cmake.in | 2 + .../MultiScaleGaussianImageFilter.h | 17 - .../MultiScaleGaussianImageFilter.hxx | 93 +--- lib/cpExtensions/QT/SimpleMPRWidget.cxx | 21 + lib/cpExtensions/QT/SimpleMPRWidget.h | 3 + lib/cpPlugins/BaseQtMainWindow.cxx | 336 +++++++++++++++ lib/cpPlugins/BaseQtMainWindow.h | 95 +++++ lib/cpPlugins/CMakeLists.txt | 2 + lib/cpPlugins/Image.hxx | 7 + lib/cpPlugins/Interface.cxx | 10 +- lib/cpPlugins/Mesh.cxx | 5 - lib/cpPlugins_ITKInstances/Base.cxx | 5 + .../Base_explicit_description.txt | 11 + lib/cpPlugins_ITKInstances/Image.cxx | 1 + .../ImageFilters_explicit_description.txt | 3 + .../Image_explicit_description.txt | 2 + .../Mesh_explicit_description.txt | 4 +- plugins/cpPluginsIO/CMakeLists.txt | 2 +- plugins/cpPluginsImageFilters/CMakeLists.txt | 2 +- .../ExtractImageFilter.cxx | 79 ++++ .../ExtractImageFilter.h | 44 ++ .../cpPluginsImageFilters/IsoImageSlicer.cxx | 116 +++++ .../cpPluginsImageFilters/IsoImageSlicer.h | 47 +++ .../JoinSeriesImageFilter.cxx | 64 +++ .../JoinSeriesImageFilter.h | 47 +++ .../MultiScaleGaussianImageFilter.cxx | 107 +++++ .../MultiScaleGaussianImageFilter.h | 47 +++ .../ResampleImageFilter.cxx | 87 ++++ .../ResampleImageFilter.h | 47 +++ .../cpPluginsImageMeshFilters/CMakeLists.txt | 2 +- plugins/cpPluginsMeshFilters/CMakeLists.txt | 2 +- plugins/cpPluginsVisualization/CMakeLists.txt | 2 +- plugins/cpPluginsWidgets/CMakeLists.txt | 2 +- 36 files changed, 1221 insertions(+), 533 deletions(-) create mode 100644 lib/cpPlugins/BaseQtMainWindow.cxx create mode 100644 lib/cpPlugins/BaseQtMainWindow.h create mode 100644 plugins/cpPluginsImageFilters/ExtractImageFilter.cxx create mode 100644 plugins/cpPluginsImageFilters/ExtractImageFilter.h create mode 100644 plugins/cpPluginsImageFilters/IsoImageSlicer.cxx create mode 100644 plugins/cpPluginsImageFilters/IsoImageSlicer.h create mode 100644 plugins/cpPluginsImageFilters/JoinSeriesImageFilter.cxx create mode 100644 plugins/cpPluginsImageFilters/JoinSeriesImageFilter.h create mode 100644 plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.cxx create mode 100644 plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.h create mode 100644 plugins/cpPluginsImageFilters/ResampleImageFilter.cxx create mode 100644 plugins/cpPluginsImageFilters/ResampleImageFilter.h diff --git a/appli/PipelineEditor/PipelineEditor.cxx b/appli/PipelineEditor/PipelineEditor.cxx index 2f7d7ea..eeaee07 100644 --- a/appli/PipelineEditor/PipelineEditor.cxx +++ b/appli/PipelineEditor/PipelineEditor.cxx @@ -2,107 +2,39 @@ #include "ui_PipelineEditor.h" #include - -#include #include -#include -#include - -#include - -// ------------------------------------------------------------------------- -#define PipelineEditor_ConnectAction( ACTION ) \ - this->connect( \ - this->m_UI->Action##ACTION, SIGNAL( triggered( ) ), \ - this, SLOT( _Action##ACTION( ) ) \ - ) - -// ------------------------------------------------------------------------- -#define PipelineEditor_ConnectButton( BUTTON ) \ - this->connect( \ - this->m_UI->Button##BUTTON, SIGNAL( clicked( ) ), \ - this, SLOT( _Button##BUTTON( ) ) \ - ) - -// ------------------------------------------------------------------------- -bool PipelineEditor_Blocker:: -eventFilter( QObject* obj, QEvent* event ) -{ - return( true ); // -> Block all events - /* NOTE: correct implementation: - switch( event->type( ) ) - { - //list event you want to prevent here ... - case QEvent::KeyPress: - case QEvent::KeyRelease: - case QEvent::MouseButtonRelease: - case QEvent::MouseButtonPress: - case QEvent::MouseButtonDblClick: - //... - return( true ); - } // hctiws - return( this->QObject::eventFilter( obj, event ) ); - */ -} - // ------------------------------------------------------------------------- PipelineEditor:: PipelineEditor( int argc, char* argv[], QApplication* app, QWidget* parent ) - : QMainWindow( parent ), - m_UI( new Ui::PipelineEditor ), - m_Application( app ), - m_Workspace( NULL ), - m_PluginsPath( "." ) + : Superclass( argc, argv, app, parent ), + m_UI( new Ui::PipelineEditor ) { + // Basic configuration this->m_UI->setupUi( this ); - - // Prepare plugins interface - QFileInfo info( argv[ 0 ] ); - if( info.exists( ) ) - { - if( !( this->m_Interface.LoadConfiguration( cpPlugins_CONFIG_FILE ) ) ) - { - this->m_PluginsPath = info.canonicalPath( ).toStdString( ); - this->_LoadPluginsFromPath( this->m_PluginsPath ); - } - /* - else - this->_UpdateLoadedPlugins( ); - */ - - } // fi - QDir exec_dir( "." ); - if( exec_dir.exists( ) ) - this->_LoadPluginsFromPath( exec_dir.canonicalPath( ).toStdString( ) ); - - /* TODO - this->m_Interface = new cpPlugins::Interface( ); - this->m_PluginsPath = info.canonicalPath( ).toStdString( ); - if( !( this->m_Interface->LoadDefaultConfiguration( this->m_PluginsPath ) ) ) - if( this->m_Interface->LoadFromFolder( this->m_PluginsPath, false ) != "" ) - if( !( this->m_Interface->SaveDefaultConfiguration( this->m_PluginsPath ) ) ) - QMessageBox::critical( - this, - "Error creating default plugins configuration", - "Could not save default plugins configuration" - ); - this->_UpdateLoadedPlugins( ); - - } // fi - */ - - // Create an empty workspace - this->m_Workspace = new cpPlugins::Workspace( ); - this->m_Workspace->SetInterface( &( this->m_Interface ) ); - this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace ); - this->m_Workspace->SetMPRViewer( this->m_UI->Viewer ); + this->_Configure( + this->m_UI->LoadedPlugins, + this->m_UI->Viewer, + this->m_UI->Canvas->editor( ) + ); // Connect actions to slots - PipelineEditor_ConnectButton( LoadPluginsFile ); - PipelineEditor_ConnectButton( LoadPluginsPath ); - PipelineEditor_ConnectAction( OpenWorkspace ); - PipelineEditor_ConnectAction( SaveWorkspace ); + this->connect( + this->m_UI->ButtonLoadPluginsFile, SIGNAL( clicked( ) ), + this, SLOT( _InteractiveLoadPlugins( ) ) + ); + this->connect( + this->m_UI->ButtonLoadPluginsPath, SIGNAL( clicked( ) ), + this, SLOT( _InteractiveLoadPluginsFromPath( ) ) + ); + this->connect( + this->m_UI->ActionOpenWorkspace, SIGNAL( triggered( ) ), + this, SLOT( _InteractiveLoadWorkspace( ) ) + ); + this->connect( + this->m_UI->ActionSaveWorkspace, SIGNAL( triggered( ) ), + this, SLOT( _InteractiveSaveWorkspace( ) ) + ); this->connect( this->m_UI->Canvas->editor( ), SIGNAL( execFilter( const std::string& ) ), @@ -121,278 +53,9 @@ PipelineEditor( int argc, char* argv[], QApplication* app, QWidget* parent ) PipelineEditor:: ~PipelineEditor( ) { - if( this->m_Workspace != NULL ) - delete this->m_Workspace; delete this->m_UI; } -// ------------------------------------------------------------------------- -void PipelineEditor:: -_LoadPluginsFromPath( const std::string& path ) -{ - QDir dir( path.c_str( ) ); - std::stringstream filters_str; - filters_str << "*." << cpPlugins_PLUGIN_EXT; - QStringList filters; - filters << filters_str.str( ).c_str( ); - auto files = dir.entryList( filters ); - for( auto fIt = files.begin( ); fIt != files.end( ); ++fIt ) - { - try - { - this->m_Interface.LoadPluginFile( - ( dir.absolutePath( ) + QDir::separator( ) + *fIt ).toStdString( ) - ); - } - catch( std::exception& err ) - { - // Just ignore un-loadable libraries - } // yrt - - } // rof - this->_UpdateLoadedPlugins( ); -} - -// ------------------------------------------------------------------------- -void PipelineEditor:: -_UpdateLoadedPlugins( ) -{ - this->_Block( ); - auto filters = this->m_Interface.GetFilters( ); - if( filters.size( ) == 0 ) - { - QMessageBox::critical( - this, - "Error loading default plugins", - "No plugins loaded: remember to load some!!!" - ); - this->_UnBlock( ); - return; - - } // fi - - for( auto cIt = filters.begin( ); cIt != filters.end( ); ++cIt ) - { - // Create or get category - QList< QTreeWidgetItem* > cat_items = - this->m_UI->LoadedPlugins->findItems( - cIt->first.c_str( ), Qt::MatchExactly | Qt::MatchRecursive - ); - QTreeWidgetItem* cat = NULL; - if( cat_items.size( ) == 0 ) - { - cat = new QTreeWidgetItem( - ( QTreeWidgetItem* )( NULL ), QStringList( cIt->first.c_str( ) ) - ); - this->m_UI->LoadedPlugins->addTopLevelItem( cat ); - } - else - cat = cat_items[ 0 ]; - - // Create filters - auto fIt = cIt->second.begin( ); - for( ; fIt != cIt->second.end( ); ++fIt ) - { - QList< QTreeWidgetItem* > filter_items = - this->m_UI->LoadedPlugins->findItems( - fIt->c_str( ), Qt::MatchExactly | Qt::MatchRecursive - ); - auto fiIt = filter_items.begin( ); - auto found_fiIt = filter_items.end( ); - for( ; fiIt != filter_items.end( ); ++fiIt ) - if( ( *fiIt )->parent( ) == cat ) - found_fiIt = fiIt; - - // Add filter - if( found_fiIt == filter_items.end( ) ) - QTreeWidgetItem* filter = new QTreeWidgetItem( - cat, QStringList( fIt->c_str( ) ) - ); - - } // rof - - } // rof - this->_UnBlock( ); - this->m_Interface.SaveConfiguration( cpPlugins_CONFIG_FILE ); -} - -// ------------------------------------------------------------------------- -void PipelineEditor:: -_Block( ) -{ - this->m_Application->setOverrideCursor( Qt::WaitCursor ); - this->m_Application->installEventFilter( &( this->m_Blocker ) ); -} - -// ------------------------------------------------------------------------- -void PipelineEditor:: -_UnBlock( ) -{ - while( this->m_Application->overrideCursor( ) ) - this->m_Application->restoreOverrideCursor( ); - this->m_Application->removeEventFilter( &( this->m_Blocker ) ); -} - -// ------------------------------------------------------------------------- -void PipelineEditor:: -_ButtonLoadPluginsFile( ) -{ - QFileDialog dlg( this ); - dlg.setFileMode( QFileDialog::ExistingFiles ); - dlg.setDirectory( "." ); - - std::stringstream name_filter; - std::string suffix = std::string( cpPlugins_PLUGIN_EXT ); - name_filter - << "Plugins file (*." << cpPlugins_PLUGIN_EXT << ");;All files (*)"; - dlg.setNameFilter( name_filter.str( ).c_str( ) ); - dlg.setDefaultSuffix( suffix.c_str( ) ); - - if( !( dlg.exec( ) ) ) - return; - - // Read - QStringList names = dlg.selectedFiles( ); - std::stringstream err_str; - for( auto qIt = names.begin( ); qIt != names.end( ); ++qIt ) - { - try - { - this->m_Interface.LoadPluginFile( qIt->toStdString( ) ); - } - catch( std::exception& err ) - { - err_str << err.what( ) << std::endl; - - } // yrt - - } // rof - - // Show an error message - std::string err = err_str.str( ); - if( err.size( ) > 0 ) - QMessageBox::critical( - this, - "Error loading plugins", - err.c_str( ) - ); - - // Update view - // TODO: this->m_Interface.SaveDefaultConfiguration( this->m_PluginsPath ); - this->_UpdateLoadedPlugins( ); -} - -// ------------------------------------------------------------------------- -void PipelineEditor:: -_ButtonLoadPluginsPath( ) -{ - /* - QFileDialog dlg( this ); - dlg.setFileMode( QFileDialog::DirectoryOnly ); - dlg.setDirectory( "." ); - if( !( dlg.exec( ) ) ) - return; - - // Read - std::string dir = dlg.selectedFiles( ).begin( )->toStdString( ); - std::string err = this->m_Interface->LoadFromFolder( dir, false ); - if( err != "" ) - QMessageBox::critical( - this, - "Error loading plugins directory", - err.c_str( ) - ); - - // Update view - this->m_Interface->SaveDefaultConfiguration( this->m_PluginsPath ); - this->_UpdateLoadedPlugins( ); - */ -} - -// ------------------------------------------------------------------------- -void PipelineEditor:: -_ActionOpenWorkspace( ) -{ - QFileDialog dlg( this ); - dlg.setFileMode( QFileDialog::ExistingFile ); - dlg.setDirectory( "." ); - dlg.setNameFilter( - QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" ) - ); - dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) ); - if( !( dlg.exec( ) ) ) - return; - - std::string fname = dlg.selectedFiles( ).at( 0 ).toStdString( ); - if( this->m_Workspace != NULL ) - delete this->m_Workspace; - this->m_Workspace = new cpPlugins::Workspace( ); - this->m_Workspace->SetInterface( &( this->m_Interface ) ); - this->m_Workspace->SetMPRViewer( this->m_UI->Viewer ); - std::string err = this->m_Workspace->LoadWorkspace( fname ); - if( err != "" ) - { - delete this->m_Workspace; - this->m_Workspace = NULL; - QMessageBox::critical( - this, - QMessageBox::tr( "Error loading workspace" ), - QMessageBox::tr( err.c_str( ) ) - ); - } - else - this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace ); -} - -// ------------------------------------------------------------------------- -void PipelineEditor:: -_ActionSaveWorkspace( ) -{ - if( this->m_Workspace == NULL ) - return; - - QFileDialog dlg( this ); - dlg.setFileMode( QFileDialog::AnyFile ); - dlg.setDirectory( "." ); - dlg.setAcceptMode( QFileDialog::AcceptSave ); - dlg.setNameFilter( - QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" ) - ); - dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) ); - if( !( dlg.exec( ) ) ) - return; - std::string fname = dlg.selectedFiles( ).at( 0 ).toStdString( ); - - std::string err = this->m_Workspace->SaveWorkspace( fname ); - if( err != "" ) - QMessageBox::critical( - this, - QMessageBox::tr( "Error saving workspace" ), - QMessageBox::tr( err.c_str( ) ) - ); -} - - -// ------------------------------------------------------------------------- -void PipelineEditor:: -_ExecFilter( const std::string& filter_name ) -{ - if( this->m_Workspace != NULL ) - { - // Update filter, if needed - this->_Block( ); - std::string err = this->m_Workspace->Execute( filter_name ); - this->_UnBlock( ); - if( err != "" ) - QMessageBox::critical( - this, - QMessageBox::tr( "Error executing filter" ), - QMessageBox::tr( err.c_str( ) ) - ); - - } // fi -} - // ------------------------------------------------------------------------- void PipelineEditor:: _ShowFilterOutput( @@ -405,7 +68,7 @@ _ShowFilterOutput( this->_ExecFilter( filter_name ); // Get output - auto filter = this->m_Workspace->GetFilter( filter_name ); + auto filter = this->m_Workspace.GetFilter( filter_name ); if( filter != NULL ) { auto output = filter->GetOutputData( output_name ); @@ -446,18 +109,6 @@ _ShowFilterOutput( QMessageBox::tr( "No known VTK conversion!" ) ); - /* TODO - if( this->m_UI->Viewer->AddData( output, data_name, "" ) ) - { - if( this->m_UI->Viewer->GetNumberOfData( ) > 1 ) - this->m_UI->Viewer->SetDataColor( data_name, 1, 0, 0 ); - else - this->m_UI->Viewer->SetMainImage( data_name ); - this->m_UI->Viewer->ShowData( data_name ); - } - else - */ - } // fi } // fi diff --git a/appli/PipelineEditor/PipelineEditor.h b/appli/PipelineEditor/PipelineEditor.h index c5f1261..fa6f48e 100644 --- a/appli/PipelineEditor/PipelineEditor.h +++ b/appli/PipelineEditor/PipelineEditor.h @@ -1,20 +1,7 @@ #ifndef __PIPELINEEDITOR__H__ #define __PIPELINEEDITOR__H__ -// Qt stuff -#include -#include -#include -#include - -/** - */ -class PipelineEditor_Blocker - : public QObject -{ -protected: - virtual bool eventFilter( QObject* obj, QEvent* event ) ITK_OVERRIDE; -}; +#include // ------------------------------------------------------------------------- namespace Ui @@ -25,13 +12,13 @@ namespace Ui /** */ class PipelineEditor - : public QMainWindow + : public cpPlugins::BaseQtMainWindow { Q_OBJECT; public: - typedef PipelineEditor Self; - typedef QMainWindow Superclass; + typedef PipelineEditor Self; + typedef cpPlugins::BaseQtMainWindow Superclass; public: explicit PipelineEditor( @@ -41,29 +28,13 @@ public: ); virtual ~PipelineEditor( ); -protected: - void _LoadPluginsFromPath( const std::string& path ); - void _UpdateLoadedPlugins( ); - void _Block( ); - void _UnBlock( ); - protected slots: - void _ButtonLoadPluginsFile( ); - void _ButtonLoadPluginsPath( ); - void _ActionOpenWorkspace( ); - void _ActionSaveWorkspace( ); - void _ExecFilter( const std::string& filter_name ); void _ShowFilterOutput( const std::string& filter_name, const std::string& output_name ); private: - Ui::PipelineEditor* m_UI; - QApplication* m_Application; - PipelineEditor_Blocker m_Blocker; - cpPlugins::Workspace* m_Workspace; - cpPlugins::Interface m_Interface; - std::string m_PluginsPath; + Ui::PipelineEditor* m_UI; }; #endif // __CPPIPELINEEDITOR__H__ diff --git a/appli/examples/plugins/CMakeLists.txt b/appli/examples/plugins/CMakeLists.txt index 752c62b..2484205 100644 --- a/appli/examples/plugins/CMakeLists.txt +++ b/appli/examples/plugins/CMakeLists.txt @@ -8,7 +8,7 @@ SET( FOREACH(example ${examples_SOURCES}) ADD_EXECUTABLE(${example} ${example}.cxx) - TARGET_LINK_LIBRARIES(${example} cpPlugins) + TARGET_LINK_LIBRARIES(${example} cpPlugins cpPipelineEditor) ENDFOREACH(example) ## eof - $RCSfile$ diff --git a/cmake/cpPluginsConfig.cmake.in b/cmake/cpPluginsConfig.cmake.in index 734e990..8937069 100644 --- a/cmake/cpPluginsConfig.cmake.in +++ b/cmake/cpPluginsConfig.cmake.in @@ -83,7 +83,9 @@ ENDIF(MSVC) # =================== SET(cpExtensions_LIBRARY cpExtensions) +SET(cpPlugins_tinyxml2_LIBRARY cpPlugins_tinyxml2) SET(cpPlugins_LIBRARY cpPlugins) +SET(cpPipelineEditor_LIBRARY cpPipelineEditor) # ====================== # -- Executable names -- diff --git a/lib/cpExtensions/Algorithms/MultiScaleGaussianImageFilter.h b/lib/cpExtensions/Algorithms/MultiScaleGaussianImageFilter.h index 5dba45b..c0612a2 100644 --- a/lib/cpExtensions/Algorithms/MultiScaleGaussianImageFilter.h +++ b/lib/cpExtensions/Algorithms/MultiScaleGaussianImageFilter.h @@ -29,14 +29,6 @@ namespace cpExtensions typedef std::set< double > TScalesContainer; - enum FilterId - { - Gradient = 0, - GradientMagnitude, - Hessian, - None - }; - protected: /** */ @@ -59,14 +51,6 @@ namespace cpExtensions itkTypeMacro( MultiScaleGaussianImageFilter, itkImageToImageFilter ); public: - void SetFilterToGradient( ); - void SetFilterToGradientMagnitude( ); - void SetFilterToHessian( ); - - bool IsGradientFilter( ) const; - bool IsGradientMagnitudeFilter( ) const; - bool IsHessianFilter( ) const; - void AddScale( const double& s ); unsigned long GetNumberOfScales( ) const; @@ -86,7 +70,6 @@ namespace cpExtensions protected: TScalesContainer m_Scales; - FilterId m_FilterId; }; } // ecapseman diff --git a/lib/cpExtensions/Algorithms/MultiScaleGaussianImageFilter.hxx b/lib/cpExtensions/Algorithms/MultiScaleGaussianImageFilter.hxx index c2e7cff..aff0fd8 100644 --- a/lib/cpExtensions/Algorithms/MultiScaleGaussianImageFilter.hxx +++ b/lib/cpExtensions/Algorithms/MultiScaleGaussianImageFilter.hxx @@ -14,9 +14,7 @@ #include #include -#include #include -#include // ------------------------------------------------------------------------- template< class I, class O > @@ -83,77 +81,6 @@ operator()( const _T& a, const _T& b ) const return( ( vb.magnitude( ) < va.magnitude( ) )? a: b ); } -// ------------------------------------------------------------------------- -template< class I, class O > -void -cpExtensions::Algorithms:: -MultiScaleGaussianImageFilter< I, O >:: -SetFilterToGradient( ) -{ - if( - itk::NumericTraits< typename O::PixelType >::GetLength( ) == - I::ImageDimension - ) - this->m_FilterId = Self::Gradient; - else - this->m_FilterId = Self::None; - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void -cpExtensions::Algorithms:: -MultiScaleGaussianImageFilter< I, O >:: -SetFilterToGradientMagnitude( ) -{ - if( itk::NumericTraits< typename O::PixelType >::GetLength( ) == 1 ) - this->m_FilterId = Self::GradientMagnitude; - else - this->m_FilterId = Self::None; - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void -cpExtensions::Algorithms:: -MultiScaleGaussianImageFilter< I, O >:: -SetFilterToHessian( ) -{ - itkExceptionMacro( << "Check for hessian definition." ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -bool -cpExtensions::Algorithms:: -MultiScaleGaussianImageFilter< I, O >:: -IsGradientFilter( ) const -{ - return( this->m_FilterId == Self::Gradient ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -bool -cpExtensions::Algorithms:: -MultiScaleGaussianImageFilter< I, O >:: -IsGradientMagnitudeFilter( ) const -{ - return( this->m_FilterId == Self::GradientMagnitude ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -bool -cpExtensions::Algorithms:: -MultiScaleGaussianImageFilter< I, O >:: -IsHessianFilter( ) const -{ - return( this->m_FilterId == Self::Hessian ); -} - // ------------------------------------------------------------------------- template< class I, class O > void @@ -182,14 +109,6 @@ MultiScaleGaussianImageFilter< I, O >:: MultiScaleGaussianImageFilter( ) : Superclass( ) { - this->SetFilterToGradientMagnitude( ); - if( !this->IsGradientMagnitudeFilter( ) ) - { - this->SetFilterToGradient( ); - if( !this->IsGradientFilter( ) ) - this->SetFilterToHessian( ); - - } // fi } // ------------------------------------------------------------------------- @@ -207,16 +126,8 @@ cpExtensions::Algorithms:: MultiScaleGaussianImageFilter< I, O >:: GenerateData( ) { - typedef itk::GradientRecursiveGaussianImageFilter< I, O > _TGF; - typedef itk::GradientMagnitudeRecursiveGaussianImageFilter< I, O > _TGMF; - typedef itk::HessianRecursiveGaussianImageFilter< I, O > _THF; - - if( this->IsGradientFilter( ) ) - this->_GenerateData< _TGF >( ); - else if( this->IsGradientMagnitudeFilter( ) ) - this->_GenerateData< _TGMF >( ); - else if( this->IsHessianFilter( ) ) - this->_GenerateData< _THF >( ); + typedef itk::GradientRecursiveGaussianImageFilter< I, O > _TGF; + this->_GenerateData< _TGF >( ); } // ------------------------------------------------------------------------- diff --git a/lib/cpExtensions/QT/SimpleMPRWidget.cxx b/lib/cpExtensions/QT/SimpleMPRWidget.cxx index 98c8191..ee2196e 100644 --- a/lib/cpExtensions/QT/SimpleMPRWidget.cxx +++ b/lib/cpExtensions/QT/SimpleMPRWidget.cxx @@ -299,6 +299,27 @@ HideData( const std::string& name ) { } +// ------------------------------------------------------------------------- +void cpExtensions::QT::SimpleMPRWidget:: +SetWindowLevel( const double& w, const double& l ) +{ + this->m_MPRObjects->SetWindowLevel( w, l ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::QT::SimpleMPRWidget:: +GetWindow( ) const +{ + return( this->m_MPRObjects->GetWindow( ) ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::QT::SimpleMPRWidget:: +GetLevel( ) const +{ + return( this->m_MPRObjects->GetLevel( ) ); +} + // ------------------------------------------------------------------------- vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: GetInteractor( unsigned int i ) diff --git a/lib/cpExtensions/QT/SimpleMPRWidget.h b/lib/cpExtensions/QT/SimpleMPRWidget.h index c4d5ec5..ba2b79b 100644 --- a/lib/cpExtensions/QT/SimpleMPRWidget.h +++ b/lib/cpExtensions/QT/SimpleMPRWidget.h @@ -82,6 +82,9 @@ namespace cpExtensions ); void ShowData( const std::string& name ); void HideData( const std::string& name ); + void SetWindowLevel( const double& w, const double& l ); + double GetWindow( ) const; + double GetLevel( ) const; vtkRenderWindowInteractor* GetInteractor( unsigned int i ); diff --git a/lib/cpPlugins/BaseQtMainWindow.cxx b/lib/cpPlugins/BaseQtMainWindow.cxx new file mode 100644 index 0000000..24953f0 --- /dev/null +++ b/lib/cpPlugins/BaseQtMainWindow.cxx @@ -0,0 +1,336 @@ +#include + +#ifdef cpPlugins_QT4 + +#include +#include +#include +#include +#include +#include +#include +#include + +// ------------------------------------------------------------------------- +bool cpPlugins::BaseQtMainWindow::_TBlocker:: +eventFilter( QObject* obj, QEvent* event ) +{ + return( true ); // -> Block all events + /* NOTE: correct implementation: + switch( event->type( ) ) + { + //list event you want to prevent here ... + case QEvent::KeyPress: + case QEvent::KeyRelease: + case QEvent::MouseButtonRelease: + case QEvent::MouseButtonPress: + case QEvent::MouseButtonDblClick: + //... + return( true ); + } // hctiws + return( this->QObject::eventFilter( obj, event ) ); + */ +} + +// ------------------------------------------------------------------------- +cpPlugins::BaseQtMainWindow:: +BaseQtMainWindow( + int argc, char* argv[], + QApplication* app, + QWidget* parent + ) + : Superclass( parent ), + m_Application( app ), + m_PluginsPath( "." ), + m_TreeWidget( NULL ), + m_Editor( NULL ) +{ + // Prepare plugins interface + QFileInfo info( argv[ 0 ] ); + if( info.exists( ) ) + { + this->m_Interface.LoadConfiguration( cpPlugins_CONFIG_FILE ); + this->_LoadPluginsFromPath( this->m_PluginsPath ); + this->m_PluginsPath = info.canonicalPath( ).toStdString( ); + + } // fi + QDir exec_dir( "." ); + if( exec_dir.exists( ) ) + { + this->_LoadPluginsFromPath( exec_dir.canonicalPath( ).toStdString( ) ); + this->m_PluginsPath = exec_dir.canonicalPath( ).toStdString( ); + + } // fi + + // Prepare workspace + this->m_Workspace.SetInterface( &( this->m_Interface ) ); +} + +// ------------------------------------------------------------------------- +cpPlugins::BaseQtMainWindow:: +~BaseQtMainWindow( ) +{ + this->m_Interface.UnloadAll( ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::BaseQtMainWindow:: +_Configure( + QTreeWidget* tree, + cpExtensions::QT::SimpleMPRWidget* mpr, + cpPipelineEditor::Editor* editor + ) +{ + this->m_TreeWidget = tree; + if( this->m_TreeWidget != NULL ) + this->_UpdateLoadedPlugins( ); + this->m_Editor = editor; + if( this->m_Editor != NULL ) + this->m_Editor->setWorkspace( &( this->m_Workspace ) ); + if( mpr != NULL ) + this->m_Workspace.SetMPRViewer( mpr ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::BaseQtMainWindow:: +_LoadPlugins( const std::string& filename ) +{ + try + { + this->m_Interface.LoadPluginFile( filename ); + this->_UpdateLoadedPlugins( ); + } + catch( std::exception& err ) + { + QMessageBox::critical( + this, + "Error loading plugins path", + err.what( ) + ); + + } // yrt +} + +// ------------------------------------------------------------------------- +void cpPlugins::BaseQtMainWindow:: +_LoadPluginsFromPath( const std::string& path ) +{ + try + { + this->m_Interface.LoadPluginDir( path ); + this->_UpdateLoadedPlugins( ); + } + catch( std::exception& err ) + { + QMessageBox::critical( + this, + "Error loading plugins path", + err.what( ) + ); + + } // yrt +} + +// ------------------------------------------------------------------------- +void cpPlugins::BaseQtMainWindow:: +_UpdateLoadedPlugins( ) +{ + this->_Block( ); + auto filters = this->m_Interface.GetFilters( ); + if( filters.size( ) == 0 ) + { + this->_UnBlock( ); + QMessageBox::critical( + this, + "Error loading default plugins", + "No plugins loaded: remember to load some!!!" + ); + return; + + } // fi + + if( this->m_TreeWidget != NULL ) + { + for( auto cIt = filters.begin( ); cIt != filters.end( ); ++cIt ) + { + // Create or get category + QList< QTreeWidgetItem* > cat_items = + this->m_TreeWidget->findItems( + cIt->first.c_str( ), Qt::MatchExactly | Qt::MatchRecursive + ); + QTreeWidgetItem* cat = NULL; + if( cat_items.size( ) == 0 ) + { + cat = new QTreeWidgetItem( + ( QTreeWidgetItem* )( NULL ), QStringList( cIt->first.c_str( ) ) + ); + this->m_TreeWidget->addTopLevelItem( cat ); + } + else + cat = cat_items[ 0 ]; + + // Create filters + auto fIt = cIt->second.begin( ); + for( ; fIt != cIt->second.end( ); ++fIt ) + { + QList< QTreeWidgetItem* > filter_items = + this->m_TreeWidget->findItems( + fIt->c_str( ), Qt::MatchExactly | Qt::MatchRecursive + ); + auto fiIt = filter_items.begin( ); + auto found_fiIt = filter_items.end( ); + for( ; fiIt != filter_items.end( ); ++fiIt ) + if( ( *fiIt )->parent( ) == cat ) + found_fiIt = fiIt; + + // Add filter + if( found_fiIt == filter_items.end( ) ) + QTreeWidgetItem* filter = new QTreeWidgetItem( + cat, QStringList( fIt->c_str( ) ) + ); + + } // rof + + } // rof + + } // fi + this->_UnBlock( ); + this->m_Interface.SaveConfiguration( cpPlugins_CONFIG_FILE ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::BaseQtMainWindow:: +_Block( ) +{ + this->m_Application->setOverrideCursor( Qt::WaitCursor ); + this->m_Application->installEventFilter( &( this->m_Blocker ) ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::BaseQtMainWindow:: +_UnBlock( ) +{ + while( this->m_Application->overrideCursor( ) ) + this->m_Application->restoreOverrideCursor( ); + this->m_Application->removeEventFilter( &( this->m_Blocker ) ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::BaseQtMainWindow:: +_LoadWorkspace( const std::string& filename ) +{ + std::string err = this->m_Workspace.LoadWorkspace( filename ); + if( err != "" ) + { + QMessageBox::critical( + this, + QMessageBox::tr( "Error loading workspace" ), + QMessageBox::tr( err.c_str( ) ) + ); + } + else + { + if( this->m_Editor != NULL ) + this->m_Editor->setWorkspace( &( this->m_Workspace ) ); + + } // fi +} + +// ------------------------------------------------------------------------- +void cpPlugins::BaseQtMainWindow:: +_SaveWorkspace( const std::string& filename ) +{ + std::string err = this->m_Workspace.SaveWorkspace( filename ); + if( err != "" ) + QMessageBox::critical( + this, + QMessageBox::tr( "Error saving workspace" ), + QMessageBox::tr( err.c_str( ) ) + ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::BaseQtMainWindow:: +_InteractiveLoadPlugins( ) +{ + QFileDialog dlg( this ); + dlg.setFileMode( QFileDialog::ExistingFiles ); + dlg.setDirectory( this->m_PluginsPath.c_str( ) ); + + std::stringstream name_filter; + std::string suffix = std::string( cpPlugins_PLUGIN_EXT ); + name_filter + << "Plugins file (*." << cpPlugins_PLUGIN_EXT << ");;All files (*)"; + dlg.setNameFilter( name_filter.str( ).c_str( ) ); + dlg.setDefaultSuffix( suffix.c_str( ) ); + if( !( dlg.exec( ) ) ) + return; + + QStringList names = dlg.selectedFiles( ); + for( auto qIt = names.begin( ); qIt != names.end( ); ++qIt ) + this->_LoadPlugins( qIt->toStdString( ) ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::BaseQtMainWindow:: +_InteractiveLoadPluginsFromPath( ) +{ + QFileDialog dlg( this ); + dlg.setFileMode( QFileDialog::DirectoryOnly ); + dlg.setDirectory( this->m_PluginsPath.c_str( ) ); + if( !( dlg.exec( ) ) ) + return; + this->_LoadPluginsFromPath( dlg.selectedFiles( ).begin( )->toStdString( ) ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::BaseQtMainWindow:: +_InteractiveLoadWorkspace( ) +{ + QFileDialog dlg( this ); + dlg.setFileMode( QFileDialog::ExistingFile ); + dlg.setDirectory( "." ); + dlg.setNameFilter( + QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" ) + ); + dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) ); + if( !( dlg.exec( ) ) ) + return; + this->_LoadWorkspace( dlg.selectedFiles( ).begin( )->toStdString( ) ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::BaseQtMainWindow:: +_InteractiveSaveWorkspace( ) +{ + QFileDialog dlg( this ); + dlg.setFileMode( QFileDialog::AnyFile ); + dlg.setDirectory( "." ); + dlg.setAcceptMode( QFileDialog::AcceptSave ); + dlg.setNameFilter( + QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" ) + ); + dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) ); + if( !( dlg.exec( ) ) ) + return; + this->_SaveWorkspace( dlg.selectedFiles( ).begin( )->toStdString( ) ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::BaseQtMainWindow:: +_ExecFilter( const std::string& filter_name ) +{ + this->_Block( ); + std::string err = this->m_Workspace.Execute( filter_name ); + this->_UnBlock( ); + if( err != "" ) + QMessageBox::critical( + this, + QMessageBox::tr( "Error executing filter" ), + QMessageBox::tr( err.c_str( ) ) + ); +} + +#endif // cpPlugins_QT4 + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/BaseQtMainWindow.h b/lib/cpPlugins/BaseQtMainWindow.h new file mode 100644 index 0000000..430de43 --- /dev/null +++ b/lib/cpPlugins/BaseQtMainWindow.h @@ -0,0 +1,95 @@ +#ifndef __CPPLUGINS__BASEQTMAINWINDOW__H__ +#define __CPPLUGINS__BASEQTMAINWINDOW__H__ + +#include + +#ifdef cpPlugins_QT4 + +#include +#include +#include + +namespace cpExtensions +{ + namespace QT + { + class SimpleMPRWidget; + } +} +namespace cpPipelineEditor +{ + class Editor; +} +class QTreeWidget; + +namespace cpPlugins +{ + /** + */ + class cpPlugins_EXPORT BaseQtMainWindow + : public QMainWindow + { + Q_OBJECT; + + public: + typedef BaseQtMainWindow Self; + typedef QMainWindow Superclass; + + protected: + /** + */ + class _TBlocker + : public QObject + { + protected: + virtual bool eventFilter( QObject* obj, QEvent* event ) ITK_OVERRIDE; + }; + + public: + explicit BaseQtMainWindow( + int argc, char* argv[], + QApplication* app, + QWidget* parent = NULL + ); + virtual ~BaseQtMainWindow( ); + + protected: + void _Configure( + QTreeWidget* tree, + cpExtensions::QT::SimpleMPRWidget* mpr, + cpPipelineEditor::Editor* editor + ); + void _LoadPlugins( const std::string& filename ); + void _LoadPluginsFromPath( const std::string& path ); + void _UpdateLoadedPlugins( ); + void _Block( ); + void _UnBlock( ); + + void _LoadWorkspace( const std::string& filename ); + void _SaveWorkspace( const std::string& filename ); + + protected slots: + void _InteractiveLoadPlugins( ); + void _InteractiveLoadPluginsFromPath( ); + void _InteractiveLoadWorkspace( ); + void _InteractiveSaveWorkspace( ); + void _ExecFilter( const std::string& filter_name ); + + protected: + QApplication* m_Application; + _TBlocker m_Blocker; + Workspace m_Workspace; + Interface m_Interface; + std::string m_PluginsPath; + + QTreeWidget* m_TreeWidget; + cpPipelineEditor::Editor* m_Editor; + }; + +} // ecapseman + +#endif // cpPlugins_QT4 + +#endif // __CPPLUGINS__BASEQTMAINWINDOW__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/CMakeLists.txt b/lib/cpPlugins/CMakeLists.txt index 8cf91bd..b1d2741 100644 --- a/lib/cpPlugins/CMakeLists.txt +++ b/lib/cpPlugins/CMakeLists.txt @@ -32,10 +32,12 @@ IF(USE_QT4) ) SET( lib_QT_Headers + BaseQtMainWindow.h ParametersQtDialog.h ) SET( lib_QT_Sources + BaseQtMainWindow.cxx ParametersQtDialog.cxx ) SET( diff --git a/lib/cpPlugins/Image.hxx b/lib/cpPlugins/Image.hxx index 47778dd..6caf7f0 100644 --- a/lib/cpPlugins/Image.hxx +++ b/lib/cpPlugins/Image.hxx @@ -110,6 +110,9 @@ _ITK_2_VTK_2( itk::LightObject* o ) #define cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, PIXEL, D ) \ this->FUNC( dynamic_cast< itk::Image< PIXEL, D >* >( INPUT ) ) +#define cpPlugin_Image_Demangle_VectorPixel_Dim( FUNC, INPUT, VECTOR, PIXEL, D ) \ + this->FUNC( dynamic_cast< itk::Image< VECTOR< PIXEL, D >, D >* >( INPUT ) ) + #define cpPlugin_Image_Demangle_Pixel_AllScalars( r, FUNC, INPUT, D ) \ r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, char, D ); \ if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, short, D ); \ @@ -144,6 +147,10 @@ _ITK_2_VTK_2( itk::LightObject* o ) if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< unsigned int >, D ); \ if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< unsigned long >, D ) +#define cpPlugin_Image_Demangle_VectorPixel_AllFloats( r, FUNC, INPUT, VECTOR, D ) \ + r = cpPlugin_Image_Demangle_VectorPixel_Dim( FUNC, INPUT, VECTOR, float, D ); \ + if( r != "" ) r = cpPlugin_Image_Demangle_VectorPixel_Dim( FUNC, INPUT, VECTOR, double, D ) + #endif // __CPPLUGINS__IMAGE__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface.cxx b/lib/cpPlugins/Interface.cxx index 58e468d..1d88373 100644 --- a/lib/cpPlugins/Interface.cxx +++ b/lib/cpPlugins/Interface.cxx @@ -82,7 +82,9 @@ LoadPluginFile( const std::string& filename ) ); // Check if it was already loaded - if( this->m_DynLibraries.find( canonical_fn ) != this->m_DynLibraries.end( ) ) + if( + this->m_DynLibraries.find( canonical_fn ) != this->m_DynLibraries.end( ) + ) return; // Ok, try to load the library @@ -154,7 +156,11 @@ LoadPluginDir( const std::string& dirname ) { try { - this->LoadPluginFile( ent->d_name ); + this->LoadPluginFile( + dirname + + std::string( "/" ) + + ent->d_name + ); count++; } catch( ... ) diff --git a/lib/cpPlugins/Mesh.cxx b/lib/cpPlugins/Mesh.cxx index 76bde83..76ba6dd 100644 --- a/lib/cpPlugins/Mesh.cxx +++ b/lib/cpPlugins/Mesh.cxx @@ -1,7 +1,6 @@ #include #include -#include #include #include #include @@ -17,10 +16,6 @@ SetITK( itk::LightObject* o ) if( !r ) r = this->_ITK_2_VTK< itk::Mesh< double, 2 > >( o ); if( !r ) r = this->_ITK_2_VTK< itk::Mesh< float, 3 > >( o ); if( !r ) r = this->_ITK_2_VTK< itk::Mesh< double, 3 > >( o ); - if( !r ) r = this->_ITK_2_VTK< itk::QuadEdgeMesh< float, 2 > >( o ); - if( !r ) r = this->_ITK_2_VTK< itk::QuadEdgeMesh< double, 2 > >( o ); - if( !r ) r = this->_ITK_2_VTK< itk::QuadEdgeMesh< float, 3 > >( o ); - if( !r ) r = this->_ITK_2_VTK< itk::QuadEdgeMesh< double, 3 > >( o ); } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins_ITKInstances/Base.cxx b/lib/cpPlugins_ITKInstances/Base.cxx index 4d792de..ab20534 100644 --- a/lib/cpPlugins_ITKInstances/Base.cxx +++ b/lib/cpPlugins_ITKInstances/Base.cxx @@ -6,6 +6,11 @@ namespace itk { + cpPlugins_ITKInstances_Base_ostream( FixedArray, float, 2 ); + cpPlugins_ITKInstances_Base_ostream( FixedArray, double, 2 ); + cpPlugins_ITKInstances_Base_ostream( FixedArray, float, 3 ); + cpPlugins_ITKInstances_Base_ostream( FixedArray, double, 3 ); + cpPlugins_ITKInstances_Base_ostream( Point, float, 1 ); cpPlugins_ITKInstances_Base_ostream( Vector, float, 1 ); cpPlugins_ITKInstances_Base_ostream( Point, double, 1 ); diff --git a/lib/cpPlugins_ITKInstances/Base_explicit_description.txt b/lib/cpPlugins_ITKInstances/Base_explicit_description.txt index 7c156e5..38010d4 100644 --- a/lib/cpPlugins_ITKInstances/Base_explicit_description.txt +++ b/lib/cpPlugins_ITKInstances/Base_explicit_description.txt @@ -4,6 +4,7 @@ i map i string i vector i itkArray.h +i itkArray2D.h i itkConvertPixelBuffer.h i itkDefaultConvertPixelTraits.h i itkFixedArray.h @@ -11,17 +12,25 @@ i itkImportImageContainer.h i itkIndex.h i itkMatrix.h i itkPoint.h +i itkCovariantVector.h i itkVector.h i itkRGBPixel.h i itkRGBAPixel.h i itkSimpleDataObjectDecorator.h +i itkDataObjectDecorator.h +i itkAffineTransform.h +i itkTransform.h c itk::Array< #1 > c itk::FixedArray< #1 , #2 > c itk::FixedArray< float , 6 > c itk::Point< #5 , #2 > c itk::Vector< #5 , #2 > +c itk::CovariantVector< #5 , #2 > c itk::Matrix< #5 , #2 , #2 > c #7 < #1 > +c itk::Array2D < #5 > +c itk::Transform < #5 , #2 , #2 > +c itk::DataObjectDecorator< itk::Transform < #5 , #2 , #2 > > c itk::SimpleDataObjectDecorator< #1 > c itk::SimpleDataObjectDecorator< #3 > c itk::SimpleDataObjectDecorator< std::vector< itk::Index< #6 > > > @@ -33,6 +42,7 @@ c itk::ConvertPixelBuffer< #1 , #7 < #4 > , itk::DefaultConvertPixelTraits< #7 < c itk::ImportImageContainer< unsigned long , #1 > c itk::ImportImageContainer< unsigned long , std::complex< #5 > > c itk::ImportImageContainer< unsigned long , #7 < #1 > > +c itk::ImportImageContainer< unsigned long , #8 < #5 , #2 > > a #1 = #integers;#floats a #2 = #all_dims a #3 = bool;std::string @@ -40,3 +50,4 @@ a #4 = #integers;#floats a #5 = #floats a #6 = #all_visual_dims a #7 = itk::RGBPixel;itk::RGBAPixel +a #8 = itk::Vector;itk::CovariantVector diff --git a/lib/cpPlugins_ITKInstances/Image.cxx b/lib/cpPlugins_ITKInstances/Image.cxx index 9090add..4d9976f 100644 --- a/lib/cpPlugins_ITKInstances/Image.cxx +++ b/lib/cpPlugins_ITKInstances/Image.cxx @@ -1,4 +1,5 @@ #include +#include // ------------------------------------------------------------------------- #define cpPlugins_ITKInstances_Image_ImageRegion( D ) \ diff --git a/lib/cpPlugins_ITKInstances/ImageFilters_explicit_description.txt b/lib/cpPlugins_ITKInstances/ImageFilters_explicit_description.txt index 73d0c8e..88ed85c 100644 --- a/lib/cpPlugins_ITKInstances/ImageFilters_explicit_description.txt +++ b/lib/cpPlugins_ITKInstances/ImageFilters_explicit_description.txt @@ -7,7 +7,10 @@ c itk::ImageSource< itk::Image< #1 , #2 > > c itk::ImageSource< itk::Image< std::complex< #3 > , #2 > > c itk::ImageSource< itk::Image< #5 < #1 > , #2 > > c itk::ImageToImageFilter< itk::Image< #1 , #2 > , itk::Image< #4 , #2 > > +c itk::ImageToImageFilter< itk::Image< #1 , 2 > , itk::Image< #1 , 3 > > +c itk::ImageToImageFilter< itk::Image< #1 , 3 > , itk::Image< #1 , 2 > > c itk::InPlaceImageFilter< itk::Image< #1 , #2 > , itk::Image< #4 , #2 > > +c itk::InPlaceImageFilter< itk::Image< #1 , 3 > , itk::Image< #1 , 2 > > c itk::ImageTransformer< itk::Image< #1 , #2 > > a #1 = #integers;#floats a #2 = #all_dims diff --git a/lib/cpPlugins_ITKInstances/Image_explicit_description.txt b/lib/cpPlugins_ITKInstances/Image_explicit_description.txt index 7b1708d..8811f6e 100644 --- a/lib/cpPlugins_ITKInstances/Image_explicit_description.txt +++ b/lib/cpPlugins_ITKInstances/Image_explicit_description.txt @@ -13,6 +13,7 @@ c itk::ImageRegion< #2 > c itk::Image< #1 , #2 > c itk::Image< std::complex< #4 > , #2 > c itk::Image< #6 < #1 > , #2 > +c itk::Image< #7 < #4 , #2 > , #2 > c itk::ImageToVTKImageFilter< itk::Image< #1 , #3 > > c itk::ImageToVTKImageFilter< itk::Image< #6 < #1 > , #3 > > a #1 = #integers;#floats @@ -21,3 +22,4 @@ a #3 = #all_visual_dims a #4 = #floats a #5 = #integers_ptr;#floats_ptr a #6 = itk::RGBPixel;itk::RGBAPixel +a #7 = itk::Vector;itk::CovariantVector diff --git a/lib/cpPlugins_ITKInstances/Mesh_explicit_description.txt b/lib/cpPlugins_ITKInstances/Mesh_explicit_description.txt index 7cec3ab..91077f6 100644 --- a/lib/cpPlugins_ITKInstances/Mesh_explicit_description.txt +++ b/lib/cpPlugins_ITKInstances/Mesh_explicit_description.txt @@ -2,12 +2,10 @@ f cpPlugins_ITKInstances/Base.h i itkBoundingBox.h i itkPointSet.h i itkMesh.h -i itkQuadEdgeMesh.h i itkLineCell.h i itkPolygonCell.h i itkTriangleCell.h c itk::VectorContainer< unsigned long, itk::Point< #1 , #2 > > -c itk::MapContainer< unsigned long , itk::QuadEdgeMeshPoint< #1 , #2 , itk::GeometricalQuadEdge< unsigned long, unsigned long, bool, bool, true > > > c itk::BoundingBox< unsigned long , #2 , float, itk::VectorContainer< unsigned long , itk::Point< float , #2 > > > c itk::PointSet< #1 , #2 > c #4 < #1 , #2 > @@ -15,4 +13,4 @@ c #3 < itk::CellInterface< #1 , itk::CellTraitsInfo< #2 , float , float , unsign a #1 = #floats a #2 = #all_visual_dims a #3 = itk::LineCell;itk::PolygonCell;itk::TriangleCell -a #4 = itk::Mesh;itk::QuadEdgeMesh +a #4 = itk::Mesh diff --git a/plugins/cpPluginsIO/CMakeLists.txt b/plugins/cpPluginsIO/CMakeLists.txt index 1a8c84d..1ee81a9 100644 --- a/plugins/cpPluginsIO/CMakeLists.txt +++ b/plugins/cpPluginsIO/CMakeLists.txt @@ -57,7 +57,7 @@ GENERATE_EXPORT_HEADER( EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/plugins/${lib_DIR}/${lib_NAME}_Export.h STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC ) -TARGET_LINK_LIBRARIES(${lib_NAME} ${target_LIBRARIES}) +TARGET_LINK_LIBRARIES(${lib_NAME} cpPipelineEditor ${target_LIBRARIES}) ## ======================== ## -- Installation rules -- diff --git a/plugins/cpPluginsImageFilters/CMakeLists.txt b/plugins/cpPluginsImageFilters/CMakeLists.txt index 94af7c5..262bca9 100644 --- a/plugins/cpPluginsImageFilters/CMakeLists.txt +++ b/plugins/cpPluginsImageFilters/CMakeLists.txt @@ -58,7 +58,7 @@ GENERATE_EXPORT_HEADER( EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/plugins/${lib_DIR}/${lib_NAME}_Export.h STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC ) -TARGET_LINK_LIBRARIES(${lib_NAME} ${target_LIBRARIES}) +TARGET_LINK_LIBRARIES(${lib_NAME} cpPipelineEditor ${target_LIBRARIES}) ## ======================== ## -- Installation rules -- diff --git a/plugins/cpPluginsImageFilters/ExtractImageFilter.cxx b/plugins/cpPluginsImageFilters/ExtractImageFilter.cxx new file mode 100644 index 0000000..ac2b1cd --- /dev/null +++ b/plugins/cpPluginsImageFilters/ExtractImageFilter.cxx @@ -0,0 +1,79 @@ +#include +#include +#include + +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::ExtractImageFilter:: +ExtractImageFilter( ) + : Superclass( ) +{ + this->_AddInput( "Input" ); + this->_AddOutput< cpPlugins::Image >( "Output" ); + this->m_Parameters.ConfigureAsBool( "ReduceDimension" ); + this->m_Parameters.SetBool( "ReduceDimension", false ); + + /* TODO + std::vector< std::string > choices; + choices.push_back( "float" ); + choices.push_back( "double" ); + this->m_Parameters.ConfigureAsChoices( "ScalarType", choices ); + this->m_Parameters.SetSelectedChoice( "ScalarType", "float" ); + this->m_Parameters.ConfigureAsReal( "UpperThresholdValue" ); + this->m_Parameters.ConfigureAsUint( "InsideValue" ); + this->m_Parameters.ConfigureAsUint( "OutsideValue" ); + + this->m_Parameters.SetReal( "LowerThresholdValue", 0 ); + this->m_Parameters.SetReal( "UpperThresholdValue", 10000 ); + this->m_Parameters.SetReal( "InsideValue", 1 ); + this->m_Parameters.SetReal( "OutsideValue", 0 ); + */ +} + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::ExtractImageFilter:: +~ExtractImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +std::string cpPluginsImageFilters::ExtractImageFilter:: +_GenerateData( ) +{ + auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( ); + std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 ); + return( r ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +std::string cpPluginsImageFilters::ExtractImageFilter:: +_GD0( _TImage* image ) +{ + typedef + itk::Image< typename _TImage::PixelType, _TImage::ImageDimension - 1 > + _TOutImage; + typedef itk::ExtractImageFilter< _TImage, _TOutImage > _TFilter; + + if( image == NULL ) + return( + "ImageFilters::ExtractImageFilter: No valid input image." + ); + + + // Configure filter + typename _TImage::RegionType reg; + + _TFilter* filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( image ); + filter->SetExtractionRegion( reg ); + + // Connect output + this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); + return( "" ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/ExtractImageFilter.h b/plugins/cpPluginsImageFilters/ExtractImageFilter.h new file mode 100644 index 0000000..01ad545 --- /dev/null +++ b/plugins/cpPluginsImageFilters/ExtractImageFilter.h @@ -0,0 +1,44 @@ +#ifndef __CPPLUGINSIMAGEFILTERS__EXTRACTIMAGEFILTER__H__ +#define __CPPLUGINSIMAGEFILTERS__EXTRACTIMAGEFILTER__H__ + +#include +#include + +namespace cpPluginsImageFilters +{ + /** + */ + class cpPluginsImageFilters_EXPORT ExtractImageFilter + : public cpPlugins::ProcessObject + { + public: + typedef ExtractImageFilter Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( ExtractImageFilter, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( ExtractImageFilter, ImageFilters ); + + protected: + ExtractImageFilter( ); + virtual ~ExtractImageFilter( ); + + virtual std::string _GenerateData( ); + + template< class _TImage > + inline std::string _GD0( _TImage* image ); + + private: + // Purposely not implemented + ExtractImageFilter( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSIMAGEFILTERS__EXTRACTIMAGEFILTER__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/IsoImageSlicer.cxx b/plugins/cpPluginsImageFilters/IsoImageSlicer.cxx new file mode 100644 index 0000000..942a6e4 --- /dev/null +++ b/plugins/cpPluginsImageFilters/IsoImageSlicer.cxx @@ -0,0 +1,116 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +/* + #include + #include + #include +*/ + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::IsoImageSlicer:: +IsoImageSlicer( ) + : Superclass( ) +{ + this->_AddInput( "Input" ); + this->_AddOutput< cpPlugins::Image >( "Output" ); + + std::vector< std::string > choices; + choices.push_back( "float" ); + choices.push_back( "double" ); + this->m_Parameters.ConfigureAsChoices( "ScalarType", choices ); + this->m_Parameters.SetSelectedChoice( "ScalarType", "float" ); + /* TODO + this->m_Parameters.ConfigureAsReal( "LowerThresholdValue" ); + this->m_Parameters.ConfigureAsReal( "UpperThresholdValue" ); + this->m_Parameters.ConfigureAsUint( "InsideValue" ); + this->m_Parameters.ConfigureAsUint( "OutsideValue" ); + + this->m_Parameters.SetReal( "LowerThresholdValue", 0 ); + this->m_Parameters.SetReal( "UpperThresholdValue", 10000 ); + this->m_Parameters.SetReal( "InsideValue", 1 ); + this->m_Parameters.SetReal( "OutsideValue", 0 ); + */ +} + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::IsoImageSlicer:: +~IsoImageSlicer( ) +{ +} + +// ------------------------------------------------------------------------- +std::string cpPluginsImageFilters::IsoImageSlicer:: +_GenerateData( ) +{ + auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( ); + std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 ); + return( r ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +std::string cpPluginsImageFilters::IsoImageSlicer:: +_GD0( _TImage* image ) +{ + if( image != NULL ) + { + auto choice = this->m_Parameters.GetSelectedChoice( "OutputResolution" ); + if( choice == "float" ) + return( this->_GD1< _TImage, float >( image ) ); + else if( choice == "double" ) + return( this->_GD1< _TImage, double >( image ) ); + else return( "IsoImageSlicer: no valid scalar type." ); + } + else + return( + "ImageFilters::IsoImageSlicer: No valid input image." + ); +} + +// ------------------------------------------------------------------------- +template< class _TImage, class _TScalar > +std::string cpPluginsImageFilters::IsoImageSlicer:: +_GD1( _TImage* image ) +{ + typedef + cpExtensions::Algorithms::IsoImageSlicer< _TImage, _TScalar > + _TFilter; + typedef typename _TFilter::TVector _TVector; + typedef typename _TFilter::TMatrix _TMatrix; + + // Configure filter + _TFilter* filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( image ); + filter->SetInterpolator( NULL ); + filter->SetTranslation( _TVector( ) ); + filter->SetRotation( _TMatrix( ) ); + filter->SetSize( 1 ); + /* TODO + filter->SetLowerThreshold( lower_val ); + filter->SetUpperThreshold( upper_val ); + filter->SetInsideValue( in_val ); + filter->SetOutsideValue( out_val ); + filter->Update( ); + */ + + // Connect output + this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); + return( "" ); +} + +#include +#include + +template class cpPluginsImageFilters_EXPORT cpExtensions::Algorithms::BezierCurveFunction< itk::Vector< float, 3 > >; +template class cpPluginsImageFilters_EXPORT cpExtensions::Algorithms::BezierCurveFunction< itk::Vector< double, 3 > >; + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/IsoImageSlicer.h b/plugins/cpPluginsImageFilters/IsoImageSlicer.h new file mode 100644 index 0000000..96868e8 --- /dev/null +++ b/plugins/cpPluginsImageFilters/IsoImageSlicer.h @@ -0,0 +1,47 @@ +#ifndef __CPPLUGINSIMAGEFILTERS__ISOIMAGESLICER__H__ +#define __CPPLUGINSIMAGEFILTERS__ISOIMAGESLICER__H__ + +#include +#include + +namespace cpPluginsImageFilters +{ + /** + */ + class cpPluginsImageFilters_EXPORT IsoImageSlicer + : public cpPlugins::ProcessObject + { + public: + typedef IsoImageSlicer Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( IsoImageSlicer, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( IsoImageSlicer, ImageFilters ); + + protected: + IsoImageSlicer( ); + virtual ~IsoImageSlicer( ); + + virtual std::string _GenerateData( ); + + template< class _TImage > + inline std::string _GD0( _TImage* image ); + + template< class _TImage, class _TScalar > + inline std::string _GD1( _TImage* image ); + + private: + // Purposely not implemented + IsoImageSlicer( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSIMAGEFILTERS__ISOIMAGESLICER__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/JoinSeriesImageFilter.cxx b/plugins/cpPluginsImageFilters/JoinSeriesImageFilter.cxx new file mode 100644 index 0000000..9b58be4 --- /dev/null +++ b/plugins/cpPluginsImageFilters/JoinSeriesImageFilter.cxx @@ -0,0 +1,64 @@ +#include +#include +#include + +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::JoinSeriesImageFilter:: +JoinSeriesImageFilter( ) + : Superclass( ) +{ + this->_AddInput( "Input" ); + this->_AddOutput< cpPlugins::Image >( "Output" ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::JoinSeriesImageFilter:: +~JoinSeriesImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +std::string cpPluginsImageFilters::JoinSeriesImageFilter:: +_GenerateData( ) +{ + auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( ); + std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 ); + return( r ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +std::string cpPluginsImageFilters::JoinSeriesImageFilter:: +_GD0( _TImage* image ) +{ + typedef + itk::Image< typename _TImage::PixelType, _TImage::ImageDimension + 1 > + _TOutImage; + typedef itk::JoinSeriesImageFilter< _TImage, _TOutImage > _TFilter; + + if( image == NULL ) + return( + "ImageFilters::JoinSeriesImageFilter: No valid input image." + ); + + // Configure filter + _TFilter* filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( image ); + /* TODO + filter->SetLowerThreshold( lower_val ); + filter->SetUpperThreshold( upper_val ); + filter->SetInsideValue( in_val ); + filter->SetOutsideValue( out_val ); + filter->Update( ); + */ + + // Connect output + this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); + return( "" ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/JoinSeriesImageFilter.h b/plugins/cpPluginsImageFilters/JoinSeriesImageFilter.h new file mode 100644 index 0000000..02d1d49 --- /dev/null +++ b/plugins/cpPluginsImageFilters/JoinSeriesImageFilter.h @@ -0,0 +1,47 @@ +#ifndef __CPPLUGINSIMAGEFILTERS__JOINSERIESIMAGEFILTER__H__ +#define __CPPLUGINSIMAGEFILTERS__JOINSERIESIMAGEFILTER__H__ + +#include +#include + +namespace cpPluginsImageFilters +{ + /** + */ + class cpPluginsImageFilters_EXPORT JoinSeriesImageFilter + : public cpPlugins::ProcessObject + { + public: + typedef JoinSeriesImageFilter Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( JoinSeriesImageFilter, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( JoinSeriesImageFilter, ImageFilters ); + + protected: + JoinSeriesImageFilter( ); + virtual ~JoinSeriesImageFilter( ); + + virtual std::string _GenerateData( ); + + template< class _TImage > + inline std::string _GD0( _TImage* image ); + + template< class _TImage, class _TScalar > + inline std::string _GD1( _TImage* image ); + + private: + // Purposely not implemented + JoinSeriesImageFilter( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSIMAGEFILTERS__JOINSERIESIMAGEFILTER__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.cxx b/plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.cxx new file mode 100644 index 0000000..07e5956 --- /dev/null +++ b/plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.cxx @@ -0,0 +1,107 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::MultiScaleGaussianImageFilter:: +MultiScaleGaussianImageFilter( ) + : Superclass( ) +{ + this->_AddInput( "Input" ); + this->_AddOutput< cpPlugins::Image >( "Output" ); + + this->m_Parameters.ConfigureAsRealList( "Sigmas" ); + + std::vector< std::string > choices; + choices.push_back( "float" ); + choices.push_back( "double" ); + this->m_Parameters.ConfigureAsChoices( "ScalarType", choices ); + this->m_Parameters.SetSelectedChoice( "ScalarType", "float" ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::MultiScaleGaussianImageFilter:: +~MultiScaleGaussianImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +std::string cpPluginsImageFilters::MultiScaleGaussianImageFilter:: +_GenerateData( ) +{ + auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( ); + std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 ); + if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 ); + return( r ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +std::string cpPluginsImageFilters::MultiScaleGaussianImageFilter:: +_GD0( _TImage* image ) +{ + if( image != NULL ) + { + auto choice = this->m_Parameters.GetSelectedChoice( "ScalarType" ); + if( choice == "float" ) + return( this->_GD1< _TImage, float >( image ) ); + else if( choice == "double" ) + return( this->_GD1< _TImage, double >( image ) ); + else return( "MultiScaleGaussianImageFilter: no valid scalar type." ); + } + else + return( + "MultiScaleGaussianImageFilter: No valid input image." + ); +} + +// ------------------------------------------------------------------------- +template< class _TImage, class _TScalar > +std::string cpPluginsImageFilters::MultiScaleGaussianImageFilter:: +_GD1( _TImage* image ) +{ + typedef itk::CovariantVector< _TScalar, _TImage::ImageDimension > _TVector; + typedef itk::Image< _TVector, _TImage::ImageDimension > _TGradient; + typedef + cpExtensions::Algorithms::MultiScaleGaussianImageFilter< _TImage, _TGradient > + _TFilter; + + auto sigmas = this->m_Parameters.GetRealList( "Sigmas" ); + if( sigmas.size( ) == 0 ) + return( + "MultiScaleGaussianImageFilter: No given sigmas." + ); + + // Configure filter + _TFilter* filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( image ); + for( auto sIt = sigmas.begin( ); sIt != sigmas.end( ); ++sIt ) + filter->AddScale( *sIt ); + filter->Update( ); + + // Connect output + this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); + return( "" ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.h b/plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.h new file mode 100644 index 0000000..252c701 --- /dev/null +++ b/plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.h @@ -0,0 +1,47 @@ +#ifndef __CPPLUGINSIMAGEFILTERS__MULTISCALEGAUSSIANIMAGEFILTER__H__ +#define __CPPLUGINSIMAGEFILTERS__MULTISCALEGAUSSIANIMAGEFILTER__H__ + +#include +#include + +namespace cpPluginsImageFilters +{ + /** + */ + class cpPluginsImageFilters_EXPORT MultiScaleGaussianImageFilter + : public cpPlugins::ProcessObject + { + public: + typedef MultiScaleGaussianImageFilter Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( MultiScaleGaussianImageFilter, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( MultiScaleGaussianImageFilter, ImageFilters ); + + protected: + MultiScaleGaussianImageFilter( ); + virtual ~MultiScaleGaussianImageFilter( ); + + virtual std::string _GenerateData( ); + + template< class _TImage > + inline std::string _GD0( _TImage* image ); + + template< class _TImage, class _TScalar > + inline std::string _GD1( _TImage* image ); + + private: + // Purposely not implemented + MultiScaleGaussianImageFilter( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSIMAGEFILTERS__MULTISCALEGAUSSIANIMAGEFILTER__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/ResampleImageFilter.cxx b/plugins/cpPluginsImageFilters/ResampleImageFilter.cxx new file mode 100644 index 0000000..8c23956 --- /dev/null +++ b/plugins/cpPluginsImageFilters/ResampleImageFilter.cxx @@ -0,0 +1,87 @@ +#include +#include +#include + +#include +#include +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::ResampleImageFilter:: +ResampleImageFilter( ) + : Superclass( ) +{ + this->_AddInput( "Input" ); + this->_AddOutput< cpPlugins::Image >( "Output" ); + std::vector< std::string > choices; + choices.push_back( "float" ); + choices.push_back( "double" ); + this->m_Parameters.ConfigureAsChoices( "ScalarType", choices ); + this->m_Parameters.SetSelectedChoice( "ScalarType", "float" ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageFilters::ResampleImageFilter:: +~ResampleImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +std::string cpPluginsImageFilters::ResampleImageFilter:: +_GenerateData( ) +{ + auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( ); + std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 1 ); + if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 ); + if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 ); + if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 4 ); + return( r ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +std::string cpPluginsImageFilters::ResampleImageFilter:: +_GD0( _TImage* image ) +{ + if( image != NULL ) + { + auto choice = this->m_Parameters.GetSelectedChoice( "OutputResolution" ); + if( choice == "float" ) + return( this->_GD1< _TImage, float >( image ) ); + else if( choice == "double" ) + return( this->_GD1< _TImage, double >( image ) ); + else return( "ResampleImageFilter: no valid scalar type." ); + } + else + return( + "ResampleImageFilter: No valid input image." + ); +} + +// ------------------------------------------------------------------------- +template< class _TImage, class _TScalar > +std::string cpPluginsImageFilters::ResampleImageFilter:: +_GD1( _TImage* image ) +{ + typedef + itk::ResampleImageFilter< _TImage, _TImage, _TScalar, _TScalar > + _TFilter; + + if( image == NULL ) + return( + "ImageFilters::ResampleImageFilter: No valid input image." + ); + + + // Configure filter + _TFilter* filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( image ); + + // Connect output + this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); + return( "" ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/ResampleImageFilter.h b/plugins/cpPluginsImageFilters/ResampleImageFilter.h new file mode 100644 index 0000000..0d22ee3 --- /dev/null +++ b/plugins/cpPluginsImageFilters/ResampleImageFilter.h @@ -0,0 +1,47 @@ +#ifndef __CPPLUGINSIMAGEFILTERS__RESAMPLEIMAGEFILTER__H__ +#define __CPPLUGINSIMAGEFILTERS__RESAMPLEIMAGEFILTER__H__ + +#include +#include + +namespace cpPluginsImageFilters +{ + /** + */ + class cpPluginsImageFilters_EXPORT ResampleImageFilter + : public cpPlugins::ProcessObject + { + public: + typedef ResampleImageFilter Self; + typedef cpPlugins::ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( ResampleImageFilter, cpPlugins::ProcessObject ); + cpPlugins_Id_Macro( ResampleImageFilter, ImageFilters ); + + protected: + ResampleImageFilter( ); + virtual ~ResampleImageFilter( ); + + virtual std::string _GenerateData( ); + + template< class _TImage > + inline std::string _GD0( _TImage* image ); + + template< class _TImage, class _TScalar > + inline std::string _GD1( _TImage* image ); + + private: + // Purposely not implemented + ResampleImageFilter( const Self& ); + Self& operator=( const Self& ); + }; + +} // ecapseman + +#endif // __CPPLUGINSIMAGEFILTERS__RESAMPLEIMAGEFILTER__H__ + +// eof - $RCSfile$ diff --git a/plugins/cpPluginsImageMeshFilters/CMakeLists.txt b/plugins/cpPluginsImageMeshFilters/CMakeLists.txt index bda2804..4f3c562 100644 --- a/plugins/cpPluginsImageMeshFilters/CMakeLists.txt +++ b/plugins/cpPluginsImageMeshFilters/CMakeLists.txt @@ -58,7 +58,7 @@ GENERATE_EXPORT_HEADER( EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/plugins/${lib_DIR}/${lib_NAME}_Export.h STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC ) -TARGET_LINK_LIBRARIES(${lib_NAME} ${target_LIBRARIES}) +TARGET_LINK_LIBRARIES(${lib_NAME} cpPipelineEditor ${target_LIBRARIES}) ## ======================== ## -- Installation rules -- diff --git a/plugins/cpPluginsMeshFilters/CMakeLists.txt b/plugins/cpPluginsMeshFilters/CMakeLists.txt index 25b63c6..f707ff9 100644 --- a/plugins/cpPluginsMeshFilters/CMakeLists.txt +++ b/plugins/cpPluginsMeshFilters/CMakeLists.txt @@ -58,7 +58,7 @@ GENERATE_EXPORT_HEADER( EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/plugins/${lib_DIR}/${lib_NAME}_Export.h STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC ) -TARGET_LINK_LIBRARIES(${lib_NAME} ${target_LIBRARIES}) +TARGET_LINK_LIBRARIES(${lib_NAME} cpPipelineEditor ${target_LIBRARIES}) ## ======================== ## -- Installation rules -- diff --git a/plugins/cpPluginsVisualization/CMakeLists.txt b/plugins/cpPluginsVisualization/CMakeLists.txt index 14ab446..c74f314 100644 --- a/plugins/cpPluginsVisualization/CMakeLists.txt +++ b/plugins/cpPluginsVisualization/CMakeLists.txt @@ -58,7 +58,7 @@ GENERATE_EXPORT_HEADER( EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/plugins/${lib_DIR}/${lib_NAME}_Export.h STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC ) -TARGET_LINK_LIBRARIES(${lib_NAME} ${target_LIBRARIES}) +TARGET_LINK_LIBRARIES(${lib_NAME} cpPipelineEditor ${target_LIBRARIES}) ## ======================== ## -- Installation rules -- diff --git a/plugins/cpPluginsWidgets/CMakeLists.txt b/plugins/cpPluginsWidgets/CMakeLists.txt index a01eca9..a8fb997 100644 --- a/plugins/cpPluginsWidgets/CMakeLists.txt +++ b/plugins/cpPluginsWidgets/CMakeLists.txt @@ -58,7 +58,7 @@ GENERATE_EXPORT_HEADER( EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/plugins/${lib_DIR}/${lib_NAME}_Export.h STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC ) -TARGET_LINK_LIBRARIES(${lib_NAME} ${target_LIBRARIES}) +TARGET_LINK_LIBRARIES(${lib_NAME} cpPipelineEditor ${target_LIBRARIES}) ## ======================== ## -- Installation rules -- -- 2.47.1