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