From 8f40020fcb7e8b3e990e8b02fa49316eaef1a922 Mon Sep 17 00:00:00 2001 From: Matthew Territo Date: Fri, 22 Jul 2016 12:39:09 -0600 Subject: [PATCH 01/51] Add ability to append multiple Options to an OptionProperty via addOptions(vector, vector) --- include/openspace/properties/optionproperty.h | 7 +++++++ src/properties/optionproperty.cpp | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/openspace/properties/optionproperty.h b/include/openspace/properties/optionproperty.h index cd248fe336..1a84e93c3c 100644 --- a/include/openspace/properties/optionproperty.h +++ b/include/openspace/properties/optionproperty.h @@ -74,6 +74,13 @@ public: */ void addOption(int value, std::string desc); + /** + * Appends options with vectors of values and descriptions + * \param values A std::vector of values for the options + * \param descs A std::vector of descriptions for each value + */ + void addOptions(std::vector values, std::vector descs); + /** * Returns the list of available options. * /return The list of available options diff --git a/src/properties/optionproperty.cpp b/src/properties/optionproperty.cpp index 388bebe61a..ebd8b777a7 100644 --- a/src/properties/optionproperty.cpp +++ b/src/properties/optionproperty.cpp @@ -61,6 +61,23 @@ void OptionProperty::addOption(int value, std::string desc) { _options.push_back(std::move(option)); } +void OptionProperty::addOptions(std::vector values, std::vector descs) { + if (values.size() != descs.size()) { + LERROR("Skipping " << this->fullyQualifiedIdentifier() << ": " + << "number of values (" << values.size() << ") " + << "does not equal number of descriptions (" << descs.size() << ")" + ); + return; + } + for (int i = 0; i < values.size(); i++) { + LDEBUG(this->fullyQualifiedIdentifier() << ": Adding " + << descs[i] + << " (" << values[i] << ")" + ); + this->addOption(values[i], descs[i]); + } +} + void OptionProperty::setValue(int value) { // Check if the passed value belongs to any option for (auto o : _options) { From 2abd1951fad1a4a3b1ec4f29dc83f4a23b0ea619 Mon Sep 17 00:00:00 2001 From: Matthew Territo Date: Fri, 22 Jul 2016 19:07:32 -0600 Subject: [PATCH 02/51] Add display option to OptionProperty For displaying as Radio or Dropdown --- include/openspace/properties/optionproperty.h | 14 +++++++++++ modules/onscreengui/src/renderproperties.cpp | 25 +++++++++++++------ src/properties/optionproperty.cpp | 11 ++++++++ 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/include/openspace/properties/optionproperty.h b/include/openspace/properties/optionproperty.h index 1a84e93c3c..15eb71709f 100644 --- a/include/openspace/properties/optionproperty.h +++ b/include/openspace/properties/optionproperty.h @@ -50,13 +50,20 @@ public: std::string description; }; + enum class DisplayType { + RADIO, + DROPDOWN + }; + /** * The constructor delegating the identifier and the guiName * to its super class. * \param identifier A unique identifier for this property * \param guiName The GUI name that should be used to represent this property + * \param displayType Optional DisplayType for GUI (default RADIO) */ OptionProperty(std::string identifier, std::string guiName); + OptionProperty(std::string identifier, std::string guiName, DisplayType displayType); /** * Returns the name of the class for reflection purposes. @@ -65,6 +72,12 @@ public: std::string className() const override; using IntProperty::operator=; + /** + * Returns the type for GUI display. + * \return OptionType for display purposes + */ + DisplayType displayType() const; + /** * Adds the passed option to the list of available options. The value of * the option must not have been registered previously, or a warning will @@ -100,6 +113,7 @@ private: /// The list of options which have been registered with this OptionProperty std::vector