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 /// Return objects selected in 3D viewer
61 /// \param theList - list to be filled with selected objects
62 void getSelectedObjects(AIS_ListOfInteractive& theList);
64 /// Return shapes selected in 3D viewer
65 /// \param theList - list to be filled with selected shapes
66 void getSelectedShapes(NCollection_List<TopoDS_Shape>& theList);
68 /// Selects objects in 3D viewer. Other selected objects are left as selected
69 /// \param theList - list objects to be selected
70 void setObjectsSelected(const AIS_ListOfInteractive& theList);
72 /// Select the object in 3D viewer.
73 /// \param theIO - list objects to be selected
74 void setSelected(const Handle(AIS_InteractiveObject)& theIO) { myAISContext->SetSelected(theIO); }
76 //! Trihedron 3d object shown in the viewer
77 Handle(AIS_Trihedron) trihedron() const
82 //! On/Off visibility of the trihedron object
83 void toggleTrihedron();
85 //! Returns true if trihedron is visible
86 bool isTrihedronVisible() const;
88 //! Returns true if trihedron is visible
89 void setTrihedronShown(bool on);
91 //! Returns trihedron size
92 double trihedronSize() const;
94 //! Sets trihedron size
95 void setTrihedronSize(const double sz, bool isRelative);
97 bool trihedronRelative() const
102 void updateTrihedron();
104 //! Compute trihedron size dependent on 3d scene size
105 bool computeTrihedronSize(double& theNewSize, double& theSize);
107 static void setHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
108 Qt::KeyboardModifiers theState, Qt::MouseButtons theButton);
109 static void getHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
110 Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton);
112 //! Sets the view projection
113 /// \param theX the X projection value
114 /// \param theY the Y projection value
115 /// \param theZ the Z projection value
116 void setViewProjection(double theX, double theY, double theZ);
118 typedef QMap<XGUI::HotOperation, Qt::KeyboardModifiers> StatesMap;
119 typedef QMap<XGUI::HotOperation, Qt::MouseButtons> ButtonsMap;
121 typedef QMap<XGUI::InteractionStyle, StatesMap> InteractionStyle2StatesMap;
122 typedef QMap<XGUI::InteractionStyle, ButtonsMap> InteractionStyle2ButtonsMap;
124 static InteractionStyle2StatesMap myStateMap;
125 static InteractionStyle2ButtonsMap myButtonMap;
128 void lastViewClosed();
129 void tryCloseView(XGUI_ViewWindow* theWindow);
130 void deleteView(XGUI_ViewWindow* theWindow);
131 void viewCreated(XGUI_ViewWindow* theWindow);
132 void mousePress(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
133 void mouseRelease(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
134 void mouseDoubleClick(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
135 void mouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
136 void keyPress(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
137 void keyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
138 void activated(XGUI_ViewWindow* theWindow);
139 void selectionChanged();
142 void onWindowMinimized(QMdiSubWindow*);
143 void onWindowActivated(QMdiSubWindow*);
146 void onViewClosed(QMdiSubWindow*);
147 void onMouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
148 void onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
151 void addView(QMdiSubWindow* theView);
153 /*! Removes the View from internal Views list.*/
154 void removeView(QMdiSubWindow* theView);
157 XGUI_MainWindow* myMainWindow;
159 Handle(V3d_Viewer) myV3dViewer;
160 Handle(AIS_Trihedron) myTrihedron;
161 Handle(AIS_InteractiveContext) myAISContext;
163 XGUI::InteractionStyle myInteractionStyle;
165 bool myPreselectionEnabled;
166 bool mySelectionEnabled;
167 bool myMultiSelectionEnabled;
170 double myTrihedronSize;
172 QList<QMdiSubWindow*> myViews;
174 QMdiSubWindow* myActiveView;