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