]> Creatis software - cpPlugins.git/commitdiff
More on graph editor
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 11 Jan 2016 17:22:55 +0000 (12:22 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 11 Jan 2016 17:22:55 +0000 (12:22 -0500)
41 files changed:
appli/cpPipelineEditor/QNodesEditor.cxx
appli/cpPipelineEditor/cpPipelineEditor.cxx
appli/cpPipelineEditor/cpPipelineEditor.h
appli/cpPipelineEditor/main.cxx
appli/examples/example_LoadPlugins.cxx
appli/examples/example_LoadPluginsFromPath.cxx
data/workspace_00.xml
lib/cpExtensions/DataStructures/Graph.h
lib/cpExtensions/DataStructures/Graph.hxx
lib/cpPlugins/Interface/BaseProcessObjects.h
lib/cpPlugins/Interface/DataObject.h
lib/cpPlugins/Interface/Image.h
lib/cpPlugins/Interface/Interface.cxx
lib/cpPlugins/Interface/Interface.h
lib/cpPlugins/Interface/Macros.h
lib/cpPlugins/Interface/Mesh.h
lib/cpPlugins/Interface/Object.cxx
lib/cpPlugins/Interface/Object.h
lib/cpPlugins/Interface/Plugins.cxx
lib/cpPlugins/Interface/ProcessObject.h
lib/cpPlugins/Interface/Workspace.cxx
lib/cpPlugins/Interface/Workspace.h
lib/cpPlugins/Interface/WorkspaceIO.cxx
lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.h
lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h
lib/cpPlugins/Plugins/BasicFilters/Cutter.h
lib/cpPlugins/Plugins/BasicFilters/DoubleFloodImageFilter.h
lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.h
lib/cpPlugins/Plugins/BasicFilters/FloodFillImageFilter.h
lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.h
lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.h
lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.h
lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.h
lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h
lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.h
lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.h
lib/cpPlugins/Plugins/IO/DicomSeriesReader.h
lib/cpPlugins/Plugins/IO/ImageReader.h
lib/cpPlugins/Plugins/IO/ImageWriter.h
lib/cpPlugins/Plugins/IO/MeshReader.h
lib/cpPlugins/Plugins/IO/MeshWriter.h

index a499e94308c6339660ffbf26c4e11b9c0f50fc53..6417636e44ff256c6d30cbee0ce3786b5814e228 100644 (file)
@@ -76,8 +76,6 @@ workspace( ) const
 void PipelineEditor::QNodesEditor::\r
 setWorkspace( TWorkspace* ws )\r
 {\r
-  if( this->m_Workspace == ws )\r
-    return;\r
   this->m_Workspace = ws;\r
   this->m_Graph = TGraph::New( );\r
 \r
@@ -184,8 +182,6 @@ itemAt( const QPointF& pos )
   return( NULL );\r
 }\r
 \r
-#include <iostream>\r
-\r
 // -------------------------------------------------------------------------\r
 void PipelineEditor::QNodesEditor::\r
 _CreateBlock( TFilter* f, const QPointF& pnt )\r
@@ -196,7 +192,7 @@ _CreateBlock( TFilter* f, const QPointF& pnt )
   // Add block\r
   QNEBlock* b = new QNEBlock( 0, this->m_Scene );\r
   b->setNamePort( f->GetName( ) );\r
-  b->setTypePort( f->GetClassName( ).c_str( ) );\r
+  b->setTypePort( f->GetClassName( ) );\r
   // TODO: b->setScenePos( pnt );\r
 \r
   // Add input ports\r
@@ -212,7 +208,7 @@ _CreateBlock( TFilter* f, const QPointF& pnt )
     b->addOutputPort( oIt->c_str( ) );\r
 \r
   // Keep a trace of this visual graph\r
-  this->m_Graph->InsertVertex( f->GetName( ), b );\r
+  this->m_Graph->SetVertex( f->GetName( ), b );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
index 957158a565e54c937f6dc8047d2eeb36b2351abb..6bda2a75087139d916155dfd18612aca04a1ffc7 100644 (file)
 
 // -------------------------------------------------------------------------
 cpPipelineEditor::
-cpPipelineEditor( QWidget* parent )
+cpPipelineEditor( int argc, char* argv[], QWidget* parent )
   : QMainWindow( parent ),
     m_UI( new Ui::cpPipelineEditor ),
     m_Workspace( NULL )
 {
   this->m_UI->setupUi( this );
 
+  // Prepare plugins interface
+  this->m_Plugins = new cpPlugins::Interface::Interface( );
+  QFileInfo info( argv[ 0 ] );
+  if( info.exists( ) )
+  {
+    std::string path = info.canonicalPath( ).toStdString( );
+    if( !( this->m_Plugins->LoadDefaultConfiguration( path ) ) )
+      if( this->m_Plugins->LoadFromFolder( path, false ) )
+        if( !( this->m_Plugins->SaveDefaultConfiguration( path ) ) )
+          QMessageBox::critical(
+            this,
+            "Error creating default plugins configuration",
+            "Could not save default plugins configuration"
+            );
+    this->_UpdateLoadedPlugins( );
+
+  } // fi
+
+  // Create an empty workspace
+  this->m_Workspace = new cpPlugins::Interface::Workspace( );
+  this->m_Workspace->SetInterface( this->m_Plugins );
+  this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace );
+
   // Connect actions to slots
   cpPipelineEditor_ConnectButton( LoadPluginsFile );
   cpPipelineEditor_ConnectButton( LoadPluginsPath );
@@ -44,45 +67,52 @@ cpPipelineEditor::
   delete this->m_UI;
   if( this->m_Workspace != NULL )
     delete this->m_Workspace;
+  delete this->m_Plugins;
 }
 
 // -------------------------------------------------------------------------
 void cpPipelineEditor::
 _UpdateLoadedPlugins( )
 {
-  typedef cpPlugins::Interface::Workspace::TStringContainer _TStrings;
+  auto& classes = this->m_Plugins->GetClasses( );
 
-  if( this->m_Workspace == NULL )
+  if( classes.size( ) == 0 )
+  {
+    QMessageBox::critical(
+      this,
+      "Error loading default plugins",
+      "No plugins loaded: remember to load some!!!"
+      );
     return;
 
-  _TStrings categories;
-  this->m_Workspace->GetLoadedPluginCategories( categories );
-  for( auto cIt = categories.begin( ); cIt != categories.end( ); ++cIt )
+  } // fi
+
+  auto catIt = classes.begin( );
+  for( ; catIt != classes.end( ); ++catIt )
   {
     // Create or get category
     QList< QTreeWidgetItem* > cat_items =
       this->m_UI->LoadedPlugins->findItems(
-        cIt->c_str( ), Qt::MatchExactly | Qt::MatchRecursive
+        catIt->first.c_str( ), Qt::MatchExactly | Qt::MatchRecursive
         );
     QTreeWidgetItem* cat = NULL;
     if( cat_items.size( ) == 0 )
     {
       cat = new QTreeWidgetItem(
-        ( QTreeWidgetItem* )( NULL ), QStringList( cIt->c_str( ) )
+        ( QTreeWidgetItem* )( NULL ), QStringList( catIt->first.c_str( ) )
         );
       this->m_UI->LoadedPlugins->addTopLevelItem( cat );
     }
     else
       cat = cat_items[ 0 ];
 
-    // Add filters
-    _TStrings filters = this->m_Workspace->GetLoadedPluginFilters( *cIt );
-    for( auto fIt = filters.begin( ); fIt != filters.end( ); ++fIt )
+    // Create filters
+    auto fIt = catIt->second.begin( );
+    for( ; fIt != catIt->second.end( ); ++fIt )
     {
-      // Find filter
       QList< QTreeWidgetItem* > filter_items =
         this->m_UI->LoadedPlugins->findItems(
-          fIt->c_str( ), Qt::MatchExactly | Qt::MatchRecursive
+          fIt->first.c_str( ), Qt::MatchExactly | Qt::MatchRecursive
           );
       auto fiIt = filter_items.begin( );
       auto found_fiIt = filter_items.end( );
@@ -93,9 +123,8 @@ _UpdateLoadedPlugins( )
       // Add filter
       if( found_fiIt == filter_items.end( ) )
         QTreeWidgetItem* filter = new QTreeWidgetItem(
-          cat, QStringList( fIt->c_str( ) )
+          cat, QStringList( fIt->first.c_str( ) )
           );
-
     } // rof
 
   } // rof
@@ -118,15 +147,11 @@ _ButtonLoadPluginsFile( )
   if( !( dlg.exec( ) ) )
     return;
 
-  // Create a new workspace, if not ready
-  if( this->m_Workspace == NULL )
-    this->m_Workspace = new cpPlugins::Interface::Workspace( );
-
   // Read
   QStringList names = dlg.selectedFiles( );
   std::stringstream err_str;
   for( auto qIt = names.begin( ); qIt != names.end( ); ++qIt )
-    if( !( this->m_Workspace->LoadPlugins( qIt->toStdString( ) ) ) )
+    if( !( this->m_Plugins->Load( qIt->toStdString( ) ) ) )
       err_str << qIt->toStdString( ) << std::endl;
 
   // Show an error message
@@ -139,7 +164,6 @@ _ButtonLoadPluginsFile( )
       );
 
   // Update view
-  this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace );
   this->_UpdateLoadedPlugins( );
 }
 
@@ -153,13 +177,9 @@ _ButtonLoadPluginsPath( )
   if( !( dlg.exec( ) ) )
     return;
 
-  // Create a new workspace, if not ready
-  if( this->m_Workspace == NULL )
-    this->m_Workspace = new cpPlugins::Interface::Workspace( );
-
   // Read
   std::string dir = dlg.selectedFiles( ).begin( )->toStdString( );
-  if( !( this->m_Workspace->LoadPluginsPath( dir, false ) ) )
+  if( !( this->m_Plugins->LoadFromFolder( dir, false ) ) )
     QMessageBox::critical(
       this,
       "Error loading plugins directory",
@@ -167,7 +187,6 @@ _ButtonLoadPluginsPath( )
       );
 
   // Update view
-  this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace );
   this->_UpdateLoadedPlugins( );
 }
 
@@ -189,13 +208,9 @@ _ActionOpenWorkspace( )
   if( this->m_Workspace != NULL )
     delete this->m_Workspace;
   this->m_Workspace = new cpPlugins::Interface::Workspace( );
+  this->m_Workspace->SetInterface( this->m_Plugins );
   std::string err = this->m_Workspace->LoadWorkspace( fname );
-  if( err == "" )
-  {
-    this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace );
-    this->_UpdateLoadedPlugins( );
-  }
-  else
+  if( err != "" )
   {
     delete this->m_Workspace;
     this->m_Workspace = NULL;
@@ -204,8 +219,9 @@ _ActionOpenWorkspace( )
       QMessageBox::tr( "Error loading workspace" ),
       QMessageBox::tr( err.c_str( ) )
       );
-
-  } // fi
+  }
+  else
+    this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace );
 }
 
 // -------------------------------------------------------------------------
index 7192268911e3dbd816a59cd3a976aa812bab3a4d..811777838e198dd37f145e4cae2a439a4ec200f8 100644 (file)
@@ -15,6 +15,7 @@ namespace cpPlugins
   namespace Interface
   {
     class Workspace;
+    class Interface;
   }
 }
 
@@ -30,7 +31,10 @@ public:
   typedef QMainWindow      Superclass;
 
 public:
-  explicit cpPipelineEditor( QWidget* parent = 0 );
+  explicit cpPipelineEditor(
+    int argc, char* argv[],
+    QWidget* parent = 0
+    );
   virtual ~cpPipelineEditor( );
 
 protected:
@@ -45,6 +49,7 @@ protected slots:
 private:
   Ui::cpPipelineEditor* m_UI;
   cpPlugins::Interface::Workspace* m_Workspace;
+  cpPlugins::Interface::Interface* m_Plugins;
 };
 
 #endif // __CPPIPELINEEDITOR__H__
index 7154469095791cce503aae713bad7940473805a0..3dfe4645d3db2269cf7adbf1c24d49227d0db7f8 100644 (file)
@@ -6,7 +6,7 @@
 int main( int argc, char* argv[] )
 {
   QApplication a( argc, argv );
-  cpPipelineEditor w;
+  cpPipelineEditor w( argc, argv, NULL );
   w.show( );
 
   return( a.exec( ) );
index b68087cd655cbc3c662d486f44d772903f67a7ed..76c5febe6eb4b3e08dbb57fac3a80b9669dbeba0 100644 (file)
@@ -1,11 +1,10 @@
 #include <iostream>
 #include <string>
 
-#include <cpPlugins/Interface/Plugins.h>
+#include <cpPlugins/Interface/Interface.h>
 
 // -------------------------------------------------------------------------
-typedef cpPlugins::Interface::Plugins TPlugins;
-typedef TPlugins::TStringContainer    TStringContainer;
+typedef cpPlugins::Interface::Interface TInterface;
 
 // -------------------------------------------------------------------------
 int main( int argc, char* argv[] )
@@ -17,27 +16,32 @@ int main( int argc, char* argv[] )
 
   } // fi
 
-  // Create interface
-  cpPlugins::Interface::Plugins plugins;
+  // Create interface and load plugins
+  TInterface interface;
 
   for( int i = 1; i < argc; ++i )
-    if( !plugins.LoadPlugins( argv[ i ] ) )
+    if( !interface.Load( argv[ i ] ) )
       std::cerr
         << "Error loading plugins file \""
         << argv[ i ] << "\""
         << std::endl;
 
-  TStringContainer categories;
-  plugins.GetLoadedCategories( categories );
-  for( auto pIt = categories.begin( ); pIt != categories.end( ); ++pIt )
+  // Show info
+  auto i = interface.GetLoadedPlugins( ).begin( );
+  for( ; i != interface.GetLoadedPlugins( ).end( ); ++i )
   {
-    std::cout << "Category: " << *pIt << std::endl;
-    const TStringContainer& filters = plugins.GetLoadedFilters( *pIt );
-    for( auto fIt = filters.begin( ); fIt != filters.end( ); ++fIt )
-      std::cout << "\t" << *fIt << std::endl;
+    std::cout << "Folder: " << i->first << std::endl;
+    auto j = i->second.begin( );
+    for( ; j != i->second.end( ); ++j )
+      std::cout << "\tPlugin: " << *j << std::endl;
 
   } // rof
 
+  // Show loaded classes
+  auto c = interface.GetClasses( ).begin( );
+  for( ; c != interface.GetClasses( ).end( ); ++c )
+    std::cout << "Class -> " << c->first << std::endl;
+
   return( 0 );
 }
 
index 3747995dcb6c5f97b4a1a6432b2fe947cfccbd59..ba684ce52e9eeb39d704cfa9678fa72468747aa0 100644 (file)
@@ -1,11 +1,10 @@
 #include <iostream>
 #include <string>
 
-#include <cpPlugins/Interface/Plugins.h>
+#include <cpPlugins/Interface/Interface.h>
 
 // -------------------------------------------------------------------------
