Computer Assisted Medical Intervention Tool Kit  version 6.0
Loading...
Searching...
No Matches
FrameOfReference.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 FRAMEOFREFERENCE_H
27#define FRAMEOFREFERENCE_H
28
29// -- Core stuff
30#include "CamiTKAPI.h"
33
34#include <QString>
35#include <QUuid>
36#include <QColor>
37#include <QPair>
38
39namespace camitk {
40
42
49using Unit = QString;
50
69class CAMITK_API FrameOfReference: public InterfacePersistence {
70
71private:
72
74 friend TransformationManager;
75
83 FrameOfReference();
84
89 explicit FrameOfReference(QString name, QString description = "");
90
95 FrameOfReference(QUuid uuid, QString name, QString description, int numberOfDimensions, const AnatomicalOrientation& ao, std::vector<Unit>& units);
96
98 explicit FrameOfReference(const FrameOfReference&);
99
105 bool resetUuid(QUuid newId);
106
107public:
112
117
121 void setAnatomicalOrientation(const AnatomicalOrientation& anatomicalOrientation);
122
130 void setAnatomicalOrientation(QString threeLetterCode);
131
135 int getNumberOfDimensions() const;
136
144 void setNumberOfDimensions(int numberOfDimensions);
145
147 Unit getUnit(int dimension);
148
153 void setUnit(int dimension, Unit u);
154
158 QString getName() const;
159
165 void setName(QString name);
166
171 QString getDescription() const;
172
177 void setDescription(QString desc);
178
183 const QColor& getColor();
184
188 void setColor(const QColor& color);
189
196 QString getAnatomicalOrientationLabel(int axis, bool minDirection) const;
197
202 bool operator==(const FrameOfReference& b) const;
203
208 bool operator!=(const FrameOfReference& b) const;
209
212
215 QVariant toVariant() const override;
216
220 void fromVariant(const QVariant& variant) override;
221
226 bool setUuid(QUuid newId) override;
227
231 QUuid getUuid() const override;
233
238 int getIndex();
239
240
241private:
243 AnatomicalOrientation anatomicalOrientation;
244
246 std::vector<Unit> units = {"mm", "mm", "mm", "s", ""};
247
249 int numberOfDimensions = 3;
250
252 QUuid uuid;
253
256 int index;
257
259 QString name;
260
262 QString description;
263
268 QColor color;
269
270 // init color and index (only when required, i.e. in getIndex()/getColor() and not during initialization)
271 void init();
272
274 static QPair<QColor, int> getNextColorAndIndex();
275};
276
277// -------------------- getAnatomicalOrientation --------------------
279 return anatomicalOrientation;
280};
281
283 return anatomicalOrientation;
284};
285
286// -------------------- setAnatomicalOrientation --------------------
287inline void FrameOfReference::setAnatomicalOrientation(const AnatomicalOrientation& anatomicalOrientation) {
288 this->anatomicalOrientation = anatomicalOrientation;
289}
290
291// -------------------- setAnatomicalOrientation --------------------
292inline void FrameOfReference::setAnatomicalOrientation(QString threeLetterCode) {
293 anatomicalOrientation.setOrientation(threeLetterCode);
294}
295
296// -------------------- getNumberOfDimensions --------------------
298 return numberOfDimensions;
299}
300
301// -------------------- getName --------------------
302inline QString FrameOfReference::getName() const {
303 return name;
304}
305
306// -------------------- setName --------------------
307inline void FrameOfReference::setName(QString name) {
308 this->name = name;
309}
310
311// -------------------- getDescription --------------------
312inline QString FrameOfReference::getDescription() const {
313 return description;
314}
315
316// -------------------- setDescription --------------------
317inline void FrameOfReference::setDescription(QString desc) {
318 description = desc;
319}
320
321// -------------------- getAnatomicalOrientationLabel --------------------
322inline QString FrameOfReference::getAnatomicalOrientationLabel(int axis, bool minDirection) const {
323 return anatomicalOrientation.getLabel(axis, minDirection);
324}
325
326// -------------------- operator== --------------------
327inline bool FrameOfReference::operator==(const FrameOfReference& b) const {
328 return this->getUuid() == b.getUuid();
329}
330
331// -------------------- operator!= --------------------
332inline bool FrameOfReference::operator!=(const FrameOfReference& b) const {
333 return this->getUuid() != b.getUuid();
334}
335
336// -------------------- getUuid --------------------
337inline QUuid FrameOfReference::getUuid() const {
338 return uuid;
339}
340
341}
342
343#endif // FRAMEOFREFERENCE_H
#define CAMITK_API
Definition CamiTKAPI.h:66
Definition AnatomicalOrientation.h:81
void setOrientation(QString threeLetterCode)
Sets the orientation using the standard 3-letter code.
Definition AnatomicalOrientation.h:127
bool setUuid(QUuid newId) override
Set the unique identifier only if it is not already set.
Definition FrameOfReference.cpp:91
void setDescription(QString desc)
Set the description of the FrameOfReference.
Definition FrameOfReference.h:317
void setNumberOfDimensions(int numberOfDimensions)
Set the number of dimensions of this FrameOfReference.
Definition FrameOfReference.cpp:57
bool operator==(const FrameOfReference &b) const
Equality operator.
Definition FrameOfReference.h:327
void setColor(const QColor &color)
Set a color for graphical representation of the FrameOfReference.
Definition FrameOfReference.cpp:136
void fromVariant(const QVariant &variant) override
Load the Frame content from a QVariant.
Definition FrameOfReference.cpp:116
void setAnatomicalOrientation(const AnatomicalOrientation &anatomicalOrientation)
Set anatomical orientation information.
Definition FrameOfReference.h:287
QString getName() const
Get the FrameOfReference name.
Definition FrameOfReference.h:302
bool operator!=(const FrameOfReference &b) const
Difference operator.
Definition FrameOfReference.h:332
void setUnit(int dimension, Unit u)
Set the unit of one dimension.
Definition FrameOfReference.cpp:84
QVariant toVariant() const override
Convert the Frame to a QVariant for Persistence.
Definition FrameOfReference.cpp:102
void setName(QString name)
Set the name of the FrameOfReference Should be a short string, use setDescription if you want to stor...
Definition FrameOfReference.h:307
QUuid getUuid() const override
Get the unique identifier of the Frame.
Definition FrameOfReference.h:337
QString getAnatomicalOrientationLabel(int axis, bool minDirection) const
Get the Anatomical orientation label of the corresponding axis/direction (or empty string if there is...
Definition FrameOfReference.h:322
int getNumberOfDimensions() const
Get the number of dimensions of this FrameOfReference.
Definition FrameOfReference.h:297
Unit getUnit(int dimension)
get the unit of the given dimension if dimension is valid otherwise returns an invalid Unit
Definition FrameOfReference.cpp:74
int getIndex()
Get the index (a non-unique ID useful for user interaction) indexes start at 1.
Definition FrameOfReference.cpp:67
QString getDescription() const
Get the description of the FrameOfReference.
Definition FrameOfReference.h:312
const QColor & getColor()
Get the color for graphical representation of the FrameOfReference Set the color the first time this ...
Definition FrameOfReference.cpp:143
const AnatomicalOrientation & getAnatomicalOrientation() const
Get the anatomical information of the Frame.
Definition FrameOfReference.h:278
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
Definition Action.cpp:40
QString Unit
Unit is a type that defines the unit used by data (e.g.
Definition FrameOfReference.h:49