]> Creatis software - cpPlugins.git/commitdiff
Now it's broken :-(
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 14 Jan 2016 22:21:57 +0000 (17:21 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 14 Jan 2016 22:21:57 +0000 (17:21 -0500)
30 files changed:
appli/CMakeLists.txt
appli/cpPipelineEditor/App_cpPipelineEditor.cxx [moved from appli/cpPipelineEditor/cpPipelineEditor.cxx with 88% similarity]
appli/cpPipelineEditor/App_cpPipelineEditor.h [moved from appli/cpPipelineEditor/cpPipelineEditor.h with 73% similarity]
appli/cpPipelineEditor/App_cpPipelineEditor.ui [moved from appli/cpPipelineEditor/cpPipelineEditor.ui with 94% similarity]
appli/cpPipelineEditor/CMakeLists.txt
appli/cpPipelineEditor/QNEBlock.h [deleted file]
appli/cpPipelineEditor/QNEConnection.h [deleted file]
appli/cpPipelineEditor/QNEPort.h [deleted file]
appli/cpPipelineEditor/QNodesEditor.cxx [deleted file]
appli/cpPipelineEditor/QNodesEditor.h [deleted file]
appli/cpPipelineEditor/main.cxx
lib/CMakeLists.txt
lib/cpExtensions/DataStructures/Graph.h
lib/cpExtensions/DataStructures/Graph.hxx
lib/cpPipelineEditor/Block.cxx [moved from appli/cpPipelineEditor/QNEBlock.cxx with 54% similarity]
lib/cpPipelineEditor/Block.h [new file with mode: 0644]
lib/cpPipelineEditor/CMakeLists.txt [new file with mode: 0644]
lib/cpPipelineEditor/Canvas.cxx [moved from appli/cpPipelineEditor/QNodesEditorCanvas.cxx with 86% similarity]
lib/cpPipelineEditor/Canvas.h [moved from appli/cpPipelineEditor/QNodesEditorCanvas.h with 57% similarity]
lib/cpPipelineEditor/Connection.cxx [moved from appli/cpPipelineEditor/QNEConnection.cxx with 51% similarity]
lib/cpPipelineEditor/Connection.h [new file with mode: 0644]
lib/cpPipelineEditor/Editor.cxx [new file with mode: 0644]
lib/cpPipelineEditor/Editor.h [new file with mode: 0644]
lib/cpPipelineEditor/Port.cxx [moved from appli/cpPipelineEditor/QNEPort.cxx with 62% similarity]
lib/cpPipelineEditor/Port.h [new file with mode: 0644]
lib/cpPlugins/Interface/Parameters.cxx
lib/cpPlugins/Interface/Parameters.h
lib/cpPlugins/Interface/Workspace.cxx
lib/cpPlugins/Interface/Workspace.h
lib/cpPlugins/Interface/WorkspaceIO.cxx

index 6e0414cde64c3cc7d7213340cc8ca7dad3540b98..1f50ec7bb34715ceb88097e460e20e303b2504e2 100644 (file)
@@ -6,8 +6,12 @@ IF(BUILD_EXAMPLES)
   SUBDIRS(
     examples
     ImageMPR
-    cpPipelineEditor
     )
+  IF(USE_QT4)
+    SUBDIRS(
+      cpPipelineEditor
+      )
+  ENDIF(USE_QT4)
 ENDIF(BUILD_EXAMPLES)
 
 ## eof - $RCSfile$
similarity index 88%
rename from appli/cpPipelineEditor/cpPipelineEditor.cxx
rename to appli/cpPipelineEditor/App_cpPipelineEditor.cxx
index 6bda2a75087139d916155dfd18612aca04a1ffc7..8c0a1559a9319eb9a23f8562f49d290c34414b9b 100644 (file)
@@ -1,31 +1,31 @@
-#include "cpPipelineEditor.h"
-#include "ui_cpPipelineEditor.h"
+#include "App_cpPipelineEditor.h"
+#include "ui_App_cpPipelineEditor.h"
 
-#include "QNodesEditor.h"
+#include <cpPipelineEditor/Editor.h>
 
 #include <QFileDialog>
 #include <QMessageBox>
 #include <cpPlugins/Interface/Workspace.h>
 
 // -------------------------------------------------------------------------
-#define cpPipelineEditor_ConnectAction( ACTION )        \
+#define App_cpPipelineEditor_ConnectAction( ACTION )    \
   QObject::connect(                                     \
     this->m_UI->Action##ACTION, SIGNAL( triggered( ) ), \
     this, SLOT( _Action##ACTION( ) )                    \
     )
 
 // -------------------------------------------------------------------------
-#define cpPipelineEditor_ConnectButton( BUTTON )        \
+#define App_cpPipelineEditor_ConnectButton( BUTTON )    \
   QObject::connect(                                     \
     this->m_UI->Button##BUTTON, SIGNAL( clicked( ) ),   \
     this, SLOT( _Button##BUTTON( ) )                    \
     )
 
 // -------------------------------------------------------------------------
-cpPipelineEditor::
-cpPipelineEditor( int argc, char* argv[], QWidget* parent )
+App_cpPipelineEditor::
+App_cpPipelineEditor( int argc, char* argv[], QWidget* parent )
   : QMainWindow( parent ),
-    m_UI( new Ui::cpPipelineEditor ),
+    m_UI( new Ui::App_cpPipelineEditor ),
     m_Workspace( NULL )
 {
   this->m_UI->setupUi( this );
@@ -50,19 +50,19 @@ cpPipelineEditor( int argc, char* argv[], QWidget* parent )
 
   // Create an empty workspace
   this->m_Workspace = new cpPlugins::Interface::Workspace( );
-  this->m_Workspace->SetInterface( this->m_Plugins );
+  this->m_Workspace->SetPlugins( this->m_Plugins );
   this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace );
 
   // Connect actions to slots
-  cpPipelineEditor_ConnectButton( LoadPluginsFile );
-  cpPipelineEditor_ConnectButton( LoadPluginsPath );
-  cpPipelineEditor_ConnectAction( OpenWorkspace );
-  cpPipelineEditor_ConnectAction( SaveWorkspace );
+  App_cpPipelineEditor_ConnectButton( LoadPluginsFile );
+  App_cpPipelineEditor_ConnectButton( LoadPluginsPath );
+  App_cpPipelineEditor_ConnectAction( OpenWorkspace );
+  App_cpPipelineEditor_ConnectAction( SaveWorkspace );
 }
 
 // -------------------------------------------------------------------------
-cpPipelineEditor::
-~cpPipelineEditor( )
+App_cpPipelineEditor::
+~App_cpPipelineEditor( )
 {
   delete this->m_UI;
   if( this->m_Workspace != NULL )
@@ -71,7 +71,7 @@ cpPipelineEditor::
 }
 
 // -------------------------------------------------------------------------
-void cpPipelineEditor::
+void App_cpPipelineEditor::
 _UpdateLoadedPlugins( )
 {
   auto& classes = this->m_Plugins->GetClasses( );
@@ -131,7 +131,7 @@ _UpdateLoadedPlugins( )
 }
 
 // -------------------------------------------------------------------------
-void cpPipelineEditor::
+void App_cpPipelineEditor::
 _ButtonLoadPluginsFile( )
 {
   QFileDialog dlg( this );
@@ -168,7 +168,7 @@ _ButtonLoadPluginsFile( )
 }
 
 // -------------------------------------------------------------------------
-void cpPipelineEditor::
+void App_cpPipelineEditor::
 _ButtonLoadPluginsPath( )
 {
   QFileDialog dlg( this );
@@ -191,7 +191,7 @@ _ButtonLoadPluginsPath( )
 }
 
 // -------------------------------------------------------------------------
-void cpPipelineEditor::
+void App_cpPipelineEditor::
 _ActionOpenWorkspace( )
 {
   QFileDialog dlg( this );
@@ -208,7 +208,7 @@ _ActionOpenWorkspace( )
   if( this->m_Workspace != NULL )
     delete this->m_Workspace;
   this->m_Workspace = new cpPlugins::Interface::Workspace( );
-  this->m_Workspace->SetInterface( this->m_Plugins );
+  this->m_Workspace->SetPlugins( this->m_Plugins );
   std::string err = this->m_Workspace->LoadWorkspace( fname );
   if( err != "" )
   {
@@ -225,7 +225,7 @@ _ActionOpenWorkspace( )
 }
 
 // -------------------------------------------------------------------------
-void cpPipelineEditor::
+void App_cpPipelineEditor::
 _ActionSaveWorkspace( )
 {
   if( this->m_Workspace == NULL )
similarity index 73%
rename from appli/cpPipelineEditor/cpPipelineEditor.h
rename to appli/cpPipelineEditor/App_cpPipelineEditor.h
index 811777838e198dd37f145e4cae2a439a4ec200f8..9d0d99a1998d91b48daf1c3caee3a2e4d87554ed 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __CPPIPELINEEDITOR__H__
-#define __CPPIPELINEEDITOR__H__
+#ifndef __APP_CPPIPELINEEDITOR__H__
+#define __APP_CPPIPELINEEDITOR__H__
 
 // Qt stuff
 #include <QMainWindow>
@@ -7,7 +7,7 @@
 // -------------------------------------------------------------------------
 namespace Ui
 {
-  class cpPipelineEditor;
+  class App_cpPipelineEditor;
 }
 
 namespace cpPlugins
@@ -21,21 +21,21 @@ namespace cpPlugins
 
 /**
  */
-class cpPipelineEditor
+class App_cpPipelineEditor
   : public QMainWindow
 {
   Q_OBJECT;
 
 public:
-  typedef cpPipelineEditor Self;
+  typedef App_cpPipelineEditor Self;
   typedef QMainWindow      Superclass;
 
 public:
-  explicit cpPipelineEditor(
+  explicit App_cpPipelineEditor(
     int argc, char* argv[],
     QWidget* parent = 0
     );
-  virtual ~cpPipelineEditor( );
+  virtual ~App_cpPipelineEditor( );
 
 protected:
   void _UpdateLoadedPlugins( );
@@ -47,7 +47,7 @@ protected slots:
   void _ActionSaveWorkspace( );
 
 private:
-  Ui::cpPipelineEditor* m_UI;
+  Ui::App_cpPipelineEditor* m_UI;
   cpPlugins::Interface::Workspace* m_Workspace;
   cpPlugins::Interface::Interface* m_Plugins;
 };
similarity index 94%
rename from appli/cpPipelineEditor/cpPipelineEditor.ui
rename to appli/cpPipelineEditor/App_cpPipelineEditor.ui
index 5fa8eb0e1ed2383fe109720037438ddd59dd9358..faf921784bbe044e61d5e7e178bc5f056ceb9eee 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0">
- <class>cpPipelineEditor</class>
- <widget class="QMainWindow" name="cpPipelineEditor">
+ <class>App_cpPipelineEditor</class>
+ <widget class="QMainWindow" name="App_cpPipelineEditor">
   <property name="geometry">
    <rect>
     <x>0</x>
         </item>
        </layout>
       </widget>
-      <widget class="PipelineEditor::QNodesEditorCanvas" name="Canvas" native="true">
+      <widget class="cpPipelineEditor::Canvas" name="Canvas" native="true">
        <property name="minimumSize">
         <size>
          <width>500</width>
  </widget>
  <customwidgets>
   <customwidget>
-   <class>PipelineEditor::QNodesEditorCanvas</class>
+   <class>cpPipelineEditor::Canvas</class>
    <extends>QWidget</extends>
-   <header>QNodesEditorCanvas.h</header>
+   <header>cpPipelineEditor/Canvas.h</header>
    <container>1</container>
   </customwidget>
  </customwidgets>
   <connection>
    <sender>ActionExit</sender>
    <signal>triggered()</signal>
-   <receiver>cpPipelineEditor</receiver>
+   <receiver>App_cpPipelineEditor</receiver>
    <slot>close()</slot>
    <hints>
     <hint type="sourcelabel">
index 14874c5f12b19d111dd1b1d13c92d121063e2880..82013817e8524dd70cae74a3ff1a2e3af2761dc1 100644 (file)
@@ -1,79 +1,50 @@
-IF(USE_QT4)
-  SET(App_NAME "cpPipelineEditor")
-
-  ## ====================================================
-  ## = Source code, user interafaces and resources here =
-  ## ====================================================
-
-  SET(App_SOURCE_DIR "${PROJECT_SOURCE_DIR}/appli/${App_NAME}")
-  SET(App_BINARY_DIR "${PROJECT_BINARY_DIR}/appli/${App_NAME}")
-
-  SET(
-    App_QT_SOURCES
-    QNEBlock.cxx
-    QNEConnection.cxx
-    QNEPort.cxx
-    QNodesEditor.cxx
-    QNodesEditorCanvas.cxx
-    #QNEMainWindow.cxx
-    #Edge.cxx
-    #GraphCanvas.cxx
-    #Node.cxx
-    cpPipelineEditor.cxx
-    )
-  SET(
-    App_SOURCES
-    main.cxx
-    )
-  SET(
-    App_QT_HEADERS
-    QNodesEditor.h
-    QNodesEditorCanvas.h
-    #QNEMainWindow.h
-    #GraphCanvas.h
-    cpPipelineEditor.h
-    )
-  SET(
-    App_HEADERS
-    )
-  FILE(GLOB App_QT_UI  "${App_SOURCE_DIR}/*.ui")
-  FILE(GLOB App_QT_RES "${App_SOURCE_DIR}/*.qrc")
-
-  ## =====================
-  ## = Compilation rules =
-  ## =====================
-  INCLUDE_DIRECTORIES(
-    ${App_SOURCE_DIR}
-    ${App_BINARY_DIR}
-    )
-
-  QT4_WRAP_UI(App_QT_UI_Headers ${App_QT_UI})
-  QT4_WRAP_CPP(App_QT_HEADERS_MOC_SOURCES ${App_QT_HEADERS})
-  QT4_ADD_RESOURCES(App_QT_RES_SOURCES ${App_QT_RES})
-
-  SET(GUI_TYPE "")
-  IF(WIN32)
-    SET(GUI_TYPE WIN32)
-  ENDIF(WIN32)
-  IF(APPLE)
-    SET(GUI_TYPE MACOSX_BUNDLE)
-  ENDIF(APPLE)
-
-  ADD_EXECUTABLE(
-    ${App_NAME}
-    ${GUI_TYPE}
-    ${App_QT_UI_Headers}
-    ${App_SOURCES}
-    ${App_QT_SOURCES}
-    ${App_QT_HEADERS_MOC_SOURCES}
-    ${App_QT_RES_SOURCES}
-    )
-  TARGET_LINK_LIBRARIES(
-    ${App_NAME}
-    ${QT_LIBRARIES}
-    cpExtensions
-    cpPlugins_Interface
-       )
-ENDIF(USE_QT4)
-
-## eof - $RCSfile$
+SET(App_NAME "App_cpPipelineEditor")
+SET(Dir_NAME "cpPipelineEditor")
+
+## ====================================================
+## = Source code, user interafaces and resources here =
+## ====================================================
+
+SET(App_SOURCE_DIR "${PROJECT_SOURCE_DIR}/appli/${Dir_NAME}")
+SET(App_BINARY_DIR "${PROJECT_BINARY_DIR}/appli/${Dir_NAME}")
+SET(App_QT_SOURCES App_cpPipelineEditor.cxx)
+SET(App_SOURCES    main.cxx)
+SET(App_QT_HEADERS App_cpPipelineEditor.h)
+FILE(GLOB App_QT_UI  "${App_SOURCE_DIR}/*.ui")
+FILE(GLOB App_QT_RES "${App_SOURCE_DIR}/*.qrc")
+
+## =====================
+## = Compilation rules =
+## =====================
+INCLUDE_DIRECTORIES(
+  ${App_SOURCE_DIR}
+  ${App_BINARY_DIR}
+  )
+
+QT4_WRAP_UI(App_QT_UI_Headers ${App_QT_UI})
+QT4_WRAP_CPP(App_QT_HEADERS_MOC_SOURCES ${App_QT_HEADERS})
+QT4_ADD_RESOURCES(App_QT_RES_SOURCES ${App_QT_RES})
+
+SET(GUI_TYPE "")
+IF(WIN32)
+  SET(GUI_TYPE WIN32)
+ENDIF(WIN32)
+IF(APPLE)
+  SET(GUI_TYPE MACOSX_BUNDLE)
+ENDIF(APPLE)
+
+ADD_EXECUTABLE(
+  ${App_NAME}
+  ${GUI_TYPE}
+  ${App_QT_UI_Headers}
+  ${App_SOURCES}
+  ${App_QT_SOURCES}
+  ${App_QT_HEADERS_MOC_SOURCES}
+  ${App_QT_RES_SOURCES}
+  )
+TARGET_LINK_LIBRARIES(
+  ${App_NAME}
+  cpPipelineEditor
+  )
+
+# ## eof - $RCSfile$
diff --git a/appli/cpPipelineEditor/QNEBlock.h b/appli/cpPipelineEditor/QNEBlock.h
deleted file mode 100644 (file)
index 8e95ce0..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/* Copyright (c) 2012, STANISLAW ADASZEWSKI\r
-   All rights reserved.\r
-\r
-   Redistribution and use in source and binary forms, with or without\r
-   modification, are permitted provided that the following conditions are met:\r
-   * Redistributions of source code must retain the above copyright\r
-   notice, this list of conditions and the following disclaimer.\r
-   * Redistributions in binary form must reproduce the above copyright\r
-   notice, this list of conditions and the following disclaimer in the\r
-   documentation and/or other materials provided with the distribution.\r
-   * Neither the name of STANISLAW ADASZEWSKI nor the\r
-   names of its contributors may be used to endorse or promote products\r
-   derived from this software without specific prior written permission.\r
-\r
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
-   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
-   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
-   DISCLAIMED. IN NO EVENT SHALL STANISLAW ADASZEWSKI BE LIABLE FOR ANY\r
-   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
-   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
-   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
-   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
-   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-*/\r
-\r
-#ifndef __PIPELINEEDITOR__QNEBLOCK__H__\r
-#define __PIPELINEEDITOR__QNEBLOCK__H__\r
-\r
-#include <QGraphicsPathItem>\r
-#include <cpPlugins/Interface/ProcessObject.h>\r
-\r
-namespace PipelineEditor\r
-{\r
-  class QNEPort;\r
-  class QNENamePort;\r
-  class QNETypePort;\r
-  class QNEInputPort;\r
-  class QNEOutputPort;\r
-  class QNEConnection;\r
-\r
-  class QNEBlock\r
-    : public QGraphicsPathItem\r
-  {\r
-  public:\r
-    typedef QNEBlock          Self;\r
-    typedef QGraphicsPathItem Superclass;\r
-    typedef cpPlugins::Interface::ProcessObject TFilter;\r
-  \r
-  public:\r
-    enum { Type = QGraphicsItem::UserType + 6 };\r
-\r
-    QNEBlock(\r
-      TFilter* filter,\r
-      QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL\r
-      );\r
-    virtual ~QNEBlock( );\r
-\r
-    void setNamePort( const QString& txt );\r
-    QNEInputPort* addInputPort( const QString& txt );\r
-    QNEOutputPort* addOutputPort( const QString& txt );\r
-\r
-    bool extendInputPort( const QString& txt, QNEConnection* conn );\r
-    bool extendOutputPort( const QString& txt, QNEConnection* conn );\r
-\r
-    QNEInputPort* inputPort( const QString& txt );\r
-    QNEOutputPort* outputPort( const QString& txt );\r
-\r
-    QString namePort( ) const;\r
-    const QNEInputPort* inputPort( const QString& txt ) const;\r
-    const QNEOutputPort* outputPort( const QString& txt ) const;\r
-    const QNEConnection* extendedInputPort( const QString& txt ) const;\r
-    const QNEConnection* extendedOutputPort( const QString& txt ) const;\r
-\r
-    inline int type( ) const\r
-      { return( this->Type ); }\r
-\r
-    virtual void paint(\r
-      QPainter* painter,\r
-      const QStyleOptionGraphicsItem* option,\r
-      QWidget* widget\r
-      );\r
-    \r
-  protected:\r
-    QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
-    void _setTypePort( const QString& txt );\r
-    void _configPort( QNEPort* port );\r
-\r
-    virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* evt );\r
-\r
-  private:\r
-    int m_HorzMargin;\r
-    int m_VertMargin;\r
-    int m_Width;\r
-    int m_Height;\r
-\r
-    QNENamePort* m_NamePort;\r
-    QNETypePort* m_TypePort;\r
-    std::map< std::string, QNEInputPort* >  m_InputPorts;\r
-    std::map< std::string, QNEOutputPort* > m_OutputPorts;\r
-    std::map< std::string, QNEConnection* > m_ExtOutputPorts;\r
-    std::map< std::string, QNEConnection* > m_ExtInputPorts;\r
-\r
-    TFilter::Pointer m_Filter;\r
-  };\r
-\r
-} // ecapseman\r
-\r
-#endif // __PIPELINEEDITOR__QNEBLOCK__H__\r
-\r
-// eof - $RCSfile$\r
diff --git a/appli/cpPipelineEditor/QNEConnection.h b/appli/cpPipelineEditor/QNEConnection.h
deleted file mode 100644 (file)
index bbed7dd..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Copyright (c) 2012, STANISLAW ADASZEWSKI\r
-   All rights reserved.\r
-\r
-   Redistribution and use in source and binary forms, with or without\r
-   modification, are permitted provided that the following conditions are met:\r
-   * Redistributions of source code must retain the above copyright\r
-   notice, this list of conditions and the following disclaimer.\r
-   * Redistributions in binary form must reproduce the above copyright\r
-   notice, this list of conditions and the following disclaimer in the\r
-   documentation and/or other materials provided with the distribution.\r
-   * Neither the name of STANISLAW ADASZEWSKI nor the\r
-   names of its contributors may be used to endorse or promote products\r
-   derived from this software without specific prior written permission.\r
-\r
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
-   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
-   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
-   DISCLAIMED. IN NO EVENT SHALL STANISLAW ADASZEWSKI BE LIABLE FOR ANY\r
-   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
-   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
-   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
-   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
-   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-*/\r
-\r
-#ifndef __PIPELINEEDITOR__QNECONNECTION__H__\r
-#define __PIPELINEEDITOR__QNECONNECTION__H__\r
-\r
-#include <QGraphicsPathItem>\r
-\r
-namespace PipelineEditor\r
-{\r
-  class QNEInputPort;\r
-  class QNEOutputPort;\r
-\r
-  /**\r
-   */\r
-  class QNEConnection\r
-    : public QGraphicsPathItem\r
-  {\r
-  public:\r
-    typedef QNEConnection     Self;\r
-    typedef QGraphicsPathItem Superclass;\r
-\r
-  public:\r
-    enum { Type = QGraphicsItem::UserType + 5 };\r
-\r
-    QNEConnection( QGraphicsItem* parent = 0, QGraphicsScene* scene = 0 );\r
-    virtual ~QNEConnection( );\r
-\r
-    void setPos1( const QPointF& p );\r
-    void setPos2( const QPointF& p );\r
-    void setPort1( QNEOutputPort* p );\r
-    void setPort2( QNEInputPort* p );\r
-    void updatePosFromPorts( );\r
-    void updatePath( );\r
-    QNEOutputPort* port1( ) const;\r
-    QNEInputPort* port2( ) const;\r
-\r
-    inline int type( ) const\r
-      { return( this->Type ); }\r
-\r
-  private:\r
-    QPointF m_Pos1;\r
-    QPointF m_Pos2;\r
-    QNEOutputPort* m_Port1;\r
-    QNEInputPort*  m_Port2;\r
-  };\r
-\r
-} // ecapseman\r
-\r
-#endif // __PIPELINEEDITOR__QNECONNECTION__H__\r
-\r
-// eof - $RCSfile$\r
diff --git a/appli/cpPipelineEditor/QNEPort.h b/appli/cpPipelineEditor/QNEPort.h
deleted file mode 100644 (file)
index e10af5e..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-/* Copyright (c) 2012, STANISLAW ADASZEWSKI\r
-   All rights reserved.\r
-\r
-   Redistribution and use in source and binary forms, with or without\r
-   modification, are permitted provided that the following conditions are met:\r
-   * Redistributions of source code must retain the above copyright\r
-   notice, this list of conditions and the following disclaimer.\r
-   * Redistributions in binary form must reproduce the above copyright\r
-   notice, this list of conditions and the following disclaimer in the\r
-   documentation and/or other materials provided with the distribution.\r
-   * Neither the name of STANISLAW ADASZEWSKI nor the\r
-   names of its contributors may be used to endorse or promote products\r
-   derived from this software without specific prior written permission.\r
-\r
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
-   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
-   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
-   DISCLAIMED. IN NO EVENT SHALL STANISLAW ADASZEWSKI BE LIABLE FOR ANY\r
-   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
-   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
-   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
-   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
-   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-*/\r
-\r
-#ifndef __PIPELINEEDITOR__QNEPORT__H__\r
-#define __PIPELINEEDITOR__QNEPORT__H__\r
-\r
-#include <QGraphicsPathItem>\r
-\r
-namespace PipelineEditor\r
-{\r
-  class QNEBlock;\r
-  class QNEConnection;\r
-\r
-  /**\r
-   */\r
-  class QNEPort\r
-    : public QGraphicsPathItem\r
-  {\r
-  public:\r
-    typedef QNEPort Self;\r
-    typedef QGraphicsPathItem Superclass;\r
-\r
-    enum { Type = QGraphicsItem::UserType + 1 };\r
-\r
-  public:\r
-    QNEPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
-    virtual ~QNEPort( );\r
-\r
-    void setBlock( QNEBlock* b );\r
-    inline QNEBlock* block( ) const\r
-      { return( this->m_Block ); }\r
-\r
-    virtual void setName( const QString& n );\r
-    virtual void setExtendedName( const QString& n );\r
-    inline QString name( ) const\r
-      { return( this->m_Label->toPlainText( ) ); }\r
-    inline QString extendedName( ) const\r
-      { return( this->m_ExtendedLabel->toPlainText( ) ); }\r
-\r
-    inline int radius( ) const\r
-      { return( this->m_Radius ); }\r
-\r
-    inline bool isExtended( ) const\r
-      { return( this->m_IsExtended ); }\r
-    virtual void setExtend( bool extend );\r
-\r
-    virtual bool isConnected( QNEPort* other ) = 0;\r
-    inline int type( ) const\r
-      { return( this->Type ); }\r
-\r
-    virtual void paint(\r
-      QPainter* painter,\r
-      const QStyleOptionGraphicsItem* option,\r
-      QWidget* widget\r
-      );\r
-\r
-  protected:\r
-    virtual void _updateLabels( ) { }\r
-\r
-  protected:\r
-    QNEBlock* m_Block;\r
-\r
-    int  m_Radius;\r
-    int  m_Margin;\r
-    bool m_IsExtended;\r
-\r
-    QGraphicsTextItem* m_Label;\r
-    QGraphicsTextItem* m_ExtendedLabel;\r
-  };\r
-\r
-  /**\r
-   */\r
-  class QNENamePort\r
-    : public QNEPort\r
-  {\r
-  public:\r
-    typedef QNENamePort Self;\r
-    typedef QNEPort     Superclass;\r
-\r
-    enum { Type = Superclass::Type + 1 };\r
-\r
-  public:\r
-    QNENamePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
-    virtual ~QNENamePort( );\r
-\r
-    virtual bool isConnected( QNEPort* other );\r
-    inline int type( ) const\r
-      { return( this->Type ); }\r
-\r
-  protected:\r
-    virtual void _updateLabels( );\r
-  };\r
-\r
-  /**\r
-   */\r
-  class QNETypePort\r
-    : public QNEPort\r
-  {\r
-  public:\r
-    typedef QNETypePort Self;\r
-    typedef QNEPort     Superclass;\r
-\r
-    enum { Type = Superclass::Type + 2 };\r
-\r
-  public:\r
-    QNETypePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
-    virtual ~QNETypePort( );\r
-\r
-    virtual bool isConnected( QNEPort* other );\r
-    inline int type( ) const\r
-      { return( this->Type ); }\r
-\r
-  protected:\r
-    virtual void _updateLabels( );\r
-  };\r
-\r
-  /**\r
-   */\r
-  class QNEInputPort\r
-    : public QNEPort\r
-  {\r
-  public:\r
-    typedef QNEInputPort Self;\r
-    typedef QNEPort      Superclass;\r
-\r
-    enum { Type = Superclass::Type + 3 };\r
-\r
-  public:\r
-    QNEInputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
-    virtual ~QNEInputPort( );\r
-\r
-    virtual void setExtend( bool extend );\r
-\r
-    virtual bool isConnected( QNEPort* other );\r
-    inline int type( ) const\r
-      { return( this->Type ); }\r
-\r
-    void setConnection( QNEConnection* c );\r
-    inline QNEConnection* connection( )\r
-      { return( this->m_Connection ); }\r
-    inline const QNEConnection* connection( ) const\r
-      { return( this->m_Connection ); }\r
-    inline bool hasConnection( ) const\r
-      { return( this->m_Connection != NULL ); }\r
-\r
-  protected:\r
-    QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
-    virtual void _updateLabels( );\r
-\r
-  protected:\r
-    QNEConnection* m_Connection;\r
-  };\r
-\r
-  /**\r
-   */\r
-  class QNEOutputPort\r
-    : public QNEPort\r
-  {\r
-  public:\r
-    typedef QNEOutputPort Self;\r
-    typedef QNEPort       Superclass;\r
-\r
-    enum { Type = Superclass::Type + 4 };\r
-\r
-  public:\r
-    QNEOutputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
-    virtual ~QNEOutputPort( );\r
-\r
-    virtual void setExtend( bool extend );\r
-\r
-    virtual bool isConnected( QNEPort* other );\r
-    inline int type( ) const\r
-      { return( this->Type ); }\r
-\r
-    inline QVector< QNEConnection* >& connections( )\r
-      { return( this->m_Connections ); }\r
-    inline const QVector< QNEConnection* >& connections( ) const\r
-      { return( this->m_Connections ); }\r
-\r
-  protected:\r
-    QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
-    virtual void _updateLabels( );\r
-\r
-  protected:\r
-    QVector< QNEConnection* > m_Connections;\r
-  };\r
-\r
-} // ecapseman\r
-\r
-#endif // __PIPELINEEDITOR__QNEPORT__H__\r
-\r
-// eof - $RCSfile$\r
diff --git a/appli/cpPipelineEditor/QNodesEditor.cxx b/appli/cpPipelineEditor/QNodesEditor.cxx
deleted file mode 100644 (file)
index 46508ca..0000000
+++ /dev/null
@@ -1,596 +0,0 @@
-/* Copyright (c) 2012, STANISLAW ADASZEWSKI\r
-   All rights reserved.\r
-\r
-   Redistribution and use in source and binary forms, with or without\r
-   modification, are permitted provided that the following conditions are met:\r
-   * Redistributions of source code must retain the above copyright\r
-   notice, this list of conditions and the following disclaimer.\r
-   * Redistributions in binary form must reproduce the above copyright\r
-   notice, this list of conditions and the following disclaimer in the\r
-   documentation and/or other materials provided with the distribution.\r
-   * Neither the name of STANISLAW ADASZEWSKI nor the\r
-   names of its contributors may be used to endorse or promote products\r
-   derived from this software without specific prior written permission.\r
-\r
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
-   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
-   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
-   DISCLAIMED. IN NO EVENT SHALL STANISLAW ADASZEWSKI BE LIABLE FOR ANY\r
-   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
-   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
-   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
-   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
-   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-*/\r
-\r
-#include "QNodesEditor.h"\r
-\r
-#include <QGraphicsScene>\r
-#include <QEvent>\r
-#include <QGraphicsSceneContextMenuEvent>\r
-#include <QGraphicsSceneDragDropEvent>\r
-#include <QGraphicsSceneHelpEvent>\r
-#include <QGraphicsSceneHoverEvent>\r
-#include <QGraphicsSceneMouseEvent>\r
-#include <QGraphicsSceneMoveEvent>\r
-#include <QGraphicsSceneResizeEvent>\r
-#include <QGraphicsSceneWheelEvent>\r
-#include <QInputDialog>\r
-\r
-#include "QNEPort.h"\r
-#include "QNEConnection.h"\r
-#include "QNEBlock.h"\r
-\r
-// -------------------------------------------------------------------------\r
-#define PipelineEditor_QNodesEditor_Callback_SWITCH( E, e )             \\r
-  case QEvent::E:                                                       \\r
-  {                                                                     \\r
-    Q##E##Event* evt = dynamic_cast< Q##E##Event* >( e );               \\r
-    if( evt != NULL )                                                   \\r
-      this->_##E##_cbk( evt );                                          \\r
-  }                                                                     \\r
-  break\r
-\r
-// -------------------------------------------------------------------------\r
-#define PipelineEditor_QNodesEditor_Callback_CODE( E )                  \\r
-  void PipelineEditor::QNodesEditor::_##E##_cbk( Q##E##Event* evt )\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor::QNodesEditor::\r
-QNodesEditor( QObject* parent )\r
- : Superclass( parent ),\r
-   m_Conn( NULL ),\r
-   m_Workspace( NULL )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor::QNodesEditor::\r
-~QNodesEditor( )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor::QNodesEditor::\r
-TWorkspace* PipelineEditor::QNodesEditor::\r
-workspace( )\r
-{\r
-  return( this->m_Workspace );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-const PipelineEditor::QNodesEditor::\r
-TWorkspace* PipelineEditor::QNodesEditor::\r
-workspace( ) const\r
-{\r
-  return( this->m_Workspace );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-void PipelineEditor::QNodesEditor::\r
-setWorkspace( TWorkspace* ws )\r
-{\r
-  this->m_Workspace = ws;\r
-  this->m_Graph = TGraph::New( );\r
-\r
-  // Create blocks\r
-  auto vIt = this->m_Workspace->GetGraph( )->BeginVertices( );\r
-  auto vIt_end = this->m_Workspace->GetGraph( )->EndVertices( );\r
-  for( ; vIt != vIt_end; ++vIt )\r
-  {\r
-    this->_CreateBlock(\r
-      dynamic_cast< TFilter* >( vIt->second.GetPointer( ) ),\r
-      QPointF( vIt->second->GetViewX( ), vIt->second->GetViewY( ) )\r
-      );\r
-\r
-  } // rof\r
-\r
-  // Add edges\r
-  auto rIt = this->m_Workspace->GetGraph( )->BeginEdgesRows( );\r
-  auto rIt_end = this->m_Workspace->GetGraph( )->EndEdgesRows( );\r
-  for( ; rIt != rIt_end; ++rIt )\r
-  {\r
-    QNEBlock* orig = this->m_Graph->GetVertex( rIt->first );\r
-    auto cIt = rIt->second.begin( );\r
-    for( ; cIt != rIt->second.end( ); ++cIt )\r
-    {\r
-      QNEBlock* dest = this->m_Graph->GetVertex( cIt->first );\r
-      auto eIt = cIt->second.begin( );\r
-      for( ; eIt != cIt->second.end( ); ++eIt )\r
-      {\r
-        QNEOutputPort* op = orig->outputPort( eIt->first.c_str( ) );\r
-        QNEInputPort* ip = dest->inputPort( eIt->second.c_str( ) );\r
-        if( op == NULL || ip == NULL )\r
-          continue;\r
-\r
-        QNEConnection* c = new QNEConnection( 0, this->m_Scene );\r
-        c->setPort1( op );\r
-        c->setPort2( ip );\r
-        c->updatePosFromPorts( );\r
-        c->updatePath( );\r
-        this->m_Graph->AddConnection( rIt->first, cIt->first, c );\r
-\r
-      } // rof\r
-\r
-    } // rof\r
-\r
-  } // rof\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-std::string PipelineEditor::QNodesEditor::\r
-createFilter( const std::string& filter, const QPointF& pnt )\r
-{\r
-  std::string name = filter;\r
-  while( this->m_Workspace->HasFilter( name ) )\r
-    name += std::string( "_" );\r
-  if( this->m_Workspace->CreateFilter( filter, name ) )\r
-  {\r
-    this->_CreateBlock( this->m_Workspace->GetFilter( name ), pnt );\r
-    return( name );\r
-  }\r
-  else\r
-    return( "" );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-void PipelineEditor::QNodesEditor::\r
-install( QGraphicsScene* s )\r
-{\r
-  s->installEventFilter( this );\r
-  this->m_Scene = s;\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-QGraphicsItem* PipelineEditor::QNodesEditor::\r
-itemAt( const QPointF& pos )\r
-{\r
-  QList< QGraphicsItem* > items =\r
-    this->m_Scene->items( QRectF( pos - QPointF( 1, 1 ), QSize( 3, 3 ) ) );\r
-\r
-  foreach( QGraphicsItem* item, items )\r
-    if( item->type( ) > QGraphicsItem::UserType )\r
-      return( item );\r
-  return( NULL );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-void PipelineEditor::QNodesEditor::\r
-_CreateBlock( TFilter* f, const QPointF& pnt )\r
-{\r
-  if( f == NULL )\r
-    return;\r
-\r
-  // Add block\r
-  QNEBlock* b = new QNEBlock( f, 0, this->m_Scene );\r
-  b->setPos( pnt );\r
-\r
-  // Keep a trace of this visual graph\r
-  this->m_Graph->SetVertex( f->GetName( ), b );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-/* TODO\r
-void PipelineEditor::QNodesEditor::\r
-_DoubleClick( QGraphicsSceneMouseEvent* evt, QGraphicsItem* item )\r
-{\r
-  switch( evt->button( ) )\r
-  {\r
-  case Qt::LeftButton:\r
-  {\r
-    QNEBlock* block = dynamic_cast< QNEBlock* >( item );\r
-    QNEPort* port = dynamic_cast< QNEPort* >( item );\r
-    QNEConnection* conn = dynamic_cast< QNEConnection* >( item );\r
-\r
-    if( block != NULL )\r
-    {\r
-      QString old_name = block->namePort( );\r
-      bool ok;\r
-      QString new_name =\r
-        QInputDialog::getText(\r
-          dynamic_cast< QWidget* >( this->parent( ) ),\r
-          "Change filter name",\r
-          "Filter name:",\r
-          QLineEdit::Normal,\r
-          old_name,\r
-          &ok\r
-          );\r
-      if( ok && !new_name.isEmpty( ) && old_name != new_name )\r
-      {\r
-        ok = this->m_Graph->RenameVertex(\r
-          old_name.toStdString( ),\r
-          new_name.toStdString( )\r
-          );\r
-        if( ok )\r
-        {\r
-          block->setNamePort( new_name );\r
-          this->m_Workspace->GetGraph( )->RenameVertex(\r
-            old_name.toStdString( ),\r
-            new_name.toStdString( )\r
-            );\r
-\r
-        } // fi\r
-\r
-      } // fi\r
-    }\r
-    else if( port != NULL )\r
-    {\r
-    }\r
-    else if( conn != NULL )\r
-    {\r
-    } // fi\r
-  }\r
-  break;\r
-     case Qt::RightButton:\r
-     {\r
-     }\r
-     break;\r
-     case Qt::MiddleButton:\r
-     {\r
-     }\r
-     break;\r
-  default:\r
-    break;\r
-  } // hctiws\r
-}\r
-  */\r
-\r
-// -------------------------------------------------------------------------\r
-bool PipelineEditor::QNodesEditor::\r
-eventFilter( QObject* o, QEvent* e )\r
-{\r
-  // Event type\r
-  switch( int( e->type( ) ) )\r
-  {\r
-    PipelineEditor_QNodesEditor_Callback_SWITCH( GraphicsSceneContextMenu, e );\r
-    PipelineEditor_QNodesEditor_Callback_SWITCH( GraphicsSceneDragEnter, e );\r
-    PipelineEditor_QNodesEditor_Callback_SWITCH( GraphicsSceneDragLeave, e );\r
-    PipelineEditor_QNodesEditor_Callback_SWITCH( GraphicsSceneDragMove, e );\r
-    PipelineEditor_QNodesEditor_Callback_SWITCH( GraphicsSceneDrop, e );\r
-    PipelineEditor_QNodesEditor_Callback_SWITCH( GraphicsSceneHelp, e );\r
-    PipelineEditor_QNodesEditor_Callback_SWITCH( GraphicsSceneHoverEnter, e );\r
-    PipelineEditor_QNodesEditor_Callback_SWITCH( GraphicsSceneHoverLeave, e );\r
-    PipelineEditor_QNodesEditor_Callback_SWITCH( GraphicsSceneHoverMove, e );\r
-    PipelineEditor_QNodesEditor_Callback_SWITCH( GraphicsSceneMouseDoubleClick, e );\r
-    PipelineEditor_QNodesEditor_Callback_SWITCH( GraphicsSceneMouseMove, e );\r
-    PipelineEditor_QNodesEditor_Callback_SWITCH( GraphicsSceneMousePress, e );\r
-    PipelineEditor_QNodesEditor_Callback_SWITCH( GraphicsSceneMouseRelease, e );\r
-    PipelineEditor_QNodesEditor_Callback_SWITCH( GraphicsSceneMove, e );\r
-    PipelineEditor_QNodesEditor_Callback_SWITCH( GraphicsSceneResize, e );\r
-    PipelineEditor_QNodesEditor_Callback_SWITCH( GraphicsSceneWheel, e );\r
-  default:\r
-    break;\r
-  } // hctiws\r
-\r
-  return( this->Superclass::eventFilter( o, e ) );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor_QNodesEditor_Callback_CODE( GraphicsSceneContextMenu )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor_QNodesEditor_Callback_CODE( GraphicsSceneDragEnter )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor_QNodesEditor_Callback_CODE( GraphicsSceneDragLeave )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor_QNodesEditor_Callback_CODE( GraphicsSceneDragMove )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor_QNodesEditor_Callback_CODE( GraphicsSceneDrop )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor_QNodesEditor_Callback_CODE( GraphicsSceneHelp )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor_QNodesEditor_Callback_CODE( GraphicsSceneHoverEnter )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor_QNodesEditor_Callback_CODE( GraphicsSceneHoverLeave )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor_QNodesEditor_Callback_CODE( GraphicsSceneHoverMove )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor_QNodesEditor_Callback_CODE( GraphicsSceneMouseDoubleClick )\r
-{\r
-  QGraphicsItem* item = this->itemAt( evt->scenePos( ) );\r
-  if( item == NULL )\r
-    return;\r
-\r
-  switch( evt->button( ) )\r
-  {\r
-  case Qt::LeftButton:\r
-  {\r
-    QNEBlock* block = dynamic_cast< QNEBlock* >( item );\r
-    QNEPort* port = dynamic_cast< QNEPort* >( item );\r
-    QNEConnection* conn = dynamic_cast< QNEConnection* >( item );\r
-\r
-    if( block != NULL )\r
-    {\r
-      QString old_name = block->namePort( );\r
-      bool ok;\r
-      QString new_name =\r
-        QInputDialog::getText(\r
-          dynamic_cast< QWidget* >( this->parent( ) ),\r
-          "Change filter name",\r
-          "Filter name:",\r
-          QLineEdit::Normal,\r
-          old_name,\r
-          &ok\r
-          );\r
-      if( ok && !new_name.isEmpty( ) && old_name != new_name )\r
-      {\r
-        ok = this->m_Graph->RenameVertex(\r
-          old_name.toStdString( ),\r
-          new_name.toStdString( )\r
-          );\r
-        if( ok )\r
-        {\r
-          block->setNamePort( new_name );\r
-          this->m_Workspace->GetGraph( )->RenameVertex(\r
-            old_name.toStdString( ),\r
-            new_name.toStdString( )\r
-            );\r
-\r
-        } // fi\r
-\r
-      } // fi\r
-    }\r
-    else if( port != NULL )\r
-    {\r
-      if( evt->modifiers( ) == Qt::ControlModifier )\r
-      {\r
-        port->setExtend( !( port->isExtended( ) ) );\r
-        QNEInputPort* in_port = dynamic_cast< QNEInputPort* >( port );\r
-        QNEOutputPort* out_port = dynamic_cast< QNEOutputPort* >( port );\r
-        if( port->isExtended( ) )\r
-        {\r
-          if( in_port != NULL )\r
-          {\r
-            this->m_Workspace->AddInputPort(\r
-              in_port->extendedName( ).toStdString( ),\r
-              in_port->block( )->namePort( ).toStdString( ),\r
-              in_port->name( ).toStdString( )\r
-              );\r
-          }\r
-          else if( out_port != NULL )\r
-          {\r
-          } // fi\r
-        }\r
-        else\r
-        {\r
-          if( in_port != NULL )\r
-          {\r
-          }\r
-          else if( out_port != NULL )\r
-          {\r
-          } // fi\r
-\r
-        } // fi\r
-        this->m_Scene->update( );\r
-      }\r
-      else if( evt->modifiers( ) == Qt::NoModifier )\r
-      {\r
-        if( port->isExtended( ) )\r
-        {\r
-          QString old_name = port->extendedName( );\r
-          bool ok;\r
-          QString new_name =\r
-            QInputDialog::getText(\r
-              dynamic_cast< QWidget* >( this->parent( ) ),\r
-              "Change filter name",\r
-              "Filter name:",\r
-              QLineEdit::Normal,\r
-              old_name,\r
-              &ok\r
-              );\r
-          if( ok && !new_name.isEmpty( ) && old_name != new_name )\r
-          {\r
-            // TODO: port->setExtendedName( new_name );\r
-            /* TODO\r
-               ok = this->m_Graph->RenameVertex(\r
-               old_name.toStdString( ),\r
-               new_name.toStdString( )\r
-               );\r
-               if( ok )\r
-               {\r
-               block->setNamePort( new_name );\r
-               this->m_Workspace->GetGraph( )->RenameVertex(\r
-               old_name.toStdString( ),\r
-               new_name.toStdString( )\r
-               );\r
-\r
-               } // fi\r
-            */\r
-          } // fi\r
-\r
-        } // fi\r
-\r
-      } // fi\r
-    }\r
-    else if( conn != NULL )\r
-    {\r
-    } // fi\r
-  }\r
-  break;\r
-  /* TODO:\r
-     case Qt::RightButton:\r
-     {\r
-     }\r
-     break;\r
-     case Qt::MiddleButton:\r
-     {\r
-     }\r
-     break;\r
-  */\r
-  default:\r
-    break;\r
-  } // hctiws\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor_QNodesEditor_Callback_CODE( GraphicsSceneMouseMove )\r
-{\r
-  if( this->m_Conn != NULL )\r
-  {\r
-    if( this->m_Conn->port1( ) == NULL )\r
-      this->m_Conn->setPos1( evt->scenePos( ) );\r
-    else if( this->m_Conn->port2( ) == NULL )\r
-      this->m_Conn->setPos2( evt->scenePos( ) );\r
-    this->m_Conn->updatePath( );\r
-\r
-  } // fi\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor_QNodesEditor_Callback_CODE( GraphicsSceneMousePress )\r
-{\r
-  QNEInputPort* in_port =\r
-    dynamic_cast< QNEInputPort* >( this->itemAt( evt->scenePos( ) ) );\r
-  QNEOutputPort* out_port =\r
-    dynamic_cast< QNEOutputPort* >( this->itemAt( evt->scenePos( ) ) );\r
-  if( in_port == NULL && out_port == NULL )\r
-    return;\r
-\r
-  switch( evt->button( ) )\r
-  {\r
-  case Qt::LeftButton:\r
-  {\r
-    if( out_port != NULL )\r
-    {\r
-      if( out_port->block( ) != NULL )\r
-      {\r
-        // Start new connection\r
-        this->m_Conn = new QNEConnection( 0, this->m_Scene );\r
-        this->m_Conn->setPort1( out_port );\r
-        this->m_Conn->setPos1( out_port->scenePos( ) );\r
-        this->m_Conn->setPos2( evt->scenePos( ) );\r
-        this->m_Conn->updatePosFromPorts( );\r
-        this->m_Conn->updatePath( );\r
-\r
-      } // fi\r
-\r
-    } // fi\r
-  }\r
-  break;\r
-  default:\r
-    break;\r
-\r
-  } // hctiws\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor_QNodesEditor_Callback_CODE( GraphicsSceneMouseRelease )\r
-{\r
-  if( this->m_Conn == NULL )\r
-    return;\r
-\r
-  switch( evt->button( ) )\r
-  {\r
-  case Qt::LeftButton:\r
-  {\r
-    QNEInputPort* port2 =\r
-      dynamic_cast< QNEInputPort* >( this->itemAt( evt->scenePos( ) ) );\r
-    if( port2 != NULL )\r
-    {\r
-      QNEOutputPort* port1 =\r
-        dynamic_cast< QNEOutputPort* >( this->m_Conn->port1( ) );\r
-      if( port1 != NULL )\r
-      {\r
-        if(\r
-          port1->block( ) != port2->block( ) &&\r
-          !port2->hasConnection( ) &&\r
-          !port1->isConnected( port2 ) &&\r
-          !port2->isExtended( )\r
-          )\r
-        {\r
-          this->m_Conn->setPos2( port2->scenePos( ) );\r
-          this->m_Conn->setPort2( port2 );\r
-          this->m_Conn->updatePosFromPorts( );\r
-          this->m_Conn->updatePath( );\r
-\r
-          this->m_Workspace->Connect(\r
-            port1->block( )->namePort( ).toStdString( ),\r
-            port2->block( )->namePort( ).toStdString( ),\r
-            port1->name( ).toStdString( ),\r
-            port2->name( ).toStdString( )\r
-            );\r
-          this->m_Graph->AddConnection(\r
-            port1->block( )->namePort( ).toStdString( ),\r
-            port2->block( )->namePort( ).toStdString( ),\r
-            this->m_Conn\r
-            );\r
-        }\r
-        else\r
-          delete this->m_Conn;\r
-      }\r
-      else\r
-        delete this->m_Conn;\r
-    }\r
-    else\r
-      delete this->m_Conn;\r
-    this->m_Conn = NULL;\r
-  }\r
-  break;\r
-  default:\r
-    break;\r
-  } // hctisw\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor_QNodesEditor_Callback_CODE( GraphicsSceneMove )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor_QNodesEditor_Callback_CODE( GraphicsSceneResize )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor_QNodesEditor_Callback_CODE( GraphicsSceneWheel )\r
-{\r
-}\r
-\r
-// eof - $RCSfile$\r
diff --git a/appli/cpPipelineEditor/QNodesEditor.h b/appli/cpPipelineEditor/QNodesEditor.h
deleted file mode 100644 (file)
index d148bbe..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/* Copyright (c) 2012, STANISLAW ADASZEWSKI\r
-   All rights reserved.\r
-\r
-   Redistribution and use in source and binary forms, with or without\r
-   modification, are permitted provided that the following conditions are met:\r
-   * Redistributions of source code must retain the above copyright\r
-   notice, this list of conditions and the following disclaimer.\r
-   * Redistributions in binary form must reproduce the above copyright\r
-   notice, this list of conditions and the following disclaimer in the\r
-   documentation and/or other materials provided with the distribution.\r
-   * Neither the name of STANISLAW ADASZEWSKI nor the\r
-   names of its contributors may be used to endorse or promote products\r
-   derived from this software without specific prior written permission.\r
-\r
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
-   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
-   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
-   DISCLAIMED. IN NO EVENT SHALL STANISLAW ADASZEWSKI BE LIABLE FOR ANY\r
-   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
-   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
-   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
-   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
-   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-*/\r
-\r
-#ifndef __PIPELINEEDITOR__QNODESEDITOR__H__\r
-#define __PIPELINEEDITOR__QNODESEDITOR__H__\r
-\r
-#include <QObject>\r
-#include <QPointF>\r
-#include <cpExtensions/DataStructures/Graph.h>\r
-#include <cpPlugins/Interface/Workspace.h>\r
-\r
-class QGraphicsScene;\r
-class QGraphicsSceneMouseEvent;\r
-class QGraphicsItem;\r
-class QGraphicsSceneContextMenuEvent;\r
-class QGraphicsSceneDragDropEvent;\r
-class QGraphicsSceneHelpEvent;\r
-class QGraphicsSceneHoverEvent;\r
-class QGraphicsSceneMouseEvent;\r
-class QGraphicsSceneMoveEvent;\r
-class QGraphicsSceneResizeEvent;\r
-class QGraphicsSceneWheelEvent;\r
-\r
-// -------------------------------------------------------------------------\r
-#define PipelineEditor_QNodesEditor_Callback_DCL( E )   \\r
-  void _##E##_cbk( Q##E##Event* e );\r
-\r
-namespace PipelineEditor\r
-{\r
-  class QNEConnection;\r
-  class QNEBlock;\r
-\r
-  /**\r
-   */\r
-  class QNodesEditor\r
-    : public QObject\r
-  {\r
-    Q_OBJECT;\r
-\r
-  public:\r
-    typedef QNodesEditor Self;\r
-    typedef QObject      Superclass;\r
-\r
-    typedef cpPlugins::Interface::Workspace TWorkspace;\r
-    typedef TWorkspace::TFilter             TFilter;\r
-    typedef\r
-      cpExtensions::DataStructures::\r
-      Graph< QNEBlock*, QNEConnection*, std::string > TGraph;\r
-\r
-  public:\r
-    explicit QNodesEditor( QObject* parent = 0 );\r
-    virtual ~QNodesEditor( );\r
-\r
-    TWorkspace* workspace( );\r
-    const TWorkspace* workspace( ) const;\r
-    void setWorkspace( TWorkspace* ws );\r
-\r
-    std::string createFilter(\r
-      const std::string& filter,\r
-      const QPointF& pnt = QPointF( qreal( 0 ), qreal( 0 ) )\r
-      );\r
-\r
-    void install( QGraphicsScene* s );\r
-    bool eventFilter( QObject* o, QEvent* e );\r
-\r
-  private:\r
-    QGraphicsItem* itemAt( const QPointF& pos );\r
-\r
-    inline void _CreateBlock( TFilter* f, const QPointF& pnt );\r
-\r
-  protected:\r
-    typedef QGraphicsSceneDragDropEvent QGraphicsSceneDragEnterEvent;\r
-    typedef QGraphicsSceneDragDropEvent QGraphicsSceneDragLeaveEvent;\r
-    typedef QGraphicsSceneDragDropEvent QGraphicsSceneDragMoveEvent;\r
-    typedef QGraphicsSceneDragDropEvent QGraphicsSceneDropEvent;\r
-    typedef QGraphicsSceneHoverEvent    QGraphicsSceneHoverEnterEvent;\r
-    typedef QGraphicsSceneHoverEvent    QGraphicsSceneHoverMoveEvent;\r
-    typedef QGraphicsSceneHoverEvent    QGraphicsSceneHoverLeaveEvent;\r
-    typedef QGraphicsSceneMouseEvent    QGraphicsSceneMouseDoubleClickEvent;\r
-    typedef QGraphicsSceneMouseEvent    QGraphicsSceneMouseMoveEvent;\r
-    typedef QGraphicsSceneMouseEvent    QGraphicsSceneMousePressEvent;\r
-    typedef QGraphicsSceneMouseEvent    QGraphicsSceneMouseReleaseEvent;\r
-\r
-    PipelineEditor_QNodesEditor_Callback_DCL( GraphicsSceneContextMenu );\r
-    PipelineEditor_QNodesEditor_Callback_DCL( GraphicsSceneDragEnter );\r
-    PipelineEditor_QNodesEditor_Callback_DCL( GraphicsSceneDragLeave );\r
-    PipelineEditor_QNodesEditor_Callback_DCL( GraphicsSceneDragMove );\r
-    PipelineEditor_QNodesEditor_Callback_DCL( GraphicsSceneDrop );\r
-    PipelineEditor_QNodesEditor_Callback_DCL( GraphicsSceneHelp );\r
-    PipelineEditor_QNodesEditor_Callback_DCL( GraphicsSceneHoverEnter );\r
-    PipelineEditor_QNodesEditor_Callback_DCL( GraphicsSceneHoverLeave );\r
-    PipelineEditor_QNodesEditor_Callback_DCL( GraphicsSceneHoverMove );\r
-    PipelineEditor_QNodesEditor_Callback_DCL( GraphicsSceneMouseDoubleClick );\r
-    PipelineEditor_QNodesEditor_Callback_DCL( GraphicsSceneMouseMove );\r
-    PipelineEditor_QNodesEditor_Callback_DCL( GraphicsSceneMousePress );\r
-    PipelineEditor_QNodesEditor_Callback_DCL( GraphicsSceneMouseRelease );\r
-    PipelineEditor_QNodesEditor_Callback_DCL( GraphicsSceneMove );\r
-    PipelineEditor_QNodesEditor_Callback_DCL( GraphicsSceneResize );\r
-    PipelineEditor_QNodesEditor_Callback_DCL( GraphicsSceneWheel );\r
-\r
-  private:\r
-    QGraphicsScene* m_Scene;\r
-    QNEConnection* m_Conn;\r
-\r
-    TWorkspace* m_Workspace;\r
-    TGraph::Pointer m_Graph;\r
-  };\r
-\r
-} // ecapseman\r
-\r
-#endif // __PIPELINEEDITOR__QNODESEDITOR__H__\r
-\r
-// eof - $RCSfile$\r
-\r
-      /* TODO\r
-         case QEvent::GraphicsSceneContextMenu:\r
-         QGraphicsSceneContextMenuEvent* evt =\r
-         \r
-         case QEvent::GraphicsSceneDragEnter:\r
-         case QEvent::GraphicsSceneDragLeave:\r
-         case QEvent::GraphicsSceneDragMove:\r
-         case QEvent::GraphicsSceneDrop:\r
-         case QEvent::GraphicsSceneHelp:\r
-         case QEvent::GraphicsSceneHoverEnter:\r
-         case QEvent::GraphicsSceneHoverLeave:\r
-         case QEvent::GraphicsSceneHoverMove:\r
-         case QEvent::GraphicsSceneMouseDoubleClick:\r
-         case QEvent::GraphicsSceneMouseMove:\r
-         case QEvent::GraphicsSceneMousePress:\r
-         case QEvent::GraphicsSceneMouseRelease:\r
-         case QEvent::GraphicsSceneMove:\r
-         case QEvent::GraphicsSceneResize:\r
-         case QEvent::GraphicsSceneWheel:\r
-      */\r
-    \r
index 3dfe4645d3db2269cf7adbf1c24d49227d0db7f8..52d821e5bedb5d33a07bdef149a04615dee903e1 100644 (file)
@@ -1,4 +1,4 @@
-#include "cpPipelineEditor.h"
+#include "App_cpPipelineEditor.h"
 #include <cstdlib>
 #include <QApplication>
 
@@ -6,7 +6,7 @@
 int main( int argc, char* argv[] )
 {
   QApplication a( argc, argv );
-  cpPipelineEditor w( argc, argv, NULL );
+  App_cpPipelineEditor w( argc, argv, NULL );
   w.show( );
 
   return( a.exec( ) );
index 05dcd2ba1cfa4a55b6be40a4ce89455d3f51208a..bc9f3fa6c3296a59916134ecf87ff12c865e3947 100644 (file)
@@ -3,5 +3,11 @@ SUBDIRS(
   cpPlugins
   third_party
   )
+IF(USE_QT4)
+  SUBDIRS(
+    cpPipelineEditor
+    )
+ENDIF(USE_QT4)
+
 
 ## eof - $RCSfile$
index 59679c8671e3a1aa262cb3317283e6f41f488f56..db07f2e0cf8ca52eeed617b92f832c8a49cacbd7 100644 (file)
@@ -11,7 +11,11 @@ namespace cpExtensions
 {
   namespace DataStructures
   {
-    /**
+    /** \brief A generic graph with templated index types.
+     *
+     *  @param V Vertex type.
+     *  @param C Cost type.
+     *  @param I Index type (it should be a strict weak ordering type).
      */
     template< class V, class C, class I = unsigned long >
     class Graph
@@ -27,29 +31,73 @@ namespace cpExtensions
       typedef C TCost;
       typedef I TIndex;
 
-      // Graph types
-      typedef std::map< I, V >          TVertices;
-      typedef std::vector< C >          TEdges;
-      typedef std::map< I, TEdges >     TMatrixRow;
-      typedef std::map< I, TMatrixRow > TMatrix;
+      // Base types
+      typedef std::map< TIndex, TVertex >    TVertices;
+      typedef std::vector< TCost >           TEdges;
+      typedef std::map< TIndex, TEdges >     TMatrixRow;
+      typedef std::map< TIndex, TMatrixRow > TMatrix;
 
     public:
       itkNewMacro( Self );
       itkTypeMacro( Graph, itk::LightObject );
 
     public:
+      /*! \brief Iterators over vertices.
+       *         These allow you to iterate over all of graph's vertices.
+       *
+       * Typical iteration should be done as:
+       *
+       *  TGraph g;
+       *  ...
+       *  TGraph::TVertices::[const_]iterator vIt = g.BeginVertices( );
+       *  for( ; vIt != g.EndVertices( ); ++vIt )
+       *  {
+       *    vIt->first;  --> this is the vertex's index <--
+       *    vIt->second; --> this is the vertex's value <--
+       *  }
+       */
       typename TVertices::iterator BeginVertices( );
       typename TVertices::iterator EndVertices( );
       typename TVertices::const_iterator BeginVertices( ) const;
       typename TVertices::const_iterator EndVertices( ) const;
 
+      /*! \brief Iterators over edges.
+       *         These allow you to iterate over all of graph's edges.
+       *
+       * Typical iteration should be done as:
+       *
+       *  TGraph g;
+       *  ...
+       *  TGraph::TMatrix::[const_]iterator mIt = g.BeginEdgesRows( );
+       *  for( ; mIt != g.EndEdgesRows( ); ++mIt )
+       *  {
+       *    mIt->first; --> this is the row index. <--
+       *    TGraph::TMatrixRow::[const_]iterator rIt = mIt->second.begin( );
+       *    for( ; rIt != mIt->second.end( ); ++rIt )
+       *    {
+       *      rIt->first;  --> this is the column index.
+       *      TGraph::TEdges::[const_]iterator eIt = rIt->second.begin( );
+       *      for( ; eIt != rIt->second.end( ); ++eIt )
+       *        *eIt; --> this is the cost between mIt->first and rIt->first
+       *    }
+       *  }
+       */
       typename TMatrix::iterator BeginEdgesRows( );
       typename TMatrix::iterator EndEdgetsRows( );
       typename TMatrix::const_iterator BeginEdgesRows( ) const;
       typename TMatrix::const_iterator EndEdgesRows( ) const;
 
+      /*! \brief Clear all vertices and edges.
+       */
       void Clear( );
 
+      /*! \brief Clear all edges.
+       */
+      void ClearEdges( );
+
+      /*! \brief Vertex manipulation methods.
+       *         Names are self-explanatory.
+       */
       bool HasVertexIndex( const I& index ) const;
       void SetVertex( const I& index, V& vertex );
       bool RenameVertex( const I& old_index, const I& new_index );
@@ -57,9 +105,22 @@ namespace cpExtensions
       V& GetVertex( const I& index );
       const V& GetVertex( const I& index ) const;
 
-      void AddConnection( const I& orig, const I& dest, const C& cost );
-      void RemoveConnection( const I& orig, const I& dest, const C& cost );
-
+      /*! \brief Edge manipulation methods.
+       *         Names are self-explanatory.
+       */
+      bool HasEdge( const I& orig, const I& dest ) const;
+      void AddEdge( const I& orig, const I& dest, const C& cost );
+      void RemoveEdge( const I& orig, const I& dest, const C& cost );
+      void RemoveEdges( const I& orig, const I& dest );
+      TEdges& GetEdges( const I& orig, const I& dest );
+      const TEdges& GetEdges( const I& orig, const I& dest ) const;
+
+      /*! \brief Returns graph's sinks.
+       *
+       *  A sink is a special vertex which does not have any "exiting" edges.
+       *
+       *  @return Sinks ordered by their index.
+       */
       std::set< I > GetSinks( ) const;
 
     protected:
index ac9e029fdb2f15d7a4da8726c13e2e06fcde00b4..7ca6d88f55fc9b2dd60710871a776cb430a9b7cb 100644 (file)
@@ -82,6 +82,14 @@ Clear( )
   this->m_Matrix.clear( );
 }
 
+// -------------------------------------------------------------------------
+template< class V, class C, class I >
+void cpExtensions::DataStructures::Graph< V, C, I >::
+ClearEdges( )
+{
+  this->m_Matrix.clear( );
+}
+
 // -------------------------------------------------------------------------
 template< class V, class C, class I >
 bool cpExtensions::DataStructures::Graph< V, C, I >::
@@ -108,8 +116,7 @@ RenameVertex( const I& old_index, const I& 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[ new_index ] = old_v->second;
     this->m_Vertices.erase( old_index );
 
     // Duplicate edges
@@ -215,10 +222,22 @@ GetVertex( const I& index ) const
   return( this->m_Vertices[ index ] );
 }
 
+// -------------------------------------------------------------------------
+template< class V, class C, class I >
+bool cpExtensions::DataStructures::Graph< V, C, I >::
+HasEdge( const I& orig, const I& dest ) const
+{
+  auto mIt = this->m_Matrix.find( orig );
+  if( mIt != this->m_Matrix.end( ) )
+    return( mIt->second.find( dest ) != mIt->second.end( ) );
+  else
+    return( false );
+}
+
 // -------------------------------------------------------------------------
 template< class V, class C, class I >
 void cpExtensions::DataStructures::Graph< V, C, I >::
-AddConnection( const I& orig, const I& dest, const C& cost )
+AddEdge( const I& orig, const I& dest, const C& cost )
 {
   this->m_Matrix[ orig ][ dest ].push_back( cost );
 }
@@ -226,7 +245,7 @@ AddConnection( const I& orig, const I& dest, const C& cost )
 // -------------------------------------------------------------------------
 template< class V, class C, class I >
 void cpExtensions::DataStructures::Graph< V, C, I >::
-RemoveConnection( const I& orig, const I& dest, const C& cost )
+RemoveEdge( const I& orig, const I& dest, const C& cost )
 {
   auto m = this->m_Matrix.find( orig );
   if( m != this->m_Matrix.end( ) )
@@ -253,6 +272,45 @@ RemoveConnection( const I& orig, const I& dest, const C& cost )
   } // fi
 }
 
+// -------------------------------------------------------------------------
+template< class V, class C, class I >
+void cpExtensions::DataStructures::Graph< V, C, I >::
+RemoveEdges( const I& orig, const I& dest )
+{
+  auto m = this->m_Matrix.find( orig );
+  if( m != this->m_Matrix.end( ) )
+  {
+    auto r = m->second.find( dest );
+    if( r != m->second.end( ) )
+    {
+      m->second.erase( r );
+      if( m->second.size( ) == 0 )
+        this->m_Matrix.erase( m );
+
+    } // fi
+
+  } // fi
+
+}
+
+// -------------------------------------------------------------------------
+template< class V, class C, class I >
+typename cpExtensions::DataStructures::Graph< V, C, I >::
+TEdges& cpExtensions::DataStructures::Graph< V, C, I >::
+GetEdges( const I& orig, const I& dest )
+{
+  return( this->m_Matrix[ orig ][ dest ] );
+}
+
+// -------------------------------------------------------------------------
+template< class V, class C, class I >
+const typename cpExtensions::DataStructures::Graph< V, C, I >::
+TEdges& cpExtensions::DataStructures::Graph< V, C, I >::
+GetEdges( const I& orig, const I& dest ) const
+{
+  return( this->m_Matrix[ orig ][ dest ] );
+}
+
 // -------------------------------------------------------------------------
 template< class V, class C, class I >
 std::set< I > cpExtensions::DataStructures::Graph< V, C, I >::
similarity index 54%
rename from appli/cpPipelineEditor/QNEBlock.cxx
rename to lib/cpPipelineEditor/Block.cxx
index 67f4a9bd477d873a924b5e357298233797170128..96e60f8c3d2698c6cca5edc6d8b80f1dfe775f55 100644 (file)
@@ -1,30 +1,4 @@
-/* Copyright (c) 2012, STANISLAW ADASZEWSKI\r
-   All rights reserved.\r
-\r
-   Redistribution and use in source and binary forms, with or without\r
-   modification, are permitted provided that the following conditions are met:\r
-   * Redistributions of source code must retain the above copyright\r
-   notice, this list of conditions and the following disclaimer.\r
-   * Redistributions in binary form must reproduce the above copyright\r
-   notice, this list of conditions and the following disclaimer in the\r
-   documentation and/or other materials provided with the distribution.\r
-   * Neither the name of STANISLAW ADASZEWSKI nor the\r
-   names of its contributors may be used to endorse or promote products\r
-   derived from this software without specific prior written permission.\r
-\r
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
-   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
-   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
-   DISCLAIMED. IN NO EVENT SHALL STANISLAW ADASZEWSKI BE LIABLE FOR ANY\r
-   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
-   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
-   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
-   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
-   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-*/\r
-\r
-#include "QNEBlock.h"\r
+#include "Block.h"\r
 \r
 #include <QPen>\r
 #include <QGraphicsScene>\r
 #include <QPainter>\r
 #include <QStyleOptionGraphicsItem>\r
 \r
-#include "QNEPort.h"\r
-#include "QNEConnection.h"\r
+#include "Port.h"\r
+#include "Connection.h"\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEBlock::\r
-QNEBlock( TFilter* filter, QGraphicsItem* parent, QGraphicsScene* scene )\r
+cpPipelineEditor::Block::\r
+Block( TFilter* filter, QGraphicsItem* parent, QGraphicsScene* scene )\r
   : Superclass( parent, scene ),\r
     m_HorzMargin( 20 ),\r
     m_VertMargin( 5 ),\r
@@ -75,27 +49,26 @@ QNEBlock( TFilter* filter, QGraphicsItem* parent, QGraphicsScene* scene )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEBlock::\r
-~QNEBlock( )\r
+cpPipelineEditor::Block::\r
+~Block( )\r
 {\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEBlock::\r
+void cpPipelineEditor::Block::\r
 setNamePort( const QString& txt )\r
 {\r
   if( this->m_NamePort == NULL )\r
-    this->m_NamePort = new QNENamePort( this );\r
+    this->m_NamePort = new NamePort( this );\r
   this->m_NamePort->setName( txt );\r
-  this->m_Filter->SetName( txt.toStdString( ) );\r
   this->_configPort( this->m_NamePort );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEInputPort* PipelineEditor::QNEBlock::\r
+cpPipelineEditor::InputPort* cpPipelineEditor::Block::\r
 addInputPort( const QString& txt )\r
 {\r
-  QNEInputPort* ip = new QNEInputPort( this );\r
+  InputPort* ip = new InputPort( this );\r
   ip->setExtendedName(\r
     (\r
       txt.toStdString( ) +\r
@@ -110,10 +83,10 @@ addInputPort( const QString& txt )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEOutputPort* PipelineEditor::QNEBlock::\r
+cpPipelineEditor::OutputPort* cpPipelineEditor::Block::\r
 addOutputPort( const QString& txt )\r
 {\r
-  QNEOutputPort* op = new QNEOutputPort( this );\r
+  OutputPort* op = new OutputPort( this );\r
   op->setExtendedName(\r
     (\r
       txt.toStdString( ) +\r
@@ -128,37 +101,7 @@ addOutputPort( const QString& txt )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-bool PipelineEditor::QNEBlock::\r
-extendInputPort( const QString& txt, QNEConnection* conn )\r
-{\r
-  auto p = this->m_InputPorts.find( txt.toStdString( ) );\r
-  auto i = this->m_ExtInputPorts.find( txt.toStdString( ) );\r
-  if( p != this->m_InputPorts.end( ) && i == this->m_ExtInputPorts.end( ) )\r
-  {\r
-    this->m_ExtInputPorts[ txt.toStdString( ) ] = conn;\r
-    return( true );\r
-  }\r
-  else\r
-    return( false );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-bool PipelineEditor::QNEBlock::\r
-extendOutputPort( const QString& txt, QNEConnection* conn )\r
-{\r
-  auto p = this->m_OutputPorts.find( txt.toStdString( ) );\r
-  auto i = this->m_ExtOutputPorts.find( txt.toStdString( ) );\r
-  if( p != this->m_OutputPorts.end( ) && i == this->m_ExtOutputPorts.end( ) )\r
-  {\r
-    this->m_ExtOutputPorts[ txt.toStdString( ) ] = conn;\r
-    return( true );\r
-  }\r
-  else\r
-    return( false );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor::QNEInputPort* PipelineEditor::QNEBlock::\r
+cpPipelineEditor::InputPort* cpPipelineEditor::Block::\r
 inputPort( const QString& txt )\r
 {\r
   auto i = this->m_InputPorts.find( txt.toStdString( ) );\r
@@ -169,7 +112,7 @@ inputPort( const QString& txt )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEOutputPort* PipelineEditor::QNEBlock::\r
+cpPipelineEditor::OutputPort* cpPipelineEditor::Block::\r
 outputPort( const QString& txt )\r
 {\r
   auto o = this->m_OutputPorts.find( txt.toStdString( ) );\r
@@ -180,14 +123,14 @@ outputPort( const QString& txt )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-QString PipelineEditor::QNEBlock::\r
+QString cpPipelineEditor::Block::\r
 namePort( ) const\r
 {\r
   return( this->m_NamePort->name( ) );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-const PipelineEditor::QNEInputPort* PipelineEditor::QNEBlock::\r
+const cpPipelineEditor::InputPort* cpPipelineEditor::Block::\r
 inputPort( const QString& txt ) const\r
 {\r
   auto i = this->m_InputPorts.find( txt.toStdString( ) );\r
@@ -198,7 +141,7 @@ inputPort( const QString& txt ) const
 }\r
 \r
 // -------------------------------------------------------------------------\r
-const PipelineEditor::QNEOutputPort* PipelineEditor::QNEBlock::\r
+const cpPipelineEditor::OutputPort* cpPipelineEditor::Block::\r
 outputPort( const QString& txt ) const\r
 {\r
   auto o = this->m_OutputPorts.find( txt.toStdString( ) );\r
@@ -209,29 +152,7 @@ outputPort( const QString& txt ) const
 }\r
 \r
 // -------------------------------------------------------------------------\r
-const PipelineEditor::QNEConnection* PipelineEditor::QNEBlock::\r
-extendedInputPort( const QString& txt ) const\r
-{\r
-  auto i = this->m_ExtInputPorts.find( txt.toStdString( ) );\r
-  if( i != this->m_ExtInputPorts.end( ) )\r
-    return( i->second );\r
-  else\r
-    return( NULL );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-const PipelineEditor::QNEConnection* PipelineEditor::QNEBlock::\r
-extendedOutputPort( const QString& txt ) const\r
-{\r
-  auto i = this->m_ExtOutputPorts.find( txt.toStdString( ) );\r
-  if( i != this->m_ExtOutputPorts.end( ) )\r
-    return( i->second );\r
-  else\r
-    return( NULL );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-void PipelineEditor::QNEBlock::\r
+void cpPipelineEditor::Block::\r
 paint(\r
   QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget\r
   )\r
@@ -254,25 +175,25 @@ paint(
 }\r
 \r
 // -------------------------------------------------------------------------\r
-QVariant PipelineEditor::QNEBlock::\r
+QVariant cpPipelineEditor::Block::\r
 itemChange( GraphicsItemChange change, const QVariant& value )\r
 {\r
   return( value );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEBlock::\r
+void cpPipelineEditor::Block::\r
 _setTypePort( const QString& txt )\r
 {\r
   if( this->m_TypePort == NULL )\r
-    this->m_TypePort = new QNETypePort( this );\r
+    this->m_TypePort = new TypePort( this );\r
   this->m_TypePort->setName( txt );\r
   this->_configPort( this->m_TypePort );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEBlock::\r
-_configPort( QNEPort* port )\r
+void cpPipelineEditor::Block::\r
+_configPort( Port* port )\r
 {\r
   port->setBlock( this );\r
 \r
@@ -297,28 +218,28 @@ _configPort( QNEPort* port )
   int y = -this->m_Height / 2 + this->m_VertMargin + port->radius( );\r
   foreach( QGraphicsItem* i, this->children( ) )\r
   {\r
-    QNEPort* p = dynamic_cast< QNEPort* >( i );\r
+    Port* p = dynamic_cast< Port* >( i );\r
     if( p == NULL )\r
       continue;\r
 \r
-    if( dynamic_cast< QNENamePort* >( i ) != NULL )\r
+    if( dynamic_cast< NamePort* >( i ) != NULL )\r
       i->setPos( -this->m_Width / 2 + port->radius( ), y );\r
-    else if( dynamic_cast< QNETypePort* >( i ) != NULL )\r
+    else if( dynamic_cast< TypePort* >( i ) != NULL )\r
     {\r
       i->setPos( -this->m_Width / 2 + port->radius( ), y );\r
       y += h;\r
     }\r
-    else if( dynamic_cast< QNEInputPort* >( i ) != NULL )\r
+    else if( dynamic_cast< InputPort* >( i ) != NULL )\r
       i->setPos( -this->m_Width / 2 - 2 * port->radius( ), y );\r
-    else if( dynamic_cast< QNEOutputPort* >( i ) != NULL )\r
+    else if( dynamic_cast< OutputPort* >( i ) != NULL )\r
       i->setPos( this->m_Width / 2, y );\r
 \r
     /* TODO\r
-       QNEPort* p = dynamic_cast< QNEPort* >( i );\r
+       Port* p = dynamic_cast< Port* >( i );\r
        if( p == NULL )\r
        continue;\r
 \r
-       if( dynamic_cast< QNEOutputPort* >( p ) != NULL )\r
+       if( dynamic_cast< OutputPort* >( p ) != NULL )\r
        p->setPos( this->m_Width / 2 + port->radius( ), y );\r
        else\r
        p->setPos( -this->m_Width / 2 - port->radius( ), y );\r
@@ -329,10 +250,10 @@ _configPort( QNEPort* port )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEBlock::\r
+void cpPipelineEditor::Block::\r
 mouseReleaseEvent( QGraphicsSceneMouseEvent* evt )\r
 {\r
-  if( this->m_Filter.IsNotNull( ) )\r
+  if( this->m_Filter != NULL )\r
     this->m_Filter->SetViewCoords(\r
       this->scenePos( ).x( ), this->scenePos( ).y( )\r
       );\r
diff --git a/lib/cpPipelineEditor/Block.h b/lib/cpPipelineEditor/Block.h
new file mode 100644 (file)
index 0000000..81de86f
--- /dev/null
@@ -0,0 +1,80 @@
+#ifndef __CPPIPELINEEDITOR__BLOCK__H__\r
+#define __CPPIPELINEEDITOR__BLOCK__H__\r
+\r
+#include <cpPipelineEditor/cpPipelineEditor_Export.h>\r
+#include <QGraphicsPathItem>\r
+#include <cpPlugins/Interface/ProcessObject.h>\r
+\r
+namespace cpPipelineEditor\r
+{\r
+  class Port;\r
+  class NamePort;\r
+  class TypePort;\r
+  class InputPort;\r
+  class OutputPort;\r
+\r
+  /**\r
+   */\r
+  class cpPipelineEditor_EXPORT Block\r
+    : public QGraphicsPathItem\r
+  {\r
+  public:\r
+    typedef Block             Self;\r
+    typedef QGraphicsPathItem Superclass;\r
+    typedef cpPlugins::Interface::ProcessObject TFilter;\r
+  \r
+  public:\r
+    enum { Type = QGraphicsItem::UserType + 6 };\r
+\r
+    Block(\r
+      TFilter* filter,\r
+      QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL\r
+      );\r
+    virtual ~Block( );\r
+\r
+    void setNamePort( const QString& txt );\r
+    InputPort* addInputPort( const QString& txt );\r
+    OutputPort* addOutputPort( const QString& txt );\r
+\r
+    InputPort* inputPort( const QString& txt );\r
+    OutputPort* outputPort( const QString& txt );\r
+\r
+    QString namePort( ) const;\r
+    const InputPort* inputPort( const QString& txt ) const;\r
+    const OutputPort* outputPort( const QString& txt ) const;\r
+\r
+    inline int type( ) const\r
+      { return( this->Type ); }\r
+\r
+    virtual void paint(\r
+      QPainter* painter,\r
+      const QStyleOptionGraphicsItem* option,\r
+      QWidget* widget\r
+      );\r
+    \r
+  protected:\r
+    QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
+    void _setTypePort( const QString& txt );\r
+    void _configPort( Port* port );\r
+\r
+    virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* evt );\r
+\r
+  private:\r
+    int m_HorzMargin;\r
+    int m_VertMargin;\r
+    int m_Width;\r
+    int m_Height;\r
+\r
+    NamePort* m_NamePort;\r
+    TypePort* m_TypePort;\r
+    std::map< std::string, InputPort* >  m_InputPorts;\r
+    std::map< std::string, OutputPort* > m_OutputPorts;\r
+\r
+    TFilter* m_Filter;\r
+  };\r
+\r
+} // ecapseman\r
+\r
+#endif // __CPPIPELINEEDITOR__BLOCK__H__\r
+\r
+// eof - $RCSfile$\r
diff --git a/lib/cpPipelineEditor/CMakeLists.txt b/lib/cpPipelineEditor/CMakeLists.txt
new file mode 100644 (file)
index 0000000..263b4ac
--- /dev/null
@@ -0,0 +1,50 @@
+SET(LIBRARY_NAME cpPipelineEditor)
+
+## ===============
+## = Source code =
+## ===============
+
+FILE(GLOB LIB_HEADERS_H   "*.h")
+FILE(GLOB LIB_HEADERS_HPP "*.hpp")
+FILE(GLOB LIB_HEADERS_HXX "*.hxx")
+FILE(GLOB LIB_SOURCES_C   "*.c")
+FILE(GLOB LIB_SOURCES_CPP "*.cpp")
+FILE(GLOB LIB_SOURCES_CXX "*.cxx")
+SET(
+  LIB_QT_Headers
+  Canvas.h
+  Editor.h
+  )
+
+## =====================
+## = Compilation rules =
+## =====================
+
+QT4_WRAP_CPP(LIB_QT_Wrapped_MOC_Sources ${LIB_QT_Headers})
+
+ADD_LIBRARY(
+  ${LIBRARY_NAME}
+  ${LIBRARY_TYPE}
+  ${LIB_SOURCES_C}
+  ${LIB_SOURCES_CPP}
+  ${LIB_SOURCES_CXX}
+  ${LIB_QT_Wrapped_MOC_Sources}
+  )
+GENERATE_EXPORT_HEADER(
+  ${LIBRARY_NAME}
+  BASE_NAME ${LIBRARY_NAME}
+  EXPORT_MACRO_NAME ${LIBRARY_NAME}_EXPORT
+  EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/lib/${LIBRARY_NAME}/${LIBRARY_NAME}_Export.h
+  STATIC_DEFINE ${LIBRARY_NAME}_BUILT_AS_STATIC
+  )
+TARGET_LINK_LIBRARIES(
+  ${LIBRARY_NAME}
+  ${QT_LIBRARIES}
+  cpPlugins_Interface
+  )
+
+## ========================
+## -- Installation rules --
+## ========================
+
+## eof - $RCSfile$
similarity index 86%
rename from appli/cpPipelineEditor/QNodesEditorCanvas.cxx
rename to lib/cpPipelineEditor/Canvas.cxx
index e5d914fca5f1f58c859e9daa28078a3f2ab7e737..a5fcc3f7448c31e8e2e0525d28deebd404feb6d4 100644 (file)
@@ -1,16 +1,16 @@
-#include "QNodesEditorCanvas.h"
-#include "QNodesEditor.h"
-#include "QNEBlock.h"
-#include "QNEConnection.h"
-#include "QNEPort.h"
+#include "Canvas.h"
+#include "Editor.h"
+#include "Block.h"
+#include "Connection.h"
+#include "Port.h"
 
 #include <QDragEnterEvent>
 #include <QWheelEvent>
 #include <QTreeWidget>
 
 // -------------------------------------------------------------------------
-PipelineEditor::QNodesEditorCanvas::
-QNodesEditorCanvas( QWidget* parent )
+cpPipelineEditor::Canvas::
+Canvas( QWidget* parent )
   : QGraphicsView( parent )
 {
   QGraphicsScene* scene = new QGraphicsScene( this );
@@ -18,27 +18,27 @@ QNodesEditorCanvas( QWidget* parent )
   this->setRenderHint( QPainter::Antialiasing );
   this->setAcceptDrops( true );
 
-  this->m_Editor = new QNodesEditor( this );
+  this->m_Editor = new Editor( this );
   this->m_Editor->install( scene );
 }
 
 // -------------------------------------------------------------------------
-PipelineEditor::QNodesEditorCanvas::
-~QNodesEditorCanvas( )
+cpPipelineEditor::Canvas::
+~Canvas( )
 {
 }
 
 // -------------------------------------------------------------------------
-PipelineEditor::
-QNodesEditor* PipelineEditor::QNodesEditorCanvas::
+cpPipelineEditor::
+Editor* cpPipelineEditor::Canvas::
 editor( )
 {
   return( this->m_Editor );
 }
 
 // -------------------------------------------------------------------------
-const PipelineEditor::
-QNodesEditor* PipelineEditor::QNodesEditorCanvas::
+const cpPipelineEditor::
+Editor* cpPipelineEditor::Canvas::
 editor( ) const
 {
   return( this->m_Editor );
@@ -46,20 +46,20 @@ editor( ) const
 
 // -------------------------------------------------------------------------
 /* TODO
-   void PipelineEditor::QNodesEditorCanvas::
+   void cpPipelineEditor::Canvas::
    keyPressEvent( QKeyEvent* event )
    {
    }
 
    // -------------------------------------------------------------------------
-   void PipelineEditor::QNodesEditorCanvas::
+   void cpPipelineEditor::Canvas::
    timerEvent( QTimerEvent* event )
    {
    }
 */
 
 // -------------------------------------------------------------------------
-void PipelineEditor::QNodesEditorCanvas::
+void cpPipelineEditor::Canvas::
 wheelEvent( QWheelEvent* event )
 {
   this->_scaleView(
@@ -68,7 +68,7 @@ wheelEvent( QWheelEvent* event )
 }
 
 // -------------------------------------------------------------------------
-void PipelineEditor::QNodesEditorCanvas::
+void cpPipelineEditor::Canvas::
 dragEnterEvent( QDragEnterEvent* event )
 {
   const QMimeData* mime = event->mimeData( );
@@ -77,19 +77,19 @@ dragEnterEvent( QDragEnterEvent* event )
 }
 
 // -------------------------------------------------------------------------
-void PipelineEditor::QNodesEditorCanvas::
+void cpPipelineEditor::Canvas::
 dragLeaveEvent( QDragLeaveEvent* event )
 {
 }
 
 // -------------------------------------------------------------------------
-void PipelineEditor::QNodesEditorCanvas::
+void cpPipelineEditor::Canvas::
 dragMoveEvent( QDragMoveEvent* event )
 {
 }
 
 // -------------------------------------------------------------------------
-void PipelineEditor::QNodesEditorCanvas::
+void cpPipelineEditor::Canvas::
 dropEvent( QDropEvent* event )
 {
   const QMimeData* mime = event->mimeData( );
@@ -109,7 +109,7 @@ dropEvent( QDropEvent* event )
 }
 
 // -------------------------------------------------------------------------
-void PipelineEditor::QNodesEditorCanvas::
+void cpPipelineEditor::Canvas::
 _scaleView( qreal scaleFactor )
 {
   qreal factor = this->transform( ).
@@ -123,16 +123,16 @@ _scaleView( qreal scaleFactor )
 
 // -------------------------------------------------------------------------
   /*
-void PipelineEditor::QNodesEditorCanvas::
+void cpPipelineEditor::Canvas::
 _createBlock( TFilter* f )
 {
   if( f == NULL )
     return;
 
   // Add block
-  QNEBlock* b = new QNEBlock( 0, this->scene( ) );
-  b->addPort( f->GetName( ), 0, QNEPort::NamePort );
-  b->addPort( f->GetClassName( ).c_str( ), 0, QNEPort::TypePort );
+  Block* b = new Block( 0, this->scene( ) );
+  b->addPort( f->GetName( ), 0, Port::NamePort );
+  b->addPort( f->GetClassName( ).c_str( ), 0, Port::TypePort );
 
   // Add input ports
   std::set< std::string > inputs;
@@ -152,16 +152,16 @@ _createBlock( TFilter* f )
   this->m_Graph->InsertVertex( f->GetName( ), b );
 
   // Add vertices and keep track of ports
-    std::map< std::string, std::map< std::string, QNEPort* > >
+    std::map< std::string, std::map< std::string, Port* > >
     in_ports, out_ports;
     auto vIt = this->m_Workspace->GetGraph( )->BeginVertices( );
     auto vIt_end = this->m_Workspace->GetGraph( )->EndVertices( );
     for( ; vIt != vIt_end; ++vIt )
     {
     // Add block
-    QNEBlock* b = new QNEBlock( 0, scene );
-    b->addPort( vIt->second->GetName( ), 0, QNEPort::NamePort );
-    b->addPort( vIt->second->GetClassName( ).c_str( ), 0, QNEPort::TypePort );
+    Block* b = new Block( 0, scene );
+    b->addPort( vIt->second->GetName( ), 0, Port::NamePort );
+    b->addPort( vIt->second->GetClassName( ).c_str( ), 0, Port::TypePort );
 
     // Get filter
     auto f = dynamic_cast< TFilter* >( vIt->second.GetPointer( ) );
similarity index 57%
rename from appli/cpPipelineEditor/QNodesEditorCanvas.h
rename to lib/cpPipelineEditor/Canvas.h
index 2fec183e666a96782206c75dfcb26864bd36dc3f..c327a696ae7b0c5ac08fb335f6ce9147c337f3d7 100644 (file)
@@ -1,28 +1,29 @@
-#ifndef __PIPELINEEDITOR__QNODESEDITORCANVAS__H__
-#define __PIPELINEEDITOR__QNODESEDITORCANVAS__H__
+#ifndef __CPPIPELINEEDITOR__CANVAS__H__
+#define __CPPIPELINEEDITOR__CANVAS__H__
 
+#include <cpPipelineEditor/cpPipelineEditor_Export.h>
 #include <QtGui/QGraphicsView>
 
-namespace PipelineEditor
+namespace cpPipelineEditor
 {
   // Some other forward declarations
-  class QNEBlock;
-  class QNEConnection;
-  class QNodesEditor;
+  class Block;
+  class Connection;
+  class Editor;
 
   /**
    */
-  class QNodesEditorCanvas
+  class cpPipelineEditor_EXPORT Canvas
     : public QGraphicsView
   {
     Q_OBJECT;
 
   public:
-    QNodesEditorCanvas( QWidget* parent = 0 );
-    virtual ~QNodesEditorCanvas( );
+    Canvas( QWidget* parent = 0 );
+    virtual ~Canvas( );
 
-    QNodesEditor* editor( );
-    const QNodesEditor* editor( ) const;
+    Editor* editor( );
+    const Editor* editor( ) const;
 
   protected:
     /* TODO
@@ -39,11 +40,11 @@ namespace PipelineEditor
     void _scaleView( qreal scaleFactor );
 
   protected:
-    QNodesEditor* m_Editor;
+    Editor* m_Editor;
   };
 
 } // ecapseman
 
-#endif // __PIPELINEEDITOR__QNODESEDITORCANVAS__H__
+#endif // __CPPIPELINEEDITOR__CANVAS__H__
 
 // eof - $RCSfile$
similarity index 51%
rename from appli/cpPipelineEditor/QNEConnection.cxx
rename to lib/cpPipelineEditor/Connection.cxx
index c79bb7ed27e02d6b7c5d1af662d3a7671665ab71..59f66c01af8f4e43a0b806113931e2f368960a83 100644 (file)
@@ -1,39 +1,13 @@
-/* Copyright (c) 2012, STANISLAW ADASZEWSKI\r
-   All rights reserved.\r
-\r
-   Redistribution and use in source and binary forms, with or without\r
-   modification, are permitted provided that the following conditions are met:\r
-   * Redistributions of source code must retain the above copyright\r
-   notice, this list of conditions and the following disclaimer.\r
-   * Redistributions in binary form must reproduce the above copyright\r
-   notice, this list of conditions and the following disclaimer in the\r
-   documentation and/or other materials provided with the distribution.\r
-   * Neither the name of STANISLAW ADASZEWSKI nor the\r
-   names of its contributors may be used to endorse or promote products\r
-   derived from this software without specific prior written permission.\r
-\r
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
-   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
-   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
-   DISCLAIMED. IN NO EVENT SHALL STANISLAW ADASZEWSKI BE LIABLE FOR ANY\r
-   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
-   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
-   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
-   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
-   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-*/\r
-\r
-#include "QNEConnection.h"\r
-#include "QNEPort.h"\r
+#include "Connection.h"\r
+#include "Port.h"\r
 \r
 #include <QBrush>\r
 #include <QPen>\r
 #include <QGraphicsScene>\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEConnection::\r
-QNEConnection( QGraphicsItem* parent, QGraphicsScene* scene )\r
+cpPipelineEditor::Connection::\r
+Connection( QGraphicsItem* parent, QGraphicsScene* scene )\r
   : Superclass( parent, scene )\r
 {\r
   this->setPen( QPen( Qt::black, 2 ) );\r
@@ -44,8 +18,8 @@ QNEConnection( QGraphicsItem* parent, QGraphicsScene* scene )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEConnection::\r
-~QNEConnection( )\r
+cpPipelineEditor::Connection::\r
+~Connection( )\r
 {\r
   if( this->m_Port1 != NULL )\r
     this->m_Port1->connections( ).\r
@@ -56,22 +30,22 @@ PipelineEditor::QNEConnection::
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEConnection::\r
+void cpPipelineEditor::Connection::\r
 setPos1( const QPointF& p )\r
 {\r
   this->m_Pos1 = p;\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEConnection::\r
+void cpPipelineEditor::Connection::\r
 setPos2( const QPointF& p )\r
 {\r
   this->m_Pos2 = p;\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEConnection::\r
-setPort1( QNEOutputPort* p )\r
+void cpPipelineEditor::Connection::\r
+setPort1( OutputPort* p )\r
 {\r
   if( p != NULL )\r
   {\r
@@ -82,8 +56,8 @@ setPort1( QNEOutputPort* p )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEConnection::\r
-setPort2( QNEInputPort* p )\r
+void cpPipelineEditor::Connection::\r
+setPort2( InputPort* p )\r
 {\r
   if( p != NULL )\r
   {\r
@@ -98,7 +72,7 @@ setPort2( QNEInputPort* p )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEConnection::\r
+void cpPipelineEditor::Connection::\r
 updatePosFromPorts( )\r
 {\r
   if( this->m_Port1 != NULL )\r
@@ -112,7 +86,7 @@ updatePosFromPorts( )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEConnection::\r
+void cpPipelineEditor::Connection::\r
 updatePath( )\r
 {\r
   QPainterPath p;\r
@@ -128,14 +102,14 @@ updatePath( )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEOutputPort* PipelineEditor::QNEConnection::\r
+cpPipelineEditor::OutputPort* cpPipelineEditor::Connection::\r
 port1( ) const\r
 {\r
   return( this->m_Port1 );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEInputPort* PipelineEditor::QNEConnection::\r
+cpPipelineEditor::InputPort* cpPipelineEditor::Connection::\r
 port2( ) const\r
 {\r
   return( this->m_Port2 );\r
diff --git a/lib/cpPipelineEditor/Connection.h b/lib/cpPipelineEditor/Connection.h
new file mode 100644 (file)
index 0000000..b7eb26e
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef __CPPIPELINEEDITOR__CONNECTION__H__\r
+#define __CPPIPELINEEDITOR__CONNECTION__H__\r
+\r
+#include <cpPipelineEditor/cpPipelineEditor_Export.h>\r
+#include <QGraphicsPathItem>\r
+\r
+namespace cpPipelineEditor\r
+{\r
+  class InputPort;\r
+  class OutputPort;\r
+\r
+  /**\r
+   */\r
+  class cpPipelineEditor_EXPORT Connection\r
+    : public QGraphicsPathItem\r
+  {\r
+  public:\r
+    typedef Connection     Self;\r
+    typedef QGraphicsPathItem Superclass;\r
+\r
+  public:\r
+    enum { Type = QGraphicsItem::UserType + 5 };\r
+\r
+    Connection( QGraphicsItem* parent = 0, QGraphicsScene* scene = 0 );\r
+    virtual ~Connection( );\r
+\r
+    void setPos1( const QPointF& p );\r
+    void setPos2( const QPointF& p );\r
+    void setPort1( OutputPort* p );\r
+    void setPort2( InputPort* p );\r
+    void updatePosFromPorts( );\r
+    void updatePath( );\r
+    OutputPort* port1( ) const;\r
+    InputPort* port2( ) const;\r
+\r
+    inline int type( ) const\r
+      { return( this->Type ); }\r
+\r
+  private:\r
+    QPointF m_Pos1;\r
+    QPointF m_Pos2;\r
+    OutputPort* m_Port1;\r
+    InputPort*  m_Port2;\r
+  };\r
+\r
+} // ecapseman\r
+\r
+#endif // __CPPIPELINEEDITOR__CONNECTION__H__\r
+\r
+// eof - $RCSfile$\r
diff --git a/lib/cpPipelineEditor/Editor.cxx b/lib/cpPipelineEditor/Editor.cxx
new file mode 100644 (file)
index 0000000..237bb58
--- /dev/null
@@ -0,0 +1,510 @@
+#include "Editor.h"\r
+\r
+#include <QGraphicsScene>\r
+#include <QEvent>\r
+#include <QGraphicsSceneContextMenuEvent>\r
+#include <QGraphicsSceneDragDropEvent>\r
+#include <QGraphicsSceneHelpEvent>\r
+#include <QGraphicsSceneHoverEvent>\r
+#include <QGraphicsSceneMouseEvent>\r
+#include <QGraphicsSceneMoveEvent>\r
+#include <QGraphicsSceneResizeEvent>\r
+#include <QGraphicsSceneWheelEvent>\r
+#include <QInputDialog>\r
+\r
+#include "Port.h"\r
+#include "Connection.h"\r
+#include "Block.h"\r
+\r
+// -------------------------------------------------------------------------\r
+#define cpPipelineEditor_Editor_Callback_SWITCH( E, e )                 \\r
+  case QEvent::GraphicsScene##E:                                        \\r
+  {                                                                     \\r
+    QGraphicsScene##E##Event* evt =                                     \\r
+      dynamic_cast< QGraphicsScene##E##Event* >( e );                   \\r
+    if( evt != NULL )                                                   \\r
+      this->_##E##_cbk( evt );                                          \\r
+  }                                                                     \\r
+  break;\r
+\r
+// -------------------------------------------------------------------------\r
+#define cpPipelineEditor_Editor_Callback_CODE( E )                      \\r
+  void cpPipelineEditor::Editor::_##E##_cbk( QGraphicsScene##E##Event* evt )\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor::Editor::\r
+Editor( QObject* parent )\r
+  : Superclass( parent ),\r
+    m_ActualConnection( NULL ),\r
+    m_Workspace( NULL )\r
+{\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor::Editor::\r
+~Editor( )\r
+{\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor::Editor::\r
+TWorkspace* cpPipelineEditor::Editor::\r
+workspace( )\r
+{\r
+  return( this->m_Workspace );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+const cpPipelineEditor::Editor::\r
+TWorkspace* cpPipelineEditor::Editor::\r
+workspace( ) const\r
+{\r
+  return( this->m_Workspace );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Editor::\r
+setWorkspace( TWorkspace* ws )\r
+{\r
+  this->m_Workspace = ws;\r
+  this->m_Graph = TGraph::New( );\r
+\r
+  // Create blocks\r
+  auto vIt = this->m_Workspace->GetGraph( )->BeginVertices( );\r
+  auto vIt_end = this->m_Workspace->GetGraph( )->EndVertices( );\r
+  for( ; vIt != vIt_end; ++vIt )\r
+    this->_createBlock(\r
+      dynamic_cast< TFilter* >( vIt->second.GetPointer( ) ),\r
+      QPointF( vIt->second->GetViewX( ), vIt->second->GetViewY( ) )\r
+      );\r
+\r
+  // Add edges\r
+  auto rIt = this->m_Workspace->GetGraph( )->BeginEdgesRows( );\r
+  auto rIt_end = this->m_Workspace->GetGraph( )->EndEdgesRows( );\r
+  for( ; rIt != rIt_end; ++rIt )\r
+  {\r
+    Block* orig = this->m_Graph->GetVertex( rIt->first );\r
+    auto cIt = rIt->second.begin( );\r
+    for( ; cIt != rIt->second.end( ); ++cIt )\r
+    {\r
+      Block* dest = this->m_Graph->GetVertex( cIt->first );\r
+      auto eIt = cIt->second.begin( );\r
+      for( ; eIt != cIt->second.end( ); ++eIt )\r
+      {\r
+        OutputPort* op = orig->outputPort( eIt->first.c_str( ) );\r
+        InputPort* ip = dest->inputPort( eIt->second.c_str( ) );\r
+        if( op == NULL || ip == NULL )\r
+          continue;\r
+\r
+        Connection* c = new Connection( 0, this->m_Scene );\r
+        c->setPort1( op );\r
+        c->setPort2( ip );\r
+        c->updatePosFromPorts( );\r
+        c->updatePath( );\r
+        this->m_Graph->AddEdge( rIt->first, cIt->first, c );\r
+\r
+      } // rof\r
+\r
+    } // rof\r
+\r
+  } // rof\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+std::string cpPipelineEditor::Editor::\r
+createFilter( const std::string& filter, const QPointF& pnt )\r
+{\r
+  std::string name = filter;\r
+  while( this->m_Workspace->HasFilter( name ) )\r
+    name += std::string( "_" );\r
+  if( this->m_Workspace->CreateFilter( filter, name ) )\r
+  {\r
+    this->_createBlock( this->m_Workspace->GetFilter( name ), pnt );\r
+    return( name );\r
+  }\r
+  else\r
+    return( "" );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Editor::\r
+install( QGraphicsScene* s )\r
+{\r
+  s->installEventFilter( this );\r
+  this->m_Scene = s;\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+QGraphicsItem* cpPipelineEditor::Editor::\r
+itemAt( const QPointF& pos )\r
+{\r
+  QList< QGraphicsItem* > items =\r
+    this->m_Scene->items( QRectF( pos - QPointF( 1, 1 ), QSize( 3, 3 ) ) );\r
+\r
+  foreach( QGraphicsItem* item, items )\r
+    if( item->type( ) > QGraphicsItem::UserType )\r
+      return( item );\r
+  return( NULL );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Editor::\r
+_createBlock( TFilter* f, const QPointF& pnt )\r
+{\r
+  if( f == NULL )\r
+    return;\r
+\r
+  // Add block\r
+  Block* b = new Block( f, 0, this->m_Scene );\r
+  b->setPos( pnt );\r
+\r
+  // Keep a trace of this visual graph\r
+  this->m_Graph->SetVertex( f->GetName( ), b );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+bool cpPipelineEditor::Editor::\r
+eventFilter( QObject* o, QEvent* e )\r
+{\r
+  // Event type\r
+  switch( int( e->type( ) ) )\r
+  {\r
+    cpPipelineEditor_Editor_Callback_SWITCH( ContextMenu, e );\r
+    cpPipelineEditor_Editor_Callback_SWITCH( DragEnter, e );\r
+    cpPipelineEditor_Editor_Callback_SWITCH( DragLeave, e );\r
+    cpPipelineEditor_Editor_Callback_SWITCH( DragMove, e );\r
+    cpPipelineEditor_Editor_Callback_SWITCH( Drop, e );\r
+    cpPipelineEditor_Editor_Callback_SWITCH( Help, e );\r
+    cpPipelineEditor_Editor_Callback_SWITCH( HoverEnter, e );\r
+    cpPipelineEditor_Editor_Callback_SWITCH( HoverLeave, e );\r
+    cpPipelineEditor_Editor_Callback_SWITCH( HoverMove, e );\r
+    cpPipelineEditor_Editor_Callback_SWITCH( MouseDoubleClick, e );\r
+    cpPipelineEditor_Editor_Callback_SWITCH( MouseMove, e );\r
+    cpPipelineEditor_Editor_Callback_SWITCH( MousePress, e );\r
+    cpPipelineEditor_Editor_Callback_SWITCH( MouseRelease, e );\r
+    cpPipelineEditor_Editor_Callback_SWITCH( Move, e );\r
+    cpPipelineEditor_Editor_Callback_SWITCH( Resize, e );\r
+    cpPipelineEditor_Editor_Callback_SWITCH( Wheel, e );\r
+  default:\r
+    break;\r
+  } // hctiws\r
+  return( this->Superclass::eventFilter( o, e ) );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor_Editor_Callback_CODE( ContextMenu )\r
+{\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor_Editor_Callback_CODE( DragEnter )\r
+{\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor_Editor_Callback_CODE( DragLeave )\r
+{\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor_Editor_Callback_CODE( DragMove )\r
+{\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor_Editor_Callback_CODE( Drop )\r
+{\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor_Editor_Callback_CODE( Help )\r
+{\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor_Editor_Callback_CODE( HoverEnter )\r
+{\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor_Editor_Callback_CODE( HoverLeave )\r
+{\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor_Editor_Callback_CODE( HoverMove )\r
+{\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor_Editor_Callback_CODE( MouseDoubleClick )\r
+{\r
+  QGraphicsItem* item = this->itemAt( evt->scenePos( ) );\r
+  if( item == NULL )\r
+    return;\r
+\r
+  switch( evt->button( ) )\r
+  {\r
+  case Qt::LeftButton:\r
+  {\r
+    Block* block = dynamic_cast< Block* >( item );\r
+    Port* port = dynamic_cast< Port* >( item );\r
+    Connection* conn = dynamic_cast< Connection* >( item );\r
+\r
+    if( block != NULL )\r
+    {\r
+      QString old_name = block->namePort( );\r
+      bool ok;\r
+      QString new_name =\r
+        QInputDialog::getText(\r
+          dynamic_cast< QWidget* >( this->parent( ) ),\r
+          "Change filter name",\r
+          "Filter name:",\r
+          QLineEdit::Normal,\r
+          old_name,\r
+          &ok\r
+          );\r
+      if( ok && !new_name.isEmpty( ) && old_name != new_name )\r
+      {\r
+        ok = this->m_Graph->RenameVertex(\r
+          old_name.toStdString( ),\r
+          new_name.toStdString( )\r
+          );\r
+        if( ok )\r
+        {\r
+          block->setNamePort( new_name );\r
+          this->m_Workspace->RenameFilter(\r
+            old_name.toStdString( ),\r
+            new_name.toStdString( )\r
+            );\r
+\r
+        } // fi\r
+\r
+      } // fi\r
+    }\r
+    else if( port != NULL )\r
+    {\r
+      if( evt->modifiers( ) == Qt::ControlModifier )\r
+      {\r
+        port->setExtend( !( port->isExtended( ) ) );\r
+        InputPort* in_port = dynamic_cast< InputPort* >( port );\r
+        OutputPort* out_port = dynamic_cast< OutputPort* >( port );\r
+        if( port->isExtended( ) )\r
+        {\r
+          if( in_port != NULL )\r
+          {\r
+            this->m_Workspace->ExposeInputPort(\r
+              in_port->extendedName( ).toStdString( ),\r
+              in_port->block( )->namePort( ).toStdString( ),\r
+              in_port->name( ).toStdString( )\r
+              );\r
+          }\r
+          else if( out_port != NULL )\r
+          {\r
+            this->m_Workspace->ExposeOutputPort(\r
+              out_port->extendedName( ).toStdString( ),\r
+              out_port->block( )->namePort( ).toStdString( ),\r
+              out_port->name( ).toStdString( )\r
+              );\r
+\r
+          } // fi\r
+        }\r
+        else\r
+        {\r
+          if( in_port != NULL )\r
+            this->m_Workspace->HideInputPort(\r
+              in_port->extendedName( ).toStdString( )\r
+              );\r
+          else if( out_port != NULL )\r
+            this->m_Workspace->HideOutputPort(\r
+              out_port->extendedName( ).toStdString( )\r
+              );\r
+\r
+        } // fi\r
+        this->m_Scene->update( );\r
+      }\r
+      else if( evt->modifiers( ) == Qt::NoModifier )\r
+      {\r
+        if( port->isExtended( ) )\r
+        {\r
+          QString old_name = port->extendedName( );\r
+          bool ok;\r
+          QString new_name =\r
+            QInputDialog::getText(\r
+              dynamic_cast< QWidget* >( this->parent( ) ),\r
+              "Change filter name",\r
+              "Filter name:",\r
+              QLineEdit::Normal,\r
+              old_name,\r
+              &ok\r
+              );\r
+          if( ok && !new_name.isEmpty( ) && old_name != new_name )\r
+          {\r
+            port->setExtendedName( new_name );\r
+            InputPort* in_port = dynamic_cast< InputPort* >( port );\r
+            OutputPort* out_port = dynamic_cast< OutputPort* >( port );\r
+            if( in_port != NULL )\r
+              this->m_Workspace->\r
+                RenameExposedInputPort(\r
+                  old_name.toStdString( ),\r
+                  new_name.toStdString( )\r
+                  );\r
+            else if( out_port != NULL )\r
+              this->m_Workspace->\r
+                RenameExposedOutputPort(\r
+                  old_name.toStdString( ),\r
+                  new_name.toStdString( )\r
+                  );\r
+            this->m_Scene->update( );\r
+\r
+          } // fi\r
+\r
+        } // fi\r
+\r
+      } // fi\r
+    }\r
+    else if( conn != NULL )\r
+    {\r
+    } // fi\r
+  }\r
+  break;\r
+  /* TODO:\r
+     case Qt::RightButton:\r
+     {\r
+     }\r
+     break;\r
+     case Qt::MiddleButton:\r
+     {\r
+     }\r
+     break;\r
+  */\r
+  default:\r
+    break;\r
+  } // hctiws\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor_Editor_Callback_CODE( MouseMove )\r
+{\r
+  if( this->m_ActualConnection != NULL )\r
+  {\r
+    if( this->m_ActualConnection->port1( ) == NULL )\r
+      this->m_ActualConnection->setPos1( evt->scenePos( ) );\r
+    else if( this->m_ActualConnection->port2( ) == NULL )\r
+      this->m_ActualConnection->setPos2( evt->scenePos( ) );\r
+    this->m_ActualConnection->updatePath( );\r
+\r
+  } // fi\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor_Editor_Callback_CODE( MousePress )\r
+{\r
+  InputPort* in_port =\r
+    dynamic_cast< InputPort* >( this->itemAt( evt->scenePos( ) ) );\r
+  OutputPort* out_port =\r
+    dynamic_cast< OutputPort* >( this->itemAt( evt->scenePos( ) ) );\r
+  if( in_port == NULL && out_port == NULL )\r
+    return;\r
+\r
+  switch( evt->button( ) )\r
+  {\r
+  case Qt::LeftButton:\r
+  {\r
+    if( out_port != NULL )\r
+    {\r
+      if( out_port->block( ) != NULL )\r
+      {\r
+        // Start new connection\r
+        this->m_ActualConnection = new Connection( 0, this->m_Scene );\r
+        this->m_ActualConnection->setPort1( out_port );\r
+        this->m_ActualConnection->setPos1( out_port->scenePos( ) );\r
+        this->m_ActualConnection->setPos2( evt->scenePos( ) );\r
+        this->m_ActualConnection->updatePosFromPorts( );\r
+        this->m_ActualConnection->updatePath( );\r
+\r
+      } // fi\r
+\r
+    } // fi\r
+  }\r
+  break;\r
+  default:\r
+    break;\r
+\r
+  } // hctiws\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor_Editor_Callback_CODE( MouseRelease )\r
+{\r
+  if( this->m_ActualConnection == NULL )\r
+    return;\r
+\r
+  switch( evt->button( ) )\r
+  {\r
+  case Qt::LeftButton:\r
+  {\r
+    InputPort* port2 =\r
+      dynamic_cast< InputPort* >( this->itemAt( evt->scenePos( ) ) );\r
+    if( port2 != NULL )\r
+    {\r
+      OutputPort* port1 =\r
+        dynamic_cast< OutputPort* >( this->m_ActualConnection->port1( ) );\r
+      if( port1 != NULL )\r
+      {\r
+        if(\r
+          port1->block( ) != port2->block( ) &&\r
+          !port2->hasConnection( ) &&\r
+          !port1->isConnected( port2 ) &&\r
+          !port2->isExtended( )\r
+          )\r
+        {\r
+          this->m_ActualConnection->setPos2( port2->scenePos( ) );\r
+          this->m_ActualConnection->setPort2( port2 );\r
+          this->m_ActualConnection->updatePosFromPorts( );\r
+          this->m_ActualConnection->updatePath( );\r
+\r
+          this->m_Workspace->Connect(\r
+            port1->block( )->namePort( ).toStdString( ),\r
+            port2->block( )->namePort( ).toStdString( ),\r
+            port1->name( ).toStdString( ),\r
+            port2->name( ).toStdString( )\r
+            );\r
+          this->m_Graph->AddEdge(\r
+            port1->block( )->namePort( ).toStdString( ),\r
+            port2->block( )->namePort( ).toStdString( ),\r
+            this->m_ActualConnection\r
+            );\r
+        }\r
+        else\r
+          delete this->m_ActualConnection;\r
+      }\r
+      else\r
+        delete this->m_ActualConnection;\r
+    }\r
+    else\r
+      delete this->m_ActualConnection;\r
+    this->m_ActualConnection = NULL;\r
+  }\r
+  break;\r
+  default:\r
+    break;\r
+  } // hctisw\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor_Editor_Callback_CODE( Move )\r
+{\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor_Editor_Callback_CODE( Resize )\r
+{\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor_Editor_Callback_CODE( Wheel )\r
+{\r
+}\r
+\r
+// eof - $RCSfile$\r
diff --git a/lib/cpPipelineEditor/Editor.h b/lib/cpPipelineEditor/Editor.h
new file mode 100644 (file)
index 0000000..51c8768
--- /dev/null
@@ -0,0 +1,111 @@
+#ifndef __CPPIPELINEEDITOR__EDITOR__H__\r
+#define __CPPIPELINEEDITOR__EDITOR__H__\r
+\r
+#include <cpPipelineEditor/cpPipelineEditor_Export.h>\r
+#include <cpExtensions/DataStructures/Graph.h>\r
+#include <cpPlugins/Interface/Workspace.h>\r
+#include <QObject>\r
+#include <QPointF>\r
+\r
+class QGraphicsScene;\r
+class QGraphicsSceneMouseEvent;\r
+class QGraphicsItem;\r
+class QGraphicsSceneContextMenuEvent;\r
+class QGraphicsSceneDragDropEvent;\r
+class QGraphicsSceneHelpEvent;\r
+class QGraphicsSceneHoverEvent;\r
+class QGraphicsSceneMouseEvent;\r
+class QGraphicsSceneMoveEvent;\r
+class QGraphicsSceneResizeEvent;\r
+class QGraphicsSceneWheelEvent;\r
+\r
+// -------------------------------------------------------------------------\r
+#define cpPipelineEditor_Editor_Callback_DCL( E )       \\r
+  void _##E##_cbk( QGraphicsScene##E##Event* e );\r
+\r
+namespace cpPipelineEditor\r
+{\r
+  class Connection;\r
+  class Block;\r
+\r
+  /**\r
+   */\r
+  class cpPipelineEditor_EXPORT Editor\r
+    : public QObject\r
+  {\r
+    Q_OBJECT;\r
+\r
+  public:\r
+    typedef Editor Self;\r
+    typedef QObject      Superclass;\r
+\r
+    typedef cpPlugins::Interface::Workspace TWorkspace;\r
+    typedef TWorkspace::TFilter             TFilter;\r
+    typedef\r
+      cpExtensions::DataStructures::\r
+      Graph< Block*, Connection*, std::string > TGraph;\r
+\r
+  public:\r
+    explicit Editor( QObject* parent = 0 );\r
+    virtual ~Editor( );\r
+\r
+    TWorkspace* workspace( );\r
+    const TWorkspace* workspace( ) const;\r
+    void setWorkspace( TWorkspace* ws );\r
+\r
+    std::string createFilter(\r
+      const std::string& filter,\r
+      const QPointF& pnt = QPointF( qreal( 0 ), qreal( 0 ) )\r
+      );\r
+\r
+    void install( QGraphicsScene* s );\r
+    bool eventFilter( QObject* o, QEvent* e );\r
+\r
+  private:\r
+    QGraphicsItem* itemAt( const QPointF& pos );\r
+\r
+    inline void _createBlock( TFilter* f, const QPointF& pnt );\r
+\r
+  protected:\r
+    typedef QGraphicsSceneDragDropEvent QGraphicsSceneDragEnterEvent;\r
+    typedef QGraphicsSceneDragDropEvent QGraphicsSceneDragLeaveEvent;\r
+    typedef QGraphicsSceneDragDropEvent QGraphicsSceneDragMoveEvent;\r
+    typedef QGraphicsSceneDragDropEvent QGraphicsSceneDropEvent;\r
+    typedef QGraphicsSceneHoverEvent    QGraphicsSceneHoverEnterEvent;\r
+    typedef QGraphicsSceneHoverEvent    QGraphicsSceneHoverMoveEvent;\r
+    typedef QGraphicsSceneHoverEvent    QGraphicsSceneHoverLeaveEvent;\r
+    typedef QGraphicsSceneMouseEvent    QGraphicsSceneMouseDoubleClickEvent;\r
+    typedef QGraphicsSceneMouseEvent    QGraphicsSceneMouseMoveEvent;\r
+    typedef QGraphicsSceneMouseEvent    QGraphicsSceneMousePressEvent;\r
+    typedef QGraphicsSceneMouseEvent    QGraphicsSceneMouseReleaseEvent;\r
+\r
+    cpPipelineEditor_Editor_Callback_DCL( ContextMenu );\r
+    cpPipelineEditor_Editor_Callback_DCL( DragEnter );\r
+    cpPipelineEditor_Editor_Callback_DCL( DragLeave );\r
+    cpPipelineEditor_Editor_Callback_DCL( DragMove );\r
+    cpPipelineEditor_Editor_Callback_DCL( Drop );\r
+    cpPipelineEditor_Editor_Callback_DCL( Help );\r
+    cpPipelineEditor_Editor_Callback_DCL( HoverEnter );\r
+    cpPipelineEditor_Editor_Callback_DCL( HoverLeave );\r
+    cpPipelineEditor_Editor_Callback_DCL( HoverMove );\r
+    cpPipelineEditor_Editor_Callback_DCL( MouseDoubleClick );\r
+    cpPipelineEditor_Editor_Callback_DCL( MouseMove );\r
+    cpPipelineEditor_Editor_Callback_DCL( MousePress );\r
+    cpPipelineEditor_Editor_Callback_DCL( MouseRelease );\r
+    cpPipelineEditor_Editor_Callback_DCL( Move );\r
+    cpPipelineEditor_Editor_Callback_DCL( Resize );\r
+    cpPipelineEditor_Editor_Callback_DCL( Wheel );\r
+\r
+  private:\r
+    QGraphicsScene* m_Scene;\r
+    Connection* m_ActualConnection;\r
+\r
+    TWorkspace* m_Workspace;\r
+    TGraph::Pointer m_Graph;\r
+  };\r
+\r
+} // ecapseman\r
+\r
+#endif // __CPPIPELINEEDITOR__EDITOR__H__\r
+\r
+// eof - $RCSfile$\r
similarity index 62%
rename from appli/cpPipelineEditor/QNEPort.cxx
rename to lib/cpPipelineEditor/Port.cxx
index 7b71975d3eb636981a46523ecf454f6fd5a62814..ab478c298343960aa6bd064649c0fef71a5d4869 100644 (file)
@@ -1,31 +1,5 @@
-/* Copyright (c) 2012, STANISLAW ADASZEWSKI\r
-   All rights reserved.\r
-\r
-   Redistribution and use in source and binary forms, with or without\r
-   modification, are permitted provided that the following conditions are met:\r
-   * Redistributions of source code must retain the above copyright\r
-   notice, this list of conditions and the following disclaimer.\r
-   * Redistributions in binary form must reproduce the above copyright\r
-   notice, this list of conditions and the following disclaimer in the\r
-   documentation and/or other materials provided with the distribution.\r
-   * Neither the name of STANISLAW ADASZEWSKI nor the\r
-   names of its contributors may be used to endorse or promote products\r
-   derived from this software without specific prior written permission.\r
-\r
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
-   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
-   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
-   DISCLAIMED. IN NO EVENT SHALL STANISLAW ADASZEWSKI BE LIABLE FOR ANY\r
-   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
-   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
-   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
-   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
-   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-*/\r
-\r
-#include "QNEPort.h"\r
-#include "QNEConnection.h"\r
+#include "Port.h"\r
+#include "Connection.h"\r
 \r
 #include <QGraphicsScene>\r
 #include <QFontMetrics>\r
@@ -33,8 +7,8 @@
 #include <QPen>\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEPort::\r
-QNEPort( QGraphicsItem* parent, QGraphicsScene* scene )\r
+cpPipelineEditor::Port::\r
+Port( QGraphicsItem* parent, QGraphicsScene* scene )\r
   : Superclass( parent, scene ),\r
     m_Radius( 5 ),\r
     m_Margin( 2 )\r
@@ -53,20 +27,20 @@ QNEPort( QGraphicsItem* parent, QGraphicsScene* scene )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEPort::\r
-~QNEPort( )\r
+cpPipelineEditor::Port::\r
+~Port( )\r
 {\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEPort::\r
-setBlock( QNEBlock* b )\r
+void cpPipelineEditor::Port::\r
+setBlock( Block* b )\r
 {\r
   this->m_Block = b;\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEPort::\r
+void cpPipelineEditor::Port::\r
 setName( const QString& n )\r
 {\r
   this->m_Label->setPlainText( n );\r
@@ -74,7 +48,7 @@ setName( const QString& n )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEPort::\r
+void cpPipelineEditor::Port::\r
 setExtendedName( const QString& n )\r
 {\r
   this->m_ExtendedLabel->setPlainText( n );\r
@@ -82,7 +56,7 @@ setExtendedName( const QString& n )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEPort::\r
+void cpPipelineEditor::Port::\r
 setExtend( bool extend )\r
 {\r
   // Do nothing!\r
@@ -91,7 +65,7 @@ setExtend( bool extend )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEPort::\r
+void cpPipelineEditor::Port::\r
 paint(\r
   QPainter* painter,\r
   const QStyleOptionGraphicsItem* option,\r
@@ -116,20 +90,20 @@ paint(
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNENamePort::\r
-QNENamePort( QGraphicsItem* parent, QGraphicsScene* scene )\r
+cpPipelineEditor::NamePort::\r
+NamePort( QGraphicsItem* parent, QGraphicsScene* scene )\r
   : Superclass( parent, scene )\r
 {\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNENamePort::\r
-~QNENamePort( )\r
+cpPipelineEditor::NamePort::\r
+~NamePort( )\r
 {\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNENamePort::\r
+void cpPipelineEditor::NamePort::\r
 _updateLabels( )\r
 {\r
   QFont font( this->scene( )->font( ) );\r
@@ -140,27 +114,27 @@ _updateLabels( )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-bool PipelineEditor::QNENamePort::\r
-isConnected( QNEPort* other )\r
+bool cpPipelineEditor::NamePort::\r
+isConnected( Port* other )\r
 {\r
   return( false );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNETypePort::\r
-QNETypePort( QGraphicsItem* parent, QGraphicsScene* scene )\r
+cpPipelineEditor::TypePort::\r
+TypePort( QGraphicsItem* parent, QGraphicsScene* scene )\r
   : Superclass( parent, scene )\r
 {\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNETypePort::\r
-~QNETypePort( )\r
+cpPipelineEditor::TypePort::\r
+~TypePort( )\r
 {\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNETypePort::\r
+void cpPipelineEditor::TypePort::\r
 _updateLabels( )\r
 {\r
   QFont font( this->scene( )->font( ) );\r
@@ -171,30 +145,30 @@ _updateLabels( )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-bool PipelineEditor::QNETypePort::\r
-isConnected( QNEPort* other )\r
+bool cpPipelineEditor::TypePort::\r
+isConnected( Port* other )\r
 {\r
   return( false );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEInputPort::\r
-QNEInputPort( QGraphicsItem* parent, QGraphicsScene* scene )\r
+cpPipelineEditor::InputPort::\r
+InputPort( QGraphicsItem* parent, QGraphicsScene* scene )\r
   : Superclass( parent, scene ),\r
     m_Connection( NULL )\r
 {\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEInputPort::\r
-~QNEInputPort( )\r
+cpPipelineEditor::InputPort::\r
+~InputPort( )\r
 {\r
   if( this->m_Connection != NULL )\r
     delete this->m_Connection;\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEInputPort::\r
+void cpPipelineEditor::InputPort::\r
 _updateLabels( )\r
 {\r
   QFontMetrics fm( this->scene( )->font( ) );\r
@@ -206,7 +180,7 @@ _updateLabels( )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEInputPort::\r
+void cpPipelineEditor::InputPort::\r
 setExtend( bool extend )\r
 {\r
   if( this->m_Connection == NULL )\r
@@ -219,8 +193,8 @@ setExtend( bool extend )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-bool PipelineEditor::QNEInputPort::\r
-isConnected( QNEPort* other )\r
+bool cpPipelineEditor::InputPort::\r
+isConnected( Port* other )\r
 {\r
   if( this->m_Connection != NULL )\r
     return(\r
@@ -232,14 +206,14 @@ isConnected( QNEPort* other )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEInputPort::\r
-setConnection( QNEConnection* c )\r
+void cpPipelineEditor::InputPort::\r
+setConnection( Connection* c )\r
 {\r
   this->m_Connection = c;\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-QVariant PipelineEditor::QNEInputPort::\r
+QVariant cpPipelineEditor::InputPort::\r
 itemChange( GraphicsItemChange change, const QVariant& value )\r
 {\r
   if( change == ItemScenePositionHasChanged )\r
@@ -256,22 +230,22 @@ itemChange( GraphicsItemChange change, const QVariant& value )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEOutputPort::\r
-QNEOutputPort( QGraphicsItem* parent, QGraphicsScene* scene )\r
+cpPipelineEditor::OutputPort::\r
+OutputPort( QGraphicsItem* parent, QGraphicsScene* scene )\r
   : Superclass( parent, scene )\r
 {\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEOutputPort::\r
-~QNEOutputPort( )\r
+cpPipelineEditor::OutputPort::\r
+~OutputPort( )\r
 {\r
-  foreach( QNEConnection* conn, this->m_Connections )\r
+  foreach( Connection* conn, this->m_Connections )\r
     delete conn;\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEOutputPort::\r
+void cpPipelineEditor::OutputPort::\r
 _updateLabels( )\r
 {\r
   QFontMetrics fm( this->scene( )->font( ) );\r
@@ -283,7 +257,7 @@ _updateLabels( )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEOutputPort::\r
+void cpPipelineEditor::OutputPort::\r
 setExtend( bool extend )\r
 {\r
   this->m_IsExtended = extend;\r
@@ -291,8 +265,8 @@ setExtend( bool extend )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-bool PipelineEditor::QNEOutputPort::\r
-isConnected( QNEPort* other )\r
+bool cpPipelineEditor::OutputPort::\r
+isConnected( Port* other )\r
 {\r
   auto i = this->m_Connections.begin( );\r
   bool conn = false;\r
@@ -302,12 +276,12 @@ isConnected( QNEPort* other )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-QVariant PipelineEditor::QNEOutputPort::\r
+QVariant cpPipelineEditor::OutputPort::\r
 itemChange( GraphicsItemChange change, const QVariant& value )\r
 {\r
   if( change == ItemScenePositionHasChanged )\r
   {\r
-    foreach( QNEConnection* conn, this->m_Connections )\r
+    foreach( Connection* conn, this->m_Connections )\r
     {\r
       conn->updatePosFromPorts( );\r
       conn->updatePath( );\r
diff --git a/lib/cpPipelineEditor/Port.h b/lib/cpPipelineEditor/Port.h
new file mode 100644 (file)
index 0000000..0f64a4b
--- /dev/null
@@ -0,0 +1,190 @@
+#ifndef __CPPIPELINEEDITOR__PORT__H__\r
+#define __CPPIPELINEEDITOR__PORT__H__\r
+\r
+#include <cpPipelineEditor/cpPipelineEditor_Export.h>\r
+#include <QGraphicsPathItem>\r
+\r
+namespace cpPipelineEditor\r
+{\r
+  class Block;\r
+  class Connection;\r
+\r
+  /**\r
+   */\r
+  class cpPipelineEditor_EXPORT Port\r
+    : public QGraphicsPathItem\r
+  {\r
+  public:\r
+    typedef Port Self;\r
+    typedef QGraphicsPathItem Superclass;\r
+\r
+    enum { Type = QGraphicsItem::UserType + 1 };\r
+\r
+  public:\r
+    Port( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
+    virtual ~Port( );\r
+\r
+    void setBlock( Block* b );\r
+    inline Block* block( ) const\r
+      { return( this->m_Block ); }\r
+\r
+    virtual void setName( const QString& n );\r
+    virtual void setExtendedName( const QString& n );\r
+    inline QString name( ) const\r
+      { return( this->m_Label->toPlainText( ) ); }\r
+    inline QString extendedName( ) const\r
+      { return( this->m_ExtendedLabel->toPlainText( ) ); }\r
+\r
+    inline int radius( ) const\r
+      { return( this->m_Radius ); }\r
+\r
+    inline bool isExtended( ) const\r
+      { return( this->m_IsExtended ); }\r
+    virtual void setExtend( bool extend );\r
+\r
+    virtual bool isConnected( Port* other ) = 0;\r
+    inline int type( ) const\r
+      { return( this->Type ); }\r
+\r
+    virtual void paint(\r
+      QPainter* painter,\r
+      const QStyleOptionGraphicsItem* option,\r
+      QWidget* widget\r
+      );\r
+\r
+  protected:\r
+    virtual void _updateLabels( ) { }\r
+\r
+  protected:\r
+    Block* m_Block;\r
+\r
+    int  m_Radius;\r
+    int  m_Margin;\r
+    bool m_IsExtended;\r
+\r
+    QGraphicsTextItem* m_Label;\r
+    QGraphicsTextItem* m_ExtendedLabel;\r
+  };\r
+\r
+  /**\r
+   */\r
+  class NamePort\r
+    : public Port\r
+  {\r
+  public:\r
+    typedef NamePort Self;\r
+    typedef Port     Superclass;\r
+\r
+    enum { Type = Superclass::Type + 1 };\r
+\r
+  public:\r
+    NamePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
+    virtual ~NamePort( );\r
+\r
+    virtual bool isConnected( Port* other );\r
+    inline int type( ) const\r
+      { return( this->Type ); }\r
+\r
+  protected:\r
+    virtual void _updateLabels( );\r
+  };\r
+\r
+  /**\r
+   */\r
+  class TypePort\r
+    : public Port\r
+  {\r
+  public:\r
+    typedef TypePort Self;\r
+    typedef Port     Superclass;\r
+\r
+    enum { Type = Superclass::Type + 2 };\r
+\r
+  public:\r
+    TypePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
+    virtual ~TypePort( );\r
+\r
+    virtual bool isConnected( Port* other );\r
+    inline int type( ) const\r
+      { return( this->Type ); }\r
+\r
+  protected:\r
+    virtual void _updateLabels( );\r
+  };\r
+\r
+  /**\r
+   */\r
+  class InputPort\r
+    : public Port\r
+  {\r
+  public:\r
+    typedef InputPort Self;\r
+    typedef Port      Superclass;\r
+\r
+    enum { Type = Superclass::Type + 3 };\r
+\r
+  public:\r
+    InputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
+    virtual ~InputPort( );\r
+\r
+    virtual void setExtend( bool extend );\r
+\r
+    virtual bool isConnected( Port* other );\r
+    inline int type( ) const\r
+      { return( this->Type ); }\r
+\r
+    void setConnection( Connection* c );\r
+    inline Connection* connection( )\r
+      { return( this->m_Connection ); }\r
+    inline const Connection* connection( ) const\r
+      { return( this->m_Connection ); }\r
+    inline bool hasConnection( ) const\r
+      { return( this->m_Connection != NULL ); }\r
+\r
+  protected:\r
+    QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
+    virtual void _updateLabels( );\r
+\r
+  protected:\r
+    Connection* m_Connection;\r
+  };\r
+\r
+  /**\r
+   */\r
+  class OutputPort\r
+    : public Port\r
+  {\r
+  public:\r
+    typedef OutputPort Self;\r
+    typedef Port       Superclass;\r
+\r
+    enum { Type = Superclass::Type + 4 };\r
+\r
+  public:\r
+    OutputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
+    virtual ~OutputPort( );\r
+\r
+    virtual void setExtend( bool extend );\r
+\r
+    virtual bool isConnected( Port* other );\r
+    inline int type( ) const\r
+      { return( this->Type ); }\r
+\r
+    inline QVector< Connection* >& connections( )\r
+      { return( this->m_Connections ); }\r
+    inline const QVector< Connection* >& connections( ) const\r
+      { return( this->m_Connections ); }\r
+\r
+  protected:\r
+    QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
+    virtual void _updateLabels( );\r
+\r
+  protected:\r
+    QVector< Connection* > m_Connections;\r
+  };\r
+\r
+} // ecapseman\r
+\r
+#endif // __CPPIPELINEEDITOR__PORT__H__\r
+\r
+// eof - $RCSfile$\r
index 52b2e47d423eccc3463a89a133de20acd5982d7b..1b239725411c8b5cc87e947b3c6ce6db21db0f7f 100644 (file)
@@ -1,5 +1,6 @@
 #include <cpPlugins/Interface/Parameters.h>
 #include <cpPlugins/Interface/ProcessObject.h>
+#include <third_party/tinyxml/tinyxml.h>
 
 #include <sstream>
 
@@ -460,6 +461,122 @@ SetSelectedChoice( const TString& name, const TString& choice )
     return( false );
 }
 
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Parameters::
+ToXML( TiXmlElement* parent_elem ) const
+{
+  if( parent_elem == NULL )
+    return( false );
+
+  auto pIt = this->m_Parameters.begin( );
+  for( ; pIt != this->m_Parameters.end( ); ++pIt )
+  {
+    TiXmlElement* p = new TiXmlElement( "parameter" );
+    p->SetAttribute( "name", pIt->first.c_str( ) );
+    p->SetAttribute( "value", pIt->second.second.c_str( ) );
+    if( pIt->second.first == Self::String )
+      p->SetAttribute( "type", "String" );
+    else if( pIt->second.first == Self::Bool )
+      p->SetAttribute( "type", "Bool" );
+    else if( pIt->second.first == Self::Int )
+      p->SetAttribute( "type", "Int" );
+    else if( pIt->second.first == Self::Uint )
+      p->SetAttribute( "type", "Uint" );
+    else if( pIt->second.first == Self::Real )
+      p->SetAttribute( "type", "Real" );
+    else if( pIt->second.first == Self::Index )
+      p->SetAttribute( "type", "Index" );
+    else if( pIt->second.first == Self::Point )
+      p->SetAttribute( "type", "Point" );
+    else if( pIt->second.first == Self::Vector )
+      p->SetAttribute( "type", "Vector" );
+    else if( pIt->second.first == Self::StringList )
+      p->SetAttribute( "type", "StringList" );
+    else if( pIt->second.first == Self::BoolList )
+      p->SetAttribute( "type", "BoolList" );
+    else if( pIt->second.first == Self::IntList )
+      p->SetAttribute( "type", "IntList" );
+    else if( pIt->second.first == Self::UintList )
+      p->SetAttribute( "type", "UintList" );
+    else if( pIt->second.first == Self::RealList )
+      p->SetAttribute( "type", "RealList" );
+    else if( pIt->second.first == Self::IndexList )
+      p->SetAttribute( "type", "IndexList" );
+    else if( pIt->second.first == Self::PointList )
+      p->SetAttribute( "type", "PointList" );
+    else if( pIt->second.first == Self::VectorList )
+      p->SetAttribute( "type", "VectorList" );
+    else if( pIt->second.first == Self::Choices )
+      p->SetAttribute( "type", "Choices" );
+    parent_elem->LinkEndChild( p );
+
+  } // rof
+  return( true );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Parameters::
+FromXML( const TiXmlElement* filter_elem )
+{
+  this->m_Parameters.clear( );
+
+  const TiXmlElement* param = filter_elem->FirstChildElement( "parameter" );
+  bool ret = false;
+  while( param != NULL )
+  {
+    const char* param_name = param->Attribute( "name" );
+    const char* param_type = param->Attribute( "type" );
+    if( param_name != NULL && param_type != NULL )
+    {
+      TParameter value;
+      value.second = param->Attribute( "value" );
+
+      std::string param_type_str( param_type );
+      if( param_type_str == "Bool" )
+        value.first = Self::Bool;
+      else if( param_type_str == "Int" )
+        value.first = Self::Int;
+      else if( param_type_str == "Uint" )
+        value.first = Self::Uint;
+      else if( param_type_str == "Real" )
+        value.first = Self::Real;
+      else if( param_type_str == "Index" )
+        value.first = Self::Index;
+      else if( param_type_str == "Point" )
+        value.first = Self::Point;
+      else if( param_type_str == "Vector" )
+        value.first = Self::Vector;
+      else if( param_type_str == "StringList" )
+        value.first = Self::StringList;
+      else if( param_type_str == "BoolList" )
+        value.first = Self::BoolList;
+      else if( param_type_str == "IntList" )
+        value.first = Self::IntList;
+      else if( param_type_str == "UintList" )
+        value.first = Self::UintList;
+      else if( param_type_str == "RealList" )
+        value.first = Self::RealList;
+      else if( param_type_str == "IndexList" )
+        value.first = Self::IndexList;
+      else if( param_type_str == "PointList" )
+        value.first = Self::PointList;
+      else if( param_type_str == "VectorList" )
+        value.first = Self::VectorList;
+      else if( param_type_str == "Choices" )
+        value.first = Self::Choices;
+      else
+        value.first = Self::String;
+
+      this->m_Parameters[ param_name ] = value;
+
+    } // fi
+    param = param->NextSiblingElement( "parameter" );
+    ret = true;
+
+  } // elihw
+  return( ret );
+}
+
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Parameters::
 Parameters( )
index dfcfc793300e552a1055e82cbda7725d888f39cd..d8a1f578bc9a7a1f532a4857ebae48cd2c6f26be 100644 (file)
@@ -11,6 +11,8 @@
 #include <itkObject.h>
 #include <itkObjectFactory.h>
 
+class TiXmlElement;
+
 namespace cpPlugins
 {
   namespace Interface
@@ -204,6 +206,9 @@ namespace cpPlugins
 
       bool SetSelectedChoice( const TString& name, const TString& choice );
 
+      bool ToXML( TiXmlElement* parent_elem ) const;
+      bool FromXML( const TiXmlElement* filter_elem );
+
     protected:
       Parameters( );
       virtual ~Parameters( );
index dfe66d9bf51ba197638a23eba5815f2ec7c20c93..be724acf5f186989cb7ccbbf7a3e518375a4f309 100644 (file)
@@ -3,7 +3,7 @@
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Workspace::
 Workspace( )
-  : m_Interface( NULL )
+  : m_Plugins( NULL )
 {
   this->m_Graph = TGraph::New( );
 }
@@ -16,26 +16,26 @@ cpPlugins::Interface::Workspace::
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Workspace::
-TInterface* cpPlugins::Interface::Workspace::
-GetInterface( )
+TPlugins* cpPlugins::Interface::Workspace::
+GetPlugins( )
 {
-  return( this->m_Interface );
+  return( this->m_Plugins );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::Workspace::
-SetInterface( TInterface* i )
+const cpPlugins::Interface::Workspace::
+TPlugins* cpPlugins::Interface::Workspace::
+GetPlugins( ) const
 {
-  if( this->m_Interface != i )
-    this->m_Interface = i;
+  return( this->m_Plugins );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Workspace::
-Clear( )
+SetPlugins( TPlugins* i )
 {
-  if( this->m_Graph.IsNotNull( ) )
-    this->m_Graph->Clear( );
+  if( this->m_Plugins != i )
+    this->m_Plugins = i;
 }
 
 // -------------------------------------------------------------------------
@@ -54,17 +54,65 @@ GetGraph( ) const
   return( this->m_Graph );
 }
 
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Workspace::
+Clear( )
+{
+  if( this->m_Graph.IsNotNull( ) )
+    this->m_Graph->Clear( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Workspace::
+ClearConnections( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::Workspace::
+TFilter* cpPlugins::Interface::Workspace::
+GetFilter( const std::string& name )
+{
+  TFilter* f =
+    dynamic_cast< TFilter* >(
+      this->m_Graph->GetVertex( name ).GetPointer( )
+      );
+  return( f );
+}
+
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::Workspace::
+TFilter* cpPlugins::Interface::Workspace::
+GetFilter( const std::string& name ) const
+{
+  const TFilter* f =
+    dynamic_cast< const TFilter* >(
+      this->m_Graph->GetVertex( name ).GetPointer( )
+      );
+  return( f );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Workspace::
+HasFilter( const std::string& name ) const
+{
+  if( this->m_Graph->HasVertexIndex( name ) )
+    return( this->GetFilter( name ) != NULL );
+  else
+    return( false );
+}
+
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Workspace::
 CreateFilter( const std::string& filter, const std::string& name )
 {
-  if( this->m_Interface == NULL )
+  if( this->m_Plugins == 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_Plugins->CreateObject( filter );
     if( f.IsNotNull( ) )
     {
       f->SetName( name );
@@ -79,6 +127,26 @@ CreateFilter( const std::string& filter, const std::string& name )
     return( true );
 }
 
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Workspace::
+RenameFilter( const std::string& old_name, const std::string& new_name )
+{
+  if( this->m_Graph->RenameVertex( old_name, new_name ) )
+  {
+    TFilter* f = this->GetFilter( new_name );
+    f->SetName( new_name );
+    return( true );
+  }
+  else
+    return( false );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Workspace::
+RemoveFilter( const std::string& name )
+{
+}
+
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Workspace::
 Connect(
@@ -94,7 +162,7 @@ Connect(
 
   // Real connection
   dest->SetInput( input_name, orig->GetOutput< TData >( output_name ) );
-  this->m_Graph->AddConnection(
+  this->m_Graph->AddEdge(
     orig_filter, dest_filter,
     TConnection( output_name, input_name )
     );
@@ -105,8 +173,8 @@ Connect(
 bool cpPlugins::Interface::Workspace::
 Connect( TData* input_object, const std::string& input_name )
 {
-  auto port = this->m_InputPorts.find( input_name );
-  if( port != this->m_InputPorts.end( ) )
+  auto port = this->m_ExposedInputPorts.find( input_name );
+  if( port != this->m_ExposedInputPorts.end( ) )
   {
     TFilter* filter = this->GetFilter( port->second.first );
     if( filter != NULL )
@@ -122,99 +190,100 @@ Connect( TData* input_object, const std::string& input_name )
 }
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::Workspace::
-TParameters* cpPlugins::Interface::Workspace::
-GetParameters( const std::string& name )
+bool cpPlugins::Interface::Workspace::
+Reduce( const std::string& name )
 {
-  TFilter* f = this->GetFilter( name );
-  if( f != NULL )
-    return( f->GetParameters( ) );
-  else
-    return( NULL );
+  return( false );
 }
 
 // -------------------------------------------------------------------------
-const cpPlugins::Interface::Workspace::
-TParameters* cpPlugins::Interface::Workspace::
-GetParameters( const std::string& name ) const
+void cpPlugins::Interface::Workspace::
+ExposeInputPort(
+  const std::string& name,
+  const std::string& filter, const std::string& filter_input
+  )
 {
-  const TFilter* f = this->GetFilter( name );
-  if( f != NULL )
-    return( f->GetParameters( ) );
-  else
-    return( NULL );
+  this->m_ExposedInputPorts[ name ] = TExposedPort( filter, filter_input );
 }
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::Workspace::
-TFilter* cpPlugins::Interface::Workspace::
-GetFilter( const std::string& name )
+void cpPlugins::Interface::Workspace::
+ExposeOutputPort(
+  const std::string& name,
+  const std::string& filter, const std::string& filter_output
+  )
 {
-  TFilter* f =
-    dynamic_cast< TFilter* >(
-      this->m_Graph->GetVertex( name ).GetPointer( )
-      );
-  return( f );
+  this->m_ExposedOutputPorts[ name ] = TExposedPort( filter, filter_output );
 }
 
 // -------------------------------------------------------------------------
-const cpPlugins::Interface::Workspace::
-TFilter* cpPlugins::Interface::Workspace::
-GetFilter( const std::string& name ) const
+void cpPlugins::Interface::Workspace::
+HideInputPort( const std::string& name )
 {
-  const TFilter* f =
-    dynamic_cast< const TFilter* >(
-      this->m_Graph->GetVertex( name ).GetPointer( )
-      );
-  return( f );
+  auto i = this->m_ExposedInputPorts.find( name );
+  if( i != this->m_ExposedInputPorts.end( ) )
+    this->m_ExposedInputPorts.erase( i );
 }
 
 // -------------------------------------------------------------------------
-bool cpPlugins::Interface::Workspace::
-HasFilter( const std::string& name ) const
+void cpPlugins::Interface::Workspace::
+HideOutputPort( const std::string& name )
 {
-  if( this->m_Graph->HasVertexIndex( name ) )
-    return( this->GetFilter( name ) != NULL );
-  else
-    return( false );
+  auto i = this->m_ExposedOutputPorts.find( name );
+  if( i != this->m_ExposedOutputPorts.end( ) )
+    this->m_ExposedOutputPorts.erase( i );
 }
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Workspace::
-Reduce( const std::string& name )
-{
-  return( false );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Workspace::
-AddInputPort(
-  const std::string& name,
-  const std::string& filter, const std::string& filter_input
+RenameExposedInputPort(
+  const std::string& old_name,
+  const std::string& new_name
   )
 {
-  std::cout << name << " " << filter << " " << filter_input << std::endl;
-
-  this->m_InputPorts[ name ] = TGlobalPort( filter, filter_input );
+  auto o = this->m_ExposedInputPorts.find( old_name );
+  auto n = this->m_ExposedInputPorts.find( new_name );
+  if(
+    o != this->m_ExposedInputPorts.end( ) &&
+    n == this->m_ExposedInputPorts.end( )
+    )
+  {
+    this->m_ExposedInputPorts[ new_name ] = o->second;
+    this->m_ExposedInputPorts.erase( o );
+  }
+  else
+    return( false );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::Workspace::
-AddOutputPort(
-  const std::string& name,
-  const std::string& filter, const std::string& filter_output
+bool cpPlugins::Interface::Workspace::
+RenameExposedOutputPort(
+  const std::string& old_name,
+  const std::string& new_name
   )
 {
-  this->m_OutputPorts[ name ] = TGlobalPort( filter, filter_output );
+  auto o = this->m_ExposedOutputPorts.find( old_name );
+  auto n = this->m_ExposedOutputPorts.find( new_name );
+  if(
+    o != this->m_ExposedOutputPorts.end( ) &&
+    n == this->m_ExposedOutputPorts.end( )
+    )
+  {
+    this->m_ExposedOutputPorts[ new_name ] = o->second;
+    this->m_ExposedOutputPorts.erase( o );
+  }
+  else
+    return( false );
 }
 
 // -------------------------------------------------------------------------
+/* TODO
 cpPlugins::Interface::Workspace::
 TData* cpPlugins::Interface::Workspace::
 GetOutput( const std::string& name )
 {
-  auto port = this->m_OutputPorts.find( name );
-  if( port != this->m_OutputPorts.end( ) )
+  auto port = this->m_ExposedOutputPorts.find( name );
+  if( port != this->m_ExposedOutputPorts.end( ) )
   {
     TFilter* f = this->GetFilter( port->second.first );
     if( f != NULL )
@@ -231,8 +300,8 @@ const cpPlugins::Interface::Workspace::
 TData* cpPlugins::Interface::Workspace::
 GetOutput( const std::string& name ) const
 {
-  auto port = this->m_OutputPorts.find( name );
-  if( port != this->m_OutputPorts.end( ) )
+  auto port = this->m_ExposedOutputPorts.find( name );
+  if( port != this->m_ExposedOutputPorts.end( ) )
   {
     const TFilter* f = this->GetFilter( port->second.first );
     if( f != NULL )
@@ -248,19 +317,20 @@ GetOutput( const std::string& name ) const
 void cpPlugins::Interface::Workspace::
 ClearInputPorts( )
 {
-  this->m_InputPorts.clear( );
+  this->m_ExposedInputPorts.clear( );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Workspace::
 ClearOutputPorts( )
 {
-  this->m_OutputPorts.clear( );
+  this->m_ExposedOutputPorts.clear( );
 }
+*/
 
 // -------------------------------------------------------------------------
 std::string cpPlugins::Interface::Workspace::
-Execute( )
+Execute( QWidget* p )
 {
   // Find sinks
   std::set< std::string > sinks = this->m_Graph->GetSinks( );
@@ -269,7 +339,7 @@ Execute( )
   std::string err = "";
   for( auto sIt = sinks.begin( ); sIt != sinks.end( ); ++sIt )
   {
-    std::string lerr = this->Execute( *sIt, NULL );
+    std::string lerr = this->Execute( *sIt, p );
     if( lerr != "" )
       err += lerr + std::string( "\n" );
 
index 919233f40fb0e4a60630bef7c23c7cba559ec8c3..1f2fadaeb4393b5911ef4e8ca269f33c72b5627c 100644 (file)
@@ -16,12 +16,12 @@ namespace cpPlugins
 {
   namespace Interface
   {
-    /**
+    /** \brief A complex pipeline
      */
     class cpPlugins_Interface_EXPORT Workspace
     {
     public:
-      typedef cpPlugins::Interface::Interface     TInterface;
+      typedef cpPlugins::Interface::Interface     TPlugins;
       typedef cpPlugins::Interface::Object        TObject;
       typedef cpPlugins::Interface::ProcessObject TFilter;
       typedef cpPlugins::Interface::DataObject    TData;
@@ -29,8 +29,8 @@ namespace cpPlugins
 
       // Various types
       typedef std::set< std::string >               TStringContainer;
-      typedef std::pair< std::string, std::string > TGlobalPort;
-      typedef std::map< std::string, TGlobalPort >  TGlobalPorts;
+      typedef std::pair< std::string, std::string > TExposedPort;
+      typedef std::map< std::string, TExposedPort > TExposedPorts;
 
       // Graph type
       typedef std::pair< std::string, std::string > TConnection;
@@ -43,57 +43,82 @@ namespace cpPlugins
       virtual ~Workspace( );
 
       // Plugins management
-      TInterface* GetInterface( );
-      void SetInterface( TInterface* i );
+      TPlugins* GetPlugins( );
+      const TPlugins* GetPlugins( ) const;
+      void SetPlugins( TPlugins* i );
 
       // Workspace IO
       std::string LoadWorkspace( const std::string& fname );
       std::string SaveWorkspace( const std::string& fname ) const;
 
       // Graph management
-      void Clear( );
       TGraph* GetGraph( );
       const TGraph* GetGraph( ) const;
+
+      void Clear( );
+      void ClearConnections( );
+
+      // Filter management
+      TFilter* GetFilter( const std::string& name );
+      const TFilter* GetFilter( const std::string& name ) const;
+      bool HasFilter( const std::string& name ) const;
       bool CreateFilter( const std::string& filter, const std::string& name );
+      bool RenameFilter(
+        const std::string& old_name, const std::string& new_name
+        );
+      void RemoveFilter( const std::string& name );
+
+      // Connection management
       bool Connect(
         const std::string& orig_filter, const std::string& dest_filter,
-        const std::string& output_name,
-        const std::string& input_name
+        const std::string& output_name, const std::string& input_name
         );
-      bool Connect( TData* input_object, const std::string& input_name );
-      TParameters* GetParameters( const std::string& name );
-      const TParameters* GetParameters( const std::string& name ) const;
-      TFilter* GetFilter( const std::string& name );
-      const TFilter* GetFilter( const std::string& name ) const;
-      bool HasFilter( const std::string& name ) const;
+      bool Connect( TData* input_object, const std::string& exposed_port );
+      void RemoveConnection(
+        const std::string& dest_filter, const std::string& input_name
+        );
+      void RemoveConnection( const std::string& exposed_port );
+      void RemoveConnections( const std::string& dest_filter );
 
       // Graph reduction
       bool Reduce( const std::string& name );
-      void AddInputPort(
+      void ExposeInputPort(
         const std::string& name,
         const std::string& filter, const std::string& filter_input
         );
-      void AddOutputPort(
+      void ExposeOutputPort(
         const std::string& name,
         const std::string& filter, const std::string& filter_output
         );
-      TData* GetOutput( const std::string& name );
-      const TData* GetOutput( const std::string& name ) const;
-      void ClearInputPorts( );
-      void ClearOutputPorts( );
+      void HideInputPort( const std::string& name );
+      void HideOutputPort( const std::string& name );
+
+      bool RenameExposedInputPort(
+        const std::string& old_name,
+        const std::string& new_name
+        );
+      bool RenameExposedOutputPort(
+        const std::string& old_name,
+        const std::string& new_name
+        );
+
+      TData* GetExposedInput( const std::string& name );
+      const TData* GetExposedInput( const std::string& name ) const;
+      TData* GetExposedOutput( const std::string& name );
+      const TData* GetExposedOutput( const std::string& name ) const;
 
       // Pipeline execution
-      std::string Execute( );
+      std::string Execute( QWidget* p = NULL );
       std::string Execute( const std::string& name, QWidget* p = NULL );
 
     protected:
       // Plugins interface
-      TInterface* m_Interface;
+      TPlugins* m_Plugins;
 
       // Processing graph
       typename TGraph::Pointer m_Graph;
-      TGlobalPorts m_InputPorts;
-      TGlobalPorts m_OutputPorts;
+      TExposedPorts m_ExposedInputPorts;
+      TExposedPorts m_ExposedOutputPorts;
     };
 
   } // ecapseman
index 7e7a2bd5b63423ac9e7b114b04658a03850a7bba..1d0ea81e0b05582aad6fe32dcfa837ad99be8958 100644 (file)
@@ -32,61 +32,7 @@ LoadWorkspace( const std::string& fname )
 
         // Read parameters
         TParameters* parameters = new_filter->GetParameters( );
-        parameters->Clear( );
-
-        TiXmlElement* param = filter->FirstChildElement( "parameter" );
-        while( param != NULL )
-        {
-          const char* param_name = param->Attribute( "name" );
-          const char* param_type = param->Attribute( "type" );
-          if( param_name != NULL && param_type != NULL )
-          {
-            std::string param_type_str( param_type );
-            const char* value = param->Attribute( "value" );
-            if( value != NULL )
-            {
-              if( param_type_str == "String" )
-                parameters->ConfigureAsString( param_name );
-              else if( param_type_str == "Bool" )
-                parameters->ConfigureAsBool( param_name );
-              else if( param_type_str == "Int" )
-                parameters->ConfigureAsInt( param_name );
-              else if( param_type_str == "Uint" )
-                parameters->ConfigureAsUint( param_name );
-              else if( param_type_str == "Real" )
-                parameters->ConfigureAsReal( param_name );
-              else if( param_type_str == "Index" )
-                parameters->ConfigureAsIndex( param_name );
-              else if( param_type_str == "Point" )
-                parameters->ConfigureAsPoint( param_name );
-              else if( param_type_str == "Vector" )
-                parameters->ConfigureAsVector( param_name );
-              else if( param_type_str == "StringList" )
-                parameters->ConfigureAsStringList( param_name );
-              else if( param_type_str == "BoolList" )
-                parameters->ConfigureAsBoolList( param_name );
-              else if( param_type_str == "IntList" )
-                parameters->ConfigureAsIntList( param_name );
-              else if( param_type_str == "UintList" )
-                parameters->ConfigureAsUintList( param_name );
-              else if( param_type_str == "RealList" )
-                parameters->ConfigureAsRealList( param_name );
-              else if( param_type_str == "IndexList" )
-                parameters->ConfigureAsIndexList( param_name );
-              else if( param_type_str == "PointList" )
-                parameters->ConfigureAsPointList( param_name );
-              else if( param_type_str == "VectorList" )
-                parameters->ConfigureAsVectorList( param_name );
-              else if( param_type_str == "Choices" )
-                parameters->ConfigureAsChoices( param_name );
-              parameters->SetString( param_name, value, false );
-
-            } // fi
-
-          } // fi
-          param = param->NextSiblingElement( "parameter" );
-
-        } // elihw
+        parameters->FromXML( filter );
       }
       else
         err
@@ -122,6 +68,33 @@ LoadWorkspace( const std::string& fname )
 
   } // elihw
 
+  // Read exposed inputs
+  TiXmlElement* port = root->FirstChildElement( "exposed_input_port" );
+  while( port != NULL )
+  {
+    this->ExposeInputPort(
+      port->Attribute( "port_name" ),
+      port->Attribute( "filter" ),
+      port->Attribute( "filter_port_name" )
+      );
+    port = connection->NextSiblingElement( "exposed_input_port" );
+
+  } // elihw
+
+  // Read exposed outputs
+#error ACA VOY
+  port = root->FirstChildElement( "exposed_output_port" );
+  while( port != NULL )
+  {
+    this->ExposeOutputPort(
+      port->Attribute( "port_name" ),
+      port->Attribute( "filter" ),
+      port->Attribute( "filter_port_name" )
+      );
+    port = connection->NextSiblingElement( "exposed_output_port" );
+
+  } // elihw
+
   // Finish and return
   delete doc;
   return( err.str( ) );
@@ -150,52 +123,8 @@ SaveWorkspace( const std::string& fname ) const
       e->SetAttribute( "ViewY", filter->GetViewY( ) );
 
       const TParameters* params = filter->GetParameters( );
-      std::vector< std::string > names;
-      params->GetNames( names );
-      for( auto nIt = names.begin( ); nIt != names.end( ); ++nIt )
-      {
-        TiXmlElement* p = new TiXmlElement( "parameter" );
-        p->SetAttribute( "name", nIt->c_str( ) );
-        if( params->HasString( *nIt ) )
-          p->SetAttribute( "type", "String" );
-        else if( params->HasBool( *nIt ) ) 
-          p->SetAttribute( "type", "Bool" );
-        else if( params->HasInt( *nIt ) )
-          p->SetAttribute( "type", "Int" );
-        else if( params->HasUint( *nIt ) )
-          p->SetAttribute( "type", "Uint" );
-        else if( params->HasReal( *nIt ) )
-          p->SetAttribute( "type", "Real" );
-        else if( params->HasIndex( *nIt ) )
-          p->SetAttribute( "type", "Index" );
-        else if( params->HasPoint( *nIt ) )
-          p->SetAttribute( "type", "Point" );
-        else if( params->HasVector( *nIt ) )
-          p->SetAttribute( "type", "Vector" );
-        else if( params->HasStringList( *nIt ) )
-          p->SetAttribute( "type", "StringList" );
-        else if( params->HasBoolList( *nIt ) )
-          p->SetAttribute( "type", "BoolList" );
-        else if( params->HasIntList( *nIt ) )
-          p->SetAttribute( "type", "IntList" );
-        else if( params->HasUintList( *nIt ) )
-          p->SetAttribute( "type", "UintList" );
-        else if( params->HasRealList( *nIt ) )
-          p->SetAttribute( "type", "RealList" );
-        else if( params->HasIndexList( *nIt ) )
-          p->SetAttribute( "type", "IndexList" );
-        else if( params->HasPointList( *nIt ) )
-          p->SetAttribute( "type", "PointList" );
-        else if( params->HasVectorList( *nIt ) )
-          p->SetAttribute( "type", "VectorList" );
-        else if( params->HasChoices( *nIt ) )
-          p->SetAttribute( "type", "Choices" );
-        p->SetAttribute(
-          "value", params->GetString( *nIt, false ).c_str( )
-          );
-        e->LinkEndChild( p );
+      params->ToXML( e );
 
-      } // rof
       root->LinkEndChild( e );
     }
     else if( data != NULL )
@@ -233,6 +162,29 @@ SaveWorkspace( const std::string& fname ) const
 
   } // rof
 
+  // Save exposed ports
+  auto eipIt = this->m_ExposedInputPorts.begin( );
+  for( ; eipIt != this->m_ExposedInputPorts.end( ); ++eipIt )
+  {
+    TiXmlElement* port = new TiXmlElement( "exposed_input_port" );
+    port->SetAttribute( "port_name", eipIt->first.c_str( ) );
+    port->SetAttribute( "filter", eipIt->second.first.c_str( ) );
+    port->SetAttribute( "filter_port_name", eipIt->second.second.c_str( ) );
+    root->LinkEndChild( port );
+
+  } // rof
+
+  auto eopIt = this->m_ExposedOutputPorts.begin( );
+  for( ; eopIt != this->m_ExposedOutputPorts.end( ); ++eopIt )
+  {
+    TiXmlElement* port = new TiXmlElement( "exposed_output_port" );
+    port->SetAttribute( "port_name", eopIt->first.c_str( ) );
+    port->SetAttribute( "filter", eopIt->second.first.c_str( ) );
+    port->SetAttribute( "filter_port_name", eopIt->second.second.c_str( ) );
+    root->LinkEndChild( port );
+
+  } // rof
+
   // Physical write and return
   doc->LinkEndChild( root );
   doc->SaveFile( fname.c_str( ) );