]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 29 Jan 2016 23:09:22 +0000 (18:09 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 29 Jan 2016 23:09:22 +0000 (18:09 -0500)
15 files changed:
appli/examples/CMakeLists.txt
appli/examples/example_SphereSource.cxx [new file with mode: 0644]
lib/cpPipelineEditor/Block.cxx
lib/cpPlugins/Interface/ProcessObject.cxx
lib/cpPlugins/Interface/ProcessObject.h
lib/cpPlugins/Interface/ProcessObject.hxx
lib/cpPlugins/Interface/ProcessObjectPort.cxx [new file with mode: 0644]
lib/cpPlugins/Interface/ProcessObjectPort.h [new file with mode: 0644]
lib/cpPlugins/Interface/Workspace.cxx
lib/cpPlugins/Interface/Workspace.h
lib/cpPlugins/Plugins/BasicFilters/InputDataReproducer.cxx
lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx
lib/cpPlugins/Plugins/IO/DicomSeriesReader.cxx
lib/cpPlugins/Plugins/IO/DicomSeriesReader.h
lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx

index b6161de48119ba393d50c6b0a61db251418f0563..ad1e23c0a4f3bb6b8efb941c34a4f5afe8bee0b2 100644 (file)
@@ -27,6 +27,7 @@ ENDFOREACH(prog)
 
 SET(
   EXAMPLES_PROGRAMS_WITH_PLUGINS
+  example_SphereSource
   #example_ReadWriteImage
   #example_MarchingCubes
   #example_MPR
diff --git a/appli/examples/example_SphereSource.cxx b/appli/examples/example_SphereSource.cxx
new file mode 100644 (file)
index 0000000..75e99a3
--- /dev/null
@@ -0,0 +1,54 @@
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+#include <cpPlugins/Interface/Interface.h>
+#include <cpPlugins/Interface/ProcessObject.h>
+
+// -------------------------------------------------------------------------
+typedef cpPlugins::Interface::Interface     TInterface;
+typedef cpPlugins::Interface::ProcessObject TFilter;
+
+// -------------------------------------------------------------------------
+int main( int argc, char* argv[] )
+{
+  if( argc < 6 )
+  {
+    std::cerr
+      << "Usage: " << argv[ 0 ]
+      << " plugins_dir"
+      << " radius phi_res theta_res output_mesh" << std::endl;
+    return( 1 );
+
+  } // fi
+
+  // Create interface and load plugins
+  TInterface interface;
+  if( interface.LoadFromFolder( argv[ 1 ], true ) )
+  {
+    TFilter::Pointer source =
+      interface.CreateObject( "cpPlugins::BasicFilters::SphereMeshSource" );
+    TFilter::Pointer writer =
+      interface.CreateObject( "cpPlugins::IO::MeshWriter" );
+
+    // Configure source
+    source->GetParameters( )->SetString( "Radius", argv[ 2 ], true );
+    source->GetParameters( )->SetString( "PhiResolution", argv[ 3 ], true );
+    source->GetParameters( )->SetString( "ThetaResolution", argv[ 4 ], true );
+
+    // Configure writer
+    writer->GetParameters( )->SetString( "FileName", argv[ 5 ], true );
+
+    // Connect filters
+    writer->SetInput( "Input", source->GetOutput( "Output" ) );
+
+    // Execute pipeline
+    std::cout << "Error: \"" << writer->Update( ) << "\"" << std::endl;
+  }
+  else
+    std::cerr << "No plugins found." << std::endl;
+
+  return( 0 );
+}
+
+// eof - $RCSfile$
index 0cc3bd4c84c59a3268248acd54147d25bd0735b0..61938a7b9073545cb81db9700d7bb3af9a3318c5 100644 (file)
@@ -9,6 +9,8 @@
 #include <QStyleOptionGraphicsItem>\r
 #include <QGraphicsWidget>\r
 \r
+#include <cpPlugins/Interface/ParametersQtDialog.h>\r
+\r
 #include "Port.h"\r
 #include "Connection.h"\r
 #include "Editor.h"\r
@@ -285,7 +287,7 @@ contextMenuEvent( QGraphicsSceneContextMenuEvent* evt )
   QAction* selectedAction = menu.exec( evt->screenPos( ) );\r
 \r
   if( selectedAction == configureAction )\r
-    auto res = this->m_Filter->ExecConfigurationDialog( NULL );\r
+    this->m_Filter->GetParametersDialog( )->exec( );\r
   else if( selectedAction == updateAction )\r
     this->m_Editor->updateFilter( this->namePort( ).toStdString( ) );\r
 }\r
index 5434319fb09c1d9e7a8b47169e15185d83cda862..1128fe10444ab89c454748101ccfeec30da93e27 100644 (file)
@@ -1,4 +1,5 @@
 #include <cpPlugins/Interface/ProcessObject.h>
+#include <itkProcessObject.h>
 
 #ifdef cpPlugins_Interface_QT4
 #include <QApplication>
@@ -6,16 +7,13 @@
 #include <cpPlugins/Interface/SimpleMPRWidget.h>
 #endif // cpPlugins_Interface_QT4
 
-#include <vtkRenderWindowInteractor.h>
-
 // -------------------------------------------------------------------------
 std::set< std::string > cpPlugins::Interface::ProcessObject::
 GetInputsNames( ) const
 {
   std::set< std::string > names;
-  auto dIt = this->m_Inputs.begin( );
-  for( ; dIt != this->m_Inputs.end( ); ++dIt )
-    names.insert( dIt->first );
+  for( auto i = this->m_Inputs.begin( ); i != this->m_Inputs.end( ); ++i )
+    names.insert( i->first );
   return( names );
 }
 
@@ -24,9 +22,8 @@ std::set< std::string > cpPlugins::Interface::ProcessObject::
 GetOutputsNames( ) const
 {
   std::set< std::string > names;
-  auto dIt = this->m_Outputs.begin( );
-  for( ; dIt != this->m_Outputs.end( ); ++dIt )
-    names.insert( dIt->first );
+  for( auto i = this->m_Outputs.begin( ); i != this->m_Outputs.end( ); ++i )
+    names.insert( i->first );
   return( names );
 }
 
@@ -44,16 +41,43 @@ GetNumberOfOutputs( ) const
   return( this->m_Outputs.size( ) );
 }
 
+// -------------------------------------------------------------------------
+cpPlugins::Interface::
+ProcessObjectPort& cpPlugins::Interface::ProcessObject::
+GetOutput( const std::string& id )
+{
+  static ProcessObjectPort null_port;
+  auto i = this->m_Outputs.find( id );
+  if( i == this->m_Outputs.end( ) )
+  {
+    null_port = NULL;
+    return( null_port );
+  }
+  else
+    return( i->second );
+}
+
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::
+ProcessObjectPort& cpPlugins::Interface::ProcessObject::
+GetOutput( const std::string& id ) const
+{
+  static const ProcessObjectPort null_port;
+  auto i = this->m_Outputs.find( id );
+  if( i == this->m_Outputs.end( ) )
+    return( null_port );
+  else
+    return( i->second );
+}
+
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::ProcessObject::
-SetInput(
-  const std::string& id, cpPlugins::Interface::DataObject::Pointer* dobj
-  )
+SetInput( const std::string& id, const ProcessObjectPort& port )
 {
-  _TDataContainer::iterator i = this->m_Inputs.find( id );
+  auto i = this->m_Inputs.find( id );
   if( i != this->m_Inputs.end( ) )
   {
-    i->second = dobj;
+    i->second = port;
     this->Modified( );
     return( true );
   }
@@ -62,103 +86,92 @@ SetInput(
 }
 
 // -------------------------------------------------------------------------
-std::string cpPlugins::Interface::ProcessObject::
-Update( )
+void cpPlugins::Interface::ProcessObject::
+DisconnectInputs( )
 {
-  std::string r = "";
-
-  // Force upstream updates
-  _TDataContainer::iterator i = this->m_Inputs.begin( );
-  for( ; i != this->m_Inputs.end( ) && r == ""; ++i )
-  {
-    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
-  if( r == "" )
-    r = this->_GenerateData( );
-
-  // Return error description, if any
-  return( r );
+  auto i = this->m_Inputs.begin( );
+  for( ; i != this->m_Inputs.end( ); ++i )
+    i->second = NULL;
+  this->Modified( );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::ProcessObject::
 DisconnectOutputs( )
 {
-  _TDataContainer::iterator i = this->m_Outputs.begin( );
+  auto i = this->m_Outputs.begin( );
   for( ; i != this->m_Outputs.end( ); ++i )
-    if( i->second->IsNotNull( ) )
-      ( *( i->second ) )->DisconnectPipeline( );
+    if( i->second.IsValid( ) )
+      i->second->DisconnectPipeline( );
+  this->Modified( );
 }
 
 // -------------------------------------------------------------------------
-vtkRenderWindowInteractor* cpPlugins::Interface::ProcessObject::
-GetSingleInteractor( )
+void cpPlugins::Interface::ProcessObject::
+Disconnect( )
 {
-  return( this->m_SingleInteractor );
+  this->DisconnectInputs( );
+  this->DisconnectOutputs( );
 }
 
 // -------------------------------------------------------------------------
-const vtkRenderWindowInteractor* cpPlugins::Interface::ProcessObject::
-GetSingleInteractor( ) const
+itk::ModifiedTimeType cpPlugins::Interface::ProcessObject::
+GetMTime( ) const
 {
-  return( this->m_SingleInteractor );
+  auto params_time = this->m_Parameters->GetMTime( );
+  auto filter_time = this->Superclass::GetMTime( );
+  auto ipobj = this->GetITK< itk::ProcessObject >( );
+  if( ipobj == NULL )
+  {
+    auto vpobj = this->GetVTK< vtkAlgorithm >( );
+    if( vpobj != NULL )
+      filter_time = ( const_cast< vtkAlgorithm* >( vpobj ) )->GetMTime( );
+  }
+  else
+    filter_time = ipobj->GetMTime( );
+  return( ( params_time < filter_time )? filter_time: params_time );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetSingleInteractor( vtkRenderWindowInteractor* interactor )
+std::string cpPlugins::Interface::ProcessObject::
+Update( )
 {
-  this->m_SingleInteractor = interactor;
-}
+  static 
+  std::string r = "";
 
-// -------------------------------------------------------------------------
-cpPlugins::Interface::
-SimpleMPRWidget* cpPlugins::Interface::ProcessObject::
-GetMPRViewer( )
-{
-  return( this->m_MPRViewer );
-}
+  // Force upstream updates
+  _TDataContainer::iterator i = this->m_Inputs.begin( );
+  bool need_to_update = false;
+  for( ; i != this->m_Inputs.end( ) && r == ""; ++i )
+  {
+    if( i->second.IsValid( ) )
+    {
+      Self* src = dynamic_cast< Self* >( i->second->GetSource( ) );
+      if( src != NULL )
+      {
+        need_to_update |= ( this->m_LastExecutionTime < src->GetMTime( ) );
+        r = src->Update( );
 
-// -------------------------------------------------------------------------
-const cpPlugins::Interface::
-SimpleMPRWidget* cpPlugins::Interface::ProcessObject::
-GetMPRViewer( ) const
-{
-  return( this->m_MPRViewer );
-}
+      } // fi
+    }
+    else
+      r = "cpPlugins::Interface::ProcessObject: No input connected.";
 
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetMPRViewer( cpPlugins::Interface::SimpleMPRWidget* wdg )
-{
-  this->m_MPRViewer = wdg;
-}
+  } // rof
 
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::ProcessObject::
-ExecConfigurationDialog( QWidget* parent )
-{
-  bool r = false;
-#ifdef cpPlugins_Interface_QT4
-  if( this->m_ParametersDialog != NULL )
+  // Current update
+  if( r == "" )
   {
-    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
+    if( this->m_LastExecutionTime < this->GetMTime( ) || need_to_update )
+    {
+      r = this->_GenerateData( );
+      this->m_LastExecutionTime = this->GetMTime( );
+
+    } // fi
+
+  } // fi
+
+  // Return error description, if any
   return( r );
 }
 
@@ -166,6 +179,7 @@ ExecConfigurationDialog( QWidget* parent )
 cpPlugins::Interface::ProcessObject::
 ProcessObject( )
   : Superclass( ),
+    m_LastExecutionTime( 0 ),
     m_ParametersDialog( NULL ),
     m_MPRViewer( NULL )
 {
@@ -174,7 +188,11 @@ ProcessObject( )
 
 #ifdef cpPlugins_Interface_QT4
   if( QApplication::instance( ) != NULL )
+  {
     this->m_ParametersDialog = new ParametersQtDialog( );
+    this->m_ParametersDialog->setParameters( this->m_Parameters );
+
+  } // fi
 #endif // cpPlugins_Interface_QT4
 }
 
@@ -182,35 +200,19 @@ ProcessObject( )
 cpPlugins::Interface::ProcessObject::
 ~ProcessObject( )
 {
-#ifdef cpPlugins_Interface_QT4
+  this->Disconnect( );
   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 )
 {
+  typedef typename _TDataContainer::value_type _TValue;
   auto i = this->m_Inputs.find( name );
   if( i == this->m_Inputs.end( ) )
-  {
-    this->m_Inputs[ name ] = NULL;
-    this->Modified( );
-
-  } // fi
+    i = this->m_Inputs.insert( _TValue( name, NULL ) ).first;
 }
 
 // eof - $RCSfile$
index ec6cb2a53bb7a69fe96d3d166691f2ec8d58666c..862da18b48a949f46fcd4b033ec9928d6846d701 100644 (file)
@@ -1,20 +1,15 @@
 #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
 #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
 
+#include <map>
 #include <set>
 
 #include <itkDataObject.h>
-
-#include <cpPlugins/Interface/DataObject.h>
+#include <cpPlugins/Interface/ProcessObjectPort.h>
 #include <cpPlugins/Interface/Parameters.h>
 
 // Some forward declarations
 class vtkRenderWindowInteractor;
-#ifdef cpPlugins_Interface_QT4
-class QWidget;
-#else
-typedef char QWidget;
-#endif // cpPlugins_Interface_QT4
 
 namespace cpPlugins
 {
@@ -48,75 +43,55 @@ namespace cpPlugins
       itkTypeMacro( ProcessObject, Object );
       cpPlugins_Id_Macro( ProcessObject, BaseObject );
 
-      itkBooleanMacro( Interactive );
-      itkGetConstMacro( Interactive, bool );
-      itkSetMacro( Interactive, bool );
-
       itkGetConstObjectMacro( Parameters, TParameters );
+
       itkGetObjectMacro( Parameters, TParameters );
+      itkGetMacro( ParametersDialog, ParametersQtDialog* );
+      itkGetMacro( SingleInteractor, vtkRenderWindowInteractor* );
+      itkGetMacro( MPRViewer, SimpleMPRWidget* );
+
+      itkSetObjectMacro( ParametersDialog, ParametersQtDialog );
+      itkSetObjectMacro( SingleInteractor, vtkRenderWindowInteractor );
+      itkSetObjectMacro( MPRViewer, SimpleMPRWidget );
 
     public:
-      virtual std::set< std::string > GetInputsNames( ) const;
-      virtual std::set< std::string > GetOutputsNames( ) const;
+      // IO management
+      std::set< std::string > GetInputsNames( ) const;
+      std::set< std::string > GetOutputsNames( ) const;
       unsigned int GetNumberOfInputs( ) const;
       unsigned int GetNumberOfOutputs( ) const;
 
-      virtual bool SetInput( const std::string& id, DataObject::Pointer* dobj );
-
-      virtual std::string Update( );
-      virtual void DisconnectOutputs( );
-
-      // Widgets management
-      vtkRenderWindowInteractor* GetSingleInteractor( );
-      const vtkRenderWindowInteractor* GetSingleInteractor( ) const;
-      void SetSingleInteractor( vtkRenderWindowInteractor* interactor );
-      SimpleMPRWidget* GetMPRViewer( );
-      const SimpleMPRWidget* GetMPRViewer( ) const;
-      void SetMPRViewer( SimpleMPRWidget* wdg );
-      virtual bool ExecConfigurationDialog( QWidget* parent );
+      ProcessObjectPort& GetOutput( const std::string& id );
+      const ProcessObjectPort& GetOutput( const std::string& id ) const;
 
       template< class T >
         inline T* GetInputData( const std::string& id );
-
       template< class T >
         inline const T* GetInputData( const std::string& id ) const;
-
       template< class T >
         inline T* GetOutputData( const std::string& id );
-
       template< class T >
         inline const T* GetOutputData( const std::string& id ) const;
 
-      DataObject::Pointer* GetOutputPort( const std::string& id )
-      {
-        auto i = this->m_Outputs.find( id );
-        if( i != this->m_Outputs.end( ) )
-          return( i->second );
-        else
-          return( NULL );
-      }
-
-      const DataObject::Pointer* GetOutputPort( const std::string& id ) const
-      {
-        auto i = this->m_Outputs.find( id );
-        if( i != this->m_Outputs.end( ) )
-          return( i->second );
-        else
-          return( NULL );
-      }
+      bool SetInput( const std::string& id, const ProcessObjectPort& port );
+
+      void DisconnectInputs( );
+      void DisconnectOutputs( );
+      void Disconnect( );
+
+      // Pipeline execution
+      virtual itk::ModifiedTimeType GetMTime( ) const;
+      virtual std::string Update( );
 
     protected:
       ProcessObject( );
       virtual ~ProcessObject( );
 
-      virtual void _AddInput( const std::string& name );
-
+      void _AddInput( const std::string& name );
       template< class O >
-        inline void _AddOutput( const std::string& id );
-
+        inline void _AddOutput( const std::string& name );
       template< class F >
         inline F* _CreateITK( );
-
       template< class F >
         inline F* _CreateVTK( );
 
@@ -128,16 +103,16 @@ namespace cpPlugins
       Self& operator=( const Self& );
 
     protected:
+      typedef std::map< std::string, ProcessObjectPort > _TDataContainer;
+      _TDataContainer     m_Inputs;
+      _TDataContainer     m_Outputs;
       Parameters::Pointer m_Parameters;
-      ParametersQtDialog* m_ParametersDialog;
 
-      vtkSmartPointer< vtkRenderWindowInteractor > m_SingleInteractor;
-      SimpleMPRWidget*                             m_MPRViewer;
-      bool                                         m_Interactive;
+      itk::ModifiedTimeType m_LastExecutionTime;
 
-      typedef std::map< std::string, DataObject::Pointer* > _TDataContainer;
-      _TDataContainer m_Inputs;
-      _TDataContainer m_Outputs;
+      ParametersQtDialog*        m_ParametersDialog;
+      vtkRenderWindowInteractor* m_SingleInteractor;
+      SimpleMPRWidget*           m_MPRViewer;
     };
 
   } // ecapseman
index a3362fc5b8ce25de6305aa15d636456cb575c7cc..1b691ff0ee2f90d7d4ab096e764884170506b653 100644 (file)
@@ -6,9 +6,9 @@ template< class T >
 T* cpPlugins::Interface::ProcessObject::
 GetInputData( const std::string& id )
 {
-  _TDataContainer::iterator i = this->m_Inputs.find( id );
+  auto i = this->m_Inputs.find( id );
   if( i != this->m_Inputs.end( ) )
-    return( dynamic_cast< T* >( i->second->GetPointer( ) ) );
+    return( dynamic_cast< T* >( i->second.GetPointer( ) ) );
   else
     return( NULL );
 }
@@ -18,9 +18,9 @@ template< class T >
 const T* cpPlugins::Interface::ProcessObject::
 GetInputData( const std::string& id ) const
 {
-  _TDataContainer::const_iterator i = this->m_Inputs.find( id );
+  auto i = this->m_Inputs.find( id );
   if( i != this->m_Inputs.end( ) )
-    return( dynamic_cast< const T* >( i->second->GetPointer( ) ) );
+    return( dynamic_cast< const T* >( i->second.GetPointer( ) ) );
   else
     return( NULL );
 }
@@ -30,9 +30,9 @@ template< class T >
 T* cpPlugins::Interface::ProcessObject::
 GetOutputData( const std::string& id )
 {
-  _TDataContainer::iterator i = this->m_Outputs.find( id );
+  auto i = this->m_Outputs.find( id );
   if( i != this->m_Outputs.end( ) )
-    return( dynamic_cast< T* >( i->second->GetPointer( ) ) );
+    return( dynamic_cast< T* >( i->second.GetPointer( ) ) );
   else
     return( NULL );
 }
@@ -42,9 +42,9 @@ template< class T >
 const T* cpPlugins::Interface::ProcessObject::
 GetOutputData( const std::string& id ) const
 {
-  _TDataContainer::const_iterator i = this->m_Outputs.find( id );
+  auto i = this->m_Outputs.find( id );
   if( i != this->m_Outputs.end( ) )
-    return( dynamic_cast< const T* >( i->second->GetPointer( ) ) );
+    return( dynamic_cast< const T* >( i->second.GetPointer( ) ) );
   else
     return( NULL );
 }
@@ -52,18 +52,17 @@ GetOutputData( const std::string& id ) const
 // -------------------------------------------------------------------------
 template< class O >
 void cpPlugins::Interface::ProcessObject::
-_AddOutput( const std::string& id )
+_AddOutput( const std::string& name )
 {
-  auto oIt = this->m_Outputs.find( id );
-  if( oIt == this->m_Outputs.end( ) )
+  typedef typename _TDataContainer::value_type _TValue;
+  auto i = this->m_Outputs.find( name );
+  if( i == this->m_Outputs.end( ) )
   {
-    this->m_Outputs[ id ] = new DataObject::Pointer( );
-    oIt = this->m_Outputs.find( id );
+    typename O::Pointer o = O::New( );
+    o->SetSource( this );
+    this->m_Outputs[ name ] = o;
 
   } // fi
-  *( oIt->second ) = O::New( );
-  ( *( oIt->second ) )->SetSource( this );
-  this->Modified( );
 }
 
 // -------------------------------------------------------------------------
@@ -71,13 +70,13 @@ template< class F >
 F* cpPlugins::Interface::ProcessObject::
 _CreateITK( )
 {
-  F* filter = dynamic_cast< F* >( this->m_ITKObject.GetPointer( ) );
+  F* filter = this->GetITK< F >( );
   if( filter == NULL )
   {
-    typename F::Pointer ptr = F::New( );
-    this->m_ITKObject = ptr;
-    filter = ptr.GetPointer( );
-    this->m_VTKObject = NULL;
+    typename F::Pointer filter_ptr = F::New( );
+    this->SetITK( filter_ptr.GetPointer( ) );
+    this->SetVTK( NULL );
+    filter = filter_ptr.GetPointer( );
 
   } // fi
   return( filter );
@@ -88,12 +87,13 @@ template< class F >
 F* cpPlugins::Interface::ProcessObject::
 _CreateVTK( )
 {
-  F* filter = dynamic_cast< F* >( this->m_VTKObject.GetPointer( ) );
+  F* filter = this->GetVTK< F >( );
   if( filter == NULL )
   {
-    filter = F::New( );
-    this->m_VTKObject = filter;
-    this->m_ITKObject = NULL;
+    vtkSmartPointer< F > filter_ptr = vtkSmartPointer< F >::New( );
+    this->SetITK( NULL );
+    this->SetVTK( filter_ptr );
+    filter = filter_ptr.GetPointer( );
 
   } // fi
   return( filter );
diff --git a/lib/cpPlugins/Interface/ProcessObjectPort.cxx b/lib/cpPlugins/Interface/ProcessObjectPort.cxx
new file mode 100644 (file)
index 0000000..cec8fac
--- /dev/null
@@ -0,0 +1,55 @@
+#include <cpPlugins/Interface/ProcessObjectPort.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObjectPort::
+ProcessObjectPort( )
+{
+  this->m_Data = NULL;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObjectPort::
+ProcessObjectPort( DataObject* obj )
+{
+  this->m_Data = obj;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObjectPort::
+ProcessObjectPort( const Self& other )
+{
+  this->m_Data = other.m_Data.GetPointer( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObjectPort::
+~ProcessObjectPort( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObjectPort::
+Self& cpPlugins::Interface::ProcessObjectPort::
+operator=( DataObject* obj )
+{
+  this->m_Data = obj;
+  return( *this );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObjectPort::
+Self& cpPlugins::Interface::ProcessObjectPort::
+operator=( const Self& other )
+{
+  this->m_Data = other.m_Data.GetPointer( );
+  return( *this );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::ProcessObjectPort::
+IsValid( ) const
+{
+  return( this->m_Data.IsNotNull( ) );
+}
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Interface/ProcessObjectPort.h b/lib/cpPlugins/Interface/ProcessObjectPort.h
new file mode 100644 (file)
index 0000000..393fd53
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECTPORT__H__
+#define __CPPLUGINS__INTERFACE__PROCESSOBJECTPORT__H__
+
+#include <cpPlugins/Interface/DataObject.h>
+
+namespace cpPlugins
+{
+  namespace Interface
+  {
+    /**
+     */
+    class cpPlugins_Interface_EXPORT ProcessObjectPort
+    {
+    public:
+      typedef ProcessObjectPort Self;
+
+    public:
+      ProcessObjectPort( );
+      ProcessObjectPort( DataObject* obj );
+      ProcessObjectPort( const Self& other );
+      virtual ~ProcessObjectPort( );
+      Self& operator=( DataObject* obj );
+      Self& operator=( const Self& other );
+
+      bool IsValid( ) const;
+
+      // This could be seen as a pointer to DataObject's
+      DataObject* GetPointer( )
+      { return( this->m_Data.GetPointer( ) ); }
+      const DataObject* GetPointer( ) const
+      { return( this->m_Data.GetPointer( ) ); }
+      DataObject* operator->( ) const
+      { return( this->m_Data.GetPointer( ) ); }
+
+    protected:
+      cpPlugins::Interface::DataObject::Pointer m_Data;
+
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__INTERFACE__PROCESSOBJECTPORT__H__
+
+// eof - $RCSfile$
index b37c2caa8b5c92d2418c6450515389847350f3a3..c56897e2b1cbc317f67b6397d2736d35fb42505e 100644 (file)
@@ -211,27 +211,30 @@ Connect(
     return( false );
 
   // Real connection
-  dest->SetInput( input_name, orig->GetOutputPort( output_name ) );
-  this->m_Graph->AddEdge(
-    orig_filter, dest_filter,
-    TConnection( output_name, input_name )
-    );
-  return( false );
+  if( dest->SetInput( input_name, orig->GetOutput( output_name ) ) )
+  {
+    this->m_Graph->AddEdge(
+      orig_filter, dest_filter,
+      TConnection( output_name, input_name )
+      );
+    return( true );
+  }
+  else
+    return( false );
 }
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Workspace::
-Connect( TData::Pointer* input_object, const std::string& input_name )
+Connect(
+  const ProcessObjectPort& input_port, const std::string& exposed_port
+  )
 {
-  auto port = this->m_ExposedInputPorts.find( input_name );
+  auto port = this->m_ExposedInputPorts.find( exposed_port );
   if( port != this->m_ExposedInputPorts.end( ) )
   {
     TFilter* filter = this->GetFilter( port->second.first );
     if( filter != NULL )
-    {
-      filter->SetInput( port->second.second, input_object );
-      return( true );
-    }
+      return( filter->SetInput( port->second.second, input_port ) );
     else
       return( false );
   }
index b4c464124765668b64e0508fdc10dd45c679cdf3..be85418dac277ad54389fc0b1d89ccea75018c79 100644 (file)
@@ -93,7 +93,7 @@ namespace cpPlugins
         const std::string& output_name, const std::string& input_name
         );
       bool Connect(
-        TData::Pointer* input_object, const std::string& exposed_port
+        const ProcessObjectPort& input_port, const std::string& exposed_port
         );
       void RemoveConnection(
         const std::string& dest_filter, const std::string& input_name
index 78d5da4c51348f4ba7066db9d9f6288c49be8df8..957136d3187879ce34c35c1105b1d4dff64f436a 100644 (file)
@@ -26,7 +26,7 @@ _GenerateData( )
     return( "InputDataReproducer: No input/output ports." );
 
   // Connect output
-  *( o->second ) = *( i->second );
+  o->second = i->second;
   return( "" );
 }
 
index f989635f039427972112ff8ff2a97faeae78cdf7..53e39f0581b9ca1829a530995662d07be191dd37 100644 (file)
@@ -10,7 +10,7 @@ cpPlugins::BasicFilters::SphereMeshSource::
 SphereMeshSource( )
   : Superclass( )
 {
-  this->_AddInput( "Center" );
+  // TODO: this->_AddInput( "Center" );
   this->_AddOutput< cpPlugins::Interface::Mesh >( "Output" );
 
   this->m_Parameters->ConfigureAsReal( "Radius" );
index 4841bcf0fdd3a5948ece446dacf65df46d8d9774..ef7c581ad6f0a910ae129d8bcd7165a7d20d9b05 100644 (file)
@@ -20,6 +20,7 @@
 #include <itkGDCMSeriesFileNames.h>
 
 // -------------------------------------------------------------------------
+/*
 bool cpPlugins::IO::DicomSeriesReader::
 ExecConfigurationDialog( QWidget* parent )
 {
@@ -185,6 +186,7 @@ ExecConfigurationDialog( QWidget* parent )
 
   return( r );
 }
+*/
 
 // -------------------------------------------------------------------------
 cpPlugins::IO::DicomSeriesReader::
index 1d619d0c1bf63e6cca15fa3017d4d5b9899b326b..968932f72458936296cd7120daf02d0dad676910 100644 (file)
@@ -34,8 +34,10 @@ namespace cpPlugins
       itkTypeMacro( DicomSeriesReader, ImageReader );
       cpPlugins_Id_Macro( cpPlugins::IO::DicomSeriesReader, IO );
 
-    public:
-      virtual bool ExecConfigurationDialog( QWidget* parent );
+      /* TODO
+         public:
+         virtual bool ExecConfigurationDialog( QWidget* parent );
+      */
 
     protected:
       DicomSeriesReader( );
index c5c8383eb2a6813e802184a78e96aa48bbb9e97a..97e96fa2353c512d9c0c0adf535f77adcd8403a8 100644 (file)
@@ -100,7 +100,7 @@ _GD0( itk::DataObject* image )
   } // fi
 
   // Single interactor
-  _S* s = dynamic_cast< _S* >( this->m_SingleInteractor.GetPointer( ) );
+  _S* s = dynamic_cast< _S* >( this->m_SingleInteractor );
   if( s != NULL )
   {
     if( this->m_Configured )