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