1 // SUPERV SUPERVGUI : GUI for Supervisor component
3 // Copyright (C) 2003 OPEN CASCADE
5 // File : SUPERVGUI_CanvasLink.h
6 // Author : Natalia KOPNOVA
9 #ifndef SUPERVGUI_CanvasLink_H
10 #define SUPERVGUI_CanvasLink_H
13 #include "SUPERVGUI_Def.h"
15 #include <qvaluevector.h>
18 class SUPERVGUI_CanvasPort;
20 class SUPERVGUI_CanvasLink : public QObject {
24 SUPERVGUI_CanvasLink(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Link_ptr theLink=0);
25 virtual ~SUPERVGUI_CanvasLink();
30 void setHilighted(bool state);
31 void setColor(const QColor& theColor);
33 virtual void moveByPort(SUPERVGUI_CanvasPort* thePort);
34 virtual void moveByPort(SUPERVGUI_CanvasPort* thePort, int dx, int dy);
36 SUPERV_Link getEngine() const { return myLink; }
37 SUPERVGUI_Main* getMain() const { return myMain; }
39 SUPERVGUI_CanvasPort* getInputPort() const { return myInputPort; }
40 SUPERVGUI_CanvasPort* getOutputPort() const { return myOutputPort; }
42 void setSelectedObject(QCanvasItem* theItem, const QPoint& thePoint);
43 virtual QPopupMenu* getPopupMenu(QWidget* theParent);
46 virtual void remove();
51 void addPoint(const QPoint& thePoint, const int& theIndex = -1);
54 QCanvasItemList myPrs;
60 SUPERVGUI_Main* myMain;
62 SUPERVGUI_CanvasPort* myInputPort;
63 SUPERVGUI_CanvasPort* myOutputPort;
66 QCanvasItem* mySelectedItem;
67 QPoint mySelectedPoint;
71 class SUPERVGUI_CanvasStreamLink : public SUPERVGUI_CanvasLink {
75 SUPERVGUI_CanvasStreamLink(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::StreamLink_ptr theLink=0);
76 ~SUPERVGUI_CanvasStreamLink() {}
78 SUPERV_StreamLink getStreamEngine() const { return myStreamLink; }
81 virtual void remove();
84 SUPERV_StreamLink myStreamLink;
88 class SUPERVGUI_CanvasLinkBuilder : public SUPERVGUI_CanvasLink {
92 SUPERVGUI_CanvasLinkBuilder(QObject* theParent, SUPERVGUI_Main* theMain, SUPERVGUI_CanvasPort* thePort=0);
93 virtual ~SUPERVGUI_CanvasLinkBuilder();
95 bool canCreateEngine(SUPERVGUI_CanvasPort* thePort);
96 void setCoords(SUPERV::Link_ptr theLink);
98 SUPERVGUI_CanvasPort* getStartPort() const { return myPort; }
100 int getPointCount() const { return (int) (myPrs.count()/2); }
101 void addNextPoint(const QPoint& thePoint, bool theOrtho = false);
102 void setFloatPoint(const QPoint& thePoint);
103 void removeLastPoint();
105 virtual void moveByPort(SUPERVGUI_CanvasPort* thePort);
106 virtual void moveByPort(SUPERVGUI_CanvasPort* thePort, int dx, int dy);
109 SUPERVGUI_CanvasPort* myPort;
111 QCanvasLine* myFloatingEdge;
115 class SUPERVGUI_CanvasEdgePrs;
116 class SUPERVGUI_CanvasPointPrs : public QCanvasEllipse
119 SUPERVGUI_CanvasPointPrs(QCanvas* theCanvas, SUPERVGUI_CanvasLink* theLink, const int& theIndex = -1);
120 ~SUPERVGUI_CanvasPointPrs() {}
122 SUPERVGUI_CanvasLink* getLink() const { return myLink; }
123 int getIndex() const { return myIndex; }
125 void setInEdge(SUPERVGUI_CanvasEdgePrs* theEdge);
126 void setOutEdge(SUPERVGUI_CanvasEdgePrs* theEdge);
128 void moveBy(double dx, double dy);
129 void setColor(const QColor& theColor);
131 void setMoving(bool b) { myMoving = b; }
132 bool isMoving() const { return myMoving; }
134 virtual int rtti() const;
137 SUPERVGUI_CanvasLink* myLink;
141 SUPERVGUI_CanvasEdgePrs* myInEdge;
142 SUPERVGUI_CanvasEdgePrs* myOutEdge;
146 class SUPERVGUI_CanvasEdgePrs : public QCanvasLine
149 SUPERVGUI_CanvasEdgePrs(QCanvas* theCanvas, SUPERVGUI_CanvasLink* theLink);
150 ~SUPERVGUI_CanvasEdgePrs() {}
152 SUPERVGUI_CanvasLink* getLink() const { return myLink; }
154 void setFromPoint(int x, int y);
155 void setToPoint(int x, int y);
157 void moveBy(double dx, double dy) {}
158 void setColor(const QColor& theColor);
160 virtual int rtti() const;
163 SUPERVGUI_CanvasLink* myLink;