Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
mitkVectorProperty.h
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 #ifndef mitkVectorProperty_h
14 #define mitkVectorProperty_h
15 
16 // MITK
17 #include <MitkCoreExports.h>
18 #include <mitkBaseProperty.h>
19 
20 // STL
21 #include <vector>
22 
23 namespace mitk
24 {
31  template <typename D>
33  {
34  static const char *prefix() { return "Invalid"; }
35  };
36 
51  template <typename DATATYPE>
53  {
54  public:
55  typedef std::vector<DATATYPE> VectorType;
56 
57  // Manually expand most of mitkClassMacro:
58  // mitkClassMacro(VectorProperty<DATATYPE>, mitk::BaseProperty);
59  // This manual expansion is done to override explicitly
60  // the GetNameOfClass() and GetStaticNameOfClass() methods
65  std::vector<std::string> GetClassHierarchy() const override { return mitk::GetClassHierarchy<Self>(); }
69  static const char *GetStaticNameOfClass()
70  {
71  // concatenate a prefix dependent on the template type and our own classname
72  static std::string nameOfClass = std::string(VectorPropertyDataType<DATATYPE>::prefix()) + "VectorProperty";
73  return nameOfClass.c_str();
74  }
75 
76  const char *GetNameOfClass() const override { return this->GetStaticNameOfClass(); }
77  itkFactorylessNewMacro(Self);
78  itkCloneMacro(Self);
79 
88  std::string GetValueAsString() const override;
89 
91  virtual const VectorType &GetValue() const;
92 
94  virtual void SetValue(const VectorType &parameter_vector);
95 
96  bool ToJSON(nlohmann::json& j) const override;
97  bool FromJSON(const nlohmann::json& j) override;
98 
99  private:
101  VectorProperty &operator=(const Self &);
102 
104  itk::LightObject::Pointer InternalClone() const override;
105 
107  bool IsEqual(const BaseProperty &an_other_property) const override;
108 
110  bool Assign(const BaseProperty &an_other_property) override;
111 
113  VectorType m_PropertyContent;
114  };
115 
117 #define MITK_DECLARE_VECTOR_PROPERTY(TYPE, PREFIX) \
118  \
119  typedef VectorProperty<TYPE> PREFIX##VectorProperty; \
120  \
121  template <> \
122  \
123  struct VectorPropertyDataType<TYPE> \
124  { \
125  static const char *prefix() { return #PREFIX; } \
126  };
127 
129 #define MITK_DEFINE_VECTOR_PROPERTY(TYPE) template class VectorProperty<TYPE>;
130 
133 
134 } // namespace
135 
136 #endif
mitk::BaseProperty
Abstract base class for properties.
Definition: mitkBaseProperty.h:36
mitk::VectorProperty::Self
VectorProperty< DATATYPE > Self
Definition: mitkVectorProperty.h:61
mitk::FromJSON
MITKCORE_EXPORT void FromJSON(const nlohmann::json &j, AffineTransform3D::Pointer transform)
Read transform from JSON array (16 elements, resp. 4x4 matrix).
itk::SmartPointer< Self >
mitk::VectorProperty::GetNameOfClass
const char * GetNameOfClass() const override
Definition: mitkVectorProperty.h:76
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::VectorPropertyDataType::prefix
static const char * prefix()
Definition: mitkVectorProperty.h:34
mitk::VectorPropertyDataType
Helper for VectorProperty to determine a good ITK ClassName.
Definition: mitkVectorProperty.h:32
mitk::VectorProperty::SuperClass
BaseProperty SuperClass
Definition: mitkVectorProperty.h:62
json
nlohmann::json json
Definition: mitkModelTestFixture.h:29
MitkCoreExports.h
MITK_DECLARE_VECTOR_PROPERTY
#define MITK_DECLARE_VECTOR_PROPERTY(TYPE, PREFIX)
This should be used in .h files.
Definition: mitkVectorProperty.h:117
mitk::VectorProperty
Providing a std::vector as property.
Definition: mitkVectorProperty.h:52
mitk::VectorProperty::GetStaticNameOfClass
static const char * GetStaticNameOfClass()
Definition: mitkVectorProperty.h:69
mitk::ToJSON
MITKCORE_EXPORT void ToJSON(nlohmann::json &j, AffineTransform3D::ConstPointer transform)
Write transform (4x4 matrix) as JSON array with 16 elements.
mitk::VectorProperty::Pointer
itk::SmartPointer< Self > Pointer
Definition: mitkVectorProperty.h:63
mitk::VectorProperty::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: mitkVectorProperty.h:64
mitk::VectorProperty::GetClassHierarchy
std::vector< std::string > GetClassHierarchy() const override
Definition: mitkVectorProperty.h:65
mitkBaseProperty.h
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15
mitk::VectorProperty::VectorType
std::vector< DATATYPE > VectorType
Definition: mitkVectorProperty.h:55