]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 19 Jan 2016 22:53:41 +0000 (17:53 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 19 Jan 2016 22:53:41 +0000 (17:53 -0500)
33 files changed:
appli/ImageMPR/ImageMPR.cxx
appli/cpPipelineEditor/App_cpPipelineEditor.cxx
appli/cpPipelineEditor/App_cpPipelineEditor.h
appli/cpPipelineEditor/App_cpPipelineEditor.ui
lib/cpExtensions/Interaction/ImageInteractorStyle.cxx
lib/cpExtensions/Interaction/ImageInteractorStyle.h
lib/cpPipelineEditor/Block.cxx
lib/cpPipelineEditor/Block.h
lib/cpPipelineEditor/Editor.cxx
lib/cpPipelineEditor/Editor.h
lib/cpPipelineEditor/Port.cxx
lib/cpPipelineEditor/Port.h
lib/cpPlugins/Interface/Parameters.h
lib/cpPlugins/Interface/ParametersQtDialog.cxx
lib/cpPlugins/Interface/ParametersQtDialog.h
lib/cpPlugins/Interface/Plugins.cxx
lib/cpPlugins/Interface/PointList.cxx [new file with mode: 0644]
lib/cpPlugins/Interface/PointList.h [new file with mode: 0644]
lib/cpPlugins/Interface/PointList.hxx [new file with mode: 0644]
lib/cpPlugins/Interface/ProcessObject.cxx
lib/cpPlugins/Interface/ProcessObject.h
lib/cpPlugins/Interface/SimpleMPRWidget.cxx
lib/cpPlugins/Interface/SimpleMPRWidget.h
lib/cpPlugins/Interface/Workspace.cxx
lib/cpPlugins/Interface/Workspace.h
lib/cpPlugins/Plugins/BasicFilters/DoubleFloodImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx
lib/cpPlugins/Plugins/CMakeLists.txt
lib/cpPlugins/Plugins/IO/DicomSeriesReader.cxx
lib/cpPlugins/Plugins/IO/DicomSeriesReader.h
lib/cpPlugins/Plugins/Widgets/CMakeLists.txt [new file with mode: 0644]
lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx [new file with mode: 0644]
lib/cpPlugins/Plugins/Widgets/SeedWidget.h [new file with mode: 0644]

index ea198acda42c4be080aef61fc2a5bc58e223caf8..c7921b1924966bbe3fb775e17562b569d03da8e6 100644 (file)
@@ -240,13 +240,13 @@ _execPlugin( )
 
   // Configure paramereters
   auto dlg_res = this->m_Plugins.ConfigureActiveFilter( );
-  if( dlg_res == TPlugins::TProcessObject::DialogResult_Cancel )
+  if( !dlg_res )
   {
     // Just deactivate filter, since it was canceled
     this->m_Plugins.DeactivateFilter( );
     return;
   }
-  else if( dlg_res == TPlugins::TProcessObject::DialogResult_NoModal )
+  else
   {
     // Execute automatic filter and associate outputs
     this->UpdateActualFilter( );
index 8c0a1559a9319eb9a23f8562f49d290c34414b9b..864d96fb99f7ebaabd075c3baf164caae633f6d3 100644 (file)
@@ -5,18 +5,23 @@
 
 #include <QFileDialog>
 #include <QMessageBox>
+
+#include <vtkImageData.h>
+#include <vtkPolyData.h>
+
 #include <cpPlugins/Interface/Workspace.h>
+#include <cpPlugins/Interface/DataObject.h>
 
 // -------------------------------------------------------------------------
 #define App_cpPipelineEditor_ConnectAction( ACTION )    \
-  QObject::connect(                                     \
+  this->connect(                                        \
     this->m_UI->Action##ACTION, SIGNAL( triggered( ) ), \
     this, SLOT( _Action##ACTION( ) )                    \
     )
 
 // -------------------------------------------------------------------------
 #define App_cpPipelineEditor_ConnectButton( BUTTON )    \
-  QObject::connect(                                     \
+  this->connect(                                        \
     this->m_UI->Button##BUTTON, SIGNAL( clicked( ) ),   \
     this, SLOT( _Button##BUTTON( ) )                    \
     )
@@ -52,12 +57,28 @@ 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 ) );
 
   // Connect actions to slots
   App_cpPipelineEditor_ConnectButton( LoadPluginsFile );
   App_cpPipelineEditor_ConnectButton( LoadPluginsPath );
   App_cpPipelineEditor_ConnectAction( OpenWorkspace );
   App_cpPipelineEditor_ConnectAction( SaveWorkspace );
+  this->connect(
+    this->m_UI->Canvas->editor( ),
+    SIGNAL( execFilter( const std::string& ) ),
+    this,
+    SLOT( _ExecFilter( const std::string& ) )
+    );
+  this->connect(
+    this->m_UI->Canvas->editor( ),
+    SIGNAL( showFilterOutput( const std::string&, const std::string& ) ),
+    this,
+    SLOT( _ShowFilterOutput( const std::string&, const std::string& ) )
+    );
 }
 
 // -------------------------------------------------------------------------
@@ -252,4 +273,62 @@ _ActionSaveWorkspace( )
       );
 }
 
+
+// -------------------------------------------------------------------------
+void App_cpPipelineEditor::
+_ExecFilter( const std::string& filter_name )
+{
+  if( this->m_Workspace != NULL )
+  {
+    // Update filter, if needed
+    std::string err = this->m_Workspace->Execute( filter_name );
+    if( err != "" )
+      QMessageBox::critical(
+        this,
+        QMessageBox::tr( "Error executing filter" ),
+        QMessageBox::tr( err.c_str( ) )
+        );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+void App_cpPipelineEditor::
+_ShowFilterOutput(
+  const std::string& filter_name, const std::string& output_name
+  )
+{
+  typedef cpPlugins::Interface::DataObject _TDataObject;
+
+  // Update filter, if needed
+  this->_ExecFilter( filter_name );
+
+  // Get output
+  auto filter = this->m_Workspace->GetFilter( filter_name );
+  if( filter != NULL )
+  {
+    auto output = filter->GetOutput< _TDataObject >( output_name );
+    if( output != NULL )
+    {
+      std::string data_name = output_name + "@" + filter_name;
+      if( this->m_UI->Viewer->AddData( output, data_name, "" ) )
+      {
+        if( this->m_UI->Viewer->GetNumberOfData( ) > 1 )
+          this->m_UI->Viewer->SetDataColor( data_name, 1, 0, 0 );
+        else
+          this->m_UI->Viewer->SetMainImage( data_name );
+        this->m_UI->Viewer->ShowData( data_name );
+      }
+      else
+        QMessageBox::critical(
+          this,
+          QMessageBox::tr( "Error showing data" ),
+          QMessageBox::tr( "No known VTK conversion!" )
+          );
+
+    } // fi
+
+  } // fi
+}
+
 // eof - $RCSfile$
index 9d0d99a1998d91b48daf1c3caee3a2e4d87554ed..831ef36155b4e9e955abf1211157285e104ef898 100644 (file)
@@ -45,6 +45,10 @@ protected slots:
   void _ButtonLoadPluginsPath( );
   void _ActionOpenWorkspace( );
   void _ActionSaveWorkspace( );
+  void _ExecFilter( const std::string& filter_name );
+  void _ShowFilterOutput(
+    const std::string& filter_name, const std::string& output_name
+    );
 
 private:
   Ui::App_cpPipelineEditor* m_UI;
index faf921784bbe044e61d5e7e178bc5f056ceb9eee..f54b6fd1795366c3797234f252765cec9c74af57 100644 (file)
   <widget class="QWidget" name="MainWidget">
    <layout class="QGridLayout" name="gridLayout">
     <item row="0" column="0">
-     <widget class="QSplitter" name="splitter">
+     <widget class="QSplitter" name="splitter_2">
       <property name="orientation">
-       <enum>Qt::Horizontal</enum>
+       <enum>Qt::Vertical</enum>
       </property>
-      <widget class="QFrame" name="frame">
+      <widget class="cpPlugins::Interface::SimpleMPRWidget" name="Viewer" native="true">
        <property name="minimumSize">
         <size>
-         <width>251</width>
-         <height>331</height>
+         <width>0</width>
+         <height>200</height>
         </size>
        </property>
-       <property name="frameShape">
-        <enum>QFrame::StyledPanel</enum>
-       </property>
-       <property name="frameShadow">
-        <enum>QFrame::Raised</enum>
-       </property>
-       <layout class="QVBoxLayout" name="verticalLayout">
-        <item>
-         <widget class="QGroupBox" name="groupBox">
-          <property name="minimumSize">
-           <size>
-            <width>202</width>
-            <height>67</height>
-           </size>
-          </property>
-          <property name="maximumSize">
-           <size>
-            <width>202</width>
-            <height>67</height>
-           </size>
-          </property>
-          <property name="title">
-           <string>Plugins</string>
-          </property>
-          <layout class="QHBoxLayout" name="horizontalLayout">
-           <item>
-            <widget class="QPushButton" name="ButtonLoadPluginsFile">
-             <property name="minimumSize">
-              <size>
-               <width>85</width>
-               <height>31</height>
-              </size>
-             </property>
-             <property name="maximumSize">
-              <size>
-               <width>85</width>
-               <height>31</height>
-              </size>
-             </property>
-             <property name="text">
-              <string>File</string>
-             </property>
-            </widget>
-           </item>
-           <item>
-            <widget class="QPushButton" name="ButtonLoadPluginsPath">
-             <property name="minimumSize">
-              <size>
-               <width>85</width>
-               <height>31</height>
-              </size>
-             </property>
-             <property name="maximumSize">
-              <size>
-               <width>85</width>
-               <height>31</height>
-              </size>
-             </property>
-             <property name="text">
-              <string>Path</string>
-             </property>
-            </widget>
-           </item>
-          </layout>
-         </widget>
-        </item>
-        <item>
-         <widget class="QTreeWidget" name="LoadedPlugins">
-          <property name="minimumSize">
-           <size>
-            <width>229</width>
-            <height>0</height>
-           </size>
-          </property>
-          <property name="dragEnabled">
-           <bool>true</bool>
-          </property>
-          <property name="dragDropMode">
-           <enum>QAbstractItemView::DragOnly</enum>
-          </property>
-          <column>
-           <property name="text">
-            <string>Loaded plugins</string>
-           </property>
-          </column>
-         </widget>
-        </item>
-       </layout>
       </widget>
-      <widget class="cpPipelineEditor::Canvas" name="Canvas" native="true">
-       <property name="minimumSize">
-        <size>
-         <width>500</width>
-         <height>0</height>
-        </size>
-       </property>
-       <property name="acceptDrops">
-        <bool>true</bool>
+      <widget class="QSplitter" name="splitter">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
        </property>
+       <widget class="QFrame" name="frame">
+        <property name="minimumSize">
+         <size>
+          <width>251</width>
+          <height>331</height>
+         </size>
+        </property>
+        <property name="frameShape">
+         <enum>QFrame::StyledPanel</enum>
+        </property>
+        <property name="frameShadow">
+         <enum>QFrame::Raised</enum>
+        </property>
+        <layout class="QVBoxLayout" name="verticalLayout">
+         <item>
+          <widget class="QGroupBox" name="groupBox">
+           <property name="minimumSize">
+            <size>
+             <width>202</width>
+             <height>67</height>
+            </size>
+           </property>
+           <property name="maximumSize">
+            <size>
+             <width>202</width>
+             <height>67</height>
+            </size>
+           </property>
+           <property name="title">
+            <string>Plugins</string>
+           </property>
+           <layout class="QHBoxLayout" name="horizontalLayout">
+            <item>
+             <widget class="QPushButton" name="ButtonLoadPluginsFile">
+              <property name="minimumSize">
+               <size>
+                <width>85</width>
+                <height>31</height>
+               </size>
+              </property>
+              <property name="maximumSize">
+               <size>
+                <width>85</width>
+                <height>31</height>
+               </size>
+              </property>
+              <property name="text">
+               <string>File</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QPushButton" name="ButtonLoadPluginsPath">
+              <property name="minimumSize">
+               <size>
+                <width>85</width>
+                <height>31</height>
+               </size>
+              </property>
+              <property name="maximumSize">
+               <size>
+                <width>85</width>
+                <height>31</height>
+               </size>
+              </property>
+              <property name="text">
+               <string>Path</string>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </widget>
+         </item>
+         <item>
+          <widget class="QTreeWidget" name="LoadedPlugins">
+           <property name="minimumSize">
+            <size>
+             <width>229</width>
+             <height>0</height>
+            </size>
+           </property>
+           <property name="dragEnabled">
+            <bool>true</bool>
+           </property>
+           <property name="dragDropMode">
+            <enum>QAbstractItemView::DragOnly</enum>
+           </property>
+           <column>
+            <property name="text">
+             <string>Loaded plugins</string>
+            </property>
+           </column>
+          </widget>
+         </item>
+        </layout>
+       </widget>
+       <widget class="cpPipelineEditor::Canvas" name="Canvas" native="true">
+        <property name="minimumSize">
+         <size>
+          <width>500</width>
+          <height>0</height>
+         </size>
+        </property>
+        <property name="acceptDrops">
+         <bool>true</bool>
+        </property>
+       </widget>
       </widget>
      </widget>
     </item>
    <header>cpPipelineEditor/Canvas.h</header>
    <container>1</container>
   </customwidget>
+  <customwidget>
+   <class>cpPlugins::Interface::SimpleMPRWidget</class>
+   <extends>QWidget</extends>
+   <header location="global">cpPlugins/Interface/SimpleMPRWidget.h</header>
+   <container>1</container>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections>
index 0e6dce0235da38df90e2f4a6eb5e38bab91ec51b..c037193fe97097b0d960316109a6dd0ae477f0aa 100644 (file)
@@ -108,12 +108,22 @@ GetNumberOfSeeds( ) const
 
 // -------------------------------------------------------------------------
 void cpExtensions::Interaction::ImageInteractorStyle::
-GetSeed( unsigned int id, double pos[ 3 ] ) const
+GetSeedAsPoint( unsigned int id, double pos[ 3 ] ) const
 {
   if( this->m_SeedWidget != NULL )
     this->m_SeedWidget->Representation->GetSeedWorldPosition( id, pos );
 }
 
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageInteractorStyle::
+GetSeedAsIndex( unsigned int id, int idx[ 3 ] ) const
+{
+  /* TODO
+     if( this->m_SeedWidget != NULL )
+     this->m_SeedWidget->Representation->GetSeedWorldPosition( id, pos );
+  */
+}
+
 // -------------------------------------------------------------------------
 cpExtensions::Interaction::ImageInteractorStyle::
 ImageInteractorStyle( )
index 45a349f8e46ceb42ee8b26b9f0b0bcacbb50acbf..ec54f5e33481b3c3acfd25808d0836cd133dd940 100644 (file)
@@ -68,7 +68,8 @@ namespace cpExtensions
       void SeedWidgetOff( );
       void SetSeedWidgetCommand( vtkCommand* cmd );
       unsigned int GetNumberOfSeeds( ) const;
-      void GetSeed( unsigned int id, double pos[ 3 ] ) const;
+      void GetSeedAsPoint( unsigned int id, double pos[ 3 ] ) const;
+      void GetSeedAsIndex( unsigned int id, int pos[ 3 ] ) const;
 
     protected:
       ImageInteractorStyle( );
index 7263cad8f2559343f8b4a85c76672c95889c1c4c..f27a7c8878a2ed74200e64abfa3c29a027f2678a 100644 (file)
@@ -11,6 +11,7 @@
 \r
 #include "Port.h"\r
 #include "Connection.h"\r
+#include "Editor.h"\r
 \r
 // -------------------------------------------------------------------------\r
 cpPipelineEditor::Block::\r
@@ -20,7 +21,8 @@ Block( TFilter* filter, QGraphicsItem* parent, QGraphicsScene* scene )
     m_VertMargin( 5 ),\r
     m_NamePort( NULL ),\r
     m_TypePort( NULL ),\r
-    m_Filter( filter )\r
+    m_Filter( filter ),\r
+    m_Editor( NULL )\r
 {\r
   QPainterPath p;\r
   p.addRoundedRect( -50, -15, 100, 30, 5, 5 );\r
@@ -57,6 +59,27 @@ cpPipelineEditor::Block::
 {\r
 }\r
 \r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor::Editor* cpPipelineEditor::Block::\r
+editor( )\r
+{\r
+  return( this->m_Editor );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+const cpPipelineEditor::Editor* cpPipelineEditor::Block::\r
+editor( ) const\r
+{\r
+  return( this->m_Editor );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Block::\r
+setEditor( cpPipelineEditor::Editor* editor )\r
+{\r
+  this->m_Editor = editor;\r
+}\r
+\r
 // -------------------------------------------------------------------------\r
 void cpPipelineEditor::Block::\r
 setNamePort( const QString& txt )\r
@@ -266,8 +289,7 @@ contextMenuEvent( QGraphicsSceneContextMenuEvent* evt )
     auto res = this->m_Filter->ExecConfigurationDialog( NULL );\r
   }\r
   else if( selectedAction == updateAction )\r
-  {\r
-  } // fi\r
+    this->m_Editor->updateFilter( this->namePort( ).toStdString( ) );\r
 }\r
 \r
 // eof - $RCSfile$\r
index 763ecda8e13c2c0cbf1aae1c3c1d8778641aa884..b6a7b33a898f390d0fbddeb714513149c53ea5f1 100644 (file)
@@ -7,6 +7,7 @@
 \r
 namespace cpPipelineEditor\r
 {\r
+  class Editor;\r
   class Port;\r
   class NamePort;\r
   class TypePort;\r
@@ -32,6 +33,10 @@ namespace cpPipelineEditor
       );\r
     virtual ~Block( );\r
 \r
+    Editor* editor( );\r
+    const Editor* editor( ) const;\r
+    void setEditor( Editor* editor );\r
+\r
     void setNamePort( const QString& txt );\r
     InputPort* addInputPort( const QString& txt );\r
     OutputPort* addOutputPort( const QString& txt );\r
@@ -51,7 +56,7 @@ namespace cpPipelineEditor
       const QStyleOptionGraphicsItem* option,\r
       QWidget* widget\r
       );\r
-    \r
+\r
   protected:\r
     QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
     void _setTypePort( const QString& txt );\r
@@ -72,6 +77,7 @@ namespace cpPipelineEditor
     std::map< std::string, OutputPort* > m_OutputPorts;\r
 \r
     TFilter* m_Filter;\r
+    Editor*  m_Editor;\r
   };\r
 \r
 } // ecapseman\r
index 9ab6b35537b5af476da1c5c4ed7a7b68ad607fa7..2a0fca6a04a4bb222ea61ca8d4e2dbf70e7d42dc 100644 (file)
@@ -11,6 +11,7 @@
 #include <QGraphicsSceneResizeEvent>\r
 #include <QGraphicsSceneWheelEvent>\r
 #include <QInputDialog>\r
+#include <QMessageBox>\r
 \r
 #include "Port.h"\r
 #include "Connection.h"\r
@@ -156,6 +157,7 @@ _createBlock( TFilter* f, const QPointF& pnt )
 \r
   // Add block\r
   Block* b = new Block( f, 0, this->m_Scene );\r
+  b->setEditor( this );\r
   b->setPos( pnt );\r
 \r
   // Mark exposed inputs\r
@@ -232,6 +234,22 @@ eventFilter( QObject* o, QEvent* e )
   return( this->Superclass::eventFilter( o, e ) );\r
 }\r
 \r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Editor::\r
