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 #include <qvaluevector.h>
20 class SUPERVGUI_Graph;
22 int distance(int x1, int y1, int x2, int y2);
23 int distance(QPoint thePnt, QPoint thePntLn1, QPoint thePntLn2);
26 class SUPERVGUI_Link: public QObject {
30 SUPERVGUI_Link(SUPERVGUI_Graph* theGraph, SUPERV_Link theLink=0);
32 virtual ~SUPERVGUI_Link();
34 void setBeginPort(SUPERVGUI_Port* theBeginPort);
35 SUPERVGUI_Port* getBeginPort();
37 void setInputPort(SUPERVGUI_PortIn* thePortIn);
38 SUPERVGUI_PortIn* getInputPort()
41 void setInputPortES(SUPERVGUI_PortInESNode* thePortInES);
42 SUPERVGUI_PortInESNode* getInputPortES()
43 { return myPortInES; };
49 void setOutputPort(SUPERVGUI_PortOut* thePortOut);
50 SUPERVGUI_PortOut* getOutputPort()
51 { return myPortOut; };
53 void addPoint(long theX, long theY);
54 void removeLastPoint();
57 void paint(bool toErase);
58 void paint(QPainter* thePainter, bool toErase);
59 void drawLink(QPainter* thePainter);
61 bool isInRect(int theX, int theY, int theW, int theH);
63 SUPERV_Link getEngineLink()
66 void drawTo(QPoint thePnt);
70 void addTmpPoint(QPoint thePnt);
71 void delLastTmpPoint();
73 bool isCreationComplete();
77 { return myIsSelected; };
79 bool haveSelectedPoint()
80 { return (myHltPnt > -1); };
82 int getSelectedPoint()
85 void removePoint(int thePnt);
87 void setVisible(bool theVisible);
89 static void setOrthoMode(bool theIsOrtho)
90 { OrthoMode = theIsOrtho; };
92 static bool isOrthoMode()
93 { return OrthoMode; };
95 static SUPERVGUI_Link* getSelectedLink()
96 { return SelectedLink; };
99 void linkDeleted(SUPERVGUI_Link*);
102 void onMouseMove(QMouseEvent* theEvent);
103 void onMousePress(QMouseEvent* theEvent);
104 void onMouseRelease(QMouseEvent* theEvent);
108 void connectToEvents();
109 bool isSelected(QPoint thePnt);
112 SUPERVGUI_Graph* myGraph;
113 SUPERVGUI_Port* myBeginPort;
114 SUPERVGUI_PortIn* myPortIn;
115 SUPERVGUI_PortInESNode* myPortInES;
116 SUPERVGUI_PortOut* myPortOut;
118 SUPERV_Link myEngine;
120 QPoint myPrevPoint; // used for sketching only
121 QValueVector<QPoint> myTmpPoints;
122 SUPERVGUI_Port* myStartPort;
126 // Points highlighting management
127 int myHltPnt; // number of point or -1
129 // Points moving management
131 bool myPntMovingState;
132 QPoint myBeforePnt, myMovedPnt, myAfterPnt;
140 static bool OrthoMode;
141 static bool LinkIsMoving;
142 static SUPERVGUI_Link* SelectedLink;