-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_ActionOpenWorkspace( )
-{
- QFileDialog dlg( this );
- dlg.setFileMode( QFileDialog::ExistingFile );
- dlg.setDirectory( "." );
- dlg.setNameFilter(
- QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" )
- );
- dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) );
- if( !( dlg.exec( ) ) )
- return;
-
- std::string fname = dlg.selectedFiles( ).at( 0 ).toStdString( );
- if( this->m_Workspace != NULL )
- delete this->m_Workspace;
- this->m_Workspace = new cpPlugins::Workspace( );
- this->m_Workspace->SetInterface( &( this->m_Interface ) );
- this->m_Workspace->SetMPRViewer( this->m_UI->Viewer );
- std::string err = this->m_Workspace->LoadWorkspace( fname );
- if( err != "" )
- {
- delete this->m_Workspace;
- this->m_Workspace = NULL;
- QMessageBox::critical(
- this,
- QMessageBox::tr( "Error loading workspace" ),
- QMessageBox::tr( err.c_str( ) )
- );
- }
- else
- this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace );
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_ActionSaveWorkspace( )
-{
- if( this->m_Workspace == NULL )
- return;
-
- QFileDialog dlg( this );
- dlg.setFileMode( QFileDialog::AnyFile );
- dlg.setDirectory( "." );
- dlg.setAcceptMode( QFileDialog::AcceptSave );
- dlg.setNameFilter(
- QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" )
- );
- dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) );
- if( !( dlg.exec( ) ) )
- return;
- std::string fname = dlg.selectedFiles( ).at( 0 ).toStdString( );
-
- std::string err = this->m_Workspace->SaveWorkspace( fname );
- if( err != "" )
- QMessageBox::critical(
- this,
- QMessageBox::tr( "Error saving workspace" ),
- QMessageBox::tr( err.c_str( ) )
- );
-}
-
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_ExecFilter( const std::string& filter_name )
-{
- if( this->m_Workspace != NULL )
- {
- // Update filter, if needed
- this->_Block( );
- std::string err = this->m_Workspace->Execute( filter_name );
- this->_UnBlock( );
- if( err != "" )
- QMessageBox::critical(
- this,
- QMessageBox::tr( "Error executing filter" ),
- QMessageBox::tr( err.c_str( ) )
- );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_ShowFilterOutput(
- const std::string& filter_name, const std::string& output_name
- )
-{
- typedef cpPlugins::DataObject _TDataObject;
-
- // Update filter, if needed
- this->_ExecFilter( filter_name );
-
- // Get output
- auto filter = this->m_Workspace->GetFilter( filter_name );
- if( filter != NULL )
- {
- auto output = filter->GetOutputData( output_name );
- if( output != NULL )
- {
- std::string data_name = output_name + "@" + filter_name;
- auto idata = output->GetVTK< vtkImageData >( );
- auto mdata = output->GetVTK< vtkPolyData >( );
- if( idata != NULL )
- {
- if( this->m_UI->Viewer->AddData( idata, data_name, "" ) )
- {
- if( this->m_UI->Viewer->GetNumberOfData( ) > 1 )
- this->m_UI->Viewer->SetDataColor( data_name, 1, 0, 0 );
- else
- this->m_UI->Viewer->SetMainImage( data_name );
- this->_Block( );
- this->m_UI->Viewer->ShowData( data_name );
- this->_UnBlock( );
-
- } // fi
- }
- else if( mdata != NULL )
- {
- }
- else
- QMessageBox::critical(
- this,
- QMessageBox::tr( "Error showing data" ),
- QMessageBox::tr( "No known VTK conversion!" )
- );
-
- /* TODO
- if( this->m_UI->Viewer->AddData( output, data_name, "" ) )
- {
- if( this->m_UI->Viewer->GetNumberOfData( ) > 1 )
- this->m_UI->Viewer->SetDataColor( data_name, 1, 0, 0 );
- else
- this->m_UI->Viewer->SetMainImage( data_name );
- this->m_UI->Viewer->ShowData( data_name );
- }
- else
- */
-
- } // fi
-
- } // fi