Salome HOME
NRI : Merge from V1_2.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Graph.h
1 //  SUPERV SUPERVGUI : GUI for Supervisor component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SUPERVGUI_Graph.h
25 //  Author : Francis KLOSS
26 //  Module : SUPERV
27
28 #ifndef SUPERVGUI_Graph_H
29 #define SUPERVGUI_Graph_H
30
31 using namespace std;
32 //#include "SUPERVGUI.h"
33 #include "SUPERVGUI_View.h"
34 #include "SUPERVGUI_Node.h"
35 #include "SUPERVGUI_Link.h"
36
37 class SUPERVGUI_Main;
38
39 class SUPERVGUI_Graph: public SUPERVGUI_View {
40   Q_OBJECT
41
42   public:
43     SUPERVGUI_Graph(SUPERVGUI_Main* m);
44     virtual ~SUPERVGUI_Graph();
45
46     void sync();
47     void contentsMousePressEvent(QMouseEvent* e);
48     void contentsMouseReleaseEvent(QMouseEvent* e);
49     void contentsMouseMoveEvent(QMouseEvent* e);
50
51  
52     virtual void setAsFromStudy(bool theToStudy);
53     
54     bool isLinkPrsExists(SUPERV_Link theLink);
55     bool createLinkPrs(SUPERV_Link theLink);
56     void removeLinks() 
57       { myLinksList.clear(); };
58
59     void setFullView();
60     void setControlView();
61     void deleteLink(SUPERVGUI_Link* theLink);
62
63     void deleteNode(SUPERVGUI_Node* theNode);
64     
65     void draw();
66     void clearView();
67
68     bool isAnyLinkCreating() { return (myNewLink != 0);};
69
70 signals:
71   void mouseMoved(QMouseEvent* theEvent);
72   void mousePressed(QMouseEvent* theEvent);
73   void mouseReleased(QMouseEvent* theEvent);
74
75 public slots:
76   void sketchBegin(SUPERVGUI_Port* thePort);
77   void sketchEnd(SUPERVGUI_Port* thePort);
78   
79  
80 private slots:
81   void addPoint();
82   void deleteLink();
83   void deletePoint();
84   void delLastPnt();
85   void delCreatingLink();
86   void setOrtho();
87
88   protected:
89     bool eventFilter(QObject* object, QEvent* event);
90
91   private:
92
93     QPoint myMousePos;
94     SUPERVGUI_Link* mySelectedLink;
95     int mySelectedPoint;
96
97     // Popup menu for link creation management
98     QPopupMenu* mySketchPopup;
99     int myDelPntItem;
100     int myOrtoItem;
101
102      // Popup menu for link
103     QPopupMenu* myLinkPopup;
104     int myDelLinkPntItem;
105     int myAddLinkPntItem;
106     int myDelLinkItem;
107    
108
109     SUPERVGUI_Link* myNewLink;
110     QPtrList<SUPERVGUI_Link> myLinksList;
111 };
112
113 #endif