5 #include "XGUI_Constants.h"
11 #include <V3d_Viewer.hxx>
12 #include <AIS_InteractiveContext.hxx>
13 #include <AIS_Trihedron.hxx>
14 #include <NCollection_List.hxx>
15 #include <TopoDS_Shape.hxx>
17 class XGUI_MainWindow;
19 class XGUI_ViewWindow;
23 class AIS_ListOfInteractive;
27 * \brief Represents a 3d viewer. The viewer manages 3d scene and a set of view windows
28 * when each of view window is a one point of view on this scene.
30 class XGUI_EXPORT XGUI_Viewer: public QObject
34 static QString backgroundData(QStringList&, QIntList&, QIntList&);
36 XGUI_Viewer(XGUI_MainWindow* theParent, bool DisplayTrihedron = true);
39 //! Creates a new view window
40 QMdiSubWindow* createView(V3d_TypeOfView theType = V3d_ORTHOGRAPHIC);
42 //! Return pointer on a main window - parent of the Viewer
43 XGUI_MainWindow* mainWindow() const
48 //! Returns OCCT object which manages 3d scene
49 Handle(V3d_Viewer) v3dViewer() const
54 //! Returns OCCT object which manages displaying and selection in 3d scene
55 Handle(AIS_InteractiveContext) AISContext() const
60 //! Activate local selection
61 //! \param theAIS the list of objects
62 //! \param theMode the selection mode
63 //! \param isUpdateViewer the state wether the viewer should be updated immediatelly
64 void setLocalSelection(const AIS_ListOfInteractive& theAISObjects, const int theMode,
65 const bool isUpdateViewer);
66 //! Deactivate local selection
67 //! \param isUpdateViewer the state wether the viewer should be updated immediatelly
68 void setGlobalSelection(const bool isUpdateViewer);
70 /// Return objects selected in 3D viewer
71 /// \param theList - list to be filled with selected objects
72 void getSelectedObjects(AIS_ListOfInteractive& theList);
74 /// Return shapes selected in 3D viewer
75 /// \param theList - list to be filled with selected shapes
76 void getSelectedShapes(NCollection_List<TopoDS_Shape>& theList);
78 /// Selects objects in 3D viewer. Other selected objects are left as selected
79 /// \param theList - list objects to be selected
80 void setObjectsSelected(const AIS_ListOfInteractive& theList);
82 /// Select the object in 3D viewer.
83 /// \param theIO - list objects to be selected
84 void setSelected(const Handle(AIS_InteractiveObject)& theIO) { myAISContext->SetSelected(theIO); }
86 //! Trihedron 3d object shown in the viewer
87 Handle(AIS_Trihedron) trihedron() const
92 //! On/Off visibility of the trihedron object
93 void toggleTrihedron();
95 //! Returns true if trihedron is visible
96 bool isTrihedronVisible() const;
98 //! Returns true if trihedron is visible
99 void setTrihedronShown(bool on);
101 //! Returns trihedron size
102 double trihedronSize() const;
104 //! Sets trihedron size
105 void setTrihedronSize(const double sz, bool isRelative);
107 bool trihedronRelative() const
112 void updateTrihedron();
114 //! Compute trihedron size dependent on 3d scene size
115 bool computeTrihedronSize(double& theNewSize, double& theSize);
117 static void setHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
118 Qt::KeyboardModifiers theState, Qt::MouseButtons theButton);
119 static void getHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
120 Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton);
122 //! Sets the view projection
123 /// \param theX the X projection value
124 /// \param theY the Y projection value
125 /// \param theZ the Z projection value
126 void setViewProjection(double theX, double theY, double theZ);
128 typedef QMap<XGUI::HotOperation, Qt::KeyboardModifiers> StatesMap;
129 typedef QMap<XGUI::HotOperation, Qt::MouseButtons> ButtonsMap;
131 typedef QMap<XGUI::InteractionStyle, StatesMap> InteractionStyle2StatesMap;
132 typedef QMap<XGUI::InteractionStyle, ButtonsMap> InteractionStyle2ButtonsMap;
134 static InteractionStyle2StatesMap myStateMap;
135 static InteractionStyle2ButtonsMap myButtonMap;
138 void lastViewClosed();
139 void tryCloseView(XGUI_ViewWindow* theWindow);
140 void deleteView(XGUI_ViewWindow* theWindow);
141 void viewCreated(XGUI_ViewWindow* theWindow);
142 void mousePress(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
143 void mouseRelease(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
144 void mouseDoubleClick(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
145 void mouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
146 void keyPress(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
147 void keyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
148 void activated(XGUI_ViewWindow* theWindow);
149 void selectionChanged();
152 void onWindowMinimized(QMdiSubWindow*);
153 void onWindowActivated(QMdiSubWindow*);
156 void onViewClosed(QMdiSubWindow*);
157 void onMouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
158 void onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
161 void addView(QMdiSubWindow* theView);
163 /*! Removes the View from internal Views list.*/
164 void removeView(QMdiSubWindow* theView);
167 XGUI_MainWindow* myMainWindow;
169 Handle(V3d_Viewer) myV3dViewer;Handle(AIS_Trihedron) myTrihedron;Handle(AIS_InteractiveContext) myAISContext;
171 XGUI::InteractionStyle myInteractionStyle;
173 bool myPreselectionEnabled;
174 bool mySelectionEnabled;
175 bool myMultiSelectionEnabled;
178 double myTrihedronSize;
180 QList<QMdiSubWindow*> myViews;
182 QMdiSubWindow* myActiveView;