Salome HOME
A new dialog class for edition of Ports of an InLine nodes is introduced. This funct...
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_CtrlLink.cxx
1 //  SUPERV SUPERVGUI : GUI for Supervisor component
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : SUPERVGUI_CtrlLink.cxx
8 //  Author : Vitaly SMETANNIKOV
9 //  Module : SUPERV
10
11 using namespace std;
12 #include "SUPERVGUI_CtrlLink.h"
13 #include "SUPERVGUI_Graph.h"
14 #include "SUPERVGUI_GraphNode.h"
15
16 #define LINE_WIDTH 2
17 #define DRAW_CLR Qt::black
18
19 SUPERVGUI_CtrlLink::SUPERVGUI_CtrlLink(SUPERVGUI_Graph* theGraph,
20                                       SUPERVGUI_GraphNode* theFromNode,
21                                       SUPERVGUI_GraphNode* theToNode) 
22 {
23   myOutNode = theFromNode;
24   myInNode = theToNode;
25   myGraph = theGraph;
26 }
27
28
29
30 void SUPERVGUI_CtrlLink::paint(QPainter* thePainter, bool toErase) {
31   if ((myGraph == NULL) || (myInNode == NULL) || (myOutNode == NULL))
32     return;
33   thePainter->save();
34
35   QPen aDataPen;
36   aDataPen.setWidth(LINE_WIDTH);
37   if (toErase) {
38     aDataPen.setColor(myGraph->viewport()->paletteBackgroundColor());
39   } else {
40     aDataPen.setColor(DRAW_CLR);
41   }
42   thePainter->setPen(aDataPen);
43   thePainter->moveTo(myOutNode->getOutConnectPnt());
44   thePainter->lineTo(myInNode->getInConnectPnt());
45
46   thePainter->restore();
47 }