MeVisLab Toolbox Reference
CSOModificator.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 
15 
16 #pragma once
17 
18 
19 #include "CSOGenerator.h"
20 #include <set>
21 #include <vector>
22 
23 ML_START_NAMESPACE
24 
26 
29 {
30 
31 public:
32 
34  CSOModificator(const std::string& type="CSOModificator", int numInImages=0,int numOutImages=0);
35 
36 protected:
37 
39  ~CSOModificator() override;
40 
42  void activateAttachments() override;
43 
45  void handleNotification(Field* field) override;
46 
48  virtual void resetParsedIds();
49 
53  virtual void process();
54 
56  virtual void clearOutput();
57 
60  virtual std::vector<CSO*> getCSOsToBeProcessed(const std::vector<CSO *> &csosFromIdList);
61 
63  virtual bool shouldUseUndoRedo() const;
64 
67  virtual bool canProcessInput();
68 
70  virtual void _setupCSOList();
71 
77  virtual void _applyModificator();
78 
81  virtual void _applyModificatorOnCSOs(const std::vector<CSO*>& csosToBeProcessed);
82 
85  virtual void _applyModificatorOn(CSO& outputCSO);
86 
88  virtual void _updateCSOType(CSO& outputCSO);
89 
91  virtual void _notifyObservers(bool didSomething);
92 
100  virtual bool shouldTriggerInputChanged(Field* field) const;
101 
106  virtual bool shouldTriggerParameterApplied(Field* field) const;
107 
108  bool _isChangeSettingField(Field *field) const;
109 
111  virtual void _onInputChanged();
112  virtual void _onParameterApplied();
113  virtual void _onCSOIdListChanged();
115  virtual void _onApply();
116 
119  bool _isInIdList(CSO *cso);
120 
122  void _parseCSOIds(std::set<unsigned int>& ids);
123 
124  std::vector<CSO *> _getModifyCSOsFromIdList();
125 
126  void _storeCurrentStateInUndoManager(std::vector<CSO*> csosToBeProcessed);
127 
129  void _applyChangedSettings(CSO &cso) const;
130 
132  static void _csoListNotifyObserverCB(void* userData, int notificationFlag);
133 
134  /* FIELDS */
135 
140 
144 
148 
151 
156 
159 
160  /* MEMBER VARIABLES */
161 
163  CSOListPtr _inCSOList;
165  CSOListPtr _outCSOList;
170 
172  std::set<unsigned int> _parsedIDs;
175 
180 
185 
187 
188 private:
189  bool _shouldBaseParameterFieldTriggerUpdate(Field *field) const;
190  bool _isAutomaticallyUpdating();
191  bool _isAutomaticallyClearing();
192 };
193 
194 ML_END_NAMESPACE
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
Definition: MLCSOSystem.h:23
Field to encapsulate a pointer to an ML base object.
Definition: mlFields.h:1187
Field to encapsulate a boolean value.
Definition: mlFields.h:62
The CSOGenerator is the base class for all modules that generate CSOs, be it automatically or interac...
Definition: CSOGenerator.h:29
Base class for performing modifications on the CSOs of a CSOList.
virtual void clearOutput()
Clears all outputs (used by auto clear mode)
BoolField * _changeSettingsForModifiedCSOsFld
Shall the module's user settings be used for modified CSOs?
virtual void _applyModificatorOnCSOs(const std::vector< CSO * > &csosToBeProcessed)
may be overwritten by subclasses if, for example, CSOs should be processed in parallel
virtual void _setupCSOList()
Sets the _outCSOList correctly.
virtual void _applyModificator()
Applies the modification to the CSOs of the attached list.
StringField * _csoIdListFld
The list of ids of the CSOs to be transformed; if this list is empty, all CSOs are transformed.
virtual bool canProcessInput()
returns whether the current input can be processed, i.e.
virtual void _notifyObservers(bool didSomething)
Notifies other modules that processing has finished.
void _storeCurrentStateInUndoManager(std::vector< CSO * > csosToBeProcessed)
virtual void _onCSOIdListChanged()
virtual void _applyModificatorOn(CSO &outputCSO)
may be overwritten by subclasses if CSOs are processed one by one
bool _outCSOListChanged
Flag that indicates that _outCSOList has been changed and thus that _outputCSOListFld has to be updat...
virtual void resetParsedIds()
Resets parameteres of the modificator.
bool _isWorkingDirectlyOnInputCSOList
Flag that indicates whether this module should work on its input CSO list directly.
virtual std::vector< CSO * > getCSOsToBeProcessed(const std::vector< CSO * > &csosFromIdList)
may be overwritten to filter out CSOs that are processed by this modificator, by default returns the ...
virtual bool shouldTriggerParameterApplied(Field *field) const
This method exists only for legacy reasons and shoult not be overwritten when writing new CSOModifica...
void _applyChangedSettings(CSO &cso) const
Changes the settings of the given CSO (only if _changeSettingsForModifiedCSOsFld is true).
virtual void _updateCSOType(CSO &outputCSO)
Updates the CSO's type. Most modules change the type to the modificators name, but not all do it.
BoolField * _listenToFinishingNotificationsFld
Shall the module listen to finishing events?
bool _isInIdList(CSO *cso)
Checks if the given CSO is in the list of IDs given by _csoIdListFld.
BoolField * _listenToSelectionNotificationsFld
Shall the module listen to selection change notifications?
bool _parsedIDsValid
Flag that indicates if _parsedIDs is valid.
virtual void _onWorkDirectlyOnInputChanged()
bool _isNotifyingMyself
Is this module notifying itself? Locking variable to avoid infinite loops.
virtual void process()
Sets up the CSOList, applies the modificator to the CSOList and notifies other modules that processin...
virtual bool shouldUseUndoRedo() const
Whether undo/Redo should be used.
std::vector< CSO * > _getModifyCSOsFromIdList()
CSOModificator(const std::string &type="CSOModificator", int numInImages=0, int numOutImages=0)
Standard constructor.
virtual void _onInputChanged()
helper functions called by handleNotification, may be overwritten in very special cases
virtual void _onParameterApplied()
ML_ABSTRACT_MODULE_CLASS_HEADER(CSOModificator)
bool _isOutputCSOListOwner
Flag that indicates whether this module is the owner of the output CSO list.
std::set< unsigned int > _parsedIDs
The IDs of the CSOs that should be processed according to the _csoIdListFld.
CSOListPtr _inCSOList
A pointer to the input CSOList.
void activateAttachments() override
Initialize module after loading.
bool _isChangeSettingField(Field *field) const
BaseField * _inputCSOListFld
The input CSOList.
static void _csoListNotifyObserverCB(void *userData, int notificationFlag)
Can be called from anywhere from the network.
BoolField * _workDirectlyOnInputListFld
Shall the module work directly on the input CSOList? Otherwise, it would work on a copy which is retu...
void _parseCSOIds(std::set< unsigned int > &ids)
Parse the CSO id field into the given vector of ids.
BoolField * _useUndoRedoFld
Shall undo/redo be used? The value is ignored if workDirectlyOnInputList is disabled.
void handleNotification(Field *field) override
Called when input changes.
BaseField * _outputCSOListFld
The filtered output CSOList.
CSOListPtr _outCSOList
A pointer to the output CSOList.
~CSOModificator() override
Standard destructor.
virtual bool shouldTriggerInputChanged(Field *field) const
returns whether a field notification triggers auto update.
bool _isInNotificationCB
Locking variable for removing/adding a notification observer.
virtual void _onApply()
The CSO represents a contour segmentation object.
Definition: CSO.h:44
Base class for all fields used in the ML.
Definition: mlField.h:73
Field to encapsulate a string value.
Definition: mlFields.h:1000