]> Creatis software - cpPlugins.git/commitdiff
More on PipelineEditor
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 10 Dec 2015 23:07:32 +0000 (18:07 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 10 Dec 2015 23:07:32 +0000 (18:07 -0500)
12 files changed:
appli/cpPipelineEditor/CMakeLists.txt
appli/cpPipelineEditor/Edge.cxx
appli/cpPipelineEditor/Edge.h
appli/cpPipelineEditor/GraphCanvas.cxx [moved from appli/cpPipelineEditor/GraphWidget.cxx with 50% similarity]
appli/cpPipelineEditor/GraphCanvas.h [new file with mode: 0644]
appli/cpPipelineEditor/GraphWidget.h [deleted file]
appli/cpPipelineEditor/Node.cxx
appli/cpPipelineEditor/Node.h
appli/cpPipelineEditor/cpPipelineEditor.cxx
appli/cpPipelineEditor/cpPipelineEditor.ui
lib/cpPlugins/Interface/ProcessObject.cxx
lib/cpPlugins/Interface/ProcessObject.h

index 5ecebcdd1499986311dfff071f0ecde82d6a8b9a..002e6e26ef9df23a86a7cc2d0b89ca7774272849 100644 (file)
@@ -11,7 +11,7 @@ IF(USE_QT4)
   SET(
     App_QT_SOURCES
     Edge.cxx
-    GraphWidget.cxx
+    GraphCanvas.cxx
     Node.cxx
     cpPipelineEditor.cxx
     )
@@ -21,9 +21,7 @@ IF(USE_QT4)
     )
   SET(
     App_QT_HEADERS
-    Edge.h
-    GraphWidget.h
-    Node.h
+    GraphCanvas.h
     cpPipelineEditor.h
     )
   SET(
index 1442a61ad2fac751c9d37a6c3e61a882dae8a6e1..5c515eecd0c65cdc6e98437b1beca478c0457980 100644 (file)
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-**   * Redistributions of source code must retain the above copyright
-**     notice, this list of conditions and the following disclaimer.
-**   * Redistributions in binary form must reproduce the above copyright
-**     notice, this list of conditions and the following disclaimer in
-**     the documentation and/or other materials provided with the
-**     distribution.
-**   * Neither the name of The Qt Company Ltd nor the names of its
-**     contributors may be used to endorse or promote products derived
-**     from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QPainter>
-
 #include "Edge.h"
 #include "Node.h"
 
-#include <math.h>
-
-static const double Pi = 3.14159265358979323846264338327950288419717;
-static double TwoPi = 2.0 * Pi;
-
-Edge::Edge(Node *sourceNode, Node *destNode)
-    : arrowSize(10)
+// -------------------------------------------------------------------------
+PipelineEditor::Edge::
+Edge( PipelineEditor::Node* src, PipelineEditor::Node* des )
+  : QGraphicsItem( NULL ),
+    m_ArrowSize( 10 )
 {
-    setAcceptedMouseButtons(0);
-    source = sourceNode;
-    dest = destNode;
-    source->addEdge(this);
-    dest->addEdge(this);
-    this->setToolTip( "Edge!!!" );
-    adjust();
+  this->setAcceptedMouseButtons( 0 );
+  this->m_Source = src;
+  this->m_Destination = des;
+  this->m_Source->addEdge( this );
+  this->m_Destination->addEdge( this );
+  // TODO: this->setToolTip( "Edge!!!" );
+  this->adjust( );
 }
 
-Node *Edge::sourceNode() const
+// -------------------------------------------------------------------------
+PipelineEditor::Edge::
+~Edge( )
 {
-    return source;
 }
 
-Node *Edge::destNode() const
+// -------------------------------------------------------------------------
+PipelineEditor::Node* PipelineEditor::Edge::
+sourceNode( ) const
 {
-    return dest;
+  return( this->m_Source );
 }
 
-void Edge::adjust()
+// -------------------------------------------------------------------------
+PipelineEditor::Node* PipelineEditor::Edge::
+destinationNode( ) const
 {
-    if (!source || !dest)
-        return;
-
-    QLineF line(mapFromItem(source, 0, 0), mapFromItem(dest, 0, 0));
-    qreal length = line.length();
-
-    prepareGeometryChange();
-
-    if (length > qreal(20.)) {
-        QPointF edgeOffset((line.dx() * 10) / length, (line.dy() * 10) / length);
-        sourcePoint = line.p1() + edgeOffset;
-        destPoint = line.p2() - edgeOffset;
-    } else {
-        sourcePoint = destPoint = line.p1();
-    }
+  return( this->m_Destination );
 }
 
-QRectF Edge::boundingRect() const
+// -------------------------------------------------------------------------
+void PipelineEditor::Edge::
+adjust( )
 {
-    if (!source || !dest)
-        return QRectF();
-
-    qreal penWidth = 1;
-    qreal extra = (penWidth + arrowSize) / 2.0;
+  if( this->m_Source == NULL || this->m_Destination == NULL )
+    return;
+
+  QLineF line(
+    mapFromItem( this->m_Source, 0, 0 ),
+    mapFromItem( this->m_Destination, 0, 0 )
+    );
+  qreal length = line.length( );
+
+  this->prepareGeometryChange( );
+
+  if( length > qreal( 20 ) )
+  {
+    QPointF edgeOffset(
+      ( line.dx( ) * qreal( 10 ) ) / length,
+      ( line.dy( ) * qreal( 10 ) ) / length
+      );
+    this->m_SourcePoint = line.p1( ) + edgeOffset;
+    this->m_DestinationPoint = line.p2( ) - edgeOffset;
+  }
+  else
+    this->m_SourcePoint = this->m_DestinationPoint = line.p1( );
+}
 
-    return QRectF(sourcePoint, QSizeF(destPoint.x() - sourcePoint.x(),
-                                      destPoint.y() - sourcePoint.y()))
-        .normalized()
-        .adjusted(-extra, -extra, extra, extra);
+// -------------------------------------------------------------------------
+QRectF PipelineEditor::Edge::
+boundingRect( ) const
+{
+  if( this->m_Source == NULL || this->m_Destination == NULL )
+    return( QRectF( ) );
+
+  qreal penWidth = 1;
+  qreal extra = ( penWidth + this->m_ArrowSize ) / qreal( 2 );
+
+  return(
+    QRectF(
+      this->m_SourcePoint,
+      QSizeF(
+        this->m_DestinationPoint.x( ) - this->m_SourcePoint.x( ),
+        this->m_DestinationPoint.y( ) - this->m_SourcePoint.y( )
+        )
+      ).normalized( ).adjusted( -extra, -extra, extra, extra )
+    );
 }
 
-void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+// -------------------------------------------------------------------------
+void PipelineEditor::Edge::
+paint(
+  QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget
+  )
 {
-    if (!source || !dest)
-        return;
+  /* TODO
+  if (!source || !dest)
+      return;
 
     QLineF line(sourcePoint, destPoint);
     if (qFuzzyCompare(line.length(), qreal(0.)))
@@ -135,6 +122,7 @@ void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
     painter->setBrush(Qt::black);
     painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2);
     painter->drawText( center, "Edge!!!" );
+  */
 }
 
 // eof - $RCSfile$
index 49bf282e208165be4417cf85267db1fc9451659c..4968fb3841e68f29be62bb7ca5185e2637b9cd1b 100644 (file)
@@ -1,73 +1,43 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-**   * Redistributions of source code must retain the above copyright
-**     notice, this list of conditions and the following disclaimer.
-**   * Redistributions in binary form must reproduce the above copyright
-**     notice, this list of conditions and the following disclaimer in
-**     the documentation and/or other materials provided with the
-**     distribution.
-**   * Neither the name of The Qt Company Ltd nor the names of its
-**     contributors may be used to endorse or promote products derived
-**     from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef EDGE_H
-#define EDGE_H
+#ifndef __PIPELINEEDITOR__EDGE__H__
+#define __PIPELINEEDITOR__EDGE__H__
 
 #include <QGraphicsItem>
 
-class Node;
-
-class Edge : public QGraphicsItem
+namespace PipelineEditor
 {
-public:
-    Edge(Node *sourceNode, Node *destNode);
-
-    Node *sourceNode() const;
-    Node *destNode() const;
-
-    void adjust();
-
-    enum { Type = UserType + 2 };
-    int type() const { return Type; }
-
-protected:
-    QRectF boundingRect() const;
-    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
-
-private:
-    Node *source, *dest;
-
-    QPointF sourcePoint;
-    QPointF destPoint;
-    qreal arrowSize;
-};
-
-#endif
+  // Some forward declarations
+  class Node;
+
+  /**
+   */
+  class Edge
+    : public QGraphicsItem
+  {
+  public:
+    Edge( Node* src, Node* des );
+    virtual ~Edge( );
+
+    Node* sourceNode( ) const;
+    Node* destinationNode( ) const;
+    void adjust( );
+    QRectF boundingRect( ) const;
+    void paint(
+      QPainter* painter,
+      const QStyleOptionGraphicsItem* option,
+      QWidget* widget
+      );
+
+  private:
+    Node* m_Source;
+    Node* m_Destination;
+
+    QPointF m_SourcePoint;
+    QPointF m_DestinationPoint;
+    qreal m_ArrowSize;
+  };
+
+} // ecapseman
+
+#endif // __PIPELINEEDITOR__EDGE__H__
+
+// eof - $RCSfile$
similarity index 50%
rename from appli/cpPipelineEditor/GraphWidget.cxx
rename to appli/cpPipelineEditor/GraphCanvas.cxx
index 2eb9553f20402c1bf16e0968137df295d8c4f8e9..3b3041cdcd8afd0364a5d16b3e404d42eccbbaba 100644 (file)
-/****************************************************************************
- **
- ** Copyright (C) 2015 The Qt Company Ltd.
- ** Contact: http://www.qt.io/licensing/
- **
- ** This file is part of the examples of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:BSD$
- ** You may use this file under the terms of the BSD license as follows:
- **
- ** "Redistribution and use in source and binary forms, with or without
- ** modification, are permitted provided that the following conditions are
- ** met:
- **   * Redistributions of source code must retain the above copyright
- **     notice, this list of conditions and the following disclaimer.
- **   * Redistributions in binary form must reproduce the above copyright
- **     notice, this list of conditions and the following disclaimer in
- **     the documentation and/or other materials provided with the
- **     distribution.
- **   * Neither the name of The Qt Company Ltd nor the names of its
- **     contributors may be used to endorse or promote products derived
- **     from this software without specific prior written permission.
- **
- **
- ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- **
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
-
-#include "GraphWidget.h"
+#include "GraphCanvas.h"
 #include "Edge.h"
 #include "Node.h"
 
-#include <QtGui>
+#include <QWheelEvent>
 
 #include <cpPlugins/Interface/Workspace.h>
 
-#include <math.h>
-
-GraphWidget::GraphWidget( QWidget* parent )
+// -------------------------------------------------------------------------
+PipelineEditor::GraphCanvas::
+GraphCanvas( QWidget* parent )
   : QGraphicsView( parent ),
-    timerId( 0 ),
     m_Workspace( NULL )
 {
   QGraphicsScene* scene = new QGraphicsScene( this );
   scene->setItemIndexMethod( QGraphicsScene::NoIndex );
-  // TODO: scene->setSceneRect( -200, -200, 400, 400 );
   this->setScene( scene );
-  /* TODO
-     this->setCacheMode(CacheBackground);
-     this->setViewportUpdateMode(BoundingRectViewportUpdate);
-     this->setRenderHint(QPainter::Antialiasing);
-     this->setTransformationAnchor(AnchorUnderMouse);
-     this->scale(qreal(0.8), qreal(0.8));
-     this->setMinimumSize(400, 400);
-     this->setWindowTitle( tr("Elastic Nodes") );
-  */
+}
 
