Salome HOME
Fix for shortcut problem
[modules/shaper.git] / src / NewGeom / NewGeom_SalomeViewer.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3
4 #ifndef NewGeom_SalomeViewer_H
5 #define NewGeom_SalomeViewer_H
6
7 #include "NewGeom.h"
8
9 #include <ModuleBase_IViewer.h>
10 #include <ModuleBase_IViewWindow.h>
11
12 #include <V3d_View.hxx>
13
14 class SUIT_ViewWindow;
15 class QMouseEvent;
16 class QKeyEvent;
17
18 class NewGeom_OCCSelector;
19 class OCCViewer_Viewer;
20 class SUIT_ViewManager;
21
22 /**
23 * \ingroup Salome
24 * A class for providing access of NewGeom functionality to 
25 * SALOME view window functionality
26 */
27 class NewGeom_SalomeView: public ModuleBase_IViewWindow
28 {
29 public:
30   /// Constructor
31   /// \param theViewer a reference to a viewer
32   NewGeom_SalomeView(OCCViewer_Viewer* theViewer) { myViewer = theViewer; }
33
34   virtual Handle(V3d_View) v3dView() const;
35
36   /// Set the current viewer
37   /// \param theViewer a viewer instance
38   void setViewer(OCCViewer_Viewer* theViewer) { myViewer = theViewer; }
39
40   /// Returns current viewer
41   OCCViewer_Viewer* viewer() const { return myViewer; }
42
43 private:
44   /// A reference to a viewer
45   OCCViewer_Viewer* myViewer;
46 };
47
48
49 /**
50 * \ingroup Salome
51 * A class for providing access of NewGeom functionality to 
52 * SALOME viewer functionality
53 */
54 class NewGeom_SalomeViewer : public ModuleBase_IViewer
55 {
56 Q_OBJECT
57  public:
58    /// Constructor
59    /// \param theParent a parent object
60   NewGeom_SalomeViewer(QObject* theParent);
61
62   ~NewGeom_SalomeViewer();
63
64   //! Returns AIS_InteractiveContext from current OCCViewer
65   virtual Handle(AIS_InteractiveContext) AISContext() const;
66
67   //! Retrurns V3d_Vioewer from current viewer
68   virtual Handle(V3d_Viewer) v3dViewer() const;
69
70   //! Returns Vsd_View object from currently active view window
71   virtual Handle(V3d_View) activeView() const;
72
73   //! Enable or disable selection in the viewer
74   virtual void enableSelection(bool isEnabled);
75
76   //! Returns true if selection is enabled
77   virtual bool isSelectionEnabled() const;
78
79   //! Enable or disable multiselection in the viewer
80   virtual void enableMultiselection(bool isEnable);
81
82   //! Returns true if multiselection is enabled
83   virtual bool isMultiSelectionEnabled() const;
84
85   //! Perfroms the fit all for the active view
86   virtual void fitAll();
87
88   //! Sets the view projection
89   /// \param theX the X projection value
90   /// \param theY the Y projection value
91   /// \param theZ the Z projection value
92   virtual void setViewProjection(double theX, double theY, double theZ);
93
94   /// Set selector
95   /// \param theSel a selector instance
96   void setSelector(NewGeom_OCCSelector* theSel);
97
98   /// Add selection filter to the viewer
99   virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
100
101   /// Remove selection filter from the viewer
102   virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
103
104   /// Remove all selection filters from the viewer
105   virtual void clearSelectionFilters();
106
107   /// Returns current selector
108   NewGeom_OCCSelector* selector() const
109   {
110     return mySelector;
111   }
112
113   /// Update current viewer
114   virtual void update();
115
116   /// Method returns True if the viewer can process editing objects 
117   /// by mouse drugging. If this is impossible thet it has to return False.
118   virtual bool canDragByMouse() const;
119
120  private slots:
121   void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
122   void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
123   void onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*);
124   void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
125   void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
126   void onKeyRelease(SUIT_ViewWindow*, QKeyEvent*);
127
128   void onTryCloseView(SUIT_ViewWindow*);
129   void onDeleteView(SUIT_ViewWindow*);
130   void onViewCreated(SUIT_ViewWindow*);
131   void onActivated(SUIT_ViewWindow*);
132
133   void onSelectionChanged();
134
135  private:
136   NewGeom_OCCSelector* mySelector;
137   NewGeom_SalomeView* myView;
138   bool myIsSelectionChanged;
139 };
140
141
142 #endif