Salome HOME
Update code documentation
[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 * A class for providing access of NewGeom functionality to 
24 * SALOME view window functionality
25 */
26 class NewGeom_SalomeView: public ModuleBase_IViewWindow
27 {
28 public:
29   /// Constructor
30   /// \param theViewer a reference to a viewer
31   NewGeom_SalomeView(OCCViewer_Viewer* theViewer) { myViewer = theViewer; }
32
33   virtual Handle(V3d_View) v3dView() const;
34
35   /// Set the current viewer
36   /// \param theViewer a viewer instance
37   void setViewer(OCCViewer_Viewer* theViewer) { myViewer = theViewer; }
38
39   /// Returns current viewer
40   OCCViewer_Viewer* viewer() const { return myViewer; }
41
42 private:
43   /// A reference to a viewer
44   OCCViewer_Viewer* myViewer;
45 };
46
47
48 /**
49 * A class for providing access of NewGeom functionality to 
50 * SALOME viewer functionality
51 */
52 class NewGeom_SalomeViewer : public ModuleBase_IViewer
53 {
54 Q_OBJECT
55  public:
56    /// Constructor
57    /// \param theParent a parent object
58   NewGeom_SalomeViewer(QObject* theParent);
59
60   ~NewGeom_SalomeViewer();
61
62   //! Returns AIS_InteractiveContext from current OCCViewer
63   virtual Handle(AIS_InteractiveContext) AISContext() const;
64
65   //! Retrurns V3d_Vioewer from current viewer
66   virtual Handle(V3d_Viewer) v3dViewer() const;
67
68   //! Returns Vsd_View object from currently active view window
69   virtual Handle(V3d_View) activeView() const;
70
71   //! Enable or disable selection in the viewer
72   virtual void enableSelection(bool isEnabled);
73
74   //! Returns true if selection is enabled
75   virtual bool isSelectionEnabled() const;
76
77   //! Enable or disable multiselection in the viewer
78   virtual void enableMultiselection(bool isEnable);
79
80   //! Returns true if multiselection is enabled
81   virtual bool isMultiSelectionEnabled() const;
82
83   //! Perfroms the fit all for the active view
84   virtual void fitAll();
85
86   //! Sets the view projection
87   /// \param theX the X projection value
88   /// \param theY the Y projection value
89   /// \param theZ the Z projection value
90   virtual void setViewProjection(double theX, double theY, double theZ);
91
92   /// Set selector
93   /// \param theSel a selector instance
94   void setSelector(NewGeom_OCCSelector* theSel);
95
96   /// Add selection filter to the viewer
97   virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
98
99   /// Remove selection filter from the viewer
100   virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
101
102   /// Remove all selection filters from the viewer
103   virtual void clearSelectionFilters();
104
105   /// Returns current selector
106   NewGeom_OCCSelector* selector() const
107   {
108     return mySelector;
109   }
110
111   /// Update current viewer
112   virtual void update();
113
114
115  private slots:
116   void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
117   void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
118   void onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*);
119   void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
120   void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
121   void onKeyRelease(SUIT_ViewWindow*, QKeyEvent*);
122
123   void onTryCloseView(SUIT_ViewWindow*);
124   void onDeleteView(SUIT_ViewWindow*);
125   void onViewCreated(SUIT_ViewWindow*);
126   void onActivated(SUIT_ViewWindow*);
127
128   void onSelectionChanged();
129
130  private:
131   NewGeom_OCCSelector* mySelector;
132   NewGeom_SalomeView* myView;
133   bool myIsSelectionChanged;
134 };
135
136
137 #endif