-  /*
-    Node *node1 = new Node(this);
-    Node *node2 = new Node(this);
-    Node *node3 = new Node(this);
-    Node *node4 = new Node(this);
-    centerNode = new Node(this);
-    Node *node6 = new Node(this);
-    Node *node7 = new Node(this);
-    Node *node8 = new Node(this);
-    Node *node9 = new Node(this);
-    scene->addItem(node1);
-    scene->addItem(node2);
-    scene->addItem(node3);
-    scene->addItem(node4);
-    scene->addItem(centerNode);
-    scene->addItem(node6);
-    scene->addItem(node7);
-    scene->addItem(node8);
-    scene->addItem(node9);
-    scene->addItem(new Edge(node1, node2));
-    scene->addItem(new Edge(node2, node3));
-    scene->addItem(new Edge(node2, centerNode));
-    scene->addItem(new Edge(node3, node6));
-    scene->addItem(new Edge(node4, node1));
-    scene->addItem(new Edge(node4, centerNode));
-    scene->addItem(new Edge(centerNode, node6));
-    scene->addItem(new Edge(centerNode, node8));
-    scene->addItem(new Edge(node6, node9));
-    scene->addItem(new Edge(node7, node4));
-    scene->addItem(new Edge(node8, node7));
-    scene->addItem(new Edge(node9, node8));
-
-    node1->setPos(-50, -50);
-    node2->setPos(0, -50);
-    node3->setPos(50, -50);
-    node4->setPos(-50, 0);
-    centerNode->setPos(0, 0);
-    node6->setPos(50, 0);
-    node7->setPos(-50, 50);
-    node8->setPos(0, 50);
-    node9->setPos(50, 50);
-  */
+// -------------------------------------------------------------------------
+PipelineEditor::GraphCanvas::
+~GraphCanvas( )
+{
 }
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::Workspace* GraphWidget::
+cpPlugins::Interface::Workspace* PipelineEditor::GraphCanvas::
 workspace( )
 {
   return( this->m_Workspace );
 }
 
 // -------------------------------------------------------------------------
