Salome HOME
sources 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 #include "SUPERVGUI_CtrlLink.h"
37 #include <qmap.h>
38
39
40 class SUPERVGUI_Main;
41
42 class SUPERVGUI_Graph: public SUPERVGUI_View {
43   Q_OBJECT
44
45   public:
46     SUPERVGUI_Graph(SUPERVGUI_Main* m);
47     virtual ~SUPERVGUI_Graph();
48
49     void sync();
50     void contentsMousePressEvent(QMouseEvent* e);
51     void contentsMouseReleaseEvent(QMouseEvent* e);
52     void contentsMouseMoveEvent(QMouseEvent* e);
53
54  
55     virtual void setAsFromStudy(bool theToStudy);
56     
57     bool isLinkPrsExists(SUPERV_Link theLink);
58     bool createLinkPrs(SUPERV_Link theLink);
59     void removeLinks() 
60       { myLinksList.clear(); };
61
62     void setFullView();
63     void setControlView();
64     bool isControlView() { return myIsControlView; }
65
66     void deleteLink(SUPERVGUI_Link* theLink);
67
68     void deleteNode(SUPERVGUI_Node* theNode);
69     
70     void draw();
71     void clearView();
72
73     bool isAnyLinkCreating() { return (myNewLink != 0);};
74
75 signals:
76   void mouseMoved(QMouseEvent* theEvent);
77   void mousePressed(QMouseEvent* theEvent);
78   void mouseReleased(QMouseEvent* theEvent);
79
80 public slots:
81   void sketchBegin(SUPERVGUI_Port* thePort);
82   void sketchEnd(SUPERVGUI_Port* thePort);
83   
84  
85 private slots:
86   void addPoint();
87   void deleteLink();
88   void deletePoint();
89   void delLastPnt();
90   void delCreatingLink();
91   void setOrtho();
92
93   protected:
94     bool eventFilter(QObject* object, QEvent* event);
95
96   private:
97
98     QPoint myMousePos;
99     SUPERVGUI_Link* mySelectedLink;
100     int mySelectedPoint;
101
102     // Popup menu for link creation management
103     QPopupMenu* mySketchPopup;
104     int myDelPntItem;
105     int myOrtoItem;
106
107      // Popup menu for link
108     QPopupMenu* myLinkPopup;
109     int myDelLinkPntItem;
110     int myAddLinkPntItem;
111     int myDelLinkItem;
112    
113     bool myIsControlView;
114     SUPERVGUI_Link* myNewLink;
115     QPtrList<SUPERVGUI_Link> myLinksList;
116     QMap<QString, SUPERVGUI_CtrlLink> myCtrlLinks;
117 };
118
119 #endif