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)
33 //! Returns AIS_InteractiveContext from current OCCViewer
34 virtual Handle(AIS_InteractiveContext) AISContext() const = 0;
36 //! Retrurns V3d_Vioewer from current viewer
37 virtual Handle(V3d_Viewer) v3dViewer() const = 0;
39 //! Returns Vsd_View object from currently active view window
40 virtual Handle(V3d_View) activeView() const = 0;
42 //! Enable or disable selection in the viewer
43 //! \param isEnabled is enable or disable flag
44 virtual void enableSelection(bool isEnabled) = 0;
46 //! Returns true if selection is enabled
47 virtual bool isSelectionEnabled() const = 0;
49 //! Enable or disable multiselection in the viewer
50 //! \param isEnable is enable or disable flag
51 virtual void enableMultiselection(bool isEnable) = 0;
53 //! Returns true if multiselection is enabled
54 virtual bool isMultiSelectionEnabled() const = 0;
56 //! Perfroms the fit all for the active view
57 virtual void fitAll() = 0;
59 //! Sets the view projection
60 /// \param theX the X projection value
61 /// \param theY the Y projection value
62 /// \param theZ the Z projection value
63 virtual void setViewProjection(double theX, double theY, double theZ) = 0;
65 /// Add selection filter to the viewer
66 /// \param theFilter a selection filter
67 virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
69 /// Remove selection filter from the viewer
70 /// \param theFilter a selection filter
71 virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
73 /// Remove all selection filters from the viewer
74 virtual void clearSelectionFilters() = 0;
76 /// Update current viewer
77 virtual void update() = 0;
79 const double Scale(const Handle(V3d_View)& theView)
81 if (!myWindowScale.contains(theView))
82 myWindowScale.insert(theView, theView->Camera()->Scale());
83 return myWindowScale[theView];
86 void SetScale(const Handle(V3d_View)& theView, const double theVal) { myWindowScale[theView] = theVal; }
88 /// Method returns True if the viewer can process editing objects
89 /// by mouse drugging. If this is impossible thet it has to return False.
90 virtual bool canDragByMouse() const { return true; }
93 /// Signal emited when last view window is closed
94 void lastViewClosed();
96 /// Signal emited before view window is closed
97 void tryCloseView(ModuleBase_IViewWindow* theWnd);
99 /// Signal emited on delete view window
100 void deleteView(ModuleBase_IViewWindow* theWnd);
102 /// Signal emited on creation of view window
103 void viewCreated(ModuleBase_IViewWindow* theWnd);
105 /// Signal emited on key release
106 void activated(ModuleBase_IViewWindow* theWnd);
108 /// Signal emited on mouse press
109 void mousePress(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
111 /// Signal emited on mouse release
112 void mouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
114 /// Signal emited on mouse double click
115 void mouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
117 /// Signal emited on mouse move
118 void mouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
120 /// Signal emited on key press
121 void keyPress(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
123 /// Signal emited on key release
124 void keyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
126 /// Signal emited on selection changed
127 void selectionChanged();
129 /// Signal emited on selection changed
130 void contextMenuRequested(QContextMenuEvent*);
132 /// Signal emitted on transformation of view point in view window
133 /// \param theTransformation type of transformation (see AppElements_ViewWindow::OperationType)
134 void viewTransformed(int theTransformation);
137 QMap<Handle(V3d_View), double> myWindowScale;