ALBA
albaCameraTransform.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaCameraTransform
5 Authors: Marco Petrone
6
7 Copyright (c) BIC
8 All rights reserved. See Copyright.txt or
9
10
11 This software is distributed WITHOUT ANY WARRANTY; without even
12 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the above copyright notice for more information.
14
15=========================================================================*/
16
17#ifndef __albaCameraTransform_h
18#define __albaCameraTransform_h
19
20#include "albaTransformBase.h"
21
22//----------------------------------------------------------------------------
23// forward declarations :
24//----------------------------------------------------------------------------
25class vtkRenderer;
26class vtkTransform;
27class vtkCamera;
28class albaOBB;
29class vtkCallbackCommand;
30class vtkObject;
31
64class ALBA_EXPORT albaCameraTransform:public albaTransformBase
65{
66public:
69
71
73 {
76 ATTACH_TO_CLIPPING_PLANE
77 };
78
80 {
86 NUM_OF_MAPPINGS
87 };
88
90 {
92 PRESERVE_SIZE
93 };
94
96 void SetRenderer(vtkRenderer *ren);
97
99 vtkRenderer *GetRenderer() {return m_Renderer;}
100
104 void SetBounds(albaOBB *bounds) {m_Bounds=bounds;}
105 albaOBB *GetBounds() {return m_Bounds;}
106
108 void SetFollowPosition(int flag) {m_FollowPosition=flag;Modified();}
109 int GetFollowPosition() {return m_FollowPosition;}
110 void FollowPositionOn() {SetFollowPosition(true);}
111 void FollowPositionOff() {SetFollowPosition(false);}
112
114 void SetFollowOrientation(int flag) {m_FollowOrientation=flag;Modified();}
115 int GetFollowOrientation () {return m_FollowOrientation;}
116 void FollowOrientationOn() {SetFollowOrientation(true);}
117 void FollowOrientationOff() {SetFollowOrientation(false);}
118
120 void SetFollowScale(int flag) {m_FollowScale=flag;Modified();}
121 int GetFollowScale() {return m_FollowScale;}
122 void FollowScaleOn() {SetFollowScale(true);}
123 void FollowScaleOff() {SetFollowScale(false);}
124
126 void SetPositionMode(int type) {m_PositionMode=type;Modified();}
127 int GetPositionMode() {return m_PositionMode;}
128 void SetPositionModeToAttachToFocalPoint() {SetPositionMode(ATTACH_TO_FOCAL_POINT);}
129 void SetPositionModeToAttachToCamera() {SetPositionMode(ATTACH_TO_CAMERA);}
130 void SetPositionModeToAttachToClippingPlane() {SetPositionMode(ATTACH_TO_CLIPPING_PLANE);}
131
133 void SetScalingMode(int mode) {m_ScalingMode=mode;}
134 int GetScalingMode() {return m_ScalingMode;}
135
142
150
152 void SetFittingMode(int mode) {m_FittingMode=mode;Modified();}
153 int GetFittingMode() {return m_FittingMode;}
154
158 virtual unsigned long GetMTime();
159
160 virtual int DeepCopy(albaCameraTransform *trans);
161
163 void UpdatePoseMatrix(albaMatrix *matrix,albaMatrix *old_view_matrix, albaMatrix *new_view_matrix);
164
169 static void AutoOrientation(albaMatrix *matrix,vtkRenderer *ren);
170 void AutoOrientation() {AutoOrientation(m_Matrix,m_Renderer);}
171
175 static void AutoPosition(albaMatrix *matrix,vtkRenderer *ren, int mode=ATTACH_TO_FOCAL_POINT);
176 void AutoPosition() {AutoPosition(m_Matrix,m_Renderer,m_PositionMode);}
177
182 static void AutoFitting(albaMatrix *matrix,albaOBB *tracked_bounds,vtkRenderer *ren,int mode=MIN_SCALE);
183 void AutoFitting() {AutoFitting(m_Matrix,m_Bounds,m_Renderer,m_FittingMode);}
184
190 static void AutoFitting2(albaMatrix *matrix,albaOBB *tracked_bounds,vtkRenderer *ren,int mode=ANISOTROPIC);
191 void AutoFitting2() {AutoFitting2(m_Matrix,m_Bounds,m_Renderer,m_FittingMode);}
192
199 static void ComputeScaling(albaOBB *inBox, albaOBB *outBox,double *scale,int mode=MIN_SCALE);
200
202
203protected:
204
206 virtual void InternalUpdate();
207
208 static void InternalProcessEvents(vtkObject* sender, unsigned long channel, void* clientdata, void* calldata);
209
210 vtkRenderer* m_Renderer;
211 vtkCamera* m_Camera;
218
220
224
225 vtkCallbackCommand* m_EventRouter;
226
227private:
228 albaCameraTransform(const albaCameraTransform&); // Not implemented
229 void operator=(const albaCameraTransform&); // Not implemented
230};
231
232#endif /* __albaCameraTransform_h */
233
Implement transform between view coordinates to world coordinates.
virtual void InternalUpdate()
Updates the internal matrix.
int m_FollowPosition
Flag for enabling the translation according to camera position.
static void ComputeScaling(albaOBB *inBox, albaOBB *outBox, double *scale, int mode=MIN_SCALE)
Compute scale between two boxes according to given modality:
virtual unsigned long GetMTime()
Get the MTime: this is the bit of magic that makes everything work.
void SetScalingMode(int mode)
Set which kind of scaling should be applied to the transform.
int m_FollowScale
Flag for enabling the scaling according to camera frustum.
int m_ScalingMode
Kind of scaling policy (.
void SetPositionMode(int type)
Set the modality to fit the Z coordinate.
vtkRenderer * GetRenderer()
Return the renderer used as input for this transform.
@ ANISOTROPIC
set XYZ scales to fit exactly
@ MAX_SCALE
Select the maximum scale among X/Y (i.e. fit the minimum size)
@ FIT_X
Always fit the X axis.
@ FIT_Y
Always fit the Y axis.
@ MIN_SCALE
Select the minimum scale X/Y (i.e. fit the maximum size)
int m_FollowOrientation
Flag for enabling the re-orientation according to camera position.
void SetPositionModeToAttachToClippingPlane()
vtkCamera * m_Camera
this is to find if the render's active camera is changed
static void AutoFitting(albaMatrix *matrix, albaOBB *tracked_bounds, vtkRenderer *ren, int mode=MIN_SCALE)
Change matrix scale to create a transform making two boxes to fit.Translation and Orientation are lef...
virtual ~albaCameraTransform()
vtkRenderer * m_Renderer
This stores the renderer used as input.
void SetRenderer(vtkRenderer *ren)
Set the renderer used as input for this transform.
virtual int DeepCopy(albaCameraTransform *trans)
static void AutoPosition(albaMatrix *matrix, vtkRenderer *ren, int mode=ATTACH_TO_FOCAL_POINT)
change matrix translation to create a transform making points to be centered into the camera's focal ...
void SetFollowOrientation(int flag)
Enable/Disable following of the camera orientation.
void SetBounds(albaOBB *bounds)
Set the bounds of the object that should follow the camera.
void SetPositionModeToAttachToFocalPoint()
void SetScalingModeToAutoFitting()
Set scaling mode to AUTO_FITTING: the transform try to fit the given m_Bounds (see SetBounds() ) to t...
@ ATTACH_TO_FOCAL_POINT
Follow the focal point.
@ ATTACH_TO_CAMERA
Follow the camera position.
void SetFollowPosition(int flag)
Enable/Disable following of the camera position.
void SetFittingMode(int mode)
set which kind of AutoFitting strategy should be used
vtkCallbackCommand * m_EventRouter
void SetScalingModeToPreserveSize()
(not yet implemented) Set scaling mode to PRESERVE_SIZE.
int m_FittingMode
Kind of scaling used to fit the view frustum.
int m_PositionMode
Modality defining the rule to set the position with respect to the camera.
static void InternalProcessEvents(vtkObject *sender, unsigned long channel, void *clientdata, void *calldata)
void UpdatePoseMatrix(albaMatrix *matrix, albaMatrix *old_view_matrix, albaMatrix *new_view_matrix)
Change the given matrix to follow camera movements.
static void AutoOrientation(albaMatrix *matrix, vtkRenderer *ren)
change matrix orientation to create a transform making points to be oriented according to camera orie...
albaOBB * m_Bounds
m_Bounds of the object that should follow the camera
@ AUTO_FITTING
scale the bounds to fit the camera frustum
static void AutoFitting2(albaMatrix *matrix, albaOBB *tracked_bounds, vtkRenderer *ren, int mode=ANISOTROPIC)
Change matrix scale to create a transform making two boxes to fit.
void SetFollowScale(int flag)
Enable/Disable following of the camera scaling.
albaTypeMacro(albaCameraTransform, albaTransformBase)
albaMatrix - Time stamped 4x4 Matrix.
Definition: albaMatrix.h:44
This class simply stores a Box boundary (i.e.
Definition: albaOBB.h:37
Superclass for Homogeneous transformations.
void Modified()
update modification time stamp for this object