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 virtual QWidget* activeViewPort() const = 0;
45 //! Enable or disable selection in the viewer
46 //! \param isEnabled is enable or disable flag
47 virtual void enableSelection(bool isEnabled) = 0;
49 //! Returns true if selection is enabled
50 virtual bool isSelectionEnabled() const = 0;
52 //! Enable or disable multiselection in the viewer
53 //! \param isEnable is enable or disable flag
54 virtual void enableMultiselection(bool isEnable) = 0;
56 //! Returns true if multiselection is enabled
57 virtual bool isMultiSelectionEnabled() const = 0;
59 //! Enable or disable draw mode in the viewer
60 virtual bool enableDrawMode(bool isEnabled) = 0;
62 //! Perfroms the fit all for the active view
63 virtual void fitAll() = 0;
65 //! Sets the view projection
66 /// \param theX the X projection value
67 /// \param theY the Y projection value
68 /// \param theZ the Z projection value
69 /// \param theTwist the twist angle in radians
70 virtual void setViewProjection( double theX, double theY, double theZ,
71 double theTwist ) = 0;
73 /// Add selection filter to the viewer
74 /// \param theFilter a selection filter
75 virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
77 /// Remove selection filter from the viewer
78 /// \param theFilter a selection filter
79 virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
81 /// Returns true if the selection filter is set to the viewer
82 /// \param theFilter a selection filter
83 virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
85 /// Remove all selection filters from the viewer
86 virtual void clearSelectionFilters() = 0;
88 /// Update current viewer
89 virtual void update() = 0;
91 /// Returns a scale factor of the given view
92 /// \param theView a view object
93 const double Scale(const Handle(V3d_View)& theView)
95 if (!myWindowScale.contains(theView))
96 myWindowScale.insert(theView, theView->Camera()->Scale());
97 return myWindowScale[theView];
100 /// Remember a scale factor for the view object
101 /// \param theView a view object
102 /// \param theVal a scale factor
103 void SetScale(const Handle(V3d_View)& theView, const double theVal) { myWindowScale[theView] = theVal; }
105 /// Method returns True if the viewer can process editing objects
106 /// by mouse drugging. If this is impossible thet it has to return False.
107 virtual bool canDragByMouse() const { return true; }
109 /// Fit all along Z (perpendicular to display)
110 virtual void Zfitall() = 0;
113 /// Signal emited when last view window is closed
114 void lastViewClosed();
116 /// Signal emited before view window is closed
117 void tryCloseView(ModuleBase_IViewWindow* theWnd);
119 /// Signal emited on delete view window
120 void deleteView(ModuleBase_IViewWindow* theWnd);
122 /// Signal emited on creation of view window
123 void viewCreated(ModuleBase_IViewWindow* theWnd);
125 /// Signal emited on key release
126 void activated(ModuleBase_IViewWindow* theWnd);
128 /// Signal emited on mouse press
129 void mousePress(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
131 /// Signal emited on mouse release
132 void mouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
134 /// Signal emited on mouse double click
135 void mouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
137 /// Signal emited on mouse move
138 void mouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
140 /// Signal emited on key press
141 void keyPress(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
143 /// Signal emited on key release
144 void keyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
146 /// Signal emited on selection changed
147 void selectionChanged();
149 /// Signal emited on selection changed
150 void contextMenuRequested(QContextMenuEvent*);
152 /// Signal emitted on transformation of view point in view window
153 /// \param theTransformation type of transformation (see AppElements_ViewWindow::OperationType)
154 void viewTransformed(int theTransformation);
156 /// Signal emited on selection changed
157 void trihedronVisibilityChanged(bool theState);
160 /// A map for storing a scale factors dependent on view object
161 QMap<Handle(V3d_View), double> myWindowScale;