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
15 #include "SUPERVGUI_Def.h"
16 #include "SUPERVGUI_Port.h"
17 #include <qvaluevector.h>
19 class SUPERVGUI_Graph;
21 int distance(int x1, int y1, int x2, int y2);
22 int distance(QPoint thePnt, QPoint thePntLn1, QPoint thePntLn2);
25 class SUPERVGUI_Link: public QObject {
29 SUPERVGUI_Link(SUPERVGUI_Graph* theGraph, SUPERV_Link theLink=0);
31 virtual ~SUPERVGUI_Link();
33 void setBeginPort(SUPERVGUI_Port* theBeginPort);
34 SUPERVGUI_Port* getBeginPort();
36 void setInputPort(SUPERVGUI_PortIn* thePortIn);
37 SUPERVGUI_PortIn* getInputPort()
40 void setInputPortES(SUPERVGUI_PortInESNode* thePortInES);
41 SUPERVGUI_PortInESNode* getInputPortES()
42 { return myPortInES; };
48 void setOutputPort(SUPERVGUI_PortOut* thePortOut);
49 SUPERVGUI_PortOut* getOutputPort()
50 { return myPortOut; };
52 void addPoint(long theX, long theY);
53 void removeLastPoint();
56 void paint(bool toErase);
57 void paint(QPainter* thePainter, bool toErase);
58 void drawLink(QPainter* thePainter);
60 bool isInRect(int theX, int theY, int theW, int theH);
62 SUPERV_Link getEngineLink()
65 void drawTo(QPoint thePnt);
69 void addTmpPoint(QPoint thePnt);
70 void delLastTmpPoint();
72 bool isCreationComplete();
76 { return myIsSelected; };
78 bool haveSelectedPoint()
79 { return (myHltPnt > -1); };
81 int getSelectedPoint()
84 void removePoint(int thePnt);
86 void setVisible(bool theVisible);
88 static void setOrthoMode(bool theIsOrtho)
89 { OrthoMode = theIsOrtho; };
91 static bool isOrthoMode()
92 { return OrthoMode; };
94 static SUPERVGUI_Link* getSelectedLink()
95 { return SelectedLink; };
98 void linkDeleted(SUPERVGUI_Link*);
101 void onMouseMove(QMouseEvent* theEvent);
102 void onMousePress(QMouseEvent* theEvent);
103 void onMouseRelease(QMouseEvent* theEvent);
107 void connectToEvents();
108 bool isSelected(QPoint thePnt);
111 SUPERVGUI_Graph* myGraph;
112 SUPERVGUI_Port* myBeginPort;
113 SUPERVGUI_PortIn* myPortIn;
114 SUPERVGUI_PortInESNode* myPortInES;
115 SUPERVGUI_PortOut* myPortOut;
117 SUPERV_Link myEngine;
119 QPoint myPrevPoint; // used for sketching only
120 QValueVector<QPoint> myTmpPoints;
121 SUPERVGUI_Port* myStartPort;
125 // Points highlighting management
126 int myHltPnt; // number of point or -1
128 // Points moving management
130 bool myPntMovingState;
131 QPoint myBeforePnt, myMovedPnt, myAfterPnt;
139 static bool OrthoMode;
140 static bool LinkIsMoving;
141 static SUPERVGUI_Link* SelectedLink;