1 // SUPERV SUPERVGUI : GUI for Supervisor component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SUPERVGUI_CanvasLink.h
23 // Author : Natalia KOPNOVA
26 #ifndef SUPERVGUI_CanvasLink_H
27 #define SUPERVGUI_CanvasLink_H
29 #include "SUPERVGUI_Def.h"
31 #include <qvaluevector.h>
34 class SUPERVGUI_CanvasPort;
36 class SUPERVGUI_CanvasLink : public QObject {
40 SUPERVGUI_CanvasLink(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Link_ptr theLink=0);
41 virtual ~SUPERVGUI_CanvasLink();
46 void setHilighted(bool state);
47 void setColor(const QColor& theColor);
49 virtual void moveByPort(SUPERVGUI_CanvasPort* thePort);
50 virtual void moveByPort(SUPERVGUI_CanvasPort* thePort, int dx, int dy);
52 SUPERV_Link getEngine() const { return myLink; }
53 SUPERVGUI_Main* getMain() const { return myMain; }
55 SUPERVGUI_CanvasPort* getInputPort() const { return myInputPort; }
56 SUPERVGUI_CanvasPort* getOutputPort() const { return myOutputPort; }
58 void setSelectedObject(QCanvasItem* theItem, const QPoint& thePoint);
59 virtual QPopupMenu* getPopupMenu(QWidget* theParent);
61 QString getToolTipText() const;
64 void objectCreatedDeleted(); // mkr : PAL8237
67 virtual void remove();
72 void addPoint(const QPoint& thePoint, const int& theIndex = -1);
75 QCanvasItemList myPrs;
81 SUPERVGUI_Main* myMain;
83 SUPERVGUI_CanvasPort* myInputPort;
84 SUPERVGUI_CanvasPort* myOutputPort;
87 QCanvasItem* mySelectedItem;
88 QPoint mySelectedPoint;
92 class SUPERVGUI_CanvasStreamLink : public SUPERVGUI_CanvasLink {
96 SUPERVGUI_CanvasStreamLink(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::StreamLink_ptr theLink=0);
97 ~SUPERVGUI_CanvasStreamLink() {}
99 SUPERV_StreamLink getStreamEngine() const { return myStreamLink; }
102 virtual void remove();
105 SUPERV_StreamLink myStreamLink;
109 class SUPERVGUI_CanvasLinkBuilder : public SUPERVGUI_CanvasLink {
113 SUPERVGUI_CanvasLinkBuilder(QObject* theParent, SUPERVGUI_Main* theMain, SUPERVGUI_CanvasPort* thePort=0);
114 virtual ~SUPERVGUI_CanvasLinkBuilder();
116 bool canCreateEngine(SUPERVGUI_CanvasPort* thePort);
117 void setCoords(SUPERV::Link_ptr theLink);
119 SUPERVGUI_CanvasPort* getStartPort() const { return myPort; }
121 int getPointCount() const { return (int) (myPrs.count()/2); }
122 void addNextPoint(const QPoint& thePoint, bool theOrtho = false);
123 void setFloatPoint(const QPoint& thePoint);
124 void removeLastPoint();
126 virtual void moveByPort(SUPERVGUI_CanvasPort* thePort);
127 virtual void moveByPort(SUPERVGUI_CanvasPort* thePort, int dx, int dy);
130 SUPERVGUI_CanvasPort* myPort;
132 QCanvasLine* myFloatingEdge;
136 class SUPERVGUI_CanvasEdgePrs;
137 class SUPERVGUI_CanvasPointPrs : public QCanvasEllipse
140 SUPERVGUI_CanvasPointPrs(QCanvas* theCanvas, SUPERVGUI_CanvasLink* theLink, const int& theIndex = -1);
141 ~SUPERVGUI_CanvasPointPrs() {}
143 SUPERVGUI_CanvasLink* getLink() const { return myLink; }
144 int getIndex() const { return myIndex; }
146 void setInEdge(SUPERVGUI_CanvasEdgePrs* theEdge);
147 void setOutEdge(SUPERVGUI_CanvasEdgePrs* theEdge);
149 void moveBy(double dx, double dy);
150 void setColor(const QColor& theColor);
152 void setMoving(bool b) { myMoving = b; }
153 bool isMoving() const { return myMoving; }
155 virtual int rtti() const;
158 SUPERVGUI_CanvasLink* myLink;
162 SUPERVGUI_CanvasEdgePrs* myInEdge;
163 SUPERVGUI_CanvasEdgePrs* myOutEdge;
167 class SUPERVGUI_CanvasEdgePrs : public QCanvasLine
170 SUPERVGUI_CanvasEdgePrs(QCanvas* theCanvas, SUPERVGUI_CanvasLink* theLink);
171 ~SUPERVGUI_CanvasEdgePrs() {}
173 SUPERVGUI_CanvasLink* getLink() const { return myLink; }
175 void setFromPoint(SUPERVGUI_CanvasPointPrs* thePoint);
176 void setToPoint(SUPERVGUI_CanvasPointPrs* thePoint);
178 void moveBy(double dx, double dy);
179 void setColor(const QColor& theColor);
181 void setMoving(bool b) { myMoving = b; }
182 bool isMoving() const { return myMoving; }
184 virtual int rtti() const;
188 SUPERVGUI_CanvasLink* myLink;
190 //mkr: for moving segment of link
191 SUPERVGUI_CanvasPointPrs* myStartPoint;
192 SUPERVGUI_CanvasPointPrs* myEndPoint;