1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef ModuleBase_IViewer_H
22 #define ModuleBase_IViewer_H
24 #include "ModuleBase.h"
27 #include <AIS_InteractiveContext.hxx>
28 #include <V3d_View.hxx>
29 #include <AIS_Trihedron.hxx>
33 class QContextMenuEvent;
34 class ModuleBase_IViewWindow;
38 * A Base object for definition of connector object to
39 * Salome Viewer. Reimplemented in SHAPERGUI_SalomeViewer class
41 class MODULEBASE_EXPORT ModuleBase_IViewer : public QObject
46 /// \param theParent a parent object
47 ModuleBase_IViewer(QObject* theParent);
49 //! Returns AIS_InteractiveContext from current OCCViewer
50 virtual Handle(AIS_InteractiveContext) AISContext() const = 0;
52 //! Trihedron 3d object shown in the viewer
53 virtual Handle(AIS_Trihedron) trihedron() const = 0;
55 //! Retrurns V3d_Vioewer from current viewer
56 virtual Handle(V3d_Viewer) v3dViewer() const = 0;
58 //! Returns Vsd_View object from currently active view window
59 virtual Handle(V3d_View) activeView() const = 0;
61 //! Returns currently active view port widget
62 virtual QWidget* activeViewPort() const = 0;
64 //! Enable or disable selection in the viewer
65 //! \param isEnabled is enable or disable flag
66 virtual void enableSelection(bool isEnabled) = 0;
68 //! Returns true if selection is enabled
69 virtual bool isSelectionEnabled() const = 0;
71 //! Enable or disable multiselection in the viewer
72 //! \param isEnable is enable or disable flag
73 virtual void enableMultiselection(bool isEnable) = 0;
75 //! Returns true if multiselection is enabled
76 virtual bool isMultiSelectionEnabled() const = 0;
78 //! Enable or disable draw mode in the viewer
79 virtual bool enableDrawMode(bool isEnabled) = 0;
81 //! Perfroms the fit all for the active view
82 virtual void fitAll() = 0;
84 //! Erases all presentations from the viewer
85 virtual void eraseAll() = 0;
87 //! Sets the view projection
88 /// \param theX the X projection value
89 /// \param theY the Y projection value
90 /// \param theZ the Z projection value
91 /// \param theTwist the twist angle in radians
92 virtual void setViewProjection( double theX, double theY, double theZ,
93 double theTwist ) = 0;
95 /// Add selection filter to the viewer
96 /// \param theFilter a selection filter
97 virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
99 /// Remove selection filter from the viewer
100 /// \param theFilter a selection filter
101 virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
103 /// Returns true if the selection filter is set to the viewer
104 /// \param theFilter a selection filter
105 virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
107 /// Update current viewer
108 virtual void update() = 0;
110 /// Returns a scale factor of the given view
111 /// \param theView a view object
112 const double Scale(const Handle(V3d_View)& theView)
114 if (!myWindowScale.contains(theView))
115 myWindowScale.insert(theView, theView->Camera()->Scale());
116 return myWindowScale[theView];
119 /// Remember a scale factor for the view object
120 /// \param theView a view object
121 /// \param theVal a scale factor
122 void SetScale(const Handle(V3d_View)& theView, const double theVal)
123 { myWindowScale[theView] = theVal; }
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 { return true; }
129 /// Fit all along Z (perpendicular to display)
130 //virtual void Zfitall() = 0;
133 /// Signal emited when last view window is closed
134 void lastViewClosed();
136 /// Signal emited before view window is closed
137 void tryCloseView(ModuleBase_IViewWindow* theWnd);
139 /// Signal emited on delete view window
140 void deleteView(ModuleBase_IViewWindow* theWnd);
142 /// Signal emited on creation of view window
143 void viewCreated(ModuleBase_IViewWindow* theWnd);
145 /// Signal emited on key release
146 void activated(ModuleBase_IViewWindow* theWnd);
148 /// Signal emited on mouse press
149 void mousePress(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
151 /// Signal emited on mouse release
152 void mouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
154 /// Signal emited on mouse double click
155 void mouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
157 /// Signal emited on mouse move
158 void mouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
160 /// Signal emited on key press
161 void keyPress(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
163 /// Signal emited on key release
164 void keyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
166 /// Signal emited on selection changed
167 void selectionChanged();
169 /// Signal emited on selection changed
170 void contextMenuRequested(QContextMenuEvent*);
172 /// Signal emitted on transformation of view point in view window
173 /// \param theTransformation type of transformation (see AppElements_ViewWindow::OperationType)
174 void viewTransformed(int theTransformation);
176 /// Signal emited on selection changed
177 void trihedronVisibilityChanged(bool theState);
180 /// A map for storing a scale factors dependent on view object
181 QMap<Handle(V3d_View), double> myWindowScale;