]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 21 Jan 2016 23:47:23 +0000 (18:47 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 21 Jan 2016 23:47:23 +0000 (18:47 -0500)
appli/cpPipelineEditor/App_cpPipelineEditor.cxx
lib/cpPlugins/Interface/ProcessObject.cxx
lib/cpPlugins/Interface/ProcessObject.h
lib/cpPlugins/Interface/SimpleMPRWidget.cxx
lib/cpPlugins/Interface/Workspace.cxx
lib/cpPlugins/Interface/Workspace.h
lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx
lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx

index 78318a9a674241aad4cd1172a9aebde2196d04da..6af4723eb068421654ea6a23a6e63ce3f0823123 100644 (file)
@@ -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 != "" )
   {
index 7ed9dfc01732f45c1b51c985a416e27334f683ed..f665e091ab89e06a12ed328ea8ac9e8e274d2acf 100644 (file)
@@ -3,6 +3,7 @@
 #ifdef cpPlugins_Interface_QT4
 #include <QApplication>
 #include <cpPlugins/Interface/ParametersQtDialog.h>
+#include <cpPlugins/Interface/SimpleMPRWidget.h>
 #endif // cpPlugins_Interface_QT4
 
 #include <vtkRenderWindowInteractor.h>
@@ -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 );
index c48d61f3e36ab0f201c30aeac8a8f71b89640473..ddd1c21aa150ad2cd38987e82ad1bfb4f76d3677 100644 (file)
@@ -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;
index 790688386333477bfd2a8ef777eecf24229f731d..3c97e409247be31045733b9ed15812b6200ccb42 100644 (file)
@@ -7,6 +7,8 @@
 #include <cpPlugins/Interface/Image.h>
 #include <cpPlugins/Interface/Mesh.h>
 // TODO: #include <QTreeWidgetItem>
+
+#include <vtkProperty.h>
 #include <vtkRendererCollection.h>
 
 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
 }
 
index 528f7741feff56af59f207ea8a4396f10d834880..ab1891a1cd073859e0467c11e431e61677c50704 100644 (file)
@@ -1,9 +1,12 @@
 #include <cpPlugins/Interface/Workspace.h>
+#include <cpPlugins/Interface/SimpleMPRWidget.h>
+#include <vtkRenderWindowInteractor.h>
 
 // -------------------------------------------------------------------------
 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;
 }
 
 // -------------------------------------------------------------------------
index 3d78f0246d834563406427f420425f174f33fa99..5df33aed50be46bcaf12e6c656dbd0581b974123 100644 (file)
@@ -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
index 82449b388a4d45f7f8a69c8c65bbacef684af206..71b3af481495376306fb099683b047d7897e9858 100644 (file)
@@ -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 );
   
index 147527eddf6264c1263e01d9d11b24f215d3736a..8dbaf9fe96ddcd372fb098cd5e409b8c41ab989e 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <cpPlugins/Interface/Image.h>
 #include <cpPlugins/Interface/PointList.h>
+#include <cpPlugins/Interface/SimpleMPRWidget.h>
 #include <cpExtensions/Interaction/ImageInteractorStyle.h>
 
 #include <vtkRenderWindowInteractor.h>
@@ -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( "" );
 }