-const cpPlugins::Interface::Workspace* GraphWidget::
+const cpPlugins::Interface::Workspace* PipelineEditor::GraphCanvas::
 workspace( ) const
 {
   return( this->m_Workspace );
 }
 
 // -------------------------------------------------------------------------
-void GraphWidget::
+void PipelineEditor::GraphCanvas::
 setWorkspace( cpPlugins::Interface::Workspace* ws )
 {
   if( this->m_Workspace == ws )
@@ -145,35 +57,122 @@ setWorkspace( cpPlugins::Interface::Workspace* ws )
     std::string label = vIt->second->GetName( ) + std::string( "\n" );
     label += vIt->second->GetClassName( );
 
-    Node* node = new Node( this, label );
+    Node* node = new Node( this, vIt->second.GetPointer( ) );
     this->m_Graph->InsertVertex( vIt->first, node );
     scene->addItem( node );
 
   } // rof
 
-  // Add edges
-  auto rIt = this->m_Workspace->GetGraph( )->BeginEdgesRows( );
-  auto rIt_end = this->m_Workspace->GetGraph( )->EndEdgesRows( );
-  for( ; rIt != rIt_end; ++rIt )
-  {
-    Node* a = this->m_Graph->GetVertex( rIt->first );
-    if( a == NULL )
-      continue;
-    auto cIt = rIt->second.begin( );
-    for( ; cIt != rIt->second.end( ); ++cIt )
-    {
-      Node* b = this->m_Graph->GetVertex( cIt->first );
-      if( b == NULL )
-        continue;
-      Edge* e = new Edge( a, b );
-      this->m_Graph->AddConnection( rIt->first, cIt->first, e );
-      scene->addItem( e );
-
-    } // rof
+  /* TODO
+     // Add edges
+     auto rIt = this->m_Workspace->GetGraph( )->BeginEdgesRows( );
+     auto rIt_end = this->m_Workspace->GetGraph( )->EndEdgesRows( );
+     for( ; rIt != rIt_end; ++rIt )
+     {
+     Node* a = this->m_Graph->GetVertex( rIt->first );
+     if( a == NULL )
+     continue;
+     auto cIt = rIt->second.begin( );
+     for( ; cIt != rIt->second.end( ); ++cIt )
+     {
+     Node* b = this->m_Graph->GetVertex( cIt->first );
+     if( b == NULL )
+     continue;
+     Edge* e = new Edge( a, b );
+     this->m_Graph->AddConnection( rIt->first, cIt->first, e );
+     scene->addItem( e );
+
+     } // rof
+
+     } // rof
+  */
+}
 
