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