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 XGUI_VIEWERPROXY_H
22 #define XGUI_VIEWERPROXY_H
25 #include <ModuleBase_IViewer.h>
27 #include <AIS_Trihedron.hxx>
30 #include <AppElements_ViewWindow.h>
36 * Proxy class which repersents or AppElements_Viewer or Salome Viewer
37 * dependently on current launching environment.
38 * It is reccomennded to use this class in operation for accessing to viewer
39 * functionality instead of direct access to a viewer
41 class XGUI_EXPORT XGUI_ViewerProxy : public ModuleBase_IViewer
46 /// \param theParent a parent object
47 XGUI_ViewerProxy(XGUI_Workshop* theParent);
49 /// Connects some signals to the viewer from the module connector
50 void connectViewProxy();
52 //! Returns AIS_InteractiveContext from current OCCViewer
53 virtual Handle(AIS_InteractiveContext) AISContext() const;
55 //! Trihedron 3d object shown in the viewer
56 virtual Handle(AIS_Trihedron) trihedron() const;
58 //! Retrurns V3d_Vioewer from current viewer
59 virtual Handle(V3d_Viewer) v3dViewer() const;
61 //! Returns Vsd_View object from currently active view window
62 virtual Handle(V3d_View) activeView() const;
64 virtual QWidget* activeViewPort() const;
66 //! Enable or disable selection in the viewer
67 virtual void enableSelection(bool isEnabled);
69 //! Returns true if selection is enabled
70 virtual bool isSelectionEnabled() const;
72 //! Enable or disable multiselection in the viewer
73 virtual void enableMultiselection(bool isEnable);
75 //! Returns true if multiselection is enabled
76 virtual bool isMultiSelectionEnabled() const;
78 //! Enable or disable draw mode in the viewer
79 virtual bool enableDrawMode(bool isEnabled);
81 //! Sets the view projection
82 /// \param theX the X projection value
83 /// \param theY the Y projection value
84 /// \param theZ the Z projection value
85 /// \param theTwist the twist angle in radians
86 virtual void setViewProjection( double theX, double theY, double theZ,
89 //! Sets the view fitted all
90 virtual void fitAll();
92 //! Erases all presentations from the viewer
93 virtual void eraseAll();
95 /// Connects to a viewer according to current environment
96 void connectToViewer();
98 /// Add selection filter to the viewer
99 virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
101 /// Remove selection filter from the viewer
102 virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
104 /// Returns true if the selection filter is set to the viewer
105 /// \param theFilter a selection filter
106 virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
108 /// Remove all selection filters from the viewer
109 virtual void clearSelectionFilters();
111 /// Update current viewer
112 virtual void update();
114 /// Method returns True if the viewer can process editing objects
115 /// by mouse drugging. If this is impossible thet it has to return False.
116 virtual bool canDragByMouse() const;
118 // Fit all along Z (perpendicular to display)
119 //virtual void Zfitall();
122 /// Emits by mouse entering the view port
123 void enterViewPort();
125 /// Emits by mouse leaving of the view port
126 void leaveViewPort();
129 /// processes the application signals to catch the mouse leaving state of the main window
132 bool eventFilter(QObject *theObject, QEvent *theEvent);
135 void onViewCreated(ModuleBase_IViewWindow* theWnd);
138 void onTryCloseView(AppElements_ViewWindow*);
139 void onDeleteView(AppElements_ViewWindow*);
140 void onViewCreated(AppElements_ViewWindow*);
141 void onActivated(AppElements_ViewWindow*);
143 void onMousePress(AppElements_ViewWindow*, QMouseEvent*);
144 void onMouseRelease(AppElements_ViewWindow*, QMouseEvent*);
145 void onMouseDoubleClick(AppElements_ViewWindow*, QMouseEvent*);
146 void onMouseMove(AppElements_ViewWindow*, QMouseEvent*);
148 void onKeyPress(AppElements_ViewWindow*, QKeyEvent*);
149 void onKeyRelease(AppElements_ViewWindow*, QKeyEvent*);
151 void onViewTransformed(AppElements_ViewWindow::OperationType);
155 XGUI_Workshop* myWorkshop;