-  } // rof
+// -------------------------------------------------------------------------
+void PipelineEditor::GraphCanvas::
+draw( )
+{
+  if( this->m_Workspace == NULL )
+    return;
+}
+
+// -------------------------------------------------------------------------
+void PipelineEditor::GraphCanvas::
+itemMoved( )
+{
+}
+
+// -------------------------------------------------------------------------
+void PipelineEditor::GraphCanvas::
+shuffle( )
+{
+}
+
+// -------------------------------------------------------------------------
+void PipelineEditor::GraphCanvas::
+zoomIn( )
+{
 }
 
+// -------------------------------------------------------------------------
+void PipelineEditor::GraphCanvas::
+zoomOut( )
+{
+}
+
+// -------------------------------------------------------------------------
+void PipelineEditor::GraphCanvas::
+keyPressEvent( QKeyEvent* event )
+{
+}
+
+// -------------------------------------------------------------------------
+void PipelineEditor::GraphCanvas::
+timerEvent( QTimerEvent* event )
+{
+}
+
+// -------------------------------------------------------------------------
+void PipelineEditor::GraphCanvas::
+wheelEvent( QWheelEvent* event )
+{
+  this->scaleView(
+    std::pow( double( 2 ), -event->delta( ) / double( 240 ) )
+    );
+}
+
+// -------------------------------------------------------------------------
+void PipelineEditor::GraphCanvas::
+drawBackground( QPainter* painter, const QRectF& rect )
+{
+  this->QGraphicsView::drawBackground( painter, rect );
+}
+
+// -------------------------------------------------------------------------
+void PipelineEditor::GraphCanvas::
+scaleView( qreal scaleFactor )
+{
+  qreal factor = this->transform( ).
+    scale( scaleFactor, scaleFactor ).
+    mapRect( QRectF( 0, 0, 1, 1 ) ).
+    width( );
+  if( factor < qreal( 0.07 ) || factor > qreal( 100 ) )
+    return;
+  this->scale( scaleFactor, scaleFactor );
+}
+
+/*
+  protected:
+    cpPlugins::Interface::Workspace* m_Workspace;
+    TGraph::Pointer m_Graph;
+  };
+*/
+
+// eof - $RCSfile$
+
+
+/*
+
 // -------------------------------------------------------------------------
 void GraphWidget::
 draw( )
@@ -314,3 +313,6 @@ void GraphWidget::zoomOut()
 {
   scaleView(1 / qreal(1.2));
 }
+
+
+*/
diff --git a/appli/cpPipelineEditor/GraphCanvas.h b/appli/cpPipelineEditor/GraphCanvas.h
new file mode 100644 (file)
index 0000000..3a4a9d0
--- /dev/null
@@ -0,0 +1,66 @@
+#ifndef __PIPELINEEDITOR__GRAPHCANVAS__H__
+#define __PIPELINEEDITOR__GRAPHCANVAS__H__
+
+#include <QtGui/QGraphicsView>
+#include <cpExtensions/DataStructures/Graph.h>
+
+// Some forward declarations
+namespace cpPlugins
+{
+  namespace Interface
+  {
+    class Workspace;
+  }
+}
+
+namespace PipelineEditor
+{
+  // Some other forward declarations
+  class Node;
+  class Edge;
+
+  /**
+   */
+  class GraphCanvas
+    : public QGraphicsView
+  {
+    Q_OBJECT;
+
+  public:
+    typedef
+    cpExtensions::DataStructures::Graph< Node*, Edge*, std::string > TGraph;
+
+  public:
+    GraphCanvas( QWidget* parent = 0 );
+    virtual ~GraphCanvas( );
+
+    cpPlugins::Interface::Workspace* workspace( );
+    const cpPlugins::Interface::Workspace* workspace( ) const;
+    void setWorkspace( cpPlugins::Interface::Workspace* ws );
+
+    void draw( );
+
+    void itemMoved( );
+
+  public slots:
+    void shuffle( );
+    void zoomIn( );
+    void zoomOut( );
+
+  protected:
+    void keyPressEvent( QKeyEvent* event );
+    void timerEvent( QTimerEvent* event );
+    void wheelEvent( QWheelEvent* event );
+    void drawBackground( QPainter* painter, const QRectF& rect );
+    void scaleView( qreal scaleFactor );
+
+  protected:
+    cpPlugins::Interface::Workspace* m_Workspace;
+    TGraph::Pointer m_Graph;
+  };
+
+} // ecapseman
+
+#endif // __PIPELINEEDITOR__GRAPHCANVAS__H__
+
+// eof - $RCSfile$
diff --git a/appli/cpPipelineEditor/GraphWidget.h b/appli/cpPipelineEditor/GraphWidget.h
deleted file mode 100644 (file)
index 3ccecc1..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
- **
- ** Copyright (C) 2015 The Qt Company Ltd.
- ** Contact: http://www.qt.io/licensing/
- **
- ** This file is part of the examples of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:BSD$
- ** You may use this file under the terms of the BSD license as follows:
- **
- ** "Redistribution and use in source and binary forms, with or without
- ** modification, are permitted provided that the following conditions are
- ** met:
- **   * Redistributions of source code must retain the above copyright
- **     notice, this list of conditions and the following disclaimer.
- **   * Redistributions in binary form must reproduce the above copyright
- **     notice, this list of conditions and the following disclaimer in
- **     the documentation and/or other materials provided with the
- **     distribution.
- **   * Neither the name of The Qt Company Ltd nor the names of its
- **     contributors may be used to endorse or promote products derived
- **     from this software without specific prior written permission.
- **
- **
- ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- **
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
-
-#ifndef GRAPHWIDGET_H
-#define GRAPHWIDGET_H
-
-#include <QtGui/QGraphicsView>
-#include <cpExtensions/DataStructures/Graph.h>
-
-class Node;
-class Edge;
-namespace cpPlugins
-{
-  namespace Interface
-  {
-    class Workspace;
-  }
-}
-
-class GraphWidget
-  : public QGraphicsView
-{
-  Q_OBJECT;
-
-public:
-  typedef
-  cpExtensions::DataStructures::
-  Graph< Node*, Edge*, std::string >
-  TGraph;
-
-public:
-  GraphWidget(QWidget *parent = 0);
-
-  cpPlugins::Interface::Workspace* workspace( );
-  const cpPlugins::Interface::Workspace* workspace( ) const;
-  void setWorkspace( cpPlugins::Interface::Workspace* ws );
-
-  void draw( );
-
-  void itemMoved();
-
-public slots:
-  void shuffle();
-  void zoomIn();
-  void zoomOut();
-
-protected:
-  void keyPressEvent(QKeyEvent *event);
-  void timerEvent(QTimerEvent *event);
-  void wheelEvent(QWheelEvent *event);
-  void drawBackground(QPainter *painter, const QRectF &rect);
-
-  void scaleView(qreal scaleFactor);
-
-private:
-  int timerId;
-  Node *centerNode;
-
-  cpPlugins::Interface::Workspace* m_Workspace;
-  TGraph::Pointer m_Graph;
-};
-
-#endif
index 2ecb9e5b1f8a6e8eaace212844d1fb8efceb1ea9..a1026dc6260e211eeb1255c13a13a2fd6901bc89 100644 (file)
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-**   * Redistributions of source code must retain the above copyright
-**     notice, this list of conditions and the following disclaimer.
-**   * Redistributions in binary form must reproduce the above copyright
-**     notice, this list of conditions and the following disclaimer in
-**     the documentation and/or other materials provided with the
-**     distribution.
-**   * Neither the name of The Qt Company Ltd nor the names of its
-**     contributors may be used to endorse or promote products derived
-**     from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGraphicsScene>
-#include <QGraphicsSceneMouseEvent>
-#include <QPainter>
-#include <QStyleOption>
-
-#include "Edge.h"
 #include "Node.h"
