Medical Imaging Interaction Toolkit  2025.12.02
Medical Imaging Interaction Toolkit
mitkTemporoSpatialStringProperty.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 mitkTemporoSpatialStringProperty_h
14 #define mitkTemporoSpatialStringProperty_h
15 
16 #include <itkConfigure.h>
17 
18 #include "mitkBaseProperty.h"
19 #include <MitkCoreExports.h>
20 
21 #include "mitkTimeGeometry.h"
22 
23 #include <string>
24 
25 namespace mitk
26 {
27 #ifdef _MSC_VER
28 #pragma warning(push)
29 #pragma warning(disable : 4522)
30 #endif
31 
37  {
38  public:
39  typedef ::itk::IndexValueType IndexValueType;
40  typedef std::string ValueType;
41 
43 
44  itkFactorylessNewMacro(Self);
45 
46  itkCloneMacro(Self);
49 
55  ValueType GetValue(const TimeStepType &timeStep,
56  const IndexValueType &zSlice,
57  bool allowCloseTime = false,
58  bool allowCloseSlice = false) const;
59  ValueType GetValueBySlice(const IndexValueType &zSlice, bool allowClose = false) const;
60  ValueType GetValueByTimeStep(const TimeStepType &timeStep, bool allowClose = false) const;
61 
62  bool HasValue() const;
63  bool HasValue(const TimeStepType &timeStep,
64  const IndexValueType &zSlice,
65  bool allowCloseTime = false,
66  bool allowCloseSlice = false) const;
67  bool HasValueBySlice(const IndexValueType &zSlice, bool allowClose = false) const;
68  bool HasValueByTimeStep(const TimeStepType &timeStep, bool allowClose = false) const;
69 
71  std::vector<IndexValueType> GetAvailableSlices(const TimeStepType& timeStep) const;
73  std::vector<TimeStepType> GetAvailableTimeSteps(const IndexValueType& slice) const;
75  std::vector<TimeStepType> GetAvailableTimeSteps() const;
77  std::vector<IndexValueType> GetAvailableSlices() const;
78 
79  void SetValue(const TimeStepType &timeStep, const IndexValueType &zSlice, const ValueType &value);
80 
81  void SetValue(const ValueType &value);
82 
83  std::string GetValueAsString() const override;
84 
88  bool IsUniform() const;
89 
90  bool ToJSON(nlohmann::json& j) const override;
91  bool FromJSON(const nlohmann::json& j) override;
92 
93  using BaseProperty::operator=;
94 
95  protected:
96  typedef std::map<IndexValueType, std::string> SliceMapType;
97  typedef std::map<TimeStepType, SliceMapType> TimeMapType;
98 
100 
101  TemporoSpatialStringProperty(const char *string = nullptr);
102  TemporoSpatialStringProperty(const std::string &s);
103 
105 
106  std::pair<bool, ValueType> CheckValue(const TimeStepType &timeStep,
107  const IndexValueType &zSlice,
108  bool allowCloseTime = false,
109  bool allowCloseSlice = false) const;
110 
111  private:
112  // purposely not implemented
114 
115  itk::LightObject::Pointer InternalClone() const override;
116 
117  bool IsEqual(const BaseProperty &property) const override;
118  bool Assign(const BaseProperty &property) override;
119  };
120 
121  namespace PropertyPersistenceSerialization
122  {
125  }
126 
127  namespace PropertyPersistenceDeserialization
128  {
130  MITKCORE_EXPORT mitk::BaseProperty::Pointer deserializeJSONToTemporoSpatialStringProperty(const std::string &value);
131  }
132 
141 
142 #ifdef _MSC_VER
143 #pragma warning(pop)
144 #endif
145 
146 } // namespace mitk
147 
148 #endif
#define MITKCORE_EXPORT
Abstract base class for properties.
Property for time and space resolved string values.
TemporoSpatialStringProperty(const std::string &s)
TemporoSpatialStringProperty(const TemporoSpatialStringProperty &)
std::vector< IndexValueType > GetAvailableSlices(const TimeStepType &timeStep) const
std::string GetValueAsString() const override
void SetValue(const ValueType &value)
std::map< IndexValueType, std::string > SliceMapType
std::vector< TimeStepType > GetAvailableTimeSteps(const IndexValueType &slice) const
void SetValue(const TimeStepType &timeStep, const IndexValueType &zSlice, const ValueType &value)
bool HasValueByTimeStep(const TimeStepType &timeStep, bool allowClose=false) const
ValueType GetValueBySlice(const IndexValueType &zSlice, bool allowClose=false) const
mitkClassMacro(TemporoSpatialStringProperty, BaseProperty)
mitkNewMacro1Param(TemporoSpatialStringProperty, const char *)
bool HasValue(const TimeStepType &timeStep, const IndexValueType &zSlice, bool allowCloseTime=false, bool allowCloseSlice=false) const
ValueType GetValue(const TimeStepType &timeStep, const IndexValueType &zSlice, bool allowCloseTime=false, bool allowCloseSlice=false) const
std::vector< TimeStepType > GetAvailableTimeSteps() const
std::vector< IndexValueType > GetAvailableSlices() const
bool ToJSON(nlohmann::json &j) const override
Serialize property value(s) to JSON.
bool FromJSON(const nlohmann::json &j) override
Deserialize property value(s) from JSON.
mitkNewMacro1Param(TemporoSpatialStringProperty, const std::string &)
std::pair< bool, ValueType > CheckValue(const TimeStepType &timeStep, const IndexValueType &zSlice, bool allowCloseTime=false, bool allowCloseSlice=false) const
TemporoSpatialStringProperty(const char *string=nullptr)
bool HasValueBySlice(const IndexValueType &zSlice, bool allowClose=false) const
ValueType GetValueByTimeStep(const TimeStepType &timeStep, bool allowClose=false) const
std::map< TimeStepType, SliceMapType > TimeMapType
nlohmann::json json
MITKCORE_EXPORT mitk::BaseProperty::Pointer deserializeJSONToTemporoSpatialStringProperty(const std::string &value)
MITKCORE_EXPORT std::string serializeTemporoSpatialStringPropertyToJSON(const mitk::BaseProperty *prop)
Find image slices visible on a given plane.
std::size_t TimeStepType
TemporoSpatialStringProperty::Pointer MITKCORE_EXPORT ExtractTimeStepFromTemporoSpatialStringProperty(const TemporoSpatialStringProperty *tsProperty, TimeStepType ts)