Belle II Software development
DefaultColorCycleStyling< AObject > Class Template Reference

Class template for coloring objects with stroke colors prepared to be the default color cycle. More...

#include <Styling.h>

Inheritance diagram for DefaultColorCycleStyling< AObject >:
ChooseableStyling< AObject > Styling< AObject >

Public Types

using ObjectMapping = Mapping<AObject>
 Mapping for the object type.
 

Public Member Functions

 DefaultColorCycleStyling ()
 Constructor. Sets the stroke mapping the the default color cycle.
 
AttributeMap map (int index, AObject &object) override
 Create a map of attributes from the stored attribute maps.
 
std::string info () override
 Returns informal string about the currently set mappings.
 
virtual std::unique_ptr< ObjectMappingcreateMapping (const std::string &mappingName)
 Create a mapping for the object from a name.
 
void set (const std::string &key, std::unique_ptr< ObjectMapping > mapping)
 Sets the given attribute to the attribute mapping.
 
void set (const std::string &key, const std::string &mappingName)
 Sets the given attribute to the fixed value.
 
void setStroke (const std::string &mappingName)
 Legacy method to set the mapping on how to match a object to the stroke color.
 
void setStrokeWidth (const std::string &mappingName)
 Legacy method to set the mapping on how to match a object to the stroke width.
 

Protected Attributes

std::map< std::string, std::unique_ptr< ObjectMapping > > m_mappingsByKey
 Map of attribute keys to mappings to be used.
 

Detailed Description

template<class AObject>
class Belle2::TrackFindingCDC::DefaultColorCycleStyling< AObject >

Class template for coloring objects with stroke colors prepared to be the default color cycle.

Definition at line 187 of file Styling.h.

Member Typedef Documentation

◆ ObjectMapping

template<class AObject>
using ObjectMapping = Mapping<AObject>
inherited

Mapping for the object type.

Definition at line 105 of file Styling.h.

Constructor & Destructor Documentation

◆ DefaultColorCycleStyling()

template<class AObject>
DefaultColorCycleStyling ( )
inline

Constructor. Sets the stroke mapping the the default color cycle.

Definition at line 190 of file Styling.h.

190 : ChooseableStyling<AObject>()
191 {
192 this->set("stroke", std::make_unique<DefaultColorCycleMapping<AObject>>());
193 }

Member Function Documentation

◆ createMapping()

template<class AObject>
virtual std::unique_ptr< ObjectMapping > createMapping ( const std::string & mappingName)
inlinevirtualinherited

Create a mapping for the object from a name.

Can be overridden by the subclass to introduce names with specific meanings. The default is to use the name as a fixed attribute value.

Reimplemented in ChooseableHitStyling, ChooseableRecoTrackStyling, and ChooseableSegmentStyling.

Definition at line 138 of file Styling.h.

139 {
140 return std::make_unique<ConstantMapping<AObject>>(mappingName);
141 }

◆ info()

template<class AObject>
std::string info ( )
inlineoverridevirtualinherited

Returns informal string about the currently set mappings.

Reimplemented from Styling< AObject >.

Definition at line 121 of file Styling.h.

122 {
123 std::ostringstream oss;
124 for (const auto& keyMapping : m_mappingsByKey) {
125 const std::string& key = keyMapping.first;
126 const std::unique_ptr<ObjectMapping>& mapping = keyMapping.second;
127 oss << key << ": " << mapping->info();
128 }
129 return oss.str();
130 }

◆ map()

template<class AObject>
AttributeMap map ( int index,
AObject & object )
inlineoverridevirtualinherited

Create a map of attributes from the stored attribute maps.

Reimplemented from Styling< AObject >.

Definition at line 109 of file Styling.h.

110 {
111 AttributeMap attributeMap;
112 for (const auto& keyMapping : m_mappingsByKey) {
113 const std::string& key = keyMapping.first;
114 const std::unique_ptr<ObjectMapping>& mapping = keyMapping.second;
115 attributeMap[key] = mapping->map(index, object);
116 }
117 return attributeMap;
118 }

◆ set() [1/2]

template<class AObject>
void set ( const std::string & key,
const std::string & mappingName )
inlineinherited

Sets the given attribute to the fixed value.

Definition at line 152 of file Styling.h.

153 {
154 std::unique_ptr<ObjectMapping> objectMapping = this->createMapping(mappingName);
155 if (objectMapping) {
156 set(key, std::move(objectMapping));
157 }
158 }

◆ set() [2/2]

template<class AObject>
void set ( const std::string & key,
std::unique_ptr< ObjectMapping > mapping )
inlineinherited

Sets the given attribute to the attribute mapping.

Definition at line 144 of file Styling.h.

145 {
146 if (mapping) {
147 m_mappingsByKey[key] = std::move(mapping);
148 }
149 }

◆ setStroke()

template<class AObject>
void setStroke ( const std::string & mappingName)
inlineinherited

Legacy method to set the mapping on how to match a object to the stroke color.

Parameters
mappingNameThe Name of the Mapping to be used. The translation from name to Mapping class must be defined in createMapping.

Definition at line 165 of file Styling.h.

166 {
167 set("stroke", mappingName);
168 }

◆ setStrokeWidth()

template<class AObject>
void setStrokeWidth ( const std::string & mappingName)
inlineinherited

Legacy method to set the mapping on how to match a object to the stroke width.

Parameters
mappingNameThe Name of the Mapping to be used. The translation from name to Mapping class must be defined in createMapping.

Definition at line 175 of file Styling.h.

176 {
177 set("stroke-width", mappingName);
178 }

Member Data Documentation

◆ m_mappingsByKey

template<class AObject>
std::map<std::string, std::unique_ptr<ObjectMapping> > m_mappingsByKey
protectedinherited

Map of attribute keys to mappings to be used.

Definition at line 182 of file Styling.h.


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