Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[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: public QObject
21 {
22 Q_OBJECT
23 public:
24   static QString backgroundData(QStringList&, QIntList&, QIntList&);
25
26   XGUI_Viewer(XGUI_MainWindow* theParent, bool DisplayTrihedron = true);
27   ~XGUI_Viewer();
28
29   QMdiSubWindow* createView(V3d_TypeOfView theType = V3d_ORTHOGRAPHIC);
30
31   XGUI_MainWindow* mainWindow() const
32   {
33     return myMainWindow;
34   }
35
36   Handle(V3d_Viewer) v3dViewer() const
37   {
38     return myV3dViewer;
39   }
40
41   Handle(AIS_InteractiveContext) AISContext() const
42   {
43     return myAISContext;
44   }
45
46   Handle(AIS_Trihedron) trihedron() const
47   {
48     return myTrihedron;
49   }
50
51   void toggleTrihedron();
52   bool isTrihedronVisible() const;
53   void setTrihedronShown(const bool on);
54   double trihedronSize() const;
55   void setTrihedronSize(const double sz, bool isRelative);
56   bool trihedronRelative() const
57   {
58     return myIsRelative;
59   }
60   void updateTrihedron();
61   bool computeTrihedronSize(double& theNewSize, double& theSize);
62
63   static void setHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
64                            Qt::KeyboardModifiers theState, Qt::MouseButtons theButton);
65   static void getHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
66                            Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton);
67
68   typedef QMap<XGUI::HotOperation, Qt::KeyboardModifiers> StatesMap;
69   typedef QMap<XGUI::HotOperation, Qt::MouseButtons> ButtonsMap;
70
71   typedef QMap<XGUI::InteractionStyle, StatesMap> InteractionStyle2StatesMap;
72   typedef QMap<XGUI::InteractionStyle, ButtonsMap> InteractionStyle2ButtonsMap;
73
74   static InteractionStyle2StatesMap myStateMap;
75   static InteractionStyle2ButtonsMap myButtonMap;
76
77 signals:
78     void lastViewClosed();
79     void tryCloseView(XGUI_ViewWindow* theWindow);
80     void deleteView(XGUI_ViewWindow* theWindow);
81     void viewCreated(XGUI_ViewWindow* theWindow);
82     void mousePress(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
83     void mouseRelease(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
84     void mouseDoubleClick(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
85     void mouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
86     void keyPress(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
87     void keyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
88     void activated(XGUI_ViewWindow* theWindow);
89
90 private slots:
91     void onViewClosed(QMdiSubWindow*);
92     //void onViewMapped();
93     void onWindowActivated(QMdiSubWindow*);
94
95 private:
96     void addView(QMdiSubWindow* theView);
97
98     /*! Removes the View from internal Views list.*/
99     void removeView(QMdiSubWindow* theView);
100
101 private:
102   XGUI_MainWindow* myMainWindow;
103
104   Handle(V3d_Viewer) myV3dViewer;Handle(AIS_Trihedron) myTrihedron;Handle(AIS_InteractiveContext) myAISContext;
105
106   XGUI::InteractionStyle myInteractionStyle;
107
108   bool myPreselectionEnabled;
109   bool mySelectionEnabled;
110   bool myMultiSelectionEnabled;
111   bool myIsRelative;
112
113   double myTrihedronSize;
114   
115     QList<QMdiSubWindow*> myViews;
116
117     QMdiSubWindow* myActiveView;
118 };
119
120 #endif