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>
15 #include <AIS_Trihedron.hxx>
17 class SUIT_ViewWindow;
21 class NewGeom_OCCSelector;
22 class OCCViewer_Viewer;
23 class SUIT_ViewManager;
27 * A class for providing access of NewGeom functionality to
28 * SALOME view window functionality
30 class NewGeom_SalomeView: public ModuleBase_IViewWindow
34 /// \param theViewer a reference to a viewer
35 NewGeom_SalomeView(OCCViewer_Viewer* theViewer);
37 virtual Handle(V3d_View) v3dView() const;
39 /// Returns the view window view port
40 virtual QWidget* viewPort() const;
42 /// Set the current viewer
43 /// \param theViewer a viewer instance
44 void setViewer(OCCViewer_Viewer* theViewer) { myViewer = theViewer; }
46 /// Returns current viewer
47 OCCViewer_Viewer* viewer() const { return myViewer; }
49 /// Sets the current view
50 void setCurrentView(SUIT_ViewWindow* theView) { myCurrentView = theView; }
53 /// A reference to a viewer
54 OCCViewer_Viewer* myViewer;
55 SUIT_ViewWindow* myCurrentView;
61 * A class for providing access of NewGeom functionality to
62 * SALOME viewer functionality
64 class NewGeom_SalomeViewer : public ModuleBase_IViewer
69 /// \param theParent a parent object
70 NewGeom_SalomeViewer(QObject* theParent);
72 ~NewGeom_SalomeViewer();
74 //! Returns AIS_InteractiveContext from current OCCViewer
75 virtual Handle(AIS_InteractiveContext) AISContext() const;
77 //! Retrurns V3d_Vioewer from current viewer
78 virtual Handle(V3d_Viewer) v3dViewer() const;
80 //! Trihedron 3d object shown in the viewer
81 virtual Handle(AIS_Trihedron) trihedron() const;
83 //! Returns Vsd_View object from currently active view window
84 virtual Handle(V3d_View) activeView() const;
86 //! Returns viewer view port
87 virtual QWidget* activeViewPort() const;
89 //! Enable or disable selection in the viewer
90 virtual void enableSelection(bool isEnabled);
92 //! Returns true if selection is enabled
93 virtual bool isSelectionEnabled() const;
95 //! Enable or disable multiselection in the viewer
96 virtual void enableMultiselection(bool isEnable);
98 //! Returns true if multiselection is enabled
99 virtual bool isMultiSelectionEnabled() const;
101 //! Enable or disable draw mode in the viewer
102 virtual bool enableDrawMode(bool isEnabled);
104 //! For some signals it disconnects the window from usual signal and connect it to the module ones
105 void reconnectActions(SUIT_ViewWindow* theWindow, const bool theUseNewGeomSlot);
107 //! Perfroms the fit all for the active view
108 virtual void fitAll();
110 //! Sets the view projection
111 /// \param theX the X projection value
112 /// \param theY the Y projection value
113 /// \param theZ the Z projection value
114 /// \param theTwist the twist angle in radians
115 virtual void setViewProjection( double theX, double theY, double theZ,
119 /// \param theSel a selector instance
120 void setSelector(NewGeom_OCCSelector* theSel);
122 /// Add selection filter to the viewer
123 virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
125 /// Remove selection filter from the viewer
126 virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
128 /// Returns true if the selection filter is set to the viewer
129 /// \param theFilter a selection filter
130 virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
132 /// Remove all selection filters from the viewer
133 virtual void clearSelectionFilters();
135 /// Returns current selector
136 NewGeom_OCCSelector* selector() const
141 /// Update current viewer
142 virtual void update();
144 /// Method returns True if the viewer can process editing objects
145 /// by mouse drugging. If this is impossible thet it has to return False.
146 virtual bool canDragByMouse() const;
148 /// Activate or deactivate viewer
149 /// \param toActivate - activation flag
150 void activateViewer(bool toActivate);
152 // Fit all along Z (perpendicular to display)
153 virtual void Zfitall();
156 void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
157 void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
158 void onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*);
159 void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
160 void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
161 void onKeyRelease(SUIT_ViewWindow*, QKeyEvent*);
163 void onTryCloseView(SUIT_ViewWindow*);
164 void onDeleteView(SUIT_ViewWindow*);
165 void onViewCreated(SUIT_ViewWindow*);
166 void onActivated(SUIT_ViewManager*);
168 void onSelectionChanged();
169 void onViewTransformed(OCCViewer_ViewWindow::OperationType);
171 /// Emit signal about trihedron visiblity change because SALOME sets the trihedron visible by this signal.
172 /// It is necessary to activate the viewer trihedron in the current selection mode
173 void onViewPortMapped();
176 NewGeom_OCCSelector* mySelector;
177 NewGeom_SalomeView* myView;
178 bool myIsSelectionChanged;