This commit is contained in:
bubnikv 2019-08-29 13:36:22 +02:00
commit d60480ca7c

View file

@ -845,21 +845,21 @@ void GLCanvas3D::LegendTexture::fill_color_print_legend_values(const GCodePrevie
{ {
auto& config = wxGetApp().preset_bundle->project_config; auto& config = wxGetApp().preset_bundle->project_config;
const std::vector<double>& color_print_values = config.option<ConfigOptionFloats>("colorprint_heights")->values; const std::vector<double>& color_print_values = config.option<ConfigOptionFloats>("colorprint_heights")->values;
const int values_cnt = color_print_values.size(); const size_t values_cnt = color_print_values.size();
if (values_cnt > 0) { if (values_cnt > 0) {
auto print_zs = canvas.get_current_print_zs(true); std::vector<double> print_zs = canvas.get_current_print_zs(true);
auto z = 0; size_t z = 0;
for (auto i = 0; i < values_cnt; ++i) for (size_t i = 0; i < values_cnt; ++i)
{ {
double prev_z = -1.0; double prev_z = -1.0;
for (z; z < print_zs.size(); ++z) for ( ; z < print_zs.size(); ++z)
if (fabs(color_print_values[i] - print_zs[z]) < EPSILON) { if (fabs(color_print_values[i] - print_zs[z]) < EPSILON) {
prev_z = print_zs[z - 1]; prev_z = z > 0 ? print_zs[z - 1] : 0.;
break; break;
} }
if (prev_z < 0) if (prev_z < 0)
continue; continue;
cp_legend_values.push_back(std::pair<double, double>(prev_z, color_print_values[i])); cp_legend_values.push_back(std::pair<double, double>(prev_z, color_print_values[i]));
} }
} }