Salome HOME
Issue #1860: fix end lines with spaces
[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 SHAPERGUI_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   //! Returns currently active view port widget
44   virtual QWidget* activeViewPort() const = 0;
45
46   //! Enable or disable selection in the viewer
47   //! \param isEnabled is enable or disable flag
48   virtual void enableSelection(bool isEnabled) = 0;
49
50   //! Returns true if selection is enabled
51   virtual bool isSelectionEnabled() const = 0;
52
53   //! Enable or disable multiselection in the viewer
54   //! \param isEnable is enable or disable flag
55   virtual void enableMultiselection(bool isEnable) = 0;
56
57   //! Returns true if multiselection is enabled
58   virtual bool isMultiSelectionEnabled() const = 0;
59
60   //! Enable or disable draw mode in the viewer
61   virtual bool enableDrawMode(bool isEnabled) = 0;
62
63   //! Perfroms the fit all for the active view
64   virtual void fitAll() = 0;
65
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;
73
74   /// Add selection filter to the viewer
75   /// \param theFilter a selection filter
76   virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
77
78   /// Remove selection filter from the viewer
79   /// \param theFilter a selection filter
80   virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
81
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;
85
86   /// Remove all selection filters from the viewer
87   virtual void clearSelectionFilters() = 0;
88
89   /// Update current viewer
90   virtual void update() = 0;
91
92   /// Returns a scale factor of the given view
93   /// \param theView a view object
94   const double Scale(const Handle(V3d_View)& theView)
95   {
96     if (!myWindowScale.contains(theView))
97       myWindowScale.insert(theView, theView->Camera()->Scale());
98     return myWindowScale[theView];
99   }
100
101   /// Remember a scale factor for the view object
102   /// \param theView a view object
103   /// \param theVal a scale factor
104   void SetScale(const Handle(V3d_View)& theView, const double theVal)
105   { myWindowScale[theView] = theVal; }
106
107   /// Method returns True if the viewer can process editing objects
108   /// by mouse drugging. If this is impossible thet it has to return False.
109   virtual bool canDragByMouse() const { return true; }
110
111   /// Fit all along Z (perpendicular to display)
112   virtual void Zfitall() = 0;
113
114 signals:
115   /// Signal emited when last view window is closed
116   void lastViewClosed();
117
118   /// Signal emited before view window is closed
119   void tryCloseView(ModuleBase_IViewWindow* theWnd);
120
121   /// Signal emited on delete view window
122   void deleteView(ModuleBase_IViewWindow* theWnd);
123
124   /// Signal emited on creation of view window
125   void viewCreated(ModuleBase_IViewWindow* theWnd);
126
127   /// Signal emited on key release
128   void activated(ModuleBase_IViewWindow* theWnd);
129
130   /// Signal emited on mouse press
131   void mousePress(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
132
133   /// Signal emited on mouse release
134   void mouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
135
136   /// Signal emited on mouse double click
137   void mouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
138
139   /// Signal emited on mouse move
140   void mouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
141
142   /// Signal emited on key press
143   void keyPress(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
144
145   /// Signal emited on key release
146   void keyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
147
148   /// Signal emited on selection changed
149   void selectionChanged();
150
151   /// Signal emited on selection changed
152   void contextMenuRequested(QContextMenuEvent*);
153
154   /// Signal emitted on transformation of view point in view window
155   /// \param theTransformation type of transformation (see AppElements_ViewWindow::OperationType)
156   void viewTransformed(int theTransformation);
157
158   /// Signal emited on selection changed
159   void trihedronVisibilityChanged(bool theState);
160
161   protected:
162     /// A map for storing a scale factors dependent on view object
163     QMap<Handle(V3d_View), double> myWindowScale;
164 };
165
166 #endif