]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_ViewerProxy.h
Salome HOME
Issue#1059: Consider operation state in selection validator
[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   //! Enable or disable draw mode in the viewer
48   virtual bool enableDrawMode(bool isEnabled);
49
50   //! Sets the view projection
51   /// \param theX the X projection value
52   /// \param theY the Y projection value
53   /// \param theZ the Z projection value
54   /// \param theTwist the twist angle in radians
55   virtual void setViewProjection( double theX, double theY, double theZ,
56                                   double theTwist );
57
58   //! Sets the view fitted all
59   virtual void fitAll();
60
61   /// Connects to a viewer according to current environment
62   void connectToViewer();
63
64   /// Add selection filter to the viewer
65   virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
66
67   /// Remove selection filter from the viewer
68   virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
69
70   /// Returns true if the selection filter is set to the viewer
71   /// \param theFilter a selection filter
72   virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
73
74   /// Remove all selection filters from the viewer
75   virtual void clearSelectionFilters();
76
77   /// Update current viewer
78   virtual void update();
79
80   /// Method returns True if the viewer can process editing objects 
81   /// by mouse drugging. If this is impossible thet it has to return False.
82   virtual bool canDragByMouse() const;
83
84   // Fit all along Z (perpendicular to display)
85   virtual void Zfitall();
86
87 signals:
88   /// Emits by mouse entering the view port
89   void enterViewPort();
90
91   /// Emits by mouse leaving of the view port
92   void leaveViewPort();
93
94 protected:
95   /// processes the application signals to catch the mouse leaving state of the main window
96   /// \param theObject
97   /// \param theEvent
98   bool eventFilter(QObject *theObject, QEvent *theEvent);
99
100 private slots:
101   void onTryCloseView(AppElements_ViewWindow*);
102   void onDeleteView(AppElements_ViewWindow*);
103   void onViewCreated(ModuleBase_IViewWindow* theWnd);
104   void onViewCreated(AppElements_ViewWindow*);
105   void onActivated(AppElements_ViewWindow*);
106
107   void onMousePress(AppElements_ViewWindow*, QMouseEvent*);
108   void onMouseRelease(AppElements_ViewWindow*, QMouseEvent*);
109   void onMouseDoubleClick(AppElements_ViewWindow*, QMouseEvent*);
110   void onMouseMove(AppElements_ViewWindow*, QMouseEvent*);
111
112   void onKeyPress(AppElements_ViewWindow*, QKeyEvent*);
113   void onKeyRelease(AppElements_ViewWindow*, QKeyEvent*);
114
115   void onViewTransformed(AppElements_ViewWindow::OperationType);
116
117  private:
118   XGUI_Workshop* myWorkshop;
119 };
120
121 #endif