Skip to content

Commit

Permalink
The print bed is limited to 1.2m x 1.2m. (related to #2877)
Browse files Browse the repository at this point in the history
  • Loading branch information
YuSanka committed Apr 1, 2020
1 parent f27999e commit 815989d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/slic3r/GUI/BedShapeDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,17 @@ void BedShapePanel::build_panel(const ConfigOptionPoints& default_pt, const Conf
ConfigOptionDef def;
def.type = coPoints;
def.set_default_value(new ConfigOptionPoints{ Vec2d(200, 200) });
def.min = 0;
def.max = 1200;
def.label = L("Size");
def.tooltip = L("Size in X and Y of the rectangular plate.");
Option option(def, "rect_size");
optgroup->append_single_option_line(option);

def.type = coPoints;
def.set_default_value(new ConfigOptionPoints{ Vec2d(0, 0) });
def.min = -600;
def.max = 600;
def.label = L("Origin");
def.tooltip = L("Distance of the 0,0 G-code coordinate from the front left corner of the rectangle.");
option = Option(def, "rect_origin");
Expand Down
31 changes: 28 additions & 3 deletions src/slic3r/GUI/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1242,12 +1242,24 @@ void PointCtrl::msw_rescale(bool rescale_sidetext/* = false*/)
y_textctrl->SetMinSize(field_size);
}

bool PointCtrl::value_was_changed(wxTextCtrl* win)
{
if (m_value.empty())
return true;

boost::any val = m_value;
// update m_value!
get_value();

return boost::any_cast<Vec2d>(m_value) != boost::any_cast<Vec2d>(val);
}

void PointCtrl::propagate_value(wxTextCtrl* win)
{
if (!win->GetValue().empty())
on_change_field();
else
if (win->GetValue().empty())
on_kill_focus();
else if (value_was_changed(win))
on_change_field();
}

void PointCtrl::set_value(const Vec2d& value, bool change_event)
Expand Down Expand Up @@ -1281,6 +1293,19 @@ boost::any& PointCtrl::get_value()
double x, y;
x_textctrl->GetValue().ToDouble(&x);
y_textctrl->GetValue().ToDouble(&y);

if (m_opt.min > x || x > m_opt.max ||
m_opt.min > y || y > m_opt.max)
{
if (m_opt.min > x) x = m_opt.min;
if (x > m_opt.max) x = m_opt.max;
if (m_opt.min > y) y = m_opt.min;
if (y > m_opt.max) y = m_opt.max;
set_value(Vec2d(x, y), true);

show_error(m_parent, _(L("Input value is out of range")));
}

return m_value = Vec2d(x, y);
}

Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/Field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ class PointCtrl : public Field {
wxTextCtrl* y_textctrl{ nullptr };

void BUILD() override;
bool value_was_changed(wxTextCtrl* win);
// Propagate value from field to the OptionGroupe and Config after kill_focus/ENTER
void propagate_value(wxTextCtrl* win);
void set_value(const Vec2d& value, bool change_event = false);
Expand Down

0 comments on commit 815989d

Please sign in to comment.