+updateFilter( const std::string& filter_name )\r
+{\r
+  emit execFilter( filter_name );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Editor::\r
+showOutputData(\r
+  const std::string& filter_name, const std::string& output_name\r
+  )\r
+{\r
+  emit showFilterOutput( filter_name, output_name );\r
+}\r
+\r
 // -------------------------------------------------------------------------\r
 cpPipelineEditor_Editor_Callback_CODE( ContextMenu )\r
 {\r
index f7a2615027a7e60c63f8b06dd75d8f2231b80dfd..ca273b21fe6d1808429f4a9260dfbd31e2f50bca 100644 (file)
@@ -61,6 +61,19 @@ namespace cpPipelineEditor
     void install( QGraphicsScene* s );\r
     bool eventFilter( QObject* o, QEvent* e );\r
 \r
+    void updateFilter( const std::string& filter_name );\r
+    void showOutputData(\r
+      const std::string& filter_name,\r
+      const std::string& output_name\r
+      );\r
+\r
+  signals:\r
+    void execFilter( const std::string& filter_name );\r
+    void showFilterOutput(\r
+      const std::string& filter_name,\r
+      const std::string& output_name\r
+      );\r
+\r
   private:\r
     QGraphicsItem* itemAt( const QPointF& pos );\r
 \r
index ab478c298343960aa6bd064649c0fef71a5d4869..a2125f7383330bf2082ece043a3b8ec03339fb1b 100644 (file)
@@ -1,8 +1,12 @@
 #include "Port.h"\r
 #include "Connection.h"\r
+#include "Block.h"\r
+#include "Editor.h"\r
 \r
 #include <QGraphicsScene>\r
+#include <QGraphicsSceneContextMenuEvent>\r
 #include <QFontMetrics>\r
+#include <QMenu>\r
 #include <QPainter>\r
 #include <QPen>\r
 \r
@@ -292,4 +296,28 @@ itemChange( GraphicsItemChange change, const QVariant& value )
   return( value );\r
 }\r
 \r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::OutputPort::\r
+contextMenuEvent( QGraphicsSceneContextMenuEvent* evt )\r
+{\r
+  if( this->m_Block == NULL )\r
+    return;\r
+  \r
+  QMenu menu;\r
+  QAction* showAction = menu.addAction( "Show" );\r
+  QAction* hideAction = menu.addAction( "Hide" );\r
+  QAction* selectedAction = menu.exec( evt->screenPos( ) );\r
+\r
+  if( selectedAction == showAction )\r
+  {\r
+    this->m_Block->editor( )->showOutputData(\r
+      this->m_Block->namePort( ).toStdString( ),\r
+      this->name( ).toStdString( )\r
+      );\r
+  }\r
+  else if( selectedAction == hideAction )\r
+  {\r
+  } // fi\r
+}\r
+\r
 // eof - $RCSfile$\r
index 0f64a4bd4b64e0f849137ae37e289dbff3359059..18bcd94ff9231cd162699262be8880073f9edc05 100644 (file)
@@ -179,6 +179,8 @@ namespace cpPipelineEditor
     QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
     virtual void _updateLabels( );\r
 \r
+    virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent* evt );\r
+\r
   protected:\r
     QVector< Connection* > m_Connections;\r
   };\r
