]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/ProcessObject.cxx
Merge branch 'master' of ssh://git.creatis.insa-lyon.fr/cpPlugins
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.cxx
index 79fc2ab7f84880c3cdb59bdd002d38e8abc94f34..f639d7f59e3ea2b5686950a48151e98b0d05ef73 100644 (file)
@@ -1,39 +1,34 @@
 #include <cpPlugins/Interface/ProcessObject.h>
-#include <cpPlugins/Interface/DataObject.h>
 
-// -------------------------------------------------------------------------
-cpPlugins::Interface::ProcessObject::
-ProcessObject( )
-  : Superclass( )
-{
-}
+#ifdef cpPlugins_Interface_QT4
+#include <cpPlugins/Interface/ParametersQtDialog.h>
+#endif // cpPlugins_Interface_QT4
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::ProcessObject::
-~ProcessObject( )
+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( );
 }
 
 // -------------------------------------------------------------------------
-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
-{
-  return( this->m_DefaultParameters );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetParameters( const TParameters& params )
+TParameters* cpPlugins::Interface::ProcessObject::
+GetParameters( ) const
 {
-  this->m_Parameters = params;
+  return( this->m_Parameters.GetPointer( ) );
 }
 
 // -------------------------------------------------------------------------
@@ -51,76 +46,139 @@ GetNumberOfOutputs( ) const
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetNumberOfInputs( unsigned int n )
+std::vector< std::string > cpPlugins::Interface::ProcessObject::
+GetInputsNames( ) const
 {
-  this->m_Inputs.clear( );
-  this->m_Inputs.resize( n, NULL );
+  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 );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetNumberOfOutputs( unsigned int n )
+std::vector< std::string > cpPlugins::Interface::ProcessObject::
+GetOutputsNames( ) const
 {
-  this->m_Outputs.clear( );
-  this->m_Outputs.resize( n );
-
-  // Sync outputs with this source
-  for( unsigned int odx = 0; odx < this->m_Outputs.size( ); ++odx )
-    this->m_Outputs[ odx ].SetSource( this );
+  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(
-  unsigned int idx, const cpPlugins::Interface::DataObject* dobj
-  )
+SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj )
 {
-  if( idx < this->m_Inputs.size( ) )
-    this->m_Inputs[ idx ] = dobj;
-}
+  _TDataContainer::iterator i = this->m_Inputs.find( id );
+  if( i != this->m_Inputs.end( ) )
+  {
+    i->second = dobj;
+    this->Modified( );
 
-// -------------------------------------------------------------------------
-cpPlugins::Interface::DataObject* cpPlugins::Interface::ProcessObject::
-GetOutput( unsigned int idx )
-{
-  if( idx < this->m_Outputs.size( ) )
-    return( &( this->m_Outputs[ idx ] ) );
-  else
-    return( NULL );
+  } // 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[ idx ]->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( ret );
+  return( r );
 }
 
 // -------------------------------------------------------------------------
-itk::DataObject* cpPlugins::Interface::ProcessObject::
-_GetInput( unsigned int idx )
+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( );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::ProcessObject::
+ExecConfigurationDialog( QWidget* parent )
 {
-  if( idx < this->m_Inputs.size( ) )
-    return( this->m_Inputs[ idx ]->GetDataObject( ) );
+  bool r = false;
+
+#ifdef cpPlugins_Interface_QT4
+
+  if( this->m_ParametersDialog == NULL )
+  {
+    this->m_ParametersDialog = new ParametersQtDialog( parent );
+    this->m_ParametersDialog->setTitle(
+      this->GetClassName( ) + std::string( " basic configuration" )
+      );
+    this->m_ParametersDialog->setParameters( this->m_Parameters );
+
+  } // fi
+
+  if( !( this->m_ParametersDialog->IsModal( ) ) )
+  {
+    this->m_ParametersDialog->show( );
+    r = true;
+  }
   else
-    return( NULL );
+    r = ( this->m_ParametersDialog->exec( ) == 1 );
+
+  /*
+    r = cpPlugins::Interface::ParametersQtDialog(
+    this->m_Parameters,
+    this->GetClassName( ) + std::string( " basic configuration" ),
+    parent
+    );
+    if( r )
+  */
+
+#endif // cpPlugins_Interface_QT4
+
+  return( r );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObject::
+ProcessObject( )
+  : Superclass( ),
+    m_ITKObject( NULL ),
+    m_VTKObject( NULL ),
+    m_ParametersDialog( NULL )
+{
+  this->m_Parameters = TParameters::New( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObject::
+~ProcessObject( )
+{
+  if( this->m_ParametersDialog == NULL )
+    delete this->m_ParametersDialog;
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::ProcessObject::
-_SetOutput( unsigned int idx, itk::DataObject* dobj )
+_AddInput( const std::string& name )
 {
-  if( idx < this->m_Outputs.size( ) )
-    this->m_Outputs[ idx ].SetDataObject( dobj );
+  this->m_Inputs[ name ] = NULL;
+  this->Modified( );
 }
 
 // eof - $RCSfile$