Salome HOME
Fix pb. with double omniORB.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_CanvasLink.h
1 //  SUPERV SUPERVGUI : GUI for Supervisor component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : SUPERVGUI_CanvasLink.h
23 //  Author : Natalia KOPNOVA
24 //  Module : SUPERV
25
26 #ifndef SUPERVGUI_CanvasLink_H
27 #define SUPERVGUI_CanvasLink_H
28
29 #include "SUPERVGUI_Def.h"
30 #include <qcanvas.h>
31 #include <qvaluevector.h>
32
33 class SUPERVGUI_Main;
34 class SUPERVGUI_CanvasPort;
35
36 class SUPERVGUI_CanvasLink : public QObject {
37   Q_OBJECT
38
39   public:
40     SUPERVGUI_CanvasLink(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Link_ptr theLink=0);
41     virtual ~SUPERVGUI_CanvasLink();
42
43     void show();
44     void merge();
45
46     void setHilighted(bool state);
47     void setColor(const QColor& theColor);
48
49     virtual void moveByPort(SUPERVGUI_CanvasPort* thePort);
50     virtual void moveByPort(SUPERVGUI_CanvasPort* thePort, int dx, int dy);
51
52     SUPERV_Link getEngine() const { return myLink; }
53     SUPERVGUI_Main* getMain() const { return myMain; }
54
55     SUPERVGUI_CanvasPort* getInputPort() const { return myInputPort; }
56     SUPERVGUI_CanvasPort* getOutputPort() const { return myOutputPort; }
57
58     void setSelectedObject(QCanvasItem* theItem, const QPoint& thePoint);
59     virtual QPopupMenu* getPopupMenu(QWidget* theParent);
60
61     QString getToolTipText() const;
62
63   signals:
64     void objectCreatedDeleted(); // mkr : PAL8237
65
66   public slots:
67     virtual void remove();
68     void addPoint();
69     void removePoint();
70
71   protected:
72     void addPoint(const QPoint& thePoint, const int& theIndex = -1);
73
74     QColor myColor;
75     QCanvasItemList myPrs;
76
77   private:
78     void createPrs();
79
80     SUPERV_Link     myLink;
81     SUPERVGUI_Main* myMain;
82
83     SUPERVGUI_CanvasPort* myInputPort;
84     SUPERVGUI_CanvasPort* myOutputPort;
85
86     bool myHilighted;
87     QCanvasItem* mySelectedItem;
88     QPoint       mySelectedPoint;
89 };
90
91 /*
92 class SUPERVGUI_CanvasStreamLink : public SUPERVGUI_CanvasLink {
93   Q_OBJECT
94
95   public:
96     SUPERVGUI_CanvasStreamLink(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::StreamLink_ptr theLink=0);
97     ~SUPERVGUI_CanvasStreamLink() {}
98
99     SUPERV_StreamLink getStreamEngine() const { return myStreamLink; }
100
101   public slots:
102     virtual void remove();
103
104   private:
105     SUPERV_StreamLink myStreamLink;
106 };
107 */
108
109 class SUPERVGUI_CanvasLinkBuilder : public SUPERVGUI_CanvasLink {
110   Q_OBJECT
111
112   public:
113     SUPERVGUI_CanvasLinkBuilder(QObject* theParent, SUPERVGUI_Main* theMain, SUPERVGUI_CanvasPort* thePort=0);
114     virtual ~SUPERVGUI_CanvasLinkBuilder();
115
116     bool canCreateEngine(SUPERVGUI_CanvasPort* thePort);
117     void setCoords(SUPERV::Link_ptr theLink);
118
119     SUPERVGUI_CanvasPort* getStartPort() const { return myPort; }
120
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();
125
126     virtual void moveByPort(SUPERVGUI_CanvasPort* thePort);
127     virtual void moveByPort(SUPERVGUI_CanvasPort* thePort, int dx, int dy);
128
129   private:
130     SUPERVGUI_CanvasPort* myPort;
131
132     QCanvasLine* myFloatingEdge;
133 };
134
135
136 class SUPERVGUI_CanvasEdgePrs;
137 class SUPERVGUI_CanvasPointPrs : public QCanvasEllipse 
138 {
139   public:
140     SUPERVGUI_CanvasPointPrs(QCanvas* theCanvas, SUPERVGUI_CanvasLink* theLink, const int& theIndex = -1);
141     ~SUPERVGUI_CanvasPointPrs() {}
142
143     SUPERVGUI_CanvasLink* getLink() const { return myLink; }
144     int getIndex() const { return myIndex; }
145
146     void setInEdge(SUPERVGUI_CanvasEdgePrs* theEdge);
147     void setOutEdge(SUPERVGUI_CanvasEdgePrs* theEdge);
148
149     void moveBy(double dx, double dy);
150     void setColor(const QColor& theColor);
151
152     void setMoving(bool b) { myMoving = b; }
153     bool isMoving() const { return myMoving; }
154
155     virtual int rtti() const;
156
157   private:
158     SUPERVGUI_CanvasLink* myLink;
159     int myIndex;
160     bool myMoving;
161
162     SUPERVGUI_CanvasEdgePrs* myInEdge;
163     SUPERVGUI_CanvasEdgePrs* myOutEdge;
164 };
165
166
167 class SUPERVGUI_CanvasEdgePrs : public QCanvasLine 
168 {
169   public:
170     SUPERVGUI_CanvasEdgePrs(QCanvas* theCanvas, SUPERVGUI_CanvasLink* theLink);
171     ~SUPERVGUI_CanvasEdgePrs() {}
172
173     SUPERVGUI_CanvasLink* getLink() const { return myLink; }
174
175     void setFromPoint(SUPERVGUI_CanvasPointPrs* thePoint);
176     void setToPoint(SUPERVGUI_CanvasPointPrs* thePoint);
177
178     void moveBy(double dx, double dy);
179     void setColor(const QColor& theColor);
180
181     void setMoving(bool b) { myMoving = b; }
182     bool isMoving() const { return myMoving; }
183
184     virtual int rtti() const;
185
186   private:
187     bool myMoving;
188     SUPERVGUI_CanvasLink* myLink;
189
190     //mkr: for moving segment of link
191     SUPERVGUI_CanvasPointPrs* myStartPoint;
192     SUPERVGUI_CanvasPointPrs* myEndPoint;
193 };
194
195 #endif