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
12 #include "SUPERVGUI_Def.h"
13 #include "SUPERVGUI_Port.h"
14 #include <qvaluevector.h>
16 class SUPERVGUI_Graph;
18 int distance(int x1, int y1, int x2, int y2);
19 int distance(QPoint thePnt, QPoint thePntLn1, QPoint thePntLn2);
22 class SUPERVGUI_Link: public QObject {
26 SUPERVGUI_Link(SUPERVGUI_Graph* theGraph, SUPERV_Link theLink=0);
28 virtual ~SUPERVGUI_Link();
30 void setBeginPort(SUPERVGUI_Port* theBeginPort);
31 SUPERVGUI_Port* getBeginPort();
33 void setInputPort(SUPERVGUI_PortIn* thePortIn);
34 SUPERVGUI_PortIn* getInputPort()
37 void setInputPortES(SUPERVGUI_PortInESNode* thePortInES);
38 SUPERVGUI_PortInESNode* getInputPortES()
39 { return myPortInES; };
45 void setOutputPort(SUPERVGUI_PortOut* thePortOut);
46 SUPERVGUI_PortOut* getOutputPort()
47 { return myPortOut; };
49 void addPoint(long theX, long theY);
50 void removeLastPoint();
53 void paint(bool toErase);
54 void paint(QPainter* thePainter, bool toErase);
55 void drawLink(QPainter* thePainter);
57 bool isInRect(int theX, int theY, int theW, int theH);
59 SUPERV_Link getEngineLink()
62 void drawTo(QPoint thePnt);
66 void addTmpPoint(QPoint thePnt);
67 void delLastTmpPoint();
69 bool isCreationComplete();
73 { return myIsSelected; };
75 bool haveSelectedPoint()
76 { return (myHltPnt > -1); };
78 int getSelectedPoint()
81 void removePoint(int thePnt);
83 static void setOrthoMode(bool theIsOrtho)
84 { OrthoMode = theIsOrtho; };
86 static bool isOrthoMode()
87 { return OrthoMode; };
89 static SUPERVGUI_Link* getSelectedLink()
90 { return SelectedLink; };
93 void linkDeleted(SUPERVGUI_Link*);
96 void onMouseMove(QMouseEvent* theEvent);
97 void onMousePress(QMouseEvent* theEvent);
98 void onMouseRelease(QMouseEvent* theEvent);
102 void connectToEvents();
103 bool isSelected(QPoint thePnt);
106 SUPERVGUI_Graph* myGraph;
107 SUPERVGUI_Port* myBeginPort;
108 SUPERVGUI_PortIn* myPortIn;
109 SUPERVGUI_PortInESNode* myPortInES;
110 SUPERVGUI_PortOut* myPortOut;
112 SUPERV_Link myEngine;
114 QPoint myPrevPoint; // used for sketching only
115 QValueVector<QPoint> myTmpPoints;
116 SUPERVGUI_Port* myStartPort;
120 // Points highlighting management
121 int myHltPnt; // number of point or -1
123 // Points moving management
125 bool myPntMovingState;
126 QPoint myBeforePnt, myMovedPnt, myAfterPnt;
132 static bool OrthoMode;
133 static bool LinkIsMoving;
134 static SUPERVGUI_Link* SelectedLink;