Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / VVTK / VVTK_InteractorStyle.h
1 //  SALOME VTKViewer : build VTK viewer into Salome desktop
2 //
3 //  Copyright (C) 2003  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. 
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : VVTK_InteractorStyle.h
25 //  Author : Christophe ATTANASIO
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef __VVTK_InteractorStyle_h
30 #define __VVTK_InteractorStyle_h
31
32
33 #include "VVTK.h"
34
35 #include "SVTK_InteractorStyle.h"
36 //
37 //-------------------------------------------
38 //! Control the value of increment in new style of interaction.
39 /*!
40   This class controls of value of increment,
41   for pan/rotate/zoom operations in new style 
42   of interaction
43 */
44 class VVTK_ControllerIncrement : public SVTK_ControllerIncrement {
45  public:
46   vtkTypeMacro(VVTK_ControllerIncrement,SVTK_ControllerIncrement);
47   static VVTK_ControllerIncrement* New();
48   
49   //! Increace the increment value by multiplying on 2
50   virtual int Increase();
51
52   //! Decreace the increment value by division on 2
53   virtual int Decrease();
54   
55  protected:
56   VVTK_ControllerIncrement();
57   virtual ~VVTK_ControllerIncrement();
58   //
59  private:
60   VVTK_ControllerIncrement(const VVTK_ControllerIncrement&);  //Not implemented
61   void operator=(const VVTK_ControllerIncrement&);  //Not implemented
62 };
63 //
64 //-------------------------------------------
65 //! Control the behaviour of KeyDown event in new style of interaction.
66 /*!
67   This class controls of behaviour of of KeyDown event
68   in new style of interaction.
69 */
70 class VVTK_ControllerOnKeyDown : public SVTK_ControllerOnKeyDown{
71  public:
72   vtkTypeMacro(VVTK_ControllerOnKeyDown, SVTK_ControllerOnKeyDown);
73   static VVTK_ControllerOnKeyDown* New();
74
75   //! Provides the action on event 
76   virtual bool OnKeyDown(vtkInteractorStyle* );
77
78  protected:
79   VVTK_ControllerOnKeyDown();
80   virtual ~VVTK_ControllerOnKeyDown();
81   
82  private:
83   VVTK_ControllerOnKeyDown(const VVTK_ControllerOnKeyDown&);//Not implemented
84   void operator=(const VVTK_ControllerOnKeyDown&);          //Not implemented
85 };
86
87
88 //! Introduce new style of interaction (keyboard free)
89 class VVTK_EXPORT VVTK_InteractorStyle : public SVTK_InteractorStyle
90 {
91  public:
92   static VVTK_InteractorStyle *New();
93   vtkTypeMacro(VVTK_InteractorStyle,SVTK_InteractorStyle);
94
95   //! Redefined from SVTK_InteractorStyle::SetInteractor in order to add an observer (callback) for custorm event (space mouse event)
96   virtual
97   void
98   SetInteractor( vtkRenderWindowInteractor* );
99   
100  protected:
101   VVTK_InteractorStyle();
102   ~VVTK_InteractorStyle();
103
104   VVTK_InteractorStyle(const VVTK_InteractorStyle&); // Not implemented
105   void operator=(const VVTK_InteractorStyle&); // Not implemented
106
107   // Generic event bindings must be overridden in subclasses
108
109   //! Redefine SVTK_InteractorStyle::OnLeftButtonDown
110   virtual void OnLeftButtonDown(int ctrl, int shift, int x, int y);
111
112   //! Redefine SVTK_InteractorStyle::OnMiddleButtonDown
113   virtual void OnMiddleButtonDown(int ctrl, int shift, int x, int y);
114
115   //! Redefine SVTK_InteractorStyle::OnLeftButtonUp
116   virtual void OnLeftButtonUp(int ctrl, int shift, int x, int y);
117
118   //! Redefine SVTK_InteractorStyle::OnMiddleButtonUp
119   virtual void OnMiddleButtonUp(int ctrl, int shift, int x, int y);
120
121   //! Redefine SVTK_InteractorStyle::onFinishOperation
122   virtual void onFinishOperation();
123
124   //! Main process VTK event method
125   static 
126   void
127   ProcessEvents(vtkObject* object, 
128                 unsigned long event,
129                 void* clientData, 
130                 void* callData );
131
132   //! Redefine SVTK_InteractorStyle::onSpaceMouseButton
133   virtual void onSpaceMouseButton( int button );
134   
135   //! To decrease magnification of the Gauss Points
136   void DecreaseGaussPointMagnification();
137
138   //! To increase magnification of the Gauss Points
139   void IncreaseGaussPointMagnification();
140
141   //! SpaceMouse short cuts
142   int mySMDecreaseMagnificationBtn;
143   int mySMIncreaseMagnificationBtn;
144   
145   bool myIsMidButtonDown;
146   bool myIsLeftButtonDown;
147 };
148
149 #endif