]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/ProcessObject.cxx
Machete filter with interactive plane: it now supports images and meshes. Not yet...
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.cxx
index 6f3bd34e3d8e537e47282613974ae73f87548272..7552e5e1dea890027ee644926240d7ccb66a7cb3 100644 (file)
@@ -1,6 +1,7 @@
 #include <cpPlugins/Interface/ProcessObject.h>
 
 #ifdef cpPlugins_Interface_QT4
+#include <QApplication>
 #include <cpPlugins/Interface/ParametersQtDialog.h>
 #endif // cpPlugins_Interface_QT4
 
@@ -17,99 +18,41 @@ 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::
-GetParameters( )
-{
-  return( this->m_Parameters.GetPointer( ) );
-}
-
-// -------------------------------------------------------------------------
-const cpPlugins::Interface::ProcessObject::
-TParameters* cpPlugins::Interface::ProcessObject::
-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
+GetInputsNames( std::set< std::string >& names ) const
 {
-  return( this->m_Inputs.size( ) );
-}
-
-// -------------------------------------------------------------------------
-unsigned int cpPlugins::Interface::ProcessObject::
-GetNumberOfOutputs( ) const
-{
-  return( this->m_Outputs.size( ) );
-}
-
-// -------------------------------------------------------------------------
-std::vector< std::string > cpPlugins::Interface::ProcessObject::
-GetInputsNames( ) const
-{
-  std::vector< std::string > r;
+  names.clear( );
   auto dIt = this->m_Inputs.begin( );
   for( ; dIt != this->m_Inputs.end( ); ++dIt )
-    r.push_back( dIt->first );
-  return( r );
+    names.insert( dIt->first );
 }
 
 // -------------------------------------------------------------------------
-std::vector< std::string > cpPlugins::Interface::ProcessObject::
-GetOutputsNames( ) const
+void cpPlugins::Interface::ProcessObject::
+GetOutputsNames( std::set< std::string >& names ) const
 {
-  std::vector< std::string > r;
+  names.clear( );
   auto dIt = this->m_Outputs.begin( );
   for( ; dIt != this->m_Outputs.end( ); ++dIt )
-    r.push_back( dIt->first );
-  return( r );
+    names.insert( dIt->first );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::ProcessObject::
+SetOutputObjectName(
+  const std::string& new_object_name, const std::string& output_name
+  )
+{
+  auto oIt = this->m_Outputs.find( output_name );
+  if( oIt != this->m_Outputs.end( ) )
+  {
+    this->m_OutputObjectsNames[ output_name ] = new_object_name;
+    this->Modified( );
+    return( true );
+  }
+  else
+    return( false );
 }
 
 // -------------------------------------------------------------------------
@@ -145,6 +88,16 @@ 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 );
 }
@@ -164,8 +117,11 @@ void cpPlugins::Interface::ProcessObject::
 AddInteractor( 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 );
 }
 
 // -------------------------------------------------------------------------
@@ -177,22 +133,33 @@ ExecConfigurationDialog( QWidget* parent )
 
 #ifdef cpPlugins_Interface_QT4
 
-  this->m_ParametersDialog->setParent( NULL );
-  this->m_ParametersDialog->setParameters( this->m_Parameters );
-
-  if( !( this->m_ParametersDialog->IsModal( ) ) )
+  if( QApplication::instance( ) != NULL )
   {
-    this->m_ParametersDialog->show( );
-    r = Self::DialogResult_Modal;
-  }
-  else
-  {
-    if( this->m_ParametersDialog->exec( ) == 1 )
-      r = Self::DialogResult_NoModal;
+    if( this->m_ParametersDialog == NULL )
+      this->m_ParametersDialog = new ParametersQtDialog( );
+    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
-      r = Self::DialogResult_Cancel;
+    {
+      if( this->m_ParametersDialog->exec( ) == 1 )
+        r = Self::DialogResult_NoModal;
+      else
+        r = Self::DialogResult_Cancel;
 
-  } // fi
+    } // fi
+  }
+  else
+    r = Self::DialogResult_Cancel;
 
 #endif // cpPlugins_Interface_QT4
 
@@ -205,22 +172,19 @@ 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( )
 {
-  delete this->m_ParametersDialog;
+  if( this->m_ParametersDialog != NULL )
+    delete this->m_ParametersDialog;
 }
 
 // -------------------------------------------------------------------------
@@ -231,4 +195,7 @@ _AddInput( const std::string& name )
   this->Modified( );
 }
 
+// -------------------------------------------------------------------------
+CPPLUGINS_PROVIDER_SOURCE( cpPlugins::Interface::ProcessObject, 1, 1 );
+
 // eof - $RCSfile$