Inviwo  0.9.10.1
Inviwo documentation
inviwo::ListProperty Class Reference

A property that has specified sub-properties which can be added using the graphical user interface. More...

#include <listproperty.h>

+ Inheritance diagram for inviwo::ListProperty:

Public Types

using iterator = std::vector< Property * >::iterator
 
using const_iterator = std::vector< std::unique_ptr< Property > >::const_iterator
 
- Public Types inherited from inviwo::PropertyOwner
using iterator = std::vector< Property * >::iterator
 
using const_iterator = std::vector< Property * >::const_iterator
 

Public Member Functions

virtual std::string getClassIdentifier () const override
 
 ListProperty (std::string identifier, const std::string &displayName, size_t maxNumberOfElements=0, ListPropertyUIFlags uiFlags=ListPropertyUIFlag::Add|ListPropertyUIFlag::Remove, InvalidationLevel invalidationLevel=InvalidationLevel::InvalidResources, PropertySemantics semantics=PropertySemantics::Default)
 
 ListProperty (std::string identifier, const std::string &displayName, std::vector< std::unique_ptr< Property >> prefabs, size_t maxNumberOfElements=0, ListPropertyUIFlags uiFlags=ListPropertyUIFlag::Add|ListPropertyUIFlag::Remove, InvalidationLevel invalidationLevel=InvalidationLevel::InvalidResources, PropertySemantics semantics=PropertySemantics::Default)
 
 ListProperty (std::string identifier, const std::string &displayName, std::unique_ptr< Property > prefab, size_t maxNumberOfElements=0, ListPropertyUIFlags uiFlags=ListPropertyUIFlag::Add|ListPropertyUIFlag::Remove, InvalidationLevel invalidationLevel=InvalidationLevel::InvalidResources, PropertySemantics semantics=PropertySemantics::Default)
 
 ListProperty (const ListProperty &rhs)
 
virtual ListPropertyclone () const override
 
virtual std::string getClassIdentifierForWidget () const override
 Returns which property's widget should be used when the WidgetFactory tries to create a widget. Defaults to getClassIdentifier(), should only be overridden if a subclass want to reuse another property's widget.
 
virtual void set (const Property *src) override
 
void set (const ListProperty *src)
 
void setMaxNumberOfElements (size_t n)
 set the max number of list elements. This will remove additional properties if the list property contains more than n items. More...
 
size_t getMaxNumberOfElements () const
 
void clear ()
 remove all list entries
 
void addProperty (size_t prefabIndex)
 add a list entry which is created from the respective prefab object. This function has no effect if the list size will exceed the maximum number of elements. More...
 
virtual void addProperty (Property *property, bool owner=true) override
 add property as new list entry. The type of the property must match one of the prefab objects. This function has no effect if the list size will exceed the maximum number of elements. More...
 
virtual void addProperty (Property &property) override
 add property as new list entry. The type of the property must match one of the prefab objects. This function has no effect if the list size will exceed the maximum number of elements. More...
 
virtual void insertProperty (size_t index, Property *property, bool owner=true) override
 insert property in the list at position index If index is not valid, the property is appended. The type of the property must match one of the prefab objects. This function has no effect if the list size will exceed the maximum number of elements. More...
 
virtual void insertProperty (size_t index, Property &property) override
 insert property in the list at position index If index is not valid, the property is appended. The type of the property must match one of the prefab objects. This function has no effect if the list size will exceed the maximum number of elements. More...
 
virtual PropertyremoveProperty (const std::string &identifier) override
 
virtual PropertyremoveProperty (Property *property) override
 
virtual PropertyremoveProperty (Property &property) override
 
virtual PropertyremoveProperty (size_t index) override
 remove property referred to by index More...
 
size_t getPrefabCount () const
 return number of prefab objects More...
 
void addPrefab (std::unique_ptr< Property > p)
 add a new prefab object p to be used as template when instantiating new list elements More...
 
const std::vector< std::unique_ptr< Property > > & getPrefabs () const
 
