26#ifndef ANATOMICALORIENTATION_H
27#define ANATOMICALORIENTATION_H
30#include <QVariantList>
105 AnatomicalOrientation(QString minXLabel, QString maxXLabel, QString minYLabel, QString maxYLabel, QString minZLabel, QString maxZLabel) {
106 setOrientation(minXLabel, maxXLabel, minYLabel, maxYLabel, minZLabel, maxZLabel);
130 if (this->set3LetterCode(threeLetterCode)) {
142 void setOrientation(QString minXLabel, QString maxXLabel, QString minYLabel, QString maxYLabel, QString minZLabel, QString maxZLabel) {
144 minLabels = {minXLabel, minYLabel, minZLabel};
145 maxLabels = {maxXLabel, maxYLabel, maxZLabel};
153 if (axis >= 0 && axis < 3) {
155 minLabels[axis] = minLabel;
164 if (axis >= 0 && axis < 3) {
166 maxLabels[axis] = maxLabel;
176 void setLabels(
int axis, QString minLabel, QString maxLabel) {
185 if (axis >= 0 && axis < 3) {
186 return minLabels[axis];
197 if (axis >= 0 && axis < 3) {
198 return maxLabels[axis];
218 for (
unsigned int ax = 0; ax < 3; ++ax) {
219 if (minLabels[ax] == name) {
222 else if (maxLabels[ax] == name) {
234 QString invertedCode = code;
235 for (
int i = 0; i < code.size(); ++i) {
236 if (code[i] ==
'R') {
237 invertedCode[i] =
'L';
239 else if (code[i] ==
'L') {
240 invertedCode[i] =
'R';
242 else if (code[i] ==
'A') {
243 invertedCode[i] =
'P';
245 else if (code[i] ==
'P') {
246 invertedCode[i] =
'A';
248 else if (code[i] ==
'I') {
249 invertedCode[i] =
'S';
251 else if (code[i] ==
'S') {
252 invertedCode[i] =
'I';
254 else if (code[i] ==
'F') {
255 invertedCode[i] =
'H';
257 else if (code[i] ==
'H') {
258 invertedCode[i] =
'F';
272 if (!known || code.isEmpty()) {
277 plusCode.append(
'+');
291 QString
getLabel(
int axis,
bool minDirection)
const {
292 if (axis >= 0 && axis < 3) {
293 return minDirection ? minLabels[axis] : maxLabels[axis];
308 {
"minLabels", QVariantList{minLabels[0], minLabels[1], minLabels[2]}},
309 {
"maxLabels", QVariantList{maxLabels[0], maxLabels[1], maxLabels[2]}},
313 return QVariantMap();
323 QVariantMap map = variant.toMap();
325 if (map.contains(
"code")) {
327 code = map.value(
"code").toString();
330 if (map.contains(
"minLabels") && map.contains(
"maxLabels")) {
333 list = map.value(
"minLabels").toList();
334 if (list.size() == 3) {
335 minLabels[0] = list[0].toString();
336 minLabels[1] = list[1].toString();
337 minLabels[2] = list[2].toString();
343 list = map.value(
"maxLabels").toList();
344 if (list.size() == 3) {
345 maxLabels[0] = list[0].toString();
346 maxLabels[1] = list[1].toString();
347 maxLabels[2] = list[2].toString();
354 if (code.isEmpty()) {
359 set3LetterCode(code);
384 std::array<QString, 3> minLabels;
387 std::array<QString, 3> maxLabels;
406 bool set3LetterCode(QString code =
"",
bool forcePlus =
false) {
407 if (code.size() < 3 || code.size() > 4) {
410 if ((code.size() > 3 && code[3] ==
'+') || forcePlus) {
416 this->code.truncate(3);
418 minLabels[0] = code[0];
419 minLabels[1] = code[1];
420 minLabels[2] = code[2];
421 maxLabels[0] = invertedCode[0];
422 maxLabels[1] = invertedCode[1];
423 maxLabels[2] = invertedCode[2];
AnatomicalOrientation describes the relationship between 3D axes of a FrameOfReference and medical im...
Definition AnatomicalOrientation.h:83
AnatomicalOrientation(QString minXLabel, QString maxXLabel, QString minYLabel, QString maxYLabel, QString minZLabel, QString maxZLabel)
Constructor setting a custom label for each axis negative and positive directions.
Definition AnatomicalOrientation.h:105
void setMaxLabel(int axis, QString maxLabel)
Set the label of the corresponding axis positive direction.
Definition AnatomicalOrientation.h:163
bool setUuid(QUuid newid) override
SetUuid does nothing It does not store the uuid, but is needed to implement InterfacePersistence.
Definition AnatomicalOrientation.h:369
QString getMaxLabel(int axis) const
Get the label of the positive/maximum direction of the specified axis.
Definition AnatomicalOrientation.h:196
QString getLabel(int axis, bool minDirection) const
Returns the label of the corresponding axis/direction (or empty string if there is no label)
Definition AnatomicalOrientation.h:291
QString getMinLabel(int axis) const
Get the label of the negative/minimum direction of the specified axis.
Definition AnatomicalOrientation.h:184
void setOrientation(QString threeLetterCode)
Sets the orientation using the standard 3-letter code.
Definition AnatomicalOrientation.h:129
void setLabels(int axis, QString minLabel, QString maxLabel)
Set both negative and positive direction labels for an axis.
Definition AnatomicalOrientation.h:176
QString get3LetterCode(bool plus=false) const
Return the current 3 letter code or an empty string if it is unknown or custom.
Definition AnatomicalOrientation.h:271
void setUnkown()
Reset anatomical information to unknown.
Definition AnatomicalOrientation.h:112
QVariant toVariant() const override
Convert all data from the object to a QVariantMap.
Definition AnatomicalOrientation.h:304
bool isUnknown() const
Check if anatomical information is unknown.
Definition AnatomicalOrientation.h:122
AnatomicalOrientation()
Default constructor.
Definition AnatomicalOrientation.h:91
AnatomicalOrientation(QString threeLetterCode)
Constructor from a 3-letter code (e.g.
Definition AnatomicalOrientation.h:98
void setOrientation(QString minXLabel, QString maxXLabel, QString minYLabel, QString maxYLabel, QString minZLabel, QString maxZLabel)
Set a custom label for the negative and positive directions of all axes.
Definition AnatomicalOrientation.h:142
void fromVariant(const QVariant &variant) override
Load data from a QVariant to initialize the current object.
Definition AnatomicalOrientation.h:320
QUuid getUuid() const override
Returns an invalid uuid because AnatomicalOrientation is part of a FrameOfReference which has its own...
Definition AnatomicalOrientation.h:377
static QString invert3LetterCode(const QString &code)
Returns the inverted 3-letter code (e.g.
Definition AnatomicalOrientation.h:233
void setMinLabel(int axis, QString minLabel)
Set the label of the corresponding axis negative direction.
Definition AnatomicalOrientation.h:152
std::pair< int, bool > getAxisFromName(QString name) const
Definition AnatomicalOrientation.h:217
Interface for all objects that should be serialized by the PersistenceManager.
Definition InterfacePersistence.h:38