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