-#include "GraphWidget.h"
+#include "Edge.h"
+#include "GraphCanvas.h"
+
+#include <QFontMetricsF>
+#include <QGraphicsWidget>
+#include <QGraphicsSceneHoverEvent>
+
+#include <cpPlugins/Interface/Object.h>
+#include <cpPlugins/Interface/ProcessObject.h>
+
+#define PORT_SIZE 10
+
+// -------------------------------------------------------------------------
+PipelineEditor::Node::
+Node( GraphCanvas* canvas, cpPlugins::Interface::Object* object )
+  : QGraphicsItem( NULL ),
+    m_Canvas( canvas ),
+    m_Object( object ),
+    m_UpdatedBounds( false )
+{
+  this->setFlag( QGraphicsItem::ItemIsMovable );
+  this->setFlag( QGraphicsItem::ItemSendsGeometryChanges );
+  this->setCacheMode( QGraphicsItem::DeviceCoordinateCache );
+  this->setAcceptHoverEvents( true );
+  this->setZValue( -1 );
+  this->setToolTip( this->m_Object->GetName( ) );
+}
+
+// -------------------------------------------------------------------------
+PipelineEditor::Node::
+~Node( )
+{
+}
+
+// -------------------------------------------------------------------------
+void PipelineEditor::Node::
+addEdge( PipelineEditor::Edge* edge )
+{
+  this->m_Edges << edge;
+  edge->adjust( );
+}
 
-Node::Node(GraphWidget *graphWidget, const std::string& label)
-  : graph(graphWidget),
-    m_Label( label )
+// -------------------------------------------------------------------------
+QList< PipelineEditor::Edge* > PipelineEditor::Node::
+edges( ) const
 {
-    setFlag(ItemIsMovable);
-    setFlag(ItemSendsGeometryChanges);
-    setCacheMode(DeviceCoordinateCache);
-    setZValue(-1);
-    this->setToolTip( this->m_Label.c_str( ) );
+  return( this->m_Edges );
 }
 
