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