SUBDIRS(
examples
ImageMPR
- cpPipelineEditor
)
+ IF(USE_QT4)
+ SUBDIRS(
+ cpPipelineEditor
+ )
+ ENDIF(USE_QT4)
ENDIF(BUILD_EXAMPLES)
## eof - $RCSfile$
-#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 );
// 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 )
}
// -------------------------------------------------------------------------
-void cpPipelineEditor::
+void App_cpPipelineEditor::
_UpdateLoadedPlugins( )
{
auto& classes = this->m_Plugins->GetClasses( );
}
// -------------------------------------------------------------------------
-void cpPipelineEditor::
+void App_cpPipelineEditor::
_ButtonLoadPluginsFile( )
{
QFileDialog dlg( this );
}
// -------------------------------------------------------------------------
-void cpPipelineEditor::
+void App_cpPipelineEditor::
_ButtonLoadPluginsPath( )
{
QFileDialog dlg( this );
}
// -------------------------------------------------------------------------
-void cpPipelineEditor::
+void App_cpPipelineEditor::
_ActionOpenWorkspace( )
{
QFileDialog dlg( this );
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 != "" )
{
}
// -------------------------------------------------------------------------
-void cpPipelineEditor::
+void App_cpPipelineEditor::
_ActionSaveWorkspace( )
{
if( this->m_Workspace == NULL )
-#ifndef __CPPIPELINEEDITOR__H__
-#define __CPPIPELINEEDITOR__H__
+#ifndef __APP_CPPIPELINEEDITOR__H__
+#define __APP_CPPIPELINEEDITOR__H__
// Qt stuff
#include <QMainWindow>
// -------------------------------------------------------------------------
namespace Ui
{
- class cpPipelineEditor;
+ class App_cpPipelineEditor;
}
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( );
void _ActionSaveWorkspace( );
private:
- Ui::cpPipelineEditor* m_UI;
+ Ui::App_cpPipelineEditor* m_UI;
cpPlugins::Interface::Workspace* m_Workspace;
cpPlugins::Interface::Interface* m_Plugins;
};
<?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">
-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$
+++ /dev/null
-/* 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
+++ /dev/null
-/* 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
+++ /dev/null
-/* 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
+++ /dev/null
-/* 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
+++ /dev/null
-/* 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
-#include "cpPipelineEditor.h"
+#include "App_cpPipelineEditor.h"
#include <cstdlib>
#include <QApplication>
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( ) );
cpPlugins
third_party
)
+IF(USE_QT4)
+ SUBDIRS(
+ cpPipelineEditor
+ )
+ENDIF(USE_QT4)
+
## eof - $RCSfile$
{
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
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 );
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:
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 >::
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
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 );
}
// -------------------------------------------------------------------------
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( ) )
} // 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 >::
-/* 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
}\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
}\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
}\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
}\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
}\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
}\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
}\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
}\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
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
}\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
--- /dev/null
+#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
--- /dev/null
+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$
-#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 );
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 );
// -------------------------------------------------------------------------
/* 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(
}
// -------------------------------------------------------------------------
-void PipelineEditor::QNodesEditorCanvas::
+void cpPipelineEditor::Canvas::
dragEnterEvent( QDragEnterEvent* event )
{
const QMimeData* mime = event->mimeData( );
}
// -------------------------------------------------------------------------
-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( );
}
// -------------------------------------------------------------------------
-void PipelineEditor::QNodesEditorCanvas::
+void cpPipelineEditor::Canvas::
_scaleView( qreal scaleFactor )
{
qreal factor = this->transform( ).
// -------------------------------------------------------------------------
/*
-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;
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( ) );
-#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
void _scaleView( qreal scaleFactor );
protected:
- QNodesEditor* m_Editor;
+ Editor* m_Editor;
};
} // ecapseman
-#endif // __PIPELINEEDITOR__QNODESEDITORCANVAS__H__
+#endif // __CPPIPELINEEDITOR__CANVAS__H__
// eof - $RCSfile$
-/* 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
}\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
}\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
}\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
}\r
\r
// -------------------------------------------------------------------------\r
-void PipelineEditor::QNEConnection::\r
+void cpPipelineEditor::Connection::\r
updatePosFromPorts( )\r
{\r
if( this->m_Port1 != NULL )\r
}\r
\r
// -------------------------------------------------------------------------\r
-void PipelineEditor::QNEConnection::\r
+void cpPipelineEditor::Connection::\r
updatePath( )\r
{\r
QPainterPath p;\r
}\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
--- /dev/null
+#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
--- /dev/null
+#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
--- /dev/null
+#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
-/* 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
#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
}\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
}\r
\r
// -------------------------------------------------------------------------\r
-void PipelineEditor::QNEPort::\r
+void cpPipelineEditor::Port::\r
setExtendedName( const QString& n )\r
{\r
this->m_ExtendedLabel->setPlainText( n );\r
}\r
\r
// -------------------------------------------------------------------------\r
-void PipelineEditor::QNEPort::\r
+void cpPipelineEditor::Port::\r
setExtend( bool extend )\r
{\r
// Do nothing!\r
}\r
\r
// -------------------------------------------------------------------------\r
-void PipelineEditor::QNEPort::\r
+void cpPipelineEditor::Port::\r
paint(\r
QPainter* painter,\r
const QStyleOptionGraphicsItem* option,\r
}\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
}\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
}\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
}\r
\r
// -------------------------------------------------------------------------\r
-void PipelineEditor::QNEInputPort::\r
+void cpPipelineEditor::InputPort::\r
setExtend( bool extend )\r
{\r
if( this->m_Connection == NULL )\r
}\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
}\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
}\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
}\r
\r
// -------------------------------------------------------------------------\r
-void PipelineEditor::QNEOutputPort::\r
+void cpPipelineEditor::OutputPort::\r
setExtend( bool extend )\r
{\r
this->m_IsExtended = extend;\r
}\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
}\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
--- /dev/null
+#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
#include <cpPlugins/Interface/Parameters.h>
#include <cpPlugins/Interface/ProcessObject.h>
+#include <third_party/tinyxml/tinyxml.h>
#include <sstream>
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( )
#include <itkObject.h>
#include <itkObjectFactory.h>
+class TiXmlElement;
+
namespace cpPlugins
{
namespace Interface
bool SetSelectedChoice( const TString& name, const TString& choice );
+ bool ToXML( TiXmlElement* parent_elem ) const;
+ bool FromXML( const TiXmlElement* filter_elem );
+
protected:
Parameters( );
virtual ~Parameters( );
// -------------------------------------------------------------------------
cpPlugins::Interface::Workspace::
Workspace( )
- : m_Interface( NULL )
+ : m_Plugins( NULL )
{
this->m_Graph = TGraph::New( );
}
// -------------------------------------------------------------------------
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;
}
// -------------------------------------------------------------------------
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 );
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(
// 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 )
);
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 )
}
// -------------------------------------------------------------------------
-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 )
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 )
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( );
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" );
{
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;
// 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;
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
// 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
} // 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( ) );
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 )
} // 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( ) );