ListPropertyUIFlags getUIFlags () const
 
virtual void serialize (Serializer &s) const override
 
virtual void deserialize (Deserializer &d) override
 
- Public Member Functions inherited from inviwo::CompositeProperty
 CompositeProperty (const std::string &identifier, const std::string &displayName, InvalidationLevel invalidationLevel=InvalidationLevel::InvalidResources, PropertySemantics semantics=PropertySemantics::Default)
 
 CompositeProperty (const CompositeProperty &rhs)=default
 
virtual bool isCollapsed () const
 
virtual void setCollapsed (bool value)
 
virtual void setOwner (PropertyOwner *owner) override
 
void set (const CompositeProperty *src)
 
virtual void setValid () override
 
virtual InvalidationLevel getInvalidationLevel () const override
 
virtual CompositePropertysetCurrentStateAsDefault () override
 
virtual CompositePropertyresetToDefaultState () override
 
virtual CompositePropertysetReadOnly (bool value) override
 Enable or disable editing of property.
 
virtual void invalidate (InvalidationLevel invalidationLevel, Property *modifiedProperty=0) override
 
virtual ProcessorgetProcessor () override
 
virtual const ProcessorgetProcessor () const override
 
virtual std::vector< std::string > getPath () const override
 
- Public Member Functions inherited from inviwo::Property
 Property (const std::string &identifier="", const std::string &displayName="", InvalidationLevel invalidationLevel=InvalidationLevel::InvalidOutput, PropertySemantics semantics=PropertySemantics::Default)
 
virtual ~Property ()
 Removes itself from its PropertyOwner.
 
virtual PropertysetIdentifier (const std::string &identifier)
 
virtual std::string getIdentifier () const
 
virtual PropertysetDisplayName (const std::string &displayName)
 A property's name displayed to the user.
 
virtual std::string getDisplayName () const
 
virtual PropertysetSemantics (const PropertySemantics &semantics)
 
virtual PropertySemantics getSemantics () const
 
virtual bool getReadOnly () const
 
virtual PropertysetInvalidationLevel (InvalidationLevel invalidationLevel)
 
PropertyOwnergetOwner ()
 
const PropertyOwnergetOwner () const
 
void registerWidget (PropertyWidget *propertyWidget)
 
void deregisterWidget (PropertyWidget *propertyWidget)
 
const std::vector< PropertyWidget * > & getWidgets () const
 
void setInitiatingWidget (PropertyWidget *propertyWidget)
 
void clearInitiatingWidget ()
 
bool hasWidgets () const
 
virtual PropertypropertyModified ()
 
virtual PropertysetModified ()
 
virtual bool isModified () const
 
std::shared_ptr< std::function< void()> > onChangeScoped (std::function< void()> callback)
 
const BaseCallBack * onChange (std::function< void()> callback)
 
void removeOnChange (const BaseCallBack *callback)
 
template<typename T >
const BaseCallBack * onChange (T *object, void(T::*method)())
 
template<typename T >
void removeOnChange (T *object)
 
virtual PropertysetUsageMode (UsageMode usageMode)
 
virtual UsageMode getUsageMode () const
 
virtual void setSerializationMode (PropertySerializationMode mode)
 
virtual PropertySerializationMode getSerializationMode () const
 
virtual PropertysetVisible (bool val)
 
virtual bool getVisible () const
 
template<typename P , typename DecisionFunc >
PropertyvisibilityDependsOn (P &prop, DecisionFunc callback)
 
template<typename P , typename DecisionFunc >
PropertyreadonlyDependsOn (P &prop, DecisionFunc callback)
 
virtual Document getDescription () const
 
template<typename P >
PropertyautoLinkToProperty (const std::string &propertyPath)
 
const std::vector< std::pair< std::string, std::string > > & getAutoLinkToProperty () const
 
- Public Member Functions inherited from inviwo::Observable< PropertyObserver >
 Observable (const Observable< PropertyObserver > &other)
 
 Observable (Observable< PropertyObserver > &&other)
 
