]> Creatis software - cpPlugins.git/commitdiff
Widget integration (step 6/6): Interactive architecture finished. Needs to be tested...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 14 Oct 2015 23:30:05 +0000 (18:30 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 14 Oct 2015 23:30:05 +0000 (18:30 -0500)
31 files changed:
appli/ImageMPR/ImageMPR.cxx
appli/ImageMPR/ImageMPR.h
appli/examples/CMakeLists.txt
appli/examples/example_MPR.cxx
lib/cpExtensions/Visualization/ImageSliceActors.cxx
lib/cpExtensions/Visualization/ImageSliceActors.h
lib/cpExtensions/Visualization/MPRActors.cxx
lib/cpExtensions/Visualization/MPRActors.h
lib/cpExtensions/Visualization/MPRObjects.h
lib/cpPlugins/Interface/BaseMPRWindow.cxx
lib/cpPlugins/Interface/BaseMPRWindow.h
lib/cpPlugins/Interface/Parameters.cxx
lib/cpPlugins/Interface/Parameters.h
lib/cpPlugins/Interface/ProcessObject.cxx
lib/cpPlugins/Interface/ProcessObject.h
lib/cpPlugins/Interface/ProcessObject.hxx
lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx
lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/FloodFillImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/FloodFillImageFilter.h
lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx
lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx
lib/cpPlugins/Plugins/IO/ImageReader.cxx
lib/cpPlugins/Plugins/IO/ImageWriter.cxx
lib/cpPlugins/Plugins/IO/MeshReader.cxx
lib/cpPlugins/Plugins/IO/MeshWriter.cxx

index ada90eaa9ac06e67c5694d300146987a99c7a394..58276cb7433b6b7027347130614d0e8ee7c057d2 100644 (file)
@@ -13,10 +13,14 @@ ImageMPR::
 ImageMPR( QWidget* parent )
   : QMainWindow( parent ),
     m_UI( new Ui::ImageMPR ),
-    m_ImageLoaded( false )
+    m_ImageLoaded( "" ),
+    m_Flooding( false )
 {
   this->m_UI->setupUi( this );
 
+  // Associate callbacks
+  this->m_UI->MPR->AddCursorCommand( Self::_CursorCommand, this );
+
   // Connect actions
   ImageMPR_ConnectAction( OpenImage );
   ImageMPR_ConnectAction( OpenSegmentation );
@@ -47,7 +51,7 @@ ImageMPR::
 void ImageMPR::
 _aOpenImage( )
 {
-  if( this->m_ImageLoaded )
+  if( this->m_ImageLoaded != "" )
     this->m_UI->MPR->ClearAll( );
   this->m_ImageLoaded = this->m_UI->MPR->LoadImage( );
 }
@@ -56,7 +60,7 @@ _aOpenImage( )
 void ImageMPR::
 _aOpenSegmentation( )
 {
-  if( this->m_ImageLoaded )
+  if( this->m_ImageLoaded != "" )
     this->m_ImageLoaded = this->m_UI->MPR->LoadImage( );
 }
 
@@ -121,7 +125,19 @@ _execPlugin( )
   if( action == NULL )
     return;
   std::string name = action->text( ).toStdString( );
-  this->m_UI->MPR->ExecuteFilter( name, 0 );
+
+  if( name == "cpPlugins::BasicFilters::FloodFillImageFilter" )
+  {
+    this->m_Flooding = true;
+  }
+  else
+  {
+    this->m_Flooding = false;
+    this->m_UI->MPR->ExecuteFilter(
+      name, this->m_ImageLoaded, "SegmentedImage"
+      );
+
+  } // fi
 
   // Configure filter
   /*
@@ -165,6 +181,50 @@ _execPlugin( )
   */
 }
 
+// -------------------------------------------------------------------------
+void ImageMPR::
+_CursorCommand( double* pos, int axis, void* data )
+{
+  Self* app = reinterpret_cast< Self* >( data );
+  if( app == NULL )
+    return;
+  if( !( app->m_Flooding ) )
+    return;
+
+  cpPlugins::Interface::ProcessObject::Pointer filter =
+    app->m_UI->MPR->CreateFilter(
+      "cpPlugins::BasicFilters::FloodFillImageFilter"
+      );
+  if( filter.IsNull( ) )
+    return;
+
+  cpPlugins::Interface::Parameters* params = filter->GetParameters( );
+  params->SetPoint( "Seed", 3, pos );
+  params->SetReal( "Window", app->m_UI->MPR->GetWindow( ) );
+  params->SetReal( "Level", app->m_UI->MPR->GetLevel( ) );
+  params->SetUint( "InsideValue", 1 );
+  params->SetUint( "OutsideValue", 0 );
+  filter->SetInput( "Input", app->m_UI->MPR->GetImage( app->m_ImageLoaded ) );
+  app->m_UI->MPR->Block( );
+  std::string err = filter->Update( );
+  cpPlugins::Interface::BaseMPRWindow::TImage::Pointer image = filter->GetOutput< cpPlugins::Interface::BaseMPRWindow::TImage >( "Output" );
+  filter->DisconnectOutputs( );
+  app->m_UI->MPR->AddImage( "Segmentation", image );
+  app->m_UI->MPR->Unblock( );
+
+
+
+  /* TODO
+     std::cout
+     << "CursorCommand ==> "
+     << pos[ 0 ] << " "
+     << pos[ 1 ] << " "
+    << pos[ 2 ] << " : "
+    << axis << " "
+    << data << std::endl;
+  */
+}
+
 /*
 #include "MementoState.h"
 
index 1cc16c9cb368ed1fa33d75f6112992e7d7ddf573..a89d0f9ed2c80bf625b05889eefa73fc97f718f4 100644 (file)
@@ -119,6 +119,15 @@ class ImageMPR
   Q_OBJECT;
 
 public:
+  typedef ImageMPR    Self;
+  typedef QMainWindow Superclass;
+
+  typedef cpExtensions::Visualization::MPRObjects TMPRObjects;
+  typedef TMPRObjects::TCursorCommand     TCursorCommand;
+  typedef TMPRObjects::TMouseCommand      TMouseCommand;
+  typedef TMPRObjects::TMouseWheelCommand TMouseWheelCommand;
+  typedef TMPRObjects::TKeyCommand        TKeyCommand;
+
   // Plugins types
   /*
     typedef cpPlugins::Interface::Interface        TPluginsInterface;
@@ -157,11 +166,16 @@ private slots:
 
   void _execPlugin( );
 
+protected:
+  // Callbacks
+  static void _CursorCommand( double* pos, int axis, void* data );
+
 private:
   Ui::ImageMPR* m_UI;
 
   // Some state flags
-  bool m_ImageLoaded;
+  std::string m_ImageLoaded;
+  bool m_Flooding;
 
   // Plugins objects
   /*
index 2fd980d419444ec1760a211f143f1a3299a2a46d..517433382de2b41597ade8a1093b227a3355b065 100644 (file)
@@ -26,8 +26,9 @@ ENDFOREACH(prog)
 
 SET(
   EXAMPLES_PROGRAMS_WITH_PLUGINS
-  example_ReadWriteImage
-  example_View2DImage
+  #example_ReadWriteImage
+  #example_MPR
+  #example_View2DImage
   ##example_MarchingCubes
   ##example_OtsuFilter
   ##example_RGBImageToHSVChannels
@@ -38,8 +39,7 @@ SET(
   ##example_MPR
   )
 
-
-FOREACH(prog ${EXAMPLES_PROGRAMS}) 
+FOREACH(prog ${EXAMPLES_PROGRAMS_WITH_PLUGINS}) 
   ADD_EXECUTABLE(
     ${prog}
     ${prog}.cxx
index 9f6e113151d5d0ed38b07a13ac998d3bf0a58e3a..dca90845c3d66fd245b4b3d4378d0f4e0d6ad8b5 100644 (file)
@@ -35,6 +35,7 @@ public:
     }
   virtual void Execute( vtkObject* caller, unsigned long eId , void* data )
     {
+      /*
       vtkSliderWidget* wdg =
         reinterpret_cast< vtkSliderWidget* >( caller );
       if( wdg == NULL )
@@ -56,6 +57,7 @@ public:
         this->Actors->SetWindow( 0, rep->GetValue( ) );
       else if( title == "Level" )
         this->Actors->SetLevel( 0, rep->GetValue( ) );
+      */
     }
   SliderCallback( )
     : vtkCommand( )
