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 email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
20 #ifndef XGUI_VIEWERPROXY_H
21 #define XGUI_VIEWERPROXY_H
24 #include <ModuleBase_IViewer.h>
26 #include <AIS_Trihedron.hxx>
29 #include <AppElements_ViewWindow.h>
35 * Proxy class which repersents or AppElements_Viewer or Salome Viewer
36 * dependently on current launching environment.
37 * It is reccomennded to use this class in operation for accessing to viewer
38 * functionality instead of direct access to a viewer
40 class XGUI_EXPORT XGUI_ViewerProxy : public ModuleBase_IViewer
45 /// \param theParent a parent object
46 XGUI_ViewerProxy(XGUI_Workshop* theParent);
48 /// Connects some signals to the viewer from the module connector
49 void connectViewProxy();
51 //! Returns AIS_InteractiveContext from current OCCViewer
52 virtual Handle(AIS_InteractiveContext) AISContext() const;
54 //! Trihedron 3d object shown in the viewer
55 virtual Handle(AIS_Trihedron) trihedron() const;
57 //! Retrurns V3d_Vioewer from current viewer
58 virtual Handle(V3d_Viewer) v3dViewer() const;
60 //! Returns Vsd_View object from currently active view window
61 virtual Handle(V3d_View) activeView() const;
63 virtual QWidget* activeViewPort() const;
65 //! Enable or disable selection in the viewer
66 virtual void enableSelection(bool isEnabled);
68 //! Returns true if selection is enabled
69 virtual bool isSelectionEnabled() const;
71 //! Enable or disable multiselection in the viewer
72 virtual void enableMultiselection(bool isEnable);
74 //! Returns true if multiselection is enabled
75 virtual bool isMultiSelectionEnabled() const;
77 //! Enable or disable draw mode in the viewer
78 virtual bool enableDrawMode(bool isEnabled);
80 //! Sets the view projection
81 /// \param theX the X projection value
82 /// \param theY the Y projection value
83 /// \param theZ the Z projection value
84 /// \param theTwist the twist angle in radians
85 virtual void setViewProjection( double theX, double theY, double theZ,
88 //! Sets the view fitted all
89 virtual void fitAll();
91 //! Erases all presentations from the viewer
92 virtual void eraseAll();
94 /// Connects to a viewer according to current environment
95 void connectToViewer();
97 /// Add selection filter to the viewer
98 virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
100 /// Remove selection filter from the viewer
101 virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
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);
107 /// Remove all selection filters from the viewer
108 virtual void clearSelectionFilters();
110 /// Update current viewer
111 virtual void update();
113 /// Method returns True if the viewer can process editing objects
114 /// by mouse drugging. If this is impossible thet it has to return False.
115 virtual bool canDragByMouse() const;
117 // Fit all along Z (perpendicular to display)
118 //virtual void Zfitall();
121 /// Emits by mouse entering the view port
122 void enterViewPort();
124 /// Emits by mouse leaving of the view port
125 void leaveViewPort();
128 /// processes the application signals to catch the mouse leaving state of the main window
131 bool eventFilter(QObject *theObject, QEvent *theEvent);
134 void onViewCreated(ModuleBase_IViewWindow* theWnd);
137 void onTryCloseView(AppElements_ViewWindow*);
138 void onDeleteView(AppElements_ViewWindow*);
139 void onViewCreated(AppElements_ViewWindow*);
140 void onActivated(AppElements_ViewWindow*);
142 void onMousePress(AppElements_ViewWindow*, QMouseEvent*);
143 void onMouseRelease(AppElements_ViewWindow*, QMouseEvent*);
144 void onMouseDoubleClick(AppElements_ViewWindow*, QMouseEvent*);
145 void onMouseMove(AppElements_ViewWindow*, QMouseEvent*);
147 void onKeyPress(AppElements_ViewWindow*, QKeyEvent*);
148 void onKeyRelease(AppElements_ViewWindow*, QKeyEvent*);
150 void onViewTransformed(AppElements_ViewWindow::OperationType);
154 XGUI_Workshop* myWorkshop;