Fixed calculation of bed origin in bed shape dialog

This commit is contained in:
Enrico Turri 2018-07-30 10:03:17 +02:00
parent bf4871d7f8
commit 11b0325c66

View File

@ -9,6 +9,8 @@
#include "Model.hpp" #include "Model.hpp"
#include "boost/nowide/iostream.hpp" #include "boost/nowide/iostream.hpp"
#include <algorithm>
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@ -146,21 +148,18 @@ void BedShapePanel::set_shape(ConfigOptionPoints* points)
if (lines[0].parallel_to(lines[2]) && lines[1].parallel_to(lines[3])) { if (lines[0].parallel_to(lines[2]) && lines[1].parallel_to(lines[3])) {
// okay, it's a rectangle // okay, it's a rectangle
// find origin // find origin
// the || 0 hack prevents "-0" which might confuse the user coordf_t x_min, x_max, y_min, y_max;
int x_min, x_max, y_min, y_max; x_max = x_min = points->values[0].x;
x_max = x_min = points->values[0].x;
y_max = y_min = points->values[0].y; y_max = y_min = points->values[0].y;
for (auto pt : points->values){ for (auto pt : points->values)
if (x_min > pt.x) x_min = pt.x; {
if (x_max < pt.x) x_max = pt.x; x_min = std::min(x_min, pt.x);
if (y_min > pt.y) y_min = pt.y; x_max = std::max(x_max, pt.x);
if (y_max < pt.y) y_max = pt.y; y_min = std::min(y_min, pt.y);
} y_max = std::max(y_max, pt.y);
if (x_min < 0) x_min = 0; }
if (x_max < 0) x_max = 0;
if (y_min < 0) y_min = 0; auto origin = new ConfigOptionPoints{ Pointf(-x_min, -y_min) };
if (y_max < 0) y_max = 0;
auto origin = new ConfigOptionPoints{ Pointf(-x_min, -y_min) };
m_shape_options_book->SetSelection(SHAPE_RECTANGULAR); m_shape_options_book->SetSelection(SHAPE_RECTANGULAR);
auto optgroup = m_optgroups[SHAPE_RECTANGULAR]; auto optgroup = m_optgroups[SHAPE_RECTANGULAR];