Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_CanvasNodePrs.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_CanvasNodePrs.h
23 //  Author : Natalia KOPNOVA
24 //  Module : SUPERV
25
26 #ifndef SUPERVGUI_CanvasNodePrs_H
27 #define SUPERVGUI_CanvasNodePrs_H
28
29 #include "SUPERVGUI_Def.h"
30
31 #include <qcanvas.h>
32
33
34 class SUPERVGUI_CanvasNodePrs;
35 class SUPERVGUI_CanvasPortPrs;
36 class SUIT_ResourceMgr;
37 class SUPERVGUI_CanvasHookPrs : public QCanvasEllipse
38 {
39   public:
40     SUPERVGUI_CanvasHookPrs(QCanvas* theCanvas, SUPERVGUI_CanvasNodePrs* theNode, const bool& theIn);
41     SUPERVGUI_CanvasHookPrs(QCanvas* theCanvas, SUPERVGUI_CanvasPortPrs* thePort, const bool& theIn);
42     ~SUPERVGUI_CanvasHookPrs();
43
44     QObject* getObject() const;
45
46     void setCoords(int x, int y);
47
48     void setVisible(bool b);
49     void moveBy(double dx, double dy);
50     void setZ(double z);
51
52     virtual int rtti() const;
53
54   private:
55     void init(QCanvas* theCanvas);
56
57     SUPERVGUI_CanvasNodePrs* myNodePrs;
58     SUPERVGUI_CanvasPortPrs* myPortPrs;
59
60     bool myIn;
61
62     QCanvasLine* myLine;
63 };
64
65
66 class SUPERVGUI_CanvasNode;
67 class SUPERVGUI_CanvasNodePrs: public QCanvasPolygonalItem {
68
69   public:
70     SUPERVGUI_CanvasNodePrs( SUIT_ResourceMgr*, QCanvas*, SUPERVGUI_CanvasNode*, bool theCellPrs=false);
71     virtual ~SUPERVGUI_CanvasNodePrs();
72
73     SUPERVGUI_CanvasNode* getNode() const { return myNode; }
74     QObject* getObject(const QPoint& thePos) const;
75
76     QString getStatus() const { return myStatus; }
77     QColor getStatusColor() const { return myStatusColor; }
78
79     void setStatus(QString theStatus) { myStatus = theStatus; }
80     void setStatusColor(QColor theStatusColor) { myStatusColor = theStatusColor; }
81     
82     virtual int width() const;
83     virtual int height() const;
84
85     virtual int getTitleHeight() const;
86     virtual int getLabelHeight() const;
87     virtual int getStatusHeight() const;
88     virtual int getBodyHeight() const;
89     virtual int getPortHeight() const;
90     virtual int getStreamHeight() const;
91     virtual int getGateHeight() const;
92     
93     QPointArray areaPoints() const;
94     void moveBy(double dx, double dy);
95     void setZ(double z);
96
97     void setMoving(bool b) { myMoving = b; }
98     bool isMoving() const { return myMoving; }
99
100     virtual int rtti() const;
101
102     virtual void hideAll();
103     virtual void showAll();
104     virtual void setLabelVisible(bool b);
105     virtual void setPortVisible(bool b);
106     bool isLabelVisible() const { return myLabelVisible; }
107     bool isPortVisible() const { return myPortVisible; }
108
109     virtual void setNodeColor(const QColor& theColor);
110     virtual QColor nodeColor() const { return myColor; }
111
112     virtual void setState(SUPERV::GraphState theState);
113     virtual void updateInfo();
114     virtual void updatePorts();
115     virtual void updateGates();
116     virtual void updatePoints();
117
118     virtual QPoint getInConnectionPoint() const;
119     virtual QPoint getOutConnectionPoint() const;
120
121     virtual QRect getRect() const;
122     virtual QRect getTitleRect() const;
123     virtual QRect getStatusRect() const;
124     virtual QRect getLabelRect() const;
125     virtual QRect getBodyRect() const;
126     virtual QRect getGateRect() const;
127
128   protected:
129     void draw(QPainter& thePainter);
130     virtual void drawShape(QPainter& thePainter);
131
132     virtual void drawTitle(QPainter& thePainter);
133     virtual void drawLabel(QPainter& thePainter);
134     virtual void drawPort(QPainter& thePainter);
135     virtual void drawGate(QPainter& thePainter);
136     virtual void drawStatus(QPainter& thePainter);
137
138     virtual void drawFrame(QPainter& thePainter);
139     virtual void drawTitleShape(QPainter& thePainter);
140     virtual void drawStatusShape(QPainter& thePainter);
141
142     SUIT_ResourceMgr* resMgr() const { return myMgr; }
143     bool myPortVisible;
144
145   private:
146     SUPERVGUI_CanvasNode* myNode;
147     SUIT_ResourceMgr* myMgr;
148
149     int myWidth;
150
151     int myTitleHeight;
152     int myLabelHeight;
153     int myStatusHeight;
154     int myPortHeight;
155     int myStreamHeight;
156     int myGateHeight;
157
158     bool myLabelVisible;
159     bool myCellPrs;
160     bool myMoving;
161
162     QString myStatus;
163     QString myTime;
164
165     QColor myColor;
166     QColor myStatusColor;
167
168     SUPERVGUI_CanvasHookPrs* myPointIn;
169     SUPERVGUI_CanvasHookPrs* myPointOut;
170 };
171
172
173 class SUPERVGUI_CanvasPort;
174 class SUPERVGUI_CanvasPortPrs {
175
176  public:
177   SUPERVGUI_CanvasPortPrs(QCanvas* theCanvas, SUPERVGUI_CanvasPort* thePort);
178   ~SUPERVGUI_CanvasPortPrs();
179
180   SUPERVGUI_CanvasPort* getPort() { return myPort; }
181   virtual void update(bool theForce = false);
182
183   virtual bool isHilight() const;
184   virtual bool isAlert() const;
185
186   virtual QString getText() const;
187   virtual int getAlignment() const;
188
189   void setPortRect(const QRect& theRect);
190   QRect getPortRect() const { return myRect; }
191
192   void setVisible(bool b);
193   bool isVisible() const { return myVisible; }
194
195   void moveBy(int dx, int dy);
196   void setZ(double z);
197
198   QPoint getConnectionPoint() const;
199   void draw(QPainter& thePainter);
200
201  private:
202   SUPERVGUI_CanvasPort* myPort;
203   QCanvas*              myCanvas;
204   QRect                 myRect;
205   QString               myText;
206
207   SUPERVGUI_CanvasHookPrs* myPoint;
208   bool                  myVisible;
209 };
210
211 #endif