From 273699a71c538630c162de031f0c95014319311d Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Wed, 20 Jan 2016 17:14:55 -0500 Subject: [PATCH] ... --- appli/CMakeLists.txt | 2 +- .../cpPipelineEditor/App_cpPipelineEditor.cxx | 17 +- appli/cpPipelineEditor/App_cpPipelineEditor.h | 1 + appli/examples/CMakeLists.txt | 22 +- appli/examples/example_LoadPlugins.cxx | 12 +- .../examples/example_LoadPluginsFromPath.cxx | 14 +- appli/examples/example_TestParameters.cxx | 35 - lib/cpPipelineEditor/Block.cxx | 17 +- lib/cpPipelineEditor/Editor.cxx | 6 +- lib/cpPlugins/Interface/BaseApplication.h | 27 - lib/cpPlugins/Interface/BaseMPRWidget.cxx | 580 ------------- lib/cpPlugins/Interface/BaseMPRWidget.h | 156 ---- lib/cpPlugins/Interface/BaseMPRWidget.ui | 126 --- lib/cpPlugins/Interface/CMakeLists.txt | 3 - lib/cpPlugins/Interface/DataObject.cxx | 2 - lib/cpPlugins/Interface/DataObject.h | 22 +- lib/cpPlugins/Interface/Image.h | 4 +- lib/cpPlugins/Interface/Image.hxx | 3 +- lib/cpPlugins/Interface/ImplicitFunction.cxx | 3 + lib/cpPlugins/Interface/ImplicitFunction.h | 6 +- lib/cpPlugins/Interface/Interface.cxx | 1 + lib/cpPlugins/Interface/Macros.h | 6 +- lib/cpPlugins/Interface/Mesh.h | 3 + lib/cpPlugins/Interface/Object.cxx | 24 + lib/cpPlugins/Interface/Object.h | 33 +- .../Interface/{DataObject.hxx => Object.hxx} | 14 +- lib/cpPlugins/Interface/Parameters.cxx | 49 +- lib/cpPlugins/Interface/Parameters.h | 71 +- lib/cpPlugins/Interface/Parameters.hxx | 339 -------- .../Interface/ParametersQtDialog.cxx | 42 +- lib/cpPlugins/Interface/Plugins.cxx | 811 ------------------ lib/cpPlugins/Interface/Plugins.h | 173 ---- lib/cpPlugins/Interface/Plugins.hxx | 30 - lib/cpPlugins/Interface/ProcessObject.cxx | 89 +- lib/cpPlugins/Interface/ProcessObject.h | 57 +- lib/cpPlugins/Interface/ProcessObject.hxx | 52 +- .../BasicFilters/BinaryErodeImageFilter.cxx | 2 +- .../BinaryThresholdImageFilter.cxx | 2 +- lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx | 2 +- .../BasicFilters/DoubleFloodImageFilter.cxx | 28 +- .../BasicFilters/DoubleFloodImageFilter.h | 2 - .../BasicFilters/ExtractSliceImageFilter.cxx | 2 +- .../BasicFilters/FloodFillImageFilter.cxx | 18 +- .../Plugins/BasicFilters/MacheteFilter.cxx | 43 +- .../BasicFilters/MacheteImageFilter.cxx | 4 +- .../Plugins/BasicFilters/MacheteImageFilter.h | 2 +- .../Plugins/BasicFilters/MarchingCubes.cxx | 2 +- .../BasicFilters/MedianImageFilter.cxx | 2 +- .../BasicFilters/OtsuThresholdImageFilter.cxx | 2 +- .../RGBImageToOtherChannelsFilter.cxx | 2 +- .../SignedMaurerDistanceMapImageFilter.cxx | 2 +- .../Plugins/BasicFilters/SphereMeshSource.cxx | 13 +- lib/cpPlugins/Plugins/IO/ImageReader.cxx | 2 +- lib/cpPlugins/Plugins/IO/MeshReader.cxx | 2 +- lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx | 2 +- 55 files changed, 277 insertions(+), 2709 deletions(-) delete mode 100644 lib/cpPlugins/Interface/BaseApplication.h delete mode 100644 lib/cpPlugins/Interface/BaseMPRWidget.cxx delete mode 100644 lib/cpPlugins/Interface/BaseMPRWidget.h delete mode 100644 lib/cpPlugins/Interface/BaseMPRWidget.ui rename lib/cpPlugins/Interface/{DataObject.hxx => Object.hxx} (70%) delete mode 100644 lib/cpPlugins/Interface/Parameters.hxx delete mode 100644 lib/cpPlugins/Interface/Plugins.cxx delete mode 100644 lib/cpPlugins/Interface/Plugins.h delete mode 100644 lib/cpPlugins/Interface/Plugins.hxx diff --git a/appli/CMakeLists.txt b/appli/CMakeLists.txt index 1f50ec7..785c97e 100644 --- a/appli/CMakeLists.txt +++ b/appli/CMakeLists.txt @@ -5,7 +5,7 @@ SUBDIRS( IF(BUILD_EXAMPLES) SUBDIRS( examples - ImageMPR + #ImageMPR ) IF(USE_QT4) SUBDIRS( diff --git a/appli/cpPipelineEditor/App_cpPipelineEditor.cxx b/appli/cpPipelineEditor/App_cpPipelineEditor.cxx index 864d96f..78318a9 100644 --- a/appli/cpPipelineEditor/App_cpPipelineEditor.cxx +++ b/appli/cpPipelineEditor/App_cpPipelineEditor.cxx @@ -31,7 +31,8 @@ App_cpPipelineEditor:: App_cpPipelineEditor( int argc, char* argv[], QWidget* parent ) : QMainWindow( parent ), m_UI( new Ui::App_cpPipelineEditor ), - m_Workspace( NULL ) + m_Workspace( NULL ), + m_PluginsPath( "." ) { this->m_UI->setupUi( this ); @@ -40,10 +41,10 @@ App_cpPipelineEditor( int argc, char* argv[], QWidget* parent ) QFileInfo info( argv[ 0 ] ); if( info.exists( ) ) { - std::string path = info.canonicalPath( ).toStdString( ); - if( !( this->m_Plugins->LoadDefaultConfiguration( path ) ) ) - if( this->m_Plugins->LoadFromFolder( path, false ) ) - if( !( this->m_Plugins->SaveDefaultConfiguration( path ) ) ) + this->m_PluginsPath = info.canonicalPath( ).toStdString( ); + if( !( this->m_Plugins->LoadDefaultConfiguration( this->m_PluginsPath ) ) ) + if( this->m_Plugins->LoadFromFolder( this->m_PluginsPath, false ) ) + if( !( this->m_Plugins->SaveDefaultConfiguration( this->m_PluginsPath ) ) ) QMessageBox::critical( this, "Error creating default plugins configuration", @@ -185,6 +186,7 @@ _ButtonLoadPluginsFile( ) ); // Update view + this->m_Plugins->SaveDefaultConfiguration( this->m_PluginsPath ); this->_UpdateLoadedPlugins( ); } @@ -208,6 +210,7 @@ _ButtonLoadPluginsPath( ) ); // Update view + this->m_Plugins->SaveDefaultConfiguration( this->m_PluginsPath ); this->_UpdateLoadedPlugins( ); } @@ -230,6 +233,10 @@ _ActionOpenWorkspace( ) delete this->m_Workspace; this->m_Workspace = new cpPlugins::Interface::Workspace( ); this->m_Workspace->SetPlugins( this->m_Plugins ); + this->m_Workspace->AddInteractor( this->m_UI->Viewer->GetInteractor( 0 ) ); + this->m_Workspace->AddInteractor( this->m_UI->Viewer->GetInteractor( 1 ) ); + this->m_Workspace->AddInteractor( this->m_UI->Viewer->GetInteractor( 2 ) ); + this->m_Workspace->AddInteractor( this->m_UI->Viewer->GetInteractor( 3 ) ); std::string err = this->m_Workspace->LoadWorkspace( fname ); if( err != "" ) { diff --git a/appli/cpPipelineEditor/App_cpPipelineEditor.h b/appli/cpPipelineEditor/App_cpPipelineEditor.h index 831ef36..41b31b0 100644 --- a/appli/cpPipelineEditor/App_cpPipelineEditor.h +++ b/appli/cpPipelineEditor/App_cpPipelineEditor.h @@ -54,6 +54,7 @@ private: Ui::App_cpPipelineEditor* m_UI; cpPlugins::Interface::Workspace* m_Workspace; cpPlugins::Interface::Interface* m_Plugins; + std::string m_PluginsPath; }; #endif // __CPPIPELINEEDITOR__H__ diff --git a/appli/examples/CMakeLists.txt b/appli/examples/CMakeLists.txt index 9938095..b6161de 100644 --- a/appli/examples/CMakeLists.txt +++ b/appli/examples/CMakeLists.txt @@ -17,7 +17,7 @@ SET( example_TestParameters example_LoadPlugins example_LoadPluginsFromPath - example_WorkspaceSandBox + #example_WorkspaceSandBox ) FOREACH(prog ${EXAMPLES_PROGRAMS_ONLY_INTERFACE}) @@ -27,15 +27,15 @@ ENDFOREACH(prog) SET( EXAMPLES_PROGRAMS_WITH_PLUGINS - example_ReadWriteImage - example_MarchingCubes + #example_ReadWriteImage + #example_MarchingCubes #example_MPR - example_View2DImage - example_ViewImageThreshold - example_HandleWidget - example_SeedWidget - example_SphereWidget - example_Test_Memento + #example_View2DImage + #example_ViewImageThreshold + #example_HandleWidget + #example_SeedWidget + #example_SphereWidget + #example_Test_Memento ##example_OtsuFilter ##example_RGBImageToHSVChannels ##example_RGBImageToYPbPrChannels @@ -59,9 +59,9 @@ ENDFOREACH(prog) SET( NOPLUGINS_EXAMPLES_PROGRAMS - example_BaseInteractorStyle + #example_BaseInteractorStyle - example_ContourWidget + #example_ContourWidget ##example_Test_async ## example_MacheteFilter ## example_Test_DoubleClick diff --git a/appli/examples/example_LoadPlugins.cxx b/appli/examples/example_LoadPlugins.cxx index 76c5feb..9b40183 100644 --- a/appli/examples/example_LoadPlugins.cxx +++ b/appli/examples/example_LoadPlugins.cxx @@ -38,9 +38,15 @@ int main( int argc, char* argv[] ) } // rof // Show loaded classes - auto c = interface.GetClasses( ).begin( ); - for( ; c != interface.GetClasses( ).end( ); ++c ) - std::cout << "Class -> " << c->first << std::endl; + auto cat = interface.GetClasses( ).begin( ); + for( ; cat != interface.GetClasses( ).end( ); ++cat ) + { + std::cout << "Catergory -> " << cat->first << std::endl; + auto cla = cat->second.begin( ); + for( ; cla != cat->second.end( ); ++cla ) + std::cout << "\tClass -> " << cla->first << std::endl; + + } // rof return( 0 ); } diff --git a/appli/examples/example_LoadPluginsFromPath.cxx b/appli/examples/example_LoadPluginsFromPath.cxx index ba684ce..451d333 100644 --- a/appli/examples/example_LoadPluginsFromPath.cxx +++ b/appli/examples/example_LoadPluginsFromPath.cxx @@ -31,10 +31,16 @@ int main( int argc, char* argv[] ) } // rof - // Show loaded classes - auto c = interface.GetClasses( ).begin( ); - for( ; c != interface.GetClasses( ).end( ); ++c ) - std::cout << "Class -> " << c->first << std::endl; + // Show loaded classes + auto cat = interface.GetClasses( ).begin( ); + for( ; cat != interface.GetClasses( ).end( ); ++cat ) + { + std::cout << "Catergory -> " << cat->first << std::endl; + auto cla = cat->second.begin( ); + for( ; cla != cat->second.end( ); ++cla ) + std::cout << "\tClass -> " << cla->first << std::endl; + + } // rof return( 0 ); } diff --git a/appli/examples/example_TestParameters.cxx b/appli/examples/example_TestParameters.cxx index 807b4d9..2e6e9e0 100644 --- a/appli/examples/example_TestParameters.cxx +++ b/appli/examples/example_TestParameters.cxx @@ -1,9 +1,6 @@ #include #include -#include -#include - #include // ------------------------------------------------------------------------- @@ -21,28 +18,19 @@ void PrintList( const L& lst, const std::string& desc ) int main( int argc, char* argv[] ) { typedef cpPlugins::Interface::Parameters TParameters; - typedef itk::Index< 3 > TIndex; - typedef itk::Point< float, 3 > TPoint; TParameters::Pointer parameters = TParameters::New( ); - TIndex idx; idx[ 0 ] = 1; idx[ 1 ] = 2; idx[ 2 ] = 3; - TPoint pnt; pnt[ 0 ] = 3.1; pnt[ 1 ] = 2.2; pnt[ 2 ] = 1.3; - parameters->ConfigureAsString( "StringParam" ); parameters->ConfigureAsBool( "BoolParam" ); parameters->ConfigureAsInt( "IntParam" ); parameters->ConfigureAsUint( "UintParam" ); parameters->ConfigureAsReal( "RealParam" ); - parameters->ConfigureAsIndex( "IndexParam" ); - parameters->ConfigureAsPoint( "PointParam" ); parameters->ConfigureAsStringList( "StringListParam" ); parameters->ConfigureAsBoolList( "BoolListParam" ); parameters->ConfigureAsIntList( "IntListParam" ); parameters->ConfigureAsUintList( "UintListParam" ); parameters->ConfigureAsRealList( "RealListParam" ); - parameters->ConfigureAsIndexList( "IndexListParam" ); - parameters->ConfigureAsPointList( "PointListParam" ); std::vector< std::string > choices; choices.push_back( "bat" ); @@ -62,11 +50,6 @@ int main( int argc, char* argv[] ) parameters->SetUint( "UintParam", 1234567 ); parameters->SetReal( "RealParam", 3.14159244444 ); - idx[ 0 ] = 10; idx[ 1 ] = 20; idx[ 2 ] = 30; - pnt[ 0 ] = 30.1; pnt[ 1 ] = 21.2; pnt[ 2 ] = 12.3; - parameters->SetIndex( "IndexParam", 3, idx ); - parameters->SetPoint( "PointParam", 3, pnt ); - std::cout << "---------------------------------------------" << std::endl; parameters->Print( std::cout ); std::cout << "---------------------------------------------" << std::endl; @@ -76,8 +59,6 @@ int main( int argc, char* argv[] ) parameters->ClearIntList( "IntListParam" ); parameters->ClearUintList( "UintListParam" ); parameters->ClearRealList( "RealListParam" ); - parameters->ClearIndexList( "IndexListParam" ); - parameters->ClearPointList( "PointListParam" ); parameters->AddToStringList( "StringListParam", "one" ); parameters->AddToStringList( "StringListParam", "two" ); @@ -126,22 +107,6 @@ int main( int argc, char* argv[] ) parameters->AddToRealList( "RealListParam", 1.0012 ); parameters->AddToRealList( "RealListParam", 1.131245 ); - idx.Fill( 1 ); - parameters->AddToIndexList( "IndexListParam", 3, idx ); - idx.Fill( 2 ); - parameters->AddToIndexList( "IndexListParam", 3, idx ); - idx.Fill( 3 ); - parameters->AddToIndexList( "IndexListParam", 3, idx ); - - pnt.Fill( 1.2 ); - parameters->AddToPointList( "PointListParam", 3, pnt ); - pnt.Fill( 3.14 ); - parameters->AddToPointList( "PointListParam", 3, pnt ); - pnt.Fill( 6.28 ); - parameters->AddToPointList( "PointListParam", 3, pnt ); - pnt.Fill( 1.63 ); - parameters->AddToPointList( "PointListParam", 3, pnt ); - std::cout << "---------------------------------------------" << std::endl; parameters->Print( std::cout ); std::cout << "---------------------------------------------" << std::endl; diff --git a/lib/cpPipelineEditor/Block.cxx b/lib/cpPipelineEditor/Block.cxx index f27a7c8..bce1197 100644 --- a/lib/cpPipelineEditor/Block.cxx +++ b/lib/cpPipelineEditor/Block.cxx @@ -41,14 +41,12 @@ Block( TFilter* filter, QGraphicsItem* parent, QGraphicsScene* scene ) this->_setTypePort( this->m_Filter->GetClassName( ) ); // Add input ports - std::set< std::string > inputs; - this->m_Filter->GetInputsNames( inputs ); + auto inputs = this->m_Filter->GetInputsNames( ); for( auto iIt = inputs.begin( ); iIt != inputs.end( ); ++iIt ) this->addInputPort( iIt->c_str( ) ); // Add output ports - std::set< std::string > outputs; - this->m_Filter->GetOutputsNames( outputs ); + auto outputs = this->m_Filter->GetOutputsNames( ); for( auto oIt = outputs.begin( ); oIt != outputs.end( ); ++oIt ) this->addOutputPort( oIt->c_str( ) ); } @@ -211,10 +209,13 @@ itemChange( GraphicsItemChange change, const QVariant& value ) void cpPipelineEditor::Block:: _setTypePort( const QString& txt ) { - if( this->m_TypePort == NULL ) - this->m_TypePort = new TypePort( this ); - this->m_TypePort->setName( txt ); - this->_configPort( this->m_TypePort ); + /* TODO + if( this->m_TypePort == NULL ) + this->m_TypePort = new TypePort( this ); + this->m_TypePort->setName( txt ); + this->_configPort( this->m_TypePort ); + */ + this->setToolTip( txt ); } // ------------------------------------------------------------------------- diff --git a/lib/cpPipelineEditor/Editor.cxx b/lib/cpPipelineEditor/Editor.cxx index 2a0fca6..f74ce6e 100644 --- a/lib/cpPipelineEditor/Editor.cxx +++ b/lib/cpPipelineEditor/Editor.cxx @@ -162,8 +162,7 @@ _createBlock( TFilter* f, const QPointF& pnt ) // Mark exposed inputs auto& e_in = this->m_Workspace->GetExposedInputPorts( ); - std::set< std::string > f_in; - f->GetInputsNames( f_in ); + auto f_in = f->GetInputsNames( ); for( auto iIt = f_in.begin( ); iIt != f_in.end( ); ++iIt ) { auto eIt = e_in.begin( ); @@ -182,8 +181,7 @@ _createBlock( TFilter* f, const QPointF& pnt ) // Mark exposed outputs auto& e_out = this->m_Workspace->GetExposedOutputPorts( ); - std::set< std::string > f_out; - f->GetOutputsNames( f_out ); + auto f_out = f->GetOutputsNames( ); for( auto iIt = f_out.begin( ); iIt != f_out.end( ); ++iIt ) { auto eIt = e_out.begin( ); diff --git a/lib/cpPlugins/Interface/BaseApplication.h b/lib/cpPlugins/Interface/BaseApplication.h deleted file mode 100644 index 549296b..0000000 --- a/lib/cpPlugins/Interface/BaseApplication.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef __CPPLUGINS__INTERFACE__BASEAPPLICATION__H__ -#define __CPPLUGINS__INTERFACE__BASEAPPLICATION__H__ - -#include - -namespace cpPlugins -{ - namespace Interface - { - /** - */ - class cpPlugins_Interface_EXPORT BaseApplication - { - public: - BaseApplication( ) { } - virtual ~BaseApplication( ) { } - - virtual void UpdateActualFilter( ) = 0; - }; - - } // ecapseman - -} // ecapseman - -#endif // __CPPLUGINS__INTERFACE__BASEAPPLICATION__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/BaseMPRWidget.cxx b/lib/cpPlugins/Interface/BaseMPRWidget.cxx deleted file mode 100644 index 052e374..0000000 --- a/lib/cpPlugins/Interface/BaseMPRWidget.cxx +++ /dev/null @@ -1,580 +0,0 @@ -#include - -#ifdef cpPlugins_Interface_QT4 - -#include -#include -#include -#include -#include -#include - -double cpPlugins::Interface::BaseMPRWidget:: -cm_Colors[ 8 ][ 3 ] = -{ - { 1.0, 0.0, 0.0 }, - { 0.0, 1.0, 0.0 }, - { 0.0, 0.0, 1.0 }, - { 0.0, 1.0, 1.0 }, - { 1.0, 0.0, 1.0 }, - { 1.0, 1.0, 0.0 }, - { 1.0, 0.5, 0.0 }, - { 1.0, 0.0, 0.5 } -}; - -// ------------------------------------------------------------------------- -cpPlugins::Interface::BaseMPRWidget:: -BaseMPRWidget( QWidget* parent ) - : QWidget( parent ), - m_UI( new Ui::BaseMPRWidget ), - m_MainImage( "" ) -{ - this->m_UI->setupUi( this ); - - // Configure VTK widgets - this->m_VTK[ 0 ] = this->m_UI->VTK01; - this->m_VTK[ 1 ] = this->m_UI->VTK00; - this->m_VTK[ 2 ] = this->m_UI->VTK10; - this->m_VTK[ 3 ] = this->m_UI->VTK11; - - this->m_MPRObjects = vtkSmartPointer< TMPRObjects >::New( ); - this->m_MPRObjects->SetRenderWindows( - this->m_VTK[ 0 ]->GetRenderWindow( ), - this->m_VTK[ 1 ]->GetRenderWindow( ), - this->m_VTK[ 2 ]->GetRenderWindow( ), - this->m_VTK[ 3 ]->GetRenderWindow( ) - ); - - // Connect slots - QObject::connect( - this->m_UI->TopSplitter, SIGNAL( splitterMoved( int, int ) ), - this, SLOT( _SyncBottom( int, int ) ) - ); - QObject::connect( - this->m_UI->BottomSplitter, SIGNAL( splitterMoved( int, int ) ), - this, SLOT( _SyncTop( int, int ) ) - ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::BaseMPRWidget:: -~BaseMPRWidget( ) -{ - delete this->m_UI; -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::BaseMPRWidget:: -AddData( - cpPlugins::Interface::DataObject* data, const std::string& name, - const std::string& parent - ) -{ - if( name == "" ) - return( false ); - - auto iIt = this->m_Data.find( name ); - if( iIt == this->m_Data.end( ) ) - { - if( parent != "" ) - { - auto pIt = this->m_Data.find( parent ); - if( pIt == this->m_Data.end( ) ) - return( false ); - - } // fi - - // Add new data - this->m_Data[ name ].SetSourceDataObject( data ); - - // Add to tree view - this->_UpdateTreeItem( name, parent ); - return( true ); - } - else - return( false ); -} - -// ------------------------------------------------------------------------- -const std::string& cpPlugins::Interface::BaseMPRWidget:: -GetMainImage( ) const -{ - return( this->m_MainImage ); -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::BaseMPRWidget:: -SetMainImage( const std::string& name ) -{ - auto iIt = this->m_Data.find( name ); - if( iIt != this->m_Data.end( ) ) - { - if( iIt->second.Tag == Data::IMAGE ) - { - this->m_MainImage = name; - return( true ); - } - else - return( false ); - } - else - return( false ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::BaseMPRWidget:: -DeleteData( const std::string& name ) -{ - auto iIt = this->m_Data.find( name ); - if( iIt != this->m_Data.end( ) ) - { - this->m_Data.erase( iIt ); - - // Get children - std::vector< std::string > to_erase; - auto tIt = this->m_Tree.begin( ); - for( ; tIt != this->m_Tree.end( ); ++tIt ) - if( tIt->second == name ) - to_erase.push_back( tIt->first ); - - // Delete from tree - tIt = this->m_Tree.find( name ); - if( tIt != this->m_Tree.end( ) ) - this->m_Tree.erase( tIt ); - - // Recursive erase - auto dIt = to_erase.begin( ); - for( ; dIt != to_erase.end( ); ++dIt ) - this->DeleteData( *dIt ); - - // Delete from tree widget - QTreeWidgetItem* item = this->_FindItemInTree( name ); - if( item != NULL ) - this->m_UI->LoadedData->removeItemWidget( item, 0 ); - - // Reset main image, just in case - if( this->m_Data.size( ) == 0 ) - this->m_MainImage = ""; - - } // fi -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::BaseMPRWidget:: -DeleteAllData( ) -{ - this->m_MPRObjects->Clear( ); - this->m_Data.clear( ); - this->m_Tree.clear( ); - this->m_UI->LoadedData->clear( ); - this->m_MainImage = ""; -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::BaseMPRWidget:: -SetDataColor( - const std::string& name, const double& r, const double& g, const double& b - ) -{ - /* - auto iIt = this->m_Data.find( name ); - if( iIt == this->m_Data.end( ) ) - return; - - if( iIt->second.Tag == Data::IMAGE ) - { - } - else if( iIt->second.Tag == Data::MESH ) - { - } // fi - */ -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::BaseMPRWidget:: -ShowData( const std::string& name ) -{ - auto iIt = this->m_Data.find( name ); - if( iIt == this->m_Data.end( ) ) - return; - - if( iIt->second.Tag == Data::IMAGE ) - { - if( name == this->m_MainImage ) - this->m_MPRObjects->SetInputImage( iIt->second.Image ); - else - { - unsigned int i = ( this->m_MPRObjects->GetNumberOfImages( ) - 1 ) % 8; - this->m_MPRObjects->AddBinaryImage( - iIt->second.Image, - Self::cm_Colors[ i ][ 0 ], - Self::cm_Colors[ i ][ 1 ], - Self::cm_Colors[ i ][ 2 ] - ); - } - this->m_MPRObjects->Show( ); - } - else if( iIt->second.Tag == Data::MESH ) - { - /* TODO - vtkRenderer* ren = - this->m_VTK[ 3 ]->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( ); - if( ren == NULL ) - return; - ren->AddActor( iIt->second.GetMeshActor( ) ); - this->m_VTK[ 3 ]->GetRenderWindow( )->Render( ); - */ - } // fi -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::BaseMPRWidget:: -HideData( const std::string& name ) -{ -} - -// ------------------------------------------------------------------------- -vtkRenderWindowInteractor* cpPlugins::Interface::BaseMPRWidget:: -GetInteractor( unsigned int i ) -{ - if( i < 4 ) - { - if( this->m_VTK[ i ] != NULL ) - return( this->m_VTK[ i ]->GetInteractor( ) ); - else - return( NULL ); - } - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -/* - bool cpPlugins::Interface::BaseMPRWidget:: - ShowImage( - vtkImageData* image, - const std::string& name, - const std::string& parent - ) - { - // Update tree view - QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent ); - if( new_item == NULL ) - return( false ); - - // Associate new data - this->m_Images[ name ] = image; - this->m_Tree[ name ] = parent; - - // Show image and return - this->m_MPRObjects->AddImage( image ); - return( true ); - } - - // ------------------------------------------------------------------------- - bool cpPlugins::Interface::BaseMPRWidget:: - ShowImage( - vtkImageData* image, - const std::string& name, - const std::string& parent, - const double& r, const double& g, const double& b - ) - { - // Update tree view - QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent ); - if( new_item == NULL ) - return( false ); - - // Associate new data - this->m_Images[ name ] = image; - this->m_Tree[ name ] = parent; - - // Show image and return - this->m_MPRObjects->AddImage( image ); - return( true ); - } - - // ------------------------------------------------------------------------- - bool cpPlugins::Interface::BaseMPRWidget:: - ShowMesh( - vtkPolyData* mesh, - const std::string& name, - const std::string& parent - ) - { - // Update tree view - QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent ); - if( new_item == NULL ) - return( false ); - - // Associate new data - PolyDataActor* actor = new PolyDataActor( mesh ); - this->m_Meshes[ name ] = actor; - this->m_Tree[ name ] = parent; - - // Show mesh - this->_Add3DActor( actor->Actor ); - return( true ); - } - - // ------------------------------------------------------------------------- - bool cpPlugins::Interface::BaseMPRWidget:: - ShowMesh( - vtkPolyData* mesh, - const std::string& name, - const std::string& parent, - const double& r, const double& g, const double& b - ) - { - return false; - } - - // ------------------------------------------------------------------------- - void cpPlugins::Interface::BaseMPRWidget:: - ClearAll( ) - { - this->m_MPRObjects->ClearAll( ); - this->m_Images.clear( ); - this->m_Meshes.clear( ); - } -*/ - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::BaseMPRWidget:: -GetSelectedData( ) const -{ - QTreeWidgetItem* item = this->m_UI->LoadedData->currentItem( ); - if( item != NULL ) - return( item->text( 0 ).toStdString( ) ); - else - return( "" ); -} - -// ------------------------------------------------------------------------- -QTreeWidgetItem* cpPlugins::Interface::BaseMPRWidget:: -_FindItemInTree( const std::string& name ) const -{ - QList< QTreeWidgetItem* > items = - this->m_UI->LoadedData->findItems( - name.c_str( ), Qt::MatchExactly | Qt::MatchRecursive - ); - if( items.size( ) > 0 ) - return( items[ 0 ] ); - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -QTreeWidgetItem* cpPlugins::Interface::BaseMPRWidget:: -_UpdateTreeItem( const std::string& name, const std::string& parent ) -{ - // Update tree view - QTreeWidgetItem* new_item = NULL; - if( parent != "" ) - { - QTreeWidgetItem* parent_item = this->_FindItemInTree( parent ); - if( parent_item != NULL ) - { - QTreeWidgetItem* old_item = this->_FindItemInTree( name ); - if( old_item == NULL ) - { - new_item = - new QTreeWidgetItem( parent_item, QStringList( name.c_str( ) ) ); - parent_item->setExpanded( true ); - - } // fi - - } // fi - } - else - { - new_item = new QTreeWidgetItem( - ( QTreeWidgetItem* )( NULL ), QStringList( name.c_str( ) ) - ); - this->m_UI->LoadedData->addTopLevelItem( new_item ); - - } // fi - return( new_item ); -} - -// ------------------------------------------------------------------------- -/* - void cpPlugins::Interface::BaseMPRWidget:: - _Add3DActor( vtkProp3D* prop ) - { - vtkRenderer* ren = - this->m_VTK[ 3 ]->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( ); - if( ren == NULL ) - return; - ren->AddActor( prop ); - this->m_VTK[ 3 ]->GetRenderWindow( )->Render( ); - } -*/ - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::BaseMPRWidget:: -_SyncBottom( int a, int b ) -{ - this->m_UI->BottomSplitter->setSizes( this->m_UI->TopSplitter->sizes( ) ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::BaseMPRWidget:: -_SyncTop( int a, int b ) -{ - this->m_UI->TopSplitter->setSizes( this->m_UI->BottomSplitter->sizes( ) ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::BaseMPRWidget::PolyDataActor:: -PolyDataActor( ) - : Mesh( NULL ), - Normals( NULL ), - Stripper( NULL ), - Mapper( NULL ), - Actor( NULL ) -{ -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::BaseMPRWidget::PolyDataActor:: -~PolyDataActor( ) -{ - if( this->Actor != NULL ) this->Actor->Delete( ); - if( this->Mapper != NULL ) this->Mapper->Delete( ); - if( this->Stripper != NULL ) this->Stripper->Delete( ); - if( this->Normals != NULL ) this->Normals->Delete( ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::BaseMPRWidget::PolyDataActor:: -Configure( vtkPolyData* pd ) -{ - if( pd == NULL ) - return; - - double range[ 2 ]; - pd->GetScalarRange( range ); - - this->Normals = vtkPolyDataNormals::New( ); - this->Stripper = vtkStripper::New( ); - this->Mapper = vtkPolyDataMapper::New( ); - this->Actor = vtkQuadricLODActor::New( ); - - this->Mesh = pd; - this->Normals->SetInputData( pd ); - this->Normals->SetFeatureAngle( 60.0 ); - this->Stripper->SetInputConnection( this->Normals->GetOutputPort( ) ); - this->Mapper->SetInputConnection( this->Stripper->GetOutputPort( ) ); - this->Mapper->UseLookupTableScalarRangeOff( ); - this->Mapper->SetScalarRange( - range[ 0 ], ( ( range[ 1 ] - range[ 0 ] ) * 0.75 ) + range[ 0 ] - ); - this->Actor->SetMapper( this->Mapper ); - this->Actor->DeferLODConstructionOff( ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::BaseMPRWidget::Data:: -Data( ) -{ - this->Tag = Data::IMAGE; - this->Source = NULL; - this->Image = NULL; -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::BaseMPRWidget::Data:: -~Data( ) -{ -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::BaseMPRWidget:: -Data& cpPlugins::Interface::BaseMPRWidget::Data:: -operator=( const Data& data ) -{ - this->Tag = data.Tag; - this->Source = data.Source; - if( this->Tag == Data::IMAGE ) - this->Image = data.Image; - else if( this->Tag == Data::MESH ) - this->Mesh = data.Mesh; - return( *this ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface:: -DataObject* cpPlugins::Interface::BaseMPRWidget::Data:: -GetSourceDataObject( ) -{ - return( this->Source ); -} - -// ------------------------------------------------------------------------- -const cpPlugins::Interface:: -DataObject* cpPlugins::Interface::BaseMPRWidget::Data:: -GetSourceDataObject( ) const -{ - return( this->Source ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::BaseMPRWidget::Data:: -SetSourceDataObject( cpPlugins::Interface::DataObject* dobj ) -{ - typedef cpPlugins::Interface::Image _TImage; - typedef cpPlugins::Interface::Mesh _TMesh; - - this->Source = dobj; - _TImage* image = dynamic_cast< _TImage* >( dobj ); - if( image != NULL ) - { - this->Tag = Data::IMAGE; - this->Image = image->GetVTK< vtkImageData >( ); - } - else - { - _TMesh* mesh = dynamic_cast< _TMesh* >( dobj ); - if( mesh == NULL ) - return; - - this->Tag = Data::MESH; - this->Mesh.Configure( mesh->GetVTK< vtkPolyData >( ) ); - - } // fi -} - -// ------------------------------------------------------------------------- -vtkImageData* cpPlugins::Interface::BaseMPRWidget::Data:: -GetImage( ) -{ - if( this->Tag == Data::IMAGE ) - return( this->Image ); - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -vtkPolyData* cpPlugins::Interface::BaseMPRWidget::Data:: -GetMesh( ) -{ - if( this->Tag == Data::MESH ) - return( this->Mesh.Mesh ); - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -vtkProp* cpPlugins::Interface::BaseMPRWidget::Data:: -GetMeshActor( ) -{ - if( this->Tag == Data::MESH ) - return( this->Mesh.Actor ); - else - return( NULL ); -} - -#endif // cpPlugins_Interface_QT4 - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/BaseMPRWidget.h b/lib/cpPlugins/Interface/BaseMPRWidget.h deleted file mode 100644 index d3b89dd..0000000 --- a/lib/cpPlugins/Interface/BaseMPRWidget.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef __CPPLUGINS__INTERFACE__BASEMPRWIDGET__H__ -#define __CPPLUGINS__INTERFACE__BASEMPRWIDGET__H__ - -#include -#include - -#ifdef cpPlugins_Interface_QT4 - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include - -// ------------------------------------------------------------------------- -class QTreeWidgetItem; -class QVTKWidget; - -namespace Ui -{ - class BaseMPRWidget; -} - -// ------------------------------------------------------------------------- -namespace cpPlugins -{ - namespace Interface - { - // Some forward declarations - class DataObject; - - /** - */ - class cpPlugins_Interface_EXPORT BaseMPRWidget - : public QWidget - { - Q_OBJECT; - - public: - typedef BaseMPRWidget Self; - typedef cpExtensions::Visualization::MPRObjects TMPRObjects; - - typedef TMPRObjects::TStyle TStyle; - typedef TMPRObjects::TMouseCommand TMouseCommand; - typedef TMPRObjects::TMouseWheelCommand TMouseWheelCommand; - typedef TMPRObjects::TKeyCommand TKeyCommand; - typedef TMPRObjects::TVoidCommand TVoidCommand; - typedef TMPRObjects::TMouseMoveCommand TMouseMoveCommand; - typedef TMPRObjects::TMouseClickCommand TMouseClickCommand; - typedef TMPRObjects::TMouseDoubleClickCommand TMouseDoubleClickCommand; - typedef TMPRObjects::TExposeCommand TExposeCommand; - typedef TMPRObjects::TConfigureCommand TConfigureCommand; - typedef TMPRObjects::TEnterCommand TEnterCommand; - typedef TMPRObjects::TLeaveCommand TLeaveCommand; - - public: - explicit BaseMPRWidget( QWidget* parent = 0 ); - virtual ~BaseMPRWidget( ); - - // Data management - bool AddData( - DataObject* data, const std::string& name, - const std::string& parent - ); - const std::string& GetMainImage( ) const; - bool SetMainImage( const std::string& name ); - void DeleteData( const std::string& name ); - void DeleteAllData( ); - - // Some visualization accessors - void SetDataColor( - const std::string& name, - const double& r, const double& g, const double& b - ); - void ShowData( const std::string& name ); - void HideData( const std::string& name ); - - vtkRenderWindowInteractor* GetInteractor( unsigned int i ); - - // Visual objects accessors - std::string GetSelectedData( ) const; - - protected: - QTreeWidgetItem* _FindItemInTree( const std::string& name ) const; - QTreeWidgetItem* _UpdateTreeItem( - const std::string& name, - const std::string& parent - ); - - private slots: - void _SyncBottom( int a, int b ); - void _SyncTop( int a, int b ); - - protected: - static double cm_Colors[ 8 ][ 3 ]; - - Ui::BaseMPRWidget* m_UI; - vtkSmartPointer< TMPRObjects > m_MPRObjects; - QVTKWidget* m_VTK[ 4 ]; - - struct PolyDataActor - { - vtkPolyData* Mesh; - vtkPolyDataNormals* Normals; - vtkStripper* Stripper; - vtkPolyDataMapper* Mapper; - vtkQuadricLODActor* Actor; - - PolyDataActor( ); - virtual ~PolyDataActor( ); - void Configure( vtkPolyData* pd ); - }; - - struct Data - { - enum { IMAGE, MESH } Tag; - DataObject* Source; - vtkImageData* Image; - PolyDataActor Mesh; - - Data( ); - virtual ~Data( ); - - Data& operator=( const Data& data ); - - DataObject* GetSourceDataObject( ); - const DataObject* GetSourceDataObject( ) const; - void SetSourceDataObject( DataObject* dobj ); - - vtkImageData* GetImage( ); - vtkPolyData* GetMesh( ); - vtkProp* GetMeshActor( ); - }; - - std::string m_MainImage; - std::map< std::string, Data > m_Data; - std::map< std::string, std::string > m_Tree; - }; - - } // ecapseman - -} // ecapseman - -#endif // cpPlugins_Interface_QT4 - -#endif // __CPPLUGINS__INTERFACE__BASEMPRWIDGET__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/BaseMPRWidget.ui b/lib/cpPlugins/Interface/BaseMPRWidget.ui deleted file mode 100644 index 8eafb59..0000000 --- a/lib/cpPlugins/Interface/BaseMPRWidget.ui +++ /dev/null @@ -1,126 +0,0 @@ - - - BaseMPRWidget - - - - 0 - 0 - 580 - 424 - - - - Form - - - - - - - 562 - 406 - - - - Qt::Horizontal - - - - - 150 - 406 - - - - - 500 - 16777215 - - - - - Data - - - - - - - 406 - 406 - - - - Qt::Vertical - - - - - 406 - 200 - - - - Qt::Horizontal - - - - - 200 - 200 - - - - - - - 200 - 200 - - - - - - - - 406 - 200 - - - - Qt::Horizontal - - - - - 200 - 200 - - - - - - - 200 - 200 - - - - - - - - - - - - QVTKWidget - QWidget -
QVTKWidget.h
- 1 -
-
- - -
diff --git a/lib/cpPlugins/Interface/CMakeLists.txt b/lib/cpPlugins/Interface/CMakeLists.txt index 44eb019..3de13f1 100644 --- a/lib/cpPlugins/Interface/CMakeLists.txt +++ b/lib/cpPlugins/Interface/CMakeLists.txt @@ -20,7 +20,6 @@ FILE(GLOB LIB_SOURCES_CXX "*.cxx") IF(USE_QT4) SET( LIB_QT_UI - BaseMPRWidget.ui SimpleMPRWidget.ui ParametersListWidget.ui ) @@ -28,14 +27,12 @@ IF(USE_QT4) LIB_QT_Headers ParametersListWidget.h ParametersQtDialog.h - BaseMPRWidget.h SimpleMPRWidget.h ) SET( LIB_QT_Sources ParametersListWidget.cxx ParametersQtDialog.cxx - BaseMPRWidget.cxx SimpleMPRWidget.cxx ) SET( diff --git a/lib/cpPlugins/Interface/DataObject.cxx b/lib/cpPlugins/Interface/DataObject.cxx index c937e4d..deac58c 100644 --- a/lib/cpPlugins/Interface/DataObject.cxx +++ b/lib/cpPlugins/Interface/DataObject.cxx @@ -67,8 +67,6 @@ DisconnectPipeline( ) cpPlugins::Interface::DataObject:: DataObject( ) : Superclass( ), - m_ITKObject( NULL ), - m_VTKObject( NULL ), m_Source( NULL ) { } diff --git a/lib/cpPlugins/Interface/DataObject.h b/lib/cpPlugins/Interface/DataObject.h index 05b7023..e2d79ff 100644 --- a/lib/cpPlugins/Interface/DataObject.h +++ b/lib/cpPlugins/Interface/DataObject.h @@ -3,10 +3,6 @@ #include -#include -#include -#include - namespace cpPlugins { namespace Interface @@ -37,18 +33,6 @@ namespace cpPlugins void DisconnectPipeline( ); - template< class T > - inline T* GetITK( ); - - template< class T > - inline const T* GetITK( ) const; - - template< class T > - inline T* GetVTK( ); - - template< class T > - inline const T* GetVTK( ) const; - protected: DataObject( ); virtual ~DataObject( ); @@ -59,17 +43,13 @@ namespace cpPlugins Self& operator=( const Self& ); protected: - itk::Object::Pointer m_ITKObject; - vtkSmartPointer< vtkObject > m_VTKObject; - ProcessObject* m_Source; + ProcessObject* m_Source; }; } // ecapseman } // ecapseman -#include - #endif // __CPPLUGINS__INTERFACE__DATAOBJECT__H__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Image.h b/lib/cpPlugins/Interface/Image.h index 23e1c23..729acdf 100644 --- a/lib/cpPlugins/Interface/Image.h +++ b/lib/cpPlugins/Interface/Image.h @@ -5,7 +5,9 @@ #include -// ------------------------------------------------------------------------- +// Some forward declarations +class vtkObject; + namespace cpPlugins { namespace Interface diff --git a/lib/cpPlugins/Interface/Image.hxx b/lib/cpPlugins/Interface/Image.hxx index 5b675b2..ab2c5ea 100644 --- a/lib/cpPlugins/Interface/Image.hxx +++ b/lib/cpPlugins/Interface/Image.hxx @@ -48,6 +48,7 @@ SetITK( itk::Object* object ) this->m_VTKObject = NULL; this->m_ITKvVTKConnection = NULL; this->Modified( ); + return; } // fi @@ -118,7 +119,7 @@ _ITK_2_VTK( itk::Object* object ) typedef itk::Image< P, D > _I; typedef itk::ImageToVTKImageFilter< _I > _I2Vtk; - // Check if input object has the desired type + // Check (yes, again!!!) if input object has the desired type _I* image = dynamic_cast< _I* >( object ); if( image == NULL ) return; diff --git a/lib/cpPlugins/Interface/ImplicitFunction.cxx b/lib/cpPlugins/Interface/ImplicitFunction.cxx index 5802ac8..cae117d 100644 --- a/lib/cpPlugins/Interface/ImplicitFunction.cxx +++ b/lib/cpPlugins/Interface/ImplicitFunction.cxx @@ -1,5 +1,8 @@ #include +#include + +#include #include #include #include diff --git a/lib/cpPlugins/Interface/ImplicitFunction.h b/lib/cpPlugins/Interface/ImplicitFunction.h index 18ff63d..a8c8a78 100644 --- a/lib/cpPlugins/Interface/ImplicitFunction.h +++ b/lib/cpPlugins/Interface/ImplicitFunction.h @@ -4,10 +4,8 @@ #include #include -#include - -#include -#include +// Sompe forward declarations +class vtkImplicitFunction; namespace cpPlugins { diff --git a/lib/cpPlugins/Interface/Interface.cxx b/lib/cpPlugins/Interface/Interface.cxx index 34dbf2e..9d7b2fe 100644 --- a/lib/cpPlugins/Interface/Interface.cxx +++ b/lib/cpPlugins/Interface/Interface.cxx @@ -1,4 +1,5 @@ #include +#include #include #include #include diff --git a/lib/cpPlugins/Interface/Macros.h b/lib/cpPlugins/Interface/Macros.h index 90cea8c..790a997 100644 --- a/lib/cpPlugins/Interface/Macros.h +++ b/lib/cpPlugins/Interface/Macros.h @@ -6,10 +6,10 @@ #include // ------------------------------------------------------------------------- -#define cpPlugins_Id_Macro( name, category ) \ +#define cpPlugins_Id_Macro( N, C ) \ public: \ - virtual const char* GetClassName( ) const { return( #name ); } \ - virtual const char* GetClassCategory( ) const { return( #category ); } + virtual const char* GetClassName( ) const { return( #N ); } \ + virtual const char* GetClassCategory( ) const { return( #C ); } // ------------------------------------------------------------------------- #define CPPLUGINS_PROVIDER_HEADER_BEGIN( TYPE ) \ diff --git a/lib/cpPlugins/Interface/Mesh.h b/lib/cpPlugins/Interface/Mesh.h index e769239..10752ba 100644 --- a/lib/cpPlugins/Interface/Mesh.h +++ b/lib/cpPlugins/Interface/Mesh.h @@ -3,6 +3,9 @@ #include +// Some forward declarations +class vtkObject; + namespace cpPlugins { namespace Interface diff --git a/lib/cpPlugins/Interface/Object.cxx b/lib/cpPlugins/Interface/Object.cxx index 369b20f..583f59a 100644 --- a/lib/cpPlugins/Interface/Object.cxx +++ b/lib/cpPlugins/Interface/Object.cxx @@ -1,9 +1,33 @@ #include +#include +#include + +// ------------------------------------------------------------------------- +void cpPlugins::Interface::Object:: +Modified( ) const +{ + const itk::Object* i = this->GetITK< itk::Object >( ); + vtkObject* v = const_cast< vtkObject* >( this->GetVTK< vtkObject >( ) ); + if( i != NULL ) i->Modified( ); + if( v != NULL ) v->Modified( ); + this->Superclass::Modified( ); +} + +// ------------------------------------------------------------------------- +float cpPlugins::Interface::Object:: +SetViewCoords( float x, float y ) +{ + this->SetViewX( x ); + this->SetViewY( y ); +} + // ------------------------------------------------------------------------- cpPlugins::Interface::Object:: Object( ) : Superclass( ), + m_ITKObject( NULL ), + m_VTKObject( NULL ), m_Name( "" ), m_ViewX( float( 0 ) ), m_ViewY( float( 0 ) ) diff --git a/lib/cpPlugins/Interface/Object.h b/lib/cpPlugins/Interface/Object.h index 345be7f..0adfa8e 100644 --- a/lib/cpPlugins/Interface/Object.h +++ b/lib/cpPlugins/Interface/Object.h @@ -4,9 +4,13 @@ #include #include + #include #include +#include +#include + namespace cpPlugins { namespace Interface @@ -36,11 +40,20 @@ namespace cpPlugins itkSetMacro( ViewY, float ); public: - inline float SetViewCoords( float x, float y ) - { - this->SetViewX( x ); - this->SetViewY( y ); - } + virtual void Modified( ) const; + float SetViewCoords( float x, float y ); + + template< class T > + inline T* GetITK( ); + + template< class T > + inline const T* GetITK( ) const; + + template< class T > + inline T* GetVTK( ); + + template< class T > + inline const T* GetVTK( ) const; protected: Object( ); @@ -52,14 +65,20 @@ namespace cpPlugins Self& operator=( const Self& ); protected: - std::string m_Name; - float m_ViewX, m_ViewY; + itk::LightObject::Pointer m_ITKObject; + vtkSmartPointer< vtkObjectBase > m_VTKObject; + std::string m_Name; + + float m_ViewX; + float m_ViewY; }; } // ecapseman } // ecapseman +#include + #endif // __CPPLUGINS__INTERFACE__OBJECT__H__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/DataObject.hxx b/lib/cpPlugins/Interface/Object.hxx similarity index 70% rename from lib/cpPlugins/Interface/DataObject.hxx rename to lib/cpPlugins/Interface/Object.hxx index a7e6c63..914d5ca 100644 --- a/lib/cpPlugins/Interface/DataObject.hxx +++ b/lib/cpPlugins/Interface/Object.hxx @@ -1,9 +1,9 @@ -#ifndef __CPPLUGINS__INTERFACE__DATAOBJECT__HXX__ -#define __CPPLUGINS__INTERFACE__DATAOBJECT__HXX__ +#ifndef __CPPLUGINS__INTERFACE__OBJECT__HXX__ +#define __CPPLUGINS__INTERFACE__OBJECT__HXX__ // ------------------------------------------------------------------------- template< class T > -T* cpPlugins::Interface::DataObject:: +T* cpPlugins::Interface::Object:: GetITK( ) { return( dynamic_cast< T* >( this->m_ITKObject.GetPointer( ) ) ); @@ -11,7 +11,7 @@ GetITK( ) // ------------------------------------------------------------------------- template< class T > -const T* cpPlugins::Interface::DataObject:: +const T* cpPlugins::Interface::Object:: GetITK( ) const { return( dynamic_cast< const T* >( this->m_ITKObject.GetPointer( ) ) ); @@ -19,7 +19,7 @@ GetITK( ) const // ------------------------------------------------------------------------- template< class T > -T* cpPlugins::Interface::DataObject:: +T* cpPlugins::Interface::Object:: GetVTK( ) { return( dynamic_cast< T* >( this->m_VTKObject.GetPointer( ) ) ); @@ -27,12 +27,12 @@ GetVTK( ) // ------------------------------------------------------------------------- template< class T > -const T* cpPlugins::Interface::DataObject:: +const T* cpPlugins::Interface::Object:: GetVTK( ) const { return( dynamic_cast< const T* >( this->m_VTKObject.GetPointer( ) ) ); } -#endif // __CPPLUGINS__INTERFACE__DATAOBJECT__HXX__ +#endif // __CPPLUGINS__INTERFACE__OBJECT__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Parameters.cxx b/lib/cpPlugins/Interface/Parameters.cxx index 7e2459c..e6db0e3 100644 --- a/lib/cpPlugins/Interface/Parameters.cxx +++ b/lib/cpPlugins/Interface/Parameters.cxx @@ -44,7 +44,7 @@ Clear( ) // ------------------------------------------------------------------------- void cpPlugins::Interface::Parameters:: -GetNames( std::vector< TString >& container ) const +GetNames( std::vector< std::string >& container ) const { container.clear( ); TParameters::const_iterator i = this->m_Parameters.begin( ); @@ -55,7 +55,7 @@ GetNames( std::vector< TString >& container ) const // ------------------------------------------------------------------------- cpPlugins::Interface::Parameters:: Type cpPlugins::Interface::Parameters:: -GetType( const TString& name ) const +GetType( const std::string& name ) const { auto i = this->m_Parameters.find( name ); if( i != this->m_Parameters.end( ) ) @@ -70,7 +70,7 @@ GetType( const TString& name ) const return( #Y ) std::string cpPlugins::Interface::Parameters:: -GetTypeAsString( const TString& name ) const +GetTypeAsString( const std::string& name ) const { auto i = this->m_Parameters.find( name ); cpPlugins_Parameters_TypeAsString( String ); @@ -78,9 +78,6 @@ GetTypeAsString( const TString& name ) const else cpPlugins_Parameters_TypeAsString( Int ); else cpPlugins_Parameters_TypeAsString( Uint ); else cpPlugins_Parameters_TypeAsString( Real ); - else cpPlugins_Parameters_TypeAsString( Index ); - else cpPlugins_Parameters_TypeAsString( Point ); - else cpPlugins_Parameters_TypeAsString( Vector ); else cpPlugins_Parameters_TypeAsString( OpenFileName ); else cpPlugins_Parameters_TypeAsString( SaveFileName ); else cpPlugins_Parameters_TypeAsString( PathName ); @@ -89,9 +86,6 @@ GetTypeAsString( const TString& name ) const else cpPlugins_Parameters_TypeAsString( IntList ); else cpPlugins_Parameters_TypeAsString( UintList ); else cpPlugins_Parameters_TypeAsString( RealList ); - else cpPlugins_Parameters_TypeAsString( IndexList ); - else cpPlugins_Parameters_TypeAsString( PointList ); - else cpPlugins_Parameters_TypeAsString( VectorList ); else cpPlugins_Parameters_TypeAsString( OpenFileNameList ); else cpPlugins_Parameters_TypeAsString( SaveFileNameList ); else cpPlugins_Parameters_TypeAsString( PathNameList ); @@ -113,9 +107,6 @@ GetTypeFromString( const std::string& t ) else cpPlugins_Parameters_TypeFromString( Int, t ); else cpPlugins_Parameters_TypeFromString( Uint, t ); else cpPlugins_Parameters_TypeFromString( Real, t ); - else cpPlugins_Parameters_TypeFromString( Index, t ); - else cpPlugins_Parameters_TypeFromString( Point, t ); - else cpPlugins_Parameters_TypeFromString( Vector, t ); else cpPlugins_Parameters_TypeFromString( OpenFileName, t ); else cpPlugins_Parameters_TypeFromString( SaveFileName, t ); else cpPlugins_Parameters_TypeFromString( PathName, t ); @@ -124,9 +115,6 @@ GetTypeFromString( const std::string& t ) else cpPlugins_Parameters_TypeFromString( IntList, t ); else cpPlugins_Parameters_TypeFromString( UintList, t ); else cpPlugins_Parameters_TypeFromString( RealList, t ); - else cpPlugins_Parameters_TypeFromString( IndexList, t ); - else cpPlugins_Parameters_TypeFromString( PointList, t ); - else cpPlugins_Parameters_TypeFromString( VectorList, t ); else cpPlugins_Parameters_TypeFromString( OpenFileNameList, t ); else cpPlugins_Parameters_TypeFromString( SaveFileNameList, t ); else cpPlugins_Parameters_TypeFromString( PathNameList, t ); @@ -189,7 +177,7 @@ ConfigureAsChoices( // ------------------------------------------------------------------------- std::vector< std::string > cpPlugins::Interface::Parameters:: -GetChoices( const TString& name ) const +GetChoices( const std::string& name ) const { std::vector< std::string > choices; @@ -236,19 +224,18 @@ GetSelectedChoice( const std::string& name ) const // ------------------------------------------------------------------------- bool cpPlugins::Interface::Parameters:: -SetSelectedChoice( const TString& name, const TString& choice ) +SetSelectedChoice( const std::string& name, const std::string& choice ) { auto i = this->m_Parameters.find( name ); if( i != this->m_Parameters.end( ) ) { if( i->second.first == Self::Choices ) { - std::vector< std::string > c = this->GetChoices( name ); - if( std::find( c.begin( ), c.end( ), choice ) != c.end( ) ) + std::istringstream str_choices( i->second.second ); + std::string choices; + std::getline( str_choices, choices, '@' ); + if( choices.find( choice ) != std::string::npos ) { - std::istringstream str_choices( i->second.second ); - std::string choices; - std::getline( str_choices, choices, '@' ); std::stringstream new_choices; new_choices << choices << "@" << choice; i->second.second = new_choices.str( ); @@ -264,24 +251,6 @@ SetSelectedChoice( const TString& name, const TString& choice ) return( false ); } -// ------------------------------------------------------------------------- -#define cpPlugins_Parameters_ClearList( Y ) \ - void cpPlugins::Interface::Parameters:: \ - Clear##Y##List( const TString& name ) \ - { \ - auto i = this->m_Parameters.find( name ); \ - if( i == this->m_Parameters.end( ) ) \ - return; \ - if( i->second.first != Self::Y##List ) \ - return; \ - i->second.second = ""; \ - this->Modified( ); \ - } - -cpPlugins_Parameters_ClearList( Index ); -cpPlugins_Parameters_ClearList( Point ); -cpPlugins_Parameters_ClearList( Vector ); - // ------------------------------------------------------------------------- bool cpPlugins::Interface::Parameters:: ToXML( TiXmlElement* parent_elem ) const diff --git a/lib/cpPlugins/Interface/Parameters.h b/lib/cpPlugins/Interface/Parameters.h index c93e160..f751e98 100644 --- a/lib/cpPlugins/Interface/Parameters.h +++ b/lib/cpPlugins/Interface/Parameters.h @@ -159,12 +159,10 @@ namespace cpPlugins enum Type { String , Bool , Int , - Uint , Real , Index , - Point , Vector , OpenFileName , + Uint , Real , OpenFileName , SaveFileName , PathName , StringList , BoolList , IntList , UintList , - RealList , IndexList , PointList , - VectorList , OpenFileNameList , SaveFileNameList , + RealList , OpenFileNameList , SaveFileNameList , PathNameList , Choices , NoType }; @@ -189,9 +187,6 @@ namespace cpPlugins cpPlugins_Parameters_Configure( Int ); cpPlugins_Parameters_Configure( Uint ); cpPlugins_Parameters_Configure( Real ); - cpPlugins_Parameters_Configure( Index ); - cpPlugins_Parameters_Configure( Point ); - cpPlugins_Parameters_Configure( Vector ); cpPlugins_Parameters_Configure( OpenFileName ); cpPlugins_Parameters_Configure( SaveFileName ); cpPlugins_Parameters_Configure( PathName ); @@ -200,9 +195,6 @@ namespace cpPlugins cpPlugins_Parameters_Configure( IntList ); cpPlugins_Parameters_Configure( UintList ); cpPlugins_Parameters_Configure( RealList ); - cpPlugins_Parameters_Configure( IndexList ); - cpPlugins_Parameters_Configure( PointList ); - cpPlugins_Parameters_Configure( VectorList ); cpPlugins_Parameters_Configure( OpenFileNameList ); cpPlugins_Parameters_Configure( SaveFileNameList ); cpPlugins_Parameters_Configure( PathNameList ); @@ -258,63 +250,6 @@ namespace cpPlugins const std::string& name, const std::string& choice ); - // Some templated methods - template< class I > - I GetIndex( - const std::string& name, const unsigned int& dim - ) const; - template< class P > - P GetPoint( - const std::string& name, const unsigned int& dim - ) const; - template< class V > - V GetVector( - const std::string& name, const unsigned int& dim - ) const; - - template< class I > - void SetIndex( - const std::string& name, const unsigned int& dim, const I& v - ); - template< class P > - void SetPoint( - const std::string& name, const unsigned int& dim, const P& v - ); - template< class V > - void SetVector( - const std::string& name, const unsigned int& dim, const V& v - ); - - template< class I > - std::vector< I > GetIndexList( - const std::string& name, const unsigned int& dim - ) const; - template< class P > - std::vector< P > GetPointList( - const std::string& name, const unsigned int& dim - ) const; - template< class V > - std::vector< V > GetVectorList( - const std::string& name, const unsigned int& dim - ) const; - - template< class I > - void AddToIndexList( - const std::string& name, const unsigned int& dim, const I& v - ); - template< class P > - void AddToPointList( - const std::string& name, const unsigned int& dim, const P& v - ); - template< class P > - void AddToVectorList( - const std::string& name, const unsigned int& dim, const P& v - ); - - void ClearIndexList( const std::string& name ); - void ClearPointList( const std::string& name ); - void ClearVectorList( const std::string& name ); - // XML "streaming" bool ToXML( TiXmlElement* parent_elem ) const; bool FromXML( const TiXmlElement* filter_elem ); @@ -341,8 +276,6 @@ namespace cpPlugins } // ecapseman -#include - #endif // __CPPLUGINS__INTERFACE__PARAMETERS__H__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Parameters.hxx b/lib/cpPlugins/Interface/Parameters.hxx deleted file mode 100644 index eecb2b6..0000000 --- a/lib/cpPlugins/Interface/Parameters.hxx +++ /dev/null @@ -1,339 +0,0 @@ -#ifndef __CPPLUGINS__INTERFACE__PARAMETERS__HXX__ -#define __CPPLUGINS__INTERFACE__PARAMETERS__HXX__ - -// ------------------------------------------------------------------------- -template< class I > -I cpPlugins::Interface::Parameters:: -GetIndex( const std::string& name, const unsigned int& dim ) const -{ - I v; - auto i = this->m_Parameters.find( name ); - if( i != this->m_Parameters.end( ) ) - { - if( i->second.first == Self::Index ) - { - std::istringstream str( i->second.second ); - std::string token; - unsigned int d = 0; - while( std::getline( str, token, ';' ) && d < dim ) - { - v[ d ] = std::atoi( token.c_str( ) ); - d++; - - } // elihw - return( v ); - - } // fi - - } // fi - - // If parameter not found - for( unsigned int d = 0; d < dim; ++d ) - v[ d ] = 0; - return( v ); -} - -// ------------------------------------------------------------------------- -template< class P > -P cpPlugins::Interface::Parameters:: -GetPoint( const std::string& name, const unsigned int& dim ) const -{ - P v; - auto i = this->m_Parameters.find( name ); - if( i != this->m_Parameters.end( ) ) - { - if( i->second.first == Self::Point ) - { - std::istringstream str( i->second.second ); - std::string token; - unsigned int d = 0; - while( std::getline( str, token, ';' ) && d < dim ) - { - std::istringstream tok_str( token ); - tok_str >> v[ d ]; - d++; - - } // elihw - return( v ); - - } // fi - - } // fi - - // If parameter not found - for( unsigned int d = 0; d < dim; ++d ) - v[ d ] = float( 0 ); - return( v ); -} - -// ------------------------------------------------------------------------- -template< class V > -V cpPlugins::Interface::Parameters:: -GetVector( const std::string& name, const unsigned int& dim ) const -{ - V v; - auto i = this->m_Parameters.find( name ); - if( i != this->m_Parameters.end( ) ) - { - if( i->second.first == Self::Vector ) - { - std::istringstream str( i->second.second ); - std::string token; - unsigned int d = 0; - while( std::getline( str, token, ';' ) && d < dim ) - { - std::istringstream tok_str( token ); - tok_str >> v[ d ]; - d++; - - } // elihw - return( v ); - - } // fi - - } // fi - - // If parameter not found - for( unsigned int d = 0; d < dim; ++d ) - v[ d ] = float( 0 ); - return( v ); -} - -// ------------------------------------------------------------------------- -template< class I > -void cpPlugins::Interface::Parameters:: -SetIndex( const std::string& name, const unsigned int& dim, const I& v ) -{ - TParameters::iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return; - if( i->second.first != Self::Index ) - return; - - std::stringstream str; - str << v[ 0 ]; - for( unsigned int d = 1; d < dim; ++d ) - str << ";" << v[ d ]; - i->second.second = str.str( ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class P > -void cpPlugins::Interface::Parameters:: -SetPoint( const std::string& name, const unsigned int& dim, const P& v ) -{ - TParameters::iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return; - if( i->second.first != Self::Point ) - return; - - std::stringstream str; - str << v[ 0 ]; - for( unsigned int d = 1; d < dim; ++d ) - str << ";" << v[ d ]; - i->second.second = str.str( ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class V > -void cpPlugins::Interface::Parameters:: -SetVector( const std::string& name, const unsigned int& dim, const V& v ) -{ - TParameters::iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return; - if( i->second.first != Self::Vector ) - return; - - std::stringstream str; - str << v[ 0 ]; - for( unsigned int d = 1; d < dim; ++d ) - str << ";" << v[ d ]; - i->second.second = str.str( ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class I > -std::vector< I > cpPlugins::Interface::Parameters:: -GetIndexList( const std::string& name, const unsigned int& dim ) const -{ - std::vector< I > lst; - auto i = this->m_Parameters.find( name ); - if( i != this->m_Parameters.end( ) ) - { - if( i->second.first == Self::IndexList ) - { - std::istringstream str( i->second.second ); - std::string token; - unsigned int d = 0; - while( std::getline( str, token, '#' ) ) - { - std::istringstream str2( token ); - std::string token2; - unsigned int d = 0; - I v; - while( std::getline( str2, token2, ';' ) && d < dim ) - { - v[ d ] = std::atoi( token.c_str( ) ); - d++; - - } // elihw - lst.push_back( v ); - - } // elihw - - } // fi - - } // fi - return( lst ); -} - -// ------------------------------------------------------------------------- -template< class P > -std::vector< P > cpPlugins::Interface::Parameters:: -GetPointList( const std::string& name, const unsigned int& dim ) const -{ - std::vector< P > lst; - - auto i = this->m_Parameters.find( name ); - if( i != this->m_Parameters.end( ) ) - { - if( i->second.first == Self::PointList ) - { - std::istringstream str( i->second.second ); - std::string token; - unsigned int d = 0; - while( std::getline( str, token, '#' ) ) - { - std::istringstream str2( token ); - std::string token2; - unsigned int d = 0; - P v; - while( std::getline( str2, token2, ';' ) && d < dim ) - { - std::istringstream tok_str( token ); - tok_str >> v[ d ]; - d++; - - } // elihw - lst.push_back( v ); - - } // elihw - - } // fi - - } // fi - return( lst ); -} - -// ------------------------------------------------------------------------- -template< class V > -std::vector< V > cpPlugins::Interface::Parameters:: -GetVectorList( const std::string& name, const unsigned int& dim ) const -{ - std::vector< V > lst; - - auto i = this->m_Parameters.find( name ); - if( i != this->m_Parameters.end( ) ) - { - if( i->second.first == Self::VectorList ) - { - std::istringstream str( i->second.second ); - std::string token; - unsigned int d = 0; - while( std::getline( str, token, '#' ) ) - { - std::istringstream str2( token ); - std::string token2; - unsigned int d = 0; - V v; - while( std::getline( str2, token2, ';' ) && d < dim ) - { - std::istringstream tok_str( token ); - tok_str >> v[ d ]; - d++; - - } // elihw - lst.push_back( v ); - - } // elihw - - } // fi - - } // fi - return( lst ); -} - -// ------------------------------------------------------------------------- -template< class I > -void cpPlugins::Interface::Parameters:: -AddToIndexList( const std::string& name, const unsigned int& dim, const I& v ) -{ - TParameters::iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return; - if( i->second.first != Self::IndexList ) - return; - - std::stringstream str; - if( i->second.second == "" ) - str << v[ 0 ]; - else - str << "#" << v[ 0 ]; - for( unsigned int d = 1; d < dim; ++d ) - str << ";" << v[ d ]; - i->second.second += str.str( ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class P > -void cpPlugins::Interface::Parameters:: -AddToPointList( const std::string& name, const unsigned int& dim, const P& v ) -{ - TParameters::iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return; - if( i->second.first != Self::PointList ) - return; - - std::stringstream str; - if( i->second.second == "" ) - str << v[ 0 ]; - else - str << "#" << v[ 0 ]; - for( unsigned int d = 1; d < dim; ++d ) - str << ";" << v[ d ]; - i->second.second += str.str( ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class V > -void cpPlugins::Interface::Parameters:: -AddToVectorList( const std::string& name, const unsigned int& dim, const V& v ) -{ - TParameters::iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return; - if( i->second.first != Self::VectorList ) - return; - - std::stringstream str; - if( i->second.second == "" ) - str << v[ 0 ]; - else - str << "#" << v[ 0 ]; - for( unsigned int d = 1; d < dim; ++d ) - str << ";" << v[ d ]; - i->second.second += str.str( ); - this->Modified( ); -} - -#endif // __CPPLUGINS__INTERFACE__PARAMETERS__HXX__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ParametersQtDialog.cxx b/lib/cpPlugins/Interface/ParametersQtDialog.cxx index e502c6e..0c3d437 100644 --- a/lib/cpPlugins/Interface/ParametersQtDialog.cxx +++ b/lib/cpPlugins/Interface/ParametersQtDialog.cxx @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -19,11 +20,6 @@ #include #include -// ------------------------------------------------------------------------- -#include -#include -#include - /* TODO class SingleSeedCommand : public vtkCommand @@ -244,12 +240,6 @@ setParameters( Parameters* parameters ) w_input = v_double; } break; - case Parameters::Index: - break; - case Parameters::Point: - break; - case Parameters::Vector: - break; case Parameters::OpenFileName: { QFrame* frame = new QFrame( this ); @@ -367,12 +357,6 @@ setParameters( Parameters* parameters ) w_input = frame; } break; - case Parameters::IndexList: - break; - case Parameters::PointList: - break; - case Parameters::VectorList: - break; case Parameters::OpenFileNameList: { QFrame* frame = new QFrame( this ); @@ -528,22 +512,10 @@ updateParameters( ) } // fi } break; - case Parameters::Index: - break; - case Parameters::Point: - break; - case Parameters::Vector: - break; case Parameters::StringList: break; case Parameters::BoolList: break; - case Parameters::IndexList: - break; - case Parameters::PointList: - break; - case Parameters::VectorList: - break; case Parameters::SaveFileNameList: break; case Parameters::PathNameList: @@ -632,22 +604,10 @@ updateView( ) } // fi } break; - case Parameters::Index: - break; - case Parameters::Point: - break; - case Parameters::Vector: - break; case Parameters::StringList: break; case Parameters::BoolList: break; - case Parameters::IndexList: - break; - case Parameters::PointList: - break; - case Parameters::VectorList: - break; case Parameters::SaveFileNameList: break; case Parameters::PathNameList: diff --git a/lib/cpPlugins/Interface/Plugins.cxx b/lib/cpPlugins/Interface/Plugins.cxx deleted file mode 100644 index c5727c2..0000000 --- a/lib/cpPlugins/Interface/Plugins.cxx +++ /dev/null @@ -1,811 +0,0 @@ -#include - -#include - -#include -#include - -#ifdef cpPlugins_Interface_QT4 - -#include -#include -#include -#include - -#ifdef _WIN32 -# define PLUGIN_PREFIX "" -# define PLUGIN_EXT "dll" -# define PLUGIN_REGEX "Plugins file (*.dll);;All files (*)" -#else // Linux -# define PLUGIN_PREFIX "lib" -# define PLUGIN_EXT "so" -# define PLUGIN_REGEX "Plugins file (*.so);;All files (*)" -#endif // _WIN32 - -#endif // cpPlugins_Interface_QT4 - -// ------------------------------------------------------------------------- -cpPlugins::Interface::Plugins:: -Plugins( ) - : m_Widget( NULL ), - m_Application( NULL ), - m_LastLoadedPlugin( "" ), - m_ActiveFilter( NULL ) -{ -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::Plugins:: -~Plugins( ) -{ -} - -// ------------------------------------------------------------------------- -QWidget* cpPlugins::Interface::Plugins:: -GetWidget( ) -{ - return( this->m_Widget ); -} - -// ------------------------------------------------------------------------- -const QWidget* cpPlugins::Interface::Plugins:: -GetWidget( ) const -{ - return( this->m_Widget ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -SetWidget( QWidget* widget ) -{ - this->m_Widget = widget; -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -BlockWidget( ) -{ -#ifdef cpPlugins_Interface_QT4 - if( this->m_Widget != NULL ) - { - QApplication::setOverrideCursor( Qt::WaitCursor ); - this->m_Widget->setEnabled( false ); - - } // fi -#endif // cpPlugins_Interface_QT4 -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -UnblockWidget( ) -{ -#ifdef cpPlugins_Interface_QT4 - if( this->m_Widget != NULL ) - { - QApplication::restoreOverrideCursor( ); - this->m_Widget->setEnabled( true ); - - } // fi -#endif // cpPlugins_Interface_QT4 -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -DialogLoadPlugins( ) -{ -#ifdef cpPlugins_Interface_QT4 - if( this->m_Widget != NULL ) - { - QFileDialog dialog( this->m_Widget ); - dialog.setFileMode( QFileDialog::ExistingFile ); - dialog.setDirectory( this->m_LastLoadedPlugin.c_str( ) ); - dialog.setNameFilter( QFileDialog::tr( PLUGIN_REGEX ) ); - dialog.setDefaultSuffix( QFileDialog::tr( PLUGIN_EXT ) ); - if( !( dialog.exec( ) ) ) - return; - - std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( ); - if( !( this->LoadPlugins( fname ) ) ) - QMessageBox::critical( - this->m_Widget, - QMessageBox::tr( "Ignoring plugin" ), - QMessageBox::tr( fname.c_str( ) ) - ); - - } // fi -#endif // cpPlugins_Interface_QT4 -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface:: -BaseApplication* cpPlugins::Interface::Plugins:: -GetApplication( ) -{ - return( this->m_Application ); -} - -// ------------------------------------------------------------------------- -const cpPlugins::Interface:: -BaseApplication* cpPlugins::Interface::Plugins:: -GetApplication( ) const -{ - return( this->m_Application ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -SetApplication( BaseApplication* a ) -{ - this->m_Application = a; -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::Plugins:: -LoadPluginsPath( const std::string& path, bool r ) -{ - /* TODO - this->BlockWidget( ); - - // Load all plugins from given folder - std::list< std::string > files = - this->m_Interface.LoadFromFolder( path, r ); - - // Update a simple track - bool ret = false; - if( files.size( ) > 0 ) - { - for( auto fIt = files.begin( ); fIt != files.end( ); ++fIt ) - { - this->m_LoadedPlugins.insert( *fIt ); - this->m_LastLoadedPlugin = *fIt; - ret = true; - - } // rof - this->_UpdateLoadedPluginsInformation( ); - - } // fi - - this->UnblockWidget( ); - return( ret ); - */ - return( false ); -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::Plugins:: -LoadPlugins( const std::string& fname ) -{ - this->BlockWidget( ); - - // Is it already loaded? - bool ret = true; - if( this->m_LoadedPlugins.find( fname ) == this->m_LoadedPlugins.end( ) ) - { - // Was it succesfully loaded? - ret = this->m_Interface.Load( fname ); - - // Update a simple track - if( ret ) - { - this->m_LoadedPlugins.insert( fname ); - this->m_LastLoadedPlugin = fname; - this->_UpdateLoadedPluginsInformation( ); - - } // fi - - } // fi - - this->UnblockWidget( ); - return( ret ); -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::Plugins:: -LoadPluginsConfigurationFile( const std::string& fname ) -{ - // Load file into a char buffer - std::ifstream in( - fname.c_str( ), std::ios::in | std::ios::binary | std::ios::ate - ); - if( !in.is_open( ) ) - return( false ); - - std::streampos size = in.tellg( ); - char* buffer = new char[ size ]; - in.seekg( 0, std::ios::beg ); - in.read( buffer, size ); - in.close( ); - - // Read stream - std::stringstream in_stream( buffer ); - char line[ 4096 ]; - while( in_stream ) - { - in_stream.getline( line, 4096 ); - this->LoadPlugins( line ); - - } // elihw - delete buffer; - - return( true ); -} - -// ------------------------------------------------------------------------- -const cpPlugins::Interface::Plugins:: -TStringContainer& cpPlugins::Interface::Plugins:: -GetLoadedPlugins( ) const -{ - return( this->m_LoadedPlugins ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -GetLoadedCategories( TStringContainer& categories ) const -{ - categories.clear( ); - auto fIt = this->m_LoadedFilters.begin( ); - for( ; fIt != this->m_LoadedFilters.end( ); ++fIt ) - categories.insert( fIt->first ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -GetLoadedFilters( TStringContainer& filters ) const -{ - filters.clear( ); - auto pIt = this->m_LoadedFilters.begin( ); - for( ; pIt != this->m_LoadedFilters.end( ); ++pIt ) - for( auto fIt = pIt->second.begin( ); fIt != pIt->second.end( ); ++fIt ) - filters.insert( *fIt ); -} - -// ------------------------------------------------------------------------- -const cpPlugins::Interface::Plugins:: -TStringContainer& cpPlugins::Interface::Plugins:: -GetLoadedFilters( const std::string& category ) const -{ - static const TStringContainer EMPTY; - auto pIt = this->m_LoadedFilters.find( category ); - if( pIt != this->m_LoadedFilters.end( ) ) - return( pIt->second ); - else - return( EMPTY ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -AddInteractor( vtkRenderWindowInteractor* interactor ) -{ - this->m_Interactors.insert( interactor ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -RemoveInteractor( vtkRenderWindowInteractor* interactor ) -{ - this->m_Interactors.erase( interactor ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -ClearInteractors( ) -{ - this->m_Interactors.clear( ); -} - -// ------------------------------------------------------------------------- -#define cpPlugins_Plugins_HasMacro( F ) \ - bool cpPlugins::Interface::Plugins:: \ - Has##F( ) const \ - { \ - return( this->m_IOFilters.find( #F ) != this->m_IOFilters.end( ) ); \ - } - -cpPlugins_Plugins_HasMacro( ImageReader ); -cpPlugins_Plugins_HasMacro( DicomSeriesReader ); -cpPlugins_Plugins_HasMacro( MeshReader ); -cpPlugins_Plugins_HasMacro( ImageWriter ); -cpPlugins_Plugins_HasMacro( MeshWriter ); - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::Plugins:: -ReadImage( const std::string& fname, const std::string& parent ) -{ - std::vector< std::string > fnames( 1, fname ); - return( this->ReadImage( fnames, parent ) ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::Plugins:: -ReadImage( - const std::vector< std::string >& fnames, const std::string& parent - ) -{ - // Load source - this->_ActivateIOFilter( "ImageReader" ); - - // Configure reader - TParameters* params = this->GetActiveFilterParameters( ); - params->ClearStringList( "FileNames" ); - for( auto nIt = fnames.begin( ); nIt != fnames.end( ); ++nIt ) - params->AddToStringList( "FileNames", *nIt ); - - // Execute filter - return( this->_ReadData( parent ) ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::Plugins:: -ReadImage( const std::string& parent ) -{ - // Load source - this->_ActivateIOFilter( "ImageReader" ); - - // Try to configure source - if( !( this->ConfigureActiveFilter( ) ) ) - { - this->DeactivateFilter( ); - return( "" ); - - } // fi - - // Execute filter - return( this->_ReadData( parent ) ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::Plugins:: -ReadDicomSeries( const std::string& parent ) -{ - // Load source - this->_ActivateIOFilter( "DicomSeriesReader" ); - - // Try to configure source - if( !( this->ConfigureActiveFilter( ) ) ) - { - this->DeactivateFilter( ); - return( "" ); - - } // fi - - // Execute filter - return( this->_ReadData( parent ) ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::Plugins:: -ReadMesh( const std::string& fname, const std::string& parent ) -{ - // Load source - this->_ActivateIOFilter( "MeshReader" ); - - // Configure reader - TParameters* params = this->GetActiveFilterParameters( ); - params->SetString( "FileName", fname ); - - // Execute filter - return( this->_ReadData( parent ) ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::Plugins:: -ReadMesh( const std::string& parent ) -{ - // Load source - this->_ActivateIOFilter( "MeshReader" ); - - // Try to configure source - if( !( this->ConfigureActiveFilter( ) ) ) - { - this->DeactivateFilter( ); - return( "" ); - - } // fi - - // Execute filter - return( this->_ReadData( parent ) ); -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::Plugins:: -WriteDataObject( const std::string& fname, const std::string& name ) -{ - typedef cpPlugins::Interface::Image _TImage; - typedef cpPlugins::Interface::Mesh _TMesh; - - // Activate sink - TDataObject* obj = this->GetData< TDataObject >( name ); - if( dynamic_cast< cpPlugins::Interface::Image* >( obj ) != NULL ) - this->_ActivateIOFilter( "ImageWriter" ); - else if( dynamic_cast< cpPlugins::Interface::Mesh* >( obj ) != NULL ) - this->_ActivateIOFilter( "MeshWriter" ); - else - { - this->DeactivateFilter( ); - return( false ); - - } // fi - - // Configure writer - TParameters* params = this->GetActiveFilterParameters( ); - params->SetString( "FileName", fname ); - - // Execute filter - return( this->_WriteData( name ) ); -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::Plugins:: -WriteDataObject( const std::string& name ) -{ - typedef cpPlugins::Interface::Image _TImage; - typedef cpPlugins::Interface::Mesh _TMesh; - - // Activate sink - TDataObject* obj = this->GetData< TDataObject >( name ); - if( dynamic_cast< cpPlugins::Interface::Image* >( obj ) != NULL ) - this->_ActivateIOFilter( "ImageWriter" ); - else if( dynamic_cast< cpPlugins::Interface::Mesh* >( obj ) != NULL ) - this->_ActivateIOFilter( "MeshWriter" ); - else - { - this->DeactivateFilter( ); - return( false ); - - } // fi - - // Try to configure source - if( !( this->ConfigureActiveFilter( ) ) ) - { - this->DeactivateFilter( ); - return( false ); - - } // fi - - // Execute filter - return( this->_WriteData( name ) ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -ClearDataObjects( ) -{ - this->m_DataObjects.clear( ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -DeleteDataObject( const std::string& name ) -{ - // Find and delete object - auto oIt = this->m_DataObjects.find( name ); - if( oIt == this->m_DataObjects.end( ) ) - return; - this->m_DataObjects.erase( oIt ); - - // Delete children - TStringContainer children; - this->GetChildren( children, name ); - auto cIt = children.begin( ); - for( ; cIt != children.end( ); ++cIt ) - this->DeleteDataObject( *cIt ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -GetDataObjects( TStringContainer& names ) -{ - names.clear( ); - auto oIt = this->m_DataObjects.begin( ); - for( ; oIt != this->m_DataObjects.end( ); ++oIt ) - names.insert( oIt->first ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::Plugins:: -GetParent( const std::string& name ) const -{ - // Find and delete object - auto oIt = this->m_DataObjects.find( name ); - if( oIt != this->m_DataObjects.end( ) ) - return( oIt->second.first ); - else - return( "" ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -GetChildren( TStringContainer& names, const std::string& name ) const -{ - names.clear( ); - auto oIt = this->m_DataObjects.begin( ); - for( ; oIt != this->m_DataObjects.end( ); ++oIt ) - if( oIt->second.first == name ) - names.insert( oIt->first ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -GetRoots( TStringContainer& names ) const -{ - this->GetChildren( names, "" ); -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::Plugins:: -ActivateFilter( const std::string& name ) -{ - this->m_ActiveFilter = this->m_Interface.CreateObject( name ); - if( this->m_ActiveFilter.IsNotNull( ) ) - { - this->m_ActiveFilter->SetPlugins( this ); - auto iIt = this->m_Interactors.begin( ); - for( ; iIt != this->m_Interactors.end( ); ++iIt ) - this->m_ActiveFilter->AddInteractor( *iIt ); - return( true ); - } - else - return( false ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -DeactivateFilter( ) -{ - if( this->m_ActiveFilter.IsNotNull( ) ) - this->m_ActiveFilter->DisconnectOutputs( ); - this->m_ActiveFilter = NULL; -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::Plugins:: -HasActiveFilter( ) const -{ - return( this->m_ActiveFilter.IsNotNull( ) ); -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::Plugins:: -IsActiveFilterInteractive( ) const -{ - if( this->m_ActiveFilter.IsNotNull( ) ) - return( this->m_ActiveFilter->GetInteractive( ) ); - else - return( false ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -GetActiveFilterInputsNames( TStringContainer& names ) const -{ - if( this->m_ActiveFilter.IsNotNull( ) ) - this->m_ActiveFilter->GetInputsNames( names ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -GetActiveFilterOutputsNames( TStringContainer& names ) const -{ - if( this->m_ActiveFilter.IsNotNull( ) ) - this->m_ActiveFilter->GetOutputsNames( names ); -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::Plugins:: -ConnectInputInActiveFilter( - const std::string& object_name, const std::string& input_name - ) -{ - if( this->m_ActiveFilter.IsNotNull( ) ) - { - TDataObject* dobj = this->GetData< TDataObject >( object_name ); - if( dobj != NULL ) - { - this->m_ActiveFilter->SetInput( input_name, dobj ); - return( true ); - - } // fi - - } // fi - return( false ); -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::Plugins:: -SetOutputNameInActiveFilter( - const std::string& new_object_name, const std::string& output_name - ) -{ - if( this->m_ActiveFilter.IsNotNull( ) ) - return( - this->m_ActiveFilter->SetOutputObjectName( - new_object_name, output_name - ) - ); - else - return( false ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::Plugins:: -TParameters* cpPlugins::Interface::Plugins:: -GetActiveFilterParameters( ) -{ - if( this->m_ActiveFilter.IsNotNull( ) ) - return( this->m_ActiveFilter->GetParameters( ) ); - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -const cpPlugins::Interface::Plugins:: -TParameters* cpPlugins::Interface::Plugins:: -GetActiveFilterParameters( ) const -{ - if( this->m_ActiveFilter.IsNotNull( ) ) - return( this->m_ActiveFilter->GetParameters( ) ); - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::Plugins:: -TProcessObject::DialogResult cpPlugins::Interface::Plugins:: -ConfigureActiveFilter( ) -{ - if( this->m_ActiveFilter.IsNotNull( ) ) - return( this->m_ActiveFilter->ExecConfigurationDialog( this->m_Widget ) ); - else - return( false ); -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::Plugins:: -UpdateActiveFilter( TStringContainer& outputs, const std::string& parent ) -{ - if( this->m_ActiveFilter.IsNull( ) ) - return( false ); - - // Execute filter - this->BlockWidget( ); - std::string err = this->m_ActiveFilter->Update( ); - this->UnblockWidget( ); - - // Associate outputs - outputs.clear( ); - if( err == "" ) - { - std::set< std::string > names; - this->m_ActiveFilter->GetOutputsNames( names ); - for( auto oIt = names.begin( ); oIt != names.end( ); ++oIt ) - { - TDataObject* dobj = - this->m_ActiveFilter->GetOutput< TDataObject >( *oIt ); - - if( std::string( dobj->GetName( ) ) == std::string( "" ) ) - dobj->SetName( - this->m_ActiveFilter->GetName( ) + std::string( "_" ) + *oIt - ); - this->_InsertNewData( dobj, parent ); - outputs.insert( dobj->GetName( ) ); - - } // rof - // this->m_ActiveFilter->DisconnectOutputs( ); - return( true ); - } - else - { -#ifdef cpPlugins_Interface_QT4 - if( this->m_Widget != NULL ) - QMessageBox::critical( - this->m_Widget, - QMessageBox::tr( "Error reading image." ), - QMessageBox::tr( err.c_str( ) ) - ); - else - throw std::runtime_error( - std::string( "Error reading image: " ) + err - ); -#else // cpPlugins_Interface_QT4 - throw std::runtime_error( - std::string( "Error reading image: " ) + err - ); -#endif // cpPlugins_Interface_QT4 - return( false ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Plugins:: -_UpdateLoadedPluginsInformation( ) -{ - this->m_LoadedFilters.clear( ); - const TInterface::TClasses& cls = this->m_Interface.GetClasses( ); - for( auto i = cls.begin( ); i != cls.end( ); ++i ) - { - TProcessObject::Pointer o = this->m_Interface.CreateObject( i->first ); - std::string name = o->GetClassName( ); - std::string category = o->GetClassCategory( ); - - if( - category == "ImageReader" || - category == "ImageWriter" || - category == "MeshReader" || - category == "MeshWriter" || - category == "DicomSeriesReader" - ) - this->m_IOFilters[ category ] = o; - else - this->m_LoadedFilters[ category ].insert( name ); - - } // rof -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::Plugins:: -_ActivateIOFilter( const std::string& filter ) -{ - // Activate reader - auto fIt = this->m_IOFilters.find( filter ); - if( fIt != this->m_IOFilters.end( ) ) - { - this->m_ActiveFilter = fIt->second; - return( true ); - } - else - return( false ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::Plugins:: -_ReadData( const std::string& parent ) -{ - if( !( this->HasActiveFilter( ) ) ) - return( "" ); - - TStringContainer outputs; - if( this->UpdateActiveFilter( outputs, parent ) ) - return( *( outputs.begin( ) ) ); - else - return( "" ); -} - -// ------------------------------------------------------------------------ -bool cpPlugins::Interface::Plugins:: -_WriteData( const std::string& name ) -{ - if( !( this->HasActiveFilter( ) ) ) - return( false ); - - TStringContainer inputs; - this->GetActiveFilterInputsNames( inputs ); - bool r = true; - for( auto iIt = inputs.begin( ); iIt != inputs.end( ); ++iIt ) - r &= this->ConnectInputInActiveFilter( name, *iIt ); - - if( r ) - { - TStringContainer outputs; - return( this->UpdateActiveFilter( outputs, "" ) ); - } - else - return( false ); -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::Plugins:: -_InsertNewData( TDataObject* dobj, const std::string& parent ) -{ - if( parent != "" ) - { - auto oIt = this->m_DataObjects.find( parent ); - if( oIt == this->m_DataObjects.end( ) ) - return( false ); - - } // fi - this->m_DataObjects[ dobj->GetName( ) ] = _TTreeNode( parent, dobj ); - return( true ); -} - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Plugins.h b/lib/cpPlugins/Interface/Plugins.h deleted file mode 100644 index f93f377..0000000 --- a/lib/cpPlugins/Interface/Plugins.h +++ /dev/null @@ -1,173 +0,0 @@ -#ifndef __CPPLUGINS__INTERFACE__PLUGINS__H__ -#define __CPPLUGINS__INTERFACE__PLUGINS__H__ - -#include -#include -#include - -#include -#include -#include -#include - -// Some forward declarations -class vtkRenderWindowInteractor; -#ifdef cpPlugins_Interface_QT4 -class QWidget; -#else -typedef char QWidget; -#endif // cpPlugins_Interface_QT4 - -namespace cpPlugins -{ - namespace Interface - { - // Some forward declarations - class BaseApplication; - - /** - */ - class cpPlugins_Interface_EXPORT Plugins - { - public: - typedef cpPlugins::Interface::Interface TInterface; - typedef cpPlugins::Interface::ProcessObject TProcessObject; - typedef cpPlugins::Interface::DataObject TDataObject; - typedef TProcessObject::TParameters TParameters; - - typedef std::set< std::string > TStringContainer; - - public: - Plugins( ); - virtual ~Plugins( ); - - // Qt oriented methods - QWidget* GetWidget( ); - const QWidget* GetWidget( ) const; - void SetWidget( QWidget* widget ); - void BlockWidget( ); - void UnblockWidget( ); - void DialogLoadPlugins( ); - - // Connection to main application - BaseApplication* GetApplication( ); - const BaseApplication* GetApplication( ) const; - void SetApplication( BaseApplication* a ); - - // Plugins management - bool LoadPluginsPath( const std::string& path, bool r = false ); - bool LoadPlugins( const std::string& fname ); - bool LoadPluginsConfigurationFile( const std::string& fname ); - const TStringContainer& GetLoadedPlugins( ) const; - void GetLoadedCategories( TStringContainer& categories ) const; - void GetLoadedFilters( TStringContainer& filters ) const; - const TStringContainer& GetLoadedFilters( - const std::string& category - ) const; - - // Interactors - void AddInteractor( vtkRenderWindowInteractor* interactor ); - void RemoveInteractor( vtkRenderWindowInteractor* interactor ); - void ClearInteractors( ); - - // Data IO - bool HasImageReader( ) const; - bool HasDicomSeriesReader( ) const; - bool HasMeshReader( ) const; - bool HasImageWriter( ) const; - bool HasMeshWriter( ) const; - - std::string ReadImage( - const std::string& fname, const std::string& parent - ); - std::string ReadImage( - const std::vector< std::string >& fnames, const std::string& parent - ); - std::string ReadImage( const std::string& parent ); - std::string ReadDicomSeries( const std::string& parent ); - std::string ReadMesh( - const std::string& fname, const std::string& parent - ); - std::string ReadMesh( const std::string& parent ); - - bool WriteDataObject( - const std::string& fname, const std::string& name - ); - bool WriteDataObject( const std::string& name ); - - // Data objects - void ClearDataObjects( ); - void DeleteDataObject( const std::string& name ); - void GetDataObjects( TStringContainer& names ); - std::string GetParent( const std::string& name ) const; - void GetChildren( - TStringContainer& names, const std::string& name - ) const; - void GetRoots( TStringContainer& names ) const; - - template< class T > - inline T* GetData( const std::string& name ); - - template< class T > - inline const T* GetData( const std::string& name ) const; - - // Filter acces - bool ActivateFilter( const std::string& name ); - void DeactivateFilter( ); - bool HasActiveFilter( ) const; - bool IsActiveFilterInteractive( ) const; - void GetActiveFilterInputsNames( TStringContainer& names ) const; - void GetActiveFilterOutputsNames( TStringContainer& names ) const; - bool ConnectInputInActiveFilter( - const std::string& object_name, const std::string& input_name - ); - bool SetOutputNameInActiveFilter( - const std::string& new_object_name, const std::string& output_name - ); - TParameters* GetActiveFilterParameters( ); - const TParameters* GetActiveFilterParameters( ) const; - TProcessObject::DialogResult ConfigureActiveFilter( ); - bool UpdateActiveFilter( - TStringContainer& outputs, - const std::string& parent - ); - - protected: - void _UpdateLoadedPluginsInformation( ); - bool _ActivateIOFilter( const std::string& filter ); - std::string _ReadData( const std::string& parent ); - bool _WriteData( const std::string& name ); - bool _InsertNewData( TDataObject* dobj, const std::string& parent ); - - protected: - // MVC objects - QWidget* m_Widget; - BaseApplication* m_Application; - - // Plugins interface - TInterface m_Interface; - TStringContainer m_LoadedPlugins; - std::string m_LastLoadedPlugin; - std::map< std::string, TStringContainer > m_LoadedFilters; - - // Loaded filters - std::map< std::string, TProcessObject::Pointer > m_IOFilters; - TProcessObject::Pointer m_ActiveFilter; - - // Loaded data objects - typedef std::pair< std::string, TDataObject::Pointer > _TTreeNode; - std::map< std::string, _TTreeNode > m_DataObjects; - - // Associated interactors - std::set< vtkRenderWindowInteractor* > m_Interactors; - }; - - } // ecapseman - -} // ecapseman - -#include - -#endif // __CPPLUGINS__INTERFACE__PLUGINS__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Plugins.hxx b/lib/cpPlugins/Interface/Plugins.hxx deleted file mode 100644 index b2bcd8a..0000000 --- a/lib/cpPlugins/Interface/Plugins.hxx +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __CPPLUGINS__INTERFACE__PLUGINS__HXX__ -#define __CPPLUGINS__INTERFACE__PLUGINS__HXX__ - -// ------------------------------------------------------------------------- -template< class T > -T* cpPlugins::Interface::Plugins:: -GetData( const std::string& name ) -{ - auto dIt = this->m_DataObjects.find( name ); - if( dIt != this->m_DataObjects.end( ) ) - return( dynamic_cast< T* >( dIt->second.second.GetPointer( ) ) ); - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -template< class T > -const T* cpPlugins::Interface::Plugins:: -GetData( const std::string& name ) const -{ - auto dIt = this->m_DataObjects.find( name ); - if( dIt != this->m_DataObjects.end( ) ) - return( dynamic_cast< const T* >( dIt->second.second.GetPointer( ) ) ); - else - return( NULL ); -} - -#endif // __CPPLUGINS__INTERFACE__PLUGINS__HXX__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index 1db1a61..7ed9dfc 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -8,34 +8,25 @@ #include // ------------------------------------------------------------------------- -void cpPlugins::Interface::ProcessObject:: -Modified( ) const -{ - if( this->m_ITKObject.IsNotNull( ) ) - this->m_ITKObject->Modified( ); - if( this->m_VTKObject.GetPointer( ) != NULL ) - this->m_VTKObject->Modified( ); - this->Superclass::Modified( ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::ProcessObject:: -GetInputsNames( std::set< std::string >& names ) const +std::set< std::string > cpPlugins::Interface::ProcessObject:: +GetInputsNames( ) const { - names.clear( ); + std::set< std::string > names; auto dIt = this->m_Inputs.begin( ); for( ; dIt != this->m_Inputs.end( ); ++dIt ) names.insert( dIt->first ); + return( names ); } // ------------------------------------------------------------------------- -void cpPlugins::Interface::ProcessObject:: -GetOutputsNames( std::set< std::string >& names ) const +std::set< std::string > cpPlugins::Interface::ProcessObject:: +GetOutputsNames( ) const { - names.clear( ); + std::set< std::string > names; auto dIt = this->m_Outputs.begin( ); for( ; dIt != this->m_Outputs.end( ); ++dIt ) names.insert( dIt->first ); + return( names ); } // ------------------------------------------------------------------------- @@ -54,23 +45,6 @@ GetNumberOfOutputs( ) const // ------------------------------------------------------------------------- bool cpPlugins::Interface::ProcessObject:: -SetOutputObjectName( - const std::string& new_object_name, const std::string& output_name - ) -{ - auto oIt = this->m_Outputs.find( output_name ); - if( oIt != this->m_Outputs.end( ) ) - { - this->m_OutputObjectsNames[ output_name ] = new_object_name; - this->Modified( ); - return( true ); - } - else - return( false ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::ProcessObject:: SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj ) { _TDataContainer::iterator i = this->m_Inputs.find( id ); @@ -78,8 +52,10 @@ SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj ) { i->second = dobj; this->Modified( ); - - } // fi + return( true ); + } + else + return( false ); } // ------------------------------------------------------------------------- @@ -107,16 +83,6 @@ Update( ) if( r == "" ) r = this->_GenerateData( ); - // Configure output names - auto oIt = this->m_Outputs.begin( ); - for( ; oIt != this->m_Outputs.end( ); ++oIt ) - { - auto nIt = this->m_OutputObjectsNames.find( oIt->first ); - if( nIt != this->m_OutputObjectsNames.end( ) ) - oIt->second->SetName( nIt->second ); - - } // rof - // Return error description, if any return( r ); } @@ -143,12 +109,10 @@ GetInteractors( ) const void cpPlugins::Interface::ProcessObject:: AddInteractor( vtkRenderWindowInteractor* interactor ) { + this->m_Interactors.insert( interactor ); #ifdef cpPlugins_Interface_QT4 - if( this->m_ParametersDialog == NULL ) - this->m_ParametersDialog = new ParametersQtDialog( ); this->m_ParametersDialog->addInteractor( interactor ); #endif // cpPlugins_Interface_QT4 - this->m_Interactors.insert( interactor ); } // ------------------------------------------------------------------------- @@ -156,29 +120,16 @@ bool cpPlugins::Interface::ProcessObject:: ExecConfigurationDialog( QWidget* parent ) { bool r = false; - #ifdef cpPlugins_Interface_QT4 - - if( QApplication::instance( ) != NULL ) + if( this->m_ParametersDialog != NULL ) { - if( this->m_ParametersDialog == NULL ) - this->m_ParametersDialog = new ParametersQtDialog( ); - /* TODO - this->m_ParametersDialog->setTitle( - this->GetClassName( ) + std::string( " basic configuration" ) - ); - */ - this->m_ParametersDialog->setParent( NULL ); this->m_ParametersDialog->setParameters( this->m_Parameters ); - r = ( this->m_ParametersDialog->exec( ) == 1 ); } else r = false; - #endif // cpPlugins_Interface_QT4 - return( r ); } @@ -186,21 +137,25 @@ ExecConfigurationDialog( QWidget* parent ) cpPlugins::Interface::ProcessObject:: ProcessObject( ) : Superclass( ), - m_ITKObject( NULL ), - m_VTKObject( NULL ), - m_ParametersDialog( NULL ), - m_Plugins( NULL ) + m_ParametersDialog( NULL ) { this->m_Parameters = TParameters::New( ); this->m_Parameters->SetProcessObject( this ); + +#ifdef cpPlugins_Interface_QT4 + if( QApplication::instance( ) != NULL ) + this->m_ParametersDialog = new ParametersQtDialog( ); +#endif // cpPlugins_Interface_QT4 } // ------------------------------------------------------------------------- cpPlugins::Interface::ProcessObject:: ~ProcessObject( ) { +#ifdef cpPlugins_Interface_QT4 if( this->m_ParametersDialog != NULL ) delete this->m_ParametersDialog; +#endif // cpPlugins_Interface_QT4 } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/ProcessObject.h b/lib/cpPlugins/Interface/ProcessObject.h index 52b5654..c48d61f 100644 --- a/lib/cpPlugins/Interface/ProcessObject.h +++ b/lib/cpPlugins/Interface/ProcessObject.h @@ -3,13 +3,11 @@ #include +#include + #include #include -#include -#include -#include - // Some forward declarations class vtkRenderWindowInteractor; #ifdef cpPlugins_Interface_QT4 @@ -23,7 +21,6 @@ namespace cpPlugins namespace Interface { // Some forward declarations - class Plugins; #ifdef cpPlugins_Interface_QT4 class ParametersQtDialog; #else @@ -50,31 +47,19 @@ namespace cpPlugins cpPlugins_Id_Macro( ProcessObject, BaseObject ); itkBooleanMacro( Interactive ); + itkGetConstMacro( Interactive, bool ); + itkSetMacro( Interactive, bool ); itkGetConstObjectMacro( Parameters, TParameters ); itkGetObjectMacro( Parameters, TParameters ); - itkGetConstMacro( Plugins, const Plugins* ); - itkGetMacro( Plugins, Plugins* ); - itkGetConstMacro( Interactive, bool ); - - itkSetObjectMacro( Plugins, Plugins ); - itkSetMacro( Interactive, bool ); public: - // To impact pipeline - virtual void Modified( ) const; - - virtual void GetInputsNames( std::set< std::string >& names ) const; - virtual void GetOutputsNames( std::set< std::string >& names ) const; + virtual std::set< std::string > GetInputsNames( ) const; + virtual std::set< std::string > GetOutputsNames( ) const; unsigned int GetNumberOfInputs( ) const; unsigned int GetNumberOfOutputs( ) const; - virtual bool SetOutputObjectName( - const std::string& new_object_name, - const std::string& output_name - ); - - virtual void SetInput( const std::string& id, DataObject* dobj ); + virtual bool SetInput( const std::string& id, DataObject* dobj ); virtual std::string Update( ); virtual void DisconnectOutputs( ); @@ -83,18 +68,6 @@ namespace cpPlugins virtual void AddInteractor( vtkRenderWindowInteractor* interactor ); virtual bool ExecConfigurationDialog( QWidget* parent ); - template< class T > - inline T* GetITK( ); - - template< class T > - inline const T* GetITK( ) const; - - template< class T > - inline T* GetVTK( ); - - template< class T > - inline const T* GetVTK( ) const; - template< class T > inline T* GetInput( const std::string& id ); @@ -113,15 +86,15 @@ namespace cpPlugins virtual void _AddInput( const std::string& name ); + template< class O > + inline void _AddOutput( const std::string& id ); + template< class F > inline F* _CreateITK( ); template< class F > inline F* _CreateVTK( ); - template< class O > - inline void _MakeOutput( const std::string& id ); - virtual std::string _GenerateData( ) = 0; private: @@ -130,19 +103,15 @@ namespace cpPlugins Self& operator=( const Self& ); protected: - itk::ProcessObject::Pointer m_ITKObject; - vtkSmartPointer< vtkAlgorithm > m_VTKObject; - Parameters::Pointer m_Parameters; ParametersQtDialog* m_ParametersDialog; - TInteractors m_Interactors; - Plugins* m_Plugins; - bool m_Interactive; + + TInteractors m_Interactors; + bool m_Interactive; typedef std::map< std::string, DataObject::Pointer > _TDataContainer; _TDataContainer m_Inputs; _TDataContainer m_Outputs; - std::map< std::string, std::string > m_OutputObjectsNames; }; /** diff --git a/lib/cpPlugins/Interface/ProcessObject.hxx b/lib/cpPlugins/Interface/ProcessObject.hxx index 10b4dbe..33b4a20 100644 --- a/lib/cpPlugins/Interface/ProcessObject.hxx +++ b/lib/cpPlugins/Interface/ProcessObject.hxx @@ -1,38 +1,6 @@ #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__ #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__ -// ------------------------------------------------------------------------- -template< class T > -T* cpPlugins::Interface::ProcessObject:: -GetITK( ) -{ - return( dynamic_cast< T* >( this->m_ITKObject.GetPointer( ) ) ); -} - -// ------------------------------------------------------------------------- -template< class T > -const T* cpPlugins::Interface::ProcessObject:: -GetITK( ) const -{ - return( dynamic_cast< const T* >( this->m_ITKObject.GetPointer( ) ) ); -} - -// ------------------------------------------------------------------------- -template< class T > -T* cpPlugins::Interface::ProcessObject:: -GetVTK( ) -{ - return( dynamic_cast< T* >( this->m_VTKObject.GetPointer( ) ) ); -} - -// ------------------------------------------------------------------------- -template< class T > -const T* cpPlugins::Interface::ProcessObject:: -GetVTK( ) const -{ - return( dynamic_cast< const T* >( this->m_VTKObject.GetPointer( ) ) ); -} - // ------------------------------------------------------------------------- template< class T > T* cpPlugins::Interface::ProcessObject:: @@ -81,6 +49,16 @@ GetOutput( const std::string& id ) const return( NULL ); } +// ------------------------------------------------------------------------- +template< class O > +void cpPlugins::Interface::ProcessObject:: +_AddOutput( const std::string& id ) +{ + this->m_Outputs[ id ] = O::New( ); + this->m_Outputs[ id ]->SetSource( this ); + this->Modified( ); +} + // ------------------------------------------------------------------------- template< class F > F* cpPlugins::Interface::ProcessObject:: @@ -114,16 +92,6 @@ _CreateVTK( ) return( filter ); } -// ------------------------------------------------------------------------- -template< class O > -void cpPlugins::Interface::ProcessObject:: -_MakeOutput( const std::string& id ) -{ - this->m_Outputs[ id ] = O::New( ); - this->m_Outputs[ id ]->SetSource( this ); - this->Modified( ); -} - #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx index 55b2eed..fb9d6ea 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx @@ -11,7 +11,7 @@ BinaryErodeImageFilter( ) : Superclass( ) { this->_AddInput( "Input" ); - this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); + this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); this->m_Parameters->ConfigureAsUint( "Radius" ); this->m_Parameters->SetUint( "Radius", 2 ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx index 09ba2c3..1956112 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx @@ -9,7 +9,7 @@ BinaryThresholdImageFilter( ) : Superclass( ) { this->_AddInput( "Input" ); - this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); + this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); this->m_Parameters->ConfigureAsReal( "LowerThresholdValue" ); this->m_Parameters->ConfigureAsReal( "UpperThresholdValue" ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx b/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx index d0907b4..3d3104f 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx @@ -15,7 +15,7 @@ Cutter( ) { this->_AddInput( "InputMesh" ); this->_AddInput( "InputFunction" ); - this->_MakeOutput< cpPlugins::Interface::Mesh >( "Output" ); + this->_AddOutput< cpPlugins::Interface::Mesh >( "Output" ); } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Plugins/BasicFilters/DoubleFloodImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/DoubleFloodImageFilter.cxx index 61ff7d2..aeaa590 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/DoubleFloodImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/DoubleFloodImageFilter.cxx @@ -1,7 +1,5 @@ #include "DoubleFloodImageFilter.h" #include -#include -#include #include #include @@ -21,6 +19,7 @@ DoubleFloodImageFilter_Dialog( : QDialog( parent, f | Qt::WindowStaysOnTopHint ), m_Filter( filter ) { +/* TODO this->m_Title = new QLabel( this ); this->m_Title->setText( "Execute simple vessel segmentation filter" ); @@ -36,21 +35,25 @@ DoubleFloodImageFilter_Dialog( QObject::connect( bb, SIGNAL( accepted( ) ), this, SLOT( accept( ) ) ); QObject::connect( bb, SIGNAL( rejected( ) ), this, SLOT( reject( ) ) ); this->m_ToolsLayout->addWidget( bb ); +*/ } // ------------------------------------------------------------------------- cpPlugins::BasicFilters::DoubleFloodImageFilter_Dialog:: ~DoubleFloodImageFilter_Dialog( ) { +/* delete this->m_Title; delete this->m_ToolsLayout; delete this->m_MainLayout; +*/ } // ------------------------------------------------------------------------- void cpPlugins::BasicFilters::DoubleFloodImageFilter_Dialog:: accept( ) { +/* // Get interactive widget if( this->m_Filter == NULL ) return; @@ -108,18 +111,20 @@ accept( ) app->UpdateActualFilter( ); } // fi +*/ } // ------------------------------------------------------------------------- void cpPlugins::BasicFilters::DoubleFloodImageFilter_Dialog:: reject( ) { +/* auto plugins = this->m_Filter->GetPlugins( ); if( plugins != NULL ) plugins->DeactivateFilter( ); this->Superclass::reject( ); +*/ } - #endif // cpPlugins_Interface_QT4 // ------------------------------------------------------------------------- @@ -127,6 +132,7 @@ cpPlugins::BasicFilters::DoubleFloodImageFilter:: DialogResult cpPlugins::BasicFilters::DoubleFloodImageFilter:: ExecConfigurationDialog( QWidget* parent ) { +/* TODO #ifdef cpPlugins_Interface_QT4 typedef cpExtensions::Interaction::ImageInteractorStyle _TImageStyle; @@ -159,6 +165,8 @@ ExecConfigurationDialog( QWidget* parent ) #else // cpPlugins_Interface_QT4 return( false ); #endif // cpPlugins_Interface_QT4 +*/ + return( false ); } // ------------------------------------------------------------------------- @@ -166,6 +174,7 @@ cpPlugins::BasicFilters::DoubleFloodImageFilter:: DoubleFloodImageFilter( ) : Superclass( ) { + /* TODO this->_AddInput( "Input" ); this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); @@ -180,6 +189,7 @@ DoubleFloodImageFilter( ) this->m_Parameters->SetReal( "Level", 0 ); this->m_Parameters->SetUint( "InsideValue", 255 ); this->m_Parameters->SetUint( "OutsideValue", 0 ); + */ } // ------------------------------------------------------------------------- @@ -192,6 +202,7 @@ cpPlugins::BasicFilters::DoubleFloodImageFilter:: std::string cpPlugins::BasicFilters::DoubleFloodImageFilter:: _GenerateData( ) { + /* TODO cpPlugins::Interface::Image* image = this->GetInput< cpPlugins::Interface::Image >( "Input" ); if( image == NULL ) @@ -203,6 +214,8 @@ _GenerateData( ) else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 ); else r = "DoubleFloodImageFilter: Input image type not supported."; return( r ); + */ + return( "" ); } // ------------------------------------------------------------------------- @@ -210,14 +223,19 @@ template< class I > std::string cpPlugins::BasicFilters::DoubleFloodImageFilter:: _GD0( itk::DataObject* image ) { + /* TODO return( this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >( image ) ); + */ + return( "" ); + } // ------------------------------------------------------------------------- +/* TODO template< class I, class R = float > class cpPlugins_BasicFilters_DoubleFloodImageFilter_Function : public itk::ImageFunction< I, bool, R > @@ -301,12 +319,14 @@ protected: mutable unsigned char m_StartValue; mutable bool m_Start; }; +*/ // ------------------------------------------------------------------------- template< class I, class O > inline std::string cpPlugins::BasicFilters::DoubleFloodImageFilter:: _RealGD( itk::DataObject* image ) { + /* TODO typedef typename O::PixelType _OP; typedef cpPlugins_BasicFilters_DoubleFloodImageFilter_Function< I > _F; typedef itk::FloodFilledImageFunctionConditionalConstIterator< I, _F > _It; @@ -359,6 +379,8 @@ _RealGD( itk::DataObject* image ) } else return( "DoubleFloodImageFilter: output not correctly created." ); + */ + return( "" ); } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/BasicFilters/DoubleFloodImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/DoubleFloodImageFilter.h index 3a887d0..0383c0f 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/DoubleFloodImageFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/DoubleFloodImageFilter.h @@ -18,8 +18,6 @@ namespace cpPlugins #ifdef cpPlugins_Interface_QT4 class DoubleFloodImageFilter; - /** - */ class DoubleFloodImageFilter_Dialog : public QDialog { diff --git a/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx index 5a65ca6..3f566e5 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx @@ -9,7 +9,7 @@ ExtractSliceImageFilter( ) : Superclass( ) { this->_AddInput( "Input" ); - this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); + this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); this->m_Parameters->ConfigureAsUint( "Axis" ); this->m_Parameters->ConfigureAsInt( "Slice" ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/FloodFillImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/FloodFillImageFilter.cxx index 376602b..98b9e58 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/FloodFillImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/FloodFillImageFilter.cxx @@ -1,5 +1,6 @@ #include "FloodFillImageFilter.h" #include +#include #include #include @@ -9,10 +10,11 @@ cpPlugins::BasicFilters::FloodFillImageFilter:: FloodFillImageFilter( ) : Superclass( ) { + /* TODO this->_AddInput( "Input" ); - this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); + this->_AddInput( "Seed" ); + this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); - this->m_Parameters->ConfigureAsPoint( "Seed" ); this->m_Parameters->ConfigureAsReal( "Window" ); this->m_Parameters->ConfigureAsReal( "Level" ); this->m_Parameters->ConfigureAsUint( "InsideValue" ); @@ -22,6 +24,7 @@ FloodFillImageFilter( ) this->m_Parameters->SetReal( "Level", 0 ); this->m_Parameters->SetUint( "InsideValue", 0 ); this->m_Parameters->SetUint( "OutsideValue", 255 ); + */ } // ------------------------------------------------------------------------- @@ -34,6 +37,7 @@ cpPlugins::BasicFilters::FloodFillImageFilter:: std::string cpPlugins::BasicFilters::FloodFillImageFilter:: _GenerateData( ) { + /* TODO cpPlugins::Interface::Image* image = this->GetInput< cpPlugins::Interface::Image >( "Input" ); if( image == NULL ) @@ -45,6 +49,8 @@ _GenerateData( ) else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 ); else r = "FloodFillImageFilter: Input image type not supported."; return( r ); + */ + return( "" ); } // ------------------------------------------------------------------------- @@ -52,14 +58,18 @@ template< class I > std::string cpPlugins::BasicFilters::FloodFillImageFilter:: _GD0( itk::DataObject* image ) { + /* TODO return( this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >( image ) ); + */ + return( "" ); } // ------------------------------------------------------------------------- +/* TODO template< class I, class R = float > class cpPlugins_BasicFilters_FloodFillImageFilter_Function : public itk::ImageFunction< I, bool, R > @@ -143,12 +153,14 @@ protected: mutable unsigned char m_StartValue; mutable bool m_Start; }; +*/ // ------------------------------------------------------------------------- template< class I, class O > inline std::string cpPlugins::BasicFilters::FloodFillImageFilter:: _RealGD( itk::DataObject* image ) { + /* TODO typedef typename O::PixelType _OP; typedef cpPlugins_BasicFilters_FloodFillImageFilter_Function< I > _F; typedef itk::FloodFilledImageFunctionConditionalConstIterator< I, _F > _It; @@ -196,6 +208,8 @@ _RealGD( itk::DataObject* image ) } else return( "FloodFillImageFilter: output not correctly created." ); + */ + return( "" ); } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx index 1f4709c..82449b3 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx @@ -1,8 +1,5 @@ #include "MacheteFilter.h" -#include -#include - #include #include #include @@ -72,27 +69,33 @@ accept( ) wdg->GetCenter( center ); wdg->GetNormal( normal ); - this->m_Filter->GetParameters( )->SetPoint( "PlaneCenter", 3, center ); - this->m_Filter->GetParameters( )->SetVector( "PlaneNormal", 3, normal ); + /* TODO + this->m_Filter->GetParameters( )->SetPoint( "PlaneCenter", 3, center ); + this->m_Filter->GetParameters( )->SetVector( "PlaneNormal", 3, normal ); + */ // Update filter - auto plugins = this->m_Filter->GetPlugins( ); - if( plugins != NULL ) - { - auto app = plugins->GetApplication( ); - if( app != NULL ) - app->UpdateActualFilter( ); - - } // fi + /* TODO + auto plugins = this->m_Filter->GetPlugins( ); + if( plugins != NULL ) + { + auto app = plugins->GetApplication( ); + if( app != NULL ) + app->UpdateActualFilter( ); + + } // fi + */ } // ------------------------------------------------------------------------- void cpPlugins::BasicFilters::MacheteFilter_Dialog:: reject( ) { + /* auto plugins = this->m_Filter->GetPlugins( ); if( plugins != NULL ) plugins->DeactivateFilter( ); + */ this->Superclass::reject( ); } @@ -192,11 +195,13 @@ MacheteFilter( ) m_PlaneWidget( NULL ) { this->_AddInput( "Input" ); - this->_MakeOutput< cpPlugins::Interface::DataObject >( "PositiveOutput" ); - this->_MakeOutput< cpPlugins::Interface::DataObject >( "NegativeOutput" ); + this->_AddOutput< cpPlugins::Interface::DataObject >( "PositiveOutput" ); + this->_AddOutput< cpPlugins::Interface::DataObject >( "NegativeOutput" ); + /* this->m_Parameters->ConfigureAsPoint( "PlaneCenter" ); this->m_Parameters->ConfigureAsVector( "PlaneNormal" ); + */ } // ------------------------------------------------------------------------- @@ -260,12 +265,16 @@ _RealImage( itk::DataObject* dobj ) I* image = dynamic_cast< I* >( dobj ); + /* _TPoint c = this->m_Parameters->GetPoint< _TPoint >( "PlaneCenter", I::ImageDimension ); _TVector n = this->m_Parameters->GetVector< _TVector >( "PlaneNormal", I::ImageDimension ); + */ + _TPoint c; + _TVector n; typename _TPlane::Pointer plane = _TPlane::New( ); plane->SetCenter( c ); @@ -286,7 +295,7 @@ _RealImage( itk::DataObject* dobj ) _TImage* pos_out = this->GetOutput< _TImage >( "PositiveOutput" ); if( pos_out == NULL ) { - this->_MakeOutput< _TImage >( "PositiveOutput" ); + this->_AddOutput< _TImage >( "PositiveOutput" ); pos_out = this->GetOutput< _TImage >( "PositiveOutput" ); pos_out->SetName( pos_name ); @@ -294,7 +303,7 @@ _RealImage( itk::DataObject* dobj ) _TImage* neg_out = this->GetOutput< _TImage >( "NegativeOutput" ); if( neg_out == NULL ) { - this->_MakeOutput< _TImage >( "NegativeOutput" ); + this->_AddOutput< _TImage >( "NegativeOutput" ); neg_out = this->GetOutput< _TImage >( "NegativeOutput" ); neg_out->SetName( neg_name ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.cxx index e40ecb1..980ba8d 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.cxx @@ -12,8 +12,8 @@ cpPlugins::BasicFilters::MacheteImageFilter:: MacheteImageFilter() : Superclass() { - this->_AddInput("Input"); - this->_MakeOutput< cpPlugins::Interface::Image >("Output"); + this->_AddInput( "Input" ); + this->_AddOutput< cpPlugins::Interface::Image >("Output"); this->m_Parameters->ConfigureAsReal("Radius"); //this->m_Parameters->ConfigureAsPoint("Point", 3, 3); diff --git a/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.h index e0208de..1ac3df9 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.h @@ -14,7 +14,7 @@ namespace cpPlugins : public cpPlugins::Interface::ImageToImageFilter { public: - typedef MacheteImageFilter Self; + typedef MacheteImageFilter Self; typedef cpPlugins::Interface::ImageToImageFilter Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; diff --git a/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx index 51bc937..ce6aa32 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx @@ -12,7 +12,7 @@ MarchingCubes( ) : Superclass( ) { this->_AddInput( "Input" ); - this->_MakeOutput< cpPlugins::Interface::Mesh >( "Output" ); + this->_AddOutput< cpPlugins::Interface::Mesh >( "Output" ); this->m_Parameters->ConfigureAsRealList( "Thresholds" ); } diff --git a/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx index da2f7f3..a74714c 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx @@ -9,7 +9,7 @@ MedianImageFilter( ) : Superclass( ) { this->_AddInput( "Input" ); - this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); + this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); this->m_Parameters->ConfigureAsUint( "Radius" ); this->m_Parameters->SetUint( "Radius", 3 ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx index ed8b95a..dd2bd1c 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx @@ -9,7 +9,7 @@ OtsuThresholdImageFilter( ) : Superclass( ) { this->_AddInput( "Input" ); - this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); + this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); this->m_Parameters->ConfigureAsUint( "NumberOfHistogramBins" ); this->m_Parameters->ConfigureAsUint( "InsideValue" ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx index 13e6732..433c0fa 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx @@ -14,7 +14,7 @@ RGBImageToOtherChannelsFilter( ) typedef cpPlugins::Interface::Parameters TParameters; this->_AddInput( "Input" ); - this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); + this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); std::vector< std::string > choices; choices.push_back( "HSV" ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/SignedMaurerDistanceMapImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/SignedMaurerDistanceMapImageFilter.cxx index c8740cd..1478555 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/SignedMaurerDistanceMapImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/SignedMaurerDistanceMapImageFilter.cxx @@ -9,7 +9,7 @@ SignedMaurerDistanceMapImageFilter( ) : Superclass( ) { this->_AddInput( "Input" ); - this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); + this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); this->m_Parameters->ConfigureAsReal( "BackgroundValue" ); this->m_Parameters->ConfigureAsBool( "InsideIsPositive" ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx b/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx index 2ed0b7d..cad8eb8 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx @@ -10,9 +10,9 @@ cpPlugins::BasicFilters::SphereMeshSource:: SphereMeshSource( ) : Superclass( ) { - this->_MakeOutput< cpPlugins::Interface::Mesh >( "Output" ); + this->_AddInput( "Center" ); + this->_AddOutput< cpPlugins::Interface::Mesh >( "Output" ); - this->m_Parameters->ConfigureAsPoint( "Center" ); this->m_Parameters->ConfigureAsReal( "Radius" ); this->m_Parameters->ConfigureAsUint( "PhiResolution" ); this->m_Parameters->ConfigureAsUint( "ThetaResolution" ); @@ -32,9 +32,12 @@ cpPlugins::BasicFilters::SphereMeshSource:: std::string cpPlugins::BasicFilters::SphereMeshSource:: _GenerateData( ) { - itk::Point< double, 3 > center = - this->m_Parameters->GetPoint< itk::Point< double, 3 > >( "Center", 3 ); - // TODO: center.Fill( double( 0 ) ); // TODO + itk::Point< double, 3 > center; + center.Fill( double( 0 ) ); + /* TODO + itk::Point< double, 3 > center = + this->m_Parameters->GetPoint< itk::Point< double, 3 > >( "Center", 3 ); + */ double radius = this->m_Parameters->GetReal( "Radius" ); unsigned int phi = this->m_Parameters->GetUint( "PhiResolution" ); unsigned int theta = this->m_Parameters->GetUint( "ThetaResolution" ); diff --git a/lib/cpPlugins/Plugins/IO/ImageReader.cxx b/lib/cpPlugins/Plugins/IO/ImageReader.cxx index e1f3c66..d2d619c 100644 --- a/lib/cpPlugins/Plugins/IO/ImageReader.cxx +++ b/lib/cpPlugins/Plugins/IO/ImageReader.cxx @@ -56,7 +56,7 @@ cpPlugins::IO::ImageReader:: ImageReader( ) : Superclass( ) { - this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); + this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); this->m_Parameters->ConfigureAsOpenFileNameList( "FileNames" ); this->m_Parameters->ConfigureAsBool( "VectorType" ); diff --git a/lib/cpPlugins/Plugins/IO/MeshReader.cxx b/lib/cpPlugins/Plugins/IO/MeshReader.cxx index 473686d..27d8f55 100644 --- a/lib/cpPlugins/Plugins/IO/MeshReader.cxx +++ b/lib/cpPlugins/Plugins/IO/MeshReader.cxx @@ -45,7 +45,7 @@ cpPlugins::IO::MeshReader:: MeshReader( ) : Superclass( ) { - this->_MakeOutput< cpPlugins::Interface::Mesh >( "Output" ); + this->_AddOutput< cpPlugins::Interface::Mesh >( "Output" ); std::vector< TParameters::TString > valid_types; valid_types.push_back( "float" ); diff --git a/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx b/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx index 129a8a6..147527e 100644 --- a/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx +++ b/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx @@ -13,7 +13,7 @@ SeedWidget( ) m_Configured( false ) { this->_AddInput( "ReferenceImage" ); - this->_MakeOutput< cpPlugins::Interface::PointList >( "Output" ); + this->_AddOutput< cpPlugins::Interface::PointList >( "Output" ); this->m_Parameters->ConfigureAsBool( "SeedsAreInRealSpace" ); this->m_Parameters->SetBool( "SeedsAreInRealSpace", true ); -- 2.45.1