Belle II Software development
ChooseableHitStyling Class Reference

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

#include <Styling.h>

Inheritance diagram for ChooseableHitStyling:
ChooseableStyling< const CDCHit > Styling< AObject >

Public Types

using ObjectMapping = Mapping< const CDCHit >
 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 CDCHit &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 CDCHit >
 Type of the base class.
 

Detailed Description

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

Definition at line 234 of file Styling.h.

Member Typedef Documentation

◆ ObjectMapping

using ObjectMapping = Mapping<const CDCHit >
inherited

Mapping for the object type.

Definition at line 103 of file Styling.h.

◆ Super

using Super = ChooseableStyling<const CDCHit>
private

Type of the base class.

Definition at line 238 of file Styling.h.

Member Function Documentation

◆ createMapping()

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

Method defining the available mapping names.

Reimplemented from ChooseableStyling< const CDCHit >.

Definition at line 53 of file Styling.cc.

54{
55 if (mappingName == "ZeroDriftLengthColorMap") {
56 return std::make_unique<ZeroDriftLengthColorMap>();
57 } else if (mappingName == "ZeroDriftLengthStrokeWidthMap") {
58 return std::make_unique<ZeroDriftLengthStrokeWidthMap>();
59 } else if (mappingName == "TakenFlagColorMap") {
60 return std::make_unique<TakenFlagColorMap>();
61 } else if (mappingName == "RLColorMap") {
62 return std::make_unique<RLColorMap>();
63 } else if (mappingName == "PosFlagColorMap") {
64 return std::make_unique<PosFlagColorMap>();
65 } else if (mappingName == "BackgroundTagColorMap") {
66 return std::make_unique<BackgroundTagColorMap>();
67 } else if (mappingName == "MCSegmentIdColorMap") {
68 return std::make_unique<MCSegmentIdColorMap>();
69 } else if (mappingName == "TOFColorMap") {
70 return std::make_unique<TOFColorMap>();
71 } else if (mappingName == "ReassignedSecondaryMap") {
72 return std::make_unique<ReassignedSecondaryMap>();
73 } else if (mappingName == "MCParticleColorMap") {
74 return std::make_unique<MCParticleColorMap>();
75 } else if (mappingName == "MCPDGCodeColorMap") {
76 return std::make_unique<MCPDGCodeColorMap>();
77 } else if (mappingName == "MCPrimaryColorMap") {
78 return std::make_unique<MCPrimaryColorMap>();
79 } else if (mappingName == "SimHitPDGCodeColorMap") {
80 return std::make_unique<SimHitPDGCodeColorMap>();
81 } else if (mappingName == "SimHitIsBkgColorMap") {
82 return std::make_unique<SimHitIsBkgColorMap>();
83 } else if (mappingName == "NLoops") {
84 return std::make_unique<NLoopsColorMap>();
85 } else {
86 return Super::createMapping(mappingName);
87 }
88}
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 CDCHit 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: