]> Creatis software - cpPlugins.git/commitdiff
More tree visualization
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 28 Oct 2015 03:24:43 +0000 (22:24 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 28 Oct 2015 03:24:43 +0000 (22:24 -0500)
appli/ImageMPR/ImageMPR.cxx
lib/cpExtensions/Visualization/ImageSliceActors.cxx
lib/cpPlugins/Interface/BaseMPRWidget.cxx
lib/cpPlugins/Interface/ParametersQtDialog.cxx
lib/cpPlugins/Interface/Plugins.cxx
lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h

index 47c3622e4e7430af2663940ea6a32de22d1e7de2..69970b7ccd8b6c25e7592d25e61c2475a5b2b21c 100644 (file)
@@ -138,10 +138,13 @@ _aOpenPolyData( )
 void ImageMPR::
 _aSaveImage( )
 {
-  /*
-    if( this->m_MainImage.IsNotNull( ) )
-    this->m_Plugins->WriteImage( this->m_MainImage, true );
-  */
+  std::string data_name = this->m_UI->MPR->GetSelectedData( );
+  TPlugins::TImage* image = dynamic_cast< TPlugins::TImage* >(
+    this->m_Objects[ data_name ].second.GetPointer( )
+    );
+  if( image == NULL )
+    return;
+  this->m_Plugins->WriteImage( image, true );
 }
 
 // -------------------------------------------------------------------------
@@ -154,6 +157,13 @@ _aSaveSegmentation( )
 void ImageMPR::
 _aSavePolyData( )
 {
+  std::string data_name = this->m_UI->MPR->GetSelectedData( );
+  TPlugins::TMesh* mesh = dynamic_cast< TPlugins::TMesh* >(
+    this->m_Objects[ data_name ].second.GetPointer( )
+    );
+  if( mesh == NULL )
+    return;
+  this->m_Plugins->WriteMesh( mesh, true );
 }
 
 // -------------------------------------------------------------------------
@@ -188,13 +198,6 @@ _aShowPlugins( )
 void ImageMPR::
 _execPlugin( )
 {
-  /*
-  typedef std::map< std::string, TPlugins::TImage::Pointer > _TImages;
-  typedef std::map< std::string, TPlugins::TMesh::Pointer >  _TMeshes;
-
-  // Get selected data
-  // std::string data_name = this->m_UI->MPR->GetSelectedData( );
-
   // Get filter name
   QAction* action = dynamic_cast< QAction* >( this->sender( ) );
   if( action == NULL )
@@ -222,159 +225,104 @@ _execPlugin( )
 
   } // fi
 
+  // Configure filter
+  if( !( filter->ExecConfigurationDialog( this ) ) )
+    return;
+
   // Assign inputs
+  std::string data_name = this->m_UI->MPR->GetSelectedData( );
   std::vector< std::string > inputs_names = filter->GetInputsNames( );
   if( inputs_names.size( ) == 1 )
   {
-       std::string data_name = this->m_UI->MPR->GetSelectedData( );
-       _TImages::iterator iIt = this->m_Images.find( data_name );
-       _TImages::iterator mIt = this->m_Meshes.find( data_name );
-       filter->SetInput( inputs_names[ 0 ]);
-  }
-  else if( inputs_names.size( ) > 1 )
-  {
-  } // fi
-
-  // Get outputs
-  std::vector< std::string > outputs_names = filter->GetOutputsNames( );
-  */
-
-  /*
-
-  // Choose inputs
-  if( filter_cate == "ImageToMeshFilter" )
-  {
-    // Check inputs
-    _TImages::iterator iIt = this->m_Images.find( data_name );
-    if( iIt == this->m_Images.end( ) )
+    TTree::iterator iIt = this->m_Objects.find( data_name );
+    if( iIt == this->m_Objects.end( ) )
     {
       QMessageBox::critical(
         this,
-        tr( "Error creating filter" ),
-        tr( "No valid input selected." )
+        tr( "Error configuring filter" ),
+        tr( "No valid input found. Please select a valid input." )
         );
       return;
 
-    } // fi
-
-    // Execute configuration dialog
-    if( !( filter->ExecConfigurationDialog( this ) ) )
-      return;
-
-    // Execute filter
-    filter->SetInput( "Input", iIt->second );
-    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
+    filter->SetInput( inputs_names[ 0 ], iIt->second.second );
+  }
+  else if( inputs_names.size( ) > 1 )
+  {
+    QMessageBox::critical(
+      this,
+      tr( "Error executing" ),
+      tr( "Filter has multiple inputs: NOT YET IMPLEMENTED!!!" )
+      );
+    return;
 
-    } // fi
+  } // fi
 
-    // Keep and show results
-    TPlugins::TMesh::Pointer mesh =
-      filter->GetOutput< TPlugins::TMesh >( "Output" );
-    this->m_Meshes[ filter_name ] = mesh;
-    this->_Block( );
-    this->m_UI->MPR->ShowMesh(
-      mesh->GetVTK< vtkPolyData >( ),
-      filter_name,
-      data_name
+  // 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( ) )
       );
-    this->_Unblock( );
+    return;
 
   } // fi
-  */
 
-  /*
-    if( this->m_Plugins->CreateFilter( filter, name ) )
-    {
-    if( filter->ExecConfigurationDialog( this ) )
+  // 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;
+
+    TPlugins::TImage* image = filter->GetOutput< TPlugins::TImage >( *oIt );
+    if( image != NULL )
     {
-    filter->SetInput( "Input", this->m_MainImage );
-    this->_Block( );
-    err = filter->Update( );
-    this->_Unblock( );
-    TPlugins::TMesh::Pointer mesh =
-    filter->GetOutput< TPlugins::TMesh >( "Output" );
-    this->m_Meshes.push_back( mesh );
-    mesh->CreateVTKActor( );
-    vtkActor* actor = mesh->GetVTKActor( );
-    if( actor != NULL )
-    this->m_UI->MPR->Add3DActor( actor );
+      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
-    
-    } // fi
-    }
-    else
-    QMessageBox::critical(
-    this,
-    tr( "Error creating filter" ),
-    tr( "No valid filter defined." )
-    );
-  */
-  /*
-    if( name == "cpPlugins::BasicFilters::FloodFillImageFilter" )
-    {
-    this->m_Flooding = true;
-    }
-    else
+
+    TPlugins::TMesh* mesh = filter->GetOutput< TPlugins::TMesh >( *oIt );
+    if( mesh != NULL )
     {
-    this->m_Flooding = false;
-    this->m_UI->MPR->ExecuteFilter(
-    name, this->m_ImageLoaded, "SegmentedImage"
-    );
-    
-    } // fi
-  */
-  
-  // Configure filter
-  /*
-    TPluginFilter::Pointer filter =
-    this->m_Plugins.CreateProcessObject( name );
-    bool dlg_ok = filter->ExecConfigurationDialog( NULL );
-    if( !dlg_ok )
-    return;
+      // Show mesh
+      this->_Block( );
+      this->m_UI->MPR->ShowMesh(
+        mesh->GetVTK< vtkPolyData >( ),
+        out_name,
+        data_name
+        );
+      this->_Unblock( );
 
-    // Execute filter
-    QApplication::setOverrideCursor( Qt::WaitCursor );
-    this->setEnabled( false );
-    filter->SetInput( 0, this->m_Image );
-    std::string err = filter->Update( );
-    QApplication::restoreOverrideCursor( );
-    this->setEnabled( true );
+      // Keep a track on a local data tree and go to next output
+      this->m_Objects[ out_name ] = TTreeNode( data_name, mesh );
+      continue;
 
-    // Update image
-    if( err == "" )
-    {
-    TPluginImage* result = filter->GetOutput< TPluginImage >( 0 );
-    result->DisconnectPipeline( );
-    this->m_Image = result;
-    if( this->m_Image.IsNotNull( ) )
-    this->m_MPRObjects->SetImage(
-    this->m_Image->GetVTK< vtkImageData >( )
-    );
-    MementoState(this->m_state, this->m_Image);
-    this->m_state++;
-    if (this->m_state > this->m_max_state)
-    {
-    this->m_max_state = this->m_state;
-    }
-    }
-    else
-    QMessageBox::critical(
-    this,
-    tr( "Error executing filter" ),
-    tr( err.c_str( ) )
-    );
-  */
+    } // fi
+
+  } // rof
 }
 
 // -------------------------------------------------------------------------