-typedef cpPlugins::Interface::Plugins TPlugins;
-typedef TPlugins::TStringContainer    TStringContainer;
+typedef cpPlugins::Interface::Interface TInterface;
 
 // -------------------------------------------------------------------------
 int main( int argc, char* argv[] )
@@ -17,31 +16,26 @@ int main( int argc, char* argv[] )
 
   } // fi
 
-  // Create interface
-  cpPlugins::Interface::Plugins plugins;
-
-  if( !plugins.LoadPluginsPath( argv[ 1 ] ) )
-    std::cerr
-      << "Error loading plugins from folder \""
-      << argv[ 1 ] << "\""
-      << std::endl;
-
-  const TStringContainer& loaded_plugins = plugins.GetLoadedPlugins( );
-  auto pIt = loaded_plugins.begin( );
-  for( ; pIt != loaded_plugins.end( ); ++pIt )
-    std::cout << "Plugin: " << *pIt << std::endl;
-  
-  TStringContainer categories;
-  plugins.GetLoadedCategories( categories );
-  for( auto cIt = categories.begin( ); cIt != categories.end( ); ++cIt )
+  // Create interface and load plugins
+  TInterface interface;
+  interface.LoadFromFolder( argv[ 1 ], true );
+
+  // Show info
+  auto i = interface.GetLoadedPlugins( ).begin( );
+  for( ; i != interface.GetLoadedPlugins( ).end( ); ++i )
   {
-    std::cout << "Category: " << *cIt << std::endl;
-    const TStringContainer& filters = plugins.GetLoadedFilters( *cIt );
-    for( auto fIt = filters.begin( ); fIt != filters.end( ); ++fIt )
-      std::cout << "\t" << *fIt << std::endl;
+    std::cout << "Folder: " << i->first << std::endl;
+    auto j = i->second.begin( );
+    for( ; j != i->second.end( ); ++j )
+      std::cout << "\tPlugin: " << *j << std::endl;
 
   } // rof
 
+    // Show loaded classes
+  auto c = interface.GetClasses( ).begin( );
+  for( ; c != interface.GetClasses( ).end( ); ++c )
+    std::cout << "Class -> " << c->first << std::endl;
+
   return( 0 );
 }
 
index 7f85219c09c5684ec77ae83cdedb905c941d34a6..cbf689bbae8033869a0c466fda9da9d65fbbe4e8 100644 (file)
@@ -1,6 +1,5 @@
 <?xml version="1.0" ?>
 <cpPlugins_Workspace>
-  <plugins_dir path="/home/leonardo/devel/cpPlugins/build" recursive="0"/>
   <filter class="cpPlugins::IO::ImageReader" name="reader">
     <parameter name="FileNames" type="StringList">
       <item value="test.mhd" />
index 5fb2707f5def3e5257054285d6805d59acd9e63f..b11b7031891437142ee70ce33dd3665dc872b3b4 100644 (file)
@@ -51,7 +51,8 @@ namespace cpExtensions
       void Clear( );
 
       bool HasVertexIndex( const I& index ) const;
-      void InsertVertex( const I& index, V& vertex );
+      void SetVertex( const I& index, V& vertex );
+      bool RenameVertex( const I& old_index, const I& new_index );
       V& GetVertex( const I& index );
       const V& GetVertex( const I& index ) const;
 
index c567f39dafe16c315623f3d20f20f423df68f1fc..d89be75d279fed8105849d18a16913f4d5d195eb 100644 (file)
@@ -93,11 +93,72 @@ HasVertexIndex( const I& index ) const
 // -------------------------------------------------------------------------
 template< class V, class C, class I >
 void cpExtensions::DataStructures::Graph< V, C, I >::
-InsertVertex( const I& index, V& vertex )
+SetVertex( const I& index, V& vertex )
 {
   this->m_Vertices[ index ] = vertex;
 }
 
+// -------------------------------------------------------------------------
+template< class V, class C, class I >
+bool cpExtensions::DataStructures::Graph< V, C, I >::
+RenameVertex( const I& old_index, const I& new_index )
+{
+  auto old_v = this->m_Vertices.find( old_index );
+  auto new_v = this->m_Vertices.find( new_index );
+  if( old_v != this->m_Vertices.end( ) && new_v == this->m_Vertices.end( ) )
+  {
+    // Replace vertex
+    typename TVertices::value_type new_entry( new_index, old_v->second );
+    new_v = this->m_Vertices.insert( new_entry ).first;
+    this->m_Vertices.erase( old_index );
+
+    // Duplicate edges
+    auto mIt = this->m_Matrix.begin( );
+    auto found_row = this->m_Matrix.end( );
+    for( ; mIt != this->m_Matrix.end( ); ++mIt )
+    {
+      if( mIt->first == old_index )
+        found_row = mIt;
+
+      auto rIt = mIt->second.begin( );
+      for( ; rIt != mIt->second.end( ); ++rIt )
+      {
+        if( mIt->first == old_index )
+          this->m_Matrix[ new_index ][ rIt->first ].push_back( rIt->second );
+        else if( rIt->first == old_index )
+          this->m_Matrix[ mIt->first ][ new_index ].push_back( rIt->second );
+
+      } // rof
+
+    } // rof
+
+    // Delete old edges
+    if( found_row != this->m_Matrix.end( ) )
+      this->m_Matrix.erase( found_row );
+
+    mIt = this->m_Matrix.begin( );
+    for( ; mIt != this->m_Matrix.end( ); ++mIt )
+    {
+      auto rIt = mIt->second.begin( );
+      while( rIt != mIt->second.end( ) )
+      {
+        if( rIt->first == old_index )
+        {
+          mIt->second.erase( rIt );
+          rIt = mIt->second.begin( );
+        }
+        else
+          ++rIt;
+
+      } // elihw
+
+    } // rof
+    return( true );
+  }
+  else
+    return( false );
+}
+
 // -------------------------------------------------------------------------
 template< class V, class C, class I >
 V& cpExtensions::DataStructures::Graph< V, C, I >::
index 1b2c8dbe7fec338ca546678635fb88f3db7d6ae9..a120b8446398233ca6a964161fb9ce0c2cc7b79d 100644 (file)
@@ -16,7 +16,7 @@
     typedef itk::SmartPointer< const Self > ConstPointer;               \
   public:                                                               \
     itkTypeMacro( O, S );                                               \
-    cpPlugins_Id_Macro( cpPlugins::Interface::O, "ProcessObject" );     \
+    cpPlugins_Id_Macro( cpPlugins::Interface::O, ProcessObject );       \
   protected:                                                            \
     O( );                                                               \
     virtual ~O( );                                                      \
index d90f8e960da95f0dd1ce834ce7a3ecf442a4ca33..05b70239dc06bda7ff7ac5e7451bbca89f050b95 100644 (file)
@@ -28,7 +28,7 @@ namespace cpPlugins
     public:
       itkNewMacro( Self );
       itkTypeMacro( DataObject, Object );
-      cpPlugins_Id_Macro( DataObject, "BasicObject" );
+      cpPlugins_Id_Macro( DataObject, BasicObject );
 
     public:
       ProcessObject* GetSource( );
index 30bfbf549cb1b725d32cc86063ae46b09d47649a..23e1c233c3d2d80748c4bc90b5ad807703a40dc0 100644 (file)
@@ -24,7 +24,7 @@ namespace cpPlugins
     public:
       itkNewMacro( Self );
       itkTypeMacro( Image, DataObject );
-      cpPlugins_Id_Macro( Image, "DataObject" );
+      cpPlugins_Id_Macro( Image, DataObject );
 
     public:
       template< class I >
