ImFusion C++ SDK 4.5.0
ImFusion::AnatomyPlugin::StyleSheet::StyleRule Class Reference

#include <AnatomyPlugin/include/ImFusion/AnatomyPlugin/StyleSheet.h>

Single "style" entry consisting of a selector (that matches a subset of objects) and a set of property-value pairs (a Properties instance declaration) This is the fundamental build block of styling in the anatomy plugin. More...

Inheritance diagram for ImFusion::AnatomyPlugin::StyleSheet::StyleRule:

Detailed Description

Single "style" entry consisting of a selector (that matches a subset of objects) and a set of property-value pairs (a Properties instance declaration) This is the fundamental build block of styling in the anatomy plugin.

For example, a selector "*" would match all objects and a declaration {"color": vec4(1.0, 0.0, 0.0, 1.0)} would set the color of all objects to red.

Public Member Functions

 StyleRule (Selector selector=Selector{}, Properties declaration=Properties{})
void configure (const Properties *p) override
 Configure this object instance by de-serializing the given Properties.
void configuration (Properties *p) const override
 Serialize the current object configuration into the given Properties object.
Selector & selector ()
const Selector & selector () const
Properties & declaration ()
const Properties & declaration () const
std::string toText (bool rgbaToHex) const
 Converts this object to its textual representation.
Public Member Functions inherited from ImFusion::Configurable
virtual void configureDefaults ()
 Retrieve the properties of this object, replaces values with their defaults and sets it again.
void registerParameter (ParameterBase *param)
 Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration().
void unregisterParameter (const ParameterBase *param)
 Remove the given Parameter or SubProperty from the list of registered parameters.
 Configurable (const Configurable &rhs)
 Configurable (Configurable &&rhs) noexcept
Configurable & operator= (const Configurable &)
Configurable & operator= (Configurable &&) noexcept

Static Public Member Functions

static std::vector< const StyleSheet::StyleRule * > filter (const std::vector< const StyleSheet::StyleRule * > &styles, const std::string &identifier, const Properties &attributesStructure, std::optional< AnatomicalStructure::ContentType > ct, const std::string &key, const Properties &attributesObject, const std::set< std::string > &pseudoClasses)
 Convenience function for filtering a set of StyleRule objects based on whether they "match" a specified object in the specified setting.
static Properties combine (const std::vector< const StyleSheet::StyleRule * > &matchingRules, std::optional< std::reference_wrapper< const Properties > > attributesObjectForOverride)
 Combine a list of StyleRules objects into a single Properties instances containing the final property-name to value pairs that should be applied to the object.
static std::optional< StyleRule > fromText (std::string_view text)
 Creates a StyleRule from its textual representation.

Additional Inherited Members

Public Attributes inherited from ImFusion::Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
Protected Attributes inherited from ImFusion::Configurable
std::vector< Param > m_params
 List of all registered Parameter and SubProperty instances.

Member Function Documentation

◆ configure()

void ImFusion::AnatomyPlugin::StyleSheet::StyleRule::configure ( const Properties * p)
overridevirtual

Configure this object instance by de-serializing the given Properties.

The default implementation will do so automatically for all registered Parameter and SubProperty instances.

See also
configuration() for the inverse functionality

Reimplemented from ImFusion::Configurable.

◆ configuration()

void ImFusion::AnatomyPlugin::StyleSheet::StyleRule::configuration ( Properties * p) const
overridevirtual

Serialize the current object configuration into the given Properties object.

The default implementation will do so automatically for all registered Parameter and SubProperty instances.

See also
configure() for the inverse functionality

Reimplemented from ImFusion::Configurable.

◆ toText()

std::string ImFusion::AnatomyPlugin::StyleSheet::StyleRule::toText ( bool rgbaToHex) const

Converts this object to its textual representation.

Generates a string representation of the StyleRule using a syntax inspired by CSS and Qt stylesheets for key-value pairs.

Parameters
rgbaToHexIf true, color values stored internally in RGBA format are converted to hexadecimal string representation. Named colors are not affected by this conversion.
Returns
A string representing the StyleRule.
See also
StyleRule::fromText()
StyleSheet::toText()

◆ fromText()

std::optional< StyleRule > ImFusion::AnatomyPlugin::StyleSheet::StyleRule::fromText ( std::string_view text)
static

Creates a StyleRule from its textual representation.

Parses the given text using a syntax inspired by CSS and Qt stylesheets for key-value pairs.

Parameters
textThe input text to parse.
Returns
A StyleRule if parsing succeeds; otherwise, an empty std::optional
See also
StyleRule::toText()
StyleSheet::fromText()

The documentation for this class was generated from the following file:
  • AnatomyPlugin/include/ImFusion/AnatomyPlugin/StyleSheet.h
Search Tab / S to search, Esc to close