1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 #ifndef ModuleBase_IViewer_H
4 #define ModuleBase_IViewer_H
6 #include "ModuleBase.h"
9 #include <AIS_InteractiveContext.hxx>
10 #include <V3d_View.hxx>
11 #include <AIS_Trihedron.hxx>
15 class QContextMenuEvent;
16 class ModuleBase_IViewWindow;
20 * A Base object for definition of connector object to
21 * Salome Viewer. Reimplemented in SHAPERGUI_SalomeViewer class
23 class MODULEBASE_EXPORT ModuleBase_IViewer : public QObject
28 /// \param theParent a parent object
29 ModuleBase_IViewer(QObject* theParent);
31 //! Returns AIS_InteractiveContext from current OCCViewer
32 virtual Handle(AIS_InteractiveContext) AISContext() const = 0;
34 //! Trihedron 3d object shown in the viewer
35 virtual Handle(AIS_Trihedron) trihedron() const = 0;
37 //! Retrurns V3d_Vioewer from current viewer
38 virtual Handle(V3d_Viewer) v3dViewer() const = 0;
40 //! Returns Vsd_View object from currently active view window
41 virtual Handle(V3d_View) activeView() const = 0;
43 //! Returns currently active view port widget
44 virtual QWidget* activeViewPort() const = 0;
46 //! Enable or disable selection in the viewer
47 //! \param isEnabled is enable or disable flag
48 virtual void enableSelection(bool isEnabled) = 0;
50 //! Returns true if selection is enabled
51 virtual bool isSelectionEnabled() const = 0;
53 //! Enable or disable multiselection in the viewer
54 //! \param isEnable is enable or disable flag
55 virtual void enableMultiselection(bool isEnable) = 0;
57 //! Returns true if multiselection is enabled
58 virtual bool isMultiSelectionEnabled() const = 0;
60 //! Enable or disable draw mode in the viewer
61 virtual bool enableDrawMode(bool isEnabled) = 0;
63 //! Perfroms the fit all for the active view
64 virtual void fitAll() = 0;
66 //! Sets the view projection
67 /// \param theX the X projection value
68 /// \param theY the Y projection value
69 /// \param theZ the Z projection value
70 /// \param theTwist the twist angle in radians
71 virtual void setViewProjection( double theX, double theY, double theZ,
72 double theTwist ) = 0;
74 /// Add selection filter to the viewer
75 /// \param theFilter a selection filter
76 virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
78 /// Remove selection filter from the viewer
79 /// \param theFilter a selection filter
80 virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
82 /// Returns true if the selection filter is set to the viewer
83 /// \param theFilter a selection filter
84 virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
86 /// Remove all selection filters from the viewer
87 virtual void clearSelectionFilters() = 0;
89 /// Update current viewer
90 virtual void update() = 0;
92 /// Returns a scale factor of the given view
93 /// \param theView a view object
94 const double Scale(const Handle(V3d_View)& theView)
96 if (!myWindowScale.contains(theView))
97 myWindowScale.insert(theView, theView->Camera()->Scale());
98 return myWindowScale[theView];
101 /// Remember a scale factor for the view object
102 /// \param theView a view object
103 /// \param theVal a scale factor
104 void SetScale(const Handle(V3d_View)& theView, const double theVal) { myWindowScale[theView] = theVal; }
106 /// Method returns True if the viewer can process editing objects
107 /// by mouse drugging. If this is impossible thet it has to return False.
108 virtual bool canDragByMouse() const { return true; }
110 /// Fit all along Z (perpendicular to display)
111 virtual void Zfitall() = 0;
114 /// Signal emited when last view window is closed
115 void lastViewClosed();
117 /// Signal emited before view window is closed
118 void tryCloseView(ModuleBase_IViewWindow* theWnd);
120 /// Signal emited on delete view window
121 void deleteView(ModuleBase_IViewWindow* theWnd);
123 /// Signal emited on creation of view window
124 void viewCreated(ModuleBase_IViewWindow* theWnd);
126 /// Signal emited on key release
127 void activated(ModuleBase_IViewWindow* theWnd);
129 /// Signal emited on mouse press
130 void mousePress(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
132 /// Signal emited on mouse release
133 void mouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
135 /// Signal emited on mouse double click
136 void mouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
138 /// Signal emited on mouse move
139 void mouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
141 /// Signal emited on key press
142 void keyPress(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
144 /// Signal emited on key release
145 void keyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
147 /// Signal emited on selection changed
148 void selectionChanged();
150 /// Signal emited on selection changed
151 void contextMenuRequested(QContextMenuEvent*);
153 /// Signal emitted on transformation of view point in view window
154 /// \param theTransformation type of transformation (see AppElements_ViewWindow::OperationType)
155 void viewTransformed(int theTransformation);
157 /// Signal emited on selection changed
158 void trihedronVisibilityChanged(bool theState);
161 /// A map for storing a scale factors dependent on view object
162 QMap<Handle(V3d_View), double> myWindowScale;