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