Observable< PropertyObserver > & operator= (const Observable< PropertyObserver > &other)
 
Observable< PropertyObserver > & operator= (Observable< PropertyObserver > &&other)
 
void addObserver (PropertyObserver *observer)
 
void removeObserver (PropertyObserver *observer)
 
virtual void startBlockingNotifications () override final
 
virtual void stopBlockingNotifications () override final
 
- Public Member Functions inherited from inviwo::MetaDataOwner
 MetaDataOwner (const MetaDataOwner &rhs)=default
 
MetaDataOwneroperator= (const MetaDataOwner &rhs)=default
 
void copyMetaDataFrom (const MetaDataOwner &src)
 
void copyMetaDataTo (MetaDataOwner &dst)
 
template<typename T >
T * createMetaData (const std::string &key)
 
template<typename T , typename U >
void setMetaData (const std::string &key, U value)
 
template<typename T >
bool unsetMetaData (const std::string &key)
 unset, i.e. remove the metadata entry matching the given key and type More...
 
template<typename T , typename U >
getMetaData (const std::string &key, U val) const
 
template<typename T >
T * getMetaData (const std::string &key)
 
template<typename T >
const T * getMetaData (const std::string &key) const
 
MetaDataMapgetMetaDataMap ()
 
const MetaDataMapgetMetaDataMap () const
 
template<typename T >
bool hasMetaData (const std::string &key) const
 
- Public Member Functions inherited from inviwo::PropertyOwner
virtual ~PropertyOwner ()
 Removes all properties and notifies its observers of the removal.
 
template<typename... Ts>
void addProperties (Ts &... properties)
 
const std::vector< Property * > & getProperties () const
 
const std::vector< CompositeProperty * > & getCompositeProperties () const
 
std::vector< Property * > getPropertiesRecursive () const
 
PropertygetPropertyByIdentifier (const std::string &identifier, bool recursiveSearch=false) const
 
PropertygetPropertyByPath (const std::vector< std::string > &path) const
 
template<class T >
std::vector< T * > getPropertiesByType (bool recursiveSearch=false) const
 
size_t size () const
 
Propertyoperator[] (size_t)
 
const Propertyoperator[] (size_t) const
 
iterator begin ()
 
iterator end ()
 
const_iterator cbegin () const
 
const_iterator cend () const
 
virtual bool isValid () const
 
InvalidationLevel getInvalidationLevel () const
 
void setAllPropertiesCurrentStateAsDefault ()
 
void resetAllPoperties ()
 
virtual void invokeEvent (Event *event) override
 
virtual InviwoApplicationgetInviwoApplication ()
 
- Public Member Functions inherited from inviwo::PropertyOwnerObservable
void notifyObserversWillAddProperty (Property *property, size_t index)
 
void notifyObserversDidAddProperty (Property *property, size_t index)
 
void notifyObserversWillRemoveProperty (Property *property, size_t index)
 
void notifyObserversDidRemoveProperty (Property *property, size_t index)
 
- Public Member Functions inherited from inviwo::Observable< PropertyOwnerObserver >
 Observable (const Observable< PropertyOwnerObserver > &other)
 
 Observable (Observable< PropertyOwnerObserver > &&other)
 
Observable< PropertyOwnerObserver > & operator= (const Observable< PropertyOwnerObserver > &other)
 
Observable< PropertyOwnerObserver > & operator= (Observable< PropertyOwnerObserver > &&other)
 
void addObserver (PropertyOwnerObserver *observer)
 
void removeObserver (PropertyOwnerObserver *observer)
 
virtual void startBlockingNotifications () override final
 
virtual void stopBlockingNotifications () override final
 
- Public Member Functions inherited from inviwo::Observable< CompositePropertyObserver >
 Observable (const Observable< CompositePropertyObserver > &other)
 
 Observable (Observable< CompositePropertyObserver > &&other)
 
Observable< CompositePropertyObserver > & operator= (const Observable< CompositePropertyObserver > &other)
 
Observable< CompositePropertyObserver > & operator= (Observable< CompositePropertyObserver > &&other)
 