-void Node::addEdge(Edge *edge)
+// -------------------------------------------------------------------------
+QRectF PipelineEditor::Node::
+boundingRect( ) const
 {
-    edgeList << edge;
-    edge->adjust();
+  typedef cpPlugins::Interface::ProcessObject _TFilter;
+  if( !this->m_UpdatedBounds )
+  {
+    // Text bounding box
+    QFontMetricsF fm( this->m_Canvas->font( ) );
+    this->m_Label = this->m_Object->GetName( );
+    this->m_Label += "\n";
+    this->m_Label += this->m_Object->GetClassName( ).c_str( );
+
+    // Ports
+    this->m_Bounds = fm.boundingRect( this->m_Label );
+    const _TFilter* f = dynamic_cast< const _TFilter* >( this->m_Object );
+    if( f != NULL )
+    {
+      unsigned int nIn = f->GetNumberOfInputs( );
+      unsigned int nOut = f->GetNumberOfOutputs( );
+      qreal n =
+        qreal( ( ( ( ( nIn > nOut )? nIn: nOut ) << 1 ) + 1 ) * PORT_SIZE );
+      qreal h = this->m_Bounds.height( );
+      if( n > h )
+        this->m_Bounds.setHeight( n );
+
+      // Let some space for ports
+      this->m_Bounds.setLeft(
+        this->m_Bounds.left( ) - qreal( PORT_SIZE )
+        );
+      this->m_Bounds.setTop(
+        this->m_Bounds.top( ) - qreal( PORT_SIZE )
+        );
+      this->m_Bounds.setRight(
+        this->m_Bounds.right( ) + qreal( PORT_SIZE )
+        );
+      this->m_Bounds.setBottom(
+        this->m_Bounds.bottom( ) + qreal( PORT_SIZE )
+        );
+
+    } // fi
+    this->m_UpdatedBounds = true;
+
+  } // fi
+  return( this->m_Bounds );
 }
 
-QList<Edge *> Node::edges() const
+// -------------------------------------------------------------------------
+QPainterPath PipelineEditor::Node::
+shape( ) const
 {
-    return edgeList;
+  QPainterPath path;
+  path.addRect( this->boundingRect( ) );
+  return( path );
 }
 
-void Node::calculateForces()
+// -------------------------------------------------------------------------
+void PipelineEditor::Node::
+paint(
+  QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget
+  )
 {
-    if (!scene() || scene()->mouseGrabberItem() == this) {
-        newPos = pos();
-        return;
-    }
-
-    // Sum up all forces pushing this item away
-    qreal xvel = 0;
-    qreal yvel = 0;
-    foreach (QGraphicsItem *item, scene()->items()) {
-        Node *node = qgraphicsitem_cast<Node *>(item);
-        if (!node)
-            continue;
-
-        QPointF vec = mapToItem(node, 0, 0);
-        qreal dx = vec.x();
-        qreal dy = vec.y();
-        double l = 2.0 * (dx * dx + dy * dy);
-        if (l > 0) {
-            xvel += (dx * 150.0) / l;
-            yvel += (dy * 150.0) / l;
-        }
-    }
-
-    // Now subtract all forces pulling items together
-    double weight = (edgeList.size() + 1) * 10;
-    foreach (Edge *edge, edgeList) {
-        QPointF vec;
-        if (edge->sourceNode() == this)
-            vec = mapToItem(edge->destNode(), 0, 0);
-        else
-            vec = mapToItem(edge->sourceNode(), 0, 0);
-        xvel -= vec.x() / weight;
-        yvel -= vec.y() / weight;
-    }
-
-    if (qAbs(xvel) < 0.1 && qAbs(yvel) < 0.1)
-        xvel = yvel = 0;
-
-    QRectF sceneRect = scene()->sceneRect();
-    newPos = pos() + QPointF(xvel, yvel);
-    newPos.setX(qMin(qMax(newPos.x(), sceneRect.left() + 10), sceneRect.right() - 10));
-    newPos.setY(qMin(qMax(newPos.y(), sceneRect.top() + 10), sceneRect.bottom() - 10));
-
-    newPos = pos(); // + QPointF(xvel, yvel);
+  typedef cpPlugins::Interface::ProcessObject _TFilter;
+
+  QRectF rect = this->boundingRect( );
+  painter->drawRect( rect );
+  painter->drawText( rect, Qt::AlignCenter, this->m_Label );
+
+  // Show ports
+  const _TFilter* f = dynamic_cast< const _TFilter* >( this->m_Object );
+  if( f != NULL )
+  {
+    QSizeF port_size( qreal( PORT_SIZE ), qreal( PORT_SIZE ) );
+    qreal rh = rect.height( );
+    qreal rt = rect.top( );
+    qreal rl = rect.left( );
+    qreal rr = rect.right( );
+
+    std::set< std::string > inputs, outputs;
+    f->GetInputsNames( inputs );
+    f->GetOutputsNames( outputs );
+
+    qreal oh = qreal( ( ( inputs.size( ) << 1 ) + 1 ) * PORT_SIZE );
+    qreal off = qreal( PORT_SIZE );
+    if( rh > oh )
+      off += ( rh - oh ) / qreal( 2 );
+    for( auto it = inputs.begin( ); it != inputs.end( ); ++it )
+    {
+      painter->drawRect( QRectF( QPointF( rl, rt + off ), port_size ) );
+      off += qreal( PORT_SIZE < 1 );
+
+    } // rof
+
+    oh = qreal( ( ( outputs.size( ) << 1 ) + 1 ) * PORT_SIZE );
+    off = qreal( PORT_SIZE );
+    if( rh > oh )
+      off += ( rh - oh ) / qreal( 2 );
+    for( auto it = outputs.begin( ); it != outputs.end( ); ++it )
+    {
+      painter->drawRect(
+        QRectF( QPointF( rr - qreal( PORT_SIZE ), rt + off ), port_size )
+        );
+      off += qreal( PORT_SIZE < 1 );
+
+    } // rof
+
+  } // fi
 }
 
-bool Node::advance()
+// -------------------------------------------------------------------------
+QVariant PipelineEditor::Node::
+itemChange( GraphicsItemChange change, const QVariant& value )
 {
-    if (newPos == pos())
-        return false;
+  /* TODO
+     switch( change )
+     {
+     case QGraphicsItem::ItemPositionHasChanged:
+     foreach( Edge* edge, this->m_Edges )
+     edge->adjust( );
+     this->m_Canvas->itemMoved( );
+     break;
+     default:
+     break;
+     } // hctiws
+  */
+  return( this->QGraphicsItem::itemChange( change, value ) );
+}
 
