1 // File : SUPERVGUI_Link.h
2 // Created : 20 / 12 / 2002
3 // Author : Vitaly SMETANNIKOV
6 // Copyright : Open CASCADE
8 #ifndef SUPERVGUI_Link_H
9 #define SUPERVGUI_Link_H
13 #include "SUPERVGUI_Def.h"
14 #include "SUPERVGUI_Port.h"
15 #include <qvaluevector.h>
17 class SUPERVGUI_Graph;
19 int distance(int x1, int y1, int x2, int y2);
20 int distance(QPoint thePnt, QPoint thePntLn1, QPoint thePntLn2);
23 class SUPERVGUI_Link: public QObject {
27 SUPERVGUI_Link(SUPERVGUI_Graph* theGraph, SUPERV_Link theLink=0);
29 virtual ~SUPERVGUI_Link();
31 void setBeginPort(SUPERVGUI_Port* theBeginPort);
32 SUPERVGUI_Port* getBeginPort();
34 void setInputPort(SUPERVGUI_PortIn* thePortIn);
35 SUPERVGUI_PortIn* getInputPort()
38 void setInputPortES(SUPERVGUI_PortInESNode* thePortInES);
39 SUPERVGUI_PortInESNode* getInputPortES()
40 { return myPortInES; };
46 void setOutputPort(SUPERVGUI_PortOut* thePortOut);
47 SUPERVGUI_PortOut* getOutputPort()
48 { return myPortOut; };
50 void addPoint(long theX, long theY);
51 void removeLastPoint();
54 void paint(bool toErase);
55 void paint(QPainter* thePainter, bool toErase);
56 void drawLink(QPainter* thePainter);
58 bool isInRect(int theX, int theY, int theW, int theH);
60 SUPERV_Link getEngineLink()
63 void drawTo(QPoint thePnt);
67 void addTmpPoint(QPoint thePnt);
68 void delLastTmpPoint();
70 bool isCreationComplete();
74 { return myIsSelected; };
76 bool haveSelectedPoint()
77 { return (myHltPnt > -1); };
79 int getSelectedPoint()
82 void removePoint(int thePnt);
84 void setVisible(bool theVisible);
86 static void setOrthoMode(bool theIsOrtho)
87 { OrthoMode = theIsOrtho; };
89 static bool isOrthoMode()
90 { return OrthoMode; };
92 static SUPERVGUI_Link* getSelectedLink()
93 { return SelectedLink; };
96 void linkDeleted(SUPERVGUI_Link*);
99 void onMouseMove(QMouseEvent* theEvent);
100 void onMousePress(QMouseEvent* theEvent);
101 void onMouseRelease(QMouseEvent* theEvent);
105 void connectToEvents();
106 bool isSelected(QPoint thePnt);
109 SUPERVGUI_Graph* myGraph;
110 SUPERVGUI_Port* myBeginPort;
111 SUPERVGUI_PortIn* myPortIn;
112 SUPERVGUI_PortInESNode* myPortInES;
113 SUPERVGUI_PortOut* myPortOut;
115 SUPERV_Link myEngine;
117 QPoint myPrevPoint; // used for sketching only
118 QValueVector<QPoint> myTmpPoints;
119 SUPERVGUI_Port* myStartPort;
123 // Points highlighting management
124 int myHltPnt; // number of point or -1
126 // Points moving management
128 bool myPntMovingState;
129 QPoint myBeforePnt, myMovedPnt, myAfterPnt;
137 static bool OrthoMode;
138 static bool LinkIsMoving;
139 static SUPERVGUI_Link* SelectedLink;