CustusX  18.04
An IGT application
cxPlaneTypeCollection.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 #include "cxPlaneTypeCollection.h"
12 
13 #include "cxDefinitionStrings.h"
14 #include <iostream>
15 
16 namespace cx
17 {
18 
19 PlaneTypeCollection::PlaneTypeCollection(std::vector<PLANE_TYPE> planes) :
20  mPlanes(planes)
21 {
22 }
23 
24 std::vector<PLANE_TYPE> PlaneTypeCollection::get() const
25 {
26  return mPlanes;
27 }
28 
29 void PlaneTypeCollection::add(PLANE_TYPE plane)
30 {
31  if (plane!=ptCOUNT)
32  mPlanes.push_back(plane);
33 }
34 
35 PlaneTypeCollection::PlaneTypeCollection(PLANE_TYPE a, PLANE_TYPE b, PLANE_TYPE c)
36 {
37  this->add(a);
38  this->add(b);
39  this->add(c);
40 }
41 
43 {
44  std::vector<PLANE_TYPE> planes;
45  QStringList planeText = input.split("/");
46  for (unsigned i=0; i<planeText.size(); ++i)
47  {
48  PLANE_TYPE plane = string2enum<PLANE_TYPE>(planeText[i]);
49  if (plane!=ptCOUNT)
50  planes.push_back(plane);
51  }
52 
53  if (planes.empty())
54  return defVal;
55 
56  return PlaneTypeCollection(planes);
57 }
58 
60 {
61  QStringList planeText;
62  for (unsigned i=0; i<mPlanes.size(); ++i)
63  planeText << enum2string(mPlanes[i]);
64  QString retval = planeText.join("/");
65  return retval;
66 }
67 
68 
69 } // namespace cx
70 
71 
static PlaneTypeCollection fromString(QString input, PlaneTypeCollection defVal=PlaneTypeCollection())
PlaneTypeCollection(std::vector< PLANE_TYPE > planes)
std::vector< PLANE_TYPE > get() const
void add(PLANE_TYPE plane)
QString enum2string(const ENUM &val)
Namespace for all CustusX production code.