]> Creatis software - cpPlugins.git/commitdiff
Getting ready for interactive initialization.
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 3 Nov 2015 23:19:55 +0000 (18:19 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 3 Nov 2015 23:19:55 +0000 (18:19 -0500)
22 files changed:
appli/ImageMPR/ImageMPR.cxx
appli/ImageMPR/ImageMPR.h
lib/cpExtensions/Interaction/ImageInteractorStyle.cxx
lib/cpExtensions/Interaction/ImageInteractorStyle.h
lib/cpExtensions/Visualization/MPRObjects.cxx
lib/cpExtensions/Visualization/MPRObjects.h
lib/cpPlugins/Interface/BaseMPRWidget.cxx
lib/cpPlugins/Interface/BaseMPRWidget.h
lib/cpPlugins/Interface/ParametersQtDialog.cxx
lib/cpPlugins/Interface/Plugins.cxx
lib/cpPlugins/Interface/ProcessObject.cxx
lib/cpPlugins/Interface/ProcessObject.h
lib/cpPlugins/Plugins/IO/DicomSeriesReader.cxx
lib/cpPlugins/Plugins/IO/DicomSeriesReader.h
lib/cpPlugins/Plugins/IO/ImageReader.cxx
lib/cpPlugins/Plugins/IO/ImageReader.h
lib/cpPlugins/Plugins/IO/ImageWriter.cxx
lib/cpPlugins/Plugins/IO/ImageWriter.h
lib/cpPlugins/Plugins/IO/MeshReader.cxx
lib/cpPlugins/Plugins/IO/MeshReader.h
lib/cpPlugins/Plugins/IO/MeshWriter.cxx
lib/cpPlugins/Plugins/IO/MeshWriter.h

index cc9a01569b7efcaa2d8d926401e628752d4d3314..89af18d37e5f884dec685f8b539818b786994a57 100644 (file)
@@ -57,20 +57,13 @@ ImageMPR::
 void ImageMPR::
 _aOpenImage( )
 {
-  // Clear all, since we are loading the main image
-  if( this->m_Objects.size( ) > 0 )
-  {
-    this->m_UI->MPR->ClearAll( );
-    this->m_Objects.clear( );
-
-  } // fi
-
   // Read and show image, if possible
   TPlugins::TImage::Pointer image;
   if( this->m_Plugins->ReadImage( image, true ) )
   {
     vtkImageData* vimage = image->GetVTK< vtkImageData >( );
     if( vimage == NULL )
+    {
       QMessageBox::critical(
         this,
         QMessageBox::tr( "Error showing image." ),
@@ -78,12 +71,21 @@ _aOpenImage( )
           "Image was read, but no valid VTK conversion was found."
           )
         );
+      return;
+    }
     else
-      this->m_UI->MPR->ShowImage( vimage, image->GetName( ) );
+    {
+      // Since we are opening an image, clear all
+      this->m_UI->MPR->DeleteAllData( );
+      this->m_Objects.clear( );
 
-    // Keep a track on a local data tree
-    this->m_Objects[ image->GetName( ) ] =
-      TTreeNode( "", image.GetPointer( ) );
+      // Update references
+      std::string name = image->GetName( );
+      this->m_Objects[ name ] = TTreeNode( "", image.GetPointer( ) );
+      this->m_UI->MPR->AddImage( vimage, name );
+      this->m_UI->MPR->ShowData( name );
+
+    } // fi
 
   } // fi
 }
@@ -92,20 +94,13 @@ _aOpenImage( )
 void ImageMPR::
 _aOpenDICOMSeries( )
 {
-  // Clear all, since we are loading the main image
-  if( this->m_Objects.size( ) > 0 )
-  {
-    this->m_UI->MPR->ClearAll( );
-    this->m_Objects.clear( );
-
-  } // fi
-
   // Read and show image, if possible
   TPlugins::TImage::Pointer image;
   if( this->m_Plugins->ReadDicomSeries( image ) )
   {
     vtkImageData* vimage = image->GetVTK< vtkImageData >( );
     if( vimage == NULL )
+    {
       QMessageBox::critical(
         this,
         QMessageBox::tr( "Error showing image." ),
@@ -113,12 +108,21 @@ _aOpenDICOMSeries( )
           "Image was read, but no valid VTK conversion was found."
           )
         );
+      return;
+    }
     else
-      this->m_UI->MPR->ShowImage( vimage, image->GetName( ) );
+    {
+      // Since we are opening an image, clear all
+      this->m_UI->MPR->DeleteAllData( );
+      this->m_Objects.clear( );
 
-    // Keep a track on a local data tree
-    this->m_Objects[ image->GetName( ) ] =
-      TTreeNode( "", image.GetPointer( ) );
+      // Update references
+      std::string name = image->GetName( );
+      this->m_Objects[ name ] = TTreeNode( "", image.GetPointer( ) );
+      this->m_UI->MPR->AddImage( vimage, name );
+      this->m_UI->MPR->ShowData( name );
+
+    } // fi
 
   } // fi
 }
@@ -203,7 +207,7 @@ _aShowPlugins( )
 void ImageMPR::
 _execPlugin( )
 {
-  // Get filter name
+  // Get filter's name and category
   QAction* action = dynamic_cast< QAction* >( this->sender( ) );
   if( action == NULL )
     return;
@@ -214,8 +218,7 @@ _execPlugin( )
   std::string filter_name = action->text( ).toStdString( );
 
   // Create filter
-  TPlugins::TProcessObject::Pointer filter;
-  if( !( this->m_Plugins->CreateFilter( filter, filter_name ) ) )
+  if( !( this->m_Plugins->CreateFilter( this->m_ActiveFilter, filter_name ) ) )
   {
     QMessageBox::critical(
       this,
@@ -226,17 +229,30 @@ _execPlugin( )
             std::string( "\"defined." )
             ).c_str( ) )
       );
+    this->m_ActiveFilter = NULL;
     return;
 
   } // fi
 
   // Configure filter
-  if( !( filter->ExecConfigurationDialog( this ) ) )
+  this->m_ActiveFilter->AddInteractor( this->m_UI->MPR->GetInteractor( 0 ) );
+  this->m_ActiveFilter->AddInteractor( this->m_UI->MPR->GetInteractor( 1 ) );
+  this->m_ActiveFilter->AddInteractor( this->m_UI->MPR->GetInteractor( 2 ) );
+  this->m_ActiveFilter->AddInteractor( this->m_UI->MPR->GetInteractor( 3 ) );
+
+  TPlugins::TProcessObject::DialogResult res =
+    this->m_ActiveFilter->ExecConfigurationDialog( this );
+  if( res == TPlugins::TProcessObject::DialogResult_Cancel )
+  {
+    this->m_ActiveFilter = NULL;
     return;
 
+  } // fi
+
   // Assign inputs
   std::string data_name = this->m_UI->MPR->GetSelectedData( );
-  std::vector< std::string > inputs_names = filter->GetInputsNames( );
+  std::vector< std::string > inputs_names =
+    this->m_ActiveFilter->GetInputsNames( );
   if( inputs_names.size( ) == 1 )
   {
     TTree::iterator iIt = this->m_Objects.find( data_name );
@@ -247,10 +263,11 @@ _execPlugin( )
         tr( "Error configuring filter" ),
         tr( "No valid input found. Please select a valid input." )
         );
+      this->m_ActiveFilter = NULL;
       return;
 
     } //fi
-    filter->SetInput( inputs_names[ 0 ], iIt->second.second );
+    this->m_ActiveFilter->SetInput( inputs_names[ 0 ], iIt->second.second );
   }
   else if( inputs_names.size( ) > 1 )
   {
@@ -264,70 +281,81 @@ _execPlugin( )
   } // fi
 
   // Execute filter
-  this->_Block( );
-  std::string filter_err = filter->Update( );
-  this->_Unblock( );
-  if( filter_err != "" )
-  {
-    QMessageBox::critical(
-      this,
-      tr( "Error executing" ),
-      tr( filter_err.c_str( ) )
-      );
-    return;
-
-  } // fi
+  /*
+    if( res == TPlugins::TProcessObject::DialogResult_NoModal )
+    {
+    this->_Block( );
+    std::string filter_err = this->m_ActiveFilter->Update( );
+    this->_Unblock( );
+    if( filter_err != "" )
+    {
+      QMessageBox::critical(
+        this,
+        tr( "Error executing" ),
+        tr( filter_err.c_str( ) )
+        );
+      this->m_ActiveFilter = NULL;
+      return;
 
-  // Get outputs
-  std::vector< std::string > outputs_names = filter->GetOutputsNames( );
-  for(
-    auto oIt = outputs_names.begin( );
-    oIt != outputs_names.end( );
-    ++oIt
-    )
-  {
-    std::string out_name = filter_name + "_" + *oIt;
+    } // fi
 
-    TPlugins::TImage* image = filter->GetOutput< TPlugins::TImage >( *oIt );
-    if( image != NULL )
+    // Get outputs
+    std::vector< std::string > outputs_names = filter->GetOutputsNames( );
+    for(
+      auto oIt = outputs_names.begin( );
+      oIt != outputs_names.end( );
+      ++oIt
+      )
     {
-      if( filter_cate == "ImageToBinaryImageFilter" )
-      {
-        this->m_UI->MPR->ShowImage(
-          image->GetVTK< vtkImageData >( ),
-          out_name,
-          data_name, 1, 0, 0
-          );
-      }
-      else if( filter_cate == "ImageToImageFilter" )
+      std::string out_name = filter_name + "_" + *oIt;
+
+      TPlugins::TImage* image =
+        this->m_ActiveFilter->GetOutput< TPlugins::TImage >( *oIt );
+      if( image != NULL )
       {
+        if( filter_cate == "ImageToBinaryImageFilter" )
+        {
+          this->m_UI->MPR->ShowImage(
+            image->GetVTK< vtkImageData >( ),
+            out_name,
+            data_name, 1, 0, 0
+            );
+        }
+        else if( filter_cate == "ImageToImageFilter" )
+        {
+        } // fi
+
+        // Keep a track on a local data tree and go to next output
+        this->m_Objects[ out_name ] = TTreeNode( data_name, image );
+        continue;
+
       } // fi
 
-      // Keep a track on a local data tree and go to next output
-      this->m_Objects[ out_name ] = TTreeNode( data_name, image );
-      continue;
+      TPlugins::TMesh* mesh = filter->GetOutput< TPlugins::TMesh >( *oIt );
+      if( mesh != NULL )
+      {
+        // Show mesh
+        this->_Block( );
+        this->m_UI->MPR->ShowMesh(
+          mesh->GetVTK< vtkPolyData >( ),
+          out_name,
+          data_name
+          );
+        this->_Unblock( );
 
-    } // fi
+        // Keep a track on a local data tree and go to next output
+        this->m_Objects[ out_name ] = TTreeNode( data_name, mesh );
+        continue;
 
-    TPlugins::TMesh* mesh = filter->GetOutput< TPlugins::TMesh >( *oIt );
-    if( mesh != NULL )
-    {
-      // Show mesh
-      this->_Block( );
-      this->m_UI->MPR->ShowMesh(
-        mesh->GetVTK< vtkPolyData >( ),
-        out_name,
-        data_name
-        );
-      this->_Unblock( );
+      } // fi
 
-      // Keep a track on a local data tree and go to next output
-      this->m_Objects[ out_name ] = TTreeNode( data_name, mesh );
-      continue;
+    } // rof
 
-    } // fi
+    // No-modal filters just exists for one usage
+    this->m_ActiveFilter = NULL;
 
-  } // rof
+  } // fi
+  */
 }
 
 // -------------------------------------------------------------------------