@@ -126,19 +128,20 @@ int main( int argc, char* argv[] )
 
   // Create reader
   TFilter::Pointer reader =
-    plugins.CreateProcessObject( "cpPlugins::ImageReader" );
+    plugins.CreateProcessObject( "cpPlugins::IO::ImageReader" );
   if( reader.IsNull( ) )
   {
-    std::cerr << "No suitable image reader found in plugins." << std::endl;
+    std::cerr
+      << "ERROR: No suitable image reader found in plugins."
+      << std::endl;
     return( 1 );
 
   } // fi
 
   // Configure reader
-  TParameters reader_params = reader->GetDefaultParameters( );
+  TParameters* reader_params = reader->GetParameters( );
   for( int i = 2; i < argc; ++i )
-    reader_params.AddValueToStringList( "FileNames", argv[ i ] );
-  reader->SetParameters( reader_params );
+    reader_params->AddToStringList( "FileNames", argv[ i ] );
 
   // Execute reader
   std::string msg = reader->Update( );
@@ -150,7 +153,8 @@ int main( int argc, char* argv[] )
   } // fi
 
   // Get input image's vtk representation
-  vtkImageData* image = reader->GetOutput< TImage >( 0 )->GetVTKImageData( );
+  vtkImageData* image =
+    reader->GetOutput< TImage >( "Output" )->GetVTK< vtkImageData >( );
   if( image == NULL )
   {
     std::cerr
@@ -168,6 +172,7 @@ int main( int argc, char* argv[] )
   // Renderers
   vtkSmartPointer< vtkRenderer > renderer =
     vtkSmartPointer< vtkRenderer >::New( );
+  renderer->SetBackground( 0, 0, 1 );
   window->AddRenderer( renderer );
 
   // Interactor
@@ -179,13 +184,14 @@ int main( int argc, char* argv[] )
   vtkSmartPointer< TMPRActors > mpr_actors =
     vtkSmartPointer< TMPRActors >::New( );
   mpr_actors->AddInputData( image );
-  mpr_actors->PushDataInto( NULL, NULL, NULL, renderer );
+  mpr_actors->PushActorsInto( NULL, NULL, NULL, window );
 
   // Callbacks
   vtkSmartPointer< SliderCallback > cb =
     vtkSmartPointer< SliderCallback >::New( );
   cb->Actors = mpr_actors;
 
+  /*
   Slider x_slider(
     mpr_actors->GetSliceNumberMinValue( 0 ),
     mpr_actors->GetSliceNumberMaxValue( 0 ),
@@ -221,6 +227,7 @@ int main( int argc, char* argv[] )
     "Level", interactor,
     0.300, 0.05, 0.490, 0.05, cb
     );
+    */
 
   // Begin interaction
   renderer->ResetCamera( );
index 250c2ed5547e08f2a2bb969f7832b97306a54139..5ecb83fa934876563ebf33a2b476c05b63dc9ffd 100644 (file)
@@ -216,64 +216,58 @@ GetStyle( ) const
 void cpExtensions::Visualization::ImageSliceActors::
 PushActorsInto( vtkRenderWindow* window, bool force_style )
 {
+  if( window == NULL )
+    return;
   vtkRenderWindowInteractor* rwi = window->GetInteractor( );
   vtkRenderer* renderer = window->GetRenderers( )->GetFirstRenderer( );
-
+  if( rwi == NULL || renderer == NULL )
+    return;
+  
   // Update style
-  if( rwi != NULL && force_style )
-  {
+  if( force_style )
     if( rwi->GetInteractorStyle( ) != this->Style.GetPointer( ) )
-    {
       rwi->SetInteractorStyle( this->Style );
 
-    } // fi
-
-  } // fi
+  // Update actors
+  unsigned int N = this->GetNumberOfImageActors( );
+  for( unsigned int n = 0; n < N; ++n )
+    renderer->AddActor( this->GetImageActor( n ) );
+  renderer->AddActor( this->CursorActor );
+  renderer->AddActor( this->PlaneActor );
+  renderer->AddActor( this->TextActor );
+  renderer->Modified( );
+
+  // Configure camera
+  vtkCamera* camera = renderer->GetActiveCamera( );
+  if( camera == NULL )
+    return;
 
-  if( renderer != NULL )
+  // Parallel projections are better when displaying 2D images
+  if( force_style )
   {
-    // Update actors
-    unsigned int N = this->GetNumberOfImageActors( );
-    for( unsigned int n = 0; n < N; ++n )
-      renderer->AddActor( this->GetImageActor( n ) );
-    renderer->AddActor( this->CursorActor );
-    renderer->AddActor( this->PlaneActor );
-    renderer->AddActor( this->TextActor );
-    renderer->Modified( );
-
-    // Configure camera
-    vtkCamera* camera = renderer->GetActiveCamera( );
-    if( camera == NULL )
-      return;
-
-    // Parallel projections are better when displaying 2D images
-    if( force_style )
+    int axis = this->GetAxis( );
+    camera->ParallelProjectionOn( );
+    camera->SetFocalPoint( double( 0 ), double( 0 ), double( 0 ) );
+    if( axis == 0 )
     {
-      int axis = this->GetAxis( );
-      camera->ParallelProjectionOn( );
-      camera->SetFocalPoint( double( 0 ), double( 0 ), double( 0 ) );
-      if( axis == 0 )
-      {
-        camera->SetPosition( double( 1 ), double( 0 ), double( 0 ) );
-        camera->SetViewUp  ( double( 0 ), double( 1 ), double( 0 ) );
-      }
-      else if( axis == 1 )
-      {
-        camera->SetPosition( double( 0 ), double( 1 ), double(  0 ) );
-        camera->SetViewUp  ( double( 0 ), double( 0 ), double( -1 ) );
-      }
-      else // if( axis == 2 )
-      {
-        camera->SetPosition( double( 0 ), double( 0 ), double( 1 ) );
-        camera->SetViewUp  ( double( 0 ), double( 1 ), double( 0 ) );
-
-      } // fi
+      camera->SetPosition( double( 1 ), double( 0 ), double( 0 ) );
+      camera->SetViewUp  ( double( 0 ), double( 1 ), double( 0 ) );
+    }
+    else if( axis == 1 )
+    {
+      camera->SetPosition( double( 0 ), double( 1 ), double(  0 ) );
+      camera->SetViewUp  ( double( 0 ), double( 0 ), double( -1 ) );
+    }
+    else // if( axis == 2 )
+    {
+      camera->SetPosition( double( 0 ), double( 0 ), double( 1 ) );
+      camera->SetViewUp  ( double( 0 ), double( 1 ), double( 0 ) );
 
     } // fi
-    renderer->ResetCamera( );
-    rwi->Render( );
 
   } // fi
+  renderer->ResetCamera( );
+  rwi->Render( );
 }
 
 // -------------------------------------------------------------------------
@@ -977,6 +971,7 @@ UpdateText( )
 void cpExtensions::Visualization::ImageSliceActors::
 UpdateText( double pos[ 3 ] )
 {
+  /* TODO
   if( this->SliceMappers.size( ) > 0 )
   {
     char axis;
@@ -1033,6 +1028,7 @@ UpdateText( double pos[ 3 ] )
   this->TextActor->SetInput( this->TextBuffer );
   this->TextActor->Modified( );
   this->Modified( );
+  */
 }
 
 // -------------------------------------------------------------------------
@@ -1248,7 +1244,16 @@ _MouseDoubleClickCommand(
     if( !alt && !ctr && !sft )
       actors->SetCursor( pos );
     else if( !alt && ctr && !sft && actors->SlicesCommand != NULL )
+    {
       actors->SlicesCommand( pos, actors->GetAxis( ), actors->SlicesData );
+      for( unsigned int i = 0; i < actors->CursorCommands.size( ); ++i )
+        actors->CursorCommands[ i ].first(
+          pos,
+          actors->GetAxis( ),
+          actors->CursorCommands[ i ].second
+          );
+
+    } // fi
   }
   else if( btn == ImageInteractorStyle::ButtonID_Middle )
   {
index 22bfe6a7f39ee551158ffbe80cfa67066676c559..6c97448f48c5c0cfcec9192ccc49642225da77f4 100644 (file)
@@ -38,6 +38,9 @@ namespace cpExtensions
       typedef ImageSliceActors Self;
 
       typedef void ( *TCursorCommand )( double*, int, void* );
+      typedef ImageInteractorStyle::TMouseCommand      TMouseCommand;
+      typedef ImageInteractorStyle::TMouseWheelCommand TMouseWheelCommand;
+      typedef ImageInteractorStyle::TKeyCommand        TKeyCommand;
 
     public:
       vtkTypeMacro( ImageSliceActors, vtkPropCollection );
@@ -51,6 +54,15 @@ namespace cpExtensions
       // Creation
       static ImageSliceActors* New( );
 
+      void AddCursorCommand( TCursorCommand command, void* data )
+      {
+        this->CursorCommands.push_back(
+          std::pair< TCursorCommand, void* >(
+            command, data
+            )
+          );
+      }
+
       void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 2 );
       void AddInputData( vtkImageData* data, int axis = 2 );
       void Clear( );
@@ -166,6 +178,14 @@ namespace cpExtensions
       TCursorCommand SlicesCommand;
       void* SlicesData;
 
+      // Associated commands
+      std::vector< std::pair< TCursorCommand, void* > > CursorCommands;
+      std::vector< TMouseCommand >      MouseCommands;
+      std::vector< TMouseCommand >      MouseClickCommands;
+      std::vector< TMouseCommand >      MouseDoubleClickCommands;
+      std::vector< TMouseWheelCommand > MouseWheelCommands;
+      std::vector< TKeyCommand >        KeyCommands;
+
       // Other associated actors
       typedef std::pair< vtkAlgorithm*, vtkActor* > TAssociatedActor;
       typedef std::vector< TAssociatedActor >       TAssociatedActors;
index 55f271c44c7026cc30f710b1ba0537f7fa1ea759..a02c8bc28d52ad37ff20848e333a3a5d4f1606a8 100644 (file)
@@ -2,6 +2,8 @@
 
 #include <vtkAlgorithmOutput.h>
 #include <vtkImageData.h>
+#include <vtkOutlineSource.h>
+#include <vtkProperty.h>
 #include <vtkRenderer.h>
 #include <vtkRendererCollection.h>
 #include <vtkRenderWindow.h>
@@ -40,6 +42,28 @@ AddInputConnection( vtkAlgorithmOutput* aout )
           this->Slices[ i ][ j ]->AddInputConnection(
             ( ( imap != NULL )? imap->GetOutputPort( ): aout ), j
             );
+
+    // Create bounding box
+    vtkImageData* new_image = dynamic_cast< vtkImageData* >(
+      aout->GetProducer( )->GetOutputDataObject( aout->GetIndex( ) )
+      );
+
+    // Create 3D outline
+    double bb[ 6 ];
+    new_image->GetBounds( bb );
+
+    vtkSmartPointer< vtkOutlineSource > img_ol =
+      vtkSmartPointer< vtkOutlineSource >::New( );
+    img_ol->SetBounds( bb );
+
+    vtkSmartPointer< vtkPolyDataMapper > img_ol_mapper =
+      vtkSmartPointer< vtkPolyDataMapper >::New( );
+    img_ol_mapper->SetInputConnection( img_ol->GetOutputPort( ) );
+    this->ImageOutlineActor->SetMapper( img_ol_mapper );
+    this->ImageOutlineActor->GetProperty( )->SetColor( 1, 1, 1 );
+    this->ImageOutlineActor->GetProperty( )->SetLineWidth( 1 );
+
+    this->AddItem( this->ImageOutlineActor );
   }
   else
   {
@@ -108,6 +132,23 @@ AddInputData( vtkImageData* new_image )
             this->Slices[ i ][ j ]->AddInputData( new_image, j );
 
         } // fi
