ColorPrint improvement

+ Select "Color Print" preview type if it's not after add/delete new color change
+ Added level heights to the color legend instead of "Color N"
This commit is contained in:
YuSanka 2018-11-27 12:19:39 +01:00
parent 4c8f3f6ea7
commit f203f6fbd9
6 changed files with 35 additions and 9 deletions

View file

@ -382,7 +382,7 @@ std::string GCodePreviewData::get_legend_title() const
return "";
}
GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::vector<float>& tool_colors, const int color_print_cnt /*= 0*/) const
GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::vector<float>& tool_colors, const std::vector<double>& cp_values) const
{
struct Helper
{
@ -452,13 +452,28 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::
}
case Extrusion::ColorPrint:
{
const auto color_print_cnt = cp_values.size();
for (int i = color_print_cnt; i >= 0 ; --i)
{
int val = i;
while (val >= GCodePreviewData::Range::Colors_Count)
val -= GCodePreviewData::Range::Colors_Count;
GCodePreviewData::Color color = Range::Default_Colors[val];
items.emplace_back((boost::format(Slic3r::I18N::translate(L("Color %d"))) % (i + 1)).str(), color);
if (color_print_cnt == 0) {
items.emplace_back(Slic3r::I18N::translate(L("Default print color")), color);
break;
}
if (i == 0) {
items.emplace_back((boost::format(Slic3r::I18N::translate(L("up to %.2f mm"))) % cp_values[0]).str(), color);
break;
}
if (i == color_print_cnt) {
items.emplace_back((boost::format(Slic3r::I18N::translate(L("above %.2f mm"))) % cp_values[i-1]).str(), color);
continue;
}
items.emplace_back((boost::format(Slic3r::I18N::translate(L("%.2f - %.2f mm"))) % cp_values[i-1] % cp_values[i]).str(), color);
}
break;
}