void addObserver (CompositePropertyObserver *observer)
 
void removeObserver (CompositePropertyObserver *observer)
 
virtual void startBlockingNotifications () override final
 
virtual void stopBlockingNotifications () override final
 

Static Public Attributes

static const std::string classIdentifier = "org.inviwo.ListProperty"
 
- Static Public Attributes inherited from inviwo::CompositeProperty
static const std::string classIdentifier = "org.inviwo.CompositeProperty"
 

Additional Inherited Members

- Static Public Member Functions inherited from inviwo::Property
template<typename T , typename U >
static void setStateAsDefault (T &property, const U &state)
 
- Protected Member Functions inherited from inviwo::Property
 Property (const Property &rhs)
 
Propertyoperator= (const Property &that)=delete
 
void updateWidgets ()
 
void notifyAboutChange ()
 
- Protected Member Functions inherited from inviwo::PropertyObservable
void notifyObserversOnSetIdentifier (Property *property, const std::string &identifier)
 
void notifyObserversOnSetDisplayName (Property *property, const std::string &displayName)
 
void notifyObserversOnSetSemantics (Property *property, const PropertySemantics &semantics)
 
void notifyObserversOnSetReadOnly (Property *property, bool readonly)
 
void notifyObserversOnSetVisible (Property *property, bool visible)
 
void notifyObserversOnSetUsageMode (Property *property, UsageMode usageMode)
 
- Protected Member Functions inherited from inviwo::Observable< PropertyObserver >
void forEachObserver (C callback)
 
- Protected Member Functions inherited from inviwo::ObservableInterface
void addObservationHelper (Observer *observer)
 
void removeObservationHelper (Observer *observer)
 
- Protected Member Functions inherited from inviwo::PropertyOwner
 PropertyOwner (const PropertyOwner &rhs)
 
PropertyOwneroperator= (const PropertyOwner &that)=delete
 
- Protected Member Functions inherited from inviwo::Observable< PropertyOwnerObserver >
void forEachObserver (C callback)
 
- Protected Member Functions inherited from inviwo::CompositePropertyObservable
void notifyObserversOnSetCollapsed (bool collapsed)
 
- Protected Member Functions inherited from inviwo::Observable< CompositePropertyObserver >
void forEachObserver (C callback)
 
- Protected Attributes inherited from inviwo::Property
CallBackList onChangeCallback_
 
PropertySerializationMode serializationMode_
 
- Protected Attributes inherited from inviwo::MetaDataOwner
MetaDataMap metaData_
 
- Protected Attributes inherited from inviwo::PropertyOwner
std::vector< Property * > properties_
 
std::vector< EventProperty * > eventProperties_
 
std::vector< CompositeProperty * > compositeProperties_
 
std::vector< std::unique_ptr< Property > > ownedProperties_
 

Detailed Description

A property that has specified sub-properties which can be added using the graphical user interface.

Represents a list of properties. Properties can be added by using the prefab objects registered with the list property. The prefab objects serve as templates for instantiating new list entries. If the display name of the prefab object contains a trailing number, the number is incremented for each instance and used as display name of the newly added properties.

The UI flags (ListPropertyUIFlags) determine whether the widget will allow to add and/or remove list entries. The number of list elements is limited by setting maxNumberOfElements. A value of 0 refers to no limit.

Example:

// using a single prefab object and at most 10 elements
ListProperty listProperty("myListProperty", "My ListProperty",
std::make_unique<BoolProperty>("boolProp", "BoolProperty", true), 10);
// multiple prefab objects
ListProperty listProperty("myListProperty", "My List Property",
[]() {
std::vector<std::unique_ptr<Property>> v;
v.emplace_back(std::make_unique<IntProperty>("template1", "Template 1", 5, 0, 10));
v.emplace_back(std::make_unique<IntProperty>("template2", "Template 2", 2, 0, 99));
return v;
}());

This also works when using different types of properties as prefab objects:

