From: Leonardo Florez-Valencia Date: Thu, 21 Jan 2016 23:47:23 +0000 (-0500) Subject: ... X-Git-Tag: v0.1~263 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=7caa01f9eacc4861ba7d5d9ed16872d60328088f;p=cpPlugins.git ... --- diff --git a/appli/cpPipelineEditor/App_cpPipelineEditor.cxx b/appli/cpPipelineEditor/App_cpPipelineEditor.cxx index 78318a9..6af4723 100644 --- a/appli/cpPipelineEditor/App_cpPipelineEditor.cxx +++ b/appli/cpPipelineEditor/App_cpPipelineEditor.cxx @@ -58,10 +58,7 @@ App_cpPipelineEditor( int argc, char* argv[], QWidget* parent ) this->m_Workspace = new cpPlugins::Interface::Workspace( ); this->m_Workspace->SetPlugins( this->m_Plugins ); this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace ); - 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 ) ); + this->m_Workspace->SetMPRViewer( this->m_UI->Viewer ); // Connect actions to slots App_cpPipelineEditor_ConnectButton( LoadPluginsFile ); @@ -233,10 +230,7 @@ _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 ) ); + this->m_Workspace->SetMPRViewer( this->m_UI->Viewer ); std::string err = this->m_Workspace->LoadWorkspace( fname ); if( err != "" ) { diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index 7ed9dfc..f665e09 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -3,6 +3,7 @@ #ifdef cpPlugins_Interface_QT4 #include #include +#include #endif // cpPlugins_Interface_QT4 #include @@ -98,21 +99,47 @@ DisconnectOutputs( ) } // ------------------------------------------------------------------------- -const cpPlugins::Interface::ProcessObject:: -TInteractors& cpPlugins::Interface::ProcessObject:: -GetInteractors( ) const +vtkRenderWindowInteractor* cpPlugins::Interface::ProcessObject:: +GetSingleInteractor( ) { - return( this->m_Interactors ); + return( this->m_SingleInteractor ); +} + +// ------------------------------------------------------------------------- +const vtkRenderWindowInteractor* cpPlugins::Interface::ProcessObject:: +GetSingleInteractor( ) const +{ + return( this->m_SingleInteractor ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: -AddInteractor( vtkRenderWindowInteractor* interactor ) +SetSingleInteractor( vtkRenderWindowInteractor* interactor ) { - this->m_Interactors.insert( interactor ); -#ifdef cpPlugins_Interface_QT4 - this->m_ParametersDialog->addInteractor( interactor ); -#endif // cpPlugins_Interface_QT4 + this->m_SingleInteractor = interactor; +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface:: +SimpleMPRWidget* cpPlugins::Interface::ProcessObject:: +GetMPRViewer( ) +{ + return( this->m_MPRViewer ); +} + +// ------------------------------------------------------------------------- +const cpPlugins::Interface:: +SimpleMPRWidget* cpPlugins::Interface::ProcessObject:: +GetMPRViewer( ) const +{ + return( this->m_MPRViewer ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::Interface::ProcessObject:: +SetMPRViewer( cpPlugins::Interface::SimpleMPRWidget* wdg ) +{ + this->m_MPRViewer = wdg; } // ------------------------------------------------------------------------- @@ -137,7 +164,8 @@ ExecConfigurationDialog( QWidget* parent ) cpPlugins::Interface::ProcessObject:: ProcessObject( ) : Superclass( ), - m_ParametersDialog( NULL ) + m_ParametersDialog( NULL ), + m_MPRViewer( NULL ) { this->m_Parameters = TParameters::New( ); this->m_Parameters->SetProcessObject( this ); diff --git a/lib/cpPlugins/Interface/ProcessObject.h b/lib/cpPlugins/Interface/ProcessObject.h index c48d61f..ddd1c21 100644 --- a/lib/cpPlugins/Interface/ProcessObject.h +++ b/lib/cpPlugins/Interface/ProcessObject.h @@ -23,8 +23,10 @@ namespace cpPlugins // Some forward declarations #ifdef cpPlugins_Interface_QT4 class ParametersQtDialog; + class SimpleMPRWidget; #else typedef char ParametersQtDialog; + typedef char SimpleMPRWidget; #endif // cpPlugins_Interface_QT4 /** @@ -64,8 +66,13 @@ namespace cpPlugins virtual std::string Update( ); virtual void DisconnectOutputs( ); - virtual const TInteractors& GetInteractors( ) const; - virtual void AddInteractor( vtkRenderWindowInteractor* interactor ); + // Widgets management + vtkRenderWindowInteractor* GetSingleInteractor( ); + const vtkRenderWindowInteractor* GetSingleInteractor( ) const; + void SetSingleInteractor( vtkRenderWindowInteractor* interactor ); + SimpleMPRWidget* GetMPRViewer( ); + const SimpleMPRWidget* GetMPRViewer( ) const; + void SetMPRViewer( SimpleMPRWidget* wdg ); virtual bool ExecConfigurationDialog( QWidget* parent ); template< class T > @@ -106,8 +113,9 @@ namespace cpPlugins Parameters::Pointer m_Parameters; ParametersQtDialog* m_ParametersDialog; - TInteractors m_Interactors; - bool m_Interactive; + vtkSmartPointer< vtkRenderWindowInteractor > m_SingleInteractor; + SimpleMPRWidget* m_MPRViewer; + bool m_Interactive; typedef std::map< std::string, DataObject::Pointer > _TDataContainer; _TDataContainer m_Inputs; diff --git a/lib/cpPlugins/Interface/SimpleMPRWidget.cxx b/lib/cpPlugins/Interface/SimpleMPRWidget.cxx index 7906883..3c97e40 100644 --- a/lib/cpPlugins/Interface/SimpleMPRWidget.cxx +++ b/lib/cpPlugins/Interface/SimpleMPRWidget.cxx @@ -7,6 +7,8 @@ #include #include // TODO: #include + +#include #include double cpPlugins::Interface::SimpleMPRWidget:: @@ -94,6 +96,25 @@ AddData( // Add new data this->m_Data[ name ].SetSourceDataObject( data ); + // Set color + auto iIt = this->m_Data.find( name ); + if( iIt != this->m_Data.end( ) ) + { + vtkActor* actor = + dynamic_cast< vtkActor* >( iIt->second.GetMeshActor( ) ); + if( actor != NULL ) + { + unsigned int idx = this->m_Data.size( ) % 8; + actor->GetProperty( )->SetColor( + Self::cm_Colors[ idx ][ 0 ], + Self::cm_Colors[ idx ][ 1 ], + Self::cm_Colors[ idx ][ 2 ] + ); + + } // fi + + } // fi + // Add to tree view // TODO: this->_UpdateTreeItem( name, parent ); return( true ); @@ -225,14 +246,14 @@ ShowData( const std::string& name ) } 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( ); - */ + 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 } diff --git a/lib/cpPlugins/Interface/Workspace.cxx b/lib/cpPlugins/Interface/Workspace.cxx index 528f774..ab1891a 100644 --- a/lib/cpPlugins/Interface/Workspace.cxx +++ b/lib/cpPlugins/Interface/Workspace.cxx @@ -1,9 +1,12 @@ #include +#include +#include // ------------------------------------------------------------------------- cpPlugins::Interface::Workspace:: Workspace( ) - : m_Plugins( NULL ) + : m_Plugins( NULL ), + m_MPRViewer( NULL ) { this->m_Graph = TGraph::New( ); } @@ -116,12 +119,8 @@ CreateFilter( const std::string& filter, const std::string& name ) if( f.IsNotNull( ) ) { f->SetName( name ); - for( - auto iIt = this->m_Interactors.begin( ); - iIt != this->m_Interactors.end( ); - ++iIt - ) - f->AddInteractor( *iIt ); + f->SetSingleInteractor( this->m_SingleInteractor ); + f->SetMPRViewer( this->m_MPRViewer ); TObject::Pointer o = f.GetPointer( ); this->m_Graph->SetVertex( name, o ); @@ -155,18 +154,47 @@ RemoveFilter( const std::string& name ) } // ------------------------------------------------------------------------- -const cpPlugins::Interface::Workspace:: -TInteractors& cpPlugins::Interface::Workspace:: -GetInteractors( ) const +vtkRenderWindowInteractor* cpPlugins::Interface::Workspace:: +GetSingleInteractor( ) +{ + return( this->m_SingleInteractor ); +} + +// ------------------------------------------------------------------------- +const vtkRenderWindowInteractor* cpPlugins::Interface::Workspace:: +GetSingleInteractor( ) const +{ + return( this->m_SingleInteractor ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::Interface::Workspace:: +SetSingleInteractor( vtkRenderWindowInteractor* interactor ) +{ + this->m_SingleInteractor = interactor; +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface:: +SimpleMPRWidget* cpPlugins::Interface::Workspace:: +GetMPRViewer( ) +{ + return( this->m_MPRViewer ); +} + +// ------------------------------------------------------------------------- +const cpPlugins::Interface:: +SimpleMPRWidget* cpPlugins::Interface::Workspace:: +GetMPRViewer( ) const { - return( this->m_Interactors ); + return( this->m_MPRViewer ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::Workspace:: -AddInteractor( vtkRenderWindowInteractor* interactor ) +SetMPRViewer( cpPlugins::Interface::SimpleMPRWidget* wdg ) { - this->m_Interactors.insert( interactor ); + this->m_MPRViewer = wdg; } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/Workspace.h b/lib/cpPlugins/Interface/Workspace.h index 3d78f02..5df33ae 100644 --- a/lib/cpPlugins/Interface/Workspace.h +++ b/lib/cpPlugins/Interface/Workspace.h @@ -17,6 +17,13 @@ namespace cpPlugins { namespace Interface { + // Some forward declarations +#ifdef cpPlugins_Interface_QT4 + class SimpleMPRWidget; +#else // cpPlugins_Interface_QT4 + typedef char SimpleMPRWidget; +#endif // cpPlugins_Interface_QT4 + /** \brief A complex pipeline */ class cpPlugins_Interface_EXPORT Workspace @@ -32,7 +39,6 @@ namespace cpPlugins typedef std::set< std::string > TStringContainer; typedef std::pair< std::string, std::string > TExposedPort; typedef std::map< std::string, TExposedPort > TExposedPorts; - typedef std::set< vtkRenderWindowInteractor* > TInteractors; // Graph type typedef std::pair< std::string, std::string > TConnection; @@ -71,8 +77,13 @@ namespace cpPlugins void RemoveFilter( const std::string& name ); // Widgets management - virtual const TInteractors& GetInteractors( ) const; - virtual void AddInteractor( vtkRenderWindowInteractor* interactor ); + vtkRenderWindowInteractor* GetSingleInteractor( ); + const vtkRenderWindowInteractor* GetSingleInteractor( ) const; + void SetSingleInteractor( vtkRenderWindowInteractor* interactor ); + + SimpleMPRWidget* GetMPRViewer( ); + const SimpleMPRWidget* GetMPRViewer( ) const; + void SetMPRViewer( SimpleMPRWidget* wdg ); // Connection management bool Connect( @@ -129,7 +140,8 @@ namespace cpPlugins TExposedPorts m_ExposedInputPorts; TExposedPorts m_ExposedOutputPorts; - TInteractors m_Interactors; + vtkSmartPointer< vtkRenderWindowInteractor > m_SingleInteractor; + SimpleMPRWidget* m_MPRViewer; }; } // ecapseman diff --git a/lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx index 82449b3..71b3af4 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx @@ -112,6 +112,7 @@ ExecConfigurationDialog( QWidget* parent ) // Choose a valid 3D interactor vtkRenderWindowInteractor* iren = NULL; + /* TODO auto iIt = this->m_Interactors.begin( ); for( ; iIt != this->m_Interactors.end( ) && iren == NULL; ++iIt ) { @@ -123,6 +124,7 @@ ExecConfigurationDialog( QWidget* parent ) iren = *iIt; } // rof + */ if( iren == NULL ) return( false ); diff --git a/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx b/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx index 147527e..8dbaf9f 100644 --- a/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx +++ b/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -65,6 +66,61 @@ _GD0( itk::DataObject* image ) unsigned int dim = ( I::ImageDimension < 3 )? I::ImageDimension: 3; out->Clear( ); + + // MPR + if( this->m_MPRViewer != NULL ) + { + for( unsigned int i = 0; i < 4; ++i ) + { + _S* s = + dynamic_cast< _S* >( + this->m_MPRViewer->GetInteractor( i )->GetInteractorStyle( ) + ); + if( s != NULL ) + { + if( this->m_Configured ) + { + for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i ) + { + s->GetSeedAsPoint( i, aux_pnt ); + typename I::PointType seed; + for( unsigned int d = 0; d < dim; ++d ) + seed[ d ] = aux_pnt[ d ]; + out->AddPoint( seed ); + + } // rof + } + else + s->SeedWidgetOn( ); + + } // fi + + } // rof + + } // fi + + // Single interactor + _S* s = dynamic_cast< _S* >( this->m_SingleInteractor.GetPointer( ) ); + if( s != NULL ) + { + if( this->m_Configured ) + { + for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i ) + { + s->GetSeedAsPoint( i, aux_pnt ); + typename I::PointType seed; + for( unsigned int d = 0; d < dim; ++d ) + seed[ d ] = aux_pnt[ d ]; + out->AddPoint( seed ); + + } // rof + } + else + s->SeedWidgetOn( ); + + } // fi + + /* TODO auto iIt = this->m_Interactors.begin( ); for( ; iIt != this->m_Interactors.end( ); ++iIt ) { @@ -89,6 +145,7 @@ _GD0( itk::DataObject* image ) } // fi } // rof + */ this->m_Configured = true; return( "" ); }