]> 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 9fb4ea71598e27f46131db062507b84d1709204a..6f3bd34e3d8e537e47282613974ae73f87548272 100644 (file)
@@ -4,6 +4,8 @@
 #include <cpPlugins/Interface/ParametersQtDialog.h>
 #endif // cpPlugins_Interface_QT4
 
+#include <vtkRenderWindowInteractor.h>
+
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::ProcessObject::
 Modified( ) const
@@ -15,6 +17,26 @@ Modified( ) const
   this->Superclass::Modified( );
 }
 
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::ProcessObject::
+IsInteractive( ) const
+{
+  std::vector< std::string > names;
+  this->m_Parameters->GetNames( names );
+  bool res = false;
+  auto i = names.begin( );
+  for( ; i != names.end( ); ++i )
+  {
+    TParameters::Type t = this->m_Parameters->GetType( *i );
+    res |= ( t == TParameters::Point );
+    res |= ( t == TParameters::Index );
+    res |= ( t == TParameters::PointList );
+    res |= ( t == TParameters::IndexList );
+
+  } // rof
+  return( res );
+}
+
 // -------------------------------------------------------------------------
 cpPlugins::Interface::ProcessObject::
 TParameters* cpPlugins::Interface::ProcessObject::
@@ -31,6 +53,29 @@ GetParameters( ) const
   return( this->m_Parameters.GetPointer( ) );
 }
 
+// -------------------------------------------------------------------------
+cpPlugins::Interface::
+Plugins* cpPlugins::Interface::ProcessObject::
+GetPlugins( )
+{
+  return( this->m_Plugins );
+}
+
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::
+Plugins* cpPlugins::Interface::ProcessObject::
+GetPlugins( ) const
+{
+  return( this->m_Plugins );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ProcessObject::
+SetPlugins( Plugins* p )
+{
+  this->m_Plugins = p;
+}
+
 // -------------------------------------------------------------------------
 unsigned int cpPlugins::Interface::ProcessObject::
 GetNumberOfInputs( ) const
@@ -45,6 +90,28 @@ GetNumberOfOutputs( ) const
   return( this->m_Outputs.size( ) );
 }
 
+// -------------------------------------------------------------------------
+std::vector< std::string > cpPlugins::Interface::ProcessObject::
+GetInputsNames( ) const
+{
+  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 );
+}
+
+// -------------------------------------------------------------------------
+std::vector< std::string > cpPlugins::Interface::ProcessObject::
+GetOutputsNames( ) const
+{
+  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( const std::string& id, cpPlugins::Interface::DataObject* dobj )
@@ -93,39 +160,39 @@ DisconnectOutputs( )
 }
 
 // -------------------------------------------------------------------------
-bool cpPlugins::Interface::ProcessObject::
+void cpPlugins::Interface::ProcessObject::
+AddInteractor( vtkRenderWindowInteractor* interactor )
+{
+#ifdef cpPlugins_Interface_QT4
+  this->m_ParametersDialog->addInteractor( interactor );
+#endif // cpPlugins_Interface_QT4
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObject::
+DialogResult cpPlugins::Interface::ProcessObject::
 ExecConfigurationDialog( QWidget* parent )
 {
-  bool r = false;
+  DialogResult r = Self::DialogResult_Cancel;
 
 #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
+  this->m_ParametersDialog->setParent( NULL );
+  this->m_ParametersDialog->setParameters( this->m_Parameters );
 
   if( !( this->m_ParametersDialog->IsModal( ) ) )
   {
     this->m_ParametersDialog->show( );
-    r = true;
+    r = Self::DialogResult_Modal;
   }
   else
-    r = ( this->m_ParametersDialog->exec( ) == 1 );
+  {
+    if( this->m_ParametersDialog->exec( ) == 1 )
+      r = Self::DialogResult_NoModal;
+    else
+      r = Self::DialogResult_Cancel;
 
-  /*
-    r = cpPlugins::Interface::ParametersQtDialog(
-    this->m_Parameters,
-    this->GetClassName( ) + std::string( " basic configuration" ),
-    parent
-    );
-    if( r )
-  */
+  } // fi
 
 #endif // cpPlugins_Interface_QT4
 
@@ -138,17 +205,22 @@ ProcessObject( )
   : Superclass( ),
     m_ITKObject( NULL ),
     m_VTKObject( NULL ),
-    m_ParametersDialog( NULL )
+    m_Plugins( NULL )
 {
   this->m_Parameters = TParameters::New( );
+  this->m_Parameters->SetProcessObject( this );
+
+  this->m_ParametersDialog = new ParametersQtDialog( );
+  this->m_ParametersDialog->setTitle(
+    this->GetClassName( ) + std::string( " basic configuration" )
+    );
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::ProcessObject::
 ~ProcessObject( )
 {
-  if( this->m_ParametersDialog == NULL )
-    delete this->m_ParametersDialog;
+  delete this->m_ParametersDialog;
 }
 
 // -------------------------------------------------------------------------