1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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 // SUPERV SUPERVGUI : GUI for Supervisor component
23 // File : SUPERVGUI_CanvasLink.h
24 // Author : Natalia KOPNOVA
27 #ifndef SUPERVGUI_CanvasLink_H
28 #define SUPERVGUI_CanvasLink_H
30 #include "SUPERVGUI_Def.h"
32 #include <qvaluevector.h>
35 class SUPERVGUI_CanvasPort;
37 class SUPERVGUI_CanvasLink : public QObject {
41 SUPERVGUI_CanvasLink(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Link_ptr theLink=0);
42 virtual ~SUPERVGUI_CanvasLink();
47 void setHilighted(bool state);
48 void setColor(const QColor& theColor);
50 virtual void moveByPort(SUPERVGUI_CanvasPort* thePort);
51 virtual void moveByPort(SUPERVGUI_CanvasPort* thePort, int dx, int dy);
53 SUPERV_Link getEngine() const { return myLink; }
54 SUPERVGUI_Main* getMain() const { return myMain; }
56 SUPERVGUI_CanvasPort* getInputPort() const { return myInputPort; }
57 SUPERVGUI_CanvasPort* getOutputPort() const { return myOutputPort; }
59 void setSelectedObject(QCanvasItem* theItem, const QPoint& thePoint);
60 virtual QPopupMenu* getPopupMenu(QWidget* theParent);
62 QString getToolTipText() const;
65 void objectCreatedDeleted(); // mkr : PAL8237
68 virtual void remove();
73 void addPoint(const QPoint& thePoint, const int& theIndex = -1);
76 QCanvasItemList myPrs;
82 SUPERVGUI_Main* myMain;
84 SUPERVGUI_CanvasPort* myInputPort;
85 SUPERVGUI_CanvasPort* myOutputPort;
88 QCanvasItem* mySelectedItem;
89 QPoint mySelectedPoint;
93 class SUPERVGUI_CanvasStreamLink : public SUPERVGUI_CanvasLink {
97 SUPERVGUI_CanvasStreamLink(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::StreamLink_ptr theLink=0);
98 ~SUPERVGUI_CanvasStreamLink() {}
100 SUPERV_StreamLink getStreamEngine() const { return myStreamLink; }
103 virtual void remove();
106 SUPERV_StreamLink myStreamLink;
110 class SUPERVGUI_CanvasLinkBuilder : public SUPERVGUI_CanvasLink {
114 SUPERVGUI_CanvasLinkBuilder(QObject* theParent, SUPERVGUI_Main* theMain, SUPERVGUI_CanvasPort* thePort=0);
115 virtual ~SUPERVGUI_CanvasLinkBuilder();
117 bool canCreateEngine(SUPERVGUI_CanvasPort* thePort);
118 void setCoords(SUPERV::Link_ptr theLink);
120 SUPERVGUI_CanvasPort* getStartPort() const { return myPort; }
122 int getPointCount() const { return (int) (myPrs.count()/2); }
123 void addNextPoint(const QPoint& thePoint, bool theOrtho = false);
124 void setFloatPoint(const QPoint& thePoint);
125 void removeLastPoint();
127 virtual void moveByPort(SUPERVGUI_CanvasPort* thePort);
128 virtual void moveByPort(SUPERVGUI_CanvasPort* thePort, int dx, int dy);
131 SUPERVGUI_CanvasPort* myPort;
133 QCanvasLine* myFloatingEdge;
137 class SUPERVGUI_CanvasEdgePrs;
138 class SUPERVGUI_CanvasPointPrs : public QCanvasEllipse
141 SUPERVGUI_CanvasPointPrs(QCanvas* theCanvas, SUPERVGUI_CanvasLink* theLink, const int& theIndex = -1);
142 ~SUPERVGUI_CanvasPointPrs() {}
144 SUPERVGUI_CanvasLink* getLink() const { return myLink; }
145 int getIndex() const { return myIndex; }
147 void setInEdge(SUPERVGUI_CanvasEdgePrs* theEdge);
148 void setOutEdge(SUPERVGUI_CanvasEdgePrs* theEdge);
150 void moveBy(double dx, double dy);
151 void setColor(const QColor& theColor);
153 void setMoving(bool b) { myMoving = b; }
154 bool isMoving() const { return myMoving; }
156 virtual int rtti() const;
159 SUPERVGUI_CanvasLink* myLink;
163 SUPERVGUI_CanvasEdgePrs* myInEdge;
164 SUPERVGUI_CanvasEdgePrs* myOutEdge;
168 class SUPERVGUI_CanvasEdgePrs : public QCanvasLine
171 SUPERVGUI_CanvasEdgePrs(QCanvas* theCanvas, SUPERVGUI_CanvasLink* theLink);
172 ~SUPERVGUI_CanvasEdgePrs() {}
174 SUPERVGUI_CanvasLink* getLink() const { return myLink; }
176 void setFromPoint(SUPERVGUI_CanvasPointPrs* thePoint);
177 void setToPoint(SUPERVGUI_CanvasPointPrs* thePoint);
179 void moveBy(double dx, double dy);
180 void setColor(const QColor& theColor);
182 void setMoving(bool b) { myMoving = b; }
183 bool isMoving() const { return myMoving; }
185 virtual int rtti() const;
189 SUPERVGUI_CanvasLink* myLink;
191 //mkr: for moving segment of link
192 SUPERVGUI_CanvasPointPrs* myStartPoint;
193 SUPERVGUI_CanvasPointPrs* myEndPoint;