]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/ProcessObject.cxx
...
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.cxx
index b2b9337d1ea8ccb07ee17bc1a392d7fc12070d9b..5434319fb09c1d9e7a8b47169e15185d83cda862 100644 (file)
@@ -1,23 +1,33 @@
 #include <cpPlugins/Interface/ProcessObject.h>
 
 #ifdef cpPlugins_Interface_QT4
+#include <QApplication>
 #include <cpPlugins/Interface/ParametersQtDialog.h>
+#include <cpPlugins/Interface/SimpleMPRWidget.h>
 #endif // cpPlugins_Interface_QT4
 
+#include <vtkRenderWindowInteractor.h>
+
 // -------------------------------------------------------------------------
-const cpPlugins::Interface::Parameters&
-cpPlugins::Interface::ProcessObject::
-GetDefaultParameters( ) const
+std::set< std::string > cpPlugins::Interface::ProcessObject::
+GetInputsNames( ) const
 {
-  return( this->m_DefaultParameters );
+  std::set< std::string > names;
+  auto dIt = this->m_Inputs.begin( );
+  for( ; dIt != this->m_Inputs.end( ); ++dIt )
+    names.insert( dIt->first );
+  return( names );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetParameters( const cpPlugins::Interface::Parameters& params )
+std::set< std::string > cpPlugins::Interface::ProcessObject::
+GetOutputsNames( ) const
 {
-  this->m_Parameters = params;
-  this->Modified( );
+  std::set< std::string > names;
+  auto dIt = this->m_Outputs.begin( );
+  for( ; dIt != this->m_Outputs.end( ); ++dIt )
+    names.insert( dIt->first );
+  return( names );
 }
 
 // -------------------------------------------------------------------------
@@ -35,33 +45,20 @@ 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 )
-{
-  this->m_Outputs.clear( );
-  this->m_Outputs.resize( n );
-  this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetInput( unsigned int idx, cpPlugins::Interface::DataObject* dobj )
+bool cpPlugins::Interface::ProcessObject::
+SetInput(
+  const std::string& id, cpPlugins::Interface::DataObject::Pointer* 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
+    return( true );
+  }
+  else
+    return( false );
 }
 
 // -------------------------------------------------------------------------
@@ -71,12 +68,18 @@ 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( ) );
-    if( src != NULL )
-      r = src->Update( );
-
+    if( i->second->IsNotNull( ) )
+    {
+      Self* src = dynamic_cast< Self* >( ( *( i->second ) )->GetSource( ) );
+      if( src != NULL )
+        r = src->Update( );
+    }
+    else
+      r = "cpPlugins::Interface::ProcessObject: No input connected.";
+    
   } // rof
 
   // Current update
@@ -91,9 +94,54 @@ 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( );
+}
+
+// -------------------------------------------------------------------------
+vtkRenderWindowInteractor* cpPlugins::Interface::ProcessObject::
+GetSingleInteractor( )
+{
+  return( this->m_SingleInteractor );
+}
+
+// -------------------------------------------------------------------------
+const vtkRenderWindowInteractor* cpPlugins::Interface::ProcessObject::
+GetSingleInteractor( ) const
+{
+  return( this->m_SingleInteractor );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ProcessObject::
+SetSingleInteractor( vtkRenderWindowInteractor* interactor )
+{
+  this->m_SingleInteractor = interactor;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::
+SimpleMPRWidget* cpPlugins::Interface::ProcessObject::
+GetMPRViewer( )
+{
+  return( this->m_MPRViewer );
+}
+
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::
+SimpleMPRWidget* cpPlugins::Interface::ProcessObject::
+GetMPRViewer( ) const
+{
+  return( this->m_MPRViewer );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ProcessObject::
+SetMPRViewer( cpPlugins::Interface::SimpleMPRWidget* wdg )
+{
+  this->m_MPRViewer = wdg;
 }
 
 // -------------------------------------------------------------------------
@@ -101,20 +149,16 @@ bool cpPlugins::Interface::ProcessObject::
 ExecConfigurationDialog( QWidget* parent )
 {
   bool r = false;
-
 #ifdef cpPlugins_Interface_QT4
-
-  Parameters parameters = this->m_DefaultParameters;
-  r = cpPlugins::Interface::ParametersQtDialog(
-    parameters,
-    this->GetClassName( ) + std::string( " basic configuration" ),
-    parent
-    );
-  if( r )
-    this->m_Parameters = parameters;
-
+  if( this->m_ParametersDialog != NULL )
+  {
+    this->m_ParametersDialog->setParent( NULL );
+    this->m_ParametersDialog->setParameters( this->m_Parameters );
+    r = ( this->m_ParametersDialog->exec( ) == 1 );
+  }
+  else
+    r = false;
 #endif // cpPlugins_Interface_QT4
-
   return( r );
 }
 
@@ -122,15 +166,51 @@ ExecConfigurationDialog( QWidget* parent )
 cpPlugins::Interface::ProcessObject::
 ProcessObject( )
   : Superclass( ),
-    m_ITKObject( NULL ),
-    m_VTKObject( NULL )
+    m_ParametersDialog( NULL ),
+    m_MPRViewer( NULL )
 {
+  this->m_Parameters = TParameters::New( );
+  this->m_Parameters->SetProcessObject( this );
+
+#ifdef cpPlugins_Interface_QT4
+  if( QApplication::instance( ) != NULL )
+    this->m_ParametersDialog = new ParametersQtDialog( );
+#endif // cpPlugins_Interface_QT4
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::ProcessObject::
 ~ProcessObject( )
 {
+#ifdef cpPlugins_Interface_QT4
+  if( this->m_ParametersDialog != NULL )
+    delete this->m_ParametersDialog;
+#endif // cpPlugins_Interface_QT4
+
+  /*
+    auto iIt = this->m_Inputs.begin( );
+    for( ; iIt != this->m_Inputs.end( ); ++iIt )
+    delete iIt->second;
+    this->m_Inputs.clear( );
+  */
+
+  auto oIt = this->m_Outputs.begin( );
+  for( ; oIt != this->m_Outputs.end( ); ++oIt )
+    delete oIt->second;
+  this->m_Outputs.clear( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ProcessObject::
+_AddInput( const std::string& name )
+{
+  auto i = this->m_Inputs.find( name );
+  if( i == this->m_Inputs.end( ) )
+  {
+    this->m_Inputs[ name ] = NULL;
+    this->Modified( );
+
+  } // fi
 }
 
 // eof - $RCSfile$