Salome HOME
Issue #1016: Hide selection rectangle on sketcher operation
[modules/shaper.git] / src / ModuleBase / ModuleBase_IViewer.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 #ifndef ModuleBase_IViewer_H
4 #define ModuleBase_IViewer_H
5
6 #include "ModuleBase.h"
7 #include <QObject>
8 #include <QMap>
9 #include <AIS_InteractiveContext.hxx>
10 #include <V3d_View.hxx>
11
12 class QMouseEvent;
13 class QKeyEvent;
14 class QContextMenuEvent;
15 class ModuleBase_IViewWindow;
16
17 /**
18  * \ingroup GUI
19  * A Base object for definition of connector object to
20  * Salome Viewer. Reimplemented in NewGeom_SalomeViewer class
21  */
22 class MODULEBASE_EXPORT ModuleBase_IViewer : public QObject
23 {
24 Q_OBJECT
25  public:
26    /// Constructor
27    /// \param theParent a parent object
28   ModuleBase_IViewer(QObject* theParent);
29
30   //! Returns AIS_InteractiveContext from current OCCViewer
31   virtual Handle(AIS_InteractiveContext) AISContext() const = 0;
32
33   //! Retrurns V3d_Vioewer from current viewer
34   virtual Handle(V3d_Viewer) v3dViewer() const = 0;
35
36   //! Returns Vsd_View object from currently active view window
37   virtual Handle(V3d_View) activeView() const = 0;
38
39   //! Enable or disable selection in the viewer
40   //! \param isEnabled is enable or disable flag
41   virtual void enableSelection(bool isEnabled) = 0;
42
43   //! Returns true if selection is enabled
44   virtual bool isSelectionEnabled() const = 0;
45
46   //! Enable or disable multiselection in the viewer
47   //! \param isEnable is enable or disable flag
48   virtual void enableMultiselection(bool isEnable) = 0;
49
50   //! Returns true if multiselection is enabled
51   virtual bool isMultiSelectionEnabled() const = 0;
52
53   //! Enable or disable draw mode in the viewer
54   virtual bool enableDrawMode(bool isEnabled) = 0;
55
56   //! Perfroms the fit all for the active view
57   virtual void fitAll() = 0;
58
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   /// \param theTwist the twist angle in radians
64   virtual void setViewProjection( double theX, double theY, double theZ,
65                                   double theTwist ) = 0;
66
67   /// Add selection filter to the viewer
68   /// \param theFilter a selection filter
69   virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
70
71   /// Remove selection filter from the viewer
72   /// \param theFilter a selection filter
73   virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
74
75   /// Returns true if the selection filter is set to the viewer
76   /// \param theFilter a selection filter
77   virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
78
79   /// Remove all selection filters from the viewer
80   virtual void clearSelectionFilters() = 0;
81
82   /// Update current viewer
83   virtual void update() = 0;
84
85   /// Returns a scale factor of the given view
86   /// \param theView a view object
87   const double Scale(const Handle(V3d_View)& theView)
88   {
89     if (!myWindowScale.contains(theView))
90       myWindowScale.insert(theView, theView->Camera()->Scale());
91     return myWindowScale[theView];
92   }
93
94   /// Remember a scale factor for the view object
95   /// \param theView a view object
96   /// \param theVal a scale factor
97   void SetScale(const Handle(V3d_View)& theView, const double theVal) { myWindowScale[theView] = theVal; }
98
99   /// Method returns True if the viewer can process editing objects 
100   /// by mouse drugging. If this is impossible thet it has to return False.
101   virtual bool canDragByMouse() const { return true; }
102
103   /// Fit all along Z (perpendicular to display)
104   virtual void Zfitall() = 0;
105
106 signals:
107   /// Signal emited when last view window is closed
108   void lastViewClosed();
109
110   /// Signal emited before view window is closed
111   void tryCloseView(ModuleBase_IViewWindow* theWnd);
112
113   /// Signal emited on delete view window
114   void deleteView(ModuleBase_IViewWindow* theWnd);
115
116   /// Signal emited on creation of view window
117   void viewCreated(ModuleBase_IViewWindow* theWnd);
118
119   /// Signal emited on key release
120   void activated(ModuleBase_IViewWindow* theWnd);
121
122   /// Signal emited on mouse press
123   void mousePress(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
124
125   /// Signal emited on mouse release
126   void mouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
127
128   /// Signal emited on mouse double click
129   void mouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
130
131   /// Signal emited on mouse move
132   void mouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
133
134   /// Signal emited on key press
135   void keyPress(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
136
137   /// Signal emited on key release
138   void keyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
139
140   /// Signal emited on selection changed
141   void selectionChanged();
142
143   /// Signal emited on selection changed
144   void contextMenuRequested(QContextMenuEvent*);
145
146   /// Signal emitted on transformation of view point in view window
147   /// \param theTransformation type of transformation (see AppElements_ViewWindow::OperationType)
148   void viewTransformed(int theTransformation);
149
150   protected:
151     /// A map for storing a scale factors dependent on view object
152     QMap<Handle(V3d_View), double> myWindowScale;
153 };
154
155 #endif