]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Viewer.h
Salome HOME
Update just modified part tree in object browser
[modules/shaper.git] / src / XGUI / XGUI_Viewer.h
1 #ifndef XGUI_Viewer_H
2 #define XGUI_Viewer_H
3
4 #include "XGUI_Constants.h"
5
6 #include <QObject>
7 #include <QMap>
8 #include <QList>
9
10 #include <V3d_Viewer.hxx>
11 #include <AIS_InteractiveContext.hxx>
12 #include <AIS_Trihedron.hxx>
13
14 class XGUI_MainWindow;
15 class QMdiSubWindow;
16 class XGUI_ViewWindow;
17 class QMouseEvent;
18 class QKeyEvent;
19
20 /**\class XGUI_Viewer
21  * \ingroup GUI
22  * \brief Represents a 3d viewer. The viewer manages 3d scene and a set of view windows
23  * when each of view window is a one point of view on this scene.
24  */
25 class XGUI_Viewer: public QObject
26 {
27 Q_OBJECT
28 public:
29   static QString backgroundData(QStringList&, QIntList&, QIntList&);
30
31   XGUI_Viewer(XGUI_MainWindow* theParent, bool DisplayTrihedron = true);
32   ~XGUI_Viewer();
33
34   //! Creates a new view window
35   QMdiSubWindow* createView(V3d_TypeOfView theType = V3d_ORTHOGRAPHIC);
36
37   //! Return pointer on a main window - parent of the Viewer
38   XGUI_MainWindow* mainWindow() const
39   {
40     return myMainWindow;
41   }
42
43   //! Returns OCCT object which manages 3d scene
44   Handle(V3d_Viewer) v3dViewer() const
45   {
46     return myV3dViewer;
47   }
48
49   //! Returns OCCT object which manages displaying and selection in 3d scene
50   Handle(AIS_InteractiveContext) AISContext() const
51   {
52     return myAISContext;
53   }
54
55   //! Trihedron 3d object shown in the viewer
56   Handle(AIS_Trihedron) trihedron() const
57   {
58     return myTrihedron;
59   }
60
61   //! On/Off visibility of the trihedron object
62   void toggleTrihedron();
63
64   //! Returns true if trihedron is visible
65   bool isTrihedronVisible() const;
66
67   //! Returns true if trihedron is visible
68   void setTrihedronShown(bool on);
69
70   //! Returns trihedron size
71   double trihedronSize() const;
72
73   //! Sets trihedron size
74   void setTrihedronSize(const double sz, bool isRelative);
75
76   bool trihedronRelative() const
77   {
78     return myIsRelative;
79   }
80   //! Update trihedron
81   void updateTrihedron();
82
83   //! Compute trihedron size dependent on 3d scene size
84   bool computeTrihedronSize(double& theNewSize, double& theSize);
85
86   static void setHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
87                            Qt::KeyboardModifiers theState, Qt::MouseButtons theButton);
88   static void getHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
89                            Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton);
90
91   typedef QMap<XGUI::HotOperation, Qt::KeyboardModifiers> StatesMap;
92   typedef QMap<XGUI::HotOperation, Qt::MouseButtons> ButtonsMap;
93
94   typedef QMap<XGUI::InteractionStyle, StatesMap> InteractionStyle2StatesMap;
95   typedef QMap<XGUI::InteractionStyle, ButtonsMap> InteractionStyle2ButtonsMap;
96
97   static InteractionStyle2StatesMap myStateMap;
98   static InteractionStyle2ButtonsMap myButtonMap;
99
100 signals:
101   void lastViewClosed();
102   void tryCloseView(XGUI_ViewWindow* theWindow);
103   void deleteView(XGUI_ViewWindow* theWindow);
104   void viewCreated(XGUI_ViewWindow* theWindow);
105   void mousePress(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
106   void mouseRelease(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
107   void mouseDoubleClick(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
108   void mouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
109   void keyPress(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
110   void keyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
111   void activated(XGUI_ViewWindow* theWindow);
112
113 private slots:
114   void onViewClosed(QMdiSubWindow*);
115   //void onViewMapped();
116   void onWindowActivated(QMdiSubWindow*);
117
118 private:
119   void addView(QMdiSubWindow* theView);
120
121   /*! Removes the View from internal Views list.*/
122   void removeView(QMdiSubWindow* theView);
123
124 private:
125   XGUI_MainWindow* myMainWindow;
126
127   Handle(V3d_Viewer) myV3dViewer;Handle(AIS_Trihedron) myTrihedron;Handle(AIS_InteractiveContext) myAISContext;
128
129   XGUI::InteractionStyle myInteractionStyle;
130
131   bool myPreselectionEnabled;
132   bool mySelectionEnabled;
133   bool myMultiSelectionEnabled;
134   bool myIsRelative;
135
136   double myTrihedronSize;
137   
138     QList<QMdiSubWindow*> myViews;
139
140     QMdiSubWindow* myActiveView;
141 };
142
143 #endif