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>
14 class QContextMenuEvent;
15 class ModuleBase_IViewWindow;
19 * A Base object for definition of connector object to
20 * Salome Viewer. Reimplemented in NewGeom_SalomeViewer class
22 class MODULEBASE_EXPORT ModuleBase_IViewer : public QObject
27 /// \param theParent a parent object
28 ModuleBase_IViewer(QObject* theParent);
30 //! Returns AIS_InteractiveContext from current OCCViewer
31 virtual Handle(AIS_InteractiveContext) AISContext() const = 0;
33 //! Retrurns V3d_Vioewer from current viewer
34 virtual Handle(V3d_Viewer) v3dViewer() const = 0;
36 //! Returns Vsd_View object from currently active view window
37 virtual Handle(V3d_View) activeView() const = 0;
39 virtual QWidget* activeViewPort() const = 0;
41 //! Enable or disable selection in the viewer
42 //! \param isEnabled is enable or disable flag
43 virtual void enableSelection(bool isEnabled) = 0;
45 //! Returns true if selection is enabled
46 virtual bool isSelectionEnabled() const = 0;
48 //! Enable or disable multiselection in the viewer
49 //! \param isEnable is enable or disable flag
50 virtual void enableMultiselection(bool isEnable) = 0;
52 //! Returns true if multiselection is enabled
53 virtual bool isMultiSelectionEnabled() const = 0;
55 //! Enable or disable draw mode in the viewer
56 virtual bool enableDrawMode(bool isEnabled) = 0;
58 //! Perfroms the fit all for the active view
59 virtual void fitAll() = 0;
61 //! Sets the view projection
62 /// \param theX the X projection value
63 /// \param theY the Y projection value
64 /// \param theZ the Z projection value
65 /// \param theTwist the twist angle in radians
66 virtual void setViewProjection( double theX, double theY, double theZ,
67 double theTwist ) = 0;
69 /// Add selection filter to the viewer
70 /// \param theFilter a selection filter
71 virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
73 /// Remove selection filter from the viewer
74 /// \param theFilter a selection filter
75 virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
77 /// Returns true if the selection filter is set to the viewer
78 /// \param theFilter a selection filter
79 virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
81 /// Remove all selection filters from the viewer
82 virtual void clearSelectionFilters() = 0;
84 /// Update current viewer
85 virtual void update() = 0;
87 /// Returns a scale factor of the given view
88 /// \param theView a view object
89 const double Scale(const Handle(V3d_View)& theView)
91 if (!myWindowScale.contains(theView))
92 myWindowScale.insert(theView, theView->Camera()->Scale());
93 return myWindowScale[theView];
96 /// Remember a scale factor for the view object
97 /// \param theView a view object
98 /// \param theVal a scale factor
99 void SetScale(const Handle(V3d_View)& theView, const double theVal) { myWindowScale[theView] = theVal; }
101 /// Method returns True if the viewer can process editing objects
102 /// by mouse drugging. If this is impossible thet it has to return False.
103 virtual bool canDragByMouse() const { return true; }
105 /// Fit all along Z (perpendicular to display)
106 virtual void Zfitall() = 0;
109 /// Signal emited when last view window is closed
110 void lastViewClosed();
112 /// Signal emited before view window is closed
113 void tryCloseView(ModuleBase_IViewWindow* theWnd);
115 /// Signal emited on delete view window
116 void deleteView(ModuleBase_IViewWindow* theWnd);
118 /// Signal emited on creation of view window
119 void viewCreated(ModuleBase_IViewWindow* theWnd);
121 /// Signal emited on key release
122 void activated(ModuleBase_IViewWindow* theWnd);
124 /// Signal emited on mouse press
125 void mousePress(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
127 /// Signal emited on mouse release
128 void mouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
130 /// Signal emited on mouse double click
131 void mouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
133 /// Signal emited on mouse move
134 void mouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
136 /// Signal emited on key press
137 void keyPress(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
139 /// Signal emited on key release
140 void keyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
142 /// Signal emited on selection changed
143 void selectionChanged();
145 /// Signal emited on selection changed
146 void contextMenuRequested(QContextMenuEvent*);
148 /// Signal emitted on transformation of view point in view window
149 /// \param theTransformation type of transformation (see AppElements_ViewWindow::OperationType)
150 void viewTransformed(int theTransformation);
153 /// A map for storing a scale factors dependent on view object
154 QMap<Handle(V3d_View), double> myWindowScale;