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 );
}
// -------------------------------------------------------------------------
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 );
}
// -------------------------------------------------------------------------
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 )
} // 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
}
// -------------------------------------------------------------------------