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