5 #include "XGUI_Constants.h"
11 #include <V3d_Viewer.hxx>
12 #include <AIS_InteractiveContext.hxx>
13 #include <AIS_Trihedron.hxx>
15 class XGUI_MainWindow;
17 class XGUI_ViewWindow;
21 class AIS_ListOfInteractive;
25 * \brief Represents a 3d viewer. The viewer manages 3d scene and a set of view windows
26 * when each of view window is a one point of view on this scene.
28 class XGUI_EXPORT XGUI_Viewer: public QObject
32 static QString backgroundData(QStringList&, QIntList&, QIntList&);
34 XGUI_Viewer(XGUI_MainWindow* theParent, bool DisplayTrihedron = true);
37 //! Creates a new view window
38 QMdiSubWindow* createView(V3d_TypeOfView theType = V3d_ORTHOGRAPHIC);
40 //! Return pointer on a main window - parent of the Viewer
41 XGUI_MainWindow* mainWindow() const
46 //! Returns OCCT object which manages 3d scene
47 Handle(V3d_Viewer) v3dViewer() const
52 //! Returns OCCT object which manages displaying and selection in 3d scene
53 Handle(AIS_InteractiveContext) AISContext() const
58 //! Activate local selection
59 //! \param theAIS the list of objects
60 //! \param theMode the selection mode
61 //! \param isUpdateViewer the state wether the viewer should be updated immediatelly
62 void setLocalSelection(const AIS_ListOfInteractive& theAISObjects, const int theMode,
63 const bool isUpdateViewer);
64 //! Deactivate local selection
65 //! \param isUpdateViewer the state wether the viewer should be updated immediatelly
66 void setGlobalSelection(const bool isUpdateViewer);
68 //! Trihedron 3d object shown in the viewer
69 Handle(AIS_Trihedron) trihedron() const
74 //! On/Off visibility of the trihedron object
75 void toggleTrihedron();
77 //! Returns true if trihedron is visible
78 bool isTrihedronVisible() const;
80 //! Returns true if trihedron is visible
81 void setTrihedronShown(bool on);
83 //! Returns trihedron size
84 double trihedronSize() const;
86 //! Sets trihedron size
87 void setTrihedronSize(const double sz, bool isRelative);
89 bool trihedronRelative() const
94 void updateTrihedron();
96 //! Compute trihedron size dependent on 3d scene size
97 bool computeTrihedronSize(double& theNewSize, double& theSize);
99 static void setHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
100 Qt::KeyboardModifiers theState, Qt::MouseButtons theButton);
101 static void getHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
102 Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton);
104 typedef QMap<XGUI::HotOperation, Qt::KeyboardModifiers> StatesMap;
105 typedef QMap<XGUI::HotOperation, Qt::MouseButtons> ButtonsMap;
107 typedef QMap<XGUI::InteractionStyle, StatesMap> InteractionStyle2StatesMap;
108 typedef QMap<XGUI::InteractionStyle, ButtonsMap> InteractionStyle2ButtonsMap;
110 static InteractionStyle2StatesMap myStateMap;
111 static InteractionStyle2ButtonsMap myButtonMap;
114 void lastViewClosed();
115 void tryCloseView(XGUI_ViewWindow* theWindow);
116 void deleteView(XGUI_ViewWindow* theWindow);
117 void viewCreated(XGUI_ViewWindow* theWindow);
118 void mousePress(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
119 void mouseRelease(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
120 void mouseDoubleClick(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
121 void mouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
122 void keyPress(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
123 void keyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
124 void activated(XGUI_ViewWindow* theWindow);
125 void selectionChanged();
128 void onWindowMinimized(QMdiSubWindow*);
129 void onWindowActivated(QMdiSubWindow*);
132 void onViewClosed(QMdiSubWindow*);
133 void onMouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
134 void onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
137 void addView(QMdiSubWindow* theView);
139 /*! Removes the View from internal Views list.*/
140 void removeView(QMdiSubWindow* theView);
143 XGUI_MainWindow* myMainWindow;
145 Handle(V3d_Viewer) myV3dViewer;Handle(AIS_Trihedron) myTrihedron;Handle(AIS_InteractiveContext) myAISContext;
147 XGUI::InteractionStyle myInteractionStyle;
149 bool myPreselectionEnabled;
150 bool mySelectionEnabled;
151 bool myMultiSelectionEnabled;
154 double myTrihedronSize;
156 QList<QMdiSubWindow*> myViews;
158 QMdiSubWindow* myActiveView;