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#include "vtkDoubleArray.h"
21//----------------------------------------------------------------------------
22// forward declarations :
23//----------------------------------------------------------------------------
24class albaRefSys;
25
26//----------------------------------------------------------------------------
27
46class ALBA_EXPORT albaInteractorConstraint
47{
48public:
51
54
55 //----------------------------------------------------------------------------
56 // Enums
57 //----------------------------------------------------------------------------
58
60 enum AXIS
61 {
62 X = 0,
64 Z,
66 };
67
69 enum PLANE
70 {
71 XY = 0,
75 };
76
79 {
80 LOCK = 0, // <No movement is allowed on/around the given axis
81 FREE, // <Move freely on/around the given axis
82 BOUNDS, // <Bounds constraint
83 SNAP_STEP, // <Snap on a given interval by a given step
84 SNAP_ARRAY, // <Snap on values provided in a given double array
85 };
86
87 //----------------------------------------------------------------------------
88 // Constraint modality settings
89 //----------------------------------------------------------------------------
90
95 void SetConstraintModality(int constraintModalityOnX, int constraintModalityOnY, int constraintModalityOnZ);
96
100 void SetConstraintModality(int axis, int constrainModality);
101
104
110
116
122
126 int GetConstraintPlaneAxes(int& axis1, int& axis2);
127
131 void Reset();
132
133 //----------------------------------------------------------------------------
134 // BOUNDS modality settings
135 //----------------------------------------------------------------------------
136
138 void SetLowerBound(int axis, double lbound);
139
141 double GetLowerBound(int axis);
142
144 void SetUpperBound(int axis, double ubound);
145
147 double GetUpperBound(int axis);
148
150 void SetBounds(int axis, double *bounds);
151
153 void GetBounds(int axis, double *bounds);
154
155 //----------------------------------------------------------------------------
156 // SNAP_STEP modality settings
157 //----------------------------------------------------------------------------
158
160 void SetMin(int axis, double min);
161
163 double GetMin(int axis);
164
166 void SetMax(int axis, double min);
167
169 double GetMax(int axis);
170
172 void SetStep(int axis, double step);
173
175 double GetStep(int axis);
176
178 void SetSnapStep(int axis, double min,double max, double step);
179
180 //----------------------------------------------------------------------------
181 // SNAP_ARRAY modality settings
182 //----------------------------------------------------------------------------
183
187 void SetSnapArray(int axis, vtkDoubleArray *array);
188
190 vtkDoubleArray *GetSnapArray(int axis);
191
192 //----------------------------------------------------------------------------
193 // Reference system settings
194 //----------------------------------------------------------------------------
195
199
201 void SetRefSys(albaRefSys *ref_sys);
202 void SetRefSys(albaRefSys &ref_sys);
203
204 //----------------------------------------------------------------------------
205
207 void Print(std::ostream& os, const int tabs);
208
209 void DeepCopy(const albaInteractorConstraint *source) { *this=*source;}
210
211protected:
212
215
217 int m_ConstraintModality[3];
218
220 double m_LowerBound[3];
221 double m_UpperBound[3];
222
224 double m_Min[3];
225 double m_Max[3];
226 double m_Step[3];
227
230
231};
232
233#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.