1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 #ifndef NewGeom_SalomeViewer_H
5 #define NewGeom_SalomeViewer_H
9 #include <ModuleBase_IViewer.h>
10 #include <ModuleBase_IViewWindow.h>
12 #include <OCCViewer_ViewWindow.h>
14 #include <V3d_View.hxx>
16 class SUIT_ViewWindow;
20 class NewGeom_OCCSelector;
21 class OCCViewer_Viewer;
22 class SUIT_ViewManager;
26 * A class for providing access of NewGeom functionality to
27 * SALOME view window functionality
29 class NewGeom_SalomeView: public ModuleBase_IViewWindow
33 /// \param theViewer a reference to a viewer
34 NewGeom_SalomeView(OCCViewer_Viewer* theViewer);
36 virtual Handle(V3d_View) v3dView() const;
38 /// Returns the view window view port
39 virtual QWidget* viewPort() const;
41 /// Set the current viewer
42 /// \param theViewer a viewer instance
43 void setViewer(OCCViewer_Viewer* theViewer) { myViewer = theViewer; }
45 /// Returns current viewer
46 OCCViewer_Viewer* viewer() const { return myViewer; }
48 /// Sets the current view
49 void setCurrentView(SUIT_ViewWindow* theView) { myCurrentView = theView; }
52 /// A reference to a viewer
53 OCCViewer_Viewer* myViewer;
54 SUIT_ViewWindow* myCurrentView;
60 * A class for providing access of NewGeom functionality to
61 * SALOME viewer functionality
63 class NewGeom_SalomeViewer : public ModuleBase_IViewer
68 /// \param theParent a parent object
69 NewGeom_SalomeViewer(QObject* theParent);
71 ~NewGeom_SalomeViewer();
73 //! Returns AIS_InteractiveContext from current OCCViewer
74 virtual Handle(AIS_InteractiveContext) AISContext() const;
76 //! Retrurns V3d_Vioewer from current viewer
77 virtual Handle(V3d_Viewer) v3dViewer() const;
79 //! Returns Vsd_View object from currently active view window
80 virtual Handle(V3d_View) activeView() const;
82 //! Enable or disable selection in the viewer
83 virtual void enableSelection(bool isEnabled);
85 //! Returns true if selection is enabled
86 virtual bool isSelectionEnabled() const;
88 //! Enable or disable multiselection in the viewer
89 virtual void enableMultiselection(bool isEnable);
91 //! Returns true if multiselection is enabled
92 virtual bool isMultiSelectionEnabled() const;
94 //! Perfroms the fit all for the active view
95 virtual void fitAll();
97 //! Sets the view projection
98 /// \param theX the X projection value
99 /// \param theY the Y projection value
100 /// \param theZ the Z projection value
101 virtual void setViewProjection(double theX, double theY, double theZ);
104 /// \param theSel a selector instance
105 void setSelector(NewGeom_OCCSelector* theSel);
107 /// Add selection filter to the viewer
108 virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
110 /// Remove selection filter from the viewer
111 virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
113 /// Remove all selection filters from the viewer
114 virtual void clearSelectionFilters();
116 /// Returns current selector
117 NewGeom_OCCSelector* selector() const
122 /// Update current viewer
123 virtual void update();
125 /// Method returns True if the viewer can process editing objects
126 /// by mouse drugging. If this is impossible thet it has to return False.
127 virtual bool canDragByMouse() const;
129 /// Activate or deactivate viewer
130 /// \param toActivate - activation flag
131 void activateViewer(bool toActivate);
133 // Fit all along Z (perpendicular to display)
134 virtual void Zfitall();
137 void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
138 void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
139 void onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*);
140 void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
141 void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
142 void onKeyRelease(SUIT_ViewWindow*, QKeyEvent*);
144 void onTryCloseView(SUIT_ViewWindow*);
145 void onDeleteView(SUIT_ViewWindow*);
146 void onViewCreated(SUIT_ViewWindow*);
147 void onActivated(SUIT_ViewWindow*);
149 void onSelectionChanged();
150 void onViewTransformed(OCCViewer_ViewWindow::OperationType);
153 NewGeom_OCCSelector* mySelector;
154 NewGeom_SalomeView* myView;
155 bool myIsSelectionChanged;