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