]> Creatis software - cpPlugins.git/commitdiff
MVC integration at 50%
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 26 May 2016 01:51:42 +0000 (20:51 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 26 May 2016 01:51:42 +0000 (20:51 -0500)
17 files changed:
appli/PipelineEditor/PipelineEditor.cxx
lib/cpExtensions/QT/PropertyWidget.cxx [deleted file]
lib/cpExtensions/QT/PropertyWidget.h [deleted file]
lib/cpExtensions/QT/PropertyWidget.ui [deleted file]
lib/cpExtensions/QT/SimpleMPRWidget.cxx
lib/cpExtensions/QT/SimpleMPRWidget.h
lib/cpExtensions/QT/SimpleMPRWidget.ui
lib/cpExtensions/Visualization/ImageSliceActors.cxx
lib/cpExtensions/Visualization/ImageSliceActors.h
lib/cpPipelineEditor/BaseQtMainWindow.cxx
lib/cpPlugins/DataObject.cxx
lib/cpPlugins/DataObject.h
lib/cpPlugins/DataObjectVisualizationQtDialog.cxx
lib/cpPlugins/Image.cxx
lib/cpPlugins/Image.h
lib/cpPlugins/Workspace.cxx
lib/cpPlugins/Workspace.h

index a4cd75e79a82be20ef74ed1d545da061eda89417..f646520e93159e9af103afc8ee7c2ce8d9dccfbd 100644 (file)
@@ -3,8 +3,8 @@
 
 #include <QMessageBox>
 
+#include <cpPlugins/Image.h>
 #include <cpPipelineEditor/Editor.h>
-#include <cpExtensions/QT/PropertyWidget.h>
 
 #include <vtkImageData.h>
 #include <vtkPolyData.h>
@@ -84,55 +84,22 @@ _ShowFilterOutput(
   this->_ExecFilter( filter_name );
 
   // Get output
-  auto filter = this->m_Workspace.GetFilter( filter_name );
-  if( filter != NULL )
+  auto output = this->m_Workspace.GetOutput( filter_name, output_name );
+  if( output == NULL )
   {
-    auto out = filter->GetOutput( output_name );
-    if( out != NULL )
-    {
-      auto id = out->GetVTK< vtkImageData >( );
-      auto md = out->GetVTK< vtkPolyData >( );
-      if( id != NULL )
-      {
-        this->_Block( );
-        this->m_UI->Viewer->Clear( );
-        this->m_UI->Viewer->SetMainImage( id );
-        auto actors = this->m_UI->Viewer->GetMainImageActors( );
-        out->ClearVTKActors( );
-        for( auto aIt = actors.begin( ); aIt != actors.end( ); ++aIt )
-          out->AddVTKActor( aIt->first, aIt->second );
-        this->_UnBlock( );
-      }
-      else if( md != NULL )
-      {
-        this->_Block( );
-        this->m_UI->Viewer->AddMesh( md );
-        out->AddVTKActor(
-          this->m_UI->Viewer->GetActor( md ),
-          this->m_UI->Viewer->GetRenderer( 3 )
-          );
-        this->_UnBlock( );
-      }
-      else
-        QMessageBox::critical(
-          this,
-          QMessageBox::tr( "Error showing data" ),
-          QMessageBox::tr( "No known VTK conversion!" )
-          );
-    }
-    else
-      QMessageBox::critical(
-        this,
-        QMessageBox::tr( "Error showing data" ),
-        QMessageBox::tr( "Unknown port name." )
-        );
-  }
-  else
     QMessageBox::critical(
       this,
       QMessageBox::tr( "Error showing data" ),
-      QMessageBox::tr( "Unknown filter." )
+      QMessageBox::tr( "Unknown port name." )
       );
+    return;
+
+  } // fi
+
+  // Create and associate actor
+  this->_Block( );
+  this->m_UI->Viewer->AddActor( output->CreateVTKActor( ) );
+  this->_UnBlock( );
 }
 
 // -------------------------------------------------------------------------
@@ -164,34 +131,35 @@ _PropertiesFilterOutput(
   const std::string& filter_name, const std::string& output_name
   )
 {
-  // Get output
-  auto filter = this->m_Workspace.GetFilter( filter_name );
-  if( filter != NULL )
-  {
-    auto output = filter->GetOutputData< vtkPolyData >( output_name );
-    if( output != NULL )
-    {
-      auto actor = this->m_UI->Viewer->GetActor( output );
-      if( actor != NULL )
-      {
-        cpExtensions::QT::PropertyWidget* wdg =
-          new cpExtensions::QT::PropertyWidget( NULL );
-        wdg->SetProp( actor );
-        wdg->SetRenderWindow(
-          this->m_UI->Viewer->GetInteractor( 3 )->GetRenderWindow( )
-          );
-        wdg->show( );
-
-      } // fi
-    }
-    else
-      QMessageBox::critical(
-        this,
-        QMessageBox::tr( "Error showing data" ),
-        QMessageBox::tr( "No known VTK conversion!" )
-        );
+  /* TODO
+     auto filter = this->m_Workspace.GetFilter( filter_name );
+     if( filter != NULL )
+     {
+     auto output = filter->GetOutputData< vtkPolyData >( output_name );
+     if( output != NULL )
+     {
+     auto actor = this->m_UI->Viewer->GetActor( output );
+     if( actor != NULL )
+     {
+     cpExtensions::QT::PropertyWidget* wdg =
+     new cpExtensions::QT::PropertyWidget( NULL );
+     wdg->SetProp( actor );
+     wdg->SetRenderWindow(
+     this->m_UI->Viewer->GetInteractor( 3 )->GetRenderWindow( )
+     );
+     wdg->show( );
 
-  } // fi
+     } // fi
+     }
+     else
+     QMessageBox::critical(
+     this,
+     QMessageBox::tr( "Error showing data" ),
+     QMessageBox::tr( "No known VTK conversion!" )
+     );
+
+     } // fi
+  */
 }
 
 // eof - $RCSfile$
diff --git a/lib/cpExtensions/QT/PropertyWidget.cxx b/lib/cpExtensions/QT/PropertyWidget.cxx
deleted file mode 100644 (file)
index 3b719ff..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-#include <cpExtensions/QT/PropertyWidget.h>
-
-#ifdef cpExtensions_QT4
-
-#include <QColorDialog>
-#include <vtkActor.h>
-#include <vtkMapper.h>
-#include <vtkProp.h>
-#include <vtkProperty.h>
-#include <vtkRenderWindow.h>
-
-#include <cpExtensions/ui_PropertyWidget.h>
-
-// -------------------------------------------------------------------------
-cpExtensions::QT::PropertyWidget::
-PropertyWidget( QWidget* parent )
-  : QWidget( parent ),
-    m_UI( new Ui::PropertyWidget ),
-    m_Prop( NULL ),
-    m_Window( NULL )
-{
-  this->m_UI->setupUi( this );
-  this->connect(
-    this->m_UI->m_Color, SIGNAL( clicked( ) ),
-    this, SLOT( _Color( ) )
-    );
-  this->connect(
-    this->m_UI->m_Opacity, SIGNAL( valueChanged( int ) ),
-    this, SLOT( _Opacity( int ) )
-    );
-  this->connect(
-    this->m_UI->m_LineWidth, SIGNAL( valueChanged( double ) ),
-    this, SLOT( _LineWidth( double ) )
-    );
-  this->connect(
-    this->m_UI->m_PointSize, SIGNAL( valueChanged( double ) ),
-    this, SLOT( _PointSize( double ) )
-    );
-}
-
-// -------------------------------------------------------------------------
-cpExtensions::QT::PropertyWidget::
-~PropertyWidget( )
-{
-  delete this->m_UI;
-}
-
-// -------------------------------------------------------------------------
-vtkProp* cpExtensions::QT::PropertyWidget::
-GetProp( )
-{
-  return( this->m_Prop );
-}
-
-// -------------------------------------------------------------------------
-vtkRenderWindow* cpExtensions::QT::PropertyWidget::
-GetRenderWindow( )
-{
-  return( this->m_Window );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::PropertyWidget::
-SetProp( vtkProp* p )
-{
-  this->m_Prop = p;
-  if( this->m_Prop == NULL )
-    return;
-
-  auto actor = dynamic_cast< vtkActor* >( this->m_Prop );
-  if( actor == NULL )
-    return;
-
-  double opacity = actor->GetProperty( )->GetOpacity( );
-  double lw = actor->GetProperty( )->GetLineWidth( );
-  double ps = actor->GetProperty( )->GetPointSize( );
-  opacity *= this->m_UI->m_Opacity->maximum( );
-
-  this->m_UI->m_Opacity->setValue( opacity );
-  this->m_UI->m_LineWidth->setValue( lw );
-  this->m_UI->m_PointSize->setValue( ps );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::PropertyWidget::
-SetRenderWindow( vtkRenderWindow* w )
-{
-  this->m_Window = w;
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::PropertyWidget::
-_Color( )
-{
-  if( this->m_Prop == NULL )
-    return;
-
-  auto actor = dynamic_cast< vtkActor* >( this->m_Prop );
-  if( actor == NULL )
-    return;
-
-  double rgb[ 3 ];
-  actor->GetProperty( )->GetColor( rgb );
-  QColor color =
-    QColorDialog::getColor(
-      QColor( rgb[ 0 ] * 255, rgb[ 1 ] * 255, rgb[ 2 ] * 255 ),
-      this,
-      "Select Color",
-      QColorDialog::DontUseNativeDialog
-      );
-  if( color.isValid( ) )
-  {
-    rgb[ 0 ] = double( color.red( ) ) / double( 255 );
-    rgb[ 1 ] = double( color.green( ) ) / double( 255 );
-    rgb[ 2 ] = double( color.blue( ) ) / double( 255 );
-    actor->GetMapper( )->ScalarVisibilityOff( );
-    actor->GetProperty( )->SetColor( rgb );
-    actor->Modified( );
-    if( this->m_Window != NULL )
-      this->m_Window->Render( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::PropertyWidget::
-_Opacity( int o )
-{
-  if( this->m_Prop == NULL )
-    return;
-
-  auto actor = dynamic_cast< vtkActor* >( this->m_Prop );
-  if( actor == NULL )
-    return;
-  double v = double( o ) / double( this->m_UI->m_Opacity->maximum( ) );
-  actor->GetProperty( )->SetOpacity( v );
-  actor->Modified( );
-  if( this->m_Window != NULL )
-    this->m_Window->Render( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::PropertyWidget::
-_LineWidth( double lw )
-{
-  if( this->m_Prop == NULL )
-    return;
-
-  auto actor = dynamic_cast< vtkActor* >( this->m_Prop );
-  if( actor == NULL )
-    return;
-  actor->GetProperty( )->SetLineWidth( lw );
-  actor->Modified( );
-  if( this->m_Window != NULL )
-    this->m_Window->Render( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::PropertyWidget::
-_PointSize( double ps )
-{
-  if( this->m_Prop == NULL )
-    return;
-
-  auto actor = dynamic_cast< vtkActor* >( this->m_Prop );
-  if( actor == NULL )
-    return;
-  actor->GetProperty( )->SetPointSize( ps );
-  actor->Modified( );
-  if( this->m_Window != NULL )
-    this->m_Window->Render( );
-}
-
-#endif // cpExtensions_QT4
-
-// eof - $RCSfile$
diff --git a/lib/cpExtensions/QT/PropertyWidget.h b/lib/cpExtensions/QT/PropertyWidget.h
deleted file mode 100644 (file)
index 598ad08..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef __CPEXTENSIONS__QT__PROPERTYWIDGET__H__
-#define __CPEXTENSIONS__QT__PROPERTYWIDGET__H__
-
-#include <cpExtensions/Config.h>
-
-#ifdef cpExtensions_QT4
-
-#include <QWidget>
-
-// -------------------------------------------------------------------------
-class vtkProp;
-class vtkRenderWindow;
-
-namespace Ui
-{
-  class PropertyWidget;
-}
-
-// -------------------------------------------------------------------------
-namespace cpExtensions
-{
-  namespace QT
-  {
-    /**
-     */
-    class cpExtensions_EXPORT PropertyWidget
-      : public QWidget
-    {
-      Q_OBJECT;
-
-    public:
-      typedef PropertyWidget Self;
-
-    public:
-      explicit PropertyWidget( QWidget* parent = 0 );
-      virtual ~PropertyWidget( );
-
-      vtkProp* GetProp( );
-      vtkRenderWindow* GetRenderWindow( );
-      void SetProp( vtkProp* p );
-      void SetRenderWindow( vtkRenderWindow* w );
-
-    protected slots:
-      void _Color( );
-      void _Opacity( int o );
-      void _LineWidth( double lw );
-      void _PointSize( double ps );
-
-    protected:
-      Ui::PropertyWidget* m_UI;
-      vtkProp*            m_Prop;
-      vtkRenderWindow*    m_Window;
-    };
-
-  } // ecapseman
-
-} // ecapseman
-
-#endif // cpExtensions_QT4
-
-#endif // __CPEXTENSIONS__QT__PROPERTYWIDGET__H__
-
-// eof - $RCSfile$
diff --git a/lib/cpExtensions/QT/PropertyWidget.ui b/lib/cpExtensions/QT/PropertyWidget.ui
deleted file mode 100644 (file)
index 3784ecd..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>PropertyWidget</class>
- <widget class="QWidget" name="PropertyWidget">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>595</width>
-    <height>125</height>
-   </rect>
-  </property>
-  <property name="minimumSize">
-   <size>
-    <width>595</width>
-    <height>125</height>
-   </size>
-  </property>
-  <property name="maximumSize">
-   <size>
-    <width>595</width>
-    <height>125</height>
-   </size>
-  </property>
-  <property name="windowTitle">
-   <string>Form</string>
-  </property>
-  <layout class="QGridLayout" name="gridLayout">
-   <item row="0" column="0">
-    <layout class="QVBoxLayout" name="verticalLayout_2">
-     <item>
-      <widget class="QPushButton" name="m_Color">
-       <property name="text">
-        <string>Color</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <layout class="QVBoxLayout" name="verticalLayout">
-       <item>
-        <layout class="QHBoxLayout" name="horizontalLayout">
-         <item>
-          <widget class="QLabel" name="label">
-           <property name="minimumSize">
-            <size>
-             <width>54</width>
-             <height>21</height>
-            </size>
-           </property>
-           <property name="maximumSize">
-            <size>
-             <width>54</width>
-             <height>21</height>
-            </size>
-           </property>
-           <property name="text">
-            <string>Opacity:</string>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="QSlider" name="m_Opacity">
-           <property name="maximum">
-            <number>100</number>
-           </property>
-           <property name="value">
-            <number>100</number>
-           </property>
-           <property name="orientation">
-            <enum>Qt::Horizontal</enum>
-           </property>
-          </widget>
-         </item>
-        </layout>
-       </item>
-       <item>
-        <layout class="QHBoxLayout" name="horizontalLayout_4">
-         <item>
-          <layout class="QHBoxLayout" name="horizontalLayout_2">
-           <item>
-            <widget class="QLabel" name="label_2">
-             <property name="minimumSize">
-              <size>
-               <width>71</width>
-               <height>21</height>
-              </size>
-             </property>
-             <property name="maximumSize">
-              <size>
-               <width>71</width>
-               <height>21</height>
-              </size>
-             </property>
-             <property name="text">
-              <string>Line width:</string>
-             </property>
-            </widget>
-           </item>
-           <item>
-            <widget class="QDoubleSpinBox" name="m_LineWidth">
-             <property name="maximum">
-              <double>100.000000000000000</double>
-             </property>
-             <property name="singleStep">
-              <double>1.000000000000000</double>
-             </property>
-             <property name="value">
-              <double>1.000000000000000</double>
-             </property>
-            </widget>
-           </item>
-          </layout>
-         </item>
-         <item>
-          <layout class="QHBoxLayout" name="horizontalLayout_3">
-           <item>
-            <widget class="QLabel" name="label_3">
-             <property name="minimumSize">
-              <size>
-               <width>67</width>
-               <height>21</height>
-              </size>
-             </property>
-             <property name="maximumSize">
-              <size>
-               <width>67</width>
-               <height>21</height>
-              </size>
-             </property>
-             <property name="text">
-              <string>Point size:</string>
-             </property>
-            </widget>
-           </item>
-           <item>
-            <widget class="QDoubleSpinBox" name="m_PointSize">
-             <property name="maximum">
-              <double>100.000000000000000</double>
-             </property>
-             <property name="singleStep">
-              <double>1.000000000000000</double>
-             </property>
-             <property name="value">
-              <double>1.000000000000000</double>
-             </property>
-            </widget>
-           </item>
-          </layout>
-         </item>
-        </layout>
-       </item>
-      </layout>
-     </item>
-    </layout>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
index ab47c28a32e0e354b1e4a0dafcd57ac0ad852c80..f838a2ea704c118576580bd39897728d1f5277f1 100644 (file)
@@ -14,10 +14,10 @@ SimpleMPRWidget( QWidget* parent )
   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_VTK[ 0 ] = this->m_UI->VTK_X;
+  this->m_VTK[ 1 ] = this->m_UI->VTK_Y;
+  this->m_VTK[ 2 ] = this->m_UI->VTK_Z;
+  this->m_VTK[ 3 ] = this->m_UI->VTK_3D;
 
   for( unsigned int i = 0; i < 4; ++i )
   {
@@ -66,15 +66,16 @@ Clear( )
 void cpExtensions::QT::SimpleMPRWidget::
 SetMainImage( vtkImageData* image )
 {
+  this->Clear( );
   for( unsigned int i = 0; i < 3; ++i )
   {
-    this->m_2DSlices[ i ] = vtkSmartPointer< TActors >::New( );
+    this->m_2DSlices[ i ] = vtkSmartPointer< TSliceActors >::New( );
     this->m_2DSlices[ i ]->SetInputData( image, i );
     this->m_2DSlices[ i ]->PushInto( this->m_Renderers[ i ] );
     this->m_VTK[ i ]->GetRenderWindow( )->GetInteractor( )->
       SetInteractorStyle( this->m_2DSlices[ i ]->GetStyle( ) );
 
-    this->m_3DSlices[ i ] = vtkSmartPointer< TActors >::New( );
+    this->m_3DSlices[ i ] = vtkSmartPointer< TSliceActors >::New( );
     this->m_3DSlices[ i ]->SetInputData( image, i );
     this->m_3DSlices[ i ]->PushInto( this->m_Renderers[ 3 ] );
     this->m_3DSlices[ i ]->SetStyle(
@@ -85,58 +86,133 @@ SetMainImage( vtkImageData* image )
       );
 
   } // rof
+  this->_AssociateSlices( );
+}
 
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+SetMainActor( vtkImageActor* actor )
+{
+  this->Clear( );
+  vtkImageData* image = NULL;
   for( unsigned int i = 0; i < 3; ++i )
   {
-    for( unsigned int j = 0; j < 3; ++j )
+    this->m_2DSlices[ i ] = vtkSmartPointer< TSliceActors >::New( );
+    if( i == 0 )
     {
-      if( i != j )
-        this->m_2DSlices[ i ]->AssociateSlice( this->m_2DSlices[ j ] );
-      this->m_2DSlices[ i ]->AssociateSlice( this->m_3DSlices[ j ] );
-
-    } // rof
+      this->m_2DSlices[ i ]->SetInputActor( actor, i );
+      image = this->m_2DSlices[ i ]->GetInputData( );
+    }
+    else
+      this->m_2DSlices[ i ]->SetInputData( image, i );
+    this->m_2DSlices[ i ]->PushInto( this->m_Renderers[ i ] );
+    this->m_VTK[ i ]->GetRenderWindow( )->GetInteractor( )->
+      SetInteractorStyle( this->m_2DSlices[ i ]->GetStyle( ) );
 
-  } // rof
-  for( unsigned int i = 0; i < 3; ++i )
-  {
-    this->m_2DSlices[ i ]->GetStyle( )->
-      SetCurrentRenderer( this->m_Renderers[ i ] );
-    this->m_Renderers[ i ]->ResetCamera( );
-    this->m_VTK[ i ]->GetRenderWindow( )->Render( );
+    this->m_3DSlices[ i ] = vtkSmartPointer< TSliceActors >::New( );
+    this->m_3DSlices[ i ]->SetInputData( image, i );
+    this->m_3DSlices[ i ]->PushInto( this->m_Renderers[ 3 ] );
+    this->m_3DSlices[ i ]->SetStyle(
+      dynamic_cast< vtkInteractorStyle* >(
+        this->m_Renderers[ 3 ]->GetRenderWindow( )->
+        GetInteractor( )->GetInteractorStyle( )
+        )
+      );
 
   } // rof
-  this->m_Renderers[ 3 ]->ResetCamera( );
-  this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
+  this->_AssociateSlices( );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::QT::SimpleMPRWidget::
-AddMesh( vtkPolyData* mesh )
+AddImage( vtkImageData* image )
 {
-  PolyDataActor a;
-  a.Configure( mesh );
-  this->m_PolyDatas[ mesh ] = a;
-  this->m_Renderers[ 3 ]->AddViewProp( a.Actor );
+  std::cerr << "SimpleMPR: adding image" << std::endl;
+  std::exit( 1 );
+}
 
-  bool has_main_image = false;
-  for( unsigned int i = 0; i < 3; ++i )
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+AddImageActor( vtkImageActor* actor )
+{
+  unsigned int i = 0;
+  bool cont = true;
+  while( i < 3 && cont )
   {
     if( this->m_2DSlices[ i ].GetPointer( ) != NULL )
     {
-      if( this->m_2DSlices[ i ]->GetInputData( ) != NULL )
+      if( this->m_2DSlices[ i ]->GetImageActor( ) != NULL )
       {
-        has_main_image = true;
-        this->m_2DSlices[ i ]->AddMesh( mesh );
-        this->m_2DSlices[ i ]->Render( );
-
-      } // fi
+        // TODO: add image actor
+      }
+      else
+        cont = false;
 
     } // fi
+    i++;
 
   } // rof
-  if( !has_main_image )
-    this->m_Renderers[ 3 ]->ResetCamera( );
-  this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
+
+  // Add if no actors were found
+  if( cont )
+    this->SetMainActor( actor );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+AddMesh( vtkPolyData* mesh )
+{
+  std::cerr << "SimpleMPR: adding mesh" << std::endl;
+  std::exit( 1 );
+  /* TODO
+     PolyDataActor a;
+     a.Configure( mesh );
+     this->m_PolyDatas[ mesh ] = a;
+     this->m_Renderers[ 3 ]->AddViewProp( a.Actor );
+
+     bool has_main_image = false;
+     for( unsigned int i = 0; i < 3; ++i )
+     {
+     if( this->m_2DSlices[ i ].GetPointer( ) != NULL )
+     {
+     if( this->m_2DSlices[ i ]->GetInputData( ) != NULL )
+     {
+     has_main_image = true;
+     this->m_2DSlices[ i ]->AddMesh( mesh );
+     this->m_2DSlices[ i ]->Render( );
+
+     } // fi
+
+     } // fi
+
+     } // rof
+     if( !has_main_image )
+     this->m_Renderers[ 3 ]->ResetCamera( );
+     this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
+  */
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+AddMeshActor( vtkActor* actor )
+{
+  std::cerr << "SimpleMPR: adding mesh actor" << std::endl;
+  std::exit( 1 );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+AddActor( vtkProp* actor )
+{
+  auto ia = dynamic_cast< vtkImageActor* >( actor );
+  if( ia == NULL )
+  {
+    auto ma = dynamic_cast< vtkActor* >( actor );
+    if( ma != NULL )
+      this->AddMeshActor( ma );
+  }
+  else
+    this->AddImageActor( ia );
 }
 
 // -------------------------------------------------------------------------
@@ -160,39 +236,85 @@ GetRenderer( unsigned int i )
 }
 
 // -------------------------------------------------------------------------
-std::vector< std::pair< vtkImageActor*, vtkRenderer* > >
-cpExtensions::QT::SimpleMPRWidget::
-GetMainImageActors( )
+vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget::
+GetRenderWindow( unsigned int i )
 {
-  std::vector< std::pair< vtkImageActor*, vtkRenderer* > > actors;
-  for( unsigned int i = 0; i < 3; ++i )
+  if( i < 4 )
   {
-    actors.push_back(
-      std::pair< vtkImageActor*, vtkRenderer* >(
-        this->m_2DSlices[ i ]->GetImageActor( ),
-        this->m_Renderers[ i ]
-        )
-      );
-    actors.push_back(
-      std::pair< vtkImageActor*, vtkRenderer* >(
-        this->m_3DSlices[ i ]->GetImageActor( ),
-        this->m_Renderers[ 3 ]
-        )
-      );
-
-  } // rof
-  return( actors );
+    if( this->m_Renderers[ i ].GetPointer( ) != NULL )
+      return( this->m_Renderers[ i ]->GetRenderWindow( ) );
+    else
+      return( NULL );
+  }
+  else
+    return( NULL );
 }
 
 // -------------------------------------------------------------------------
-vtkActor* cpExtensions::QT::SimpleMPRWidget::
-GetActor( vtkPolyData* mesh )
+/* TODO
+   std::vector< std::pair< vtkImageActor*, vtkRenderer* > >
+   cpExtensions::QT::SimpleMPRWidget::
+   GetMainImageActors( )
+   {
+   std::vector< std::pair< vtkImageActor*, vtkRenderer* > > actors;
+   for( unsigned int i = 0; i < 3; ++i )
+   {
+   actors.push_back(
+   std::pair< vtkImageActor*, vtkRenderer* >(
+   this->m_2DSlices[ i ]->GetImageActor( ),
+   this->m_Renderers[ i ]
+   )
+   );
+   actors.push_back(
+   std::pair< vtkImageActor*, vtkRenderer* >(
+   this->m_3DSlices[ i ]->GetImageActor( ),
+   this->m_Renderers[ 3 ]
+   )
+   );
+
+   } // rof
+   return( actors );
+   }
+*/
+
+// -------------------------------------------------------------------------
+/* TODO
+   vtkActor* cpExtensions::QT::SimpleMPRWidget::
+   GetActor( vtkPolyData* mesh )
+   {
+   auto i = this->m_PolyDatas.find( mesh );
+   if( i != this->m_PolyDatas.end( ) )
+   return( i->second.Actor.GetPointer( ) );
+   else
+   return( NULL );
+   }
+*/
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+_AssociateSlices( )
 {
-  auto i = this->m_PolyDatas.find( mesh );
-  if( i != this->m_PolyDatas.end( ) )
-    return( i->second.Actor.GetPointer( ) );
-  else
-    return( NULL );
+  for( unsigned int i = 0; i < 3; ++i )
+  {
+    for( unsigned int j = 0; j < 3; ++j )
+    {
+      if( i != j )
+        this->m_2DSlices[ i ]->AssociateSlice( this->m_2DSlices[ j ] );
+      this->m_2DSlices[ i ]->AssociateSlice( this->m_3DSlices[ j ] );
+
+    } // rof
+
+  } // rof
+  for( unsigned int i = 0; i < 3; ++i )
+  {
+    this->m_2DSlices[ i ]->GetStyle( )->
+      SetCurrentRenderer( this->m_Renderers[ i ] );
+    this->m_Renderers[ i ]->ResetCamera( );
+    this->m_VTK[ i ]->GetRenderWindow( )->Render( );
+
+  } // rof
+  this->m_Renderers[ 3 ]->ResetCamera( );
+  this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
 }
 
 // -------------------------------------------------------------------------
index d5f33539fe0fb5cd29a0437fa32f65d55f3cc8ca..802846063e4c89fcbd019aab8e531e9d500f2339 100644 (file)
@@ -39,7 +39,7 @@ namespace cpExtensions
     public:
       typedef SimpleMPRWidget Self;
 
-      typedef cpExtensions::Visualization::ImageSliceActors TActors;
+      typedef cpExtensions::Visualization::ImageSliceActors TSliceActors;
 
       /**
        */
@@ -96,14 +96,25 @@ namespace cpExtensions
       // Data management
       void Clear( );
       void SetMainImage( vtkImageData* image );
+      void SetMainActor( vtkImageActor* actor );
+      void AddImage( vtkImageData* image );
+      void AddImageActor( vtkImageActor* actor );
       void AddMesh( vtkPolyData* mesh );
+      void AddMeshActor( vtkActor* actor );
+      void AddActor( vtkProp* actor );
 
       // Visual objects
       vtkRenderWindowInteractor* GetInteractor( unsigned int i );
       vtkRenderer* GetRenderer( unsigned int i );
-      std::vector< std::pair< vtkImageActor*, vtkRenderer* > >
-        GetMainImageActors( );
-      vtkActor* GetActor( vtkPolyData* mesh );
+      vtkRenderWindow* GetRenderWindow( unsigned int i );
+      /* TODO
+         std::vector< std::pair< vtkImageActor*, vtkRenderer* > >
+         GetMainImageActors( );
+         vtkActor* GetActor( vtkPolyData* mesh );
+      */
+
+    protected:
+      void _AssociateSlices( );
 
     private slots:
       void _SyncBottom( int a, int b );
@@ -113,9 +124,9 @@ namespace cpExtensions
       Ui::SimpleMPRWidget* m_UI;
       QVTKWidget*          m_VTK[ 4 ];
 
-      vtkSmartPointer< vtkRenderer > m_Renderers[ 4 ];
-      vtkSmartPointer< TActors >     m_2DSlices[ 3 ];
-      vtkSmartPointer< TActors >     m_3DSlices[ 3 ];
+      vtkSmartPointer< vtkRenderer >  m_Renderers[ 4 ];
+      vtkSmartPointer< TSliceActors > m_2DSlices[ 3 ];
+      vtkSmartPointer< TSliceActors > m_3DSlices[ 3 ];
 
       std::map< vtkPolyData*, PolyDataActor > m_PolyDatas;
     };
index c8246e1f6c14ffbccf09e843f973dd761901e8b5..fc1dfa39660453b655564d94c5cc4c06e78eca62 100644 (file)
@@ -35,7 +35,7 @@
       <property name="orientation">
        <enum>Qt::Horizontal</enum>
       </property>
-      <widget class="QVTKWidget" name="VTK00" native="true">
+      <widget class="QVTKWidget" name="VTK_Y">
        <property name="minimumSize">
         <size>
          <width>200</width>
@@ -43,7 +43,7 @@
         </size>
        </property>
       </widget>
-      <widget class="QVTKWidget" name="VTK01" native="true">
+      <widget class="QVTKWidget" name="VTK_X">
        <property name="minimumSize">
         <size>
          <width>200</width>
@@ -62,7 +62,7 @@
       <property name="orientation">
        <enum>Qt::Horizontal</enum>
       </property>
-      <widget class="QVTKWidget" name="VTK10" native="true">
+      <widget class="QVTKWidget" name="VTK_Z">
        <property name="minimumSize">
         <size>
          <width>200</width>
@@ -70,7 +70,7 @@
         </size>
        </property>
       </widget>
-      <widget class="QVTKWidget" name="VTK11" native="true">
+      <widget class="QVTKWidget" name="VTK_3D">
        <property name="minimumSize">
         <size>
          <width>200</width>
@@ -87,7 +87,7 @@
   <customwidget>
    <class>QVTKWidget</class>
    <extends>QWidget</extends>
-   <header location="global">QVTKWidget.h</header>
+   <header>QVTKWidget.h</header>
    <container>1</container>
   </customwidget>
  </customwidgets>
index 2254ac9501169b8a7e729dc8c684a1c559a04ec5..3ac1e5d909afd1530a394419bc724edfb515e999 100644 (file)
@@ -82,6 +82,21 @@ SetInputData( vtkImageData* data, int orientation )
   this->_ConfigureInput( orientation );
 }
 
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+SetInputActor( vtkProp* actor, int orientation )
+{
+  auto real_actor = dynamic_cast< vtkImageActor* >( actor );
+  if( real_actor == NULL )
+    return;
+  auto real_mapper =
+    dynamic_cast< vtkImageSliceMapper* >( real_actor->GetMapper( ) );
+  if( real_mapper == NULL )
+    return;
+  this->m_Mapper = real_mapper;
+  this->_ConfigureInput( orientation );
+}
+
 // -------------------------------------------------------------------------
 vtkImageData* cpExtensions::Visualization::ImageSliceActors::
 GetInputData( )
index 075c6ec0edabea6a31daff54e18a7d7322338d62..6aca9db1b470ce4f705024db2ebbf01de258294b 100644 (file)
@@ -83,6 +83,7 @@ namespace cpExtensions
       void Clear( );
       void SetInputConnection( vtkAlgorithmOutput* aout, int orientation );
       void SetInputData( vtkImageData* data, int orientation );
+      void SetInputActor( vtkProp* actor, int orientation );
       vtkImageData* GetInputData( );
 
       vtkImageActor* GetImageActor( );
index 8a9536b70ddf79140508e03bee159619b021eec3..b423294ff53e05073948b0c1c9d76b02dc981f33 100644 (file)
@@ -14,7 +14,7 @@ bool cpPipelineEditor::BaseQtMainWindow::_TBlocker::
 eventFilter( QObject* obj, QEvent* event )
 {
   return( true ); // -> Block all events
-  /* NOTE: correct implementation:
+  /* NOTE: this should be the correct implementation:
      switch( event->type( ) )
      {
      //list event you want to prevent here ...
index ebfb8b224a7176f4564600347b4d831fa2de7572..9fd054d8a7f2b07b64b454ad6a54d237d971a859 100644 (file)
@@ -85,66 +85,10 @@ CreateQtDialog( )
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::DataObject::
-AddVTKActor( vtkProp* actor, vtkRenderer* renderer )
+vtkProp* cpPlugins::DataObject::
+CreateVTKActor( )
 {
-  if( actor != NULL && renderer != NULL )
-  {
-    TDataView v;
-    v.Actor = actor;
-    v.Renderer = renderer;
-    this->m_Actors.insert( v );
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::DataObject::
-ClearVTKActors( )
-{
-  this->m_Actors.clear( );
-  this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::DataObject::
-RenderVTKActors( )
-{
-  for( auto i = this->m_Actors.begin( ); i != this->m_Actors.end( ); ++i )
-    i->Renderer->GetRenderWindow( )->Render( );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::DataObject::TDataViews::
-iterator cpPlugins::DataObject::
-BeginVTKActors( )
-{
-  return( this->m_Actors.begin( ) );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::DataObject::TDataViews::
-iterator cpPlugins::DataObject::
-EndVTKActors( )
-{
-  return( this->m_Actors.end( ) );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::DataObject::TDataViews::
-const_iterator cpPlugins::DataObject::
-BeginVTKActors( ) const
-{
-  return( this->m_Actors.begin( ) );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::DataObject::TDataViews::
-const_iterator cpPlugins::DataObject::
-EndVTKActors( ) const
-{
-  return( this->m_Actors.end( ) );
+  return( NULL );
 }
 
 // -------------------------------------------------------------------------
index 9ff55d8a0cee67db4090c5694e67ea88de329ad4..0abc4a4defe3ab9c909453e56026654cff1455c1 100644 (file)
@@ -2,9 +2,9 @@
 #define __CPPLUGINS__DATAOBJECT__H__
 
 #include <cpPlugins/Object.h>
-#include <set>
-#include <vtkProp.h>
-#include <vtkRenderer.h>
+
+// Some forward declarations
+class vtkProp;
 
 namespace cpPlugins
 {
@@ -28,15 +28,6 @@ namespace cpPlugins
     itkTypeMacro( DataObject, Object );
     cpPlugins_Id_Macro( DataObject, Object );
 
-    struct TDataView
-    {
-      vtkSmartPointer< vtkProp >     Actor;
-      vtkSmartPointer< vtkRenderer > Renderer;
-      bool operator<( const TDataView& b ) const
-        { return( this->Actor.GetPointer( ) < b.Actor.GetPointer( ) ); }
-    };
-    typedef std::set< TDataView > TDataViews;
-
   public:
     ProcessObject* GetSource( );
     const ProcessObject* GetSource( ) const;
@@ -48,13 +39,7 @@ namespace cpPlugins
     virtual DataObjectVisualizationQtDialog* CreateQtDialog( );
 
     // VTK actors
-    virtual void AddVTKActor( vtkProp* actor, vtkRenderer* renderer );
-    virtual void ClearVTKActors( );
-    virtual void RenderVTKActors( );
-    TDataViews::iterator BeginVTKActors( );
-    TDataViews::iterator EndVTKActors( );
-    TDataViews::const_iterator BeginVTKActors( ) const;
-    TDataViews::const_iterator EndVTKActors( ) const;
+    virtual vtkProp* CreateVTKActor( );
 
   protected:
     DataObject( );
@@ -67,7 +52,6 @@ namespace cpPlugins
 
   protected:
     ProcessObject* m_Source;
-    TDataViews     m_Actors;
   };
 
 } // ecapseman
index cd6ca7662d387bcdb9f47e923fd82827f74e4bbe..7494eed3116ce07575d14644c2dde45b1f3d980a 100644 (file)
@@ -116,6 +116,7 @@ _updateWidgets( )
 void cpPlugins::DataObjectVisualizationQtDialog::
 _configureForImage( )
 {
+  /* TODO
   auto image = this->m_DataObject->GetVTK< vtkImageData >( );
   auto aIt = this->m_DataObject->BeginVTKActors( );
   if( image == NULL || aIt == this->m_DataObject->EndVTKActors( ) )
@@ -204,12 +205,14 @@ _configureForImage( )
   op_layout->addWidget( op_label );
   op_layout->addWidget( op_sld );
   this->m_ToolsLayout->addLayout( op_layout );
+*/
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::DataObjectVisualizationQtDialog::
 _configureForMesh( )
 {
+  /* TODO
   auto mesh = this->m_DataObject->GetVTK< vtkPolyData >( );
   auto aIt = this->m_DataObject->BeginVTKActors( );
   if( mesh == NULL || aIt == this->m_DataObject->EndVTKActors( ) )
@@ -305,12 +308,14 @@ _configureForMesh( )
   op_layout->addWidget( op_label );
   op_layout->addWidget( op_sld );
   this->m_ToolsLayout->addLayout( op_layout );
+*/
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::DataObjectVisualizationQtDialog::
 _setWindow( double w )
 {
+  /* TODO
   if( this->m_DataObject == NULL )
     return;
   auto aIt = this->m_DataObject->BeginVTKActors( );
@@ -326,12 +331,14 @@ _setWindow( double w )
 
   } // rof
   this->_render( );
+*/
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::DataObjectVisualizationQtDialog::
 _setLevel( double l )
 {
+  /* TODO
   if( this->m_DataObject == NULL )
     return;
   auto aIt = this->m_DataObject->BeginVTKActors( );
@@ -347,15 +354,18 @@ _setLevel( double l )
 
   } // rof
   this->_render( );
+*/
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::DataObjectVisualizationQtDialog::
 _render( )
 {
+  /* TODO
   if( this->m_DataObject == NULL )
     return;
   this->m_DataObject->RenderVTKActors( );
+*/
 }
 
 // -------------------------------------------------------------------------
@@ -450,6 +460,7 @@ _sldLevel( int v )
 void cpPlugins::DataObjectVisualizationQtDialog::
 _sldOpacity( int v )
 {
+  /* TODO
   if( this->m_DataObject == NULL )
     return;
   auto* sld = this->findChild< QSlider* >( "op_sld" );
@@ -479,6 +490,7 @@ _sldOpacity( int v )
 
   } // rof
   this->_render( );
+*/
 }
 
 // -------------------------------------------------------------------------
@@ -497,6 +509,7 @@ _boxLineWidth( int v )
 void cpPlugins::DataObjectVisualizationQtDialog::
 _scalarVisibility( int v )
 {
+  /* TODO
   if( this->m_DataObject == NULL )
     return;
   auto* btn = this->findChild< QPushButton* >( "color_button" );
@@ -529,12 +542,14 @@ _scalarVisibility( int v )
 
   } // rof
   this->_render( );
+*/
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::DataObjectVisualizationQtDialog::
 _color( )
 {
+  /* TODO
   if( this->m_DataObject == NULL )
     return;
   auto* btn = this->findChild< QPushButton* >( "color_button" );
@@ -559,6 +574,7 @@ _color( )
     this->_scalarVisibility( 0 );
 
   } // fi
+*/
 }
 
 #endif // cpPlugins_QT4
index ba3ff298c951b66f6809ea1dc5bcc4a074b00758..04d28da6069585e16d8aacf162fa065d8fd2deaf 100644 (file)
@@ -1,5 +1,8 @@
 #include <cpPlugins/Image.h>
 
+#include <vtkImageActor.h>
+#include <vtkImageSliceMapper.h>
+
 // -------------------------------------------------------------------------
 void cpPlugins::Image::
 SetITK( itk::LightObject* o )
@@ -25,6 +28,18 @@ SetVTK( vtkObjectBase* o )
   std::exit( 1 );
 }
 
+// -------------------------------------------------------------------------
+vtkProp* cpPlugins::Image::
+CreateVTKActor( )
+{
+  vtkImageSliceMapper* mapper = vtkImageSliceMapper::New( );
+  vtkImageActor* actor = vtkImageActor::New( );
+  mapper->SetInputData( this->GetVTK< vtkImageData >( ) );
+  actor->SetMapper( mapper );
+  mapper->Delete( );
+  return( actor );
+}
+
 // -------------------------------------------------------------------------
 cpPlugins::Image::
 Image( )
index 4831ecfc0562bbe27834908645e59c4f4be8895a..62b9ff183fd7dc71c6fe64220724853b8428d19c 100644 (file)
@@ -27,6 +27,8 @@ namespace cpPlugins
     virtual void SetITK( itk::LightObject* o ) ITK_OVERRIDE;
     virtual void SetVTK( vtkObjectBase* o ) ITK_OVERRIDE;
 
+    virtual vtkProp* CreateVTKActor( ) ITK_OVERRIDE;
+
   protected:
     Image( );
     virtual ~Image( );
index d441c49699b86e8b49e399a2dc1adb75006f1aa5..4c1fe1d298b2976faf57a21b5869bdfa1d0d365a 100644 (file)
@@ -94,6 +94,28 @@ GetFilter( const std::string& name ) const
   return( f );
 }
 
+// -------------------------------------------------------------------------
+cpPlugins::DataObject* cpPlugins::Workspace::
+GetOutput( const std::string& filter, const std::string& output )
+{
+  auto f = this->GetFilter( filter );
+  if( f != NULL )
+    return( f->GetOutput( output ) );
+  else
+    return( NULL );
+}
+
+// -------------------------------------------------------------------------
+const cpPlugins::DataObject* cpPlugins::Workspace::
+GetOutput( const std::string& filter, const std::string& output ) const
+{
+  auto f = this->GetFilter( filter );
+  if( f != NULL )
+    return( f->GetOutput( output ) );
+  else
+    return( NULL );
+}
+
 // -------------------------------------------------------------------------
 bool cpPlugins::Workspace::
 HasFilter( const std::string& name ) const
index d5884589700b5e17dc46037f00348cbae0f8930c..eaa5f115f1ae0c091736a994708f048cbd8eca57 100644 (file)
@@ -68,6 +68,12 @@ namespace cpPlugins
     // Filter management
     ProcessObject* GetFilter( const std::string& name );
     const ProcessObject* GetFilter( const std::string& name ) const;
+    DataObject* GetOutput(
+      const std::string& filter, const std::string& output
+      );
+    const DataObject* GetOutput(
+      const std::string& filter, const std::string& output
+      ) const;
     bool HasFilter( const std::string& name ) const;
     ProcessObject* CreateFilter(
       const std::string& category,