-    setPos(newPos);
-    return true;
+// -------------------------------------------------------------------------
+void PipelineEditor::Node::
+mousePressEvent( QGraphicsSceneMouseEvent* event )
+{
+  this->update( );
+  this->QGraphicsItem::mousePressEvent( event );
 }
 
-QRectF Node::boundingRect() const
+// -------------------------------------------------------------------------
+void PipelineEditor::Node::
+mouseReleaseEvent( QGraphicsSceneMouseEvent* event )
 {
-#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
-    // Add some extra space around the circle for easier touching with finger
-    qreal adjust = 30;
-    return QRectF( -10 - adjust, -10 - adjust,
-                  20 + adjust * 2, 20 + adjust * 2);
-#else
-    qreal adjust = 2;
-    return QRectF( -10 - adjust, -10 - adjust,
-                  23 + adjust, 23 + adjust);
-#endif
+  this->update( );
+  this->QGraphicsItem::mouseReleaseEvent( event );
 }
 
-QPainterPath Node::shape() const
+// -------------------------------------------------------------------------
+void PipelineEditor::Node::
+mouseDoubleClickEvent( QGraphicsSceneMouseEvent* event )
 {
-    QPainterPath path;
-#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
-    // Add some extra space around the circle for easier touching with finger
-    path.addEllipse( -40, -40, 80, 80);
-#else
-    path.addEllipse(-10, -10, 20, 20);
-#endif
-    return path;
 }
 
-void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
+// -------------------------------------------------------------------------
+void PipelineEditor::Node::
+hoverMoveEvent( QGraphicsSceneHoverEvent* event )
 {
-    painter->setPen(Qt::NoPen);
-    painter->setBrush(Qt::darkGray);
-    painter->drawEllipse(-7, -7, 20, 20);
-
-    QPointF text_point = this->boundingRect( ).bottomRight( ) + this->pos( );
-    painter->drawText( text_point, this->m_Label.c_str( ) );
-    std::cout << text_point.x( ) << " " << text_point.y( ) << std::endl;
-
-    QRadialGradient gradient(-3, -3, 10);
-    if (option->state & QStyle::State_Sunken) {
-        gradient.setCenter(3, 3);
-        gradient.setFocalPoint(3, 3);
-        gradient.setColorAt(1, QColor(Qt::yellow).light(120));
-        gradient.setColorAt(0, QColor(Qt::darkYellow).light(120));
-    } else {
-        gradient.setColorAt(0, Qt::yellow);
-        gradient.setColorAt(1, Qt::darkYellow);
-    }
-    painter->setBrush(gradient);
-
-    painter->setPen(QPen(Qt::black, 0));
-    painter->drawEllipse(-10, -10, 20, 20);
+  QPointF pos = event->pos( );
 }
 
+/* TODO
+   private:
+   GraphCanvas*   m_Canvas;
+   QList< Edge* > m_Edges;
+   std::string    m_Label;
+   };
+
+   } // ecapseman
+
+   #endif // __PIPELINEEDITOR__NODE__H__
+*/
+
+// eof - $RCSfile$
+
+
+/*
 QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
 {
-    switch (change) {
-    case ItemPositionHasChanged:
-        foreach (Edge *edge, edgeList)
-            edge->adjust();
-        graph->itemMoved();
-        break;
-    default:
-        break;
-    };
-
-    return QGraphicsItem::itemChange(change, value);
+  switch (change) {
+  case ItemPositionHasChanged:
+    foreach (Edge *edge, edgeList)
+      edge->adjust();
+    graph->itemMoved();
+    break;
+  default:
+    break;
+  };
+
+  return QGraphicsItem::itemChange(change, value);
 }
 
 void Node::mousePressEvent(QGraphicsSceneMouseEvent *event)
 {
-    update();
-    QGraphicsItem::mousePressEvent(event);
+  update();
+  QGraphicsItem::mousePressEvent(event);
 }
 
 void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
 {
-    update();
-    QGraphicsItem::mouseReleaseEvent(event);
+  update();
+  QGraphicsItem::mouseReleaseEvent(event);
 }
 
+// eof - $RCSfile$
+*/
index 088ade7c16904e77dc548a66d3b12db013766003..8dc526a9aceae4b1543057e501cbc8de885f1dd3 100644 (file)
@@ -1,82 +1,67 @@
-/****************************************************************************
- **
- ** Copyright (C) 2015 The Qt Company Ltd.
- ** Contact: http://www.qt.io/licensing/
- **
- ** This file is part of the examples of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:BSD$
- ** You may use this file under the terms of the BSD license as follows:
- **
- ** "Redistribution and use in source and binary forms, with or without
- ** modification, are permitted provided that the following conditions are
- ** met:
- **   * Redistributions of source code must retain the above copyright
- **     notice, this list of conditions and the following disclaimer.
- **   * Redistributions in binary form must reproduce the above copyright
- **     notice, this list of conditions and the following disclaimer in
- **     the documentation and/or other materials provided with the
- **     distribution.
- **   * Neither the name of The Qt Company Ltd nor the names of its
- **     contributors may be used to endorse or promote products derived
- **     from this software without specific prior written permission.
- **
- **
- ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- **
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
-
-#ifndef NODE_H
-#define NODE_H
+#ifndef __PIPELINEEDITOR__NODE__H__
+#define __PIPELINEEDITOR__NODE__H__
 
 #include <QGraphicsItem>
 #include <QList>
 
-class Edge;
-class GraphWidget;
+// Some forward declarations
 class QGraphicsSceneMouseEvent;
+class QGraphicsSceneHoverEvent;
+
+// Some forward declarations
+namespace cpPlugins
+{
+  namespace Interface
+  {
+    class Object;
+  }
+}
 
-class Node : public QGraphicsItem
+namespace PipelineEditor
 {
-public:
-  Node(GraphWidget *graphWidget, const std::string& label );
+  // Some other forward declarations
+  class Edge;
+  class GraphCanvas;
+
+  /**
+   */
+  class Node
+    : public QGraphicsItem
+  {
+  public:
+    Node( GraphCanvas* canvas, cpPlugins::Interface::Object* object );
+    virtual ~Node( );
 
-  void addEdge(Edge *edge);
-  QList<Edge *> edges() const;
+    void addEdge( Edge* edge );
+    QList< Edge* > edges( ) const;
 
-  enum { Type = UserType + 1 };
-  int type() const { return Type; }
+    QRectF boundingRect( ) const;
+    QPainterPath shape( ) const;
+    void paint(
+      QPainter* painter,
+      const QStyleOptionGraphicsItem* option,
+      QWidget* widget
+      );
 
-  void calculateForces();
-  bool advance();
+  protected:
+    QVariant itemChange( GraphicsItemChange change, const QVariant& value );
 
-  QRectF boundingRect() const;
-  QPainterPath shape() const;
-  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+    void mousePressEvent( QGraphicsSceneMouseEvent* event );
+    void mouseReleaseEvent( QGraphicsSceneMouseEvent* event );
+    void mouseDoubleClickEvent( QGraphicsSceneMouseEvent* event );
+    void hoverMoveEvent( QGraphicsSceneHoverEvent* event );
 
-protected:
-  QVariant itemChange(GraphicsItemChange change, const QVariant &value);
+  private:
+    GraphCanvas*   m_Canvas;
+    QList< Edge* > m_Edges;
+    cpPlugins::Interface::Object* m_Object;
+    mutable QString m_Label;
+    mutable QRectF m_Bounds;
+    mutable bool m_UpdatedBounds;
+  };
 
