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 /// Return objects selected in 3D viewer
69 /// \param theList - list to be filled with selected objects
70 void getSelectedObjects(AIS_ListOfInteractive& theList);
72 /// Selects objects in 3D viewer. Other selected objects are left as selected
73 /// \param theList - list objects to be selected
74 void setObjectsSelected(const AIS_ListOfInteractive& theList);
76 /// Select the object in 3D viewer.
77 /// \param theIO - list objects to be selected
78 void setSelected(const Handle(AIS_InteractiveObject)& theIO) { myAISContext->SetSelected(theIO); }
80 //! Trihedron 3d object shown in the viewer
81 Handle(AIS_Trihedron) trihedron() const
86 //! On/Off visibility of the trihedron object
87 void toggleTrihedron();
89 //! Returns true if trihedron is visible
90 bool isTrihedronVisible() const;
92 //! Returns true if trihedron is visible
93 void setTrihedronShown(bool on);
95 //! Returns trihedron size
96 double trihedronSize() const;
98 //! Sets trihedron size
99 void setTrihedronSize(const double sz, bool isRelative);
101 bool trihedronRelative() const
106 void updateTrihedron();
108 //! Compute trihedron size dependent on 3d scene size
109 bool computeTrihedronSize(double& theNewSize, double& theSize);
111 static void setHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
112 Qt::KeyboardModifiers theState, Qt::MouseButtons theButton);
113 static void getHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
114 Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton);
116 typedef QMap<XGUI::HotOperation, Qt::KeyboardModifiers> StatesMap;
117 typedef QMap<XGUI::HotOperation, Qt::MouseButtons> ButtonsMap;
119 typedef QMap<XGUI::InteractionStyle, StatesMap> InteractionStyle2StatesMap;
120 typedef QMap<XGUI::InteractionStyle, ButtonsMap> InteractionStyle2ButtonsMap;
122 static InteractionStyle2StatesMap myStateMap;
123 static InteractionStyle2ButtonsMap myButtonMap;
126 void lastViewClosed();
127 void tryCloseView(XGUI_ViewWindow* theWindow);
128 void deleteView(XGUI_ViewWindow* theWindow);
129 void viewCreated(XGUI_ViewWindow* theWindow);
130 void mousePress(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
131 void mouseRelease(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
132 void mouseDoubleClick(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
133 void mouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
134 void keyPress(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
135 void keyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
136 void activated(XGUI_ViewWindow* theWindow);
137 void selectionChanged();
140 void onWindowMinimized(QMdiSubWindow*);
141 void onWindowActivated(QMdiSubWindow*);
144 void onViewClosed(QMdiSubWindow*);
145 void onMouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
146 void onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
149 void addView(QMdiSubWindow* theView);
151 /*! Removes the View from internal Views list.*/
152 void removeView(QMdiSubWindow* theView);
155 XGUI_MainWindow* myMainWindow;
157 Handle(V3d_Viewer) myV3dViewer;Handle(AIS_Trihedron) myTrihedron;Handle(AIS_InteractiveContext) myAISContext;
159 XGUI::InteractionStyle myInteractionStyle;
161 bool myPreselectionEnabled;
162 bool mySelectionEnabled;
163 bool myMultiSelectionEnabled;
166 double myTrihedronSize;
168 QList<QMdiSubWindow*> myViews;
170 QMdiSubWindow* myActiveView;