#include <cpPlugins/Interface/ProcessObject.h>
+#ifdef cpPlugins_Interface_QT4
+#include <cpPlugins/Interface/ParametersQtDialog.h>
+#endif // cpPlugins_Interface_QT4
+
+#include <vtkRenderWindowInteractor.h>
+
// -------------------------------------------------------------------------
-cpPlugins::Interface::ProcessObject::
-ProcessObject( )
- : Superclass( )
+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( );
}
// -------------------------------------------------------------------------
-cpPlugins::Interface::ProcessObject::
-~ProcessObject( )
+bool cpPlugins::Interface::ProcessObject::
+IsInteractive( ) const
{
+ std::vector< std::string > names;
+ this->m_Parameters->GetNames( names );
+ bool res = false;
+ auto i = names.begin( );
+ for( ; i != names.end( ); ++i )
+ {
+ TParameters::Type t = this->m_Parameters->GetType( *i );
+ res |= ( t == TParameters::Point );
+ res |= ( t == TParameters::Index );
+ res |= ( t == TParameters::PointList );
+ res |= ( t == TParameters::IndexList );
+
+ } // rof
+ return( res );
}
// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::ProcessObject::
-GetClassName( ) const
+cpPlugins::Interface::ProcessObject::
+TParameters* cpPlugins::Interface::ProcessObject::
+GetParameters( )
{
- return( "cpPlugins::Interface::ProcessObject" );
+ return( this->m_Parameters.GetPointer( ) );
}
// -------------------------------------------------------------------------
const cpPlugins::Interface::ProcessObject::
-TParameters& cpPlugins::Interface::ProcessObject::
-GetDefaultParameters( ) const
+TParameters* cpPlugins::Interface::ProcessObject::
+GetParameters( ) const
+{
+ return( this->m_Parameters.GetPointer( ) );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::
+Plugins* cpPlugins::Interface::ProcessObject::
+GetPlugins( )
{
- return( this->m_DefaultParameters );
+ return( this->m_Plugins );
+}
+
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::
+Plugins* cpPlugins::Interface::ProcessObject::
+GetPlugins( ) const
+{
+ return( this->m_Plugins );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::ProcessObject::
-SetParameters( const TParameters& params )
+SetPlugins( Plugins* p )
{
- this->m_Parameters = params;
+ this->m_Plugins = p;
}
// -------------------------------------------------------------------------
}
// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetInput(
- unsigned int idx, const cpPlugins::Interface::DataObject* dobj
- )
+std::vector< std::string > cpPlugins::Interface::ProcessObject::
+GetInputsNames( ) const
{
- if( idx < this->m_Inputs.size( ) )
- this->m_Inputs[ idx ] = dobj;
+ std::vector< std::string > r;
+ auto dIt = this->m_Inputs.begin( );
+ for( ; dIt != this->m_Inputs.end( ); ++dIt )
+ r.push_back( dIt->first );
+ return( r );
}
// -------------------------------------------------------------------------
-cpPlugins::Interface::DataObject* cpPlugins::Interface::ProcessObject::
-GetOutput( unsigned int idx ) const
+std::vector< std::string > cpPlugins::Interface::ProcessObject::
+GetOutputsNames( ) const
{
- if( idx < this->m_Outputs.size( ) )
- return( this->m_Outputs[ idx ] );
- else
- return( NULL );
+ std::vector< std::string > r;
+ auto dIt = this->m_Outputs.begin( );
+ for( ; dIt != this->m_Outputs.end( ); ++dIt )
+ r.push_back( dIt->first );
+ return( r );
+}
+
+// -------------------------------------------------------------------------
+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
- for( unsigned int idx = 0; idx < this->m_Inputs.size( ); ++idx )
- this->m_Inputs->GetSource( )->Update( );
+ _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
- std::string ret = this->_GenerateData( );
+ if( r == "" )
+ r = this->_GenerateData( );
+
+ // 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( );
+}
- // Sync outputs
- for( unsigned int odx = 0; odx < this->m_Outputs.size( ); ++odx )
- this->m_Outputs->SetSource( this );
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ProcessObject::
+AddInteractor( vtkRenderWindowInteractor* interactor )
+{
+#ifdef cpPlugins_Interface_QT4
+ this->m_ParametersDialog->addInteractor( interactor );
+#endif // cpPlugins_Interface_QT4
+}
- return( ret );
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObject::
+DialogResult cpPlugins::Interface::ProcessObject::
+ExecConfigurationDialog( QWidget* parent )
+{
+ DialogResult r = Self::DialogResult_Cancel;
+
+#ifdef cpPlugins_Interface_QT4
+
+ 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
+
+#endif // cpPlugins_Interface_QT4
+
+ return( r );
}
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObject::
+ProcessObject( )
+ : Superclass( ),
+ m_ITKObject( NULL ),
+ m_VTKObject( NULL ),
+ m_Plugins( NULL )
+{
+ this->m_Parameters = TParameters::New( );
+ this->m_Parameters->SetProcessObject( this );
+
+ this->m_ParametersDialog = new ParametersQtDialog( );
+ this->m_ParametersDialog->setTitle(
+ this->GetClassName( ) + std::string( " basic configuration" )
+ );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObject::
+~ProcessObject( )
+{
+ delete this->m_ParametersDialog;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ProcessObject::
+_AddInput( const std::string& name )
+{
+ this->m_Inputs[ name ] = NULL;
+ this->Modified( );
+}
// eof - $RCSfile$