-  void mousePressEvent(QGraphicsSceneMouseEvent *event);
-  void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+} // ecapseman
 
-private:
-  QList<Edge *> edgeList;
-  QPointF newPos;
-  GraphWidget *graph;
-  std::string m_Label;
-};
+#endif // __PIPELINEEDITOR__NODE__H__
 
-#endif
+// eof - $RCSfile$
index 3516270e45ac90095c97f81a9c0951eed0a23de4..87fd6c86e65984f7c81926d1aeac700462407da9 100644 (file)
@@ -55,8 +55,7 @@ _ActionOpenWorkspace( )
   std::string err = this->m_Workspace->LoadWorkspace( fname );
   if( err == "" )
   {
-    this->m_UI->GraphCanvas->setWorkspace( this->m_Workspace );
-    this->m_UI->GraphCanvas->draw( );
+    this->m_UI->Canvas->setWorkspace( this->m_Workspace );
   }
   else
   {
index 4b474618e22558303b3d50a7184640cbb2c38507..f35e6366ea34b0dce1f93f78463894783d8e9570 100644 (file)
@@ -16,7 +16,7 @@
   <widget class="QWidget" name="MainWidget">
    <layout class="QGridLayout" name="gridLayout">
     <item row="0" column="0">
-     <widget class="GraphWidget" name="GraphCanvas" native="true"/>
+     <widget class="PipelineEditor::GraphCanvas" name="Canvas" native="true"/>
     </item>
    </layout>
   </widget>
@@ -58,9 +58,9 @@
  </widget>
  <customwidgets>
   <customwidget>
-   <class>GraphWidget</class>
+   <class>PipelineEditor::GraphCanvas</class>
    <extends>QWidget</extends>
-   <header>GraphWidget.h</header>
+   <header>GraphCanvas.h</header>
    <container>1</container>
   </customwidget>
  </customwidgets>
index efd2bca6fcf5da5311f17568155a1c0507c82953..266b0ea1c7a94d97eed7cf8eacab9ca52e9a8b8d 100644 (file)
@@ -38,6 +38,20 @@ GetOutputsNames( std::set< std::string >& names ) const
     names.insert( dIt->first );
 }
 
+// -------------------------------------------------------------------------
+unsigned int cpPlugins::Interface::ProcessObject::
+GetNumberOfInputs( ) const
+{
+  return( this->m_Inputs.size( ) );
+}
+
+// -------------------------------------------------------------------------
+unsigned int cpPlugins::Interface::ProcessObject::
+GetNumberOfOutputs( ) const
+{
+  return( this->m_Outputs.size( ) );
+}
+
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::ProcessObject::
 SetOutputObjectName(
index 6578beb35e0b533d51d508dbbb88b934d818dda2..6c6a8e7b468179cea12172a554d08c0add4c4abb 100644 (file)
@@ -72,6 +72,8 @@ namespace cpPlugins
 
       virtual void GetInputsNames( std::set< std::string >& names ) const;
       virtual void GetOutputsNames( std::set< std::string >& names ) const;
+      unsigned int GetNumberOfInputs( ) const;
+      unsigned int GetNumberOfOutputs( ) const;
 
       virtual bool SetOutputObjectName(
         const std::string& new_object_name,