#include #ifdef cpPlugins_Interface_QT4 #include #include #endif // cpPlugins_Interface_QT4 #include // ------------------------------------------------------------------------- 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( ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: GetInputsNames( std::set< std::string >& names ) const { names.clear( ); auto dIt = this->m_Inputs.begin( ); for( ; dIt != this->m_Inputs.end( ); ++dIt ) names.insert( dIt->first ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: GetOutputsNames( std::set< std::string >& names ) const { names.clear( ); auto dIt = this->m_Outputs.begin( ); for( ; dIt != this->m_Outputs.end( ); ++dIt ) names.insert( dIt->first ); } // ------------------------------------------------------------------------- bool cpPlugins::Interface::ProcessObject:: SetOutputObjectName( const std::string& new_object_name, const std::string& output_name ) { auto oIt = this->m_Outputs.find( output_name ); if( oIt != this->m_Outputs.end( ) ) { this->m_OutputObjectsNames[ output_name ] = new_object_name; this->Modified( ); return( true ); } else return( false ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj ) { _TDataContainer::iterator i = this->m_Inputs.find( id ); if( i != this->m_Inputs.end( ) ) { i->second = dobj; this->Modified( ); } // fi } // ------------------------------------------------------------------------- std::string cpPlugins::Interface::ProcessObject:: Update( ) { std::string r = ""; // Force upstream updates _TDataContainer::iterator i = this->m_Inputs.begin( ); for( ; i != this->m_Inputs.end( ) && r == ""; ++i ) { Self* src = dynamic_cast< Self* >( i->second->GetSource( ) ); if( src != NULL ) r = src->Update( ); } // rof // Current update if( r == "" ) r = this->_GenerateData( ); // Configure output names auto oIt = this->m_Outputs.begin( ); for( ; oIt != this->m_Outputs.end( ); ++oIt ) { auto nIt = this->m_OutputObjectsNames.find( oIt->first ); if( nIt != this->m_OutputObjectsNames.end( ) ) oIt->second->SetName( nIt->second ); } // rof // Return error description, if any return( r ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: DisconnectOutputs( ) { _TDataContainer::iterator i = this->m_Outputs.begin( ); for( ; i != this->m_Outputs.end( ); ++i ) if( i->second.IsNotNull( ) ) i->second->DisconnectPipeline( ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: AddInteractor( vtkRenderWindowInteractor* interactor ) { #ifdef cpPlugins_Interface_QT4 if( this->m_ParametersDialog == NULL ) this->m_ParametersDialog = new ParametersQtDialog( ); this->m_ParametersDialog->addInteractor( interactor ); #endif // cpPlugins_Interface_QT4 this->m_Interactors.insert( interactor ); } // ------------------------------------------------------------------------- cpPlugins::Interface::ProcessObject:: DialogResult cpPlugins::Interface::ProcessObject:: ExecConfigurationDialog( QWidget* parent ) { DialogResult r = Self::DialogResult_Cancel; #ifdef cpPlugins_Interface_QT4 if( QApplication::instance( ) != NULL ) { if( this->m_ParametersDialog == NULL ) this->m_ParametersDialog = new ParametersQtDialog( ); this->m_ParametersDialog->setTitle( this->GetClassName( ) + std::string( " basic configuration" ) ); this->m_ParametersDialog->setParent( NULL ); this->m_ParametersDialog->setParameters( this->m_Parameters ); if( !( this->m_ParametersDialog->IsModal( ) ) ) { this->m_ParametersDialog->show( ); r = Self::DialogResult_Modal; } else { if( this->m_ParametersDialog->exec( ) == 1 ) r = Self::DialogResult_NoModal; else r = Self::DialogResult_Cancel; } // fi } else r = Self::DialogResult_Cancel; #endif // cpPlugins_Interface_QT4 return( r ); } // ------------------------------------------------------------------------- cpPlugins::Interface::ProcessObject:: ProcessObject( ) : Superclass( ), m_ITKObject( NULL ), m_VTKObject( NULL ), m_ParametersDialog( NULL ), m_Plugins( NULL ) { this->m_Parameters = TParameters::New( ); this->m_Parameters->SetProcessObject( this ); } // ------------------------------------------------------------------------- cpPlugins::Interface::ProcessObject:: ~ProcessObject( ) { if( this->m_ParametersDialog != NULL ) delete this->m_ParametersDialog; } // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: _AddInput( const std::string& name ) { this->m_Inputs[ name ] = NULL; this->Modified( ); } // ------------------------------------------------------------------------- CPPLUGINS_PROVIDER_SOURCE( cpPlugins::Interface::ProcessObject, 1, 1 ); // eof - $RCSfile$