index 494f1893bfab3fd2010b1aeea892d48f18f55c53..34dbf2e6fc186218481d1ebbfabd448bb64d4681 100644 (file)
@@ -1,4 +1,36 @@
 #include <cpPlugins/Interface/Interface.h>
+#include <cstdlib>
+#include <fstream>
+#include <sstream>
+
+#ifdef _WIN32
+#  define PLUGIN_PREFIX ""
+#  define PLUGIN_EXT ".dll"
+#else // Linux
+#  define PLUGIN_PREFIX "lib"
+#  define PLUGIN_EXT ".so"
+#endif // _WIN32
+#define PLUGIN_CONFIG_FILE "plugins.cfg"
+
+namespace cpPlugins
+{
+  namespace Interface
+  {
+    struct PathSeparator
+    {
+      bool operator()( char c ) const
+        {
+#ifdef _WIN32
+          return( c == '\\' || c == '/' );
+#else // Linux like
+          return( c == '/' );
+#endif // _WIN32
+        }
+    };
+
+  } // ecapseman
+
+} // ecapseman
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Interface::
@@ -14,6 +46,56 @@ cpPlugins::Interface::Interface::
   this->UnloadAll( );
 }
 
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Interface::
+LoadDefaultConfiguration( const std::string& path )
+{
+  std::ifstream file( PLUGIN_CONFIG_FILE );
+  if( file )
+  {
+    char buffer[ 1000 ];
+    while( file.getline( buffer, 1000 ) )
+    {
+      // std::string line( buffer );
+      std::istringstream line( buffer );
+      std::string name, folder;
+      std::getline( line, name, '@' );
+      std::getline( line, folder, '@' );
+      std::stringstream path;
+      path << folder << "/" << PLUGIN_PREFIX << name << PLUGIN_EXT;
+      this->Load( path.str( ) );
+
+    } // elihw
+
+    file.close( );
+    return( true );
+  }
+  else
+    return( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Interface::
+SaveDefaultConfiguration( const std::string& path )
+{
+  std::ofstream file( PLUGIN_CONFIG_FILE );
+  if( file )
+  {
+    auto pIt = this->m_LoadedPlugins.begin( );
+    for( ; pIt != this->m_LoadedPlugins.end( ); ++pIt )
+    {
+      auto fIt = pIt->second.begin( );
+      for( ; fIt != pIt->second.end( ); ++fIt )
+        file << *fIt << "@" << pIt->first << std::endl;
+
+    } // rof
+    file.close( );
+    return( true );
+  }
+  else
+    return( false );
+}
+
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Interface::
 TClasses& cpPlugins::Interface::Interface::
@@ -30,28 +112,52 @@ GetClasses( ) const
   return( this->m_Classes );
 }
 
+// -------------------------------------------------------------------------
+cpPlugins::Interface::Interface::
+TLoadedPlugins& cpPlugins::Interface::Interface::
+GetLoadedPlugins( )
+{
+  return( this->m_LoadedPlugins );
+}
+
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::Interface::
+TLoadedPlugins& cpPlugins::Interface::Interface::
+GetLoadedPlugins( ) const
+{
+  return( this->m_LoadedPlugins );
+}
+
 // -------------------------------------------------------------------------
 cpPlugins::Interface::ProcessObject::Pointer
 cpPlugins::Interface::Interface::
 CreateObject( const std::string& name ) const
 {
-  TClassesIterator cIt = this->m_Classes.find( name );
-  if( cIt != this->m_Classes.end( ) )
+  cpPlugins::Interface::ProcessObject::Pointer po = NULL;
+  auto catIt = this->m_Classes.begin( );
+  while( catIt != this->m_Classes.end( ) )
   {
-    ProcessObjectProvider* provider =
-      dynamic_cast< ProcessObjectProvider* >(
-        this->m_Providers[ cIt->second ]
-        );
-    if( provider != NULL )
+    auto classIt = catIt->second.find( name );
+    if( classIt != catIt->second.end( ) )
     {
-      cpPlugins::Interface::ProcessObject::Pointer po = provider->create( );
-      po->SetName( name );
-      return( po );
+      ProcessObjectProvider* provider =
+        dynamic_cast< ProcessObjectProvider* >(
+          this->m_Providers[ classIt->second ]
+          );
+      if( provider != NULL )
+      {
+        po = provider->create( );
+        po->SetName( name );
 
-    } // fi
+      } // fi
+      catIt = this->m_Classes.end( );
+    }
+    else
+      catIt++;
 
-  } // fi
-  return( NULL );
+  } // elihw
+
+  return( po );
 }
 
 // -------------------------------------------------------------------------
