1 // SUPERV SUPERVGUI : GUI for Supervisor component
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : SUPERVGUI_Link.h
8 // Author : Vitaly SMETANNIKOV
11 #ifndef SUPERVGUI_Link_H
12 #define SUPERVGUI_Link_H
16 #include "SUPERVGUI_Def.h"
17 #include "SUPERVGUI_Port.h"
18 //_CS_PhB BUG QT erreur de compilation #include <qvaluevector.h>
21 class SUPERVGUI_Graph;
23 int distance(int x1, int y1, int x2, int y2);
24 int distance(QPoint thePnt, QPoint thePntLn1, QPoint thePntLn2);
27 class SUPERVGUI_Link: public QObject {
31 SUPERVGUI_Link(SUPERVGUI_Graph* theGraph, SUPERV_Link theLink=0);
33 virtual ~SUPERVGUI_Link();
35 void setBeginPort(SUPERVGUI_Port* theBeginPort);
36 SUPERVGUI_Port* getBeginPort();
38 void setInputPort(SUPERVGUI_PortIn* thePortIn);
39 SUPERVGUI_PortIn* getInputPort()
42 void setInputPortES(SUPERVGUI_PortInESNode* thePortInES);
43 SUPERVGUI_PortInESNode* getInputPortES()
44 { return myPortInES; };
50 void setOutputPort(SUPERVGUI_PortOut* thePortOut);
51 SUPERVGUI_PortOut* getOutputPort()
52 { return myPortOut; };
54 void addPoint(long theX, long theY);
55 void removeLastPoint();
58 void paint(bool toErase);
59 void paint(QPainter* thePainter, bool toErase);
60 void drawLink(QPainter* thePainter);
62 bool isInRect(int theX, int theY, int theW, int theH);
64 SUPERV_Link getEngineLink()
67 void drawTo(QPoint thePnt);
71 void addTmpPoint(QPoint thePnt);
72 void delLastTmpPoint();
74 bool isCreationComplete();
78 { return myIsSelected; };
80 bool haveSelectedPoint()
81 { return (myHltPnt > -1); };
83 int getSelectedPoint()
86 void removePoint(int thePnt);
88 void setVisible(bool theVisible);
90 static void setOrthoMode(bool theIsOrtho)
91 { OrthoMode = theIsOrtho; };
93 static bool isOrthoMode()
94 { return OrthoMode; };
96 static SUPERVGUI_Link* getSelectedLink()
97 { return SelectedLink; };
100 void linkDeleted(SUPERVGUI_Link*);
103 void onMouseMove(QMouseEvent* theEvent);
104 void onMousePress(QMouseEvent* theEvent);
105 void onMouseRelease(QMouseEvent* theEvent);
109 void connectToEvents();
110 bool isSelected(QPoint thePnt);
113 SUPERVGUI_Graph* myGraph;
114 SUPERVGUI_Port* myBeginPort;
115 SUPERVGUI_PortIn* myPortIn;
116 SUPERVGUI_PortInESNode* myPortInES;
117 SUPERVGUI_PortOut* myPortOut;
119 SUPERV_Link myEngine;
121 QPoint myPrevPoint; // used for sketching only
122 //_CS_PhB BUG QT erreur de compilation QValueVector<QPoint> myTmpPoints;
123 vector<QPoint> myTmpPoints;
125 SUPERVGUI_Port* myStartPort;
129 // Points highlighting management
130 int myHltPnt; // number of point or -1
132 // Points moving management
134 bool myPntMovingState;
135 QPoint myBeforePnt, myMovedPnt, myAfterPnt;
143 static bool OrthoMode;
144 static bool LinkIsMoving;
145 static SUPERVGUI_Link* SelectedLink;