#include <mitkEnumerationProperty.h>
Public Types | |
typedef EnumerationProperty | Self |
typedef BaseProperty | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer < const Self > | ConstPointer |
typedef unsigned int | IdType |
typedef std::map< IdType, std::string > | EnumIdsContainerType |
typedef std::map< std::string, IdType > | EnumStringsContainerType |
typedef EnumIdsContainerType::const_iterator | EnumConstIterator |
Public Member Functions | |
virtual const char * | GetClassName () const |
virtual bool | AddEnum (const std::string &name, const IdType &id) |
virtual bool | SetValue (const std::string &name) |
virtual bool | SetValue (const IdType &id) |
virtual IdType | GetValueAsId () const |
virtual std::string | GetValueAsString () const |
virtual void | Clear () |
virtual EnumIdsContainerType::size_type | Size () const |
virtual EnumConstIterator | Begin () const |
virtual EnumConstIterator | End () const |
virtual std::string | GetEnumString (const IdType &id) const |
virtual IdType | GetEnumId (const std::string &name) const |
virtual bool | IsValidEnumerationValue (const IdType &val) const |
virtual bool | IsValidEnumerationValue (const std::string &val) const |
virtual bool | operator== (const BaseProperty &property) const |
Subclasses must implement this operator==. Operator== which is used by PropertyList to check whether a property has been changed. | |
const EnumIdsContainerType & | GetEnumIds () const |
const EnumStringsContainerType & | GetEnumStrings () const |
EnumIdsContainerType & | GetEnumIds () |
EnumStringsContainerType & | GetEnumStrings () |
Static Public Member Functions | |
static Pointer | New () |
Protected Member Functions | |
EnumerationProperty () |
This class may be used to store properties similar to enumeration values. Each enumeration value is identified via a string representation and a id. Note, that both string representation and id MUST be unique. This is checked when inserting a new enumeration value. Please note that you have to add valid enumeration values before you may use the Get/SetValue methods.
To use the class enumeration property you have 2 choices:
1. Directly use the class and add your possible enumeration values via AddEnum(name, id). NOte that the ids do not have to be in any order, they just have to be unique. The current value is set via SetValue(...) and retrieved via GetValueAsId() or GetValueAsString(). 2. Create a subclass, which adds the possible enumeration values in its constructor and maybe adds some additional convenience functions to set/get the value. NOte that you should override AddEnum(...) as protected so that the user may not add additional invalid enumeration values. As example see mitk::VtkRepresentationProperty or mitk::VtkInterpolationProperty
Definition at line 49 of file mitkEnumerationProperty.h.
typedef itk::SmartPointer<const Self> mitk::EnumerationProperty::ConstPointer |
Reimplemented from mitk::BaseProperty.
Reimplemented in mitk::ModalityProperty, mitk::PlaneOrientationProperty, mitk::ResliceMethodProperty, mitk::ShaderProperty, mitk::VtkInterpolationProperty, mitk::VtkRepresentationProperty, mitk::VtkResliceInterpolationProperty, mitk::VtkScalarModeProperty, mitk::VtkVolumeRenderingProperty, mitk::OdfNormalizationMethodProperty, mitk::OdfScaleByProperty, mitk::GridRepresentationProperty, mitk::GridVolumeMapperProperty, mitk::OrganTypeProperty, and mitk::PlanarFigureControlPointStyleProperty.
Definition at line 53 of file mitkEnumerationProperty.h.
typedef EnumIdsContainerType::const_iterator mitk::EnumerationProperty::EnumConstIterator |
Type used for iterators over all defined enumeration values.
Definition at line 77 of file mitkEnumerationProperty.h.
typedef std::map<IdType, std::string> mitk::EnumerationProperty::EnumIdsContainerType |
Type used to store a mapping from enumeration id to enumeration string/ description
Definition at line 66 of file mitkEnumerationProperty.h.
typedef std::map<std::string, IdType> mitk::EnumerationProperty::EnumStringsContainerType |
Type used to store a mapping from enumeration string/description to enumeration id
Definition at line 72 of file mitkEnumerationProperty.h.
typedef unsigned int mitk::EnumerationProperty::IdType |
Represents the unique id which is asigned to each enumeration value
Definition at line 55 of file mitkEnumerationProperty.h.
typedef itk::SmartPointer<Self> mitk::EnumerationProperty::Pointer |
Reimplemented from mitk::BaseProperty.
Reimplemented in mitk::ModalityProperty, mitk::PlaneOrientationProperty, mitk::ResliceMethodProperty, mitk::ShaderProperty, mitk::VtkInterpolationProperty, mitk::VtkRepresentationProperty, mitk::VtkResliceInterpolationProperty, mitk::VtkScalarModeProperty, mitk::VtkVolumeRenderingProperty, mitk::OdfNormalizationMethodProperty, mitk::OdfScaleByProperty, mitk::GridRepresentationProperty, mitk::GridVolumeMapperProperty, mitk::OrganTypeProperty, and mitk::PlanarFigureControlPointStyleProperty.
Definition at line 53 of file mitkEnumerationProperty.h.
Reimplemented from mitk::BaseProperty.
Reimplemented in mitk::ModalityProperty, mitk::PlaneOrientationProperty, mitk::ResliceMethodProperty, mitk::ShaderProperty, mitk::VtkInterpolationProperty, mitk::VtkRepresentationProperty, mitk::VtkResliceInterpolationProperty, mitk::VtkScalarModeProperty, mitk::VtkVolumeRenderingProperty, mitk::OdfNormalizationMethodProperty, mitk::OdfScaleByProperty, mitk::GridRepresentationProperty, mitk::GridVolumeMapperProperty, mitk::OrganTypeProperty, and mitk::PlanarFigureControlPointStyleProperty.
Definition at line 53 of file mitkEnumerationProperty.h.
Reimplemented from mitk::BaseProperty.
Reimplemented in mitk::ModalityProperty, mitk::PlaneOrientationProperty, mitk::ResliceMethodProperty, mitk::ShaderProperty, mitk::VtkInterpolationProperty, mitk::VtkRepresentationProperty, mitk::VtkResliceInterpolationProperty, mitk::VtkScalarModeProperty, mitk::VtkVolumeRenderingProperty, mitk::OdfNormalizationMethodProperty, mitk::OdfScaleByProperty, mitk::GridRepresentationProperty, mitk::GridVolumeMapperProperty, mitk::OrganTypeProperty, and mitk::PlanarFigureControlPointStyleProperty.
Definition at line 53 of file mitkEnumerationProperty.h.
mitk::EnumerationProperty::EnumerationProperty | ( | ) | [protected] |
Default constructor. The current value of the enumeration is undefined.
Definition at line 26 of file mitkEnumerationProperty.cpp.
{ m_CurrentValue = 0; }
bool mitk::EnumerationProperty::AddEnum | ( | const std::string & | name, |
const IdType & | id | ||
) | [virtual] |
Adds an enumeration value into the enumeration. The name and id provided must be unique. This is checked while adding the new enumeration value. If it is not unique, false is returned. If addition was successful, true is returned.
name | the unique string representation of the enumeration value |
id | the unique integer representation of the enumeration value |
Reimplemented in mitk::PlaneOrientationProperty, mitk::VtkInterpolationProperty, mitk::VtkRepresentationProperty, mitk::VtkResliceInterpolationProperty, mitk::VtkScalarModeProperty, mitk::VtkVolumeRenderingProperty, mitk::OdfNormalizationMethodProperty, mitk::OdfScaleByProperty, mitk::GridRepresentationProperty, mitk::GridVolumeMapperProperty, and mitk::PlanarFigureControlPointStyleProperty.
Definition at line 32 of file mitkEnumerationProperty.cpp.
{ if ( ( ! IsValidEnumerationValue( name ) ) && ( ! IsValidEnumerationValue( id ) ) ) { GetEnumIds().insert( std::make_pair( id, name ) ); GetEnumStrings().insert( std::make_pair( name, id ) ); return true; } else { return false; } }
mitk::EnumerationProperty::EnumConstIterator mitk::EnumerationProperty::Begin | ( | ) | const [virtual] |
Provides access to the set of known enumeration values. The string representation may be accessed via iterator->second, the id may be access via iterator->first
Definition at line 101 of file mitkEnumerationProperty.cpp.
Referenced by QmitkDataManagerView::SurfaceRepresentationMenuAboutToShow().
{ return GetEnumIds().begin(); }
void mitk::EnumerationProperty::Clear | ( | ) | [virtual] |
Clears all possible enumeration values and the current enumeration value.
Definition at line 86 of file mitkEnumerationProperty.cpp.
{ GetEnumIds().clear(); GetEnumStrings().clear(); m_CurrentValue = 0; }
mitk::EnumerationProperty::EnumConstIterator mitk::EnumerationProperty::End | ( | ) | const [virtual] |
Specifies the end of the range of the known enumeration values.
Definition at line 107 of file mitkEnumerationProperty.cpp.
Referenced by QmitkDataManagerView::SurfaceRepresentationMenuAboutToShow().
{ return GetEnumIds().end(); }
virtual const char* mitk::EnumerationProperty::GetClassName | ( | ) | const [virtual] |
Reimplemented from mitk::BaseProperty.
Reimplemented in mitk::ModalityProperty, mitk::PlaneOrientationProperty, mitk::ResliceMethodProperty, mitk::ShaderProperty, mitk::VtkInterpolationProperty, mitk::VtkRepresentationProperty, mitk::VtkResliceInterpolationProperty, mitk::VtkScalarModeProperty, mitk::VtkVolumeRenderingProperty, mitk::OdfNormalizationMethodProperty, mitk::OdfScaleByProperty, mitk::GridRepresentationProperty, mitk::GridVolumeMapperProperty, mitk::OrganTypeProperty, and mitk::PlanarFigureControlPointStyleProperty.
mitk::EnumerationProperty::IdType mitk::EnumerationProperty::GetEnumId | ( | const std::string & | name ) | const [virtual] |
Returns the integer representation for the given string.
name | the enumeration name for which the integer representation should be determined if the name is invalid, the return value is unspecified. |
Definition at line 126 of file mitkEnumerationProperty.cpp.
{ if ( IsValidEnumerationValue( name ) ) { return GetEnumStrings().find( name )->second; } else { return 0; } }
const mitk::EnumerationProperty::EnumIdsContainerType & mitk::EnumerationProperty::GetEnumIds | ( | ) | const |
Definition at line 175 of file mitkEnumerationProperty.cpp.
{ std::string className = this->GetNameOfClass(); // virtual! return s_IdMapForClassName[ className ]; }
mitk::EnumerationProperty::EnumIdsContainerType & mitk::EnumerationProperty::GetEnumIds | ( | ) |
Definition at line 168 of file mitkEnumerationProperty.cpp.
{ std::string className = this->GetNameOfClass(); // virtual! return s_IdMapForClassName[ className ]; }
std::string mitk::EnumerationProperty::GetEnumString | ( | const IdType & | id ) | const [virtual] |
Returns the string representation for the given id.
id | the id for which the string representation should be determined if id is invalid, the return value is unspecified. |
Definition at line 113 of file mitkEnumerationProperty.cpp.
{ if ( IsValidEnumerationValue( id ) ) { return GetEnumIds().find( id )->second; } else { return "invalid enum id or enums empty"; } }
const mitk::EnumerationProperty::EnumStringsContainerType & mitk::EnumerationProperty::GetEnumStrings | ( | ) | const |
Definition at line 189 of file mitkEnumerationProperty.cpp.
{ std::string className = this->GetNameOfClass(); // virtual! return s_StringMapForClassName[ className ]; }
mitk::EnumerationProperty::EnumStringsContainerType & mitk::EnumerationProperty::GetEnumStrings | ( | ) |
Definition at line 182 of file mitkEnumerationProperty.cpp.
{ std::string className = this->GetNameOfClass(); // virtual! return s_StringMapForClassName[ className ]; }
mitk::EnumerationProperty::IdType mitk::EnumerationProperty::GetValueAsId | ( | ) | const [virtual] |
Returns the id of the current enumeration value. If it was not yet set, the return value is unspecified
Definition at line 75 of file mitkEnumerationProperty.cpp.
Referenced by mitk::VolumeDataVtkMapper3D::GenerateData(), mitk::ImageMapperGL2D::GenerateData(), and QmitkRenderWindowMenu::OnCrossHairMenuAboutToShow().
{
return m_CurrentValue;
}
std::string mitk::EnumerationProperty::GetValueAsString | ( | ) | const [virtual] |
Returns the string representation of the current enumeration value. If it was not yet set, the return value is unspecified
Reimplemented from mitk::BaseProperty.
Definition at line 80 of file mitkEnumerationProperty.cpp.
Referenced by mitk::ShaderRepository::ApplyProperties(), QmitkDataManagerView::SurfaceRepresentationActionToggled(), and QmitkDataManagerView::SurfaceRepresentationMenuAboutToShow().
{ return GetEnumString( m_CurrentValue ); }
bool mitk::EnumerationProperty::IsValidEnumerationValue | ( | const std::string & | val ) | const [virtual] |
Determines if a given string representation of an enumeration value is valid or not
val | the string to check |
Definition at line 162 of file mitkEnumerationProperty.cpp.
{ return ( GetEnumStrings().find( val ) != GetEnumStrings().end() ); }
bool mitk::EnumerationProperty::IsValidEnumerationValue | ( | const IdType & | val ) | const [virtual] |
Determines if a given integer representation of an enumeration value is valid or not
val | the integer value to check |
Definition at line 156 of file mitkEnumerationProperty.cpp.
Referenced by QmitkDataManagerView::SurfaceRepresentationActionToggled().
{ return ( GetEnumIds().find( val ) != GetEnumIds().end() ); }
static Pointer mitk::EnumerationProperty::New | ( | ) | [static] |
Reimplemented in mitk::ModalityProperty, mitk::PlaneOrientationProperty, mitk::ResliceMethodProperty, mitk::ShaderProperty, mitk::VtkInterpolationProperty, mitk::VtkRepresentationProperty, mitk::VtkResliceInterpolationProperty, mitk::VtkScalarModeProperty, mitk::VtkVolumeRenderingProperty, mitk::OdfNormalizationMethodProperty, mitk::OdfScaleByProperty, mitk::GridRepresentationProperty, mitk::GridVolumeMapperProperty, mitk::OrganTypeProperty, and mitk::PlanarFigureControlPointStyleProperty.
Referenced by mitkEnumerationPropertyTest().
bool mitk::EnumerationProperty::operator== | ( | const BaseProperty & | property ) | const [virtual] |
Subclasses must implement this operator==. Operator== which is used by PropertyList to check whether a property has been changed.
Implements mitk::BaseProperty.
Definition at line 139 of file mitkEnumerationProperty.cpp.
bool mitk::EnumerationProperty::SetValue | ( | const std::string & | name ) | [virtual] |
Sets the current value of the enumeration
name | the string representation of the enumeration value to set |
Definition at line 47 of file mitkEnumerationProperty.cpp.
Referenced by mitk::GridRepresentationProperty::GridRepresentationProperty(), mitk::GridVolumeMapperProperty::GridVolumeMapperProperty(), mitk::OdfNormalizationMethodProperty::OdfNormalizationMethodProperty(), mitk::OdfScaleByProperty::OdfScaleByProperty(), mitk::PlanarFigureControlPointStyleProperty::PlanarFigureControlPointStyleProperty(), mitk::PlaneOrientationProperty::PlaneOrientationProperty(), mitk::ResliceMethodProperty::ResliceMethodProperty(), QmitkDataManagerView::SurfaceRepresentationActionToggled(), mitk::VtkInterpolationProperty::VtkInterpolationProperty(), mitk::VtkRepresentationProperty::VtkRepresentationProperty(), mitk::VtkResliceInterpolationProperty::VtkResliceInterpolationProperty(), and mitk::VtkVolumeRenderingProperty::VtkVolumeRenderingProperty().
{ if ( IsValidEnumerationValue( name ) ) { m_CurrentValue = GetEnumId( name ); Modified(); return true; } else { return false; } }
bool mitk::EnumerationProperty::SetValue | ( | const IdType & | id ) | [virtual] |
Sets the current value of the enumeration
id | the integer representation of the enumeration value to set |
Definition at line 61 of file mitkEnumerationProperty.cpp.
{ if ( IsValidEnumerationValue( id ) ) { m_CurrentValue = id; Modified(); return true; } else { return false; } }
mitk::EnumerationProperty::EnumIdsContainerType::size_type mitk::EnumerationProperty::Size | ( | ) | const [virtual] |
Determines the number of enumeration values which have been added via AddEnum(...).
Definition at line 94 of file mitkEnumerationProperty.cpp.
Referenced by mitk::OrganTypeProperty::AddEnumerationTypes(), and mitk::ModalityProperty::AddEnumerationTypes().
{ return GetEnumIds().size(); }