SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
This factory class returns icon-constructors for Operations. More...
#include <OperationIcons.h>
Public Types | |
using | IconConstructor = std::function< std::string(const std::string &)> |
A function that takes a secondary color and returns icon data (as a string). | |
using | Index = smtk::operation::Operation::Index |
This class indexes icon-constructors the same way Operations are indexed. | |
using | IndexMap = std::unordered_map< std::string, Index > |
A map from operation names to operation indices used when creating icons by type-name. | |
using | FunctorMap = std::unordered_map< Index, IconConstructor > |
A map from operation indices to construction functors used when creating icons. | |
Public Member Functions | |
template<typename OperationType > | |
bool | registerOperation (IconConstructor &&functor) |
Register an icon constructor identified by the resource it represents. | |
void | registerDefaultIconConstructor (IconConstructor &&functor) |
Register a default icon constructor. More... | |
template<typename OperationType > | |
bool | unregisterOperation () |
Unregister an icon identified by the resource it represents. | |
template<typename OperationType > | |
std::string | createIcon (const std::string &secondaryColor) const |
Construct an icon identified by the operation it represents. More... | |
std::string | createIcon (const std::string &operationName, const std::string &secondaryColor) const |
std::string | createIcon (const Index &index, const std::string &secondaryColor) const |
This factory class returns icon-constructors for Operations.
An "icon" in this context is a binary array of the contents of an icon representation given an input secondary color (typically the background color). Currently, this corresponds to an ASCII description of an SVG image.
An IconConstructor is a functor that accepts an Operation and a string representing a secondary color and returns an icon for the Operation. Because operations are hierarchical (i.e., they may inherit other operations), IconConstructors registered to an operation may be used for derived operations when those have no registered icon. In this case, it is possible to use the provided Operation::Index to discern when an exact match or a derived operation is passed to your IconConstructor functor and alter the output accordindly.
|
inline |
Construct an icon identified by the operation it represents.
SecondaryColor is a background or nearby color that the icon must contrast with.
void smtk::view::OperationIcons::registerDefaultIconConstructor | ( | IconConstructor && | functor | ) |
Register a default icon constructor.
This constructor is used if no constructor can be found for an operation.