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 "vtkInteractorStyle.h"
83 
84 class vtkCamera;
86 
87 //
88 // XXX - would have preferred to make these enumerations within the class,
89 // enum { NONE=0, BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT };
90 // enum {CAM_INT_ROT, CAM_INT_CHOOSE, CAM_INT_PAN, CAM_INT_DOLLY};
91 // but vtkWrapTcl signaled a "syntax error" when it parsed the 'enum' line.
92 // So, am making them defines which is what the other classes that want
93 // to have constants appear to do.
94 //
95 // buttons pressed
96 #define VTK_UNICAM_NONE 0
97 #define VTK_UNICAM_BUTTON_LEFT 1
98 #define VTK_UNICAM_BUTTON_MIDDLE 2
99 #define VTK_UNICAM_BUTTON_RIGHT 3
100 //
101 // camera modes
102 #define VTK_UNICAM_CAM_INT_ROT 0
103 #define VTK_UNICAM_CAM_INT_CHOOSE 1
104 #define VTK_UNICAM_CAM_INT_PAN 2
105 #define VTK_UNICAM_CAM_INT_DOLLY 3
106 
108 {
109 public:
110  static vtkInteractorStyleUnicam *New();
112  void PrintSelf(ostream& os, vtkIndent indent);
113 
114  void SetWorldUpVector(double a[3]) {this->SetWorldUpVector(a[0],a[1],a[2]);}
115  void SetWorldUpVector(double x, double y, double z);
116  vtkGetVectorMacro(WorldUpVector, double, 3);
117 
119 
120  virtual void OnMouseMove();
121  virtual void OnLeftButtonDown();
122  virtual void OnLeftButtonUp();
123  virtual void OnLeftButtonMove();
125 
128  virtual void OnTimer();
129 
130 protected:
132  virtual ~vtkInteractorStyleUnicam();
133 
135 
136  int ButtonDown; // which button is down
137  double DTime; // time mouse button was pressed
138  double Dist; // distance the mouse has moved since button press
139  double StartPix[2]; // pixel mouse movement started at
140  double LastPos[2]; // normalized position of mouse last frame
141  double LastPix[2]; // pixel position of mouse last frame
142  double DownPt[3]; // 3D point under cursor when mouse button pressed
143  double Center [3]; // center of camera rotation
144 
145  double WorldUpVector[3]; // what the world thinks the 'up' vector is
146 
147  vtkActor *FocusSphere; // geometry for indicating center of rotation
148  int IsDot; // flag-- is the FocusSphere being displayed?
149  vtkRenderer *FocusSphereRenderer; // renderer for 'FocusSphere'
150 
151  int state; // which navigation mode was selected?
152 
153  void ChooseXY( int X, int Y ); // method for choosing type of navigation
154  void RotateXY( int X, int Y ); // method for rotating
155  void DollyXY( int X, int Y ); // method for dollying
156  void PanXY( int X, int Y ); // method for panning
157 
158  // conveinence methods for translating & rotating the camera
159  void MyTranslateCamera(double v[3]);
160  void MyRotateCamera(double cx, double cy, double cz,
161  double ax, double ay, double az,
162  double angle);
163 
164  // Given a 3D point & a vtkCamera, compute the vectors that extend
165  // from the projection of the center of projection to the center of
166  // the right-edge and the center of the top-edge onto the plane
167  // containing the 3D point & with normal parallel to the camera's
168  // projection plane.
169  void GetRightVandUpV(double *p, vtkCamera *cam,
170  double *rightV, double *upV);
171 
172  // takes in pixels, returns normalized window coordinates
173  void NormalizeMouseXY(int X, int Y, double *NX, double *NY);
174 
175  // return the aspect ratio of the current window
176  double WindowAspect();
177 private:
178  vtkInteractorStyleUnicam(const vtkInteractorStyleUnicam&); // Not implemented.
179  void operator=(const vtkInteractorStyleUnicam&); // Not implemented.
180 };
181 
182 #endif // __vtkInteractorStyleUnicam_h
183 
184 
185 
virtual void OnLeftButtonDown()
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:49
virtual void OnLeftButtonUp()
static vtkInteractorStyle * New()
abstract specification for renderers
Definition: vtkRenderer.h:69
vtkWorldPointPicker * InteractionPicker
virtual void OnTimer()
void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:37
a virtual camera for 3D rendering
Definition: vtkCamera.h:47
#define VTK_RENDERING_EXPORT
provides Unicam navigation style
provide event-driven interface to the rendering window (defines trackball mode)
find world x,y,z corresponding to display x,y,z
virtual void OnMouseMove()