Simulation Modeling Tool Kit
Public Types | Public Member Functions | List of all members
smtk::view::OperationIcons Class Reference

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

Detailed Description

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.

Member Function Documentation

◆ createIcon()

template<typename OperationType >
std::string smtk::view::OperationIcons::createIcon ( const std::string &  secondaryColor) const

Construct an icon idenfified by the operation it represents.

SecondaryColor is a background or nearby color that the icon must contrast with.

◆ registerDefaultIconConstructor()

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.

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