Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SmExaminerEventHandler.h
Go to the documentation of this file.
1 #ifndef SMALLCHANGE_SMEXAMINEREVENTHANDLER_H
2 #define SMALLCHANGE_SMEXAMINEREVENTHANDLER_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
37 #include <SmallChange/basic.h>
38 #include <Inventor/SbTime.h>
39 #include <Inventor/SbVec2f.h>
40 #include <Inventor/SbVec2s.h>
41 #include <Inventor/SbRotation.h>
42 #include <Inventor/SbPlane.h>
43 #include <Inventor/fields/SoSFBool.h>
44 
46 class SoCamera;
47 
48 class SMALLCHANGE_DLL_API SmExaminerEventHandler : public SmEventHandler {
49  typedef SmEventHandler inherited;
50 
52 
53 public:
55  static void initClass(void);
56 
58 
59  virtual void handleEvent(SoHandleEventAction * action);
60  virtual SbBool isAnimating(void);
61  virtual void preRender(SoGLRenderAction * action);
62  virtual void resetCameraFocalDistance(const SbViewportRegion & vpr);
63 
64 protected:
65  virtual ~SmExaminerEventHandler();
66 
67  virtual float clampZoom(const float val);
68  void enableButton3Movement(const SbBool onoff);
69 
70 private:
71  void setMotion3OnCamera(SbBool enable);
72  SbBool getMotion3OnCamera(void) const;
73 
74  float rotXWheelMotion(float value, float old);
75  float rotYWheelMotion(float value, float old);
76 
77  void reorientCamera(const SbRotation & rotation);
78  void spin(const SbVec2f & mousepos);
79  void pan(const SbVec2f & mousepos, const SbVec2f & prevpos);
80  void zoom(SoCamera * camera, const float diffvalue);
81  void zoomByCursor(const SbVec2f & mousepos, const SbVec2f & prevpos);
82  void pan(SoCamera * cam,
83  float aspectratio, const SbPlane & panningplane,
84  const SbVec2f & currpos, const SbVec2f & prevpos);
85 
86  SbVec2f lastmouseposition;
87  SbPlane panningplane;
88 
89  SbBool spinanimatingallowed;
90  SbVec2f lastspinposition;
91  int spinsamplecounter;
92  SbRotation spinincrement;
94 
95  SbRotation spinRotation;
96 
97  SbBool axiscrossEnabled;
98  int axiscrossSize;
99 
100 
101  struct { // tracking mouse movement in a log
102  short size;
103  short historysize;
106  } log;
107 
108  // The Microsoft Visual C++ v6.0 compiler needs a name on this class
109  // to be able to generate a constructor (which it wants to have for
110  // running the the SbVec2s constructors). So don't try to be clever
111  // and make it anonymous.
112  struct Pointer {
113  SbVec2s now, then;
114  } pointer;
115 
116  SbBool button1down;
117  SbBool button3down;
118  SbBool ctrldown, shiftdown;
119 
120  void clearLog(void);
121  void addToLog(const SbVec2s pos, const SbTime time);
122 
123  SbTime prevRedrawTime;
124 
125  SbBool motion3OnCamera;
126 
127  enum ViewerMode {
128  IDLE,
129  INTERACT,
130  ZOOMING,
131  PANNING,
132  DRAGGING,
133  SPINNING,
134  SEEK_WAIT_MODE,
135  SEEK_MODE
136  } mode;
137 
138  ViewerMode currentmode;
139  void setMode(const ViewerMode mode);
140 
141  void setCursorRepresentation(int mode);
142 
143  SbBool button3enabled;
144 };
145 
146 
147 #endif // SMALLCHANGE_SMEXAMINEREVENTHANDLER_H
The SmEventHandler class...FIXME: doc.
Definition: SmEventHandler.h:50
The SmExaminerEventHandler class...FIXME: doc.
Definition: SmExaminerEventHandler.h:48
#define SO_NODE_HEADER(classname)
SbVec2s * position
Definition: SmExaminerEventHandler.h:104
virtual void preRender(SoGLRenderAction *action)
Definition: SmEventHandler.cpp:129
virtual SbBool isAnimating(void)
Definition: SmEventHandler.cpp:141
static SbSphereSheetProjector * spinprojector
Definition: cameracontrol.cpp:18
virtual void resetCameraFocalDistance(const SbViewportRegion &vpr)
Definition: SmEventHandler.cpp:147
short historysize
Definition: SmExaminerEventHandler.h:103
Definition: SbPlane.h:44
SbTime * time
Definition: SmExaminerEventHandler.h:105
SoSFBool enableSpin
Definition: SmExaminerEventHandler.h:57
short size
Definition: SmExaminerEventHandler.h:102
virtual void handleEvent(SoHandleEventAction *action)
static void initClass(void)
Definition: SmEventHandler.cpp:65