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 //! Enable or disable selection in the viewer
40 //! \param isEnabled is enable or disable flag
41 virtual void enableSelection(bool isEnabled) = 0;
43 //! Returns true if selection is enabled
44 virtual bool isSelectionEnabled() const = 0;
46 //! Enable or disable multiselection in the viewer
47 //! \param isEnable is enable or disable flag
48 virtual void enableMultiselection(bool isEnable) = 0;
50 //! Returns true if multiselection is enabled
51 virtual bool isMultiSelectionEnabled() const = 0;
53 //! Perfroms the fit all for the active view
54 virtual void fitAll() = 0;
56 //! Sets the view projection
57 /// \param theX the X projection value
58 /// \param theY the Y projection value
59 /// \param theZ the Z projection value
60 virtual void setViewProjection(double theX, double theY, double theZ) = 0;
62 /// Add selection filter to the viewer
63 /// \param theFilter a selection filter
64 virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
66 /// Remove selection filter from the viewer
67 /// \param theFilter a selection filter
68 virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
70 /// Returns true if the selection filter is set to the viewer
71 /// \param theFilter a selection filter
72 virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
74 /// Remove all selection filters from the viewer
75 virtual void clearSelectionFilters() = 0;
77 /// Update current viewer
78 virtual void update() = 0;
80 const double Scale(const Handle(V3d_View)& theView)
82 if (!myWindowScale.contains(theView))
83 myWindowScale.insert(theView, theView->Camera()->Scale());
84 return myWindowScale[theView];
87 void SetScale(const Handle(V3d_View)& theView, const double theVal) { myWindowScale[theView] = theVal; }
89 /// Method returns True if the viewer can process editing objects
90 /// by mouse drugging. If this is impossible thet it has to return False.
91 virtual bool canDragByMouse() const { return true; }
93 // Fit all along Z (perpendicular to display)
94 virtual void Zfitall() = 0;
97 /// Signal emited when last view window is closed
98 void lastViewClosed();
100 /// Signal emited before view window is closed
101 void tryCloseView(ModuleBase_IViewWindow* theWnd);
103 /// Signal emited on delete view window
104 void deleteView(ModuleBase_IViewWindow* theWnd);
106 /// Signal emited on creation of view window
107 void viewCreated(ModuleBase_IViewWindow* theWnd);
109 /// Signal emited on key release
110 void activated(ModuleBase_IViewWindow* theWnd);
112 /// Signal emited on mouse press
113 void mousePress(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
115 /// Signal emited on mouse release
116 void mouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
118 /// Signal emited on mouse double click
119 void mouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
121 /// Signal emited on mouse move
122 void mouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
124 /// Signal emited on key press
125 void keyPress(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
127 /// Signal emited on key release
128 void keyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
130 /// Signal emited on selection changed
131 void selectionChanged();
133 /// Signal emited on selection changed
134 void contextMenuRequested(QContextMenuEvent*);
136 /// Signal emitted on transformation of view point in view window
137 /// \param theTransformation type of transformation (see AppElements_ViewWindow::OperationType)
138 void viewTransformed(int theTransformation);
141 QMap<Handle(V3d_View), double> myWindowScale;