+
+    // Create 3D outline
+    double bb[ 6 ];
+    new_image->GetBounds( bb );
+
+    vtkSmartPointer< vtkOutlineSource > img_ol =
+      vtkSmartPointer< vtkOutlineSource >::New( );
+    img_ol->SetBounds( bb );
+
+    vtkSmartPointer< vtkPolyDataMapper > img_ol_mapper =
+      vtkSmartPointer< vtkPolyDataMapper >::New( );
+    img_ol_mapper->SetInputConnection( img_ol->GetOutputPort( ) );
+    this->ImageOutlineActor->SetMapper( img_ol_mapper );
+    this->ImageOutlineActor->GetProperty( )->SetColor( 1, 1, 1 );
+    this->ImageOutlineActor->GetProperty( )->SetLineWidth( 1 );
+
+    this->AddItem( this->ImageOutlineActor );
   }
   else
   {
index 85cee5949c2fba29d3173c290ff1f01613637a98..8b88fdc2687ca93e7ff32ddd36a0f0c095c26dbc 100644 (file)
@@ -18,6 +18,11 @@ namespace cpExtensions
     public:
       typedef MPRActors Self;
 
+      typedef ImageSliceActors::TCursorCommand     TCursorCommand;
+      typedef ImageSliceActors::TMouseCommand      TMouseCommand;
+      typedef ImageSliceActors::TMouseWheelCommand TMouseWheelCommand;
+      typedef ImageSliceActors::TKeyCommand        TKeyCommand;
+
     public:
       vtkTypeMacro( MPRActors, vtkPropCollection );
 
@@ -25,6 +30,13 @@ namespace cpExtensions
       // Creation
       static MPRActors* New( );
 
+      void AddCursorCommand( TCursorCommand command, void* data )
+      {
+        this->Slices[ 0 ][ 0 ]->AddCursorCommand( command, data );
+        this->Slices[ 0 ][ 1 ]->AddCursorCommand( command, data );
+        this->Slices[ 0 ][ 2 ]->AddCursorCommand( command, data );
+      }
+
       ImageSliceActors* GetSliceActors( const int& i ) const;
 
       int AddInputConnection( vtkAlgorithmOutput* aout );
@@ -49,6 +61,15 @@ namespace cpExtensions
         unsigned int i, double r, double g, double b
         );
 
+      double GetWindow( )
+      {
+        return( this->Slices[ 0 ][ 0 ]->GetWindow( ) );
+      }
+      double GetLevel( )
+      {
+        return( this->Slices[ 0 ][ 0 ]->GetLevel( ) );
+      }
+
       // Slice access
       int GetSliceNumberMinValue( const int& axis ) const;
       int GetSliceNumberMaxValue( const int& axis ) const;
@@ -74,6 +95,13 @@ namespace cpExtensions
     protected:
       vtkSmartPointer< vtkActor >         ImageOutlineActor;
       vtkSmartPointer< ImageSliceActors > Slices[ 2 ][ 3 ];
+
+      std::vector< TCursorCommand >     CursorCommands;
+      std::vector< TMouseCommand >      MouseCommands;
+      std::vector< TMouseCommand >      MouseClickCommands;
+      std::vector< TMouseCommand >      MouseDoubleClickCommands;
+      std::vector< TMouseWheelCommand > MouseWheelCommands;
+      std::vector< TKeyCommand >        KeyCommands;
     };
 
   } // ecapseman
index 39e827f978aa80069e5df264a2a16b6c4bb9bde8..1920bb71a952352efee6717cc3782e5e1e051aee 100644 (file)
@@ -21,6 +21,11 @@ namespace cpExtensions
       typedef MPRObjects Self;
       typedef cpExtensions::Visualization::MPRActors TMPRActors;
 
+      typedef TMPRActors::TCursorCommand     TCursorCommand;
+      typedef TMPRActors::TMouseCommand      TMouseCommand;
+      typedef TMPRActors::TMouseWheelCommand TMouseWheelCommand;
+      typedef TMPRActors::TKeyCommand        TKeyCommand;
+
     public:
       vtkTypeMacro( MPRObjects, vtkObject );
 
@@ -28,6 +33,11 @@ namespace cpExtensions
       // Creation
       static MPRObjects* New( );
 
+      void AddCursorCommand( TCursorCommand command, void* data )
+      {
+        this->m_MPRActors->AddCursorCommand( command, data );
+      }
+
       void SetRenderWindows(
         vtkRenderWindow* wx, vtkRenderWindow* wy,
         vtkRenderWindow* wz, vtkRenderWindow* w3D
@@ -51,6 +61,15 @@ namespace cpExtensions
       TMPRActors* GetMPRActors( );
       const TMPRActors* GetMPRActors( ) const;
 
+      double GetWindow( ) const
+      {
+        return( this->m_MPRActors->GetWindow( ) );
+      }
+      double GetLevel( ) const
+      {
+        return( this->m_MPRActors->GetLevel( ) );
+      }
+
     protected:
       MPRObjects( );
       virtual ~MPRObjects( );
@@ -67,6 +86,13 @@ namespace cpExtensions
       // Internal pipelines
       vtkSmartPointer< TMPRActors >  m_MPRActors;
       vtkSmartPointer< vtkRenderer > m_Renderers[ 4 ];
+
+      std::vector< TCursorCommand >     CursorCommands;
+      std::vector< TMouseCommand >      MouseCommands;
+      std::vector< TMouseCommand >      MouseClickCommands;
+      std::vector< TMouseCommand >      MouseDoubleClickCommands;
+      std::vector< TMouseWheelCommand > MouseWheelCommands;
+      std::vector< TKeyCommand >        KeyCommands;
     };
 
   } // ecapseman
