Medical Imaging Interaction Toolkit  2018.4.99-4c24e3cb
Medical Imaging Interaction Toolkit
mitkAnnotationProperty.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "mitkAnnotationProperty.h"
14 
16 {
17 }
18 
19 mitk::AnnotationProperty::AnnotationProperty(const char *label, const Point3D &position)
20  : m_Label(""), m_Position(position)
21 {
22  if (label != nullptr)
23  {
24  m_Label = label;
25  }
26 }
27 
28 mitk::AnnotationProperty::AnnotationProperty(const std::string &label, const Point3D &position)
29  : m_Label(label), m_Position(position)
30 {
31 }
32 
34 {
35  if (label != nullptr)
36  {
37  m_Label = label;
38  }
39 
40  m_Position[0] = x;
41  m_Position[1] = y;
42  m_Position[2] = z;
43 }
44 
46  : m_Label(label)
47 {
48  m_Position[0] = x;
49  m_Position[1] = y;
50  m_Position[2] = z;
51 }
52 
54  : BaseProperty(other), m_Label(other.m_Label), m_Position(other.m_Position)
55 {
56 }
57 
59 {
60  return m_Position;
61 }
62 
64 {
65  if (m_Position != position)
66  {
67  m_Position = position;
68  this->Modified();
69  }
70 }
71 
72 bool mitk::AnnotationProperty::IsEqual(const BaseProperty &property) const
73 {
74  return ((this->m_Label == static_cast<const Self &>(property).m_Label) &&
75  (this->m_Position == static_cast<const Self &>(property).m_Position));
76 }
77 
78 bool mitk::AnnotationProperty::Assign(const BaseProperty &property)
79 {
80  this->m_Label = static_cast<const Self &>(property).m_Label;
81  this->m_Position = static_cast<const Self &>(property).m_Position;
82  return true;
83 }
84 
86 {
87  std::stringstream myStr;
88 
89  myStr << this->GetLabel() << this->GetPosition();
90  return myStr.str();
91 }
92 
93 itk::LightObject::Pointer mitk::AnnotationProperty::InternalClone() const
94 {
95  itk::LightObject::Pointer result(new Self(*this));
96  result->UnRegister();
97  return result;
98 }
double ScalarType
std::string GetValueAsString() const override
Abstract base class for properties.
Property for annotations.
virtual const char * GetLabel() const
const Point3D & GetPosition() const
void SetPosition(const Point3D &position)