ALBA
albaGizmoScale.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaGizmoScale
5 Authors: 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
17#ifndef __albaGizmoScale_H__
18#define __albaGizmoScale_H__
19
20//----------------------------------------------------------------------------
21// Include:
22//----------------------------------------------------------------------------
23#include "albaEvent.h"
24#include "albaObserver.h"
25#include "albaGizmoInterface.h"
26#include "albaGUIGizmoScale.h"
27
28//----------------------------------------------------------------------------
29// forward references :
30//----------------------------------------------------------------------------
33class albaMatrix;
34class albaVME;
35class albaGUI;
36
67class ALBA_EXPORT albaGizmoScale: public albaGizmoInterface
68{
69public:
70 albaGizmoScale(albaVME *input, albaObserver* listener = NULL , bool buildGUI = true);
71 virtual ~albaGizmoScale();
72
75 void SetInput(albaVME *vme);
76
78 void SetRenderWindowHeightPercentage(double percentage);
79
81 void SetAutoscale(bool autoscale);
82
84 void SetAlwaysVisible(bool alwaysVisible);
85
86 //----------------------------------------------------------------------------
87 // events handling
88 //----------------------------------------------------------------------------
89
92 void OnEvent(albaEventBase *alba_event);
93
94 //----------------------------------------------------------------------------
95 // show
96 //----------------------------------------------------------------------------
97
100 void Show(bool show);
101 void Show(bool showX, bool showY, bool showZ, bool showIso);
102
105 void SetAbsPose(albaMatrix *absPose, albaTimeStamp ts = -1);
106
108
109 //----------------------------------------------------------------------------
110 // RefSys
111 //----------------------------------------------------------------------------
112
114 void SetRefSys(albaVME *refSys);
116
117 //----------------------------------------------------------------------------
118 // Gizmo Gui
119 //----------------------------------------------------------------------------
120 albaGUI *GetGui() {return (m_GuiGizmoScale->GetGui());};
121
122 bool GetApplyScaleToVME() const { return m_ApplyScaleToVME; }
123 void SetApplyScaleToVME(bool val) { m_ApplyScaleToVME = val; }
124
125protected:
126
128
131
134
137 enum AXIS {X = 0, Y, Z};
138 enum ACTIVE_COMPONENT {NONE = -1, X_AXIS = 0, Y_AXIS, Z_AXIS, ISOTROPIC};
139
142 void Highlight(int component);
143
145 albaGizmoScaleAxis *m_GSAxis[3];
146
148
152
155
156private:
157
160 bool m_BuildGUI;
161
162 bool m_ApplyScaleToVME;
163
164 double m_CurrentDist;
165 double m_ScaleDiff;
166
169 albaMatrix *m_InitialGizmoPose;
170
173 albaMatrix *m_VmeMatrixRelativeToRefSysVME;
174
177 albaMatrix *m_RefSysVMEAbsMatrixAtMouseDown;
178
181 double GetScalingValue();
182
183
186 void BuildVector(double *p1, double *p2, double *vec) const
187 {
188 if (vec)
189 {
190 vec[0] = p2[0] - p1[0];
191 vec[1] = p2[1] - p1[1];
192 vec[2] = p2[2] - p1[2];
193 }
194 }
195
198 friend class albaGizmoScaleTest;
199};
200#endif
201
202/*
203 //----------------------------------------------------------------------------
204 // Build the scale matrix from gizmo translation during mouse_move
205 //----------------------------------------------------------------------------
206
207
208 ^ ________
209 | | |
210 |----------| |
211 | | |------>X
212 |----------| |
213 | |________|
214 O
215
216 |-------------------|
217 gl0
218
219
220 ^ ________
221 | | |
222 | ----------| |
223 | | |------>X
224 | ----------| |
225 | |________|
226 O
227
228 |------------------------------|
229 gl1
230
231
232 S = gl1 / gl0
233
234 S: scale to be postmultiplyed at mouse up
235
236
237 //----------------------------------------------------------------------------
238 // Build matrix to be sent to listener operation given the scale matrix S
239 // to be applied relative to RS refsys to the vme
240 //----------------------------------------------------------------------------
241
242
243 ^
244 ^ |
245 | |
246 | --->
247 ^ ---> VME
248 | RS
249 |
250 --->
251 W
252
253 1) Express VME matrix in RS refsys via albaTransform
254 mflTr->SetInput(VME->GetAbsMatrix)
255 mflTr->SetSourceRefSys(W)
256 mflTr->SetTargetRefSys(RS)
257
258 VME_RS = mflTr->GetTransform();
259
260 2) Postmultiply scale matrix to VME_RS matrix
261 transform->PostMultiply()
262 transform->SetMatrix(VME_RS)
263 transform->Concatenate(S)
264
265 3) Express S * VME_RS in W refsys: this is new vme abs pose
266
267 mflTr->SetInput(S_x_VME_RS)
268 mflTr->SetSourceRefSys(RS)
269 mflTr->SetTargetRS(W)
270
271 NEW_VME_ABS_pose = mflTr->GetTransform();
272
273 - At this point i could set the abs pose to the vme
274
275 4) Build matrix to be sent to listening op if a matrix to be postmultiplied to the vme abs pose has to be created
276
277
278*/
double albaTimeStamp
type for time varying data timestamps (not for pipelines timestamps!)
Definition: albaDefines.h:57
Implementation of the message object for the Subject/Observer design pattern.
Definition: albaEventBase.h:49
GUI class for scaling gizmo.
albaGUI is a panel with function to easily create GUI.
Definition: albaGUI.h:110
Base class for operations and views gizmos.
Basic gizmo component used to perform constrained scaling along one axis.
Gizmo component used to perform isotropic scaling.
Gizmo used to perform constrained scaling along the x, yz axis or the xy, xz, yz plane.
void Show(bool show)
Show the gizmo.
void SetAlwaysVisible(bool alwaysVisible)
Superclass override.
bool GetApplyScaleToVME() const
void SetInput(albaVME *vme)
Set input vme for the gizmo.
void SendTransformMatrixFromGui(albaEventBase *alba_event)
Send matrix to postmultiply to listener.
void Highlight(int component)
Highlight one component and dehighlight other components.
void SetAutoscale(bool autoscale)
Superclass override.
AXIS
gizmo components enum
albaGUI * GetGui()
Return gui owned by the gizmo.
void SetAbsPose(albaMatrix *absPose, albaTimeStamp ts=-1)
Set the gizmo pose.
void SetRenderWindowHeightPercentage(double percentage)
Superclass override.
albaVME * GetRefSys()
albaMatrix * GetAbsPose()
Get the gizmo abs pose.
void OnEvent(albaEventBase *alba_event)
Events handling.
void SetApplyScaleToVME(bool val)
void OnEventGizmoGui(albaEventBase *alba_event)
Gizmo components events handling.
virtual ~albaGizmoScale()
void OnEventGizmoComponents(albaEventBase *alba_event)
Gizmo components events handling.
int m_ActiveGizmoComponent
Register the active gizmo component at MOUSE_DOWN.
albaGUIGizmoScale * m_GuiGizmoScale
albaGizmoScale(albaVME *input, albaObserver *listener=NULL, bool buildGUI=true)
void SetRefSys(albaVME *refSys)
Set the vme to be used as reference system, the vme is referenced; default ref sys is vme abs matrix.
void Show(bool showX, bool showY, bool showZ, bool showIso)
albaGizmoScaleIsotropic * m_GSIsotropic
albaMatrix - Time stamped 4x4 Matrix.
Definition: albaMatrix.h:44
Interface implementing the Observer of the Subject/Observer design pattern.
Definition: albaObserver.h:36
albaVME -
Definition: albaVME.h:150