]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/ProcessObject.cxx
...
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.cxx
index fc010b81fac56ee6579e88beb9c4b838261eed36..5434319fb09c1d9e7a8b47169e15185d83cda862 100644 (file)
@@ -3,39 +3,31 @@
 #ifdef cpPlugins_Interface_QT4
 #include <QApplication>
 #include <cpPlugins/Interface/ParametersQtDialog.h>
+#include <cpPlugins/Interface/SimpleMPRWidget.h>
 #endif // cpPlugins_Interface_QT4
 
 #include <vtkRenderWindowInteractor.h>
 
 // -------------------------------------------------------------------------
-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( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-GetInputsNames( std::set< std::string >& names ) const
+std::set< std::string > cpPlugins::Interface::ProcessObject::
+GetInputsNames( ) const
 {
-  names.clear( );
+  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::
-GetOutputsNames( std::set< std::string >& names ) const
+std::set< std::string > cpPlugins::Interface::ProcessObject::
+GetOutputsNames( ) const
 {
-  names.clear( );
+  std::set< std::string > names;
   auto dIt = this->m_Outputs.begin( );
   for( ; dIt != this->m_Outputs.end( ); ++dIt )
     names.insert( dIt->first );
+  return( names );
 }
 
 // -------------------------------------------------------------------------
@@ -54,14 +46,14 @@ GetNumberOfOutputs( ) const
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::ProcessObject::
-SetOutputObjectName(
-  const std::string& new_object_name, const std::string& output_name
+SetInput(
+  const std::string& id, cpPlugins::Interface::DataObject::Pointer* dobj
   )
 {
-  auto oIt = this->m_Outputs.find( output_name );
-  if( oIt != this->m_Outputs.end( ) )
+  _TDataContainer::iterator i = this->m_Inputs.find( id );
+  if( i != this->m_Inputs.end( ) )
   {
-    this->m_OutputObjectsNames[ output_name ] = new_object_name;
+    i->second = dobj;
     this->Modified( );
     return( true );
   }
@@ -69,19 +61,6 @@ SetOutputObjectName(
     return( false );
 }
 
-// -------------------------------------------------------------------------
-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( )
@@ -92,9 +71,9 @@ Update( )
   _TDataContainer::iterator i = this->m_Inputs.begin( );
   for( ; i != this->m_Inputs.end( ) && r == ""; ++i )
   {
-    if( i->second.IsNotNull( ) )
+    if( i->second->IsNotNull( ) )
     {
-      Self* src = dynamic_cast< Self* >( i->second->GetSource( ) );
+      Self* src = dynamic_cast< Self* >( ( *( i->second ) )->GetSource( ) );
       if( src != NULL )
         r = src->Update( );
     }
@@ -107,16 +86,6 @@ Update( )
   if( r == "" )
     r = this->_GenerateData( );
 
-  // Configure output names
-  auto oIt = this->m_Outputs.begin( );
-  for( ; oIt != this->m_Outputs.end( ); ++oIt )
-  {
-    auto nIt = this->m_OutputObjectsNames.find( oIt->first );
-    if( nIt != this->m_OutputObjectsNames.end( ) )
-      oIt->second->SetName( nIt->second );
-
-  } // rof
-
   // Return error description, if any
   return( r );
 }
@@ -127,63 +96,69 @@ DisconnectOutputs( )
 {
   _TDataContainer::iterator i = this->m_Outputs.begin( );
   for( ; i != this->m_Outputs.end( ); ++i )
-    if( i->second.IsNotNull( ) )
-      i->second->DisconnectPipeline( );
+    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::
-AddInteractor( vtkRenderWindowInteractor* interactor )
+SetSingleInteractor( vtkRenderWindowInteractor* interactor )
 {
-#ifdef cpPlugins_Interface_QT4
-  if( this->m_ParametersDialog == NULL )
-    this->m_ParametersDialog = new ParametersQtDialog( );
-  this->m_ParametersDialog->addInteractor( interactor );
-#endif // cpPlugins_Interface_QT4
-  this->m_Interactors.insert( interactor );
+  this->m_SingleInteractor = interactor;
 }
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::ProcessObject::
-DialogResult cpPlugins::Interface::ProcessObject::
-ExecConfigurationDialog( QWidget* parent )
+cpPlugins::Interface::
+SimpleMPRWidget* cpPlugins::Interface::ProcessObject::
+GetMPRViewer( )
+{
+  return( this->m_MPRViewer );
+}
+
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::
+SimpleMPRWidget* cpPlugins::Interface::ProcessObject::
+GetMPRViewer( ) const
 {
-  DialogResult r = Self::DialogResult_Cancel;
+  return( this->m_MPRViewer );
+}
 
-#ifdef cpPlugins_Interface_QT4
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ProcessObject::
+SetMPRViewer( cpPlugins::Interface::SimpleMPRWidget* wdg )
+{
+  this->m_MPRViewer = wdg;
+}
 
-  if( QApplication::instance( ) != NULL )
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::ProcessObject::
+ExecConfigurationDialog( QWidget* parent )
+{
+  bool r = false;
+#ifdef cpPlugins_Interface_QT4
+  if( this->m_ParametersDialog != NULL )
   {
-    if( this->m_ParametersDialog == NULL )
-      this->m_ParametersDialog = new ParametersQtDialog( );
-    /* TODO
-       this->m_ParametersDialog->setTitle(
-       this->GetClassName( ) + std::string( " basic configuration" )
-       );
-    */
-
     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
+    r = ( this->m_ParametersDialog->exec( ) == 1 );
   }
   else
-    r = Self::DialogResult_Cancel;
-
+    r = false;
 #endif // cpPlugins_Interface_QT4
-
   return( r );
 }
 
@@ -191,32 +166,51 @@ ExecConfigurationDialog( QWidget* parent )
 cpPlugins::Interface::ProcessObject::
 ProcessObject( )
   : Superclass( ),
-    m_ITKObject( NULL ),
-    m_VTKObject( NULL ),
     m_ParametersDialog( NULL ),
-    m_Plugins( 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 )
 {
-  this->m_Inputs[ name ] = NULL;
-  this->Modified( );
-}
+  auto i = this->m_Inputs.find( name );
+  if( i == this->m_Inputs.end( ) )
+  {
+    this->m_Inputs[ name ] = NULL;
+    this->Modified( );
 
-// -------------------------------------------------------------------------
-CPPLUGINS_PROVIDER_SOURCE( cpPlugins::Interface::ProcessObject, 1, 1 );
+  } // fi
+}
 
 // eof - $RCSfile$