Belle II Software development
ChooseableSegmentStyling Class Reference

This Class handles the mapping from the colormapping-method name given as a string to the actual AColorMap for CDCSegments. More...

#include <Styling.h>

Inheritance diagram for ChooseableSegmentStyling:
ChooseableStyling< const CDCSegment2D > Styling< AObject >

Public Types

using ObjectMapping = Mapping< const CDCSegment2D >
 Mapping for the object type.
 

Public Member Functions

std::unique_ptr< ObjectMappingcreateMapping (const std::string &mappingName) override
 Method defining the available mapping names.
 
AttributeMap map (int index, const CDCSegment2D &object) override
 Create a map of attributes from the stored attribute maps.
 
virtual AttributeMap map (int index, AObject &object)
 Maps the object at the given index to attribute values.
 
std::string info () override
 Returns informal string about the currently set mappings.
 
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.
 

Private Types

using Super = ChooseableStyling< const CDCSegment2D >
 Type of the base class.
 

Detailed Description

This Class handles the mapping from the colormapping-method name given as a string to the actual AColorMap for CDCSegments.

Definition at line 216 of file Styling.h.

Member Typedef Documentation

◆ ObjectMapping

using ObjectMapping = Mapping<const CDCSegment2D >
inherited

Mapping for the object type.

Definition at line 103 of file Styling.h.

◆ Super

using Super = ChooseableStyling<const CDCSegment2D>
private

Type of the base class.

Definition at line 220 of file Styling.h.

Member Function Documentation

◆ createMapping()

std::unique_ptr< ChooseableSegmentStyling::ObjectMapping > createMapping ( const std::string &  mappingName)
overridevirtual

Method defining the available mapping names.

Reimplemented from ChooseableStyling< const CDCSegment2D >.

Definition at line 31 of file Styling.cc.

32{
33 if (mappingName == "SegmentMCTrackIdColorMap") {
34 return std::make_unique<SegmentMCTrackIdColorMap>();
35 } else if (mappingName == "SegmentFBInfoColorMap") {
36 return std::make_unique<SegmentFBInfoColorMap>();
37 } else if (mappingName == "SegmentFirstInTrackIdColorMap") {
38 return std::make_unique<SegmentFirstInTrackIdColorMap>();
39 } else if (mappingName == "SegmentLastInTrackIdColorMap") {
40 return std::make_unique<SegmentLastInTrackIdColorMap>();
41 } else if (mappingName == "SegmentFirstNPassedSuperLayersColorMap") {
42 return std::make_unique<SegmentFirstNPassedSuperLayersColorMap>();
43 } else if (mappingName == "SegmentLastNPassedSuperLayersColorMap") {
44 return std::make_unique<SegmentLastNPassedSuperLayersColorMap>();
45 } else if (mappingName == "ListColors") {
46 return std::make_unique<SegmentListColorsColorMap>();
47 } else {
48 return Super::createMapping(mappingName);
49 }
50}
virtual std::unique_ptr< ObjectMapping > createMapping(const std::string &mappingName)
Create a mapping for the object from a name.
Definition: Styling.h:136

◆ 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 }

◆ map() [1/2]

virtual AttributeMap map ( int  index,
AObject &  object 
)
inlinevirtualinherited

Maps the object at the given index to attribute values.

Reimplemented in FixedStyling< AObject >, and ChooseableStyling< AObject >.

Definition at line 39 of file Styling.h.

41 {
42 return {};
43 }

◆ map() [2/2]

AttributeMap map ( int  index,
const CDCSegment2D object 
)
inlineoverrideinherited

Create a map of attributes from the stored attribute maps.

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 }

◆ 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 }
std::map< std::string, std::unique_ptr< ObjectMapping > > m_mappingsByKey
Map of attribute keys to mappings to be used.
Definition: Styling.h:180

◆ 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 files: