]> SALOME platform Git repositories - modules/superv.git/blob - src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.h
Salome HOME
DCQ:prepare 2.0.0
[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 using namespace std;
13 #include "SUPERVGUI_Def.h"
14
15 #include <qcanvas.h>
16
17
18 class SUPERVGUI_CanvasNodePrs;
19 class SUPERVGUI_CanvasPortPrs;
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(QCanvas* theCanvas, SUPERVGUI_CanvasNode* theNode);
54     virtual ~SUPERVGUI_CanvasNodePrs();
55
56     SUPERVGUI_CanvasNode* getNode() const { return myNode; }
57     QObject* getObject(const QPoint& thePos) const;
58
59     virtual int width() const;
60     virtual int height() const;
61
62     virtual int getTitleHeight() const;
63     virtual int getLabelHeight() const;
64     virtual int getStatusHeight() const;
65     virtual int getBodyHeight() const;
66     virtual int getPortHeight() const;
67     virtual int getStreamHeight() const;
68     virtual int getGateHeight() const;
69     
70     QPointArray areaPoints() const;
71     void moveBy(double dx, double dy);
72     void setZ(double z);
73
74     void setMoving(bool b) { myMoving = b; }
75     bool isMoving() const { return myMoving; }
76
77     virtual int rtti() const;
78
79     virtual void hideAll();
80     virtual void showAll();
81     virtual void setLabelVisible(bool b);
82     virtual void setPortVisible(bool b);
83     bool isLabelVisible() const { return myLabelVisible; }
84     bool isPortVisible() const { return myPortVisible; }
85
86     virtual void setNodeColor(const QColor& theColor);
87     virtual QColor nodeColor() const { return myColor; }
88
89     virtual void setState(SUPERV::GraphState theState);
90     virtual void updateInfo();
91     virtual void updatePorts();
92     virtual void updateGates();
93     virtual void updatePoints();
94
95     virtual QPoint getInConnectionPoint() const;
96     virtual QPoint getOutConnectionPoint() const;
97
98     virtual QRect getRect() const;
99     virtual QRect getTitleRect() const;
100     virtual QRect getStatusRect() const;
101     virtual QRect getLabelRect() const;
102     virtual QRect getBodyRect() const;
103     virtual QRect getGateRect() const;
104
105   protected:
106     void draw(QPainter& thePainter);
107     void drawShape(QPainter& thePainter);
108
109     virtual void drawTitle(QPainter& thePainter);
110     virtual void drawLabel(QPainter& thePainter);
111     virtual void drawPort(QPainter& thePainter);
112     virtual void drawGate(QPainter& thePainter);
113     virtual void drawStatus(QPainter& thePainter);
114
115     virtual void drawFrame(QPainter& thePainter);
116     virtual void drawTitleShape(QPainter& thePainter);
117     virtual void drawStatusShape(QPainter& thePainter);
118
119   private:
120     SUPERVGUI_CanvasNode* myNode;
121
122     int myWidth;
123
124     int myTitleHeight;
125     int myLabelHeight;
126     int myStatusHeight;
127     int myPortHeight;
128     int myStreamHeight;
129     int myGateHeight;
130
131     bool myLabelVisible;
132     bool myPortVisible;
133     bool myMoving;
134
135     QString myStatus;
136     QString myTime;
137
138     QColor myColor;
139     QColor myStatusColor;
140
141     SUPERVGUI_CanvasHookPrs* myPointIn;
142     SUPERVGUI_CanvasHookPrs* myPointOut;
143 };
144
145
146 class SUPERVGUI_CanvasPort;
147 class SUPERVGUI_CanvasPortPrs {
148
149  public:
150   SUPERVGUI_CanvasPortPrs(QCanvas* theCanvas, SUPERVGUI_CanvasPort* thePort);
151   ~SUPERVGUI_CanvasPortPrs();
152
153   SUPERVGUI_CanvasPort* getPort() { return myPort; }
154   virtual void update(bool theForce = false);
155
156   virtual bool isHilight() const;
157   virtual bool isAlert() const;
158
159   virtual QString getText() const;
160   virtual int getAlignment() const;
161
162   void setPortRect(const QRect& theRect);
163   QRect getPortRect() const { return myRect; }
164
165   void setVisible(bool b);
166   bool isVisible() const { return myVisible; }
167
168   void moveBy(int dx, int dy);
169   void setZ(double z);
170
171   QPoint getConnectionPoint() const;
172   void draw(QPainter& thePainter);
173
174  private:
175   SUPERVGUI_CanvasPort* myPort;
176   QCanvas*              myCanvas;
177   QRect                 myRect;
178   QString               myText;
179
180   SUPERVGUI_CanvasHookPrs* myPoint;
181   bool                  myVisible;
182 };
183
184 #endif