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