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