Commit 2e42ebcb authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[FIX #237] the minimum and scale properties of the input texture are now...

[FIX #237] the minimum and scale properties of the input texture are now excluded from being set in the colormapper causing this bug.
parent cc17c6c6
......@@ -152,8 +152,19 @@ bool WPropertyGroup::set( boost::shared_ptr< WPropertyBase > value, bool recomme
return false;
}
// forward, use empty exclude list
return set( v, std::vector< std::string >(), recommendedOnly );
}
bool WPropertyGroup::set( boost::shared_ptr< WPropertyGroup > value, std::vector< std::string > exclude, bool recommendedOnly )
{
setImpl( value, "", exclude, recommendedOnly );
}
bool WPropertyGroup::setImpl( boost::shared_ptr< WPropertyGroup > value, std::string path, std::vector< std::string > exclude, bool recommendedOnly )
{
// go through each of the given child props
WPropertyGroup::PropertySharedContainerType::ReadTicket r = v->getReadTicket();
WPropertyGroup::PropertySharedContainerType::ReadTicket r = value->getReadTicket();
size_t c = 0; // number of props we have set
for( WPropertyGroupBase::PropertyConstIterator it = r->get().begin(); it != r->get().end(); ++it )
{
......@@ -164,12 +175,43 @@ bool WPropertyGroup::set( boost::shared_ptr< WPropertyBase > value, bool recomme
// not found. Ignore it. We cannot set the target property as the source did not exist
continue;
}
// ok there it is -> set
prop->set( *it, recommendedOnly );
c++;
// ok there it is. check exclude list.
// first: use the current property name and append it to path
std::string completePath = path + WPropertyGroupBase::separator + ( *it )->getName();
if( path == "" )
{
// no separator if the path is empty now
completePath = ( *it )->getName();
}
// now check exclude list
if( std::find( exclude.begin(), exclude.end(), completePath ) != exclude.end() )
{
// it is excluded
continue;
}
// not excluded. Is it a group or something else?
WPropertyGroup::SPtr meAsGroup = boost::shared_dynamic_cast< WPropertyGroup >( prop );
WPropertyGroup::SPtr inputAsGroup = boost::shared_dynamic_cast< WPropertyGroup >( *it );
if( inputAsGroup && meAsGroup )
{
// not excluded and is group, recurse:
c += meAsGroup->setImpl( inputAsGroup, completePath, exclude, recommendedOnly );
}
else if( inputAsGroup || meAsGroup ) // one group and one not a group, skip
{
continue;
}
else
{
c += prop->set( *it, recommendedOnly );
}
}
// success only if all props have been set
// NOTE: it think this only will ever be correct if we have no nested groups ...
return ( c == r->get().size() );
}
......
......@@ -158,6 +158,21 @@ public:
*/
virtual bool set( boost::shared_ptr< WPropertyBase > value, bool recommendedOnly = false );
/**
* This method is a special version of \ref WPropertyBase::set for groups. It allows to set the values of the contained properties. It does
* not add nor remove properties. It searches the property by name (recursively) and sets the value from the specified property group's
* property. You can use the exclusion list to exclude a certain property.
*
* \param value the source values
* \param exclude a list of property names to exclude. Use complete names here, which means, when having nested groups, apply the rules
* defined in \ref WPropertyGroupBase::findProperty.
* \param recommendedOnly if true, property types which support recommended values apply the given value as recommendation.
*
* \return true if the values of the children could be set. If one could not be set, false
*/
virtual bool set( boost::shared_ptr< WPropertyGroup > value, std::vector< std::string > exclude = std::vector< std::string >(),
bool recommendedOnly = false );
///////////////////////////////////////////////////////////////////////////////////////////////////
// Extend the WPropertyGroupBase to allow the property list to be modified
///////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -888,6 +903,20 @@ public:
WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
protected:
/**
* This function implements the set functionality. It works recursively and keeps track of the current path.
*
* \param value the value source
* \param path the current path inside the source property group
* \param exclude exclude list with paths relative to the original source group
* \param recommendedOnly recommendation flag.
*
* \return true if everything was set successfully.
*/
virtual bool setImpl( boost::shared_ptr< WPropertyGroup > value, std::string path = "",
std::vector< std::string > exclude = std::vector< std::string >(),
bool recommendedOnly = false );
private:
};
......
......@@ -39,6 +39,8 @@
#include "WPropertyGroupBase.h"
const std::string WPropertyGroupBase::separator = "/";
WPropertyGroupBase::WPropertyGroupBase( std::string name, std::string description ):
WPropertyBase( name, description ),
m_properties()
......@@ -106,7 +108,7 @@ boost::shared_ptr< WPropertyBase > WPropertyGroupBase::findProperty( std::string
// tokenize the name -> contains any paths?
typedef boost::tokenizer<boost::char_separator< char > > tokenizer;
boost::char_separator< char > sep( "/" ); // separate by /
boost::char_separator< char > sep( WPropertyGroupBase::separator.c_str() ); // separate by /
tokenizer tok( name, sep );
// iterate along the path
......
......@@ -83,6 +83,11 @@ public:
*/
typedef boost::shared_ptr< const WPropertyGroupBase > ConstSPtr;
/**
* The separator used to separate groups and subgroups
*/
static const std::string separator;
///////////////////////////////////////////////////////////////////////////////////////////////////
// Construction
///////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -152,7 +157,9 @@ public:
virtual PropertySharedContainerType::ReadTicket getReadTicket() const;
/**
* Searches the property with a given name. It does not throw any exception. It simply returns NULL if it can't be found.
* Searches the property with a given name. It does not throw any exception. It simply returns NULL if it can't be found. It searches
* in nested groups too. The naming rules for finding a property in subgroups of this group is like specifying a path, using the \ref
* separator char: "somegroup" + separator + "anothergroup" + separator + "propnametosearch".
*
* \param name the name of the property to search
*
......
......@@ -261,7 +261,11 @@ void WMColormapper::moduleMain()
dataSet->getTexture()->name()->get() << "\".";
// set the _recommended_ values from the previous ones
dataSet->getTexture()->getProperties()->set( m_lastDataSet->getTexture()->getProperties(), true );
// to avoid a critical issue with the minimum and scaler properties of the texture, we explicitly exclude them here.
std::vector< std::string > excludes;
excludes.push_back( "Minimum" );
excludes.push_back( "Scale" );
dataSet->getTexture()->getProperties()->set( m_lastDataSet->getTexture()->getProperties(), excludes, true );
// finally, set the new properties (and remove the old props)
m_properties->removeProperty( m_lastDataSet->getTexture()->getProperties() );
......
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