Skip to content

ENH: Adding Category and Advance Level Support for Discrete Item Enums

A Discrete Item's enums can now have a set of categories associated with it as well as advance level information. This information is used by the GUI system to filter out enums based on category and advance level settings.

  • setEnumCategories(const std::string& enumValue, const std::set<std::string>& cats);
  • addEnumCategory(const std::string& enumValue, const std::string& cat);
  • std::set<std::string> enumCategories(const std::string& enumValue) const;
  • const std::map<std::string, std::set<std::string>> enumCategoryInfo();
  • void setEnumAdvanceLevel(const std::string& enumValue, unsigned int level);
  • void unsetEnumAdvanceLevel(const std::string& enumValue);
  • unsigned int enumAdvanceLevel(const std::string& enumValue) const;
  • bool hasEnumAdvanceLevel(const std::string& enumValue) const;
  • const std::map<std::string, unsigned int> enumAdvanceLevelInfo() const;

Both JSON and XML IO has been updated to support the new functionality.

In terms of XML the following shows an example snippet for using the new capabilities:

       <String Name="s1" Label="Advance Level and Enum Test String" Version="0" OkToInheritCategories="true" CategoryCheckMode="Any" NumberOfRequiredValues="1">
        <Categories>
          <Cat>s1</Cat>
        </Categories>
        <DiscreteInfo>
          <Structure>
            <Value Enum="e1" AdvanceLevel="1">a</Value>
            <Categories>
              <Cat>ec1</Cat>
            </Categories>
          </Structure>
          <Structure>
            <Value Enum="e2">b</Value>
            <Categories>
              <Cat>ec2</Cat>
            </Categories>
          </Structure>
          <Value Enum="e3" AdvanceLevel="1">c</Value>
        </DiscreteInfo>
      </String>

See smtk/attribute/testing/cxx/unitCategoryTest.cxx and smtk/data/attribute/attribute_collection/ConfigurationTest.sbt for examples.

In addition to showing all of the possible enum values, the qtDiscreteValueEditor will include a "Please Select" option. This is used to show that the item is not set and can be used to unset the item.

Enums can now be filtered out based on the category and advance level information explicitly assigned to the enum. If the item's current value is not considered "valid" based on the current category/advance level settings, it is added to the list but is colored red to indicate that it is not considered "valid".

  • Also cleaned up JSON processing code for DiscreteItemDefinitions.

Addresses Issue #312 (closed)

Backport: release

Merge request reports