index 765f82f851d7b9bbb3f0ef2b3bec0c8ce70f5e1a..c93e160877d51275504aef98621a2f6a8433e5e4 100644 (file)
@@ -118,7 +118,9 @@ class TiXmlElement;
       if( i->second.first == Self::Y##List )                            \
       {                                                                 \
         std::stringstream str;                                          \
-        str << i->second.second << "#" << v;                            \
+        if( i->second.second != "" )                                    \
+          str << i->second.second << "#";                               \
+        str << v;                                                       \
         i->second.second = str.str( );                                  \
       }                                                                 \
     }                                                                   \
index 731fc77a120a9bd371c4b44a2e1dd02e4a328b76..e502c6eb28a8332692a9a3c2f14141ca3124bb2e 100644 (file)
@@ -24,6 +24,7 @@
 #include <cpPlugins/Interface/Plugins.h>
 #include <cpPlugins/Interface/BaseApplication.h>
 
+/* TODO
 class SingleSeedCommand
   : public vtkCommand
 {
@@ -87,12 +88,14 @@ public:
   cpPlugins::Interface::ParametersQtDialog* Dialog;
   std::string Name;
 };
+*/
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::ParametersQtDialog::
 ParametersQtDialog( QWidget* parent, Qt::WindowFlags f )
   : QDialog( parent, f ),
-    m_Parameters( NULL )
+    m_Parameters( NULL ),
+    m_Interactive( false )
 {
   this->m_Title = new QLabel( this );
   this->m_Title->setText( "Parameters dialog title" );
@@ -143,6 +146,34 @@ getInteractors( ) const
   return( this->m_Interactors );
 }
 
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::ParametersQtDialog::
+isInteractive( ) const
+{
+  return( this->m_Interactive );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ParametersQtDialog::
+setInteractive( bool i )
+{
+  this->m_Interactive = i;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ParametersQtDialog::
+interactiveOn( )
+{
+  this->m_Interactive = true;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ParametersQtDialog::
+interactiveOff( )
+{
+  this->m_Interactive = false;
+}
+
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::ParametersQtDialog::
 setParameters( Parameters* parameters )
@@ -158,6 +189,7 @@ setParameters( Parameters* parameters )
   this->m_Title->setText( title.str( ).c_str( ) );
 
   // Put values
+  this->m_Widgets.clear( );
   auto& raw_params = this->m_Parameters->GetRawParameters( );
   for( auto pIt = raw_params.begin( ); pIt != raw_params.end( ); ++pIt )
   {
index 4d4d37f731c5404ea5aa732906f881ae3fbca4a7..40b85141fd91efcf12233129ea62c5bc0d374ce7 100644 (file)
@@ -7,10 +7,12 @@
 
 #include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
 #include <cpPlugins/Interface/Parameters.h>
-#include <cpExtensions/Interaction/ImageInteractorStyle.h>
 
 #include <set>
 
+#include <vtkInteractorObserver.h>
+#include <vtkSmartPointer.h>
+
 #include <QDialog>
 #include <QDialogButtonBox>
 #include <QGridLayout>
@@ -31,9 +33,10 @@ namespace cpPlugins
       Q_OBJECT;
 
     public:
-      typedef cpExtensions::Interaction::ImageInteractorStyle TStyle;
-
       typedef std::set< vtkRenderWindowInteractor* > TInteractors;
+      typedef
+        std::map< std::string, vtkSmartPointer< vtkInteractorObserver > >
+        TWidgets;
 
     public:
       ParametersQtDialog( QWidget* parent = 0, Qt::WindowFlags f = 0 );
@@ -43,6 +46,10 @@ namespace cpPlugins
       void addInteractor( vtkRenderWindowInteractor* interactor );
       TInteractors& getInteractors( );
       const TInteractors& getInteractors( ) const;
+      bool isInteractive( ) const;
+      void setInteractive( bool i );
+      void interactiveOn( );
+      void interactiveOff( );
       bool setParameters( Parameters* parameters );
 
       virtual int exec( );
@@ -68,6 +75,8 @@ namespace cpPlugins
       QDialogButtonBox* m_Buttons;
 
       TInteractors m_Interactors;
+      TWidgets m_Widgets;
+      bool m_Interactive;
     };
 
   } // ecapseman
index ece9dd0a5f93762b1be093a9f9a398897042f19e..c5727c29276b423a6915e3dd1b41a8c0d462fb1a 100644 (file)
@@ -342,7 +342,7 @@ ReadImage( const std::string& parent )
   this->_ActivateIOFilter( "ImageReader" );
 
   // Try to configure source
-  if( this->ConfigureActiveFilter( ) == TProcessObject::DialogResult_Cancel )
+  if( !( this->ConfigureActiveFilter( ) ) )
   {
     this->DeactivateFilter( );
     return( "" );
@@ -361,7 +361,7 @@ ReadDicomSeries( const std::string& parent )
   this->_ActivateIOFilter( "DicomSeriesReader" );
 
   // Try to configure source
-  if( this->ConfigureActiveFilter( ) == TProcessObject::DialogResult_Cancel )
+  if( !( this->ConfigureActiveFilter( ) ) )
   {
     this->DeactivateFilter( );
     return( "" );
@@ -395,7 +395,7 @@ ReadMesh( const std::string& parent )
   this->_ActivateIOFilter( "MeshReader" );
 
   // Try to configure source
-  if( this->ConfigureActiveFilter( ) == TProcessObject::DialogResult_Cancel )
+  if( !( this->ConfigureActiveFilter( ) ) )
   {
     this->DeactivateFilter( );
     return( "" );
@@ -455,7 +455,7 @@ WriteDataObject( const std::string& name )
   } // fi
 
   // Try to configure source
-  if( this->ConfigureActiveFilter( ) == TProcessObject::DialogResult_Cancel )
+  if( !( this->ConfigureActiveFilter( ) ) )
   {
     this->DeactivateFilter( );
     return( false );
@@ -656,7 +656,7 @@ ConfigureActiveFilter( )
   if( this->m_ActiveFilter.IsNotNull( ) )
     return( this->m_ActiveFilter->ExecConfigurationDialog( this->m_Widget ) );
   else
-    return( TProcessObject::DialogResult_Cancel );
+    return( false );
 }
 
 // -------------------------------------------------------------------------
diff --git a/lib/cpPlugins/Interface/PointList.cxx b/lib/cpPlugins/Interface/PointList.cxx
new file mode 100644 (file)
index 0000000..87a3570
--- /dev/null
@@ -0,0 +1,33 @@
+#include <cpPlugins/Interface/PointList.h>
+
+// -------------------------------------------------------------------------
+unsigned long cpPlugins::Interface::PointList::
+GetNumberOfPoints( ) const
+{
+  return( this->m_NumberOfPoints );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::PointList::
+Clear( )
+{
+  this->m_ITKObject = NULL;
+  this->m_VTKObject = NULL;
+  this->m_NumberOfPoints = 0;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::PointList::
+PointList( )
+  : Superclass( )
+{
+  this->Clear( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::PointList::
+~PointList( )
+{
+}
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Interface/PointList.h b/lib/cpPlugins/Interface/PointList.h
new file mode 100644 (file)
index 0000000..f41fb18
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef __CPPLUGINS__INTERFACE__POINTLIST__H__
+#define __CPPLUGINS__INTERFACE__POINTLIST__H__
+
+#include <cpPlugins/Interface/DataObject.h>
+
+namespace cpPlugins
+{
+  namespace Interface
+  {
+    /**
+     */
+    class cpPlugins_Interface_EXPORT PointList
+      : public DataObject
+    {
+    public:
+      typedef PointList                       Self;
+      typedef DataObject                      Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( PointList, DataObject );
+      cpPlugins_Id_Macro( PointList, DataObject );
+
+    public:
+      unsigned long GetNumberOfPoints( ) const;
+
+      void Clear( );
+
+      template< class P >
+        inline void AddPoint( const P& p );
+
+      template< class P >
+        inline P GetPoint( const unsigned long& i ) const;
+
+    protected:
+      PointList( );
+      virtual ~PointList( );
+
+    private:
+      // Purposely not implemented
+      PointList( const Self& );
+      Self& operator=( const Self& );
+
+    protected:
+      unsigned long m_NumberOfPoints;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#include <cpPlugins/Interface/PointList.hxx>
+
+#endif // __CPPLUGINS__INTERFACE__POINTLIST__H__
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Interface/PointList.hxx b/lib/cpPlugins/Interface/PointList.hxx
new file mode 100644 (file)
index 0000000..95e9e1f
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef __CPPLUGINS__INTERFACE__POINTLIST__HXX__
+#define __CPPLUGINS__INTERFACE__POINTLIST__HXX__
+
+#include <itkSimpleDataObjectDecorator.h>
+#include <utility>
+#include <vector>
+
+// -------------------------------------------------------------------------
+template< class P >
+void cpPlugins::Interface::PointList::
+AddPoint( const P& p )
+{
+  typedef itk::SimpleDataObjectDecorator< std::vector< P > > _T;
+
+  _T* container = NULL;
+  if( this->m_NumberOfPoints == 0 )
+  {
+    typename _T::Pointer obj = _T::New( );
+    container = obj.GetPointer( );
+    this->m_ITKObject = container;
+  }
+  else
+    container = dynamic_cast< _T* >( this->m_ITKObject.GetPointer( ) );
+
+  if( container != NULL )
+  {
+    container->Get( ).push_back( p );
+    this->m_NumberOfPoints += 1;
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class P >
+P cpPlugins::Interface::PointList::
+GetPoint( const unsigned long& i ) const
+{
+  typedef itk::SimpleDataObjectDecorator< std::vector< P > > _T;
+
+  P ret;
+  if( i < this->m_NumberOfPoints )
+  {
+    _T* container = dynamic_cast< _T* >( this->m_ITKObject.GetPointer( ) );
+    if( container != NULL )
+      ret = container->Get( )[ i ];
+    
+  } // fi
+  return( ret );
+}
+
+#endif // __CPPLUGINS__INTERFACE__POINTLIST__HXX__
+
+// eof - $RCSfile$
index db873e9d4f854724c7606a79af4e4f00a705c5b6..1db1a61cb44db76ac27f40400912feab3523d21a 100644 (file)
@@ -131,6 +131,14 @@ DisconnectOutputs( )
       i->second->DisconnectPipeline( );
 }
 
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::ProcessObject::
+TInteractors& cpPlugins::Interface::ProcessObject::
+GetInteractors( ) const
+{
+  return( this->m_Interactors );
+}
+
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::ProcessObject::
 AddInteractor( vtkRenderWindowInteractor* interactor )
@@ -144,11 +152,10 @@ AddInteractor( vtkRenderWindowInteractor* interactor )
 }
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::ProcessObject::
-DialogResult cpPlugins::Interface::ProcessObject::
+bool cpPlugins::Interface::ProcessObject::
 ExecConfigurationDialog( QWidget* parent )
 {
-  DialogResult r = Self::DialogResult_Cancel;
+  bool r = false;
 
 #ifdef cpPlugins_Interface_QT4
 
@@ -165,14 +172,11 @@ ExecConfigurationDialog( QWidget* parent )
     this->m_ParametersDialog->setParent( NULL );
     this->m_ParametersDialog->setParameters( this->m_Parameters );
 
-    if( this->m_ParametersDialog->exec( ) == 1 )
-      r = Self::DialogResult_NoModal;
-    else
-      r = Self::DialogResult_Cancel;
+    r = ( this->m_ParametersDialog->exec( ) == 1 );
   }
   else
-    r = Self::DialogResult_Cancel;
-
+    r = false;
+  
 #endif // cpPlugins_Interface_QT4
 
   return( r );
index b6cf116e680d730dd7e35632673b64f6e1c2f1f8..52b56546abe3521d83e50b959caa80cc8d4e7729 100644 (file)
@@ -43,13 +43,7 @@ namespace cpPlugins
 
       typedef Parameters TParameters;
       typedef std::set< vtkRenderWindowInteractor* > TInteractors;
-
-      enum DialogResult
-      {
-        DialogResult_NoModal = 0,
-        DialogResult_Modal,
-        DialogResult_Cancel
-      };
+      typedef bool DialogResult;
 
     public:
       itkTypeMacro( ProcessObject, Object );
@@ -85,8 +79,9 @@ namespace cpPlugins
       virtual std::string Update( );
       virtual void DisconnectOutputs( );
 
+      virtual const TInteractors& GetInteractors( ) const;
       virtual void AddInteractor( vtkRenderWindowInteractor* interactor );
-      virtual DialogResult ExecConfigurationDialog( QWidget* parent );
+      virtual bool ExecConfigurationDialog( QWidget* parent );
 
       template< class T >
         inline T* GetITK( );
index c7c30582fdd3931f23ce7758b4216503335fa4af..790688386333477bfd2a8ef777eecf24229f731d 100644 (file)
@@ -63,6 +63,13 @@ cpPlugins::Interface::SimpleMPRWidget::
   delete this->m_UI;
 }
 
+// -------------------------------------------------------------------------
+unsigned int cpPlugins::Interface::SimpleMPRWidget::
+GetNumberOfData( ) const
+{
+  return( this->m_Data.size( ) );
+}
+
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::SimpleMPRWidget::
 AddData(
index 7fe49b65c1f415a1e3f752f562d58417db1819d0..48d39794c04c1f1a9a183b52336a142bfbe6c530 100644 (file)
@@ -66,6 +66,7 @@ namespace cpPlugins
       virtual ~SimpleMPRWidget( );
 
       // Data management
+      unsigned int GetNumberOfData( ) const;
       bool AddData(
         DataObject* data, const std::string& name,
         const std::string& parent
@@ -104,7 +105,7 @@ namespace cpPlugins
     protected:
       static double cm_Colors[ 8 ][ 3 ];
 
-      Ui::SimpleMPRWidget*             m_UI;
+      Ui::SimpleMPRWidget*           m_UI;
       vtkSmartPointer< TMPRObjects > m_MPRObjects;
       QVTKWidget*                    m_VTK[ 4 ];
 
index 67eaf0a677b3937809c3f5431fc9023a68aea909..528f7741feff56af59f207ea8a4396f10d834880 100644 (file)
@@ -116,6 +116,13 @@ 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 );
+      
       TObject::Pointer o = f.GetPointer( );
       this->m_Graph->SetVertex( name, o );
       return( true );
@@ -147,6 +154,21 @@ RemoveFilter( const std::string& name )
 {
 }
 
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::Workspace::
+TInteractors& cpPlugins::Interface::Workspace::
+GetInteractors( ) const
+{
+  return( this->m_Interactors );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Workspace::
+AddInteractor( vtkRenderWindowInteractor* interactor )
+{
+  this->m_Interactors.insert( interactor );
+}
+
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Workspace::
 Connect(
@@ -294,7 +316,7 @@ GetExposedOutputPorts( ) const
 
 // -------------------------------------------------------------------------
 std::string cpPlugins::Interface::Workspace::
-Execute( QWidget* p )
+Execute( )
 {
   // Find sinks
   std::set< std::string > sinks = this->m_Graph->GetSinks( );
@@ -303,7 +325,7 @@ Execute( QWidget* p )
   std::string err = "";
   for( auto sIt = sinks.begin( ); sIt != sinks.end( ); ++sIt )
   {
-    std::string lerr = this->Execute( *sIt, p );
+    std::string lerr = this->Execute( *sIt );
     if( lerr != "" )
       err += lerr + std::string( "\n" );
 
@@ -313,7 +335,7 @@ Execute( QWidget* p )
 
 // -------------------------------------------------------------------------
 std::string cpPlugins::Interface::Workspace::
-Execute( const std::string& name, QWidget* p )
+Execute( const std::string& name )
 {
   // Get filter
   TFilter* f = this->GetFilter( name );
@@ -324,16 +346,7 @@ Execute( const std::string& name, QWidget* p )
       );
 
   // Execute and return
-  if( p != NULL )
-  {
-    auto diag_res = f->ExecConfigurationDialog( p );
-    if( diag_res == TFilter::DialogResult_NoModal )
-      return( f->Update( ) );
-    else
-      return( "" );
-  }
-  else
-    return( f->Update( ) );
+  return( f->Update( ) );
 }
 
 // eof - $RCSfile$
index 92315d71fb8c0116b45d1c4199584fbccc425f01..3d78f0246d834563406427f420425f174f33fa99 100644 (file)
@@ -11,6 +11,7 @@
 
 // Some forward declarations
 class QWidget;
+class vtkRenderWindowInteractor;
 
 namespace cpPlugins
 {
@@ -31,6 +32,7 @@ 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;
@@ -68,6 +70,10 @@ namespace cpPlugins
         );
       void RemoveFilter( const std::string& name );
 
+      // Widgets management
+      virtual const TInteractors& GetInteractors( ) const;
+      virtual void AddInteractor( vtkRenderWindowInteractor* interactor );
+
       // Connection management
       bool Connect(
         const std::string& orig_filter, const std::string& dest_filter,
@@ -111,8 +117,8 @@ namespace cpPlugins
       const TData* GetExposedOutput( const std::string& name ) const;
 
       // Pipeline execution
-      std::string Execute( QWidget* p = NULL );
-      std::string Execute( const std::string& name, QWidget* p = NULL );
+      std::string Execute( );
+      std::string Execute( const std::string& name );
 
     protected:
       // Plugins interface
@@ -122,6 +128,8 @@ namespace cpPlugins
       typename TGraph::Pointer m_Graph;
       TExposedPorts m_ExposedInputPorts;
       TExposedPorts m_ExposedOutputPorts;
+
+      TInteractors m_Interactors;
     };
 
   } // ecapseman
index c6aef7ebd2db77fa7fbfbe39a9cd7018eb93cdc5..61ff7d2e291b46a22e67b9fed0406d48735b64dc 100644 (file)
@@ -86,7 +86,7 @@ accept( )
       if( nTotalSeeds < 2 )
       {
         double seed[ 3 ];
-        istyle->GetSeed( s, seed );
+        istyle->GetSeedAsPoint( s, seed );
         if( nTotalSeeds == 0 )
           this->m_Filter->GetParameters( )->SetPoint( "Seed0", 3, seed );
         else
@@ -149,15 +149,15 @@ ExecConfigurationDialog( QWidget* parent )
     
   } // rof
   if( !at_least_one )
-    return( Self::DialogResult_Cancel );
-
+    return( false );
+  
   // Create dialog
   this->m_Dialog = new DoubleFloodImageFilter_Dialog( NULL, this );
   this->m_Dialog->show( );
 
-  return( Self::DialogResult_Modal );
+  return( true );
 #else // cpPlugins_Interface_QT4
-  return( Self::DialogResult_Cancel );
+  return( false );
 #endif // cpPlugins_Interface_QT4
 }
 
index 8116e211ff32895d1e5f6cf2a860de75381fede9..1f4709cd689801a00b4279377dacee0baa7ac08f 100644 (file)
@@ -121,8 +121,8 @@ ExecConfigurationDialog( QWidget* parent )
     
   } // rof
   if( iren == NULL )
-    return( Self::DialogResult_Cancel );
-
+    return( false );
+  
   // Get bounding box
   double bbox[ 6 ];
   cpPlugins::Interface::Image* image =
@@ -143,7 +143,7 @@ ExecConfigurationDialog( QWidget* parent )
 
   } // fi
   if( !input_found )
-    return( Self::DialogResult_Cancel );
+    return( false );
 
   // Create plane widget
   if( this->m_PlaneWidget != NULL )
@@ -179,9 +179,9 @@ ExecConfigurationDialog( QWidget* parent )
   this->m_Dialog = new MacheteFilter_Dialog( NULL, this );
   this->m_Dialog->show( );
 
-  return( Self::DialogResult_Modal );
+  return( true );
 #else // cpPlugins_Interface_QT4
-  return( Self::DialogResult_Cancel );
+  return( false );
 #endif // cpPlugins_Interface_QT4
 }
 
index 6fe1263cf23ade46b94ff02cf84ef6e6e7d02d09..4d704888b36f01f3a09c8f00bcd3a3eaf4b8645b 100644 (file)
@@ -1,6 +1,7 @@
 SUBDIRS(
   IO
   BasicFilters
+  Widgets
   )
 
 ## eof - $RCSfile$
index e2aeb31b51f2bacb8faf5602d77e0f96d5a4265f..4841bcf0fdd3a5948ece446dacf65df46d8d9774 100644 (file)
 #include <itkGDCMSeriesFileNames.h>
 
 // -------------------------------------------------------------------------
-cpPlugins::IO::DicomSeriesReader::
-DialogResult cpPlugins::IO::DicomSeriesReader::
+bool cpPlugins::IO::DicomSeriesReader::
 ExecConfigurationDialog( QWidget* parent )
 {
-  DialogResult r = Self::DialogResult_Cancel;
+  bool r = false;
 
 #ifdef cpPlugins_Interface_QT4
 
@@ -38,7 +37,7 @@ ExecConfigurationDialog( QWidget* parent )
   dialog.setFileMode( QFileDialog::DirectoryOnly );
   dialog.setDirectory( QFileDialog::tr( "." ) );
   if( !dialog.exec( ) )
-    return( Self::DialogResult_Cancel );
+    return( false );
 
   // Prepare dialog
   QApplication::setOverrideCursor( Qt::WaitCursor );
@@ -120,7 +119,7 @@ ExecConfigurationDialog( QWidget* parent )
   {
     delete tree_widget;
     delete tree_dialog;
-    return( Self::DialogResult_Cancel );
+    return( false );
 
   } // fi
 
@@ -150,7 +149,7 @@ ExecConfigurationDialog( QWidget* parent )
     parent->setEnabled( true );
 
   if( tree_dialog->exec( ) == 0 )
-    return( Self::DialogResult_Cancel );
+    return( false );
 
   QTreeWidgetItem* item = tree_widget->currentItem( );
   if( item != NULL )
@@ -165,12 +164,12 @@ ExecConfigurationDialog( QWidget* parent )
       std::string serie_dir = item_parent->text( 0 ).toStdString( );
       std::string serie_id = item->text( 0 ).toStdString( );
       serie_id = serie_id.substr( serie_id.find_first_of( " " ) + 1 );
-      this->m_Parameters->ClearStringList( "FileNames" );
+      this->m_Parameters->ClearOpenFileNameList( "FileNames" );
       const TStringList& names = found_files[ serie_dir ][ serie_id ];
       for( unsigned int f = 0; f < names.size( ); ++f )
-        this->m_Parameters->AddToStringList( "FileNames", names[ f ] );
+        this->m_Parameters->AddToOpenFileNameList( "FileNames", names[ f ] );
 
-      r = Self::DialogResult_NoModal;
+      r = true;
 
       QApplication::restoreOverrideCursor( );
       if( parent != NULL )
index fb8edb0df4e24379d68deebc749ce5cb372fd5e1..33295bfb1732e86f5f6ca5cb58fde5f07622f70f 100644 (file)
@@ -35,7 +35,7 @@ namespace cpPlugins
       cpPlugins_Id_Macro( cpPlugins::IO::DicomSeriesReader, IO );
 
     public:
-      virtual DialogResult ExecConfigurationDialog( QWidget* parent );
+      virtual bool ExecConfigurationDialog( QWidget* parent );
 
     protected:
       DicomSeriesReader( );
diff --git a/lib/cpPlugins/Plugins/Widgets/CMakeLists.txt b/lib/cpPlugins/Plugins/Widgets/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5c1a47c
--- /dev/null
@@ -0,0 +1,55 @@
+SET(LIBRARY_NAME cpPluginsWidgets)
+
+## ===============
+## = Source code =
+## ===============
+
+FILE(GLOB LIB_HEADERS_H   "*.h")
+FILE(GLOB LIB_HEADERS_HPP "*.hpp")
+FILE(GLOB LIB_HEADERS_HXX "*.hxx")
+FILE(GLOB LIB_SOURCES_C   "*.c")
+FILE(GLOB LIB_SOURCES_CPP "*.cpp")
+FILE(GLOB LIB_SOURCES_CXX "*.cxx")
+
+## =====================
+## = Compilation rules =
+## =====================
+
+ADD_CUSTOM_COMMAND(
+  OUTPUT ${LIBRARY_NAME}_Host.cxx
+  DEPENDS ${cpPlugins_createHost_APP} ${LIB_HEADERS_H}
+  COMMAND ${cpPlugins_createHost_APP} ${LIBRARY_NAME}_Host.cxx cpPlugins::Widgets ${LIB_HEADERS_H}
+  )
+
+ADD_LIBRARY(
+  ${LIBRARY_NAME}
+  SHARED
+  ${LIBRARY_NAME}_Host.cxx
+  ${LIB_SOURCES_C}
+  ${LIB_SOURCES_CPP}
+  ${LIB_SOURCES_CXX}
+  )
+GENERATE_EXPORT_HEADER(
+  ${LIBRARY_NAME}
+  BASE_NAME ${LIBRARY_NAME}
+  EXPORT_MACRO_NAME ${LIBRARY_NAME}_EXPORT
+  EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/lib/cpPlugins/Widgets/${LIBRARY_NAME}_Export.h
+  STATIC_DEFINE ${LIBRARY_NAME}_BUILT_AS_STATIC
+  )
+TARGET_LINK_LIBRARIES(
+  ${LIBRARY_NAME}
+  cpPlugins_Interface
+  )
+
+## ========================
+## -- Installation rules --
+## ========================
+
+INSTALL(
+  TARGETS ${LIBRARY_NAME}
+  RUNTIME DESTINATION bin
+  LIBRARY DESTINATION lib
+  ARCHIVE DESTINATION lib/static
+  )
+
+## eof - $RCSfile$
diff --git a/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx b/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx
new file mode 100644 (file)
index 0000000..129a8a6
--- /dev/null
@@ -0,0 +1,96 @@
+#include "SeedWidget.h"
+
+#include <cpPlugins/Interface/Image.h>
+#include <cpPlugins/Interface/PointList.h>
+#include <cpExtensions/Interaction/ImageInteractorStyle.h>
+
+#include <vtkRenderWindowInteractor.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::Widgets::SeedWidget::
+SeedWidget( )
+  : Superclass( ),
+    m_Configured( false )
+{
+  this->_AddInput( "ReferenceImage" );
+  this->_MakeOutput< cpPlugins::Interface::PointList >( "Output" );
+
+  this->m_Parameters->ConfigureAsBool( "SeedsAreInRealSpace" );
+  this->m_Parameters->SetBool( "SeedsAreInRealSpace", true );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Widgets::SeedWidget::
+~SeedWidget( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Widgets::SeedWidget::
+_GenerateData( )
+{
+  typedef itk::ImageBase< 2 > _2DImage;
+  typedef itk::ImageBase< 3 > _3DImage;
+
+  cpPlugins::Interface::Image* image =
+    this->GetInput< cpPlugins::Interface::Image >( "ReferenceImage" );
+  if( image == NULL )
+    return( "SeedWidget: No input image." );
+
+  itk::DataObject* itk_image = image->GetITK< _2DImage >( );
+  if( itk_image != NULL )
+    return( this->_GD0< _2DImage >( itk_image ) );
+  else
+  {
+    itk_image = image->GetITK< _3DImage >( );
+    if( itk_image != NULL )
+      return( this->_GD0< _3DImage >( itk_image ) );
+
+  } // fi
+
+  return( "SeedWidget: Input image dimension not supported." );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+std::string cpPlugins::Widgets::SeedWidget::
+_GD0( itk::DataObject* image )
+{
+  typedef cpExtensions::Interaction::ImageInteractorStyle _S;
+
+  I* base_image = dynamic_cast< I* >( image );
+  cpPlugins::Interface::PointList* out =
+    this->GetOutput< cpPlugins::Interface::PointList >( "Output" );
+  double aux_pnt[ 3 ];
+  unsigned int dim = ( I::ImageDimension < 3 )? I::ImageDimension: 3;
+
+  out->Clear( );
+  auto iIt = this->m_Interactors.begin( );
+  for( ; iIt != this->m_Interactors.end( ); ++iIt )
+  {
+    _S* s = dynamic_cast< _S* >( ( *iIt )->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
+  this->m_Configured = true;
+  return( "" );
+}
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Plugins/Widgets/SeedWidget.h b/lib/cpPlugins/Plugins/Widgets/SeedWidget.h
new file mode 100644 (file)
index 0000000..709a9c6
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef __CPPLUGINS__PLUGINS__SEEDWIDGET__H__
+#define __CPPLUGINS__PLUGINS__SEEDWIDGET__H__
+
+#include <cpPlugins/Widgets/cpPluginsWidgets_Export.h>
+#include <cpPlugins/Interface/ProcessObject.h>
+
+namespace cpPlugins
+{
+  namespace Widgets
+  {
+    /**
+     */
+    class cpPluginsWidgets_EXPORT SeedWidget
+      : public cpPlugins::Interface::ProcessObject
+    {
+    public:
+      typedef SeedWidget                          Self;
+      typedef cpPlugins::Interface::ProcessObject Superclass;
+      typedef itk::SmartPointer< Self >           Pointer;
+      typedef itk::SmartPointer< const Self >     ConstPointer;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( SeedWidget, cpPlugins::Interface::ProcessObject );
+      cpPlugins_Id_Macro( cpPlugins::Widgets::SeedWidget, Widgets );
+
+    protected:
+      SeedWidget( );
+      virtual ~SeedWidget( );
+
+      virtual std::string _GenerateData( );
+
+      template< class I >
+        inline std::string _GD0( itk::DataObject* image );
+
+    private:
+      // Purposely not implemented
+      SeedWidget( const Self& );
+      Self& operator=( const Self& );
+
+    protected:
+      bool m_Configured;
+    };
+
+    // ---------------------------------------------------------------------
+    CPPLUGINS_INHERIT_PROVIDER( SeedWidget );
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__PLUGINS__SEEDWIDGET__H__
+
+// eof - $RCSfile$