SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
An icon factory creates icons for Resources and their Components. More...
#include <ObjectIcons.h>
Public Types | |
using | IconConstructor = std::function< std::string(const smtk::resource::PersistentObject &, const std::string &)> |
Public Member Functions | |
template<typename ResourceType > | |
bool | registerIconConstructor (IconConstructor &&) |
Register an icon constructor identified by the resource it represents. | |
bool | registerIconConstructor (const std::string &, IconConstructor &&) |
Register an icon constructor identified by the type name of the resource it represents. | |
bool | registerDefaultIconConstructor (IconConstructor &&) |
Register a default icon constructor. More... | |
template<typename ResourceType > | |
bool | unregisterIconConstructor () |
Unregister an icon identified by the resource it represents. | |
bool | unregisterIconConstructor (const std::string &) |
Unregister an icon identified by the type name of the resource it represents. | |
std::string | createIcon (const smtk::resource::PersistentObject &, const std::string &secondaryColor) const |
construct an icon idenfified by the resource or component it represents. More... | |
An icon factory creates icons for Resources and their Components.
An "Icon" in this context is a binary array of the contents of an icon representation given an input secondary color (a common color offset from the background used to draw unhighlighted icon features; e.g. black for a white background). Currently, this corresponds to an ASCII description of an SVG image.
An IconConstructor is a functor that accepts a PersistentObject and a string representing a secondary color and returns an icon for the PersistentObject. Because Resources contain hierarchical queries (e.g. is Resource A derived from Resource B), IconConstructors registered to a Resource are expected to return icons for the Resource and its Components, facilitating the inheritance of icon sets from parent Resources. Icon constructors can be defined for any PersistentObject, however; if an IconConstructor is registered to a PersistentObject type, this IconConstructor will have highest priority when an icon for this PersistentObject is requested.
std::string smtk::view::ObjectIcons::createIcon | ( | const smtk::resource::PersistentObject & | object, |
const std::string & | secondaryColor | ||
) | const |
construct an icon idenfified by the resource or component it represents.
secondaryColor is used for edges, and should contrast any background.
bool smtk::view::ObjectIcons::registerDefaultIconConstructor | ( | IconConstructor && | iconConstructor | ) |
Register a default icon constructor.
This constructor is used if no constructor can be identified as associated with an input resource.