MeVisLab Toolbox Reference
mlDicomValueInheritAndCreateTagInterface.h
Go to the documentation of this file.
1 // Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2 // **InsertLicense** code
3 //----------------------------------------------------------------------------------
6 
10 //----------------------------------------------------------------------------------
11 #pragma once
12 
15 
16 ML_START_NAMESPACE
17 
18 // Forwards.
20 
21 //----------------------------------------------------------------------------------
24 //----------------------------------------------------------------------------------
26 {
27 public:
28 
29  //-----------
31  enum { NumInheritModes = 5 };
32 
34  enum {
35  DoNotInherit=0,
39  CreateNewIfNeeded
40  };
41 
43  static const char * const InheritModeStrings[NumInheritModes];
44 
46  enum { NumAutoCreateValueModes = 3 };
47 
49  enum {
50  DoNotAutoCreate=0,
52  CreateIfNeeded
53  };
54 
56  static const char * const AutoCreateValueModeStrings[NumAutoCreateValueModes];
57 
75  DCMTree::RawTagId tagId,
76  const std::string &valueFieldName, /* e.g. "seriesInstanceUID" */
77  const std::string &fieldSuffix, /* e.g. "SeriesInstanceUID" */
78  bool valueIsType1,
79  const std::string &dicomModuleInfoString, /* e.g. " (General Series)" */
80  const bool useDefaultField=false,
81  const std::string &defaultFieldValue=""
82  );
83 
86 
88  void addFields() override;
89 
91  void inheritValues(DCMTree::Const_TreePtr dcmTree) override;
92 
94  std::string applyModifications(DCMTree::TreePtr dcmTree,
95  const FieldContainer *treeInfos=nullptr) override;
96 
99 
101  std::string checkConsistency() const override;
102 
104  virtual StringField &getValueFld() { return *_valueFld; }
106  virtual const StringField &getValueFld() const { return *_valueFld; }
107 
109  virtual EnumField &getInheritModeFld() { return *_inheritModeFld; }
111  virtual const EnumField &getInheritModeFld() const { return *_inheritModeFld; }
112 
114  virtual StringField *getDefaultFieldFld() { return _defaultFieldFld; }
116  virtual const StringField *getDefaultFieldFld() const { return _defaultFieldFld; }
117 
119  virtual EnumField &getAutoCreateValueFld() { return *_autoCreateValueFld; }
121  virtual const EnumField &getAutoCreateValueFld() const { return *_autoCreateValueFld; }
122 
124  virtual bool isDefaultFieldUsed() const { return _useDefaultField; }
126  virtual void setUseDefaultField(bool useDefaultField) { _useDefaultField = useDefaultField; }
127 
129  virtual NotifyField &getCreateValueFld() { return *_createValueFld; }
131  virtual const NotifyField &getCreateValueFld() const { return *_createValueFld; }
132 
136  virtual void setDefaultCreateFunction(DefaultValueCreatorBase *newDefaultCreator);
137 
140 
144  virtual void createValue();
145 
147  virtual void createValueIfNeeded();
148 
149 protected:
152 
155 
157  const std::string _valueFieldName;
158 
160  const std::string _fieldSuffix;
161 
164 
167 
170 
171  //-----------
174  const bool _valueIsType1;
175 
177  const std::string _dicomModuleInfoString;
178 
181 
183  const std::string _defaultInitValue;
184 
187 
190 };
191 
192 ML_END_NAMESPACE
Project global and OS specific declarations.
#define MLDICOMTAGINTERFACES_EXPORT
DLL export macro definition.
The class DicomModifyFieldAddOnBase is dedicated to manage fields for ML modules and instances derive...
FieldAddOn class supporting inheritance and auto creating tag values (for example DICOM UIDs or tag v...
virtual const StringField * getDefaultFieldFld() const
Constant read-only access, see _defaultFieldFld, returns nullptr if not available.
virtual NotifyField & getCreateValueFld()
See _createValueFld.
virtual const NotifyField & getCreateValueFld() const
Constant read-only access, see _createValueFld.
virtual bool isDefaultFieldUsed() const
See _useDefaultField.
const std::string _defaultInitValue
Default value passed to constructor.
virtual EnumField & getAutoCreateValueFld()
See _autoCreateValueFld.
StringField * _defaultFieldFld
Used as default value for the hidden default field if _useDefaultFieldFld is true,...
bool _useDefaultField
If enabled then a hidden default field is generated and/or used its value is used instead of a genera...
const DCMTree::RawTagId _tagId
Stores the ID of the DICOM tag to be managed.
EnumField * _inheritModeFld
Controls whether or how the value is inherited.
void addFields() override
Add fields to field container of module.
EnumField * _autoCreateValueFld
Controls whether or when a new value is generated.
virtual const StringField & getValueFld() const
Constant read-only access, see _valueFld.
const bool _valueIsType1
If true then the value is handled as Type 1 (mandatory and not empty) tag, otherwise it is allowed to...
virtual void setDefaultCreateFunction(DefaultValueCreatorBase *newDefaultCreator)
Sets a new object to create default values if not nullptr, otherwise a CreateDefaultDICOMUID instance...
virtual const DefaultValueCreatorBase & getDefaultCreateFunction() const
Returns the current default value creator; returned pointer is never nullptr.
virtual const EnumField & getInheritModeFld() const
Constant read-only access, see _inheritModeFld.
virtual const EnumField & getAutoCreateValueFld() const
Constant read-only access, see _autoCreateValueFld.
DicomValueInheritAndCreateTagInterface(Module &modRef, DCMTree::RawTagId tagId, const std::string &valueFieldName, const std::string &fieldSuffix, bool valueIsType1, const std::string &dicomModuleInfoString, const bool useDefaultField=false, const std::string &defaultFieldValue="")
Constructor, setting the reference of the module for which the fields shall be managed.
virtual void setUseDefaultField(bool useDefaultField)
On true sets the default field is used or otherwise the default value function.
virtual void createValueIfNeeded()
Same as createValue() but creates a value only if getValueFld() is empty.
std::string applyModifications(DCMTree::TreePtr dcmTree, const FieldContainer *treeInfos=nullptr) override
See DicomModifyFieldAddOnBase::applyModifications() for documentation.
DefaultValueCreatorBase * _createDefaultValuePtr
The function to create default values if no default field is available.
void inheritValues(DCMTree::Const_TreePtr dcmTree) override
Implements the copy of tag values from the given dcmTree to the fields.
~DicomValueInheritAndCreateTagInterface() override
Destructor.
virtual StringField * getDefaultFieldFld()
See _defaultFieldFld, returns nullptr if not available.
NotifyField * _createValueFld
If notified a new value is created.
virtual void createValue()
Set _valueFld to a new value according to settings of isDefaultFieldUsed() and getDefaultCreatFunctio...
const std::string _dicomModuleInfoString
Stores the description of the DICOM module for error message generation.
std::string checkConsistency() const override
Checks for invalid parameters; return textual description on error, or empty string on success.
@ CreateNew
Create a new value on inheritance instead of inheriting one.
@ InheritRecursively
Inherit value from recursively search in DCMTree or set empty if not found.
@ InheritFromTopLevel
Inherit value from top level of DCMTree or set empty if not found.
@ AutoCreateAlways
Always create a new value even if another valid one is set.
FieldAddOnBase::FieldChangeState handleFieldChanges(Field *field) override
Handle field notifications.
Field to encapsulate an enumerated value.
Definition: mlFields.h:363
FieldChangeState
Describes the type of a field changes detected in handleFieldChanges(Field *field).
Defines the class FieldContainer to encapsulate a vector of fields for (see class Field).
Base class for all fields used in the ML.
Definition: mlField.h:73
Base class for an image processing module of the ML.
Definition: mlModule.h:156
Field without value for notifications.
Definition: mlFields.h:1049
Field to encapsulate a string value.
Definition: mlFields.h:1000
Header file of the DicomModifyFieldAddOnBase class dedicated to manage fields for ML modules and inst...
boost::shared_ptr< const Tree > Const_TreePtr
Definition: DCMTree_Lib.h:73
boost::shared_ptr< Tree > TreePtr
shared pointer to a DCMTree::Tree
Definition: DCMTree_Lib.h:70
unsigned int RawTagId
Definition: DCMTree_Lib.h:147
Base class for classes creating default values.