Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkClippingProperty.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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkClippingProperty.h"
18 
19 namespace mitk
20 {
21  ClippingProperty::ClippingProperty() : m_ClippingEnabled(false), m_Origin(0.0), m_Normal(0.0) {}
23  : BaseProperty(other),
24  m_ClippingEnabled(other.m_ClippingEnabled),
25  m_Origin(other.m_Origin),
26  m_Normal(other.m_Normal)
27  {
28  }
29 
30  ClippingProperty::ClippingProperty(const Point3D &origin, const Vector3D &normal)
31  : m_ClippingEnabled(true), m_Origin(origin), m_Normal(normal)
32  {
33  }
34 
37  {
38  if (m_ClippingEnabled != enabled)
39  {
40  m_ClippingEnabled = enabled;
41  this->Modified();
42  }
43  }
44 
45  const Point3D &ClippingProperty::GetOrigin() const { return m_Origin; }
47  {
48  if (m_Origin != origin)
49  {
50  m_Origin = origin;
51  this->Modified();
52  }
53  }
54 
55  const Vector3D &ClippingProperty::GetNormal() const { return m_Normal; }
57  {
58  if (m_Normal != normal)
59  {
60  m_Normal = normal;
61  this->Modified();
62  }
63  }
64 
65  bool ClippingProperty::IsEqual(const BaseProperty &property) const
66  {
67  return ((this->m_ClippingEnabled == static_cast<const Self &>(property).m_ClippingEnabled) &&
68  (this->m_Origin == static_cast<const Self &>(property).m_Origin) &&
69  (this->m_Normal == static_cast<const Self &>(property).m_Normal));
70  }
71 
72  bool ClippingProperty::Assign(const BaseProperty &property)
73  {
74  this->m_ClippingEnabled = static_cast<const Self &>(property).m_ClippingEnabled;
75  this->m_Origin = static_cast<const Self &>(property).m_Origin;
76  this->m_Normal = static_cast<const Self &>(property).m_Normal;
77  return true;
78  }
79 
81  {
82  std::stringstream myStr;
83 
84  myStr << this->GetClippingEnabled() << this->GetOrigin() << this->GetNormal();
85  return myStr.str();
86  }
87 
88  itk::LightObject::Pointer ClippingProperty::InternalClone() const
89  {
90  itk::LightObject::Pointer result(new Self(*this));
91  result->UnRegister();
92  return result;
93  }
94 
95 } // namespace
itk::SmartPointer< Self > Pointer
Property for clipping datasets; currently only clipping planes are possible.
DataCollection - Class to facilitate loading/accessing structured data.
Abstract base class for properties.
const Vector3D & GetNormal() const
void SetOrigin(const Point3D &origin)
void SetClippingEnabled(bool enabled)
const Point3D & GetOrigin() const
void SetNormal(const Vector3D &normal)
virtual std::string GetValueAsString() const override