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 TrackingUtilities::CDCSegment2D > Styling< AObject >

Public Types

using ObjectMapping
 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 TrackingUtilities::CDCSegment2D &object) override
 Create a map of attributes from the stored attribute maps.
 
AttributeMap map (int index, const TrackingUtilities::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.
 
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 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 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.
 
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.
 
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 TrackingUtilities::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 218 of file Styling.h.

Member Typedef Documentation

◆ ObjectMapping

using ObjectMapping
inherited

Mapping for the object type.

Definition at line 105 of file Styling.h.

◆ Super

Type of the base class.

Definition at line 222 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 TrackingUtilities::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)
Definition Styling.h:138

◆ info() [1/2]

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 }

◆ info() [2/2]

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() [1/3]

AttributeMap map ( int index,
const TrackingUtilities::CDCSegment2D & object )
inlineoverrideinherited

Create a map of attributes from the stored attribute maps.

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 }

◆ map() [2/3]

AttributeMap map ( int index,
const TrackingUtilities::CDCSegment2D & object )
inlineoverrideinherited

Create a map of attributes from the stored attribute maps.

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 }

◆ map() [3/3]

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

Maps the object at the given index to attribute values.

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

Definition at line 41 of file Styling.h.

43 {
44 return {};
45 }

◆ set() [1/4]

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/4]

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() [3/4]

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 }

◆ set() [4/4]

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() [1/2]

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 }

◆ setStroke() [2/2]

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() [1/2]

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 }

◆ setStrokeWidth() [2/2]

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 [1/2]

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.

◆ m_mappingsByKey [2/2]

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