index e3a2ff0a5e06c6989ca2a869837ff6419cf54142..450bdb688e129b33390c3ce64fd7069d55fd97fe 100644 (file)
@@ -307,8 +307,8 @@ PushActorsInto( vtkRenderWindow* window, bool force_style )
     }
     else if( axis == 1 )
     {
-      camera->SetPosition( double( 0 ), double( 1 ), double( 0 ) );
-      camera->SetViewUp  ( double( 0 ), double( 0 ), double( 1 ) );
+      camera->SetPosition( double( 0 ), double( -1 ), double( 0 ) );
+      camera->SetViewUp  ( double( 0 ), double(  0 ), double( 1 ) );
     }
     else // if( axis == 2 )
     {
index fece6b83b15688d26bfb8fdc83bedcd94ba85d3c..88e3b894ecb483567e2a5bfe7fb1f07dafdaaee3 100644 (file)
@@ -84,6 +84,13 @@ ShowImage(
   const double& r, const double& g, const double& b
   )
 {
+  std::cout
+    << "BaseMPRWidget: "
+    << image << " "
+    << name << " "
+    << parent << " "
+    << r << " " << g << " " << b << std::endl;
+  return( false );
 }
 
 // -------------------------------------------------------------------------
index 8a012b646ef59f41da7d9ea03853ded410808426..0891a2b5c09c409c9c5d80381ef5114a27b441cd 100644 (file)
@@ -203,7 +203,8 @@ exec( )
   this->m_ToolsLayout->addWidget( bb );
 
   int ret = this->QDialog::exec( );
-  this->syncParameters( );
+  if( ret == 1 )
+    this->syncParameters( );
   return( ret );
 }
 
index b9dab29a1d1fafe68c5aba0195e37a1850bdd93d..45f555968db206262808d8890de0bb8641591195 100644 (file)
@@ -455,10 +455,10 @@ WriteMesh( TMesh* mesh, bool exec_qt )
   {
     bool execute = true;
     if( exec_qt )
-      execute = this->m_MeshReader->ExecConfigurationDialog( this->m_Widget );
+      execute = this->m_MeshWriter->ExecConfigurationDialog( this->m_Widget );
     if( execute )
     {
-      this->m_MeshWriter->SetInput( 0, mesh );
+      this->m_MeshWriter->SetInput( "Input", mesh );
       this->BlockWidget( );
       ret = this->m_MeshWriter->Update( );
       this->UnblockWidget( );
index 6bc538e7efa635de4ca9b99bdeecb816f7bf237b..8e2f6fbb59fdcea2c81e4c69a6508998ff13d725 100644 (file)
@@ -27,7 +27,7 @@ std::string cpPlugins::BasicFilters::OtsuThresholdImageFilter::
 _GenerateData( )
 {
   cpPlugins::Interface::Image* image =
-    this->GetInput< cpPlugins::Interface::Image >( 0 );
+    this->GetInput< cpPlugins::Interface::Image >( "Input" );
   if( image == NULL )
     return( "OtsuThresholdImageFilter: No input image." );
 
index 5f216dd01fb98747fe27bd4a10bee457a00b133e..671acb50a1518b053c6c57d5ce53b2d3f231c586 100644 (file)
@@ -27,7 +27,7 @@ namespace cpPlugins
         );
       cpPlugins_Id_Macro(
         cpPlugins::BasicFilters::OtsuThresholdImageFilter,
-        "ImageToImageFilter"
+        "ImageToBinaryImageFilter"
         );
 
     protected: