Salome HOME
Issue #904 - Fatal error aftre delete sketch from dataset used in extrusion in part
[modules/shaper.git] / src / XGUI / XGUI_ViewerProxy.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 #ifndef XGUI_VIEWERPROXY_H
4 #define XGUI_VIEWERPROXY_H
5
6 #include "XGUI.h"
7 #include <ModuleBase_IViewer.h>
8 #include <AppElements_ViewWindow.h>
9
10 class XGUI_Workshop;
11 /**
12  * \ingroup GUI
13  * Proxy class which repersents or AppElements_Viewer or Salome Viewer
14  * dependently on current launching environment.
15  * It is reccomennded to use this class in operation for accessing to viewer 
16  * functionality instead of direct access to a viewer
17  */
18 class XGUI_EXPORT XGUI_ViewerProxy : public ModuleBase_IViewer
19 {
20 Q_OBJECT
21  public:
22    /// Constructor
23    /// \param theParent a parent object
24   XGUI_ViewerProxy(XGUI_Workshop* theParent);
25
26   //! Returns AIS_InteractiveContext from current OCCViewer
27   virtual Handle(AIS_InteractiveContext) AISContext() const;
28
29   //! Retrurns V3d_Vioewer from current viewer
30   virtual Handle(V3d_Viewer) v3dViewer() const;
31
32   //! Returns Vsd_View object from currently active view window
33   virtual Handle(V3d_View) activeView() const;
34
35   //! Enable or disable selection in the viewer
36   virtual void enableSelection(bool isEnabled);
37
38   //! Returns true if selection is enabled
39   virtual bool isSelectionEnabled() const;
40
41   //! Enable or disable multiselection in the viewer
42   virtual void enableMultiselection(bool isEnable);
43
44   //! Returns true if multiselection is enabled
45   virtual bool isMultiSelectionEnabled() const;
46
47   //! Sets the view projection
48   /// \param theX the X projection value
49   /// \param theY the Y projection value
50   /// \param theZ the Z projection value
51   /// \param theTwist the twist angle in radians
52   virtual void setViewProjection( double theX, double theY, double theZ,
53                                   double theTwist );
54
55   //! Sets the view fitted all
56   virtual void fitAll();
57
58   /// Connects to a viewer according to current environment
59   void connectToViewer();
60
61   /// Add selection filter to the viewer
62   virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
63
64   /// Remove selection filter from the viewer
65   virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
66
67   /// Returns true if the selection filter is set to the viewer
68   /// \param theFilter a selection filter
69   virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
70
71   /// Remove all selection filters from the viewer
72   virtual void clearSelectionFilters();
73
74   /// Update current viewer
75   virtual void update();
76
77   /// Method returns True if the viewer can process editing objects 
78   /// by mouse drugging. If this is impossible thet it has to return False.
79   virtual bool canDragByMouse() const;
80
81   // Fit all along Z (perpendicular to display)
82   virtual void Zfitall();
83
84 signals:
85   /// Emits by mouse entering the view port
86   void enterViewPort();
87
88   /// Emits by mouse leaving of the view port
89   void leaveViewPort();
90
91 protected:
92   /// processes the application signals to catch the mouse leaving state of the main window
93   /// \param theObject
94   /// \param theEvent
95   bool eventFilter(QObject *theObject, QEvent *theEvent);
96
97 private slots:
98   void onTryCloseView(AppElements_ViewWindow*);
99   void onDeleteView(AppElements_ViewWindow*);
100   void onViewCreated(ModuleBase_IViewWindow* theWnd);
101   void onViewCreated(AppElements_ViewWindow*);
102   void onActivated(AppElements_ViewWindow*);
103
104   void onMousePress(AppElements_ViewWindow*, QMouseEvent*);
105   void onMouseRelease(AppElements_ViewWindow*, QMouseEvent*);
106   void onMouseDoubleClick(AppElements_ViewWindow*, QMouseEvent*);
107   void onMouseMove(AppElements_ViewWindow*, QMouseEvent*);
108
109   void onKeyPress(AppElements_ViewWindow*, QKeyEvent*);
110   void onKeyRelease(AppElements_ViewWindow*, QKeyEvent*);
111
112   void onViewTransformed(AppElements_ViewWindow::OperationType);
113
114  private:
115   XGUI_Workshop* myWorkshop;
116 };
117
118 #endif