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
11 #include "SUPERVGUI_Def.h"
12 #include "SUPERVGUI_Port.h"
13 #include <qvaluevector.h>
15 class SUPERVGUI_Graph;
17 int distance(int x1, int y1, int x2, int y2);
18 int distance(QPoint thePnt, QPoint thePntLn1, QPoint thePntLn2);
21 class SUPERVGUI_Link: public QObject {
25 SUPERVGUI_Link(SUPERVGUI_Graph* theGraph, SUPERV_Link theLink=0);
27 virtual ~SUPERVGUI_Link();
29 void setBeginPort(SUPERVGUI_Port* theBeginPort);
30 SUPERVGUI_Port* getBeginPort();
32 void setInputPort(SUPERVGUI_PortIn* thePortIn);
33 SUPERVGUI_PortIn* getInputPort()
36 void setInputPortES(SUPERVGUI_PortInESNode* thePortInES);
37 SUPERVGUI_PortInESNode* getInputPortES()
38 { return myPortInES; };
44 void setOutputPort(SUPERVGUI_PortOut* thePortOut);
45 SUPERVGUI_PortOut* getOutputPort()
46 { return myPortOut; };
48 void addPoint(long theX, long theY);
49 void removeLastPoint();
52 void paint(bool toErase);
53 void paint(QPainter* thePainter, bool toErase);
54 void drawLink(QPainter* thePainter);
56 bool isInRect(int theX, int theY, int theW, int theH);
58 SUPERV_Link getEngineLink()
61 void drawTo(QPoint thePnt);
65 void addTmpPoint(QPoint thePnt);
66 void delLastTmpPoint();
68 bool isCreationComplete();
72 { return myIsSelected; };
74 bool haveSelectedPoint()
75 { return (myHltPnt > -1); };
77 int getSelectedPoint()
80 void removePoint(int thePnt);
82 static void setOrthoMode(bool theIsOrtho)
83 { OrthoMode = theIsOrtho; };
85 static bool isOrthoMode()
86 { return OrthoMode; };
88 static SUPERVGUI_Link* getSelectedLink()
89 { return SelectedLink; };
92 void linkDeleted(SUPERVGUI_Link*);
95 void onMouseMove(QMouseEvent* theEvent);
96 void onMousePress(QMouseEvent* theEvent);
97 void onMouseRelease(QMouseEvent* theEvent);
101 void connectToEvents();
102 bool isSelected(QPoint thePnt);
105 SUPERVGUI_Graph* myGraph;
106 SUPERVGUI_Port* myBeginPort;
107 SUPERVGUI_PortIn* myPortIn;
108 SUPERVGUI_PortInESNode* myPortInES;
109 SUPERVGUI_PortOut* myPortOut;
111 SUPERV_Link myEngine;
113 QPoint myPrevPoint; // used for sketching only
114 QValueVector<QPoint> myTmpPoints;
115 SUPERVGUI_Port* myStartPort;
119 // Points highlighting management
120 int myHltPnt; // number of point or -1
122 // Points moving management
124 bool myPntMovingState;
125 QPoint myBeforePnt, myMovedPnt, myAfterPnt;
131 static bool OrthoMode;
132 static bool LinkIsMoving;
133 static SUPERVGUI_Link* SelectedLink;