ALBA
albaInteractorConstraint.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaInteractorConstraint
5 Authors: Marco Petrone, Stefano Perticoni
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#ifndef __albaInteractorConstraint_h
17#define __albaInteractorConstraint_h
18
19#include "vtkALBASmartPointer.h"
20
21//----------------------------------------------------------------------------
22// forward declarations :
23//----------------------------------------------------------------------------
24class albaRefSys;
25class vtkDoubleArray;
26
27//----------------------------------------------------------------------------
28
47class ALBA_EXPORT albaInteractorConstraint
48{
49public:
52
55
56 //----------------------------------------------------------------------------
57 // Enums
58 //----------------------------------------------------------------------------
59
61 enum AXIS
62 {
63 X = 0,
65 Z,
67 };
68
70 enum PLANE
71 {
72 XY = 0,
76 };
77
80 {
81 LOCK = 0, // <No movement is allowed on/around the given axis
82 FREE, // <Move freely on/around the given axis
83 BOUNDS, // <Bounds constraint
84 SNAP_STEP, // <Snap on a given interval by a given step
85 SNAP_ARRAY, // <Snap on values provided in a given double array
86 };
87
88 //----------------------------------------------------------------------------
89 // Constraint modality settings
90 //----------------------------------------------------------------------------
91
96 void SetConstraintModality(int constraintModalityOnX, int constraintModalityOnY, int constraintModalityOnZ);
97
101 void SetConstraintModality(int axis, int constrainModality);
102
105
111
117
123
127 int GetConstraintPlaneAxes(int& axis1, int& axis2);
128
132 void Reset();
133
134 //----------------------------------------------------------------------------
135 // BOUNDS modality settings
136 //----------------------------------------------------------------------------
137
139 void SetLowerBound(int axis, double lbound);
140
142 double GetLowerBound(int axis);
143
145 void SetUpperBound(int axis, double ubound);
146
148 double GetUpperBound(int axis);
149
151 void SetBounds(int axis, double *bounds);
152
154 void GetBounds(int axis, double *bounds);
155
156 //----------------------------------------------------------------------------
157 // SNAP_STEP modality settings
158 //----------------------------------------------------------------------------
159
161 void SetMin(int axis, double min);
162
164 double GetMin(int axis);
165
167 void SetMax(int axis, double min);
168
170 double GetMax(int axis);
171
173 void SetStep(int axis, double step);
174
176 double GetStep(int axis);
177
179 void SetSnapStep(int axis, double min,double max, double step);
180
181 //----------------------------------------------------------------------------
182 // SNAP_ARRAY modality settings
183 //----------------------------------------------------------------------------
184
188 void SetSnapArray(int axis, vtkDoubleArray *array);
189
191 vtkDoubleArray *GetSnapArray(int axis);
192
193 //----------------------------------------------------------------------------
194 // Reference system settings
195 //----------------------------------------------------------------------------
196
200
202 void SetRefSys(albaRefSys *ref_sys);
203 void SetRefSys(albaRefSys &ref_sys);
204
205 //----------------------------------------------------------------------------
206
208 void Print(std::ostream& os, const int tabs);
209
210 void DeepCopy(const albaInteractorConstraint *source) { *this=*source;}
211
212protected:
213
216
218 int m_ConstraintModality[3];
219
221 double m_LowerBound[3];
222 double m_UpperBound[3];
223
225 double m_Min[3];
226 double m_Max[3];
227 double m_Step[3];
228
231
232};
233
234#endif
class representing a constraint for the interaction This class is used to store constraint modality p...
void SetStep(int axis, double step)
Set the step value for snap step constraint type for the given axis.
void SetRefSys(albaRefSys *ref_sys)
Copy the contents of another RefSys into the contraint one.
vtkDoubleArray * GetSnapArray(int axis)
Get the array which contains the allowed positions for snap.
void GetBounds(int axis, double *bounds)
Get the bounds interval.
void SetMax(int axis, double min)
Set the max value for snap step constraint type for the given axis.
int GetConstraintPlane()
Return the constraint plane ie an integer from the enum {XY= 0, XZ, YZ} when there are two degree of ...
double GetMin(int axis)
Get the min value for snap step constraint type for the given axis.
void SetMin(int axis, double min)
Set the min value for snap step constraint type for the given axis.
void SetLowerBound(int axis, double lbound)
Set the lower bound for bound constraint type for the given axis.
int GetConstraintModality(int axis)
Get the constraint modality for the given axis.
albaRefSys * m_RefSys
the constraint reference system
void SetConstraintModality(int constraintModalityOnX, int constraintModalityOnY, int constraintModalityOnZ)
Contrain on a specified axis, plane or unconstrained; allowed constraints are LOCK,...
void Reset()
Constraint modality is set to LOCK for all axes, all values of the element struct are set to 0 and po...
double GetStep(int axis)
Get the step value for snap step constraint type for the given axis.
void SetSnapStep(int axis, double min, double max, double step)
Set snap step modality parameters.
void SetBounds(int axis, double *bounds)
Set the bounds interval.
double GetMax(int axis)
Get the max value for snap step constraint type for the given axis.
double GetLowerBound(int axis)
Get the lower bound for bound constraint type for the given axis.
void SetConstraintModality(int axis, int constrainModality)
Set the constraint modality for the given axis; allowed constraint modality are: LOCK,...
void SetSnapArray(int axis, vtkDoubleArray *array)
Set the array which contains the allowed positions for snap.
void DeepCopy(const albaInteractorConstraint *source)
double GetUpperBound(int axis)
Get the upper bound for bound constraint type for the given axis.
int GetNumberOfDOF()
Get the number of axis on which movement is allowed (ie unlocked axis).
int GetConstraintPlaneAxes(int &axis1, int &axis2)
Return the constraint plane axes when there are two degree of freedom for the given movement type.
int GetConstraintAxis()
Return constraint axis when there is only one degree of freedom for the given movement type.
albaInteractorConstraint(const albaInteractorConstraint &source)
Copy constructor to allow object copy.
virtual ~albaInteractorConstraint()
void SetUpperBound(int axis, double ubound)
Set the upper bound for bound constraint type for the given axis.
void SetRefSys(albaRefSys &ref_sys)
CONSTRAINT_MODALITY
The possible constrained modalities for each axis.
albaRefSys * GetRefSys()
Get the constraint reference system, i.e.
void Print(std::ostream &os, const int tabs)
Debug printing of internal data.
class representing reference system
Definition: albaRefSys.h:49
Hold a reference to a vtkObjectBase instance.