Commit 293d43dd authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Moved invalidation level from AbstractProperty to AbstractProcessor:

To now, each property hat an _invalidationLevel field that was evaluated by processors when the property had changed in order to determine what has to be done. However, since properties could also be owned by other classes, this design was semantically misleading.
Therefore, it was removed with this commit and replaced by the invalidation map of each processor. Now, this per-processor mapping of property -> invalidation level is managed by the processor itself. Furthermore, the invalidation level is no longer setup during property creation but during AbstractProcessor::addProperty(), which also makes much more sense.

ATTENTION: Due to these intrusive API changes, the code of all processors and other classes handling properties needs to be changed. As a reminder, the implementation of addProperty() also now takes a reference instead of a pointer, so that old code does no longer compile.

refs #542
parent 94a730da
......@@ -29,8 +29,8 @@ namespace campvis {
const std::string CameraProperty::loggerCat_ = "CAMPVis.core.datastructures.CameraProperty";
CameraProperty::CameraProperty(const std::string& name, const std::string& title, tgt::Camera cam /*= tgt::Camera()*/, int invalidationLevel /*= AbstractProcessor::INVALID_RESULT*/)
: GenericProperty<tgt::Camera>(name, title, cam, invalidationLevel)
CameraProperty::CameraProperty(const std::string& name, const std::string& title, tgt::Camera cam /*= tgt::Camera()*/)
: GenericProperty<tgt::Camera>(name, title, cam)
{
}
......
......@@ -37,9 +37,8 @@ namespace campvis {
* \param name Property name (unchangable!)
* \param title Property title (e.g. used for GUI)
* \param cam Camera to initialize the property with
* \param invalidationLevel Invalidation level that this property triggers
*/
CameraProperty(const std::string& name, const std::string& title, tgt::Camera cam = tgt::Camera(), int invalidationLevel = AbstractProcessor::INVALID_RESULT);
CameraProperty(const std::string& name, const std::string& title, tgt::Camera cam = tgt::Camera());
/**
* Virtual Destructor
......
......@@ -28,8 +28,8 @@ namespace campvis {
const std::string DataNameProperty::loggerCat_ = "CAMPVis.core.datastructures.DataNameProperty";
DataNameProperty::DataNameProperty(const std::string& name, const std::string& title, const std::string& value, DataAccessInfo access, int invalidationLevel /*= AbstractProcessor::INVALID_RESULT*/)
: GenericProperty<std::string>(name, title, value, invalidationLevel)
DataNameProperty::DataNameProperty(const std::string& name, const std::string& title, const std::string& value, DataAccessInfo access)
: GenericProperty<std::string>(name, title, value)
, _accessInfo(access)
{
......
......@@ -53,9 +53,8 @@ namespace campvis {
* \param title Property title (e.g. used for GUI)
* \param value Initial value
* \param access DataAccessInfo flag defining whether processor will read or write from/to the DataHandle with the given ID.
* \param invalidationLevel Invalidation level that this property triggers
*/
DataNameProperty(const std::string& name, const std::string& title, const std::string& value, DataAccessInfo access, int invalidationLevel = AbstractProcessor::INVALID_RESULT);
DataNameProperty(const std::string& name, const std::string& title, const std::string& value, DataAccessInfo access);
/**
* Virtual Destructor
......
......@@ -83,7 +83,6 @@ namespace campvis {
* \param maxValue Maximum value for this property
* \param stepValue Step value for this property
* \param decimals Number of significant decimal places
* \param invalidationLevel Invalidation level that this property triggers
*/
FloatingPointProperty(
const std::string& name,
......@@ -92,8 +91,7 @@ namespace campvis {
const T& minValue,
const T& maxValue,
const T& stepValue = T(0.01f),
const DecimalsType& decimals = DecimalsType(3),
int invalidationLevel = AbstractProcessor::INVALID_RESULT);
const DecimalsType& decimals = DecimalsType(3));
/**
* Adds the given property \a prop to the set of shared properties.
......@@ -141,9 +139,8 @@ namespace campvis {
campvis::FloatingPointProperty<T>::FloatingPointProperty(const std::string& name, const std::string& title,
const T& value, const T& minValue, const T& maxValue,
const T& stepValue,
const DecimalsType& decimals /*= DecimalsType(3)*/,
int invalidationLevel /*= AbstractProcessor::INVALID_RESULT*/)
: NumericProperty<T>(name, title, value, minValue, maxValue, stepValue, invalidationLevel)
const DecimalsType& decimals /*= DecimalsType(3)*/)
: NumericProperty<T>(name, title, value, minValue, maxValue, stepValue)
, _decimals(decimals)
{
......
......@@ -45,13 +45,11 @@ namespace campvis {
* \param name Property name
* \param title Property title (e.g. used for GUI)
* \param value Initial value of the property
* \param invalidationLevel Invalidation level that this property triggers
*/
GenericProperty(
const std::string& name,
const std::string& title,
const T& value,
int invalidationLevel = AbstractProcessor::INVALID_RESULT);
const T& value);
/**
* Virtual Destructor
......@@ -128,8 +126,8 @@ namespace campvis {
// = Template Implementation ======================================================================
template<typename T>
campvis::GenericProperty<T>::GenericProperty(const std::string& name, const std::string& title, const T& value, int invalidationLevel /*= AbstractProcessor::INVALID_RESULT*/)
: AbstractProperty(name, title, invalidationLevel)
campvis::GenericProperty<T>::GenericProperty(const std::string& name, const std::string& title, const T& value)
: AbstractProperty(name, title)
, _value(value)
, _backBuffer(value)
{
......
......@@ -28,8 +28,8 @@ namespace campvis {
const std::string MetaProperty::loggerCat_ = "CAMPVis.core.datastructures.MetaProperty";
MetaProperty::MetaProperty(const std::string& name, const std::string& title, int invalidationLevel /*= AbstractProcessor::INVALID_RESULT*/)
: AbstractProperty(name, title, invalidationLevel)
MetaProperty::MetaProperty(const std::string& name, const std::string& title)
: AbstractProperty(name, title)
{
}
......@@ -37,13 +37,13 @@ namespace campvis {
}
void MetaProperty::onPropertyChanged(const AbstractProperty* prop) {
s_changed(prop);
s_changed(this);
}
void MetaProperty::addPropertyCollection(HasPropertyCollection& pc) {
PropertyCollection& c = pc.getProperties();
for (std::vector<AbstractProperty*>::const_iterator it = c.begin(); it != c.end(); ++it) {
addProperty(*it);
addProperty(**it);
}
}
......
......@@ -45,9 +45,8 @@ namespace campvis {
* Creates a new MetaProperty
* \param name Property name (unchangable!)
* \param title Property title (e.g. used for GUI)
* \param invalidationLevel Invalidation level that this property triggers
*/
MetaProperty(const std::string& name, const std::string& title, int invalidationLevel = AbstractProcessor::INVALID_RESULT);
MetaProperty(const std::string& name, const std::string& title);
/**
* Virtual Destructor
......
......@@ -105,7 +105,6 @@ namespace campvis {
* \param minValue Minimum value for this property
* \param maxValue Maximum value for this property
* \param stepValue Step value for this property
* \param invalidationLevel Invalidation level that this property triggers
*/
NumericProperty(
const std::string& name,
......@@ -113,8 +112,7 @@ namespace campvis {
const T& value,
const T& minValue,
const T& maxValue,
const T& stepValue = T(1),
int invalidationLevel = AbstractProcessor::INVALID_RESULT);
const T& stepValue = T(1));
/**
* Virtual Destructor
......@@ -214,9 +212,8 @@ namespace campvis {
template<typename T>
campvis::NumericProperty<T>::NumericProperty(const std::string& name, const std::string& title, const T& value,
const T& minValue, const T& maxValue, const T& stepValue /*= T(1)*/,
int invalidationLevel /*= AbstractProcessor::INVALID_RESULT*/)
: GenericProperty<T>(name, title, value, invalidationLevel)
const T& minValue, const T& maxValue, const T& stepValue /*= T(1)*/)
: GenericProperty<T>(name, title, value)
, _minValue(minValue)
, _maxValue(maxValue)
, _stepValue(stepValue)
......
......@@ -42,10 +42,9 @@ namespace campvis {
* Creates a new AbstractOptionProperty.
* \param name Property name
* \param title Property title (e.g. used for GUI)
* \param invalidationLevel Invalidation level that this property triggers
*/
AbstractOptionProperty(const std::string& name, const std::string& title, int invalidationLevel = AbstractProcessor::INVALID_RESULT)
: IntProperty(name, title, -1, -1, -1, 1, invalidationLevel)
AbstractOptionProperty(const std::string& name, const std::string& title)
: IntProperty(name, title, -1, -1, -1, 1)
{
};
......@@ -108,14 +107,13 @@ namespace campvis {
* \param title Property title (e.g. used for GUI)
* \param options Array of the options for this property, must not be 0, must not be empty.
* \param count Number of items in \a options (number of options), must be greater 0.
* \param invalidationLevel Invalidation level that this property triggers
*/
GenericOptionProperty(
const std::string& name,
const std::string& title,
const GenericOption<T>* options,
int count,
int invalidationLevel = AbstractProcessor::INVALID_RESULT);
int count);
/**
* Destructor
......@@ -171,8 +169,8 @@ namespace campvis {
// = Template Implementation ======================================================================
template<typename T>
campvis::GenericOptionProperty<T>::GenericOptionProperty(const std::string& name, const std::string& title, const GenericOption<T>* options, int count, int invalidationLevel /*= AbstractProcessor::INVALID_RESULT*/)
: AbstractOptionProperty(name, title, invalidationLevel)
campvis::GenericOptionProperty<T>::GenericOptionProperty(const std::string& name, const std::string& title, const GenericOption<T>* options, int count)
: AbstractOptionProperty(name, title)
{
tgtAssert(options != 0, "Pointer to options array must not be 0.")
tgtAssert(count > 0, "The number of options must be greater 0.");
......
......@@ -35,28 +35,26 @@ namespace campvis {
HasPropertyCollection::~HasPropertyCollection() {
}
void HasPropertyCollection::addProperty(AbstractProperty* prop) {
tgtAssert(prop != 0, "Property must not be 0!");
PropertyCollection::iterator it = findProperty(prop->getName());
void HasPropertyCollection::addProperty(AbstractProperty& prop) {
PropertyCollection::iterator it = findProperty(prop.getName());
if (it != _properties.end()) {
(*it)->s_changed.disconnect(this);
s_propertyRemoved(*it);
*it = prop;
*it = &prop;
}
else {
_properties.push_back(prop);
_properties.push_back(&prop);
}
prop->s_changed.connect(this, &HasPropertyCollection::onPropertyChanged);
s_propertyAdded(prop);
prop.s_changed.connect(this, &HasPropertyCollection::onPropertyChanged);
s_propertyAdded(&prop);
}
void HasPropertyCollection::removeProperty(AbstractProperty* prop) {
tgtAssert(prop != 0, "Property must not be 0!");
PropertyCollection::iterator it = findProperty(prop->getName());
void HasPropertyCollection::removeProperty(AbstractProperty& prop) {
PropertyCollection::iterator it = findProperty(prop.getName());
if (it != _properties.end()) {
(*it)->s_changed.disconnect(this);
_properties.erase(it);
s_propertyRemoved(prop);
s_propertyRemoved(&prop);
}
}
......
......@@ -54,14 +54,14 @@ namespace campvis {
* unregister the property before destroying/deleting it.
* \param prop Property to register
*/
void addProperty(AbstractProperty* prop);
virtual void addProperty(AbstractProperty& prop);
/**
* Unregisters \a prop from this processor.
* \sa HasPropertyCollection::addProperty
* \param prop Property to unregister.
*/
void removeProperty(AbstractProperty* prop);
void removeProperty(AbstractProperty& prop);
/**
* Returns the property with the given name \a name.
......
......@@ -32,8 +32,8 @@ namespace campvis {
const std::string TransferFunctionProperty::loggerCat_ = "CAMPVis.core.datastructures.TransferFunctionProperty";
TransferFunctionProperty::TransferFunctionProperty(const std::string& name, const std::string& title, AbstractTransferFunction* tf, int invalidationLevel /*= AbstractProcessor::INVALID_RESULT*/)
: AbstractProperty(name, title, invalidationLevel)
TransferFunctionProperty::TransferFunctionProperty(const std::string& name, const std::string& title, AbstractTransferFunction* tf)
: AbstractProperty(name, title)
, _transferFunction(tf)
, _imageHandle(0)
, _autoFitWindowToData(true)
......
......@@ -47,9 +47,8 @@ namespace campvis {
* \param name Property name (unchangable!)
* \param title Property title (e.g. used for GUI)
* \param tf Transfer function to initialize the property with.
* \param invalidationLevel Invalidation level that this property triggers
*/
TransferFunctionProperty(const std::string& name, const std::string& title, AbstractTransferFunction* tf, int invalidationLevel = AbstractProcessor::INVALID_RESULT);
TransferFunctionProperty(const std::string& name, const std::string& title, AbstractTransferFunction* tf);
/**
* Virtual Destructor
......
......@@ -31,8 +31,8 @@
namespace campvis {
AbstractPointPredicate::AbstractPointPredicate(const std::string& inputVariable, const std::string& name, const std::string& title, int invalidationLevel /*= AbstractProcessor::INVALID_RESULT*/)
: MetaProperty(name, title, invalidationLevel)
AbstractPointPredicate::AbstractPointPredicate(const std::string& inputVariable, const std::string& name, const std::string& title)
: MetaProperty(name, title)
, p_enable("Enable", "Enable Predicate", true)
, p_importance("Importance", "Importance", 1.f, 0.f, 5.f, .1f, 1)
, p_color("Color", "Predicate-Specific Color", tgt::vec2(0.f), tgt::vec2(0.f), tgt::vec2(1.f), tgt::vec2(.01f, .1f), tgt::ivec2(2, 1))
......@@ -50,10 +50,10 @@ namespace campvis {
p_color.setVisible(false);
p_intensityHack.setVisible(false);
addProperty(&p_enable);
addProperty(&p_importance);
addProperty(&p_color);
addProperty(&p_intensityHack);
addProperty(p_enable);
addProperty(p_importance);
addProperty(p_color);
addProperty(p_intensityHack);
}
AbstractPointPredicate::~AbstractPointPredicate() {
......@@ -124,7 +124,7 @@ namespace campvis {
, _predicates(predicates)
{
for (size_t i = 0; i < _predicates.size(); ++i) {
addProperty(_predicates[i]);
addProperty(*_predicates[i]);
}
}
......@@ -160,12 +160,12 @@ namespace campvis {
// ================================================================================================
RangePointPredicate::RangePointPredicate(const std::string& inputVariable, const std::string& name, const std::string& title, int invalidationLevel /*= AbstractProcessor::INVALID_RESULT*/)
: AbstractPointPredicate(inputVariable, name, title, invalidationLevel)
RangePointPredicate::RangePointPredicate(const std::string& inputVariable, const std::string& name, const std::string& title)
: AbstractPointPredicate(inputVariable, name, title)
, p_range("Range", "Range", tgt::vec2(0.f, 1.f), tgt::vec2(0.f), tgt::vec2(1.f), tgt::vec2(.01f), tgt::ivec2(2))
, _rangeUniformName("_vpRange" + _name)
{
addProperty(&p_range);
addProperty(p_range);
}
RangePointPredicate::~RangePointPredicate() {
......@@ -190,12 +190,12 @@ namespace campvis {
// ================================================================================================
LabelBitPointPredicate::LabelBitPointPredicate(const std::string& inputVariable, const std::string& name, const std::string& title, int invalidationLevel /*= AbstractProcessor::INVALID_RESULT*/)
: AbstractPointPredicate(inputVariable, name, title, invalidationLevel)
LabelBitPointPredicate::LabelBitPointPredicate(const std::string& inputVariable, const std::string& name, const std::string& title)
: AbstractPointPredicate(inputVariable, name, title)
, p_bit("Bit", "Bit in Label Image", 0, 0, 16)
, _bitUniformName("_vpBit" + _name)
{
addProperty(&p_bit);
addProperty(p_bit);
}
LabelBitPointPredicate::~LabelBitPointPredicate() {
......
......@@ -39,7 +39,7 @@ namespace campvis {
class AbstractPointPredicate : public MetaProperty {
public:
AbstractPointPredicate(const std::string& inputVariable, const std::string& name, const std::string& title, int invalidationLevel = AbstractProcessor::INVALID_RESULT);
AbstractPointPredicate(const std::string& inputVariable, const std::string& name, const std::string& title);
virtual ~AbstractPointPredicate();
......@@ -138,7 +138,7 @@ namespace campvis {
class RangePointPredicate : public AbstractPointPredicate {
public:
RangePointPredicate(const std::string& inputVariable, const std::string& name, const std::string& title, int invalidationLevel = AbstractProcessor::INVALID_RESULT);
RangePointPredicate(const std::string& inputVariable, const std::string& name, const std::string& title);
virtual ~RangePointPredicate();
......@@ -158,7 +158,7 @@ namespace campvis {
class LabelBitPointPredicate : public AbstractPointPredicate {
public:
LabelBitPointPredicate(const std::string& inputVariable, const std::string& name, const std::string& title, int invalidationLevel = AbstractProcessor::INVALID_RESULT);
LabelBitPointPredicate(const std::string& inputVariable, const std::string& name, const std::string& title);
virtual ~LabelBitPointPredicate();
......
......@@ -63,12 +63,12 @@ namespace campvis {
addProcessor(&_usFusion);
addProcessor(&_usBlurFilter);
addProperty(&p_autoExecution);
addProperty(&p_sourcePath);
addProperty(&p_targetPathColor);
addProperty(&p_targetPathFuzzy);
addProperty(&p_range);
addProperty(&p_execute);
addProperty(p_autoExecution);
addProperty(p_sourcePath);
addProperty(p_targetPathColor);
addProperty(p_targetPathFuzzy);
addProperty(p_range);
addProperty(p_execute);
}
CmBatchGeneration::~CmBatchGeneration() {
......
......@@ -100,8 +100,8 @@ namespace campvis {
Geometry1DTransferFunction* dvrTF = new Geometry1DTransferFunction(128, tgt::vec2(0.05f, .8f));
dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(0.f, 1.f), tgt::col4(0, 0, 0, 0), tgt::col4(255, 255, 255, 255)));
static_cast<TransferFunctionProperty*>(_ve.getProperty("TransferFunction"))->setAutoFitWindowToData(false);
static_cast<TransferFunctionProperty*>(_ve.getProperty("TransferFunction"))->replaceTF(dvrTF);
static_cast<TransferFunctionProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::TransferFunction"))->setAutoFitWindowToData(false);
static_cast<TransferFunctionProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::TransferFunction"))->replaceTF(dvrTF);
static_cast<FloatProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::GradientLod"))->setValue(0.5f);
static_cast<FloatProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::SamplingRate"))->setValue(1.f);
......@@ -144,7 +144,7 @@ namespace campvis {
histogram->addPredicate(vpToAdd);
histogram->resetPredicates();
addProperty(php);
addProperty(*php);
}
}
......
......@@ -111,8 +111,8 @@ namespace campvis {
Geometry1DTransferFunction* dvrTF = new Geometry1DTransferFunction(128, tgt::vec2(0.05f, .8f));
dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(0.f, 1.f), tgt::col4(0, 0, 0, 0), tgt::col4(255, 255, 255, 255)));
static_cast<TransferFunctionProperty*>(_ve.getProperty("TransferFunction"))->setAutoFitWindowToData(false);
static_cast<TransferFunctionProperty*>(_ve.getProperty("TransferFunction"))->replaceTF(dvrTF);
static_cast<TransferFunctionProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::TransferFunction"))->setAutoFitWindowToData(false);
static_cast<TransferFunctionProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::TransferFunction"))->replaceTF(dvrTF);
static_cast<FloatProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::GradientLod"))->setValue(0.5f);
static_cast<FloatProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::SamplingRate"))->setValue(1.f);
......@@ -171,7 +171,7 @@ namespace campvis {
histogram->addPredicate(vpToAdd);
histogram->resetPredicates();
addProperty(php);
addProperty(*php);
}
}
......
......@@ -111,8 +111,8 @@ namespace campvis {
Geometry1DTransferFunction* dvrTF = new Geometry1DTransferFunction(128, tgt::vec2(0.05f, .8f));
dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(0.f, 1.f), tgt::col4(0, 0, 0, 0), tgt::col4(255, 255, 255, 255)));
static_cast<TransferFunctionProperty*>(_ve.getProperty("TransferFunction"))->setAutoFitWindowToData(false);
static_cast<TransferFunctionProperty*>(_ve.getProperty("TransferFunction"))->replaceTF(dvrTF);
static_cast<TransferFunctionProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::TransferFunction"))->setAutoFitWindowToData(false);
static_cast<TransferFunctionProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::TransferFunction"))->replaceTF(dvrTF);
static_cast<FloatProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::GradientLod"))->setValue(0.5f);
// static_cast<Vec4Property*>(_ve.getNestedProperty("backgroundColor1"))->setValue(tgt::vec4(1.f));
......@@ -167,7 +167,7 @@ namespace campvis {
histogram->addPredicate(vpToAdd);
histogram->resetPredicates();
addProperty(php);
addProperty(*php);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment