]> Creatis software - cpPlugins.git/commitdiff
UML-code sync
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 5 Nov 2015 23:08:54 +0000 (18:08 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 5 Nov 2015 23:08:54 +0000 (18:08 -0500)
17 files changed:
doc/uml/cpPlugins_classes.dia
lib/cpPlugins/Interface/BaseApplication.h [new file with mode: 0644]
lib/cpPlugins/Interface/BasePluginsApplication.h [deleted file]
lib/cpPlugins/Interface/DataObject.cxx
lib/cpPlugins/Interface/DataObject.h
lib/cpPlugins/Interface/Image.h
lib/cpPlugins/Interface/Image.hxx
lib/cpPlugins/Interface/Macros.h
lib/cpPlugins/Interface/Mesh.h
lib/cpPlugins/Interface/Mesh.hxx
lib/cpPlugins/Interface/Object.cxx
lib/cpPlugins/Interface/Object.h
lib/cpPlugins/Interface/Plugins.cxx
lib/cpPlugins/Interface/Plugins.h
lib/cpPlugins/Interface/Plugins.hxx [new file with mode: 0644]
lib/cpPlugins/Interface/ProcessObject.cxx
lib/cpPlugins/Interface/ProcessObject.h

index d5c06312e9c36e1ace50bf3e6689c114247c72c0..7e24d9a6680c0f444615ae14eef9a3c06d035abf 100644 (file)
Binary files a/doc/uml/cpPlugins_classes.dia and b/doc/uml/cpPlugins_classes.dia differ
diff --git a/lib/cpPlugins/Interface/BaseApplication.h b/lib/cpPlugins/Interface/BaseApplication.h
new file mode 100644 (file)
index 0000000..549296b
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef __CPPLUGINS__INTERFACE__BASEAPPLICATION__H__
+#define __CPPLUGINS__INTERFACE__BASEAPPLICATION__H__
+
+#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
+
+namespace cpPlugins
+{
+  namespace Interface
+  {
+    /**
+     */
+    class cpPlugins_Interface_EXPORT BaseApplication
+    {
+    public:
+      BaseApplication( ) { }
+      virtual ~BaseApplication( ) { }
+
+      virtual void UpdateActualFilter( ) = 0;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__INTERFACE__BASEAPPLICATION__H__
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Interface/BasePluginsApplication.h b/lib/cpPlugins/Interface/BasePluginsApplication.h
deleted file mode 100644 (file)
index 26ba271..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef __CPPLUGINS__INTERFACE__BASEPLUGINSAPPLICATION__H__
-#define __CPPLUGINS__INTERFACE__BASEPLUGINSAPPLICATION__H__
-
-#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
-
-namespace cpPlugins
-{
-  namespace Interface
-  {
-    /**
-     */
-    class cpPlugins_Interface_EXPORT BasePluginsApplication
-    {
-    public:
-      BasePluginsApplication( ) { }
-      virtual ~BasePluginsApplication( ) { }
-
-      virtual void UpdateActualFilter( ) = 0;
-    };
-
-  } // ecapseman
-
-} // ecapseman
-
-#endif // __CPPLUGINS__INTERFACE__BASEPLUGINSAPPLICATION__H__
-
-// eof - $RCSfile$
index 580434548740a34c758e10bb702be2e0705363ba..c937e4d32d868d8359018e8183136168f7ea4283 100644 (file)
@@ -1,18 +1,19 @@
 #include <cpPlugins/Interface/DataObject.h>
 
+#include <cpPlugins/Interface/ProcessObject.h>
 #include <itkDataObject.h>
 #include <vtkImageData.h>
 #include <vtkPolyData.h>
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::Object* cpPlugins::Interface::DataObject::
+cpPlugins::Interface::ProcessObject* cpPlugins::Interface::DataObject::
 GetSource( )
 {
   return( this->m_Source );
 }
 
 // -------------------------------------------------------------------------
-const cpPlugins::Interface::Object* cpPlugins::Interface::DataObject::
+const cpPlugins::Interface::ProcessObject* cpPlugins::Interface::DataObject::
 GetSource( ) const
 {
   return( this->m_Source );
@@ -20,9 +21,9 @@ GetSource( ) const
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::DataObject::
-SetSource( cpPlugins::Interface::Object* src )
+SetSource( cpPlugins::Interface::ProcessObject* src )
 {
-  if( this->m_Source.GetPointer( ) != src )
+  if( this->m_Source != src )
   {
     this->m_Source = src;
     this->Modified( );
index 841f3a2514366b9af2d01bf5e943fd2145904795..46682197b81eee9b3bae03f355965dec90b18e20 100644 (file)
@@ -1,11 +1,9 @@
 #ifndef __CPPLUGINS__INTERFACE__DATAOBJECT__H__
 #define __CPPLUGINS__INTERFACE__DATAOBJECT__H__
 
-#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
 #include <cpPlugins/Interface/Object.h>
 
 #include <itkObject.h>
-
 #include <vtkSmartPointer.h>
 #include <vtkObject.h>
 
@@ -13,6 +11,9 @@ namespace cpPlugins
 {
   namespace Interface
   {
+    // Some forward declarations
+    class ProcessObject;
+
     /**
      */
     class cpPlugins_Interface_EXPORT DataObject
@@ -26,14 +27,12 @@ namespace cpPlugins
 
     public:
       itkTypeMacro( DataObject, Object );
-      cpPlugins_Id_Macro(
-        cpPlugins::Interface::DataObject, "BasicObject"
-        );
+      cpPlugins_Id_Macro( DataObject, "BasicObject" );
 
     public:
-      Object* GetSource( );
-      const Object* GetSource( ) const;
-      void SetSource( Object* src );
+      ProcessObject* GetSource( );
+      const ProcessObject* GetSource( ) const;
+      void SetSource( ProcessObject* src );
 
       void DisconnectPipeline( );
 
@@ -61,7 +60,7 @@ namespace cpPlugins
     protected:
       itk::Object::Pointer         m_ITKObject;
       vtkSmartPointer< vtkObject > m_VTKObject;
-      Object::Pointer              m_Source;
+      ProcessObject*               m_Source;
     };
 
   } // ecapseman
index 1aeee5cc18a7b6945951fcbf7d692d1748318b70..30bfbf549cb1b725d32cc86063ae46b09d47649a 100644 (file)
@@ -1,13 +1,10 @@
 #ifndef __CPPLUGINS__INTERFACE__IMAGE__H__
 #define __CPPLUGINS__INTERFACE__IMAGE__H__
 
-#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
 #include <cpPlugins/Interface/DataObject.h>
 
 #include <itkProcessObject.h>
 
-class vtkImageData;
-
 // -------------------------------------------------------------------------
 namespace cpPlugins
 {
@@ -27,9 +24,7 @@ namespace cpPlugins
     public:
       itkNewMacro( Self );
       itkTypeMacro( Image, DataObject );
-      cpPlugins_Id_Macro(
-        cpPlugins::Interface::Image, "DataObject"
-        );
+      cpPlugins_Id_Macro( Image, "DataObject" );
 
     public:
       template< class I >
index dfabc0ab6ecdb1503981e4ac729d1dd619b6f23b..8c31dca4c7e6acc0caf11e6842a16168871b6037 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef __CPPLUGINS__INTERFACE__IMAGE__HXX__
 #define __CPPLUGINS__INTERFACE__IMAGE__HXX__
 
-#include <cpPlugins/Interface/Macros.h>
-
 #include <complex>
 
 #include <itkImage.h>
index c85cd0c160f3efec4ed0ed482fccdf8fcc3da3dc..85a9d089a81ff50a47b2f43e296e52b5bfef92e8 100644 (file)
@@ -1,12 +1,62 @@
 #ifndef __CPPLUGINS__INTERFACE__MACROS__H__
 #define __CPPLUGINS__INTERFACE__MACROS__H__
 
+#include <Pluma/Pluma.hpp>
 #include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
+#include <cpPlugins/Interface/Config.h>
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Id_Macro( name, category )                            \
+  public:                                                               \
+  virtual std::string GetClassName( ) { return( #name ); }              \
+  virtual std::string GetClassCategory( ) { return( category ); }
+
+// -------------------------------------------------------------------------
+#define CPPLUGINS_PROVIDER_HEADER_BEGIN( TYPE )                 \
+  class cpPlugins_Interface_EXPORT TYPE##Provider               \
+    : public pluma::Provider                                    \
+  {                                                             \
+private:                                                        \
+    friend class pluma::Pluma;                                  \
+    static const unsigned int PLUMA_INTERFACE_VERSION;          \
+    static const unsigned int PLUMA_INTERFACE_LOWEST_VERSION;   \
+    static const std::string PLUMA_PROVIDER_TYPE;               \
+    std::string plumaGetType( ) const                           \
+    { return( PLUMA_PROVIDER_TYPE ); }                          \
+public:                                                         \
+    unsigned int getVersion( ) const                            \
+    { return( PLUMA_INTERFACE_VERSION ); }
+
+// -------------------------------------------------------------------------
+#define CPPLUGINS_PROVIDER_HEADER_END };
+
+// -------------------------------------------------------------------------
+#define CPPLUGINS_PROVIDER_HEADER( TYPE )               \
+  CPPLUGINS_PROVIDER_HEADER_BEGIN( TYPE )               \
+  virtual TYPE::Pointer create( ) const = 0;            \
+  CPPLUGINS_PROVIDER_HEADER_END
+
+// -------------------------------------------------------------------------
+#define CPPLUGINS_PROVIDER_SOURCE( TYPE, Version, LowestVersion )       \
+  PLUMA_PROVIDER_SOURCE( TYPE, Version, LowestVersion )
+
+// -------------------------------------------------------------------------
+#define CPPLUGINS_INHERIT_PROVIDER( TYPE )                              \
+  class TYPE##Provider                                                  \
+    : public cpPlugins::Interface::ProcessObjectProvider                \
+  {                                                                     \
+  public:                                                               \
+    cpPlugins::Interface::Object::Pointer create( ) const               \
+    {                                                                   \
+      TYPE::Pointer a = TYPE::New( );                                   \
+      cpPlugins::Interface::Object::Pointer b = a.GetPointer( );        \
+      return( b );                                                      \
+    }                                                                   \
+  };
 
 /**
  * Based upon: http://www.itk.org/Wiki/Proposals:Explicit_Instantiation
  */
-
 // -------------------------------------------------------------------------
 #define cpPlugins_TEMPLATE_1( X1 )              \
   X1
index 92c3c452e378fdd4598d0059855a0a616f4b6ba4..097ed30aad229972f007f789546a798929141894 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef __CPPLUGINS__INTERFACE__MESH__H__
 #define __CPPLUGINS__INTERFACE__MESH__H__
 
-#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
 #include <cpPlugins/Interface/DataObject.h>
 
 namespace cpPlugins
@@ -22,9 +21,7 @@ namespace cpPlugins
     public:
       itkNewMacro( Self );
       itkTypeMacro( Mesh, DataObject );
-      cpPlugins_Id_Macro(
-        cpPlugins::Interface::Mesh, "DataObject"
-        );
+      cpPlugins_Id_Macro( Mesh, "DataObject" );
 
     public:
       template< class M >
index da891678da571596752fac22fa2e7cdb2046a784..6de611e2faa1fab2b533972521e16a9bc4344ff8 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef __CPPLUGINS__INTERFACE__MESH__HXX__
 #define __CPPLUGINS__INTERFACE__MESH__HXX__
 
-#include <cpPlugins/Interface/Macros.h>
-
 #include <itkMesh.h>
 #include <itkQuadEdgeMesh.h>
 
index 4ca6286c25c8b1049d8f01922e296fe906b76026..474e031f04565b552b84f2c86d1d32312d4d88e8 100644 (file)
@@ -13,7 +13,4 @@ cpPlugins::Interface::Object::
 {
 }
 
-// -------------------------------------------------------------------------
-CPPLUGINS_PROVIDER_SOURCE( cpPlugins::Interface::Object, 1, 1 );
-
 // eof - $RCSfile$
index c4a0bfba7bcb84e499728c58bf1b9046f754964c..03eb2ae1f912047a88153ad96031f91a7bb4e480 100644 (file)
@@ -1,62 +1,12 @@
 #ifndef __CPPLUGINS__INTERFACE__OBJECT__H__
 #define __CPPLUGINS__INTERFACE__OBJECT__H__
 
-#include <string>
-#include <Pluma/Pluma.hpp>
-#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
+#include <cpPlugins/Interface/Macros.h>
 
+#include <string>
 #include <itkObject.h>
 #include <itkObjectFactory.h>
 
-// -------------------------------------------------------------------------
-#define CPPLUGINS_PROVIDER_HEADER_BEGIN( TYPE )                 \
-  class cpPlugins_Interface_EXPORT TYPE##Provider               \
-    : public pluma::Provider                                    \
-  {                                                             \
-private:                                                        \
-    friend class pluma::Pluma;                                  \
-    static const unsigned int PLUMA_INTERFACE_VERSION;          \
-    static const unsigned int PLUMA_INTERFACE_LOWEST_VERSION;   \
-    static const std::string PLUMA_PROVIDER_TYPE;               \
-    std::string plumaGetType( ) const                           \
-    { return( PLUMA_PROVIDER_TYPE ); }                          \
-public:                                                         \
-    unsigned int getVersion( ) const                            \
-    { return( PLUMA_INTERFACE_VERSION ); }
-
-// -------------------------------------------------------------------------
-#define CPPLUGINS_PROVIDER_HEADER_END };
-
-// -------------------------------------------------------------------------
-#define CPPLUGINS_PROVIDER_HEADER( TYPE )               \
-  CPPLUGINS_PROVIDER_HEADER_BEGIN( TYPE )               \
-  virtual TYPE::Pointer create( ) const = 0;            \
-  CPPLUGINS_PROVIDER_HEADER_END
-
-// -------------------------------------------------------------------------
-#define CPPLUGINS_PROVIDER_SOURCE( TYPE, Version, LowestVersion )       \
-  PLUMA_PROVIDER_SOURCE( TYPE, Version, LowestVersion )
-
-// -------------------------------------------------------------------------
-#define CPPLUGINS_INHERIT_PROVIDER( TYPE )                              \
-  class TYPE##Provider                                                  \
-    : public cpPlugins::Interface::ObjectProvider                       \
-  {                                                                     \
-  public:                                                               \
-    cpPlugins::Interface::Object::Pointer create( ) const               \
-    {                                                                   \
-      TYPE::Pointer a = TYPE::New( );                                   \
-      cpPlugins::Interface::Object::Pointer b = a.GetPointer( );        \
-      return( b );                                                      \
-    }                                                                   \
-  };
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Id_Macro( name, category )                            \
-  public:                                                               \
-  virtual std::string GetClassName( ) { return( #name ); }              \
-  virtual std::string GetClassCategory( ) { return( category ); }
-
 namespace cpPlugins
 {
   namespace Interface
@@ -75,7 +25,7 @@ namespace cpPlugins
     public:
       itkNewMacro( Self );
       itkTypeMacro( Object, itkObject );
-      cpPlugins_Id_Macro( cpPlugins::Interface::Object, "BaseObject" );
+      cpPlugins_Id_Macro( Object, "BaseObject" );
 
       itkGetStringMacro( Name );
       itkSetStringMacro( Name );
@@ -93,11 +43,6 @@ namespace cpPlugins
       std::string m_Name;
     };
 
-    /**
-     * Plugin provider
-     */
-    CPPLUGINS_PROVIDER_HEADER( Object );
-
   } // ecapseman
 
 } // ecapseman
index 99aaebb012b0dbd5bc4d66027899f7a7fa89c99a..4647fde50d1d25a2669b3aa32c05df49f1c91137 100644 (file)
@@ -1,16 +1,14 @@
 #include <cpPlugins/Interface/Plugins.h>
-#include <cpPlugins/Interface/Config.h>
-
-#include <fstream>
-#include <sstream>
 
 #ifdef cpPlugins_Interface_QT4
 
-#include <QApplication>
-#include <QFileDialog>
-#include <QMenu>
-#include <QMessageBox>
-#include <QWidget>
+/*
+  #include <QApplication>
+  #include <QFileDialog>
+  #include <QMenu>
+  #include <QMessageBox>
+  #include <QWidget>
+*/
 
 #ifdef _WIN32
 #  define PLUGIN_PREFIX ""
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Plugins::
-Plugins( QWidget* widget )
-  : m_Widget( widget ),
+Plugins( )
+  : m_Widget( NULL ),
     m_Application( NULL ),
-    m_LastLoadedPlugin( "." )
+    m_Interface( NULL ),
+    m_LastLoadedPlugin( "" ),
+    m_ActiveFilter( NULL )
 {
+  this->m_Interface = new TInterface( );
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Plugins::
 ~Plugins( )
 {
-  // TODO: this causes a segfault? this->m_Interface.UnloadAll( );
+  if( this->m_Interface != NULL )
+    delete this->m_Interface;
 }
 
 // -------------------------------------------------------------------------
@@ -117,39 +119,14 @@ DialogLoadPlugins( )
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-AssociatePluginsToMenu( QMenu* menu, QObject* obj, const char* slot )
-{
-#ifdef cpPlugins_Interface_QT4
-  std::map< std::string, std::set< std::string > >::const_iterator i;
-  std::set< std::string >::const_iterator j;
-
-  menu->clear( );
-  for( i = this->m_Filters.begin( ); i != this->m_Filters.end( ); i++ )
-  {
-    QMenu* newMenu = menu->addMenu( i->first.c_str( ) );
-    for( j = i->second.begin( ); j != i->second.end( ); ++j )
-    {
-      QAction* a = newMenu->addAction( j->c_str( ) );
-      QObject::connect( a, SIGNAL( triggered( ) ), obj, slot );
-
-    } // rof
-
-  } // rof
-#endif // cpPlugins_Interface_QT4
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::
-BasePluginsApplication* cpPlugins::Interface::Plugins::
+BaseApplication* cpPlugins::Interface::Plugins::
 GetApplication( )
 {
   return( this->m_Application );
 }
 
 // -------------------------------------------------------------------------
-const cpPlugins::Interface::
-BasePluginsApplication* cpPlugins::Interface::Plugins::
+const BaseApplication* cpPlugins::Interface::Plugins::
 GetApplication( ) const
 {
   return( this->m_Application );
@@ -157,11 +134,18 @@ GetApplication( ) const
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Plugins::
-SetApplication( cpPlugins::Interface::BasePluginsApplication* a )
+SetApplication( BaseApplication* a )
 {
   this->m_Application = a;
 }
 
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Plugins::
+LoadPlugins( )
+{
+  // TODO: what to do here?
+}
+
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Plugins::
 LoadPlugins( const std::string& fname )
@@ -173,7 +157,7 @@ LoadPlugins( const std::string& fname )
   if( this->m_LoadedPlugins.find( fname ) == this->m_LoadedPlugins.end( ) )
   {
     // Was it succesfully loaded?
-    ret = this->m_Interface.Load( fname );
+    ret = this->m_Interface->Load( fname );
 
     // Update a simple track
     if( ret )
@@ -221,6 +205,412 @@ LoadPluginsConfigurationFile( const std::string& fname )
   return( true );
 }
 
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::Plugins::
+TStringContainer& cpPlugins::Interface::Plugins::
+GetLoadedPlugins( ) const
+{
+  return( this->m_LoadedPlugins );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Plugins::
+GetLoadedFilters( TStringContainer& filters ) const
+{
+  filters.clear( );
+  auto pIt = this->m_LoadedFilters.begin( );
+  for( ; pIt != this->m_LoadedFilters.end( ); ++pIt )
+    for( auto fIt = pIt->second.begin( ); fIt != pIt->second.end( ); ++fIt )
+      filters.insert( *fIt );
+}
+
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::Plugins::
+TStringContainer& cpPlugins::Interface::Plugins::
+GetLoadedFilters( const std::string& plugin ) const
+{
+  static const TStringContainer EMPTY;
+  auto pIt = this->m_LoadedFilters.find( plugin );
+  if( pIt != this->m_LoadedFilters.end( ) )
+    return( pIt->second );
+  else
+    return( EMPTY );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Plugins::
+AddInteractor( vtkRenderWindowInteractor* interactor )
+{
+  this->m_Interactors.insert( interactor );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Plugins::
+RemoveInteractor( vtkRenderWindowInteractor* interactor )
+{
+  this->m_Interactors.erase( interactor );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Plugins::
+ClearInteractors( )
+{
+  this->m_Interactors.clear( );
+}
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Plugins_HasMacro( F )                                 \
+  bool cpPlugins::Interface::Plugins::                                  \
+  Has##F( ) const                                                       \
+  {                                                                     \
+    return( this->m_IOFilters.find( #F ) != this->m_IOFilters.end( ) ); \
+  }
+
+cpPlugins_Plugins_HasMacro( ImageReader );
+cpPlugins_Plugins_HasMacro( DicomSeriesReader );
+cpPlugins_Plugins_HasMacro( MeshReader );
+cpPlugins_Plugins_HasMacro( ImageWriter );
+cpPlugins_Plugins_HasMacro( MeshWriter );
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Interface::Plugins::
+ReadImage( const std::string& fname, const std::string& parent )
+{
+  std::vector< std::string > fnames( 1, fname );
+  return( this->ReadImage( fnames, parent ) );
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Interface::Plugins::
+ReadImage(
+  const std::vector< std::string >& fnames, const std::string& parent
+  )
+{
+  // Activate reader
+  auto fIt = this->m_IOFilters.find( "ImageReader" );
+  if( fIt == this->m_IOFilters.end( ) )
+    return( "" );
+  this->m_ActiveFilter = fIt->second;
+
+  // Configure reader
+  TParameters* params = this->GetActiveFilterParameters( );
+  params->ClearStringList( "FileNames" );
+  for( auto nIt = fnames.begin( ); nIt != fnames.end( ); ++nIt )
+    params->AddToStringList( "FileNames", *nIt );
+
+  // Execute filter
+  std::string err = this->UpdateActiveFilter( );
+  if( err == "" )
+  {
+#error GET OBJECT NAME
+  }
+  else
+  {
+#error THROW ERROR
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Interface::Plugins::
+ReadImage( const std::string& parent )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Interface::Plugins::
+ReadDicomSeries( const std::string& parent )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Interface::Plugins::
+ReadMesh(
+  const std::string& fname, const std::string& parent
+  )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Interface::Plugins::
+ReadMesh( const std::string& parent )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Interface::Plugins::
+WriteDataObject(
+  const std::string& fname, const std::string& name
+  )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Interface::Plugins::
+WriteDataObject( const std::string& name )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Plugins::
+ClearDataObjects( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Plugins::
+DeleteDataObject( const std::string& name )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Plugins::
+GetDataObjects( TStringContainer& names )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Interface::Plugins::
+GetParent( const std::string& name ) const
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Plugins::
+GetChildren(
+  TStringContainer& names, const std::string& name
+  ) const
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Plugins::
+GetRoots( TStringContainer& names ) const
+{
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Plugins::
+ActivateFilter( const std::string& name )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Plugins::
+DeactivateFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Plugins::
+HasActiveFilter( ) const
+{
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Plugins::
+IsActiveFilterInteractive( ) const
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Plugins::
+GetActiveFilterInputsNames( TStringContainer& names ) const
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Plugins::
+GetActiveFilterOutputsNames( TStringContainer& names ) const
+{
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Plugins::
+ConnectInputInActiveFilter(
+  const std::string& object_name, const std::string& input_name
+  )
+{
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Plugins::
+SetOutputNameInActiveFilter(
+  const std::string& new_object_name, const std::string& output_name
+  )
+{
+}
+
+// -------------------------------------------------------------------------
+TParameters* cpPlugins::Interface::Plugins::
+GetActiveFilterParameters( )
+{
+}
+
+// -------------------------------------------------------------------------
+const TParameters* cpPlugins::Interface::Plugins::
+GetActiveFilterParameters( ) const
+{
+}
+
+// -------------------------------------------------------------------------
+TProcessObject::DialogResult cpPlugins::Interface::Plugins::
+ConfigureActiveFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Interface::Plugins::
+UpdateActiveFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Plugins::
+_UpdateLoadedPluginsInformation( )
+{
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Plugins::
+_InsertNewData( TDataObject* dobj, const std::string& parent )
+{
+}
+
+/*
+  protected:
+  // MVC objects
+  QWidget*         m_Widget;
+  BaseApplication* m_Application;
+  
+  // Plugins interface
+  TInterface       m_Interface;
+  TStringContainer m_LoadedPlugins;
+  std::string      m_LastLoadedPlugin;
+  
+  // Loaded filters
+  std::map< std::string, TProcessObject::Pointer > m_IOFilters;
+  TProcessObject::Pointer                       m_ActiveFilter;
+  std::map< std::string, std::string >   m_ActiveFilterOutputs;
+  std::map< std::string, TStringContainer >    m_LoadedFilters;
+  
+  // Loaded data objects
+  typedef std::pair< std::string, TDataObject::Pointer >  _TTreeNode;
+  std::map< std::string, _TTreeNode > m_DataObjects;
+  
+  // Associated interactors
+  std::set< vtkRenderWindowInteractor* > m_Interactors;
+  };
+  
+  } // ecapseman
+  
+  } // ecapseman
+*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#include <cpPlugins/Interface/Config.h>
+
+#include <fstream>
+#include <sstream>
+
+#ifdef cpPlugins_Interface_QT4
+
+#include <QApplication>
+#include <QFileDialog>
+#include <QMenu>
+#include <QMessageBox>
+#include <QWidget>
+
+#ifdef _WIN32
+#  define PLUGIN_PREFIX ""
+#  define PLUGIN_EXT "dll"
+#  define PLUGIN_REGEX "Plugins file (*.dll);;All files (*)"
+#else // Linux
+#  define PLUGIN_PREFIX "lib"
+#  define PLUGIN_EXT "so"
+#  define PLUGIN_REGEX "Plugins file (*.so);;All files (*)"
+#endif // _WIN32
+
+#endif // cpPlugins_Interface_QT4
+
+
+
+
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Plugins::
 AddInteractor( vtkRenderWindowInteractor* interactor )
index 8eb4d3c451945efd4ab43111cca74ba13a50ce9b..57ffe3f14a16f00acd30d1cb74e1661c9150ae3f 100644 (file)
@@ -1,27 +1,29 @@
 #ifndef __CPPLUGINS__INTERFACE__PLUGINS__H__
 #define __CPPLUGINS__INTERFACE__PLUGINS__H__
 
-#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
+#include <cpPlugins/Interface/Interface.h>
+#include <cpPlugins/Interface/DataObject.h>
+#include <cpPlugins/Interface/ProcessObject.h>
 
 #include <map>
 #include <set>
 #include <string>
+#include <vector>
 
-#include <cpPlugins/Interface/Interface.h>
-#include <cpPlugins/Interface/ProcessObject.h>
-#include <cpPlugins/Interface/Image.h>
-#include <cpPlugins/Interface/Mesh.h>
-
-class QObject;
-class QMenu;
-class QWidget;
+// Some forward declarations
 class vtkRenderWindowInteractor;
+#ifdef cpPlugins_Interface_QT4
+class QWidget;
+#else
+typedef char QWidget;
+#endif // cpPlugins_Interface_QT4
 
 namespace cpPlugins
 {
   namespace Interface
   {
-    class BasePluginsApplication;
+    // Some forward declarations
+    class BaseApplication;
 
     /**
      */
@@ -31,36 +33,36 @@ namespace cpPlugins
       typedef cpPlugins::Interface::Interface     TInterface;
       typedef cpPlugins::Interface::ProcessObject TProcessObject;
       typedef cpPlugins::Interface::DataObject    TDataObject;
-      typedef cpPlugins::Interface::Image         TImage;
-      typedef cpPlugins::Interface::Mesh          TMesh;
       typedef TProcessObject::TParameters         TParameters;
 
-      typedef std::set< std::string >           TOrderedStringContainer;
-      typedef std::map< std::string, std::set< std::string > > TFilters;
-      typedef std::pair< std::string, TDataObject::Pointer >  TTreeNode;
-      typedef std::map< std::string, TTreeNode >                  TTree;
+      typedef std::set< std::string > TStringContainer;
 
     public:
-      Plugins( QWidget* widget = NULL );
+      Plugins( );
       virtual ~Plugins( );
 
+      // Qt oriented methods
       QWidget* GetWidget( );
       const QWidget* GetWidget( ) const;
       void SetWidget( QWidget* widget );
       void BlockWidget( );
       void UnblockWidget( );
       void DialogLoadPlugins( );
-      void AssociatePluginsToMenu(
-        QMenu* menu, QObject* obj, const char* slot
-        );
 
-      BasePluginsApplication* GetApplication( );
-      const BasePluginsApplication* GetApplication( ) const;
-      void SetApplication( BasePluginsApplication* a );
+      // Connection to main application
+      BaseApplication* GetApplication( );
+      const BaseApplication* GetApplication( ) const;
+      void SetApplication( BaseApplication* a );
 
+      // Plugins management
       bool LoadPlugins( );
       bool LoadPlugins( const std::string& fname );
       bool LoadPluginsConfigurationFile( const std::string& fname );
+      const TStringContainer& GetLoadedPlugins( ) const;
+      void GetLoadedFilters( TStringContainer& filters ) const;
+      const TStringContainer& GetLoadedFilters(
+        const std::string& plugin
+        ) const;
 
       // Interactors
       void AddInteractor( vtkRenderWindowInteractor* interactor );
@@ -87,66 +89,68 @@ namespace cpPlugins
         );
       std::string ReadMesh( const std::string& parent );
 
-      bool WriteImage( const std::string& fname, const std::string& name );
-      bool WriteImage( const std::string& name );
-      bool WriteMesh( const std::string& fname, const std::string& name );
-      bool WriteMesh( const std::string& name );
+      std::string WriteDataObject(
+        const std::string& fname, const std::string& name
+        );
+      std::string WriteDataObject( const std::string& name );
 
       // Data objects
       void ClearDataObjects( );
       void DeleteDataObject( const std::string& name );
+      void GetDataObjects( TStringContainer& names );
       std::string GetParent( const std::string& name ) const;
-      const TTree& GetDataObjects( ) const;
-      TDataObject* GetDataObject( const std::string& name );
-      const TDataObject* GetDataObject( const std::string& name ) const;
-      TImage* GetImage( const std::string& name );
-      const TImage* GetImage( const std::string& name ) const;
-      TMesh* GetMesh( const std::string& name );
-      const TMesh* GetMesh( const std::string& name ) const;
+      void GetChildren(
+        TStringContainer& names, const std::string& name
+        ) const;
+      void GetRoots( TStringContainer& names ) const;
+
+      template< class T >
+        inline T* GetData( const std::string& name );
+
+      template< class T >
+        inline const T* GetData( const std::string& name ) const;
 
       // Filter acces
       bool ActivateFilter( const std::string& name );
       void DeactivateFilter( );
       bool HasActiveFilter( ) const;
       bool IsActiveFilterInteractive( ) const;
-      unsigned int GetNumberOfInputsInActiveFilter( ) const;
-      unsigned int GetNumberOfOutputsInActiveFilter( ) const;
-      std::vector< std::string > GetActiveFilterInputsNames( ) const;
-      std::vector< std::string > GetActiveFilterOutputsNames( ) const;
-      void ConnectInputInActiveFilter(
-        const std::string& object_name, const std::string& input
+      void GetActiveFilterInputsNames( TStringContainer& names ) const;
+      void GetActiveFilterOutputsNames( TStringContainer& names ) const;
+      bool ConnectInputInActiveFilter(
+        const std::string& object_name, const std::string& input_name
         );
-      void SetOutputNameInActiveFilter(
-        const std::string& new_name, const std::string& output
+      bool SetOutputNameInActiveFilter(
+        const std::string& new_object_name, const std::string& output_name
         );
       TParameters* GetActiveFilterParameters( );
       const TParameters* GetActiveFilterParameters( ) const;
       TProcessObject::DialogResult ConfigureActiveFilter( );
-      std::string UpdateActiveFilter( std::vector< std::string >& outputs );
+      std::string UpdateActiveFilter( );
 
     protected:
       void _UpdateLoadedPluginsInformation( );
       bool _InsertNewData( TDataObject* dobj, const std::string& parent );
 
     protected:
-      QWidget* m_Widget;
-      BasePluginsApplication* m_Application;
+      // MVC objects
+      QWidget*         m_Widget;
+      BaseApplication* m_Application;
 
-      TInterface              m_Interface;
-      TOrderedStringContainer m_LoadedPlugins;
-      std::string             m_LastLoadedPlugin;
+      // Plugins interface
+      TInterface*                               m_Interface;
+      TStringContainer                          m_LoadedPlugins;
+      std::string                               m_LastLoadedPlugin;
+      std::map< std::string, TStringContainer > m_LoadedFilters;
 
-      TProcessObject::Pointer              m_ImageReader;
-      TProcessObject::Pointer              m_ImageWriter;
-      TProcessObject::Pointer              m_MeshReader;
-      TProcessObject::Pointer              m_MeshWriter;
-      TProcessObject::Pointer              m_DicomSeriesReader;
-      TProcessObject::Pointer              m_ActiveFilter;
-      std::map< std::string, std::string > m_ActiveFilterOutputs;
-      TFilters m_Filters;
+      // Loaded filters
+      std::map< std::string, TProcessObject::Pointer > m_IOFilters;
+      TProcessObject::Pointer                       m_ActiveFilter;
+      std::map< std::string, std::string >   m_ActiveFilterOutputs;
 
-      // Loaded objects
-      TTree m_Objects;
+      // Loaded data objects
+      typedef std::pair< std::string, TDataObject::Pointer >  _TTreeNode;
+      std::map< std::string, _TTreeNode > m_DataObjects;
 
       // Associated interactors
       std::set< vtkRenderWindowInteractor* > m_Interactors;
@@ -156,6 +160,8 @@ namespace cpPlugins
 
 } // ecapseman
 
+#include <cpPlugins/Interface/Plugins.hxx>
+
 #endif // __CPPLUGINS__INTERFACE__PLUGINS__H__
 
 // eof - $RCSfile$
diff --git a/lib/cpPlugins/Interface/Plugins.hxx b/lib/cpPlugins/Interface/Plugins.hxx
new file mode 100644 (file)
index 0000000..b2bcd8a
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef __CPPLUGINS__INTERFACE__PLUGINS__HXX__
+#define __CPPLUGINS__INTERFACE__PLUGINS__HXX__
+
+// -------------------------------------------------------------------------
+template< class T >
+T* cpPlugins::Interface::Plugins::
+GetData( const std::string& name )
+{
+  auto dIt = this->m_DataObjects.find( name );
+  if( dIt != this->m_DataObjects.end( ) )
+    return( dynamic_cast< T* >( dIt->second.second.GetPointer( ) ) );
+  else
+    return( NULL );
+}
+
+// -------------------------------------------------------------------------
+template< class T >
+const T* cpPlugins::Interface::Plugins::
+GetData( const std::string& name ) const
+{
+  auto dIt = this->m_DataObjects.find( name );
+  if( dIt != this->m_DataObjects.end( ) )
+    return( dynamic_cast< const T* >( dIt->second.second.GetPointer( ) ) );
+  else
+    return( NULL );
+}
+
+#endif // __CPPLUGINS__INTERFACE__PLUGINS__HXX__
+
+// eof - $RCSfile$
index 6f3bd34e3d8e537e47282613974ae73f87548272..93d36d57b9a5f7bbc72908de9d2ab94dcd1b699b 100644 (file)
@@ -17,79 +17,6 @@ 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
-{
-  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
@@ -231,4 +158,7 @@ _AddInput( const std::string& name )
   this->Modified( );
 }
 
+// -------------------------------------------------------------------------
+CPPLUGINS_PROVIDER_SOURCE( cpPlugins::Interface::ProcessObject, 1, 1 );
+
 // eof - $RCSfile$
index 49f090711814a80cfac721e5d0f96b22b8ff1265..43533f5cda030a1e969f92d05a25e358650a6078 100644 (file)
@@ -1,33 +1,35 @@
 #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
 #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
 
-#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
+/*
+  #include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
 
-#include <map>
-#include <vector>
+  #include <map>
+  #include <vector>
 
-#include <cpPlugins/Interface/Config.h>
-#include <cpPlugins/Interface/Object.h>
+  #include <cpPlugins/Interface/Config.h>
+  #include <cpPlugins/Interface/DataObject.h>
+*/
 #include <cpPlugins/Interface/DataObject.h>
 #include <cpPlugins/Interface/Parameters.h>
 
-#ifdef cpPlugins_Interface_QT4
-class QWidget;
-#else
-typedef char QWidget;
-#endif // cpPlugins_Interface_QT4
-
 #include <itkProcessObject.h>
-
 #include <vtkSmartPointer.h>
 #include <vtkAlgorithm.h>
 
+// Some forward declarations
 class vtkRenderWindowInteractor;
+#ifdef cpPlugins_Interface_QT4
+class QWidget;
+#else
+typedef char QWidget;
+#endif // cpPlugins_Interface_QT4
 
 namespace cpPlugins
 {
   namespace Interface
   {
+    // Some forward declarations
     class Plugins;
 #ifdef cpPlugins_Interface_QT4
     class ParametersQtDialog;
@@ -57,24 +59,22 @@ namespace cpPlugins
 
     public:
       itkTypeMacro( ProcessObject, Object );
-      cpPlugins_Id_Macro(
-        cpPlugins::Interface::ProcessObject, "BaseObject"
-        );
+      cpPlugins_Id_Macro( ProcessObject, "BaseObject" );
 
-    public:
-      // To impact pipeline
-      virtual void Modified( ) const;
+      itkBooleanMacro( Interactive );
 
-      virtual bool IsInteractive( ) const;
-      virtual TParameters* GetParameters( );
-      virtual const TParameters* GetParameters( ) const;
+      itkGetConstObjectMacro( Parameters, TParameters );
+      itkGetObjectMacro( Parameters, TParameters );
+      itkGetConstMacro( Plugins, const Plugins* );
+      itkGetMacro( Plugins, Plugins* );
+      itkGetConstMacro( Interactive, bool );
 
-      Plugins* GetPlugins( );
-      const Plugins* GetPlugins( ) const;
-      void SetPlugins( Plugins* p );
+      itkSetObjectMacro( Plugins, Plugins );
+      itkSetMacro( Interactive, bool );
 
-      virtual unsigned int GetNumberOfInputs( ) const;
-      virtual unsigned int GetNumberOfOutputs( ) const;
+    public:
+      // To impact pipeline
+      virtual void Modified( ) const;
 
       virtual std::vector< std::string > GetInputsNames( ) const;
       virtual std::vector< std::string > GetOutputsNames( ) const;
@@ -140,12 +140,18 @@ namespace cpPlugins
       Parameters::Pointer m_Parameters;
       ParametersQtDialog* m_ParametersDialog;
       Plugins* m_Plugins;
+      bool m_Interactive;
 
       typedef std::map< std::string, DataObject::Pointer > _TDataContainer;
       _TDataContainer m_Inputs;
       _TDataContainer m_Outputs;
     };
 
+    /**
+     * Plugin provider
+     */
+    CPPLUGINS_PROVIDER_HEADER( ProcessObject );
+
   } // ecapseman
 
 } // ecapseman