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 185 of file Styling.h.

Member Typedef Documentation

◆ ObjectMapping

using ObjectMapping = Mapping<AObject>
inherited

Mapping for the object type.

Definition at line 103 of file Styling.h.

Constructor & Destructor Documentation

◆ DefaultColorCycleStyling()

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

Definition at line 188 of file Styling.h.

188 : ChooseableStyling<AObject>()
189 {
190 this->set("stroke", std::make_unique<DefaultColorCycleMapping<AObject>>());
191 }
void set(const std::string &key, std::unique_ptr< ObjectMapping > mapping)
Sets the given attribute to the attribute mapping.
Definition: Styling.h:142

Member Function Documentation

◆ createMapping()

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 ChooseableRecoTrackStyling, ChooseableSegmentStyling, and ChooseableHitStyling.

Definition at line 136 of file Styling.h.

137 {
138 return std::make_unique<ConstantMapping<AObject>>(mappingName);
139 }

◆ info()

std::string info ( )
inlineoverridevirtualinherited

Returns informal string about the currently set mappings.

Reimplemented from Styling< AObject >.

Definition at line 119 of file Styling.h.

120 {
121 std::ostringstream oss;
122 for (const auto& keyMapping : m_mappingsByKey) {
123 const std::string& key = keyMapping.first;
124 const std::unique_ptr<ObjectMapping>& mapping = keyMapping.second;
125 oss << key << ": " << mapping->info();
126 }
127 return oss.str();
128 }
std::map< std::string, std::unique_ptr< ObjectMapping > > m_mappingsByKey
Map of attribute keys to mappings to be used.
Definition: Styling.h:180

◆ map()

AttributeMap map ( int  index,
AObject &  object 
)
inlineoverridevirtualinherited

Create a map of attributes from the stored attribute maps.

Reimplemented from Styling< AObject >.

Definition at line 107 of file Styling.h.

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

◆ set() [1/2]

void set ( const std::string &  key,
const std::string &  mappingName 
)
inlineinherited

Sets the given attribute to the fixed value.

Definition at line 150 of file Styling.h.

151 {
152 std::unique_ptr<ObjectMapping> objectMapping = this->createMapping(mappingName);
153 if (objectMapping) {
154 set(key, std::move(objectMapping));
155 }
156 }
virtual std::unique_ptr< ObjectMapping > createMapping(const std::string &mappingName)
Create a mapping for the object from a name.
Definition: Styling.h:136

◆ set() [2/2]

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

Sets the given attribute to the attribute mapping.

Definition at line 142 of file Styling.h.

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

◆ setStroke()

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 163 of file Styling.h.

164 {
165 set("stroke", mappingName);
166 }

◆ setStrokeWidth()

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 173 of file Styling.h.

174 {
175 set("stroke-width", mappingName);
176 }

Member Data Documentation

◆ m_mappingsByKey

std::map<std::string, std::unique_ptr<ObjectMapping> > m_mappingsByKey
protectedinherited

Map of attribute keys to mappings to be used.

Definition at line 180 of file Styling.h.


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