Salome HOME
d8aa906e78e927607bda0b63cfb822d94d4401c0
[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, 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     bool myPortVisible;
126
127   private:
128     SUPERVGUI_CanvasNode* myNode;
129
130     int myWidth;
131
132     int myTitleHeight;
133     int myLabelHeight;
134     int myStatusHeight;
135     int myPortHeight;
136     int myStreamHeight;
137     int myGateHeight;
138
139     bool myLabelVisible;
140     bool myCellPrs;
141     bool myMoving;
142
143     QString myStatus;
144     QString myTime;
145
146     QColor myColor;
147     QColor myStatusColor;
148
149     SUPERVGUI_CanvasHookPrs* myPointIn;
150     SUPERVGUI_CanvasHookPrs* myPointOut;
151 };
152
153
154 class SUPERVGUI_CanvasPort;
155 class SUPERVGUI_CanvasPortPrs {
156
157  public:
158   SUPERVGUI_CanvasPortPrs(QCanvas* theCanvas, SUPERVGUI_CanvasPort* thePort);
159   ~SUPERVGUI_CanvasPortPrs();
160
161   SUPERVGUI_CanvasPort* getPort() { return myPort; }
162   virtual void update(bool theForce = false);
163
164   virtual bool isHilight() const;
165   virtual bool isAlert() const;
166
167   virtual QString getText() const;
168   virtual int getAlignment() const;
169
170   void setPortRect(const QRect& theRect);
171   QRect getPortRect() const { return myRect; }
172
173   void setVisible(bool b);
174   bool isVisible() const { return myVisible; }
175
176   void moveBy(int dx, int dy);
177   void setZ(double z);
178
179   QPoint getConnectionPoint() const;
180   void draw(QPainter& thePainter);
181
182  private:
183   SUPERVGUI_CanvasPort* myPort;
184   QCanvas*              myCanvas;
185   QRect                 myRect;
186   QString               myText;
187
188   SUPERVGUI_CanvasHookPrs* myPoint;
189   bool                  myVisible;
190 };
191
192 #endif