Salome HOME
f9acd8ca313c08f57cd025bcf4bfcbae78fd2bc5
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewportInputFilter.h
1 // Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef OCCVIEWER_VIEWPORTINPUTFILTER_H
24 #define OCCVIEWER_VIEWPORTINPUTFILTER_H
25
26 #include <QObject>
27
28 class OCCViewer_ViewManager;
29 class OCCViewer_ViewPort3d;
30 class OCCViewer_Viewer;
31 class SUIT_ViewWindow;
32 class QMouseEvent;
33 class QKeyEvent;
34
35 /*!
36   \class OCCViewer_ViewportInputFilter.
37   \brief The user input filter of OCC viewports. The class can be used
38          to introduce custom interactive operations in OCC viewer,
39          e.g. manipulating IO. The filter receives events in priority
40          to the viewport itself and can bypass some events if it provides
41          custom handling.
42          
43          This class is abstract and required implementation of custom reaction
44          on hooked viewport events. The role of the code behind this class
45          is to properly embed the event filter into OCC viewer's structure.
46 */
47 class OCCViewer_ViewportInputFilter : public QObject
48 {
49   Q_OBJECT
50
51 public:
52   OCCViewer_ViewportInputFilter( OCCViewer_ViewManager*, QObject* );
53   ~OCCViewer_ViewportInputFilter();
54
55 public:
56   virtual void   setEnabled( const bool );
57
58 protected:
59   virtual bool   mouseMove( QMouseEvent*, OCCViewer_ViewPort3d* ) = 0;
60   virtual bool   mousePress( QMouseEvent*, OCCViewer_ViewPort3d* ) = 0;
61   virtual bool   mouseRelease( QMouseEvent*, OCCViewer_ViewPort3d* ) = 0;
62   virtual bool   mouseDoubleClick( QMouseEvent*, OCCViewer_ViewPort3d* ) = 0;
63   virtual bool   keyPress( QKeyEvent*, OCCViewer_ViewPort3d* ) = 0;
64   virtual bool   keyRelease( QKeyEvent*, OCCViewer_ViewPort3d* ) = 0;
65
66 protected:
67   void           connectView( SUIT_ViewWindow* );
68   void           disconnectView( SUIT_ViewWindow* );
69
70 protected:
71   bool           eventFilter( QObject*, QEvent* );
72
73 protected slots:
74   void           onViewCreated( SUIT_ViewWindow* );
75   void           onViewRemoved( SUIT_ViewWindow* );
76
77 protected:
78   OCCViewer_ViewManager*  myVM;
79   OCCViewer_Viewer*       myViewer;
80   bool                    myIsEnabled;
81 };
82
83 #endif