This commit is contained in:
bubnikv 2019-02-04 15:46:20 +01:00
commit b8d6c6bbb2
5 changed files with 85 additions and 9 deletions

View file

@ -366,7 +366,11 @@ const Pointfs& GLCanvas3D::Bed::get_shape() const
bool GLCanvas3D::Bed::set_shape(const Pointfs& shape)
{
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
EType new_type = _detect_type(shape);
#else
EType new_type = _detect_type();
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
if (m_shape == shape && m_type == new_type)
// No change, no need to update the UI.
return false;
@ -516,7 +520,11 @@ void GLCanvas3D::Bed::_calc_gridlines(const ExPolygon& poly, const BoundingBox&
printf("Unable to create bed grid lines\n");
}
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
GLCanvas3D::Bed::EType GLCanvas3D::Bed::_detect_type(const Pointfs& shape) const
#else
GLCanvas3D::Bed::EType GLCanvas3D::Bed::_detect_type() const
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
{
EType type = Custom;
@ -528,7 +536,27 @@ GLCanvas3D::Bed::EType GLCanvas3D::Bed::_detect_type() const
{
if (curr->config.has("bed_shape"))
{
if (boost::contains(curr->name, "SL1"))
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
if ((curr->vendor != nullptr) && (curr->vendor->name == "Prusa Research") && (shape == dynamic_cast<const ConfigOptionPoints*>(curr->config.option("bed_shape"))->values))
{
if (boost::contains(curr->name, "SL1"))
{
type = SL1;
break;
}
else if (boost::contains(curr->name, "MK3") || boost::contains(curr->name, "MK2.5"))
{
type = MK3;
break;
}
else if (boost::contains(curr->name, "MK2"))
{
type = MK2;
break;
}
}
#else
if (boost::contains(curr->name, "SL1"))
{
//FIXME add a condition on the size of the print bed?
type = SL1;
@ -549,7 +577,8 @@ GLCanvas3D::Bed::EType GLCanvas3D::Bed::_detect_type() const
}
}
}
}
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
}
curr = bundle->printers.get_preset_parent(*curr);
}
@ -707,6 +736,7 @@ void GLCanvas3D::Bed::_render_custom() const
}
}
#if !ENABLE_REWORKED_BED_SHAPE_CHANGE
bool GLCanvas3D::Bed::_are_equal(const Pointfs& bed_1, const Pointfs& bed_2)
{
if (bed_1.size() != bed_2.size())
@ -720,6 +750,7 @@ bool GLCanvas3D::Bed::_are_equal(const Pointfs& bed_1, const Pointfs& bed_2)
return true;
}
#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE
const double GLCanvas3D::Axes::Radius = 0.5;
const double GLCanvas3D::Axes::ArrowBaseRadius = 2.5 * GLCanvas3D::Axes::Radius;
@ -4217,18 +4248,26 @@ void GLCanvas3D::set_bed_shape(const Pointfs& shape)
{
bool new_shape = m_bed.set_shape(shape);
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
if (new_shape)
{
// Set the origin and size for painting of the coordinate system axes.
m_axes.origin = Vec3d(0.0, 0.0, (double)GROUND_Z);
set_bed_axes_length(0.1 * m_bed.get_bounding_box().max_size());
m_requires_zoom_to_bed = true;
m_dirty = true;
}
#else
// Set the origin and size for painting of the coordinate system axes.
m_axes.origin = Vec3d(0.0, 0.0, (double)GROUND_Z);
set_bed_axes_length(0.1 * m_bed.get_bounding_box().max_size());
if (new_shape)
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
m_requires_zoom_to_bed = true;
#else
zoom_to_bed();
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
m_dirty = true;
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
}
void GLCanvas3D::set_bed_axes_length(double length)
@ -4779,7 +4818,9 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
if (m_reload_delayed)
return;
#if !ENABLE_REWORKED_BED_SHAPE_CHANGE
set_bed_shape(dynamic_cast<const ConfigOptionPoints*>(m_config->option("bed_shape"))->values);
#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE
if (m_regenerate_volumes)
{