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
23ML_START_NAMESPACE
24
26
29{
30
31public:
32
34 CSOModificator(const std::string& type="CSOModificator", int numInImages=0,int numOutImages=0);
35
36protected:
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
188private:
189 bool _shouldBaseParameterFieldTriggerUpdate(Field *field) const;
190 bool _isAutomaticallyUpdating();
191 bool _isAutomaticallyClearing();
192};
193
194ML_END_NAMESPACE
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
Definition MLCSOSystem.h:23
CSOGenerator(std::string type="CSOGenerator", int numInImg=0, int numOutImg=0)
Constructor.
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)
virtual void _setupCSOList()
Sets the _outCSOList correctly.
virtual void _applyModificator()
std::vector< CSO * > _getModifyCSOsFromIdList()
virtual std::vector< CSO * > getCSOsToBeProcessed(const std::vector< CSO * > &csosFromIdList)
StringField * _csoIdListFld
virtual bool canProcessInput()
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)
virtual void resetParsedIds()
Resets parameteres of the modificator.
bool _isWorkingDirectlyOnInputCSOList
Flag that indicates whether this module should work on its input CSOList directly.
virtual bool shouldTriggerParameterApplied(Field *field) const
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)
BoolField * _listenToSelectionNotificationsFld
Shall the module listen to selection change notifications?
bool _parsedIDsValid
Flag that indicates whether _parsedIDs is valid.
virtual void _onWorkDirectlyOnInputChanged()
bool _isNotifyingMyself
Is this module notifying itself? Locking variable to avoid infinite loops.
virtual void process()
virtual bool shouldUseUndoRedo() const
Returns whether undo/Redo should be used.
CSOModificator(const std::string &type="CSOModificator", int numInImages=0, int numOutImages=0)
Standard constructor.
virtual void _onInputChanged()
Helper methods 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 CSOList.
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
Initializes the 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
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 any field 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
bool _isInNotificationCB
Locking variable for removing/adding a notification observer.
virtual void _onApply()
Definition CSO.h:44