index b43975547a21ccaca3bf3efcfd693dafceda39c8..d55632c6d1dde34e34e813d27b5d520e0b1d6324 100644 (file)
@@ -158,17 +158,13 @@ LoadPlugins( )
 }
 
 // -------------------------------------------------------------------------
-bool cpPlugins::Interface::BaseMPRWindow::
+std::string cpPlugins::Interface::BaseMPRWindow::
 LoadImage( )
 {
   std::string msg = "";
-  bool ret = true;
+  std::string ret = "";
   if( this->m_ImageReader.IsNull( ) )
-  {
     msg = "No valid image reader. Please load a valid plugin file.";
-    ret = false;
-
-  } // fi
 
   if( this->m_ImageReader->ExecConfigurationDialog( this ) )
   {
@@ -176,13 +172,16 @@ LoadImage( )
     msg = this->m_ImageReader->Update( );
     if( msg == "" )
     {
-      this->m_Images.push_back(
-        this->m_ImageReader->GetOutput< TImage >( 0 )
-        );
+      TImage::Pointer image =
+        this->m_ImageReader->GetOutput< TImage >( "Output" );
+      if( this->m_Images.size( ) == 0 )
+        ret = image->GetName( );
+      else
+        ret = "Segmentation";
+      this->m_Images[ ret ] = image;
       this->m_ImageReader->DisconnectOutputs( );
       this->m_ImageReader->GetParameters( )->ClearStringList( "FileNames" );
-      vtkImageData* vtk_id =
-        this->m_Images.rbegin( )->GetPointer( )->GetVTK< vtkImageData >( );
+      vtkImageData* vtk_id = image->GetVTK< vtkImageData >( );
       if( vtk_id != NULL )
       {
         this->m_MPRObjects->AddImage( vtk_id );
@@ -195,7 +194,7 @@ LoadImage( )
         msg = "Read image does not have a valid VTK converter.";
     }
     else
-      ret = false;
+      ret = "";
 
   } // fi
 
@@ -209,33 +208,67 @@ LoadImage( )
 }
 
 // -------------------------------------------------------------------------
-bool cpPlugins::Interface::BaseMPRWindow::
+std::string cpPlugins::Interface::BaseMPRWindow::
 LoadMesh( )
 {
-  return( false );
+  return( "" );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::BaseMPRWindow::
-ExecuteFilter( const std::string& name, int input_id, int output_id )
+ExecuteFilter(
+  const std::string& name,
+  const std::string& input_id,
+  const std::string& output_id
+  )
 {
   TProcessObject::Pointer filter =
     this->m_Interface.CreateProcessObject( name );
   std::string category = filter->GetClassCategory( );
   if( category == "ImageToBinaryImageFilter" )
   {
-    if( input_id < this->m_Images.size( ) )
+    TImages::iterator iIt = this->m_Images.find( input_id );
+    if( iIt != this->m_Images.end( ) )
     {
-      filter->SetInput( 0, this->m_Images[ input_id ] );
+      filter->SetInput( "Input", this->m_Images[ input_id ] );
       bool dlg_ok = filter->ExecConfigurationDialog( NULL );
       if( !dlg_ok )
         return;
 
+      std::string err = filter->Update( );
+      std::cout << "ERR: " << err << std::endl;
+      if( err == "" )
+      {
+        this->m_Images[ "Segmentation" ] =
+          filter->GetOutput< TImage >( "Output" );
+        filter->DisconnectOutputs( );
+
+        vtkImageData* vtk_id =
+          this->m_Images[ "Segmentation" ]->GetVTK< vtkImageData >( );
+        if( vtk_id != NULL )
+          this->m_MPRObjects->AddImage( vtk_id );
+      }
+      else
+        QMessageBox::critical(
+          this, tr( "Error with plugin" ), tr( err.c_str( ) )
+          );
+
     } // fi
 
   } // fi
 }
 
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::BaseMPRWindow::
+AddImage( const std::string& name, TImage* image )
+{
+  this->m_Images[ name ] = image;
+  vtkImageData* vtk_id =
+    this->m_Images[ name ]->GetVTK< vtkImageData >( );
+  if( vtk_id != NULL )
+    this->m_MPRObjects->AddImage( vtk_id );
+}
+
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::BaseMPRWindow::
 ClearAll( )
index d0509671da4676f607e378eff898a5c88ae27bbe..9507d6f2a713310984d675d7de3ea6e1c5e9f0eb 100644 (file)
@@ -6,9 +6,9 @@
 
 #ifdef cpPlugins_Interface_QT4
 
+#include <map>
 #include <set>
 #include <string>
-#include <vector>
 
 #include <QApplication>
 #include <QMenu>
@@ -41,15 +41,26 @@ namespace cpPlugins
       typedef cpPlugins::Interface::Image         TImage;
       typedef cpPlugins::Interface::Mesh          TMesh;
 
-      typedef std::vector< TImage::Pointer > TImages;
-      typedef std::vector< TMesh::Pointer >  TMeshes;
-      typedef std::set< std::string >     TOrderedStringContainer;
+      typedef cpExtensions::Visualization::MPRObjects TMPRObjects;
+      typedef TMPRObjects::TCursorCommand     TCursorCommand;
+      typedef TMPRObjects::TMouseCommand      TMouseCommand;
+      typedef TMPRObjects::TMouseWheelCommand TMouseWheelCommand;
+      typedef TMPRObjects::TKeyCommand        TKeyCommand;
+
+      typedef std::map< std::string, TImage::Pointer >          TImages;
+      typedef std::map< std::string, TMesh::Pointer >           TMeshes;
+      typedef std::set< std::string >           TOrderedStringContainer;
       typedef std::map< std::string, std::set< std::string > > TFilters;
 
     public:
       explicit BaseMPRWindow( QWidget* parent = 0 );
       virtual ~BaseMPRWindow( );
 
+      void AddCursorCommand( TCursorCommand command, void* data )
+      {
+        this->m_MPRObjects->AddCursorCommand( command, data );
+      }
+
       void DialogLoadPlugins( );
       void AssociatePluginsToMenu(
         QMenu* menu, QObject* obj, const char* slot
@@ -68,21 +79,45 @@ namespace cpPlugins
 
       bool LoadPlugins( const std::string& fname );
       void LoadPlugins( );
-      bool LoadImage( );
-      bool LoadMesh( );
+      std::string LoadImage( );
+      std::string LoadMesh( );
 
       void ExecuteFilter(
         const std::string& name,
-        int input_id, int output_id = -1
+        const std::string& input_id,
+        const std::string& output_id
         );
 
+      TProcessObject::Pointer CreateFilter( const std::string& name )
+      {
+        return( this->m_Interface.CreateProcessObject( name ) );
+      }
+
+      void AddImage( const std::string& name, TImage* image );
+      TImage* GetImage( std::string& name ) const
+      {
+        TImages::const_iterator i = this->m_Images.find( name );
+        if( i != this->m_Images.end( ) )
+          return( i->second );
+        else
+          return( NULL );
+      }
+
+      double GetWindow( ) const
+      {
+        return( this->m_MPRObjects->GetWindow( ) );
+      }
+      double GetLevel( ) const
+      {
+        return( this->m_MPRObjects->GetLevel( ) );
+      }
+
       void ClearAll( );
 
     protected:
       void _UpdatePlugins( );
 
     protected:
-      typedef cpExtensions::Visualization::MPRObjects TMPRObjects;
       vtkSmartPointer< TMPRObjects > m_MPRObjects;
 
       QVTKWidget* m_XVTK;
index b02168b43c60ad92be24bbdc6e03831a975a3474..af641e0e6f1dbb29dabbec35f217ab61d0c59d0e 100644 (file)
@@ -1,7 +1,32 @@
 #include <cpPlugins/Interface/Parameters.h>
+#include <cpPlugins/Interface/ProcessObject.h>
 
 #include <sstream>
 
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::
+ProcessObject* cpPlugins::Interface::Parameters::
+GetProcessObject( ) const
+{
+  return( this->m_Process );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Parameters::
+SetProcessObject( ProcessObject* v )
+{
+  this->m_Process = v;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Parameters::
+Modified( ) const
+{
+  this->Superclass::Modified( );
+  if( this->m_Process != NULL )
+    this->m_Process->Modified( );
+}
+
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Parameters::
 Clear( )
@@ -416,7 +441,8 @@ SetSelectedChoice( const TString& name, const TString& choice )
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Parameters::
 Parameters( )
-  : Superclass( )
+  : Superclass( ),
+    m_Process( NULL )
 {
   this->Clear( );
 }
index abde990d0759714b422a594c28fe9722c938abf8..858a90b577970f890c379f54cc5e1404db786112 100644 (file)
@@ -15,6 +15,9 @@ namespace cpPlugins
 {
   namespace Interface
   {
+    // Some forward declarations
+    class ProcessObject;
+
     /**
      */
     class cpPlugins_Interface_EXPORT Parameters
@@ -52,6 +55,11 @@ namespace cpPlugins
       itkTypeMacro( cpPlugins::Interface::Parameters, itk::Object );
 
     public:
+      // To impact pipeline
+      virtual const ProcessObject* GetProcessObject( ) const;
+      virtual void SetProcessObject( ProcessObject* v );
+      virtual void Modified( ) const;
+
       // Parameters container configuration
       void Clear( );
 
@@ -195,6 +203,7 @@ namespace cpPlugins
 
     protected:
       TParameters m_Parameters;
+      const ProcessObject* m_Process;
     };
 
   } // ecapseman
index f832743feb2d5ce57eb43af8f7e1046e8a2550a4..ae4a1d3e4b2cf793c8eeab4ac1255691dbb589fd 100644 (file)
@@ -4,6 +4,17 @@
 #include <cpPlugins/Interface/ParametersQtDialog.h>
 #endif // cpPlugins_Interface_QT4
 
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ProcessObject::
+Modified( ) const
+{
+  if( this->m_ITKObject.IsNotNull( ) )
+    this->m_ITKObject->Modified( );
+  if( this->m_VTKObject.GetPointer( ) != NULL )
+    this->m_VTKObject->Modified( );
+  this->Superclass::Modified( );
+}
+
 // -------------------------------------------------------------------------
 cpPlugins::Interface::ProcessObject::
 TParameters* cpPlugins::Interface::ProcessObject::
@@ -36,29 +47,12 @@ GetNumberOfOutputs( ) const
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::ProcessObject::
-SetNumberOfInputs( unsigned int n )
-{
-  this->m_Inputs.clear( );
-  this->m_Inputs.resize( n );
-  this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetNumberOfOutputs( unsigned int n )
+SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj )
 {
-  this->m_Outputs.clear( );
-  this->m_Outputs.resize( n );
-  this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetInput( unsigned int idx, cpPlugins::Interface::DataObject* dobj )
-{
-  if( idx < this->m_Inputs.size( ) )
+  _TDataContainer::iterator i = this->m_Inputs.find( id );
+  if( i != this->m_Inputs.end( ) )
   {
-    this->m_Inputs[ idx ] = dobj;
+    i->second = dobj;
     this->Modified( );
 
   } // fi
@@ -71,9 +65,10 @@ Update( )
   std::string r = "";
 
   // Force upstream updates
-  for( unsigned int i = 0; i < this->m_Inputs.size( ) && r == ""; ++i )
+  _TDataContainer::iterator i = this->m_Inputs.begin( );
+  for( ; i != this->m_Inputs.end( ) && r == ""; ++i )
   {
-    Self* src = dynamic_cast< Self* >( this->m_Inputs[ i ]->GetSource( ) );
+    Self* src = dynamic_cast< Self* >( i->second->GetSource( ) );
     if( src != NULL )
       r = src->Update( );
 
@@ -91,9 +86,10 @@ Update( )
 void cpPlugins::Interface::ProcessObject::
 DisconnectOutputs( )
 {
-  for( unsigned int idx = 0; idx < this->m_Outputs.size( ); ++idx )
-    if( this->m_Outputs[ idx ].IsNotNull( ) )
-      this->m_Outputs[ idx ]->DisconnectPipeline( );
+  _TDataContainer::iterator i = this->m_Outputs.begin( );
+  for( ; i != this->m_Outputs.end( ); ++i )
+    if( i->second.IsNotNull( ) )
+      i->second->DisconnectPipeline( );
 }
 
 // -------------------------------------------------------------------------
@@ -135,4 +131,12 @@ cpPlugins::Interface::ProcessObject::
 {
 }
 
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ProcessObject::
+_AddInput( const std::string& name )
+{
+  this->m_Inputs[ name ] = NULL;
+  this->Modified( );
+}
+
 // eof - $RCSfile$
index 9cf1924992d2396d4e93f20e97a3ae81270a40b4..9548d48167c19fda02e1fdb2fa897c0afdb6c348 100644 (file)
@@ -2,6 +2,9 @@
 #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
 
 #include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
+
+#include <map>
+
 #include <cpPlugins/Interface/Config.h>
 #include <cpPlugins/Interface/Object.h>
 #include <cpPlugins/Interface/DataObject.h>
@@ -42,16 +45,16 @@ namespace cpPlugins
         );
 
     public:
+      // To impact pipeline
+      virtual void Modified( ) const;
+
       virtual TParameters* GetParameters( );
       virtual const TParameters* GetParameters( ) const;
 
       virtual unsigned int GetNumberOfInputs( ) const;
       virtual unsigned int GetNumberOfOutputs( ) const;
 
-      virtual void SetNumberOfInputs( unsigned int n );
-      virtual void SetNumberOfOutputs( unsigned int n );
-
-      virtual void SetInput( unsigned int idx, DataObject* dobj );
+      virtual void SetInput( const std::string& id, DataObject* dobj );
 
       virtual std::string Update( );
       virtual void DisconnectOutputs( );
@@ -71,21 +74,23 @@ namespace cpPlugins
         inline const T* GetVTK( ) const;
 
       template< class T >
-        inline T* GetInput( unsigned int idx );
+        inline T* GetInput( const std::string& id );
 
       template< class T >
-        inline const T* GetInput( unsigned int idx ) const;
+        inline const T* GetInput( const std::string& id ) const;
 
       template< class T >
-        inline T* GetOutput( unsigned int idx );
+        inline T* GetOutput( const std::string& id );
 
       template< class T >
-        inline const T* GetOutput( unsigned int idx ) const;
+        inline const T* GetOutput( const std::string& id ) const;
 
     protected:
       ProcessObject( );
       virtual ~ProcessObject( );
 
+      virtual void _AddInput( const std::string& name );
+
       template< class F >
         inline F* _CreateITK( );
 
@@ -93,7 +98,7 @@ namespace cpPlugins
         inline F* _CreateVTK( );
 
       template< class O >
-        inline void _MakeOutput( unsigned int idx );
+        inline void _MakeOutput( const std::string& id );
 
       virtual std::string _GenerateData( ) = 0;
 
@@ -108,8 +113,9 @@ namespace cpPlugins
 
       Parameters::Pointer m_Parameters;
 
-      std::vector< DataObject::Pointer > m_Inputs;
-      std::vector< DataObject::Pointer > m_Outputs;
+      typedef std::map< std::string, DataObject::Pointer > _TDataContainer;
+      _TDataContainer m_Inputs;
+      _TDataContainer m_Outputs;
     };
 
   } // ecapseman
index 50c03ce82cdfc0fb4c7a13fc2bd1f30424a56b5d..10b4dbe99fcc7a66fb02a42d978523e57b3e5c61 100644 (file)
@@ -36,10 +36,11 @@ GetVTK( ) const
 // -------------------------------------------------------------------------
 template< class T >
 T* cpPlugins::Interface::ProcessObject::
-GetInput( unsigned int idx )
+GetInput( const std::string& id )
 {
-  if( idx < this->m_Inputs.size( ) )
-    return( dynamic_cast< T* >( this->m_Inputs[ idx ].GetPointer( ) ) );
+  _TDataContainer::iterator i = this->m_Inputs.find( id );
+  if( i != this->m_Inputs.end( ) )
+    return( dynamic_cast< T* >( i->second.GetPointer( ) ) );
   else
     return( NULL );
 }
@@ -47,12 +48,11 @@ GetInput( unsigned int idx )
 // -------------------------------------------------------------------------
 template< class T >
 const T* cpPlugins::Interface::ProcessObject::
-GetInput( unsigned int idx ) const
+GetInput( const std::string& id ) const
 {
-  if( idx < this->m_Inputs.size( ) )
-    return(
-      dynamic_cast< const T* >( this->m_Inputs[ idx ].GetPointer( ) )
-      );
+  _TDataContainer::const_iterator i = this->m_Inputs.find( id );
+  if( i != this->m_Inputs.end( ) )
+    return( dynamic_cast< const T* >( i->second.GetPointer( ) ) );
   else
     return( NULL );
 }
@@ -60,10 +60,11 @@ GetInput( unsigned int idx ) const
 // -------------------------------------------------------------------------
 template< class T >
 T* cpPlugins::Interface::ProcessObject::
-GetOutput( unsigned int idx )
+GetOutput( const std::string& id )
 {
-  if( idx < this->m_Outputs.size( ) )
-    return( dynamic_cast< T* >( this->m_Outputs[ idx ].GetPointer( ) ) );
+  _TDataContainer::iterator i = this->m_Outputs.find( id );
+  if( i != this->m_Outputs.end( ) )
+    return( dynamic_cast< T* >( i->second.GetPointer( ) ) );
   else
     return( NULL );
 }
@@ -71,12 +72,11 @@ GetOutput( unsigned int idx )
 // -------------------------------------------------------------------------
 template< class T >
 const T* cpPlugins::Interface::ProcessObject::
-GetOutput( unsigned int idx ) const
+GetOutput( const std::string& id ) const
 {
-  if( idx < this->m_Outputs.size( ) )
-    return(
-      dynamic_cast< const T* >( this->m_Outputs[ idx ].GetPointer( ) )
-      );
+  _TDataContainer::const_iterator i = this->m_Outputs.find( id );
+  if( i != this->m_Outputs.end( ) )
+    return( dynamic_cast< const T* >( i->second.GetPointer( ) ) );
   else
     return( NULL );
 }
@@ -117,12 +117,11 @@ _CreateVTK( )
 // -------------------------------------------------------------------------
 template< class O >
 void cpPlugins::Interface::ProcessObject::
-_MakeOutput( unsigned int idx )
+_MakeOutput( const std::string& id )
 {
-  if( idx >= this->m_Outputs.size( ) )
-    return;
-  this->m_Outputs[ idx ] = O::New( );
-  this->m_Outputs[ idx ]->SetSource( this );
+  this->m_Outputs[ id ] = O::New( );
+  this->m_Outputs[ id ]->SetSource( this );
+  this->Modified( );
 }
 
 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
index 0713edfe9114a51dedf05cee2ff57f423cda6980..7460520f37303fd146525044a4560771467ea651 100644 (file)
@@ -10,11 +10,8 @@ cpPlugins::BasicFilters::BinaryErodeImageFilter::
 BinaryErodeImageFilter( )
   : Superclass( )
 {
-  //this->m_ClassName = "cpPlugins::BasicFilters::BinaryErodeImageFilter";
-  //this->m_ClassCategory = "ImageToImageFilter";
-  this->SetNumberOfInputs( 1 );
-  this->SetNumberOfOutputs( 1 );
-  this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
+  this->_AddInput( "Input" );
+  this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
 
   this->m_Parameters->ConfigureAsUint( "Radius", 2 );
 }
@@ -30,7 +27,7 @@ std::string cpPlugins::BasicFilters::BinaryErodeImageFilter::
 _GenerateData( )
 {
   cpPlugins::Interface::Image* image =
-    this->GetInput< cpPlugins::Interface::Image >( 0 );
+    this->GetInput< cpPlugins::Interface::Image >( "Input" );
   if( image == NULL )
     return( "BinaryErodeImageFilter: No input image." );
 
@@ -82,7 +79,7 @@ _RealGD( itk::DataObject* image )
 
   // Connect output
   cpPlugins::Interface::Image* out =
-    this->GetOutput< cpPlugins::Interface::Image >( 0 );
+    this->GetOutput< cpPlugins::Interface::Image >( "Output" );
   if( out != NULL )
   {
     out->SetITK< O >( filter->GetOutput( ) );
index 21df227a941c125d54a774f0f676d81fb41d6030..5dc60cba906aabf2a6f0a21845275b37b9a22633 100644 (file)
@@ -8,14 +8,13 @@ cpPlugins::BasicFilters::BinaryThresholdImageFilter::
 BinaryThresholdImageFilter( )
   : Superclass( )
 {
-  this->SetNumberOfInputs( 1 );
-  this->SetNumberOfOutputs( 1 );
-  this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
+  this->_AddInput( "Input" );
+  this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
 
   this->m_Parameters->ConfigureAsReal( "LowerThresholdValue", 0 );
-  this->m_Parameters->ConfigureAsReal( "UpperThresholdValue", 0 );
-  this->m_Parameters->ConfigureAsUint( "InsideValue", 255 );
-  this->m_Parameters->ConfigureAsUint( "OutsideValue", 1 );
+  this->m_Parameters->ConfigureAsReal( "UpperThresholdValue", 10000 );
+  this->m_Parameters->ConfigureAsUint( "InsideValue", 1 );
+  this->m_Parameters->ConfigureAsUint( "OutsideValue", 0 );
 }
 
 // -------------------------------------------------------------------------
@@ -29,7 +28,7 @@ std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter::
 _GenerateData( )
 {
   cpPlugins::Interface::Image* image =
-    this->GetInput< cpPlugins::Interface::Image >( 0 );
+    this->GetInput< cpPlugins::Interface::Image >( "Input" );
   if( image == NULL )
     return( "BinaryThresholdImageFilter: No input image." );
 
@@ -66,8 +65,8 @@ _RealGD( itk::DataObject* image )
   // Get parameters
   //unsigned int bins =
   //  this->m_Parameters.GetValueAsUint( "NumberOfHistogramBins" );
-  _IP lower_val = _IP( this->m_Parameters->GetReal( "LowerValue" ) );
-  _IP upper_val = _IP( this->m_Parameters->GetReal( "UpperValue" ) );
+  _IP lower_val = _IP( this->m_Parameters->GetReal( "LowerThresholdValue" ) );
+  _IP upper_val = _IP( this->m_Parameters->GetReal( "UpperThresholdValue" ) );
   _OP in_val = _OP( this->m_Parameters->GetUint( "InsideValue" ) );
   _OP out_val = _OP( this->m_Parameters->GetUint( "OutsideValue" ) );
 
@@ -82,7 +81,7 @@ _RealGD( itk::DataObject* image )
 
   // Connect output
   cpPlugins::Interface::Image* out =
-    this->GetOutput< cpPlugins::Interface::Image >( 0 );
+    this->GetOutput< cpPlugins::Interface::Image >( "Output" );
   if( out != NULL )
   {
     out->SetITK< O >( filter->GetOutput( ) );
index e3f1e2b98517296be15f5685f8fb3f8f28ef4c1a..d0907b41e6429badcc34a3c3cffeb474bc9afb46 100644 (file)
@@ -13,9 +13,9 @@ cpPlugins::BasicFilters::Cutter::
 Cutter( )
   : Superclass( )
 {
-  this->SetNumberOfInputs( 2 );
-  this->SetNumberOfOutputs( 1 );
-  this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
+  this->_AddInput( "InputMesh" );
+  this->_AddInput( "InputFunction" );
+  this->_MakeOutput< cpPlugins::Interface::Mesh >( "Output" );
 }
 
 // -------------------------------------------------------------------------
@@ -30,9 +30,11 @@ _GenerateData( )
 {
   // Get inputs
   cpPlugins::Interface::Mesh* mesh =
-    this->GetInput< cpPlugins::Interface::Mesh >( 0 );
+    this->GetInput< cpPlugins::Interface::Mesh >( "InputMesh" );
   cpPlugins::Interface::ImplicitFunction* function =
-    this->GetInput< cpPlugins::Interface::ImplicitFunction >( 1 );
+    this->GetInput< cpPlugins::Interface::ImplicitFunction >(
+      "InputFunction"
+      );
   if( function == NULL )
     return( "Cutter: Input data 1 is not a valid implicit function." );
 
@@ -46,7 +48,7 @@ _GenerateData( )
 
   // Execute filter
   cpPlugins::Interface::Mesh* out =
-    this->GetOutput< cpPlugins::Interface::Mesh >( 0 );
+    this->GetOutput< cpPlugins::Interface::Mesh >( "Output" );
   out->SetVTK( cutter->GetOutput( ) );
 
   return( "" );
index df46d6f434d8e62a28759818ff816a2f8fc24241..65a70809a3cd136e660a245349d10cd80703f8db 100644 (file)
@@ -8,9 +8,8 @@ cpPlugins::BasicFilters::ExtractSliceImageFilter::
 ExtractSliceImageFilter( )
   : Superclass( )
 {
-  this->SetNumberOfInputs( 1 );
-  this->SetNumberOfOutputs( 1 );
-  this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
+  this->_AddInput( "Input" );
+  this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
 
   this->m_Parameters->ConfigureAsUint( "Axis", 0 );
   this->m_Parameters->ConfigureAsInt( "Slice", 0 );
@@ -27,7 +26,7 @@ std::string cpPlugins::BasicFilters::ExtractSliceImageFilter::
 _GenerateData( )
 {
   cpPlugins::Interface::Image* image =
-    this->GetInput< cpPlugins::Interface::Image >( 0 );
+    this->GetInput< cpPlugins::Interface::Image >( "Input" );
   if( image == NULL )
     return( "ExtractSliceImageFilter: No input image." );
 
@@ -79,7 +78,7 @@ _RealGD( itk::DataObject* image )
 
   // Connect output
   cpPlugins::Interface::Image* out =
-    this->GetOutput< cpPlugins::Interface::Image >( 0 );
+    this->GetOutput< cpPlugins::Interface::Image >( "Output" );
   if( out != NULL )
   {
     out->SetITK< O >( filter->GetOutput( ) );
index 07fc9393ec14f52b2a41faaa8542ce38995c9e37..71f90cc70e8876b1bf374f5daaddf533a1cb900c 100644 (file)
@@ -9,12 +9,13 @@ cpPlugins::BasicFilters::FloodFillImageFilter::
 FloodFillImageFilter( )
   : Superclass( )
 {
-  this->SetNumberOfInputs( 1 );
-  this->SetNumberOfOutputs( 1 );
-  this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
+  this->_AddInput( "Input" );
+  this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
 
   double seed[ 3 ] = { double( 0 ) };
   this->m_Parameters->ConfigureAsPoint( "Seed", 3, seed );
+  this->m_Parameters->ConfigureAsReal( "Window", 0 );
+  this->m_Parameters->ConfigureAsReal( "Level", 0 );
   this->m_Parameters->ConfigureAsUint( "InsideValue", 0 );
   this->m_Parameters->ConfigureAsUint( "OutsideValue", 255 );
 }
@@ -30,7 +31,7 @@ std::string cpPlugins::BasicFilters::FloodFillImageFilter::
 _GenerateData( )
 {
   cpPlugins::Interface::Image* image =
-    this->GetInput< cpPlugins::Interface::Image >( 0 );
+    this->GetInput< cpPlugins::Interface::Image >( "Input" );
   if( image == NULL )
     return( "FloodFillImageFilter: No input image." );
 
@@ -76,6 +77,9 @@ public:
     itkImageFunction
     );
 
+  itkSetMacro( Window, double );
+  itkSetMacro( Level, double );
+
 public:
   virtual bool Evaluate( const TPoint& point ) const
     {
@@ -83,7 +87,29 @@ public:
     }
   virtual bool EvaluateAtIndex( const TIndex& index ) const
     {
-      return( true );
+      if( !( this->IsInsideBuffer( index ) ) )
+        return( false );
+
+      const I* image = this->GetInputImage( );
+      double w2 = this->m_Window / double( 2 );
+      double min = this->m_Level - w2;
+      double max = this->m_Level + w2;
+      unsigned char val = double( 0 );
+      double x = double( image->GetPixel( index ) );
+      double m = double( 100 ) / this->m_Window;
+      double b = ( this->m_Window - ( double( 2 ) * this->m_Level ) );
+      b *= double( 50 ) / this->m_Window;
+      if( x > min && x < max )
+        val = ( unsigned char )( ( m * x ) + b );
+
+      if( this->m_Start )
+      {
+        this->m_StartValue = val;
+        this->m_Start = false;
+        return( true );
+      }
+      else
+        return( std::abs( this->m_StartValue - val ) <= 2 );
     }
   virtual bool EvaluateAtContinuousIndex( const TCIndex& index ) const
     {
@@ -92,7 +118,10 @@ public:
 
 protected:
   cpPlugins_BasicFilters_FloodFillImageFilter_Function( )
-    : Superclass( )
+    : Superclass( ),
+      m_Window( double( 0 ) ),
+      m_Level( double( 0 ) ),
+      m_Start( true )
     {
     }
   virtual ~cpPlugins_BasicFilters_FloodFillImageFilter_Function( )
@@ -103,6 +132,12 @@ private:
   // Purposely not implemented
   cpPlugins_BasicFilters_FloodFillImageFilter_Function( const Self& other );
   Self& operator=( const Self& other );
+
+protected:
+  double m_Window;
+  double m_Level;
+  mutable unsigned char m_StartValue;
+  mutable bool m_Start;
 };
 
 // -------------------------------------------------------------------------
@@ -118,6 +153,8 @@ _RealGD( itk::DataObject* image )
   pseed = this->m_Parameters->GetPoint< typename I::PointType >(
     "Seed", I::ImageDimension
     );
+  double window = this->m_Parameters->GetReal( "Window" );
+  double level = this->m_Parameters->GetReal( "Level" );
   _OP in_val = _OP( this->m_Parameters->GetUint( "InsideValue" ) );
   _OP out_val = _OP( this->m_Parameters->GetUint( "OutsideValue" ) );
 
@@ -136,6 +173,9 @@ _RealGD( itk::DataObject* image )
   out->FillBuffer( out_val );
 
   typename _F::Pointer f = _F::New( );
+  f->SetInputImage( in );
+  f->SetWindow( window );
+  f->SetLevel( level );
   _It i( in, f );
   i.AddSeed( seed );
 
@@ -144,7 +184,7 @@ _RealGD( itk::DataObject* image )
 
   // Connect output
   cpPlugins::Interface::Image* out_port =
-    this->GetOutput< cpPlugins::Interface::Image >( 0 );
+    this->GetOutput< cpPlugins::Interface::Image >( "Output" );
   if( out_port != NULL )
   {
     out_port->SetITK< O >( out );
index e50ae24c3796ee607ac3d1955448a24a658ed381..d6d61ea4be1570bc624612f26baa82f5d4ddd6db 100644 (file)
@@ -27,7 +27,7 @@ namespace cpPlugins
         );
       cpPlugins_Id_Macro(
         cpPlugins::BasicFilters::FloodFillImageFilter,
-        "ImageToImageFilter"
+        "ImageToBinaryImageFilter"
         );
 
     protected:
index e8336754e0ed8f1d151c213233d47c88b598ff6d..625838c08f6d8d353e139069e713a9b230d98586 100644 (file)
@@ -11,9 +11,8 @@ cpPlugins::BasicFilters::MarchingCubes::
 MarchingCubes( )
   : Superclass( )
 {
-  this->SetNumberOfInputs( 1 );
-  this->SetNumberOfOutputs( 1 );
-  this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
+  this->_AddInput( "Input" );
+  this->_MakeOutput< cpPlugins::Interface::Mesh >( "Output" );
 
   this->m_Parameters->ConfigureAsRealList( "Thresholds" );
 }
@@ -30,7 +29,7 @@ _GenerateData( )
 {
   // Get input
   cpPlugins::Interface::Image* image =
-    this->GetInput< cpPlugins::Interface::Image >( 0 );
+    this->GetInput< cpPlugins::Interface::Image >( "Input" );
   if( image == NULL )
     return( "MarchingCubes: Input data is not a valid image." );
   vtkImageData* vtk_image = image->GetVTK< vtkImageData >( );
@@ -64,7 +63,7 @@ _GenerateData( )
 
   // Execute filter
   cpPlugins::Interface::Mesh* out =
-    this->GetOutput< cpPlugins::Interface::Mesh >( 0 );
+    this->GetOutput< cpPlugins::Interface::Mesh >( "Output" );
   out->SetVTK( pd );
   return( "" );
 }
index d1205e728cdce5794e032f607380bc855a50760c..d47b50016c5706d352cd279f4369cc07dafb7307 100644 (file)
@@ -8,9 +8,8 @@ cpPlugins::BasicFilters::MedianImageFilter::
 MedianImageFilter( )
   : Superclass( )
 {
-  this->SetNumberOfInputs( 1 );
-  this->SetNumberOfOutputs( 1 );
-  this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
+  this->_AddInput( "Input" );
+  this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
 
   this->m_Parameters->ConfigureAsUint( "Radius", 3 );
 }
@@ -26,7 +25,7 @@ std::string cpPlugins::BasicFilters::MedianImageFilter::
 _GenerateData( )
 {
   cpPlugins::Interface::Image* image =
-    this->GetInput< cpPlugins::Interface::Image >( 0 );
+    this->GetInput< cpPlugins::Interface::Image >( "Input" );
   if( image == NULL )
     return( "MedianImageFilter: No input image." );
 
@@ -71,7 +70,7 @@ _RealGD( itk::DataObject* image )
 
   // Connect output
   cpPlugins::Interface::Image* out =
-    this->GetOutput< cpPlugins::Interface::Image >( 0 );
+    this->GetOutput< cpPlugins::Interface::Image >( "Output" );
   if( out != NULL )
   {
     out->SetITK< O >( filter->GetOutput( ) );
index 65df9e012f352533234122fd9d7cdbfca72eb908..6bc538e7efa635de4ca9b99bdeecb816f7bf237b 100644 (file)
@@ -8,9 +8,8 @@ cpPlugins::BasicFilters::OtsuThresholdImageFilter::
 OtsuThresholdImageFilter( )
   : Superclass( )
 {
-  this->SetNumberOfInputs( 1 );
-  this->SetNumberOfOutputs( 1 );
-  this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
+  this->_AddInput( "Input" );
+  this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
 
   this->m_Parameters->ConfigureAsUint( "NumberOfHistogramBins", 100 );
   this->m_Parameters->ConfigureAsUint( "InsideValue", 255 );
@@ -76,7 +75,7 @@ _RealGD( itk::DataObject* image )
 
   // Connect output
   cpPlugins::Interface::Image* out =
-    this->GetOutput< cpPlugins::Interface::Image >( 0 );
+    this->GetOutput< cpPlugins::Interface::Image >( "Output" );
   if( out != NULL )
   {
     out->SetITK< O >( filter->GetOutput( ) );
index 31bd0fcaee6739a4965963e738d2e4351c61166b..13e6732abc1bd7410ffd31e00ccbc321b3294613 100644 (file)
@@ -13,9 +13,8 @@ RGBImageToOtherChannelsFilter( )
 {
   typedef cpPlugins::Interface::Parameters TParameters;
 
-  this->SetNumberOfInputs( 1 );
-  this->SetNumberOfOutputs( 1 );
-  this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
+  this->_AddInput( "Input" );
+  this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
 
   std::vector< std::string > choices;
   choices.push_back( "HSV" );
@@ -34,7 +33,7 @@ std::string cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter::
 _GenerateData( )
 {
   cpPlugins::Interface::Image* image =
-    this->GetInput< cpPlugins::Interface::Image >( 0 );
+    this->GetInput< cpPlugins::Interface::Image >( "Input" );
   if( image == NULL )
     return( "RGBImageToOtherChannelsFilter: No input image." );
 
@@ -88,7 +87,7 @@ _RealGD( itk::DataObject* image )
 
   // Connect output
   cpPlugins::Interface::Image* out =
-    this->GetOutput< cpPlugins::Interface::Image >( 0 );
+    this->GetOutput< cpPlugins::Interface::Image >( "Output" );
   if( out != NULL )
   {
     out->SetITK< _O >( filter->GetOutput( ) );
index 78aff5fbebf3ec19d0e5e0db59d279444a9f3c3f..c7c671b6e3e3a6871bc4ef1421ab12e3d330ab91 100644 (file)
@@ -10,9 +10,7 @@ cpPlugins::BasicFilters::SphereMeshSource::
 SphereMeshSource( )
   : Superclass( )
 {
-  this->SetNumberOfInputs( 0 );
-  this->SetNumberOfOutputs( 1 );
-  this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
+  this->_MakeOutput< cpPlugins::Interface::Mesh >( "Output" );
 
   double point[ 3 ] = { double( 0 ) };
   this->m_Parameters->ConfigureAsPoint( "Center", 3, point );
@@ -47,7 +45,7 @@ _GenerateData( )
 
   // Execute filter
   cpPlugins::Interface::Mesh* out =
-    this->GetOutput< cpPlugins::Interface::Mesh >( 0 );
+    this->GetOutput< cpPlugins::Interface::Mesh >( "Output" );
   out->SetVTK( src->GetOutput( ) );
   return( "" );
 }
index 48deb00a14d2f7fa5648465c8a435ec2b5def9a1..6068c88390f47c205978a09e4250e8c3cbb7482e 100644 (file)
@@ -46,8 +46,7 @@ cpPlugins::IO::ImageReader::
 ImageReader( )
   : Superclass( )
 {
-  this->SetNumberOfOutputs( 1 );
-  this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
+  this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
 
   this->m_Parameters->ConfigureAsStringList( "FileNames" );
   this->m_Parameters->ConfigureAsBool( "VectorType", false );
@@ -352,7 +351,7 @@ std::string cpPlugins::IO::ImageReader::
 _RealGD( const TStringList& names )
 {
   cpPlugins::Interface::Image* out =
-    this->GetOutput< cpPlugins::Interface::Image >( 0 );
+    this->GetOutput< cpPlugins::Interface::Image >( "Output" );
   if( out == NULL )
     return( "ImageReader: No output object properly created." );
 
index 2b4d89781faba34413c942dbdbeaaaafea5930d1..a6549793232a24096f5c42d61384982ea8dfdb39 100644 (file)
@@ -8,7 +8,7 @@ cpPlugins::IO::ImageWriter::
 ImageWriter( )
   : Superclass( )
 {
-  this->SetNumberOfInputs( 1 );
+  this->_AddInput( "Input" );
 
   this->m_Parameters->ConfigureAsString( "FileName", "" );
 }
@@ -39,7 +39,7 @@ std::string cpPlugins::IO::ImageWriter::
 _GD0_Image( )
 {
   cpPlugins::Interface::Image* image =
-    this->GetInput< cpPlugins::Interface::Image >( 0 );
+    this->GetInput< cpPlugins::Interface::Image >( "Input" );
   if( image == NULL )
     return( "ImageWriter: No input image." );
 
@@ -57,7 +57,7 @@ std::string cpPlugins::IO::ImageWriter::
 _GD0_VectorImage( )
 {
   cpPlugins::Interface::Image* image =
-    this->GetInput< cpPlugins::Interface::Image >( 0 );
+    this->GetInput< cpPlugins::Interface::Image >( "Input" );
   if( image == NULL )
     return( "ImageWriter: No input image." );
 
index 397b644ef10b402d267a5e0fadd98a7571e239fd..077b96955a52e3c6f977f0154fcea23faf84714e 100644 (file)
@@ -42,8 +42,7 @@ cpPlugins::IO::MeshReader::
 MeshReader( )
   : Superclass( )
 {
-  this->SetNumberOfOutputs( 1 );
-  this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
+  this->_MakeOutput< cpPlugins::Interface::Mesh >( "Output" );
 
   std::vector< TParameters::TString > valid_types;
   valid_types.push_back( "float" );
@@ -100,7 +99,7 @@ _GD1( )
   pdr->Update( );
 
   cpPlugins::Interface::Mesh* out =
-    this->GetOutput< cpPlugins::Interface::Mesh >( 0 );
+    this->GetOutput< cpPlugins::Interface::Mesh >( "Output" );
   if( out != NULL )
     out->SetVTK( pdr->GetOutput( ) );
   else
index d865c577b9c64db44723f69d3f44545ea6d47407..94af3cca29c4e9be44fc7fd92cbde430bee96aa2 100644 (file)
@@ -10,7 +10,7 @@ cpPlugins::IO::MeshWriter::
 MeshWriter( )
   : Superclass( )
 {
-  this->SetNumberOfInputs( 1 );
+  this->_AddInput( "Input" );
 
   this->m_Parameters->ConfigureAsString( "FileName", "" );
 }
@@ -26,7 +26,7 @@ std::string cpPlugins::IO::MeshWriter::
 _GenerateData( )
 {
   cpPlugins::Interface::Mesh* mesh =
-    this->GetInput< cpPlugins::Interface::Mesh >( 0 );
+    this->GetInput< cpPlugins::Interface::Mesh >( "Input" );
   if( mesh == NULL )
     return( "MeshWriter: No input mesh." );
   vtkPolyData* i = mesh->GetVTK< vtkPolyData >( );