Computer Assisted Medical Intervention Tool Kit  version 6.0
Loading...
Searching...
No Matches
Transformation.h
Go to the documentation of this file.
1/*****************************************************************************
2 * $CAMITK_LICENCE_BEGIN$
3 *
4 * CamiTK - Computer Assisted Medical Intervention ToolKit
5 * (c) 2001-2025 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
6 *
7 * Visit http://camitk.imag.fr for more information
8 *
9 * This file is part of CamiTK.
10 *
11 * CamiTK is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
14 *
15 * CamiTK is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22 *
23 * $CAMITK_LICENCE_END$
24 ****************************************************************************/
25
26#ifndef CAMITK_TRANSFORMATION_H
27#define CAMITK_TRANSFORMATION_H
28
29// -- Core stuff
30#include "CamiTKAPI.h"
32
33// -- Qt stuff
34#include <QString>
35#include <QUuid>
36
37// -- VTK stuff
38#include <vtkMatrix4x4.h>
39#include <vtkAbstractTransform.h>
40#include <vtkTransform.h>
41#include <vtkSmartPointer.h>
42
43#include <memory>
44
45namespace camitk {
46
49
81class CAMITK_API Transformation: public InterfacePersistence {
82
83private:
85 friend TransformationManager;
86
90 Transformation(const std::shared_ptr<FrameOfReference>& from, const std::shared_ptr<FrameOfReference>& to, QUuid id = QUuid::createUuid());
91
95 Transformation(const std::shared_ptr<FrameOfReference>& from, const std::shared_ptr<FrameOfReference>& to, vtkSmartPointer<vtkTransform> tr, QUuid id = QUuid::createUuid());
96
102 void setMatrix(vtkSmartPointer<vtkMatrix4x4> m);
103
104public:
105
118 vtkSmartPointer<vtkTransform> getTransform() const;
119
132 vtkMatrix4x4* getMatrix() const;
133
137 QString getName() const;
138
142 void setName(QString n);
143
148 QString getDescription() const;
149
154 void setDescription(QString desc);
155
159 const FrameOfReference* getFrom() const;
160
164 const FrameOfReference* getTo() const;
165
168
171 QVariant toVariant() const override;
172
176 void fromVariant(const QVariant& v) override;
177
181 QUuid getUuid() const override;
182
188 bool setUuid(QUuid id) override;
189
191
192private:
193
200 Transformation* getInverse();
201
208 void setTransform(vtkSmartPointer<vtkTransform> tr);
209
213 void setTo(const std::shared_ptr<FrameOfReference>& f);
214
218 void setFrom(const std::shared_ptr<FrameOfReference>& f);
219
220private:
221
223 QUuid uuid;
224
226 QString name;
227
229 QString description;
230
232 bool inversible;
233
235 vtkSmartPointer<vtkTransform> transform;
236
238 std::shared_ptr<FrameOfReference> from;
239
241 std::shared_ptr<FrameOfReference> to;
242};
243
244// -------------------- getTransform --------------------
245inline vtkSmartPointer<vtkTransform> Transformation::getTransform() const {
246 return transform;
247}
248
249// -------------------- setName --------------------
250inline void Transformation::setName(QString n) {
251 name = n;
252}
253
254// -------------------- getDescription --------------------
255inline QString Transformation::getDescription() const {
256 return description;
257}
258
259// -------------------- setDescription --------------------
260inline void Transformation::setDescription(QString desc) {
261 description = desc;
262}
263
264// -------------------- getUuid --------------------
265inline QUuid Transformation::getUuid() const {
266 return uuid;
267};
268
269// -------------------- getFrom --------------------
271 return from.get();
272}
273
274// -------------------- setFrom --------------------
275inline void Transformation::setFrom(const std::shared_ptr<FrameOfReference>& f) {
276 from = f;
277}
278
279// -------------------- getTo --------------------
281 return to.get();
282}
283
284// -------------------- setTo --------------------
285inline void Transformation::setTo(const std::shared_ptr<FrameOfReference>& f) {
286 to = f;
287}
288
289
290} // namespace camitk
291
292#endif // CAMITK_TRANSFORMATION_H
#define CAMITK_API
Definition CamiTKAPI.h:66
FrameOfReference is only a label for an abstract coordinate system.
Definition FrameOfReference.h:69
Interface for all objects that should be serialized by the PersistenceManager.
Definition InterfacePersistence.h:38
TransformationManager manages frames of reference and transformations for a CamiTK Application.
Definition TransformationManager.h:233
void setName(QString n)
Set the name of the Transformation.
Definition Transformation.h:250
void fromVariant(const QVariant &v) override
Fill the Transformation from a QVariant.
Definition Transformation.cpp:119
QString getName() const
Get the name of the Transformation.
Definition Transformation.cpp:53
QString getDescription() const
Get the description of the Transformation Description is used to provide more information than the na...
Definition Transformation.h:255
const FrameOfReference * getFrom() const
Get the FrameOfReference the Transformation starts from (origin).
Definition Transformation.h:270
QUuid getUuid() const override
Get the unique identifier of this Transformation.
Definition Transformation.h:265
QVariant toVariant() const override
Convert the Transformation to a QVariant (for serializing).
Definition Transformation.cpp:99
vtkSmartPointer< vtkTransform > getTransform() const
Get the internal vtkTransform (linear transformation) or a nullptr.
Definition Transformation.h:245
void setDescription(QString desc)
Set the description of the Transformation Description is used to provide more information than the na...
Definition Transformation.h:260
vtkMatrix4x4 * getMatrix() const
Get the internal 4x4 matrix if the Transformation is linear, otherwise nullptr.
Definition Transformation.cpp:78
const FrameOfReference * getTo() const
Get the FrameOfReference that the Transformation goes to (destination).
Definition Transformation.h:280
bool setUuid(QUuid id) override
Set the unique identifier of this transformation if the current one is Null.
Definition Transformation.cpp:88
Definition Action.cpp:40