VTK
vtkInteractorStyleUnicam.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkInteractorStyleUnicam.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
16 /*
17  * This work (vtkInteractorStyleUnicam.h) was produced under a grant from
18  * the Department of Energy to Brown University. Neither Brown University
19  * nor the authors assert any copyright with respect to this work and it may
20  * be used, reproduced, and distributed without permission.
21  */
22 
79 #ifndef vtkInteractorStyleUnicam_h
80 #define vtkInteractorStyleUnicam_h
81 
82 #include "vtkInteractionStyleModule.h" // For export macro
83 #include "vtkInteractorStyle.h"
84 
85 class vtkCamera;
87 
88 //
89 // XXX - would have preferred to make these enumerations within the class,
90 // enum { NONE=0, BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT };
91 // enum {CAM_INT_ROT, CAM_INT_CHOOSE, CAM_INT_PAN, CAM_INT_DOLLY};
92 // but vtkWrapTcl signaled a "syntax error" when it parsed the 'enum' line.
93 // So, am making them defines which is what the other classes that want
94 // to have constants appear to do.
95 //
96 // buttons pressed
97 #define VTK_UNICAM_NONE 0
98 #define VTK_UNICAM_BUTTON_LEFT 1
99 #define VTK_UNICAM_BUTTON_MIDDLE 2
100 #define VTK_UNICAM_BUTTON_RIGHT 3
101 //
102 // camera modes
103 #define VTK_UNICAM_CAM_INT_ROT 0
104 #define VTK_UNICAM_CAM_INT_CHOOSE 1
105 #define VTK_UNICAM_CAM_INT_PAN 2
106 #define VTK_UNICAM_CAM_INT_DOLLY 3
107 
109 {
110 public:
113  void PrintSelf(ostream& os, vtkIndent indent);
114 
115  void SetWorldUpVector(double a[3]) {this->SetWorldUpVector(a[0],a[1],a[2]);}
116  void SetWorldUpVector(double x, double y, double z);
117  vtkGetVectorMacro(WorldUpVector, double, 3);
118 
120 
121  virtual void OnMouseMove();
122  virtual void OnLeftButtonDown();
123  virtual void OnLeftButtonUp();
124  virtual void OnLeftButtonMove();
126 
129  virtual void OnTimer();
130 
131 protected:
134 
136 
137  int ButtonDown; // which button is down
138  double DTime; // time mouse button was pressed
139  double Dist; // distance the mouse has moved since button press
140  double StartPix[2]; // pixel mouse movement started at
141  double LastPos[2]; // normalized position of mouse last frame
142  double LastPix[2]; // pixel position of mouse last frame
143  double DownPt[3]; // 3D point under cursor when mouse button pressed
144  double Center [3]; // center of camera rotation
145 
146  double WorldUpVector[3]; // what the world thinks the 'up' vector is
147 
148  vtkActor *FocusSphere; // geometry for indicating center of rotation
149  int IsDot; // flag-- is the FocusSphere being displayed?
150  vtkRenderer *FocusSphereRenderer; // renderer for 'FocusSphere'
151 
152  int state; // which navigation mode was selected?
153 
154  void ChooseXY( int X, int Y ); // method for choosing type of navigation
155  void RotateXY( int X, int Y ); // method for rotating
156  void DollyXY( int X, int Y ); // method for dollying
157  void PanXY( int X, int Y ); // method for panning
158 
159  // conveinence methods for translating & rotating the camera
160  void MyTranslateCamera(double v[3]);
161  void MyRotateCamera(double cx, double cy, double cz,
162  double ax, double ay, double az,
163  double angle);
164 
165  // Given a 3D point & a vtkCamera, compute the vectors that extend
166  // from the projection of the center of projection to the center of
167  // the right-edge and the center of the top-edge onto the plane
168  // containing the 3D point & with normal parallel to the camera's
169  // projection plane.
170  void GetRightVandUpV(double *p, vtkCamera *cam,
171  double *rightV, double *upV);
172 
173  // takes in pixels, returns normalized window coordinates
174  void NormalizeMouseXY(int X, int Y, double *NX, double *NY);
175 
176  // return the aspect ratio of the current window
177  double WindowAspect();
178 private:
179  vtkInteractorStyleUnicam(const vtkInteractorStyleUnicam&); // Not implemented.
180  void operator=(const vtkInteractorStyleUnicam&); // Not implemented.
181 };
182 
183 #endif // vtkInteractorStyleUnicam_h
184 
185 
186 
vtkgl::z
GLdouble GLdouble z
Definition: vtkgl.h:11754
vtkInteractorStyleUnicam::SetWorldUpVector
void SetWorldUpVector(double a[3])
Definition: vtkInteractorStyleUnicam.h:115
vtkInteractorStyle.h
vtkInteractorStyleUnicam::OnLeftButtonDown
virtual void OnLeftButtonDown()
vtkWorldPointPicker
find world x,y,z corresponding to display x,y,z
Definition: vtkWorldPointPicker.h:44
vtkInteractorStyleUnicam::FocusSphereRenderer
vtkRenderer * FocusSphereRenderer
Definition: vtkInteractorStyleUnicam.h:150
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkInteractorStyleUnicam::DTime
double DTime
Definition: vtkInteractorStyleUnicam.h:138
vtkgl::v
const GLdouble * v
Definition: vtkgl.h:11595
vtkgl::x
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
vtkInteractorStyleUnicam::New
static vtkInteractorStyleUnicam * New()
vtkGetVectorMacro
#define vtkGetVectorMacro(name, type, count)
Definition: vtkSetGet.h:424
vtkInteractorStyleUnicam::RotateXY
void RotateXY(int X, int Y)
vtkInteractorStyleUnicam::vtkInteractorStyleUnicam
vtkInteractorStyleUnicam()
VTKINTERACTIONSTYLE_EXPORT
#define VTKINTERACTIONSTYLE_EXPORT
Definition: vtkInteractionStyleModule.h:15
vtkInteractorStyleUnicam::state
int state
Definition: vtkInteractorStyleUnicam.h:152
vtkInteractorStyleUnicam::WindowAspect
double WindowAspect()
vtkInteractorStyleUnicam::FocusSphere
vtkActor * FocusSphere
Definition: vtkInteractorStyleUnicam.h:148
vtkInteractionStyleModule.h
vtkInteractorStyleUnicam::OnMouseMove
virtual void OnMouseMove()
vtkInteractorStyleUnicam::Dist
double Dist
Definition: vtkInteractorStyleUnicam.h:139
vtkInteractorStyleUnicam::MyTranslateCamera
void MyTranslateCamera(double v[3])
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkInteractorStyleUnicam::OnLeftButtonMove
virtual void OnLeftButtonMove()
vtkInteractorStyleUnicam::ChooseXY
void ChooseXY(int X, int Y)
vtkCamera
a virtual camera for 3D rendering
Definition: vtkCamera.h:49
vtkInteractorStyleUnicam::~vtkInteractorStyleUnicam
virtual ~vtkInteractorStyleUnicam()
vtkInteractorStyleUnicam::NormalizeMouseXY
void NormalizeMouseXY(int X, int Y, double *NX, double *NY)
vtkInteractorStyleUnicam::OnLeftButtonUp
virtual void OnLeftButtonUp()
vtkInteractorStyleUnicam::IsDot
int IsDot
Definition: vtkInteractorStyleUnicam.h:149
vtkgl::a
GLboolean GLboolean GLboolean GLboolean a
Definition: vtkgl.h:12312
vtkInteractorStyle
provide event-driven interface to the rendering window (defines trackball mode)
Definition: vtkInteractorStyle.h:136
vtkInteractorStyleUnicam::DollyXY
void DollyXY(int X, int Y)
vtkInteractorStyleUnicam::GetRightVandUpV
void GetRightVandUpV(double *p, vtkCamera *cam, double *rightV, double *upV)
vtkInteractorStyleUnicam::OnTimer
virtual void OnTimer()
vtkInteractorStyleUnicam::ButtonDown
int ButtonDown
Definition: vtkInteractorStyleUnicam.h:137
vtkInteractorStyleUnicam::PanXY
void PanXY(int X, int Y)
vtkgl::y
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
vtkInteractorStyleUnicam::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkInteractorStyleUnicam
provides Unicam navigation style
Definition: vtkInteractorStyleUnicam.h:109
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:64
vtkInteractorStyleUnicam::InteractionPicker
vtkWorldPointPicker * InteractionPicker
Definition: vtkInteractorStyleUnicam.h:135
vtkgl::angle
GLfloat angle
Definition: vtkgl.h:18174
vtkgl::p
GLfloat GLfloat p
Definition: vtkgl.h:15717
vtkInteractorStyleUnicam::SetWorldUpVector
void SetWorldUpVector(double x, double y, double z)
vtkInteractorStyleUnicam::MyRotateCamera
void MyRotateCamera(double cx, double cy, double cz, double ax, double ay, double az, double angle)