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