index c4d43e33d37b8aee02f8a092812ec7f78ea5e238..f5cb03d4c052864de06c0307fbd21cdd9bd7ba12 100644 (file)
@@ -180,6 +180,9 @@ private:
   typedef std::map< std::string, TTreeNode > TTree;
   TTree m_Objects;
 
+  // Active filter (for modal configuration)
+  TPlugins::TProcessObject::Pointer m_ActiveFilter;
+
   // Plugins objects
   /*
     TPluginsInterface m_Plugins;
index bf82ba68140b1bb38ef89a2d1193b6240f4c62af..a23e3749d6e2ae4828c86b1af652124c57c26bc3 100644 (file)
@@ -1,5 +1,6 @@
 #include <cpExtensions/Interaction/ImageInteractorStyle.h>
 
+#include <vtkCommand.h>
 #include <vtkImageActor.h>
 #include <vtkPropCollection.h>
 #include <vtkProperty.h>
@@ -85,6 +86,16 @@ SeedWidgetOff( )
   } // fi
 }
 
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageInteractorStyle::
+SetSeedWidgetCommand( vtkCommand* cmd )
+{
+  if( cmd == NULL || this->m_SeedWidget == NULL )
+    return;
+  this->m_SeedWidget->Widget->
+    AddObserver( vtkCommand::PlacePointEvent, cmd );
+}
+
 // -------------------------------------------------------------------------
 cpExtensions::Interaction::ImageInteractorStyle::
 ImageInteractorStyle( )
index b63ca90fe65018750a060b412cabf4d8ba9e3476..c18ab724c6ff21584f5bd04f3930c93f8da5fa4e 100644 (file)
@@ -13,6 +13,7 @@
 #include <cpExtensions/Interaction/SeedWidget.h>
 
 // Forward definitions
+class vtkCommand;
 class vtkImageActor;
 
 namespace cpExtensions
@@ -65,6 +66,7 @@ namespace cpExtensions
       // Widgets
       void SeedWidgetOn( );
       void SeedWidgetOff( );
+      void SetSeedWidgetCommand( vtkCommand* cmd );
 
     protected:
       ImageInteractorStyle( );
index af0ad4192751367156338fb6ca57d38abfa2d039..a0c1f3eb64ace2ef98f0a279faa828ed1c1201f7 100644 (file)
@@ -68,6 +68,13 @@ AddImage( vtkImageData* image )
   this->RenderAll( 1e-3 );
 }
 
+// -------------------------------------------------------------------------
+unsigned int cpExtensions::Visualization::MPRObjects::
+GetNumberOfImages( ) const
+{
+  return( this->m_MPRActors->GetNumberOfImages( ) );
+}
+
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRObjects::
 ClearAll( )
index 8ac1cd2540aae98d1d3b7d2bb97228fbb3f58585..c21fca66f55e2fc36614e1442e502ad0c6af86a7 100644 (file)
@@ -45,6 +45,7 @@ namespace cpExtensions
         vtkRenderWindow* wz, vtkRenderWindow* w3D
         );
       void AddImage( vtkImageData* image );
+      unsigned int GetNumberOfImages( ) const;
       void ClearAll( );
 
       void ResetCamera( const int& id );
index 2017b177f7e75617a79e8f96a4d0d132977dd923..ae56e0783675397705e66928cb1c9485a521bafd 100644 (file)
@@ -10,7 +10,8 @@
 cpPlugins::Interface::BaseMPRWidget::
 BaseMPRWidget( QWidget* parent )
   : QWidget( parent ),
-    m_UI( new Ui::BaseMPRWidget )
+    m_UI( new Ui::BaseMPRWidget ),
+    m_MainImage( "" )
 {
   this->m_UI->setupUi( this );
 
@@ -44,27 +45,194 @@ cpPlugins::Interface::BaseMPRWidget::
 ~BaseMPRWidget( )
 {
   delete this->m_UI;
+}
 
-  // Delete polydata actors
-  std::map< std::string, PolyDataActor* >::iterator mIt =
-    this->m_Meshes.begin( );
-  for( ; mIt != this->m_Meshes.end( ); ++mIt )
-    delete mIt->second;
-  this->m_Meshes.clear( );
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::BaseMPRWidget::
+AddImage(
+  vtkImageData* image, const std::string& name, const std::string& parent
+  )
+{
+  if( name == "" )
+    return( false );
+
+  if( parent == "" )
+    this->DeleteAllData( );
+  
+  auto iIt = this->m_Data.find( name );
+  if( iIt == this->m_Data.end( ) )
+  {
+    // Update tree
+    if( parent != "" )
+    {
+      auto pIt = this->m_Data.find( parent );
+      if( pIt != this->m_Data.end( ) )
+        this->m_Tree[ name ] = parent;
+      else
+        return( false );
+    }
+    else
+      this->m_MainImage = name;
+    
+    // Add new data
+    Data nd;
+    nd.Tag = Data::IMAGE;
+    nd.Image = image;
+    this->m_Data[ name ] = nd;
+
+    // Add to tree view
+    this->_UpdateItem( name, parent );
+    return( true );
+  }
+  else
+    return( false );
 }
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::BaseMPRWidget::
-ShowImage(
+AddMesh(
+  vtkPolyData* mesh, const std::string& name, const std::string& parent
+  )
+{
+  if( name == "" || parent == "" )
+    return( false );
+  
+  auto iIt = this->m_Data.find( name );
+  if( iIt == this->m_Data.end( ) )
+  {
+    // Add new data
+    Data nd;
+    nd.Tag = Data::MESH;
+    nd.Mesh.Configure( mesh );
+    this->m_Data[ name ] = nd;
+
+    // Update tree
+    auto pIt = this->m_Data.find( parent );
+    if( pIt != this->m_Data.end( ) )
+      this->m_Tree[ name ] = parent;
+    else
+      return( false );
+    
+    // Add to tree view
+    this->_UpdateItem( name, parent );
+    return( true );
+  }
+  else
+    return( false );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::BaseMPRWidget::
+DeleteData( const std::string& name )
+{
+  auto iIt = this->m_Data.find( name );
+  if( iIt != this->m_Data.end( ) )
+  {
+    this->m_Data.erase( iIt );
+
+    // Get children
+    std::vector< std::string > to_erase;
+    auto tIt = this->m_Tree.begin( );
+    for( ; tIt != this->m_Tree.end( ); ++tIt )
+      if( tIt->second == name )
+        to_erase.push_back( tIt->first );
+
+    // Delete from tree
+    tIt = this->m_Tree.find( name );
+    if( tIt != this->m_Tree.end( ) )
+      this->m_Tree.erase( tIt );
+
+    // Recursive erase
+    auto dIt = to_erase.begin( );
+    for( ; dIt != to_erase.end( ); ++dIt )
+      this->DeleteData( *dIt );
+
+    // Delete from tree widget
+    QTreeWidgetItem* item = this->_FindItem( name );
+    if( item != NULL )
+      this->m_UI->LoadedData->removeItemWidget( item, 0 );
+
+    // Reset main image, just in case
+    if( this->m_Data.size( ) == 0 )
+      this->m_MainImage = "";
+    
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::BaseMPRWidget::
+DeleteAllData( )
+{
+  this->m_MPRObjects->ClearAll( );
+  this->m_Data.clear( );
+  this->m_Tree.clear( );
+  this->m_UI->LoadedData->clear( );
+  this->m_MainImage = "";
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::BaseMPRWidget::
+SetDataColor(
+  const std::string& name, const double& r, const double& g, const double& b
+  )
+{
+  auto iIt = this->m_Data.find( name );
+  if( iIt == this->m_Data.end( ) )
+    return;
+
+  if( iIt->second.Tag == Data::IMAGE )
+  {
+  }
+  else if( iIt->second.Tag == Data::MESH )
+  {
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::BaseMPRWidget::
+ShowData( const std::string& name )
+{
+  auto iIt = this->m_Data.find( name );
+  if( iIt == this->m_Data.end( ) )
+    return;
+
+  if( iIt->second.Tag == Data::IMAGE )
+  {
+    this->m_MPRObjects->AddImage( iIt->second.Image );
+  }
+  else if( iIt->second.Tag == Data::MESH )
+  {
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+vtkRenderWindowInteractor* cpPlugins::Interface::BaseMPRWidget::
+GetInteractor( unsigned int i )
+{
+  if( i < 4 )
+  {
+    if( this->m_VTK[ i ] != NULL )
+      return( this->m_VTK[ i ]->GetInteractor( ) );
+    else
+      return( NULL );
+  }
+  else
+    return( NULL );
+}
+
+// -------------------------------------------------------------------------
+/*
+  bool cpPlugins::Interface::BaseMPRWidget::
+  ShowImage(
   vtkImageData* image,
   const std::string& name,
   const std::string& parent
   )
-{
+  {
   // Update tree view
   QTreeWidgetItem* new_item = this->_UpdateItem( name, parent );
   if( new_item == NULL )
-    return( false );
+  return( false );
 
   // Associate new data
   this->m_Images[ name ] = image;
@@ -73,21 +241,21 @@ ShowImage(
   // Show image and return
   this->m_MPRObjects->AddImage( image );
   return( true );
-}
+  }
 
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::BaseMPRWidget::
-ShowImage(
+  // -------------------------------------------------------------------------
+  bool cpPlugins::Interface::BaseMPRWidget::
+  ShowImage(
   vtkImageData* image,
   const std::string& name,
   const std::string& parent,
   const double& r, const double& g, const double& b
   )
-{
+  {
   // Update tree view
   QTreeWidgetItem* new_item = this->_UpdateItem( name, parent );
   if( new_item == NULL )
-    return( false );
+  return( false );
 
   // Associate new data
   this->m_Images[ name ] = image;
@@ -96,20 +264,20 @@ ShowImage(
   // Show image and return
   this->m_MPRObjects->AddImage( image );
   return( true );
-}
+  }
 
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::BaseMPRWidget::
-ShowMesh(
+  // -------------------------------------------------------------------------
+  bool cpPlugins::Interface::BaseMPRWidget::
+  ShowMesh(
   vtkPolyData* mesh,
   const std::string& name,
   const std::string& parent
   )
-{
+  {
   // Update tree view
   QTreeWidgetItem* new_item = this->_UpdateItem( name, parent );
   if( new_item == NULL )
-    return( false );
+  return( false );
 
   // Associate new data
   PolyDataActor* actor = new PolyDataActor( mesh );
@@ -119,30 +287,29 @@ ShowMesh(
   // Show mesh
   this->_Add3DActor( actor->Actor );
   return( true );
-}
+  }
 
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::BaseMPRWidget::
-ShowMesh(
+  // -------------------------------------------------------------------------
+  bool cpPlugins::Interface::BaseMPRWidget::
+  ShowMesh(
   vtkPolyData* mesh,
   const std::string& name,
   const std::string& parent,
   const double& r, const double& g, const double& b
   )
-{
+  {
   return false;
-}
+  }
 
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWidget::
-ClearAll( )
-{
-  /*
-    this->m_MPRObjects->ClearAll( );
-    this->m_Images.clear( );
-    this->m_Meshes.clear( );
-  */
-}
+  // -------------------------------------------------------------------------
+  void cpPlugins::Interface::BaseMPRWidget::
+  ClearAll( )
+  {
+  this->m_MPRObjects->ClearAll( );
+  this->m_Images.clear( );
+  this->m_Meshes.clear( );
+  }
+*/
 
 // -------------------------------------------------------------------------
 std::string cpPlugins::Interface::BaseMPRWidget::
