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 /// Update current viewer
87 virtual void update() = 0;
89 /// Returns a scale factor of the given view
90 /// \param theView a view object
91 const double Scale(const Handle(V3d_View)& theView)
93 if (!myWindowScale.contains(theView))
94 myWindowScale.insert(theView, theView->Camera()->Scale());
95 return myWindowScale[theView];
98 /// Remember a scale factor for the view object
99 /// \param theView a view object
100 /// \param theVal a scale factor
101 void SetScale(const Handle(V3d_View)& theView, const double theVal)
102 { myWindowScale[theView] = theVal; }
104 /// Method returns True if the viewer can process editing objects
105 /// by mouse drugging. If this is impossible thet it has to return False.
106 virtual bool canDragByMouse() const { return true; }
108 /// Fit all along Z (perpendicular to display)
109 //virtual void Zfitall() = 0;
112 /// Signal emited when last view window is closed
113 void lastViewClosed();
115 /// Signal emited before view window is closed
116 void tryCloseView(ModuleBase_IViewWindow* theWnd);
118 /// Signal emited on delete view window
119 void deleteView(ModuleBase_IViewWindow* theWnd);
121 /// Signal emited on creation of view window
122 void viewCreated(ModuleBase_IViewWindow* theWnd);
124 /// Signal emited on key release
125 void activated(ModuleBase_IViewWindow* theWnd);
127 /// Signal emited on mouse press
128 void mousePress(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
130 /// Signal emited on mouse release
131 void mouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
133 /// Signal emited on mouse double click
134 void mouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
136 /// Signal emited on mouse move
137 void mouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
139 /// Signal emited on key press
140 void keyPress(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
142 /// Signal emited on key release
143 void keyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
145 /// Signal emited on selection changed
146 void selectionChanged();
148 /// Signal emited on selection changed
149 void contextMenuRequested(QContextMenuEvent*);
151 /// Signal emitted on transformation of view point in view window
152 /// \param theTransformation type of transformation (see AppElements_ViewWindow::OperationType)
153 void viewTransformed(int theTransformation);
155 /// Signal emited on selection changed
156 void trihedronVisibilityChanged(bool theState);
159 /// A map for storing a scale factors dependent on view object
160 QMap<Handle(V3d_View), double> myWindowScale;