MeVisLab Toolbox Reference
mlFieldAddOnBase.h
Go to the documentation of this file.
1 // Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2 // **InsertLicense** code
3 //----------------------------------------------------------------------------------
6 
11 //----------------------------------------------------------------------------------
12 #pragma once
13 
14 #include "MLReleaseToolsSystem.h"
15 #include <mlModuleIncludes.h>
16 
17 ML_START_NAMESPACE
18 
19 //----------------------------------------------------------------------------------
21 //----------------------------------------------------------------------------------
23 {
24 public:
27  NoChange = 0,
28  StatusOnlyChange,
30  RecalculationRequired
32  };
33 
35  inline FieldAddOnBase(FieldContainer &fieldContainerRef):
36  _referencedContainer(fieldContainerRef),
37  _fieldPointers(){};
38 
40  virtual ~FieldAddOnBase(){};
41 
43  inline FieldContainer &getFieldContainer(){ return _referencedContainer; }
44 
46  inline const FieldContainer &getFieldContainer() const { return _referencedContainer; }
47 
49  inline std::vector<Field*> &getFields() { return _fieldPointers; }
50 
52  inline const std::vector<Field*> &getFields() const { return _fieldPointers; }
53 
56  virtual void addFields() = 0;
57 
59  virtual void handleFieldActivationChanges(){};
60 
66  {
67  return hasField(field) ? RecalculationRequired : NoChange;
68  }
69 
72  FieldChangeState state2) const
73  {
74  if ((state1 == RecalculationRequired) || (state2 == RecalculationRequired)){
75  return RecalculationRequired;
76  }
77  else if ((state1 == StatusOnlyChange) || (state2 == StatusOnlyChange)){
78  return StatusOnlyChange;
79  }
80  else{
81  return NoChange;
82  }
83  }
84 
86  virtual bool hasField(Field *field) const;
87 
88 protected:
91  void _addFieldPointer(Field* field);
92 
93 private:
95  FieldContainer &_referencedContainer;
96 
98  std::vector<Field*> _fieldPointers;
99 
102 
104  FieldAddOnBase & operator=(const FieldAddOnBase&);
105 };
106 
107 ML_END_NAMESPACE
Project global and OS specific declarations.
#define MLRELEASE_TOOLS_EXPORT
DLL export macro definition.
Abstract base class for field interfaces to be added to other ML module classes.
const std::vector< Field * > & getFields() const
Return constant access to the list of managed fields!
const FieldContainer & getFieldContainer() const
Returns the referenced container.
void _addFieldPointer(Field *field)
Helper routine to add a Field pointer to _fieldPointers, empty pointers and pointers added more than ...
virtual void handleFieldActivationChanges()
Handle class changes according to Module::activateAttachments.
virtual FieldChangeState handleFieldChanges(Field *field)
Handle field notifications according to Module::handleNotification functionality.
std::vector< Field * > & getFields()
Return modification access to the list of managed fields, use at own risk!
virtual ~FieldAddOnBase()
Destructor.
FieldChangeState
Describes the type of a field changes detected in handleFieldChanges(Field *field).
virtual FieldChangeState getMergedFieldChangeState(FieldChangeState state1, FieldChangeState state2) const
Returns a FieldChangeState which best represents a merge of the two given states.
virtual bool hasField(Field *field) const
Returns true if the passed fieldPtr is in _fieldPointers, otherwise false.
virtual void addFields()=0
Add fields to field container of module.
FieldAddOnBase(FieldContainer &fieldContainerRef)
Constructor, setting the reference of the FieldContainer managing the fields.
FieldContainer & getFieldContainer()
Returns the referenced container.
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
@ NoChange
Do not change the voxel type.