]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/ProcessObject.cxx
merge async example
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.cxx
index c6271ca6635e1f3421669be85ddc46dfb050baf3..ae4a1d3e4b2cf793c8eeab4ac1255691dbb589fd 100644 (file)
@@ -1,19 +1,34 @@
 #include <cpPlugins/Interface/ProcessObject.h>
 
+#ifdef cpPlugins_Interface_QT4
+#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( );
+}
+
 // -------------------------------------------------------------------------
-const cpPlugins::Interface::Parameters&
 cpPlugins::Interface::ProcessObject::
-GetDefaultParameters( ) const
+TParameters* cpPlugins::Interface::ProcessObject::
+GetParameters( )
 {
-  return( this->m_DefaultParameters );
+  return( this->m_Parameters.GetPointer( ) );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetParameters( const cpPlugins::Interface::Parameters& params )
+const cpPlugins::Interface::ProcessObject::
+TParameters* cpPlugins::Interface::ProcessObject::
+GetParameters( ) const
 {
-  this->m_Parameters = params;
-  this->Modified( );
+  return( this->m_Parameters.GetPointer( ) );
 }
 
 // -------------------------------------------------------------------------
@@ -32,44 +47,17 @@ GetNumberOfOutputs( ) const
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::ProcessObject::
-SetNumberOfInputs( unsigned int n )
+SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj )
 {
-  this->m_Inputs.clear( );
-  this->m_Inputs.resize( n );
-  this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetNumberOfOutputs( unsigned int n )
-{
-  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
 }
 
-// -------------------------------------------------------------------------
-cpPlugins::Interface::DataObject* cpPlugins::Interface::ProcessObject::
-GetOutput( unsigned int idx )
-{
-  if( idx < this->m_Outputs.size( ) )
-    return( this->m_Outputs[ idx ] );
-  else
-    return( NULL );
-}
-
 // -------------------------------------------------------------------------
 std::string cpPlugins::Interface::ProcessObject::
 Update( )
@@ -77,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( );
 
@@ -97,18 +86,43 @@ 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( );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::ProcessObject::
+ExecConfigurationDialog( QWidget* parent )
+{
+  bool r = false;
+
+#ifdef cpPlugins_Interface_QT4
+
+  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
+
+  return( r );
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::ProcessObject::
 ProcessObject( )
-  : Superclass( )
+  : Superclass( ),
+    m_ITKObject( NULL ),
+    m_VTKObject( NULL )
 {
-  this->m_ClassName = "cpPlugins::Interface::ProcessObject";
-  this->m_ClassCategory = "BasicObject";
+  this->m_Parameters = TParameters::New( );
 }
 
 // -------------------------------------------------------------------------
@@ -118,24 +132,11 @@ cpPlugins::Interface::ProcessObject::
 }
 
 // -------------------------------------------------------------------------
-/* TODO
-   itk::DataObject* cpPlugins::Interface::ProcessObject::
-   _GetInput( unsigned int idx )
-   {
-   if( idx < this->m_Inputs.size( ) )
-   return( this->m_Inputs[ idx ]->GetRealDataObject( ) );
-   else
-   return( NULL );
-   }
-
-   // -------------------------------------------------------------------------
-   void cpPlugins::Interface::ProcessObject::
-   _SetOutput( unsigned int idx, itk::DataObject* dobj )
-   {
-   if( idx < this->m_Outputs.size( ) )
-   if( this->m_Outputs[ idx ].IsNotNull( ) )
-   this->m_Outputs[ idx ]->SetRealDataObject( dobj );
-   }
-*/
+void cpPlugins::Interface::ProcessObject::
+_AddInput( const std::string& name )
+{
+  this->m_Inputs[ name ] = NULL;
+  this->Modified( );
+}
 
 // eof - $RCSfile$