Added support to StateAttribute/State to support PROTECTED flag for modes and attributes

so that they cannot be overriden from above via the OVERRIDE flag.  This is
useful for things like manipulators that have handles display in the scene, you
might want to prevent their state being affected by other overriding of
light, wireframe modes etc.
This commit is contained in:
Robert Osfield
2002-08-05 12:40:24 +00:00
parent 6b52e17c48
commit fd788daa69
2 changed files with 16 additions and 12 deletions

View File

@@ -411,9 +411,9 @@ class SG_EXPORT State : public Referenced
/** Get the DisplaySettings */
inline const DisplaySettings* getDisplaySettings() const { return _displaySettings.get(); }
typedef std::pair<const StateAttribute*,StateAttribute::OverrideValue> AttributePair;
typedef std::vector<AttributePair> AttributeVec;
typedef std::vector<StateAttribute::GLModeValue> ValueVec;
typedef std::pair<const StateAttribute*,StateAttribute::OverrideValue> AttributePair;
typedef std::vector<AttributePair> AttributeVec;
typedef std::vector<StateAttribute::GLModeValue> ValueVec;
private:
@@ -590,7 +590,7 @@ inline void State::pushModeList(ModeMap& modeMap,const StateSet::ModeList& modeL
// first pair so simply push incomming pair to back.
ms.valueVec.push_back(mitr->second);
}
else if (ms.valueVec.back() & StateAttribute::OVERRIDE) // check the existing override flag
else if ((ms.valueVec.back() & StateAttribute::OVERRIDE) && !(mitr->second & StateAttribute::PROTECTED)) // check the existing override flag
{
// push existing back since override keeps the previoius value.
ms.valueVec.push_back(ms.valueVec.back());
@@ -618,7 +618,7 @@ inline void State::pushAttributeList(AttributeMap& attributeMap,const StateSet::
as.attributeVec.push_back(
AttributePair(aitr->second.first.get(),aitr->second.second));
}
else if (as.attributeVec.back().second & StateAttribute::OVERRIDE) // check the existing override flag
else if ((as.attributeVec.back().second & StateAttribute::OVERRIDE) && !(aitr->second.second & StateAttribute::PROTECTED)) // check the existing override flag
{
// push existing back since override keeps the previoius value.
as.attributeVec.push_back(as.attributeVec.back());
@@ -720,7 +720,7 @@ inline void State::applyModeList(ModeMap& modeMap,const StateSet::ModeList& mode
ModeStack& ms = this_mitr->second;
if (!ms.valueVec.empty() && ms.valueVec.back() & StateAttribute::OVERRIDE)
if (!ms.valueVec.empty() && (ms.valueVec.back() & StateAttribute::OVERRIDE) && !(ds_mitr->second & StateAttribute::PROTECTED))
{
// override is on, there just treat as a normal apply on modes.
@@ -835,14 +835,14 @@ inline void State::applyAttributeList(AttributeMap& attributeMap,const StateSet:
}
else
{
// this_mitr & ds_mitr refer to the same mode, check the overide
// if any otherwise just apply the incomming mode.
// this_mitr & ds_mitr refer to the same attribute, check the overide
// if any otherwise just apply the incomming attribute
AttributeStack& as = this_aitr->second;
if (!as.attributeVec.empty() && as.attributeVec.back().second)
if (!as.attributeVec.empty() && (as.attributeVec.back().second & StateAttribute::OVERRIDE) && !(ds_aitr->second.second & StateAttribute::PROTECTED))
{
// override is os, there just treat as a normal apply on modes.
// override is on, there just treat as a normal apply on modes.
if (as.changed)
{

View File

@@ -78,14 +78,18 @@ class SG_EXPORT StateAttribute : public Object
OFF = 0x0,
/** means that associated GLMode is enabled and Override is disabled.*/
ON = 0x1,
/** Overriding of GLMode's or StateAttributes is enabled.*/
/** Overriding of GLMode's or StateAttributes is enabled, so that state below it is overriden.*/
OVERRIDE = 0x2,
/** Protecting of GLMode's os StateAttributes is enabled, so that state from above connot override this and below state.*/
PROTECTED = 0x4,
#ifdef USE_DEPRECATED_API
/** Equivilant to OFF | OVERRIDE.*/
OVERRIDE_OFF = 0x2,
/** Equivilant to ON | OVERRIDE.*/
OVERRIDE_ON = 0x3,
#endif
/** means that GLMode or StateAttribute should in inherited from above.*/
INHERIT = 0x4
INHERIT = 0x8
};
/** Type identifier to differentiate between different state types. */