@@ -201,16 +368,18 @@ _UpdateItem( const std::string& name, const std::string& parent )
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWidget::
-_Add3DActor( vtkProp3D* prop )
-{
+/*
+  void cpPlugins::Interface::BaseMPRWidget::
+  _Add3DActor( vtkProp3D* prop )
+  {
   vtkRenderer* ren =
-    this->m_VTK[ 3 ]->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( );
+  this->m_VTK[ 3 ]->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( );
   if( ren == NULL )
-    return;
+  return;
   ren->AddActor( prop );
   this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
-}
+  }
+*/
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::BaseMPRWidget::
@@ -227,8 +396,8 @@ _SyncTop( int a, int b )
 }
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::BaseMPRWidget::PolyDataActor::
-PolyDataActor( vtkPolyData* pd )
+void cpPlugins::Interface::BaseMPRWidget::PolyDataActor::
+Configure( vtkPolyData* pd )
 {
   if( pd ==  NULL )
     return;
@@ -241,6 +410,7 @@ PolyDataActor( vtkPolyData* pd )
   this->Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
   this->Actor = vtkSmartPointer< vtkQuadricLODActor >::New( );
 
+  this->Mesh = pd;
   this->Normals->SetInputData( pd );
   this->Normals->SetFeatureAngle( 60.0 );
   this->Stripper->SetInputConnection( this->Normals->GetOutputPort( ) );
index 9ed62ceb7ede51cc041dc0a89cba61f14889c2cb..0807a87e1fa697b7b93fcd16d9ec3325d90a5305 100644 (file)
@@ -12,6 +12,7 @@
 #include <QWidget>
 
 #include <vtkSmartPointer.h>
+#include <vtkImageData.h>
 #include <vtkPolyDataMapper.h>
 #include <vtkPolyDataNormals.h>
 #include <vtkQuadricLODActor.h>
@@ -60,30 +61,56 @@ namespace cpPlugins
       explicit BaseMPRWidget( QWidget* parent = 0 );
       virtual ~BaseMPRWidget( );
 
+      // Data management
+      bool AddImage(
+        vtkImageData* image,
+        const std::string& name,
+        const std::string& parent = ""
+        );
+      bool AddMesh(
+        vtkPolyData* mesh,
+        const std::string& name,
+        const std::string& parent
+        );
+      void DeleteData( const std::string& name );
+      void DeleteAllData( );
+
       // Some visualization accessors
-      bool ShowImage(
+      void SetDataColor(
+        const std::string& name,
+        const double& r,
+        const double& g,
+        const double& b
+        );
+      void ShowData( const std::string& name );
+
+      vtkRenderWindowInteractor* GetInteractor( unsigned int i );
+
+      /*
+        bool ShowImage(
         vtkImageData* image,
         const std::string& name,
         const std::string& parent = ""
         );
-      bool ShowImage(
+        bool ShowImage(
         vtkImageData* image,
         const std::string& name,
         const std::string& parent,
         const double& r, const double& g, const double& b
         );
-      bool ShowMesh(
+        bool ShowMesh(
         vtkPolyData* mesh,
         const std::string& name,
         const std::string& parent
         );
-      bool ShowMesh(
+        bool ShowMesh(
         vtkPolyData* mesh,
         const std::string& name,
         const std::string& parent,
         const double& r, const double& g, const double& b
         );
-      void ClearAll( );
+        void ClearAll( );
+      */
 
       // Visual objects accessors
       std::string GetSelectedData( ) const;
@@ -94,8 +121,10 @@ namespace cpPlugins
         const std::string& name,
         const std::string& parent
         );
-      
-      void _Add3DActor( vtkProp3D* prop );
+
+      /* TODO
+         void _Add3DActor( vtkProp3D* prop );
+      */
 
     private slots:
       void _SyncBottom( int a, int b );
@@ -104,22 +133,67 @@ namespace cpPlugins
     protected:
       Ui::BaseMPRWidget*             m_UI;
       vtkSmartPointer< TMPRObjects > m_MPRObjects;
+      QVTKWidget*                    m_VTK[ 4 ];
 
       struct PolyDataActor
       {
+        vtkSmartPointer< vtkPolyData >        Mesh;
         vtkSmartPointer< vtkPolyDataNormals > Normals;
         vtkSmartPointer< vtkStripper >        Stripper;
         vtkSmartPointer< vtkPolyDataMapper >  Mapper;
         vtkSmartPointer< vtkQuadricLODActor > Actor;
 
-        PolyDataActor( vtkPolyData* pd );
+        void Configure( vtkPolyData* pd );
       };
 
-      std::map< std::string, vtkImageData* >  m_Images;
-      std::map< std::string, PolyDataActor* > m_Meshes;
-      std::map< std::string, std::string >    m_Tree;
+      struct Data
+      {
+        enum { IMAGE, MESH } Tag;
+        union
+        {
+          vtkImageData* Image;
+          PolyDataActor Mesh;
+        };
+
+        Data( ) { }
+        virtual ~Data( ) { }
+
+        inline Data& operator=( const Data& data )
+          {
+            this->Tag = data.Tag;
+            if( this->Tag == Data::IMAGE )
+              this->Image = data.Image;
+            else if( this->Tag == Data::MESH )
+              this->Mesh = data.Mesh;
+            return( *this );
+          }
+
+        inline vtkImageData* GetImage( )
+          {
+            if( this->Tag == Data::IMAGE )
+              return( this->Image );
+            else
+              return( NULL );
+          }
+        inline vtkPolyData* GetMesh( )
+          {
+            if( this->Tag == Data::MESH )
+              return( this->Mesh.Mesh.GetPointer( ) );
+            else
+              return( NULL );
+          }
+        inline vtkProp* GetMeshActor( )
+          {
+            if( this->Tag == Data::MESH )
+              return( this->Mesh.Actor.GetPointer( ) );
+            else
+              return( NULL );
+          }
+      };
 
-      QVTKWidget* m_VTK[ 4 ];
+      std::string m_MainImage;
+      std::map< std::string, Data >        m_Data;
+      std::map< std::string, std::string > m_Tree;
     };
 
   } // ecapseman
index 3cea961f89ba63806c0e43193ef45e203aed0787..12cca5d7b87a6b5ed3818a0085200fc2875aa6de 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <cpPlugins/Interface/ParametersListWidget.h>
 
+#include <vtkCommand.h>
 #include <vtkRenderWindowInteractor.h>
 
 #include <QCheckBox>
 #include <QLineEdit>
 #include <QWidget>
 
+// -------------------------------------------------------------------------
+class SingleSeedCommand
+  : public vtkCommand
+{
+public:
+  static SingleSeedCommand* New( )
+    { return( new SingleSeedCommand ); }
+  virtual void Execute( vtkObject* caller, unsigned long eid, void* data )
+    {
+      if( eid != vtkCommand::PlacePointEvent )
+        return;
+#error ACA VOY
+    }
+};
+
 // -------------------------------------------------------------------------
 cpPlugins::Interface::ParametersQtDialog::
 ParametersQtDialog( QWidget* parent, Qt::WindowFlags f )
@@ -131,22 +147,23 @@ setParameters( Parameters* parameters )
     }
     else if( pt == Parameters::Point || pt == Parameters::Index )
     {
+      vtkSmartPointer< SingleSeedCommand > command =
+        vtkSmartPointer< SingleSeedCommand >::New( );
+
       auto iIt = this->m_Interactors.begin( );
       for( ; iIt != this->m_Interactors.end( ); ++iIt )
       {
         TStyle* style =
           dynamic_cast< TStyle* >( ( *iIt )->GetInteractorStyle( ) );
-        std::cout << "ACA VOY --> " << style << std::endl;
-
-      } // rof
-      this->m_IsModal = false;
-
-      /*
-        if( this->m_Interactor != NULL )
+        if( style != NULL )
         {
+          style->SeedWidgetOn( );
+          style->SetSeedWidgetCommand( command );
 
         } // fi
-      */
+
+      } // rof
+      this->m_IsModal = false;
 
     } // fi
 
index 45f555968db206262808d8890de0bb8641591195..0e6921262eede919b7a53c4002fa9bff06a7dda6 100644 (file)
@@ -271,10 +271,10 @@ ReadImage( TImage::Pointer& image, bool exec_qt )
 
   if( ret == "" )
   {
-    bool execute = true;
+    TProcessObject::DialogResult dret = TProcessObject::DialogResult_NoModal;
     if( exec_qt )
-      execute = this->m_ImageReader->ExecConfigurationDialog( this->m_Widget );
-    if( execute )
+      dret = this->m_ImageReader->ExecConfigurationDialog( this->m_Widget );
+    if( dret != TProcessObject::DialogResult_Cancel )
     {
       this->BlockWidget( );
       ret = this->m_ImageReader->Update( );
@@ -319,7 +319,9 @@ ReadDicomSeries( TImage::Pointer& image )
 
   if( ret == "" )
   {
-    if( this->m_DicomSeriesReader->ExecConfigurationDialog( this->m_Widget ) )
+    TProcessObject::DialogResult dret =
+      this->m_DicomSeriesReader->ExecConfigurationDialog( this->m_Widget );
+    if( dret != TProcessObject::DialogResult_Cancel )
     {
       this->BlockWidget( );
       ret = this->m_DicomSeriesReader->Update( );
@@ -365,10 +367,10 @@ ReadMesh( TMesh::Pointer& mesh, bool exec_qt )
 
   if( ret == "" )
   {
-    bool execute = true;
+    TProcessObject::DialogResult dret = TProcessObject::DialogResult_NoModal;
     if( exec_qt )
-      execute = this->m_MeshReader->ExecConfigurationDialog( this->m_Widget );
-    if( execute )
+      dret = this->m_MeshReader->ExecConfigurationDialog( this->m_Widget );
+    if( dret != TProcessObject::DialogResult_Cancel )
     {
       this->BlockWidget( );
       ret = this->m_MeshReader->Update( );
@@ -412,10 +414,10 @@ WriteImage( TImage* image, bool exec_qt )
 
   if( ret == "" )
   {
-    bool execute = true;
+    TProcessObject::DialogResult dret = TProcessObject::DialogResult_NoModal;
     if( exec_qt )
-      execute = this->m_ImageWriter->ExecConfigurationDialog( this->m_Widget );
-    if( execute )
+      dret = this->m_ImageWriter->ExecConfigurationDialog( this->m_Widget );
+    if( dret != TProcessObject::DialogResult_Cancel )
     {
       this->m_ImageWriter->SetInput( "Input", image );
       this->BlockWidget( );
@@ -453,10 +455,10 @@ WriteMesh( TMesh* mesh, bool exec_qt )
 
   if( ret == "" )
   {
-    bool execute = true;
+    TProcessObject::DialogResult dret = TProcessObject::DialogResult_NoModal;
     if( exec_qt )
-      execute = this->m_MeshWriter->ExecConfigurationDialog( this->m_Widget );
-    if( execute )
+      dret = this->m_MeshWriter->ExecConfigurationDialog( this->m_Widget );
+    if( dret != TProcessObject::DialogResult_Cancel )
     {
       this->m_MeshWriter->SetInput( "Input", mesh );
       this->BlockWidget( );
index f639d7f59e3ea2b5686950a48151e98b0d05ef73..9c3148d00fe9adf9abd0a7392bef5c60619a6add 100644 (file)
@@ -4,6 +4,8 @@
 #include <cpPlugins/Interface/ParametersQtDialog.h>
 #endif // cpPlugins_Interface_QT4
 
+#include <vtkRenderWindowInteractor.h>
+
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::ProcessObject::
 Modified( ) const
@@ -115,39 +117,39 @@ DisconnectOutputs( )
 }
 
 // -------------------------------------------------------------------------
-bool cpPlugins::Interface::ProcessObject::
+void cpPlugins::Interface::ProcessObject::
+AddInteractor( vtkRenderWindowInteractor* interactor )
+{
+#ifdef cpPlugins_Interface_QT4
+  this->m_ParametersDialog->addInteractor( interactor );
+#endif // cpPlugins_Interface_QT4
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObject::
+DialogResult cpPlugins::Interface::ProcessObject::
 ExecConfigurationDialog( QWidget* parent )
 {
-  bool r = false;
+  DialogResult r = Self::DialogResult_Cancel;
 
 #ifdef cpPlugins_Interface_QT4
 
-  if( this->m_ParametersDialog == NULL )
-  {
-    this->m_ParametersDialog = new ParametersQtDialog( parent );
-    this->m_ParametersDialog->setTitle(
-      this->GetClassName( ) + std::string( " basic configuration" )
-      );
-    this->m_ParametersDialog->setParameters( this->m_Parameters );
-
-  } // fi
+  this->m_ParametersDialog->setParent( NULL );
+  this->m_ParametersDialog->setParameters( this->m_Parameters );
 
   if( !( this->m_ParametersDialog->IsModal( ) ) )
   {
     this->m_ParametersDialog->show( );
-    r = true;
+    r = Self::DialogResult_Modal;
   }
   else
-    r = ( this->m_ParametersDialog->exec( ) == 1 );
+  {
+    if( this->m_ParametersDialog->exec( ) == 1 )
+      r = Self::DialogResult_NoModal;
+    else
+      r = Self::DialogResult_Cancel;
 
-  /*
-    r = cpPlugins::Interface::ParametersQtDialog(
-    this->m_Parameters,
-    this->GetClassName( ) + std::string( " basic configuration" ),
-    parent
-    );
-    if( r )
-  */
+  } // fi
 
 #endif // cpPlugins_Interface_QT4
 
@@ -159,18 +161,21 @@ cpPlugins::Interface::ProcessObject::
 ProcessObject( )
   : Superclass( ),
     m_ITKObject( NULL ),
-    m_VTKObject( NULL ),
-    m_ParametersDialog( NULL )
+    m_VTKObject( NULL )
 {
   this->m_Parameters = TParameters::New( );
+
+  this->m_ParametersDialog = new ParametersQtDialog( );
+  this->m_ParametersDialog->setTitle(
+    this->GetClassName( ) + std::string( " basic configuration" )
+    );
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::ProcessObject::
 ~ProcessObject( )
 {
-  if( this->m_ParametersDialog == NULL )
-    delete this->m_ParametersDialog;
+  delete this->m_ParametersDialog;
 }
 
 // -------------------------------------------------------------------------
index 5fc98f399f605b624bcdd1155e65b67f1be823e0..6f388143cbb376cd837b207f8aaf64acf33ab167 100644 (file)
@@ -22,6 +22,8 @@ typedef char QWidget;
 #include <vtkSmartPointer.h>
 #include <vtkAlgorithm.h>
 
+class vtkRenderWindowInteractor;
+
 namespace cpPlugins
 {
   namespace Interface
@@ -45,6 +47,13 @@ namespace cpPlugins
 
       typedef Parameters TParameters;
 
+      enum DialogResult
+      {
+        DialogResult_NoModal = 0,
+        DialogResult_Modal,
+        DialogResult_Cancel
+      };
+
     public:
       itkTypeMacro( ProcessObject, Object );
       cpPlugins_Id_Macro(
@@ -69,7 +78,8 @@ namespace cpPlugins
       virtual std::string Update( );
       virtual void DisconnectOutputs( );
 
-      virtual bool ExecConfigurationDialog( QWidget* parent );
+      virtual void AddInteractor( vtkRenderWindowInteractor* interactor );
+      virtual DialogResult ExecConfigurationDialog( QWidget* parent );
 
       template< class T >
         inline T* GetITK( );
index e915fcf58e4c746881cd0a655e929309ad4c8e04..e2aeb31b51f2bacb8faf5602d77e0f96d5a4265f 100644 (file)
 #include <itkGDCMSeriesFileNames.h>
 
 // -------------------------------------------------------------------------
-bool cpPlugins::IO::DicomSeriesReader::
+cpPlugins::IO::DicomSeriesReader::
+DialogResult cpPlugins::IO::DicomSeriesReader::
 ExecConfigurationDialog( QWidget* parent )
 {
-  bool r = false;
+  DialogResult r = Self::DialogResult_Cancel;
 
 #ifdef cpPlugins_Interface_QT4
 
@@ -37,7 +38,7 @@ ExecConfigurationDialog( QWidget* parent )
   dialog.setFileMode( QFileDialog::DirectoryOnly );
   dialog.setDirectory( QFileDialog::tr( "." ) );
   if( !dialog.exec( ) )
-    return( false );
+    return( Self::DialogResult_Cancel );
 
   // Prepare dialog
   QApplication::setOverrideCursor( Qt::WaitCursor );
@@ -119,7 +120,7 @@ ExecConfigurationDialog( QWidget* parent )
   {
     delete tree_widget;
     delete tree_dialog;
-    return( false );
+    return( Self::DialogResult_Cancel );
 
   } // fi
 
@@ -149,7 +150,7 @@ ExecConfigurationDialog( QWidget* parent )
     parent->setEnabled( true );
 
   if( tree_dialog->exec( ) == 0 )
-    return( false );
+    return( Self::DialogResult_Cancel );
 
   QTreeWidgetItem* item = tree_widget->currentItem( );
   if( item != NULL )
@@ -169,7 +170,7 @@ ExecConfigurationDialog( QWidget* parent )
       for( unsigned int f = 0; f < names.size( ); ++f )
         this->m_Parameters->AddToStringList( "FileNames", names[ f ] );
 
-      r = true;
+      r = Self::DialogResult_NoModal;
 
       QApplication::restoreOverrideCursor( );
       if( parent != NULL )
index 3bad459b150aa33899ebc33cba3c968be4a3b8f6..c91247606f3e88cbfe3671a535bb0d5d680fdf0a 100644 (file)
@@ -37,7 +37,7 @@ namespace cpPlugins
         );
 
     public:
-      virtual bool ExecConfigurationDialog( QWidget* parent );
+      virtual DialogResult ExecConfigurationDialog( QWidget* parent );
 
     protected:
       DicomSeriesReader( );
index fc747eb7348f910d36a04f936a10a9f8ee43fce4..a7c6687c199b1cbc9c80f8695f4843e3971f1f41 100644 (file)
@@ -9,10 +9,11 @@
 #endif // cpPlugins_Interface_QT4
 
 // -------------------------------------------------------------------------
-bool cpPlugins::IO::ImageReader::
+cpPlugins::IO::ImageReader::
+DialogResult cpPlugins::IO::ImageReader::
 ExecConfigurationDialog( QWidget* parent )
 {
-  bool r = false;
+  DialogResult r = Self::DialogResult_Cancel;
 
 #ifdef cpPlugins_Interface_QT4
 
@@ -40,7 +41,7 @@ ExecConfigurationDialog( QWidget* parent )
         "FileNames", qIt->toStdString( )
         );
     this->m_Parameters->SetBool( "VectorType", false );
-    r = true;
+    r = Self::DialogResult_NoModal;
 
   } // fi
 
index 2f41e10ceb99021c0dd11bd42ee81b519e17d4fb..822c5fd7b4ccaea3e83b9b2408072b1fbc1cce1a 100644 (file)
@@ -37,7 +37,7 @@ namespace cpPlugins
         );
 
     public:
-      virtual bool ExecConfigurationDialog( QWidget* parent );
+      virtual DialogResult ExecConfigurationDialog( QWidget* parent );
 
     protected:
       ImageReader( );
index 63080e27adcece1d9622fbfec2390c659a78d910..519adb6638a3dc1b5fff12f811f1be9690353afb 100644 (file)
@@ -8,10 +8,11 @@
 #endif // cpPlugins_Interface_QT4
 
 // -------------------------------------------------------------------------
-bool cpPlugins::IO::ImageWriter::
+cpPlugins::IO::ImageWriter::
+DialogResult cpPlugins::IO::ImageWriter::
 ExecConfigurationDialog( QWidget* parent )
 {
-  bool r = false;
+  DialogResult r = Self::DialogResult_Cancel;
 
 #ifdef cpPlugins_Interface_QT4
 
@@ -31,7 +32,7 @@ ExecConfigurationDialog( QWidget* parent )
   if( name != "" )
   {
     this->m_Parameters->SetString( "FileName", name );
-    r = true;
+    r = Self::DialogResult_NoModal;
 
   } // fi
 
index 849fc4745f3edde9370f8676e97a15b704c2a86c..a9db113a356ca8a5ba9698fe70d2913320c936a1 100644 (file)
@@ -27,7 +27,7 @@ namespace cpPlugins
         );
 
     public:
-      virtual bool ExecConfigurationDialog( QWidget* parent );
+      virtual DialogResult ExecConfigurationDialog( QWidget* parent );
 
     protected:
       ImageWriter( );
index 077b96955a52e3c6f977f0154fcea23faf84714e..f8c3b84483a96a6b79be61bf9a11eb056fddcd48 100644 (file)
@@ -9,10 +9,11 @@
 #endif // cpPlugins_Interface_QT4
 
 // -------------------------------------------------------------------------
-bool cpPlugins::IO::MeshReader::
+cpPlugins::IO::MeshReader::
+DialogResult cpPlugins::IO::MeshReader::
 ExecConfigurationDialog( QWidget* parent )
 {
-  bool r = false;
+  DialogResult r = Self::DialogResult_Cancel;
 
 #ifdef cpPlugins_Interface_QT4
 
@@ -28,7 +29,7 @@ ExecConfigurationDialog( QWidget* parent )
     this->m_Parameters->SetSelectedChoice( "PixelType", "float" );
     this->m_Parameters->SetUint( "Dimension", 3 );
 
-    r = true;
+    r = Self::DialogResult_NoModal;
 
   } // fi
 
index 7544a243436aa5a3953d75b8e96e2a16b887e5be..6724cd5ef968c6a322796df6eac360e2f5c02bee 100644 (file)
@@ -29,7 +29,7 @@ namespace cpPlugins
         );
 
     public:
-      virtual bool ExecConfigurationDialog( QWidget* parent );
+      virtual DialogResult ExecConfigurationDialog( QWidget* parent );
 
     protected:
       MeshReader( );
index 4aae3a3d5553fe3fdf8ba7a1f0dd1cb33813edd8..13531a5590617b4595ff81e79d414107499d7667 100644 (file)
 #endif // cpPlugins_Interface_QT4
 
 // -------------------------------------------------------------------------
-bool cpPlugins::IO::MeshWriter::
+cpPlugins::IO::MeshWriter::
+DialogResult cpPlugins::IO::MeshWriter::
 ExecConfigurationDialog( QWidget* parent )
 {
-  bool r = false;
+  DialogResult r = Self::DialogResult_Cancel;
 
 #ifdef cpPlugins_Interface_QT4
 
@@ -33,7 +34,7 @@ ExecConfigurationDialog( QWidget* parent )
   if( name != "" )
   {
     this->m_Parameters->SetString( "FileName", name );
-    r = true;
+    r = Self::DialogResult_NoModal;
 
   } // fi
 
index c97509df79eb2b20d5d100a9a9a661d2da9691f9..36668646cdcbd96d1a30ecbe99ea51094ecb8fb6 100644 (file)
@@ -29,7 +29,7 @@ namespace cpPlugins
         );
 
     public:
-      virtual bool ExecConfigurationDialog( QWidget* parent );
+      virtual DialogResult ExecConfigurationDialog( QWidget* parent );
 
     protected:
       MeshWriter( );