Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[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 "SUPERVGUI_Def.h"
38 #include "QAD_SpinBoxDbl.h"
39 #include <qmap.h>
40 #include <qcombobox.h>
41 #include <qspinbox.h>
42
43
44 class SUPERVGUI_Main;
45
46 class SUPERVGUI_Graph: public SUPERVGUI_View {
47   Q_OBJECT
48
49   public:
50     SUPERVGUI_Graph(SUPERVGUI_Main* m);
51     virtual ~SUPERVGUI_Graph();
52
53     void sync();
54     void contentsMousePressEvent(QMouseEvent* e);
55     void contentsMouseReleaseEvent(QMouseEvent* e);
56     void contentsMouseMoveEvent(QMouseEvent* e);
57
58  
59     virtual void setAsFromStudy(bool theToStudy);
60     
61     bool isLinkPrsExists(SUPERV_Link theLink);
62     bool createLinkPrs(SUPERV_Link theLink);
63     void removeLinks() 
64       { myLinksList.clear(); };
65
66     void setFullView();
67     void setControlView();
68     bool isControlView() { return myIsControlView; }
69
70     void deleteLink(SUPERVGUI_Link* theLink);
71
72     void deleteNode(SUPERVGUI_Node* theNode);
73     
74     void draw();
75     void clearView();
76
77     bool isAnyLinkCreating() { return (myNewLink != 0);};
78
79 signals:
80   void mouseMoved(QMouseEvent* theEvent);
81   void mousePressed(QMouseEvent* theEvent);
82   void mouseReleased(QMouseEvent* theEvent);
83
84 public slots:
85   void sketchBegin(SUPERVGUI_Port* thePort);
86   void sketchEnd(SUPERVGUI_Port* thePort);
87   
88  
89 private slots:
90   void addPoint();
91   void deleteLink();
92   void deletePoint();
93   void delLastPnt();
94   void delCreatingLink();
95   void setOrtho();
96
97   protected:
98     bool eventFilter(QObject* object, QEvent* event);
99
100   private:
101
102     QPoint myMousePos;
103     SUPERVGUI_Link* mySelectedLink;
104     int mySelectedPoint;
105
106     // Popup menu for link creation management
107     QPopupMenu* mySketchPopup;
108     int myDelPntItem;
109     int myOrtoItem;
110
111      // Popup menu for link
112     QPopupMenu* myLinkPopup;
113     int myDelLinkPntItem;
114     int myAddLinkPntItem;
115     int myDelLinkItem;
116    
117     bool myIsControlView;
118     SUPERVGUI_Link* myNewLink;
119     QPtrList<SUPERVGUI_Link> myLinksList;
120     QMap<QString, SUPERVGUI_CtrlLink> myCtrlLinks;
121 };
122
123 //**************************************************************
124 class SUPERVGUI_DSGraphParameters: public QDialog {
125   Q_OBJECT
126
127   public:
128     SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly);
129     virtual ~SUPERVGUI_DSGraphParameters();
130
131   private slots:
132     void accept();
133
134   private:
135     
136     void setData();
137     
138     QAD_SpinBoxDbl*      myDeltaTime;
139     QLineEdit*           myTimeOut;
140     QComboBox*           myDataStreamTrace;
141
142     SUPERV_Graph    myGraph;
143 };
144
145 #endif