Skip to content

Commit c07b41c

Browse files
use enum conversion (#45)
1 parent 740dbd8 commit c07b41c

File tree

2 files changed

+18
-32
lines changed

2 files changed

+18
-32
lines changed

hydra_visualizer/src/color/colormap_utilities.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,22 @@ std::function<Color(size_t)> lookupColormap(DiscretePalette cmap) {
7171
}
7272
}
7373

74+
static const auto enum_init =
75+
config::Enum<NamedColors>::Initializer(std::map<NamedColors, std::string>{
76+
{NamedColors::BLACK, "black"},
77+
{NamedColors::WHITE, "white"},
78+
{NamedColors::RED, "red"},
79+
{NamedColors::GREEN, "green"},
80+
{NamedColors::BLUE, "blue"},
81+
{NamedColors::YELLOW, "yellow"},
82+
{NamedColors::ORANGE, "orange"},
83+
{NamedColors::PURPLE, "purple"},
84+
{NamedColors::CYAN, "cyan"},
85+
{NamedColors::MAGENTA, "magenta"},
86+
{NamedColors::PINK, "pink"},
87+
{NamedColors::GRAY, "gray"},
88+
});
89+
7490
} // namespace
7591

7692
spark_dsg::Color colorFromName(NamedColors color) {

hydra_visualizer/src/layer_info.cpp

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,7 @@ void declare_config(LayerConfig::Edges& config) {
7272
field(config.draw, "draw");
7373
field(config.scale, "scale");
7474
field(config.alpha, "alpha");
75-
enum_field(config.color,
76-
"color",
77-
{
78-
{NamedColors::BLACK, "black"},
79-
{NamedColors::WHITE, "white"},
80-
{NamedColors::RED, "red"},
81-
{NamedColors::GREEN, "green"},
82-
{NamedColors::BLUE, "blue"},
83-
{NamedColors::YELLOW, "yellow"},
84-
{NamedColors::ORANGE, "orange"},
85-
{NamedColors::PURPLE, "purple"},
86-
{NamedColors::CYAN, "cyan"},
87-
{NamedColors::MAGENTA, "magenta"},
88-
{NamedColors::PINK, "pink"},
89-
{NamedColors::GRAY, "gray"},
90-
});
75+
enum_field(config.color, "color");
9176
field(config.use_color, "use_color");
9277
field(config.draw_interlayer, "draw_interlayer");
9378
field(config.interlayer_use_source, "interlayer_use_source");
@@ -108,22 +93,7 @@ void declare_config(LayerConfig::Text& config) {
10893
field(config.scale, "scale");
10994
field(config.add_jitter, "add_jitter");
11095
field(config.jitter_scale, "jitter_scale");
111-
enum_field(config.color,
112-
"color",
113-
{
114-
{NamedColors::BLACK, "black"},
115-
{NamedColors::WHITE, "white"},
116-
{NamedColors::RED, "red"},
117-
{NamedColors::GREEN, "green"},
118-
{NamedColors::BLUE, "blue"},
119-
{NamedColors::YELLOW, "yellow"},
120-
{NamedColors::ORANGE, "orange"},
121-
{NamedColors::PURPLE, "purple"},
122-
{NamedColors::CYAN, "cyan"},
123-
{NamedColors::MAGENTA, "magenta"},
124-
{NamedColors::PINK, "pink"},
125-
{NamedColors::GRAY, "gray"},
126-
});
96+
enum_field(config.color, "color");
12797
}
12898

12999
void declare_config(LayerConfig::BoundingBoxes& config) {

0 commit comments

Comments
 (0)