SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Types | Public Member Functions | List of all members
smtk::view::ObjectIcons Class Reference

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...
 

Detailed Description

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.

Member Function Documentation

◆ createIcon()

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.

◆ registerDefaultIconConstructor()

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.


The documentation for this class was generated from the following files: