]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx
...
[cpPlugins.git] / lib / cpPlugins / Plugins / Widgets / SeedWidget.cxx
index 129a8a676136ef2458cc0d81cbdc7a76ac499668..ee8a59dfe3062d763e09ac186fe6164295af5c29 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>
@@ -13,7 +14,7 @@ SeedWidget( )
     m_Configured( false )
 {
   this->_AddInput( "ReferenceImage" );
-  this->_MakeOutput< cpPlugins::Interface::PointList >( "Output" );
+  this->_AddOutput< cpPlugins::Interface::PointList >( "Output" );
 
   this->m_Parameters->ConfigureAsBool( "SeedsAreInRealSpace" );
   this->m_Parameters->SetBool( "SeedsAreInRealSpace", true );
@@ -32,11 +33,8 @@ _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." );
-
+  auto image =
+    this->GetInputData< cpPlugins::Interface::Image >( "ReferenceImage" );
   itk::DataObject* itk_image = image->GetITK< _2DImage >( );
   if( itk_image != NULL )
     return( this->_GD0< _2DImage >( itk_image ) );
@@ -47,7 +45,6 @@ _GenerateData( )
       return( this->_GD0< _3DImage >( itk_image ) );
 
   } // fi
-
   return( "SeedWidget: Input image dimension not supported." );
 }
 
@@ -59,36 +56,65 @@ _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" );
+  auto out =
+    this->GetOutputData< 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 )
+
+  // MPR
+  if( this->m_MPRViewer != NULL )
   {
-    _S* s = dynamic_cast< _S* >( ( *iIt )->GetInteractorStyle( ) );
-    if( s != NULL )
+    for( unsigned int i = 0; i < 4; ++i )
     {
-      if( this->m_Configured )
+      _S* s =
+        dynamic_cast< _S* >(
+          this->m_MPRViewer->GetInteractor( i )->GetInteractorStyle( )
+          );
+      if( s != NULL )
       {
-        for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
+        if( this->m_Configured )
         {
-          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 );
+          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
 
-        } // rof
-      }
-      else
-        s->SeedWidgetOn( );
+  } // fi
+
+  // Single interactor
+  _S* s = dynamic_cast< _S* >( this->m_SingleInteractor );
+  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 );
 
-    } // fi
+      } // rof
+    }
+    else
+      s->SeedWidgetOn( );
 
-  } // rof
+  } // fi
   this->m_Configured = true;
   return( "" );
 }