ListProperty listProperty("myListProperty", "My List Property",
[]() {
std::vector<std::unique_ptr<Property>> v;
v.emplace_back(std::make_unique<BoolProperty>("boolProperty1", "Boolean Flag", true));
v.emplace_back(std::make_unique<TransferFunctionProperty>("tf1", "Transfer Function"));
v.emplace_back(std::make_unique<IntProperty>("template1", "Template 1", 5, 0, 10));
return v;
}());

Member Function Documentation

◆ addPrefab()

void inviwo::ListProperty::addPrefab ( std::unique_ptr< Property p)

add a new prefab object p to be used as template when instantiating new list elements

Parameters
pprefab object

◆ addProperty() [1/3]

void inviwo::ListProperty::addProperty ( size_t  prefabIndex)

add a list entry which is created from the respective prefab object. This function has no effect if the list size will exceed the maximum number of elements.

Parameters
prefabIndexindex of prefab object used for creating the new entry
Exceptions
RangeExceptionin case prefabIndex is invalid

◆ addProperty() [2/3]

void inviwo::ListProperty::addProperty ( Property property,
bool  owner = true 
)
overridevirtual

add property as new list entry. The type of the property must match one of the prefab objects. This function has no effect if the list size will exceed the maximum number of elements.

Parameters
propertyproperty to be added
ownerif true, the list property takes ownership of the property
Exceptions
Exceptionif the type of property does not match any prefab object

Reimplemented from inviwo::PropertyOwner.

◆ addProperty() [3/3]

void inviwo::ListProperty::addProperty ( Property property)
overridevirtual

add property as new list entry. The type of the property must match one of the prefab objects. This function has no effect if the list size will exceed the maximum number of elements.

Parameters
propertyproperty to be added
Exceptions
Exceptionif the type of property does not match any prefab object

Reimplemented from inviwo::PropertyOwner.

◆ clone()

ListProperty * inviwo::ListProperty::clone ( ) const
overridevirtual

Creates a clone of this property. The clone will have the same identifier, hence the identifier must be changed if the clone should be added to the same owner as this. The new clone does not have any owner set.

Reimplemented from inviwo::CompositeProperty.

◆ getPrefabCount()

size_t inviwo::ListProperty::getPrefabCount ( ) const

return number of prefab objects

Returns
count of prefabs

◆ insertProperty() [1/2]

void inviwo::ListProperty::insertProperty ( size_t  index,
Property property,
bool  owner = true 
)
overridevirtual

insert property in the list at position index If index is not valid, the property is appended. The type of the property must match one of the prefab objects. This function has no effect if the list size will exceed the maximum number of elements.

Parameters
indexinsertion point for property
propertyproperty to be inserted
ownerif true, the list property takes ownership of the property

Reimplemented from inviwo::PropertyOwner.

◆ insertProperty() [2/2]

void inviwo::ListProperty::insertProperty ( size_t  index,
Property property 
)
overridevirtual

insert property in the list at position index If index is not valid, the property is appended. The type of the property must match one of the prefab objects. This function has no effect if the list size will exceed the maximum number of elements.

Parameters
indexinsertion point for property
propertyproperty to be inserted

Reimplemented from inviwo::PropertyOwner.

◆ removeProperty()

Property * inviwo::ListProperty::removeProperty ( size_t  index)
overridevirtual

remove property referred to by index

Parameters
indexindex of property to be removed
Exceptions
RangeExceptionif index is not valid

Reimplemented from inviwo::PropertyOwner.

◆ set()

void inviwo::ListProperty::set ( const Property src)
overridevirtual

Set the value of this to that of src. The "value" is in this case considered to be for example the string in a StringProperty or the float value in a FloatProperty. But not things like the identifier of display name.

Reimplemented from inviwo::CompositeProperty.

◆ setMaxNumberOfElements()

void inviwo::ListProperty::setMaxNumberOfElements ( size_t  n)

set the max number of list elements. This will remove additional properties if the list property contains more than n items.

Parameters
nmaximum number of elements in this list property

The documentation for this class was generated from the following files: