]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/ProcessObject.cxx
Merge ssh://git.creatis.insa-lyon.fr/cpPlugins
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.cxx
index f832743feb2d5ce57eb43af8f7e1046e8a2550a4..9fb4ea71598e27f46131db062507b84d1709204a 100644 (file)
@@ -4,6 +4,17 @@
 #include <cpPlugins/Interface/ParametersQtDialog.h>
 #endif // cpPlugins_Interface_QT4
 
+// -------------------------------------------------------------------------
+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::
 TParameters* cpPlugins::Interface::ProcessObject::
@@ -36,29 +47,12 @@ GetNumberOfOutputs( ) const
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::ProcessObject::
-SetNumberOfInputs( unsigned int n )
-{
-  this->m_Inputs.clear( );
-  this->m_Inputs.resize( n );
-  this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetNumberOfOutputs( unsigned int n )
+SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj )
 {
-  this->m_Outputs.clear( );
-  this->m_Outputs.resize( n );
-  this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetInput( unsigned int idx, cpPlugins::Interface::DataObject* dobj )
-{
-  if( idx < this->m_Inputs.size( ) )
+  _TDataContainer::iterator i = this->m_Inputs.find( id );
+  if( i != this->m_Inputs.end( ) )
   {
-    this->m_Inputs[ idx ] = dobj;
+    i->second = dobj;
     this->Modified( );
 
   } // fi
@@ -71,9 +65,10 @@ Update( )
   std::string r = "";
 
   // Force upstream updates
-  for( unsigned int i = 0; i < this->m_Inputs.size( ) && r == ""; ++i )
+  _TDataContainer::iterator i = this->m_Inputs.begin( );
+  for( ; i != this->m_Inputs.end( ) && r == ""; ++i )
   {
-    Self* src = dynamic_cast< Self* >( this->m_Inputs[ i ]->GetSource( ) );
+    Self* src = dynamic_cast< Self* >( i->second->GetSource( ) );
     if( src != NULL )
       r = src->Update( );
 
@@ -91,9 +86,10 @@ Update( )
 void cpPlugins::Interface::ProcessObject::
 DisconnectOutputs( )
 {
-  for( unsigned int idx = 0; idx < this->m_Outputs.size( ); ++idx )
-    if( this->m_Outputs[ idx ].IsNotNull( ) )
-      this->m_Outputs[ idx ]->DisconnectPipeline( );
+  _TDataContainer::iterator i = this->m_Outputs.begin( );
+  for( ; i != this->m_Outputs.end( ); ++i )
+    if( i->second.IsNotNull( ) )
+      i->second->DisconnectPipeline( );
 }
 
 // -------------------------------------------------------------------------
@@ -104,15 +100,32 @@ ExecConfigurationDialog( QWidget* parent )
 
 #ifdef cpPlugins_Interface_QT4
 
-  r = cpPlugins::Interface::ParametersQtDialog(
+  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
+    r = ( this->m_ParametersDialog->exec( ) == 1 );
+
+  /*
+    r = cpPlugins::Interface::ParametersQtDialog(
     this->m_Parameters,
     this->GetClassName( ) + std::string( " basic configuration" ),
     parent
     );
-  /*
     if( r )
-    // TODO: !!! this->m_Parameters = parameters;
-    */
+  */
 
 #endif // cpPlugins_Interface_QT4
 
@@ -124,7 +137,8 @@ cpPlugins::Interface::ProcessObject::
 ProcessObject( )
   : Superclass( ),
     m_ITKObject( NULL ),
-    m_VTKObject( NULL )
+    m_VTKObject( NULL ),
+    m_ParametersDialog( NULL )
 {
   this->m_Parameters = TParameters::New( );
 }
@@ -133,6 +147,16 @@ ProcessObject( )
 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( );
 }
 
 // eof - $RCSfile$