26#ifndef ANATOMICALORIENTATION_H
27#define ANATOMICALORIENTATION_H
30#include <QVariantList>
103 AnatomicalOrientation(QString minXLabel, QString maxXLabel, QString minYLabel, QString maxYLabel, QString minZLabel, QString maxZLabel) {
104 setOrientation(minXLabel, maxXLabel, minYLabel, maxYLabel, minZLabel, maxZLabel);
128 if (this->set3LetterCode(threeLetterCode)) {
140 void setOrientation(QString minXLabel, QString maxXLabel, QString minYLabel, QString maxYLabel, QString minZLabel, QString maxZLabel) {
142 minLabels = {minXLabel, minYLabel, minZLabel};
143 maxLabels = {maxXLabel, maxYLabel, maxZLabel};
151 if (axis >= 0 && axis < 3) {
153 minLabels[axis] = minLabel;
162 if (axis >= 0 && axis < 3) {
164 maxLabels[axis] = maxLabel;
174 void setLabels(
int axis, QString minLabel, QString maxLabel) {
183 if (axis >= 0 && axis < 3) {
184 return minLabels[axis];
195 if (axis >= 0 && axis < 3) {
196 return maxLabels[axis];
216 for (
unsigned int ax = 0; ax < 3; ++ax) {
217 if (minLabels[ax] == name) {
220 else if (maxLabels[ax] == name) {
232 QString invertedCode = code;
233 for (
int i = 0; i < code.size(); ++i) {
234 if (code[i] ==
'R') {
235 invertedCode[i] =
'L';
237 else if (code[i] ==
'L') {
238 invertedCode[i] =
'R';
240 else if (code[i] ==
'A') {
241 invertedCode[i] =
'P';
243 else if (code[i] ==
'P') {
244 invertedCode[i] =
'A';
246 else if (code[i] ==
'I') {
247 invertedCode[i] =
'S';
249 else if (code[i] ==
'S') {
250 invertedCode[i] =
'I';
252 else if (code[i] ==
'F') {
253 invertedCode[i] =
'H';
255 else if (code[i] ==
'H') {
256 invertedCode[i] =
'F';
270 if (!known || code.isEmpty()) {
275 plusCode.append(
'+');
289 QString
getLabel(
int axis,
bool minDirection)
const {
290 if (axis >= 0 && axis < 3) {
291 return minDirection ? minLabels[axis] : maxLabels[axis];
306 {
"minLabels", QVariantList{minLabels[0], minLabels[1], minLabels[2]}},
307 {
"maxLabels", QVariantList{maxLabels[0], maxLabels[1], maxLabels[2]}},
311 return QVariantMap();
321 QVariantMap map = variant.toMap();
323 if (map.contains(
"code")) {
325 code = map.value(
"code").toString();
328 if (map.contains(
"minLabels") && map.contains(
"maxLabels")) {
331 list = map.value(
"minLabels").toList();
332 if (list.size() == 3) {
333 minLabels[0] = list[0].toString();
334 minLabels[1] = list[1].toString();
335 minLabels[2] = list[2].toString();
341 list = map.value(
"maxLabels").toList();
342 if (list.size() == 3) {
343 maxLabels[0] = list[0].toString();
344 maxLabels[1] = list[1].toString();
345 maxLabels[2] = list[2].toString();
352 if (code.isEmpty()) {
357 set3LetterCode(code);
382 std::array<QString, 3> minLabels;
385 std::array<QString, 3> maxLabels;
404 bool set3LetterCode(QString code =
"",
bool forcePlus =
false) {
405 if (code.size() < 3 || code.size() > 4) {
408 if ((code.size() > 3 && code[3] ==
'+') || forcePlus) {
414 this->code.truncate(3);
416 minLabels[0] = code[0];
417 minLabels[1] = code[1];
418 minLabels[2] = code[2];
419 maxLabels[0] = invertedCode[0];
420 maxLabels[1] = invertedCode[1];
421 maxLabels[2] = invertedCode[2];
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:103
void setMaxLabel(int axis, QString maxLabel)
Set the label of the corresponding axis positive direction.
Definition AnatomicalOrientation.h:161
bool setUuid(QUuid newid) override
SetUuid does nothing It does not store the uuid, but is needed to implement InterfacePersistence.
Definition AnatomicalOrientation.h:367
QString getMaxLabel(int axis) const
Get the label of the positive/maximum direction of the specified axis.
Definition AnatomicalOrientation.h:194
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:289
QString getMinLabel(int axis) const
Get the label of the negative/minimum direction of the specified axis.
Definition AnatomicalOrientation.h:182
void setOrientation(QString threeLetterCode)
Sets the orientation using the standard 3-letter code.
Definition AnatomicalOrientation.h:127
void setLabels(int axis, QString minLabel, QString maxLabel)
Set both negative and positive direction labels for an axis.
Definition AnatomicalOrientation.h:174
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:269
void setUnkown()
Reset anatomical information to unknown.
Definition AnatomicalOrientation.h:110
QVariant toVariant() const override
Convert all data from the object to a QVariantMap.
Definition AnatomicalOrientation.h:302
bool isUnknown() const
Check if anatomical information is unknown.
Definition AnatomicalOrientation.h:120
AnatomicalOrientation()
Default constructor.
Definition AnatomicalOrientation.h:89
AnatomicalOrientation(QString threeLetterCode)
Constructor from a 3-letter code (e.g.
Definition AnatomicalOrientation.h:96
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:140
void fromVariant(const QVariant &variant) override
Load data from a QVariant to initialize the current object.
Definition AnatomicalOrientation.h:318
QUuid getUuid() const override
Returns an invalid uuid because AnatomicalOrientation is part of a FrameOfReference which has its own...
Definition AnatomicalOrientation.h:375
static QString invert3LetterCode(const QString &code)
Returns the inverted 3-letter code (e.g.
Definition AnatomicalOrientation.h:231
void setMinLabel(int axis, QString minLabel)
Set the label of the corresponding axis negative direction.
Definition AnatomicalOrientation.h:150
std::pair< int, bool > getAxisFromName(QString name) const
Definition AnatomicalOrientation.h:215
Interface for all objects that should be serialized by the PersistenceManager.
Definition InterfacePersistence.h:38