@@ -63,7 +169,13 @@ Load( const std::string& path )
   {
     ret = this->m_Pluma.load( path );
     if( ret )
+    {
+      std::string folder, name;
+      Self::_SepFName( path, folder, name );
+      this->m_LoadedPlugins[ folder ].push_back( name );
       this->_LoadClasses( );
+
+    } // fi
   }
   catch( ... )
   {
@@ -77,12 +189,28 @@ Load( const std::string& path )
 bool cpPlugins::Interface::Interface::
 Load( const std::string& folder, const std::string& name )
 {
+  std::string real_folder = folder;
+  PathSeparator sep;
+  if( sep( folder[ folder.size( ) - 1 ] ) )
+    real_folder = folder.substr( 0, folder.size( ) - 1 );
+  real_folder = std::string( realpath( real_folder.c_str( ), NULL ) );
   bool ret = true;
   try
   {
-    ret = this->m_Pluma.load( folder, name );
+    ret = this->m_Pluma.load( real_folder, name );
     if( ret )
+    {
+      // Update loaded plugins
+      std::string prefix( PLUGIN_PREFIX );
+      std::string ext( PLUGIN_EXT );
+      std::string real_name = name;
+      if( prefix != "" )
+        real_name.replace( real_name.find( prefix ), prefix.size( ), "" );
+      real_name.replace( real_name.find( ext ), ext.size( ), "" );
+      this->m_LoadedPlugins[ real_folder ].push_back( real_name );
       this->_LoadClasses( );
+
+    } // fi
   }
   catch( ... )
   {
@@ -93,20 +221,35 @@ Load( const std::string& folder, const std::string& name )
 }
 
 // -------------------------------------------------------------------------
-std::list< std::string > cpPlugins::Interface::Interface::
+bool cpPlugins::Interface::Interface::
 LoadFromFolder( const std::string& folder, bool r )
 {
-  std::list< std::string > files;
   try
   {
-    files = this->m_Pluma.loadFromFolder( folder, r );
-    if( files.size( ) > 0 )
+    std::list< std::string > f = this->m_Pluma.loadFromFolder( folder, r );
+    if( f.size( ) > 0 )
+    {
+      // Update loaded plugins
+      for( auto i = f.begin( ); i != f.end( ); ++i )
+      {
+        std::string folder, name;
+        Self::_SepFName( *i, folder, name );
+        this->m_LoadedPlugins[ folder ].push_back( name );
+
+      } // rof
+
+      // Load classes
       this->_LoadClasses( );
+      return( true );
+    }
+    else
+      return( false );
   }
   catch( ... )
   {
+    return( false );
+
   } // yrt
-  return( files );
 }
 
 // -------------------------------------------------------------------------
@@ -121,6 +264,9 @@ Unload( const std::string& name )
     {
       this->m_Providers.clear( );
       this->m_Classes.clear( );
+
+      // TODO: this->m_LoadedPlugins
+
       this->_LoadClasses( );
 
     } // fi
@@ -148,13 +294,7 @@ UnloadAll( )
   } // yrt
   this->m_Providers.clear( );
   this->m_Classes.clear( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Interface::
-GetLoadedPlugins( std::vector< const std::string* >& names ) const
-{
-  this->m_Pluma.getLoadedPlugins( names );
+  this->m_LoadedPlugins.clear( );
 }
 
 // -------------------------------------------------------------------------
@@ -175,10 +315,39 @@ _LoadClasses( )
   // Get reader provider
   for( unsigned int i = 0; i < this->m_Providers.size( ); ++i )
   {
-    ProcessObject::Pointer dummy = this->m_Providers[ i ]->create( );
-    this->m_Classes[ dummy->GetClassName( ) ] = i;
+    ProcessObject::Pointer d = this->m_Providers[ i ]->create( );
+    this->m_Classes[ d->GetClassCategory( ) ][ d->GetClassName( ) ] = i;
 
   } // rof
 }
 
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Interface::
+_SepFName( const std::string& path, std::string& folder, std::string& name )
+{
+  PathSeparator sep;
+
+  // Get absolute path
+  std::string real_path = std::string( realpath( path.c_str( ), NULL ) );
+
+  // Get name
+  name = std::string(
+    std::find_if( real_path.rbegin( ), real_path.rend( ), sep ).base( ),
+    real_path.end( )
+    );
+
+  // Get containing folder
+  folder = real_path;
+  folder.replace( folder.find( name ), name.size( ), "" );
+  if( sep( folder[ folder.size( ) - 1 ] ) )
+    folder = folder.substr( 0, folder.size( ) - 1 );
+
+  // Erase prefix and extension from filename
+  std::string prefix( PLUGIN_PREFIX );
+  std::string ext( PLUGIN_EXT );
+  if( prefix != "" )
+    name.replace( name.find( prefix ), prefix.size( ), "" );
+  name.replace( name.find( ext ), ext.size( ), "" );
+}
+
 // eof - $RCSfile$
index 34f29a80cdd11067a6a9e2b3318d7e5d573f9e59..2c4ad5e04877174831d3763229b10cde5610b7e2 100644 (file)
@@ -19,8 +19,13 @@ namespace cpPlugins
     class cpPlugins_Interface_EXPORT Interface
     {
     public:
+      typedef Interface Self;
       typedef std::vector< ProcessObjectProvider* > TProviders;
-      typedef std::map< std::string, unsigned int > TClasses;
+      typedef std::map< std::string, unsigned int > TClass;
+      typedef std::map< std::string, TClass >       TClasses;
+      typedef
+        std::map< std::string, std::vector< std::string > >
+        TLoadedPlugins;
 
       typedef TProviders::const_iterator TProvidersIterator;
       typedef TClasses::const_iterator   TClassesIterator;
@@ -29,29 +34,38 @@ namespace cpPlugins
       Interface( );
       virtual ~Interface( );
 
+      bool LoadDefaultConfiguration( const std::string& path );
+      bool SaveDefaultConfiguration( const std::string& path );
+
       // Plugin access
       TClasses& GetClasses( );
       const TClasses& GetClasses( ) const;
+      TLoadedPlugins& GetLoadedPlugins( );
+      const TLoadedPlugins& GetLoadedPlugins( ) const;
       ProcessObject::Pointer CreateObject( const std::string& name ) const;
 
       // Interface to PLUMA
       bool Load( const std::string& path );
       bool Load( const std::string& folder, const std::string& name );
-      std::list< std::string > LoadFromFolder(
-        const std::string& folder, bool r = false
-        );
+      bool LoadFromFolder( const std::string& folder, bool r = false );
       bool Unload( const std::string& name );
       void UnloadAll( );
-      void GetLoadedPlugins( std::vector< const std::string* >& names ) const;
       bool IsLoaded( const std::string& name ) const;
 
     protected:
       void _LoadClasses( );
 
+      static void _SepFName(
+        const std::string& path,
+        std::string& folder,
+        std::string& name
+        );
+
     protected:
-      pluma::Pluma m_Pluma;
-      TProviders   m_Providers;
-      TClasses     m_Classes;
+      pluma::Pluma   m_Pluma;
+      TProviders     m_Providers;
+      TClasses       m_Classes;
+      TLoadedPlugins m_LoadedPlugins;
     };
 
   } // ecapseman
index ef726ede4fcf724c05c70c3d6faf5c5c0495c707..90cea8c5fae400215e057e7e467c2fefa5908b4f 100644 (file)
@@ -8,8 +8,8 @@
 // -------------------------------------------------------------------------
 #define cpPlugins_Id_Macro( name, category )                            \
   public:                                                               \
