Commit 27126766 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - preparation for having grouped properties. Renamed all properties...

[CHANGE] - preparation for having grouped properties. Renamed all properties containing an / which is now reserved.
parent 18efe4dd
......@@ -29,10 +29,13 @@
#include "WLogger.h"
#include "exceptions/WPropertyUnknown.h"
#include "exceptions/WPropertyNotUnique.h"
#include "WProperties.h"
WProperties::WProperties():
WProperties::WProperties( std::string name, std::string description ):
m_name( name ),
m_description( description ),
m_propAccess( m_properties.getAccessObject() )
{
}
......@@ -41,9 +44,41 @@ WProperties::~WProperties()
{
}
std::string WProperties::getName() const
{
return m_name;
}
std::string WProperties::getDescription() const
{
return m_description;
}
bool WProperties::propNamePredicate( boost::shared_ptr< WPropertyBase > prop1, boost::shared_ptr< WPropertyBase > prop2 ) const
{
return ( prop1->getName() == prop2->getName() );
}
void WProperties::addProperty( boost::shared_ptr< WPropertyBase > prop )
{
m_propAccess->beginWrite();
// check uniqueness:
if ( std::count_if( m_propAccess->get().begin(), m_propAccess->get().end(),
boost::bind( boost::mem_fn( &WProperties::propNamePredicate ), this, prop, _1 ) ) )
{
m_propAccess->endWrite();
// oh oh, this property name is not unique in this group
if ( !getName().empty() )
{
throw WPropertyNotUnique( "Property \"" + prop->getName() + "\" is not unique in this group (\"" + getName() + "\")." );
}
else
{
throw WPropertyNotUnique( "Property \"" + prop->getName() + "\" is not unique in this group (unnamed root)." );
}
}
m_propAccess->get().push_back( prop );
m_propAccess->endWrite();
}
......
......@@ -39,8 +39,11 @@
#include "WPropertyVariable.h"
/**
* class to manage properties of an object and to provide convinience methods for easy access and manipulation. It also allows
* thread safe iteration on its elements.
* Class to manage properties of an object and to provide convenience methods for easy access and manipulation. It also allows
* thread safe iteration on its elements. The main purpose of this class is to group properties together and to allow searching properties by a
* given name. The name of each property in a group has to be unique and is constructed using the group names containing them: hello.you.property
* is the property with the name "property" in the group "you" which against is in the group "hello".
* \note The root group of each module does not have a name.
*/
class WProperties
{
......@@ -74,15 +77,34 @@ public:
typedef PropertyContainerType::iterator PropertyIterator;
/**
* standard constructor
* Constructor. Creates an empty list of properties.
*
* \note WModule::getProperties always returns an unnamed instance.
*
* \param name the name of the property group. The GUI is using this name for naming the tabs/group boxes
* \param description the description of the group.
*/
WProperties();
WProperties( std::string name = "", std::string description = "Root Group" );
/**
* destructor
*/
virtual ~WProperties();
/**
* The name of this property group.
*
* \return the name
*/
std::string getName() const;
/**
* The description of this property group.
*
* \return the description.
*/
std::string getDescription() const;
/**
* Simply insert the specified property to the list.
*
......@@ -753,6 +775,16 @@ public:
private:
/**
* The name of this properties group.
*/
std::string m_name;
/**
* The description of this property group.
*/
std::string m_description;
/**
* The set of proerties. This uses the operators ==,<,> WProperty to determine equalness.
*/
......@@ -762,6 +794,15 @@ private:
* Access to the above property list.
*/
PropertySharedContainerType::WSharedAccess m_propAccess;
/**
* Compares the names of two properties and returns true if they are equal.
*
* \param prop1 the first prop.
* \param prop2 the second prop.
*/
bool propNamePredicate( boost::shared_ptr< WPropertyBase > prop1, boost::shared_ptr< WPropertyBase > prop2 ) const;
};
template< typename T>
......
......@@ -27,6 +27,8 @@
#include <boost/filesystem.hpp>
#include "exceptions/WPropertyNameMalformed.h"
#include "WPropertyBase.h"
#include "WPropertyVariable.h"
......@@ -35,7 +37,12 @@ WPropertyBase::WPropertyBase( std::string name, std::string description ):
m_description( description ),
m_hidden( false )
{
// initialize members
// check name validity
if ( ( m_name.find( std::string( "/" ) ) != std::string::npos ) || m_name.empty() )
{
throw WPropertyNameMalformed( "Property name \"" + name +
"\" is malformed. Do not use slashes (\"/\") or empty strings in property names." );
}
}
WPropertyBase::~WPropertyBase()
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <string>
#include "WPropertyNameMalformed.h"
WPropertyNameMalformed::WPropertyNameMalformed( const std::string& msg )
: WException( msg )
{
// init members
}
WPropertyNameMalformed::~WPropertyNameMalformed() throw()
{
// clean up
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WPROPERTYNAMEMALFORMED_H
#define WPROPERTYNAMEMALFORMED_H
#include <string>
#include "../WException.h"
/**
* Indicates invalid property name.
*/
class WPropertyNameMalformed : public WException
{
public:
/**
* Default constructor.
* \param msg the exception message.
*/
explicit WPropertyNameMalformed( const std::string& msg = "The name of the property is malformed." );
/**
* Destructor.
*/
virtual ~WPropertyNameMalformed() throw();
protected:
private:
};
#endif // WPROPERTYNAMEMALFORMED_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <string>
#include "WPropertyNotUnique.h"
WPropertyNotUnique::WPropertyNotUnique( const std::string& msg )
: WException( msg )
{
// init members
}
WPropertyNotUnique::~WPropertyNotUnique() throw()
{
// clean up
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WPROPERTYNOTUNIQUE_H
#define WPROPERTYNOTUNIQUE_H
#include <string>
#include "../WException.h"
/**
* Indicates that a given property is not unique in a group of properties.
*/
class WPropertyNotUnique : public WException
{
public:
/**
* Default constructor.
* \param msg the exception message.
*/
explicit WPropertyNotUnique( const std::string& msg = "The property is not unique." );
/**
* Destructor.
*/
virtual ~WPropertyNotUnique() throw();
protected:
private:
};
#endif // WPROPERTYNOTUNIQUE_H
......@@ -124,5 +124,5 @@ void WMClusterParamDisplay::initSubModules()
m_properties->addProperty( m_fiberClustering->getProperties()->getProperty( "Go" ) );
m_properties->addProperty( m_voxelizer->getProperties()->getProperty( "Fiber Tracts" ) );
m_properties->addProperty( m_gaussFiltering->getProperties()->getProperty( "Iterations" ) );
m_properties->addProperty( m_clusterSlicer->getProperties()->getProperty( "Show/Hide ISO Voxels" ) );
m_properties->addProperty( m_clusterSlicer->getProperties()->getProperty( "Show or Hide ISO Voxels" ) );
}
......@@ -71,7 +71,7 @@ void WMClusterSlicer::connectors()
void WMClusterSlicer::properties()
{
m_drawISOVoxels = m_properties->addProperty( "Show/Hide ISO Voxels", "En/Disables to draw the voxels withing a given ISOSurface.", true );
m_drawISOVoxels = m_properties->addProperty( "Show or Hide ISO Voxels", "En/Disables to draw the voxels withing a given ISOSurface.", true );
m_isoValue = m_properties->addProperty( "Iso Value", "", 0.01 );
}
......
......@@ -198,7 +198,7 @@ void WMFiberDisplay::activate()
void WMFiberDisplay::properties()
{
m_customColoring = m_properties->addProperty( "Custom Coloring", "Switches the coloring between custom and predefined.", false );
m_coloring = m_properties->addProperty( "Global/Local Coloring", "Switches the coloring between global and local.", true );
m_coloring = m_properties->addProperty( "Global or Local Coloring", "Switches the coloring between global and local.", true );
m_useTubesProp = m_properties->addProperty( "Use Tubes", "Draw fiber tracts as fake tubes.", false );
m_tubeThickness = m_properties->addProperty( "Tube Thickness", "Adjusts the thickness of the tubes.", 50.,
......
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