1 // SUPERV SUPERVGUI : GUI for Supervisor component
3 // Copyright (C) 2003 OPEN CASCADE
5 // File : SUPERVGUI_CanvasControlNodePrs.cxx
6 // Author : Natalia KOPNOVA
9 #include "SUPERVGUI_CanvasControlNodePrs.h"
10 #include "SUPERVGUI_CanvasControlNode.h"
11 #include "SUPERVGUI_Canvas.h"
13 #define SHIFT LABEL_HEIGHT/2
15 //=====================================================================
16 // Control node presentation
17 //=====================================================================
18 SUPERVGUI_CanvasControlNodePrs::SUPERVGUI_CanvasControlNodePrs( SUIT_ResourceMgr* mgr, QCanvas* theCanvas, SUPERVGUI_CanvasNode* theNode):
19 SUPERVGUI_CanvasNodePrs( mgr, theCanvas, theNode)
21 Trace("SUPERVGUI_CanvasControlNodePrs::SUPERVGUI_CanvasControlNodePrs");
22 setLabelVisible(false);
23 setNodeColor(Qt::cyan.light());
26 void SUPERVGUI_CanvasControlNodePrs::hideAll()
28 bool aDisp = isVisible();
31 setPortVisible(false);
39 void SUPERVGUI_CanvasControlNodePrs::showAll()
41 bool aDisp = isVisible();
52 QRect SUPERVGUI_CanvasControlNodePrs::getStatusRect() const
54 return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight()+
55 getBodyHeight()+getGateHeight(),
56 width(), getStatusHeight());
59 QRect SUPERVGUI_CanvasControlNodePrs::getBodyRect() const
61 return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight(),
62 width(), getBodyHeight());
65 QRect SUPERVGUI_CanvasControlNodePrs::getGateRect() const
67 return QRect((int)x(), ((int)y())+getTitleHeight()+getLabelHeight()+getBodyHeight(),
68 width(), getGateHeight());
71 //=====================================================================
72 // Start control node presentation
73 //=====================================================================
74 SUPERVGUI_CanvasStartNodePrs::SUPERVGUI_CanvasStartNodePrs( SUIT_ResourceMgr* mgr, QCanvas* theCanvas, SUPERVGUI_CanvasStartNode* theNode):
75 SUPERVGUI_CanvasControlNodePrs( mgr, theCanvas, theNode)
77 Trace("SUPERVGUI_CanvasStartNodePrs::SUPERVGUI_CanvasStartNodePrs");
80 QPointArray SUPERVGUI_CanvasStartNodePrs::areaPoints() const
83 int h = height()+2; // add width of pen
85 int h1 = getTitleHeight()+1;
86 int h2 = getStatusHeight()+1;
89 QPoint p((int)x(), (int)y()-1);
90 aPnts[0] = p + QPoint(0, h1);
91 aPnts[1] = p + QPoint(SHIFT, 0);
92 aPnts[2] = aPnts[1] + QPoint(w, 0);
93 aPnts[3] = aPnts[0] + QPoint(w, 0);
94 aPnts[4] = aPnts[3] + QPoint(0, h-h1-h2);
95 aPnts[5] = aPnts[2] + QPoint(0, h);
96 aPnts[6] = aPnts[1] + QPoint(0, h);
97 aPnts[7] = aPnts[0] + QPoint(0, h-h1-h2);
101 void SUPERVGUI_CanvasStartNodePrs::drawFrame(QPainter& thePainter)
105 int h1 = getTitleHeight();
106 int h2 = getStatusHeight();
108 QRect r0(r.x(), r.y()+h1, r.width(), r.height()-h1-h2);
110 QBrush saved = thePainter.brush();
111 thePainter.setBrush(NoBrush);
112 thePainter.drawRect(r0);
113 thePainter.setBrush(saved);
116 void SUPERVGUI_CanvasStartNodePrs::drawTitleShape(QPainter& thePainter)
118 QRect r = getTitleRect();
121 QPointArray aPnts(4);
122 aPnts[0] = r.topLeft() + QPoint(0, r.height());
123 aPnts[1] = r.topLeft() + QPoint(SHIFT, 0);
124 aPnts[2] = aPnts[1] + QPoint(w, 0);
125 aPnts[3] = aPnts[0] + QPoint(w, 0);
127 thePainter.setBrush(Qt::red.light());
128 thePainter.drawPolygon(aPnts);
131 void SUPERVGUI_CanvasStartNodePrs::drawStatusShape(QPainter& thePainter)
133 QRect r = getStatusRect();
136 QPointArray aPnts(4);
137 aPnts[0] = r.topLeft() + QPoint(SHIFT, r.height());
138 aPnts[1] = r.topLeft();
139 aPnts[2] = aPnts[1] + QPoint(w, 0);
140 aPnts[3] = aPnts[0] + QPoint(w, 0);
142 thePainter.drawPolygon(aPnts);
146 void SUPERVGUI_CanvasStartNodePrs::setState(SUPERV::GraphState theState)
148 QRect r = getStatusRect();
149 canvas()->setChanged(QRect(r.x(), r.y(), r.width()+SHIFT, r.height()));
150 SUPERVGUI_CanvasNodePrs::setState(theState);
154 //=====================================================================
155 // End control node presentation
156 //=====================================================================
157 SUPERVGUI_CanvasEndNodePrs::SUPERVGUI_CanvasEndNodePrs( SUIT_ResourceMgr* mgr, QCanvas* theCanvas, SUPERVGUI_CanvasEndNode* theNode):
158 SUPERVGUI_CanvasControlNodePrs(mgr,theCanvas, theNode)
160 Trace("SUPERVGUI_CanvasEndNodePrs::SUPERVGUI_CanvasEndNodePrs");
163 QPointArray SUPERVGUI_CanvasEndNodePrs::areaPoints() const
168 int h1 = getTitleHeight()+1;
169 int h2 = getStatusHeight()+1;
171 QPointArray aPnts(8);
172 QPoint p((int)x(), (int)y()-1);
173 aPnts[0] = p + QPoint(0, h1);
174 aPnts[1] = p + QPoint(-SHIFT, 0);
175 aPnts[2] = aPnts[1] + QPoint(w, 0);
176 aPnts[3] = aPnts[0] + QPoint(w, 0);
177 aPnts[4] = aPnts[3] + QPoint(0, h-h1-h2);
178 aPnts[5] = aPnts[2] + QPoint(0, h);
179 aPnts[6] = aPnts[1] + QPoint(0, h);
180 aPnts[7] = aPnts[0] + QPoint(0, h-h1-h2);
184 void SUPERVGUI_CanvasEndNodePrs::drawFrame(QPainter& thePainter)
188 int h1 = getTitleHeight();
189 int h2 = getStatusHeight();
191 QRect r0(r.x(), r.y()+h1, r.width(), r.height()-h1-h2);
193 QBrush saved = thePainter.brush();
194 thePainter.setBrush(NoBrush);
195 thePainter.drawRect(r0);
196 thePainter.setBrush(saved);
199 void SUPERVGUI_CanvasEndNodePrs::drawTitleShape(QPainter& thePainter)
201 QRect r = getTitleRect();
204 QPointArray aPnts(4);
205 aPnts[0] = r.topLeft() + QPoint(0, r.height());
206 aPnts[1] = r.topLeft() + QPoint(-SHIFT, 0);
207 aPnts[2] = aPnts[1] + QPoint(w, 0);
208 aPnts[3] = aPnts[0] + QPoint(w, 0);
210 thePainter.setBrush(Qt::red.light());
211 thePainter.drawPolygon(aPnts);
214 void SUPERVGUI_CanvasEndNodePrs::drawStatusShape(QPainter& thePainter)
216 QRect r = getStatusRect();
219 QPointArray aPnts(4);
220 aPnts[0] = r.topLeft() + QPoint(-SHIFT, r.height());
221 aPnts[1] = r.topLeft();
222 aPnts[2] = aPnts[1] + QPoint(w, 0);
223 aPnts[3] = aPnts[0] + QPoint(w, 0);
225 thePainter.drawPolygon(aPnts);
228 void SUPERVGUI_CanvasEndNodePrs::setState(SUPERV::GraphState theState)
230 QRect r = getStatusRect();
231 canvas()->setChanged(QRect(r.x()-SHIFT, r.y(), r.width()+SHIFT, r.height()));
232 SUPERVGUI_CanvasNodePrs::setState(theState);
235 //=====================================================================
236 // Goto control node presentation
237 //=====================================================================
238 SUPERVGUI_CanvasGotoNodePrs::SUPERVGUI_CanvasGotoNodePrs( SUIT_ResourceMgr* mgr, QCanvas* theCanvas, SUPERVGUI_CanvasGotoNode* theNode):
239 SUPERVGUI_CanvasControlNodePrs(mgr, theCanvas, theNode)
241 Trace("SUPERVGUI_CanvasGotoNodePrs::SUPERVGUI_CanvasGotoNodePrs");
244 QPointArray SUPERVGUI_CanvasGotoNodePrs::areaPoints() const
249 int h1 = getTitleHeight()+1;
250 int h2 = getStatusHeight()+1;
252 QPointArray aPnts(8);
253 QPoint p((int)x(), (int)y()-1);
254 aPnts[0] = p + QPoint(0, h1);
255 aPnts[1] = p + QPoint(SHIFT, 0);
256 aPnts[2] = aPnts[1] + QPoint(w-2*SHIFT, 0);
257 aPnts[3] = aPnts[0] + QPoint(w, 0);
258 aPnts[4] = aPnts[3] + QPoint(0, h-h1-h2);
259 aPnts[5] = aPnts[2] + QPoint(0, h);
260 aPnts[6] = aPnts[1] + QPoint(0, h);
261 aPnts[7] = aPnts[0] + QPoint(0, h-h1-h2);
265 void SUPERVGUI_CanvasGotoNodePrs::drawFrame(QPainter& thePainter)
269 int h1 = getTitleHeight();
270 int h2 = getStatusHeight();
272 QRect r0(r.x(), r.y()+h1, r.width(), r.height()-h1-h2);
274 QBrush saved = thePainter.brush();
275 thePainter.setBrush(NoBrush);
276 thePainter.drawRect(r0);
277 thePainter.setBrush(saved);
280 void SUPERVGUI_CanvasGotoNodePrs::drawTitleShape(QPainter& thePainter)
282 QRect r = getTitleRect();
285 QPointArray aPnts(4);
286 aPnts[0] = r.topLeft() + QPoint(0, r.height());
287 aPnts[1] = r.topLeft() + QPoint(SHIFT, 0);
288 aPnts[2] = aPnts[1] + QPoint(w-2*SHIFT, 0);
289 aPnts[3] = aPnts[0] + QPoint(w, 0);
291 thePainter.setBrush(Qt::green.light());
292 thePainter.drawPolygon(aPnts);
295 void SUPERVGUI_CanvasGotoNodePrs::drawStatusShape(QPainter& thePainter)
297 QRect r = getStatusRect();
300 QPointArray aPnts(4);
301 aPnts[0] = r.topLeft() + QPoint(SHIFT, r.height());
302 aPnts[1] = r.topLeft();
303 aPnts[2] = aPnts[1] + QPoint(w, 0);
304 aPnts[3] = aPnts[0] + QPoint(w-2*SHIFT, 0);
306 thePainter.drawPolygon(aPnts);
310 //=====================================================================
311 // Macro node presentation
312 //=====================================================================
313 SUPERVGUI_CanvasMacroNodePrs::SUPERVGUI_CanvasMacroNodePrs( SUIT_ResourceMgr* mgr, QCanvas* theCanvas, SUPERVGUI_CanvasMacroNode* theNode):
314 SUPERVGUI_CanvasNodePrs( mgr, theCanvas, theNode)
316 Trace("SUPERVGUI_CanvasControlNodePrs::SUPERVGUI_CanvasControlNodePrs");
317 setNodeColor(QColor(255, 186, 149)); //QColor(255, 200, 170));
320 void SUPERVGUI_CanvasMacroNodePrs::drawFrame(QPainter& thePainter)
322 SUPERVGUI_CanvasNodePrs::drawFrame(thePainter);
324 QPen saved = thePainter.pen();
325 thePainter.setPen(QPen(saved.color(), 2));
328 thePainter.drawLine(r.left(), r.top(), r.left(), r.bottom());
329 thePainter.drawLine(r.left()+3, r.top(), r.left()+3, r.bottom());
330 thePainter.drawLine(r.right()-3, r.top(), r.right()-3, r.bottom());
331 thePainter.drawLine(r.right(), r.top(), r.right(), r.bottom());
332 thePainter.setPen(saved);
335 QPointArray SUPERVGUI_CanvasMacroNodePrs::areaPoints() const
337 int w = width()+2; // add width of pen
340 QPointArray aPnts(4);
341 aPnts[0] = QPoint((int)x()-1, (int)y());
342 aPnts[1] = aPnts[0] + QPoint(w, 0);
343 aPnts[2] = aPnts[1] + QPoint(0, h);
344 aPnts[3] = aPnts[0] + QPoint(0, h);