-  virtual std::string GetClassName( ) { return( #name ); }              \
-  virtual std::string GetClassCategory( ) { return( category ); }
+  virtual const char* GetClassName( ) const     { return( #name ); }    \
+  virtual const char* GetClassCategory( ) const { return( #category ); }
 
 // -------------------------------------------------------------------------
 #define CPPLUGINS_PROVIDER_HEADER_BEGIN( TYPE )                 \
index 097ed30aad229972f007f789546a798929141894..e7692390bc46e12a2d2f663159d9c5ac5d56462d 100644 (file)
@@ -21,7 +21,7 @@ namespace cpPlugins
     public:
       itkNewMacro( Self );
       itkTypeMacro( Mesh, DataObject );
-      cpPlugins_Id_Macro( Mesh, "DataObject" );
+      cpPlugins_Id_Macro( Mesh, DataObject );
 
     public:
       template< class M >
index 85ef6a123f332d99ff8093906333cebe9fce8c3d..369b20f7cf79a04bc754d37556334b2b6dce1062 100644 (file)
@@ -4,7 +4,9 @@
 cpPlugins::Interface::Object::
 Object( )
   : Superclass( ),
-    m_Name( "" )
+    m_Name( "" ),
+    m_ViewX( float( 0 ) ),
+    m_ViewY( float( 0 ) )
 {
 }
 
index 03eb2ae1f912047a88153ad96031f91a7bb4e480..345be7f9cb8a9733bb2eb40636e9643e16c1b99c 100644 (file)
@@ -25,10 +25,22 @@ namespace cpPlugins
     public:
       itkNewMacro( Self );
       itkTypeMacro( Object, itkObject );
-      cpPlugins_Id_Macro( Object, "BaseObject" );
+      cpPlugins_Id_Macro( Object, BaseObject );
 
       itkGetStringMacro( Name );
+      itkGetConstMacro( ViewX, float );
+      itkGetConstMacro( ViewY, float );
+
       itkSetStringMacro( Name );
+      itkSetMacro( ViewX, float );
+      itkSetMacro( ViewY, float );
+
+    public:
+      inline float SetViewCoords( float x, float y )
+        {
+          this->SetViewX( x );
+          this->SetViewY( y );
+        }
 
     protected:
       Object( );
@@ -41,6 +53,7 @@ namespace cpPlugins
 
     protected:
       std::string m_Name;
+      float m_ViewX, m_ViewY;
     };
 
   } // ecapseman
index 62227a9d57115f4cf3380d9d863faf45e8ce6d4a..ece9dd0a5f93762b1be093a9f9a398897042f19e 100644 (file)
@@ -143,6 +143,7 @@ SetApplication( BaseApplication* a )
 bool cpPlugins::Interface::Plugins::
 LoadPluginsPath( const std::string& path, bool r )
 {
+  /* TODO
   this->BlockWidget( );
 
   // Load all plugins from given folder
@@ -166,6 +167,8 @@ LoadPluginsPath( const std::string& path, bool r )
 
   this->UnblockWidget( );
   return( ret );
+  */
+  return( false );
 }
 
 // -------------------------------------------------------------------------
index 6c6a8e7b468179cea12172a554d08c0add4c4abb..b6cf116e680d730dd7e35632673b64f6e1c2f1f8 100644 (file)
@@ -53,7 +53,7 @@ namespace cpPlugins
 
     public:
       itkTypeMacro( ProcessObject, Object );
-      cpPlugins_Id_Macro( ProcessObject, "BaseObject" );
+      cpPlugins_Id_Macro( ProcessObject, BaseObject );
 
       itkBooleanMacro( Interactive );
 
index fb8f91e5f55361a8a33e23e1804eaf3d7bed2dff..8a588afc4377279f49712bcf47aa3649ce004d85 100644 (file)
@@ -3,7 +3,7 @@
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Workspace::
 Workspace( )
-  : m_LastLoadedPlugin( "" )
+  : m_Interface( NULL )
 {
   this->m_Graph = TGraph::New( );
 }
@@ -15,95 +15,112 @@ cpPlugins::Interface::Workspace::
 }
 
 // -------------------------------------------------------------------------
-bool cpPlugins::Interface::Workspace::
-LoadPluginsPath( const std::string& path, bool r )
-{
-  // Load all plugins from given folder
-  std::list< std::string > files =
-    this->m_Interface.LoadFromFolder( path, r );
-
-  // Update a simple track
-  bool ret = false;
-  if( files.size( ) > 0 )
-  {
-    for( auto fIt = files.begin( ); fIt != files.end( ); ++fIt )
-    {
-      this->m_LoadedPlugins.insert( *fIt );
-      this->m_LastLoadedPlugin = *fIt;
-
-    } // rof
-    this->_UpdateLoadedPluginsInformation( );
-    ret = true;
-
-  } // fi
-  return( ret );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Workspace::
-LoadPlugins( const std::string& fname )
-{
-  // Is it already loaded?
-  bool ret = true;
-  if( this->m_LoadedPlugins.find( fname ) == this->m_LoadedPlugins.end( ) )
-  {
-    // Was it succesfully loaded?
-    ret = this->m_Interface.Load( fname );
-
-    // Update a simple track
-    if( ret )
-    {
-      this->m_LoadedPlugins.insert( fname );
-      this->m_LastLoadedPlugin = fname;
-      this->_UpdateLoadedPluginsInformation( );
-
-    } // fi
-
-  } // fi
-  return( ret );
-}
-
-// -------------------------------------------------------------------------
-const cpPlugins::Interface::Workspace::
-TStringContainer& cpPlugins::Interface::Workspace::
-GetLoadedPlugins( ) const
-{
-  return( this->m_LoadedPlugins );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Workspace::
-GetLoadedPluginCategories( TStringContainer& categories ) const
+cpPlugins::Interface::Workspace::
+TInterface* cpPlugins::Interface::Workspace::
+GetInterface( )
 {
-  categories.clear( );
-  auto fIt = this->m_LoadedFilters.begin( );
-  for( ; fIt != this->m_LoadedFilters.end( ); ++fIt )
-    categories.insert( fIt->first );
+  return( this->m_Interface );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Workspace::
-GetLoadedPluginFilters( TStringContainer& filters ) const
+SetInterface( TInterface* i )
 {
-  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 );
+  if( this->m_Interface != i )
+    this->m_Interface = i;
 }
 
-// -------------------------------------------------------------------------
-const cpPlugins::Interface::Workspace::
-TStringContainer& cpPlugins::Interface::Workspace::
-GetLoadedPluginFilters( const std::string& category ) const
-{
-  static const TStringContainer EMPTY;
-  auto pIt = this->m_LoadedFilters.find( category );
-  if( pIt != this->m_LoadedFilters.end( ) )
-    return( pIt->second );
-  else
-    return( EMPTY );
-}
+/* TODO
+   bool cpPlugins::Interface::Workspace::
+   LoadPluginsPath( const std::string& path, bool r )
+   {
+   // Load all plugins from given folder
+   std::list< std::string > files =
+   this->m_Interface.LoadFromFolder( path, r );
+   
+   // Update a simple track
+   bool ret = false;
+   if( files.size( ) > 0 )
+   {
+   for( auto fIt = files.begin( ); fIt != files.end( ); ++fIt )
+   {
+   this->m_LoadedPlugins.insert( *fIt );
+   this->m_LastLoadedPlugin = *fIt;
+   
+   } // rof
+   this->_UpdateLoadedPluginsInformation( );
+   ret = true;
+   
+   } // fi
+   return( ret );
+   }
+
+   // -------------------------------------------------------------------------
+   bool cpPlugins::Interface::Workspace::
+   LoadPlugins( const std::string& fname )
+   {
+   // Is it already loaded?
+   bool ret = true;
+   if( this->m_LoadedPlugins.find( fname ) == this->m_LoadedPlugins.end( ) )
+   {
+   // Was it succesfully loaded?
+   ret = this->m_Interface.Load( fname );
+   
+   // Update a simple track
+   if( ret )
+   {
+   this->m_LoadedPlugins.insert( fname );
+   this->m_LastLoadedPlugin = fname;
+   this->_UpdateLoadedPluginsInformation( );
+   
+   } // fi
+   
+   } // fi
+   return( ret );
+   }
+   
+   // -------------------------------------------------------------------------
+   const cpPlugins::Interface::Workspace::
+   TStringContainer& cpPlugins::Interface::Workspace::
+   GetLoadedPlugins( ) const
+   {
+   return( this->m_LoadedPlugins );
+   }
+   
+   // -------------------------------------------------------------------------
+   void cpPlugins::Interface::Workspace::
+   GetLoadedPluginCategories( TStringContainer& categories ) const
+   {
+   categories.clear( );
+   auto fIt = this->m_LoadedFilters.begin( );
+   for( ; fIt != this->m_LoadedFilters.end( ); ++fIt )
+   categories.insert( fIt->first );
+   }
+   
+   // -------------------------------------------------------------------------
+   void cpPlugins::Interface::Workspace::
+   GetLoadedPluginFilters( 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::Workspace::
+   TStringContainer& cpPlugins::Interface::Workspace::
+   GetLoadedPluginFilters( const std::string& category ) const
+   {
+   static const TStringContainer EMPTY;
+   auto pIt = this->m_LoadedFilters.find( category );
+   if( pIt != this->m_LoadedFilters.end( ) )
+   return( pIt->second );
+   else
+   return( EMPTY );
+   }
+*/
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Workspace::
@@ -133,15 +150,18 @@ GetGraph( ) const
 bool cpPlugins::Interface::Workspace::
 CreateFilter( const std::string& filter, const std::string& name )
 {
+  if( this->m_Interface == NULL )
+    return( false );
+
   // Get or create new filter from name
   if( !( this->m_Graph->HasVertexIndex( name ) ) )
   {
-    TFilter::Pointer f = this->m_Interface.CreateObject( filter );
+    TFilter::Pointer f = this->m_Interface->CreateObject( filter );
     if( f.IsNotNull( ) )
     {
       f->SetName( name );
       TObject::Pointer o = f.GetPointer( );
-      this->m_Graph->InsertVertex( name, o );
+      this->m_Graph->SetVertex( name, o );
       return( true );
     }
     else
@@ -301,16 +321,22 @@ Execute( const std::string& name, QWidget* p )
 void cpPlugins::Interface::Workspace::
 _UpdateLoadedPluginsInformation( )
 {
-  this->m_LoadedFilters.clear( );
-  const TInterface::TClasses& cls = this->m_Interface.GetClasses( );
-  for( auto i = cls.begin( ); i != cls.end( ); ++i )
-  {
-    TFilter::Pointer o = this->m_Interface.CreateObject( i->first );
-    std::string name = o->GetClassName( );
-    std::string category = o->GetClassCategory( );
-    this->m_LoadedFilters[ category ].insert( name );
-
-  } // rof
+  /* TODO
+     if( this->m_Interface != NULL )
+     {
+     this->m_LoadedFilters.clear( );
+     const TInterface::TClasses& cls = this->m_Interface->GetClasses( );
+     for( auto i = cls.begin( ); i != cls.end( ); ++i )
+     {
+     TFilter::Pointer o = this->m_Interface->CreateObject( i->first );
+     std::string name = o->GetClassName( );
+     std::string category = o->GetClassCategory( );
+     this->m_LoadedFilters[ category ].insert( name );
+
+     } // rof
+
+     } // fi
+  */
 }
 
 // eof - $RCSfile$
index 6618644ca582f19db5715f16e43306ebaa46649a..9a79d29ae15a3023b9b84eb26666cb7ce6c8c475 100644 (file)
@@ -41,14 +41,8 @@ namespace cpPlugins
       virtual ~Workspace( );
 
       // Plugins management
-      bool LoadPluginsPath( const std::string& path, bool r = false );
-      bool LoadPlugins( const std::string& fname );
-      const TStringContainer& GetLoadedPlugins( ) const;
-      void GetLoadedPluginCategories( TStringContainer& categories ) const;
-      void GetLoadedPluginFilters( TStringContainer& filters ) const;
-      const TStringContainer& GetLoadedPluginFilters(
-        const std::string& category
-        ) const;
+      TInterface* GetInterface( );
+      void SetInterface( TInterface* i );
 
       // Workspace IO
       std::string LoadWorkspace( const std::string& fname );
@@ -82,10 +76,7 @@ namespace cpPlugins
 
     protected:
       // Plugins interface
-      TInterface       m_Interface;
-      std::string      m_LastLoadedPlugin;
-      TStringContainer m_LoadedPlugins;
-      std::map< std::string, TStringContainer > m_LoadedFilters;
+      TInterface* m_Interface;
 
       // Processing graph
       typename TGraph::Pointer m_Graph;
index d1578ba12818ddb9a3070f113587fcffc473ae98..ce81b8639ff7089b188e6953ce1bb255dcabf8cf 100644 (file)
@@ -14,51 +14,25 @@ LoadWorkspace( const std::string& fname )
     return( "cpPlugins::Interface::Workspace: No valid workspace" );
   std::stringstream err;
 
-  // Read plugins files
-  TiXmlElement* plugins = root->FirstChildElement( "plugins" );
-  while( plugins != NULL )
-  {
-    const char* value = plugins->Attribute( "filename" );
-    if( value != NULL )
-    {
-      if( !( this->LoadPlugins( value ) ) )
-        err << "no valid plugins file \"" << value << "\"" << std::endl;
-
-    } // fi
-    plugins = plugins->NextSiblingElement( "plugins" );
-
-  } // elihw
-
-  // Read plugins paths
-  plugins = root->FirstChildElement( "plugins_dir" );
-  while( plugins != NULL )
-  {
-    const char* value = plugins->Attribute( "path" );
-    if( value != NULL )
-    {
-      int recursive;
-      if( plugins->QueryIntAttribute( "recursive", &recursive ) != TIXML_SUCCESS )
-        recursive = 0;
-      if( !( this->LoadPluginsPath( value, recursive == 1 ) ) )
-        err << "No valid plugins path \"" << value << "\"" << std::endl;
-
-    } // fi
-    plugins = plugins->NextSiblingElement( "plugins_dir" );
-
-  } // elihw
-
   // Read filters
   TiXmlElement* filter = root->FirstChildElement( "filter" );
   while( filter != NULL )
   {
     const char* class_value = filter->Attribute( "class" );
     const char* name_value = filter->Attribute( "name" );
+    float viewX = float( 0 );
+    float viewY = float( 0 );
+    filter->QueryFloatAttribute( "ViewX", &viewX );
+    filter->QueryFloatAttribute( "ViewY", &viewY );
     if( class_value != NULL && name_value != NULL )
     {
       if( this->CreateFilter( class_value, name_value ) )
       {
+        TFilter* new_filter = this->GetFilter( name_value );
+        new_filter->SetViewCoords( viewX, viewY );
+
         // Read parameters
-        TParameters* parameters = this->GetParameters( name_value );
+        TParameters* parameters = new_filter->GetParameters( );
         parameters->Clear( );
 
         TiXmlElement* param = filter->FirstChildElement( "parameter" );
@@ -162,19 +136,6 @@ SaveWorkspace( const std::string& fname ) const
   TiXmlDocument* doc = new TiXmlDocument( );
   TiXmlElement* root = new TiXmlElement( "cpPlugins_Workspace" );
 
-  // Save plugins
-  for(
-    auto plugIt = this->m_LoadedPlugins.begin( );
-    plugIt != this->m_LoadedPlugins.end( );
-    ++plugIt
-    )
-  {
-    TiXmlElement* plugin = new TiXmlElement( "plugins" );
-    plugin->SetAttribute( "filename", plugIt->c_str( ) );
-    root->LinkEndChild( plugin );
-
-  } // rof
-
   // Save vertices
   auto vIt = this->m_Graph->BeginVertices( );
   for( ; vIt != this->m_Graph->EndVertices( ); ++vIt )
@@ -184,8 +145,10 @@ SaveWorkspace( const std::string& fname ) const
     if( filter != NULL )
     {
       TiXmlElement* e = new TiXmlElement( "filter" );
-      e->SetAttribute( "class", filter->GetClassName( ).c_str( ) );
+      e->SetAttribute( "class", filter->GetClassName( ) );
       e->SetAttribute( "name", filter->GetName( ) );
+      e->SetAttribute( "ViewX", filter->GetViewX( ) );
+      e->SetAttribute( "ViewY", filter->GetViewY( ) );
 
       const TParameters* params = filter->GetParameters( );
       std::vector< std::string > names;
index 3ad43fe88cd52f8d7b83e2d4927603e9454ee515..92151bbfc030a4d9374b6747eccbc980bdbbfbef 100644 (file)
@@ -27,7 +27,7 @@ namespace cpPlugins
         );
       cpPlugins_Id_Macro(
         cpPlugins::BasicFilters::BinaryErodeImageFilter,
-        "ImageToBinaryImageFilter"
+        ImageToBinaryImageFilter
         );
 
     protected:
index 6f8331453195c61d06c8fbf4a1e00bcf7d79e61f..38ec83af2fa08961a6061362760a51cff902f1d1 100644 (file)
@@ -27,7 +27,7 @@ namespace cpPlugins
         );
       cpPlugins_Id_Macro(
         cpPlugins::BasicFilters::BinaryThresholdImageFilter,
-        "ImageToBinaryImageFilter"
+        ImageToBinaryImageFilter
         );
 
     protected:
index 8374bbcb69b1516d87a2f7d5dd8b16e32b4513a7..8f67a48b6ac462cb17431d525c0026d01456bce7 100644 (file)
@@ -23,8 +23,7 @@ namespace cpPlugins
       itkNewMacro( Self );
       itkTypeMacro( Cutter, cpPluginsInterfaceMeshToMeshFilter );
       cpPlugins_Id_Macro(
-        cpPlugins::BasicFilters::Cutter,
-        "MeshToMeshFilter"
+        cpPlugins::BasicFilters::Cutter, MeshToMeshFilter
         );
 
     protected:
index 730ffff65116fa40be380ef9a600097437abd378..3a887d06dc4964de69067c037a04166c78313a0c 100644 (file)
@@ -65,7 +65,7 @@ namespace cpPlugins
         );
       cpPlugins_Id_Macro(
         cpPlugins::BasicFilters::DoubleFloodImageFilter,
-        "ImageToBinaryImageFilter"
+        ImageToBinaryImageFilter
         );
 
     public:
index 39414ebbf77817ab130d895bef76e89f1ccb320c..e28ea6c3b6e9e8fde57dbc9958dadcddb45c9698 100644 (file)
@@ -26,7 +26,7 @@ namespace cpPlugins
         );
       cpPlugins_Id_Macro(
         cpPlugins::BasicFilters::ExtractSliceImageFilter,
-        "ImageToImageFilter"
+        ImageToImageFilter
         );
 
     protected:
index d6d61ea4be1570bc624612f26baa82f5d4ddd6db..1f70e9381e8d3e6c1d8c2be437eb41b0bd7061b8 100644 (file)
@@ -27,7 +27,7 @@ namespace cpPlugins
         );
       cpPlugins_Id_Macro(
         cpPlugins::BasicFilters::FloodFillImageFilter,
-        "ImageToBinaryImageFilter"
+        ImageToBinaryImageFilter
         );
 
     protected:
index ecd2ce6acdf8be2dc659d882cecaf9e544a60c99..a7461e17a34a1281405a04c8373a10ec05da233f 100644 (file)
@@ -76,7 +76,7 @@ namespace cpPlugins
       itkNewMacro( Self );
       itkTypeMacro( MacheteFilter, FilterObject );
       cpPlugins_Id_Macro(
-        cpPlugins::BasicFilters::MacheteFilter, "FilterObject"
+        cpPlugins::BasicFilters::MacheteFilter, FilterObject
         );
 
     public:
index 267f970e008fe47be1ca5fd5e7c8869f0b8de16e..e0208de07ca4b4a56d5d46a77dba0c4c7151ce96 100644 (file)
@@ -27,7 +27,7 @@ namespace cpPlugins
         );
       cpPlugins_Id_Macro(
         cpPlugins::BasicFilters::MacheteImageFilter,
-        "ImageToBinaryImageFilter"
+        ImageToBinaryImageFilter
         );
 
     protected:
index 2e664e5a3631fc869d8c61a1d2da91e29bc9c57b..d4b45b167057c6d2c8f587ddaee5b023d51d920a 100644 (file)
@@ -23,7 +23,7 @@ namespace cpPlugins
       itkNewMacro( Self );
       itkTypeMacro( MarchingCubes, cpPluginsInterfaceImageToMeshFilter );
       cpPlugins_Id_Macro(
-        cpPlugins::BasicFilters::MarchingCubes, "ImageToMeshFilter"
+        cpPlugins::BasicFilters::MarchingCubes, ImageToMeshFilter
         );
 
     protected:
index c036a1ed9f77593e10db9f779b14ccb7134a8c51..f7034d320b89aa0bdb2aa6cf10e360c5c77dc734 100644 (file)
@@ -27,7 +27,7 @@ namespace cpPlugins
         );
       cpPlugins_Id_Macro(
         cpPlugins::BasicFilters::MedianImageFilter,
-        "ImageToBinaryImageFilter"
+        ImageToBinaryImageFilter
         );
 
     protected:
index 671acb50a1518b053c6c57d5ce53b2d3f231c586..2e6f852e551ea8e315f3838efed4677537025448 100644 (file)
@@ -27,7 +27,7 @@ namespace cpPlugins
         );
       cpPlugins_Id_Macro(
         cpPlugins::BasicFilters::OtsuThresholdImageFilter,
-        "ImageToBinaryImageFilter"
+        ImageToBinaryImageFilter
         );
 
     protected:
index 4a42a5dc4041c347117f61fdc325f58688ad6204..9440cd02e68fbda83e609047b408acc4ba00f7a3 100644 (file)
@@ -27,7 +27,7 @@ namespace cpPlugins
         );
       cpPlugins_Id_Macro(
         cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter,
-        "ImageToImageFilter"
+        ImageToImageFilter
         );
 
     protected:
index 5789134e7fbb5a3c9e4316a3694d9b1256bad1f7..ef180ff2bc09bab73922b56cfa9a0cefe00e1ef1 100644 (file)
@@ -23,7 +23,7 @@ namespace cpPlugins
       itkNewMacro( Self );
       itkTypeMacro( SphereMeshSource, cpPluginsInterfaceMeshSource );
       cpPlugins_Id_Macro(
-        cpPlugins::BasicFilters::SphereMeshSource, "MeshSource"
+        cpPlugins::BasicFilters::SphereMeshSource, MeshSource
         );
 
     protected:
index c74d52ae4789ae4a4dfd4fa2cb8db951160bba18..fb8edb0df4e24379d68deebc749ce5cb372fd5e1 100644 (file)
@@ -32,7 +32,7 @@ namespace cpPlugins
     public:
       itkNewMacro( Self );
       itkTypeMacro( DicomSeriesReader, ImageReader );
-      cpPlugins_Id_Macro( cpPlugins::IO::DicomSeriesReader, "IO" );
+      cpPlugins_Id_Macro( cpPlugins::IO::DicomSeriesReader, IO );
 
     public:
       virtual DialogResult ExecConfigurationDialog( QWidget* parent );
index 50f0b0a7ec98fa7079a1333a65a46ab03c9153ac..520ab940340cbd601e12b075aa894ad817924714 100644 (file)
@@ -32,7 +32,7 @@ namespace cpPlugins
     public:
       itkNewMacro( Self );
       itkTypeMacro( ImageReader, cpPluginsInterfaceImageSource );
-      cpPlugins_Id_Macro( cpPlugins::IO::ImageReader, "IO" );
+      cpPlugins_Id_Macro( cpPlugins::IO::ImageReader, IO );
 
     public:
       virtual DialogResult ExecConfigurationDialog( QWidget* parent );
index 53947493d78397554ff5448c2f352f71ad376f43..0dd3a2532dfbb3b6ef36efd0bfd35fedf8863a22 100644 (file)
@@ -22,7 +22,7 @@ namespace cpPlugins
     public:
       itkNewMacro( Self );
       itkTypeMacro( ImageWriter, cpPluginsInterfaceImageSink );
-      cpPlugins_Id_Macro( cpPlugins::IO::ImageWriter, "IO" );
+      cpPlugins_Id_Macro( cpPlugins::IO::ImageWriter, IO );
 
     public:
       virtual DialogResult ExecConfigurationDialog( QWidget* parent );
index 6e18ff955d2be5bfe4a10870442d628ad8c0835e..c26c3ae64764ec7dd26c23ad7a50134debebd564 100644 (file)
@@ -24,7 +24,7 @@ namespace cpPlugins
     public:
       itkNewMacro( Self );
       itkTypeMacro( MeshReader, cpPluginsInterfaceMeshSource );
-      cpPlugins_Id_Macro( cpPlugins::IO::MeshReader, "IO" );
+      cpPlugins_Id_Macro( cpPlugins::IO::MeshReader, IO );
 
     public:
       virtual DialogResult ExecConfigurationDialog( QWidget* parent );
index 51224febb82b357755a5b20af2a47a90a4fe1a90..2dc64a64413d8eabec0af8653a6930312b5700ff 100644 (file)
@@ -24,7 +24,7 @@ namespace cpPlugins
     public:
       itkNewMacro( Self );
       itkTypeMacro( MeshWriter, cpPluginsInterfaceMeshSink );
-      cpPlugins_Id_Macro( cpPlugins::IO::MeshWriter, "IO" );
+      cpPlugins_Id_Macro( cpPlugins::IO::MeshWriter, IO );
 
     public:
       virtual DialogResult ExecConfigurationDialog( QWidget* parent );