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) 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(); EType new_type = _detect_type();
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
if (m_shape == shape && m_type == new_type) if (m_shape == shape && m_type == new_type)
// No change, no need to update the UI. // No change, no need to update the UI.
return false; return false;
@ -516,7 +520,11 @@ void GLCanvas3D::Bed::_calc_gridlines(const ExPolygon& poly, const BoundingBox&
printf("Unable to create bed grid lines\n"); 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 GLCanvas3D::Bed::EType GLCanvas3D::Bed::_detect_type() const
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
{ {
EType type = Custom; EType type = Custom;
@ -528,7 +536,27 @@ GLCanvas3D::Bed::EType GLCanvas3D::Bed::_detect_type() const
{ {
if (curr->config.has("bed_shape")) 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? //FIXME add a condition on the size of the print bed?
type = SL1; 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); 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) bool GLCanvas3D::Bed::_are_equal(const Pointfs& bed_1, const Pointfs& bed_2)
{ {
if (bed_1.size() != bed_2.size()) 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; return true;
} }
#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE
const double GLCanvas3D::Axes::Radius = 0.5; const double GLCanvas3D::Axes::Radius = 0.5;
const double GLCanvas3D::Axes::ArrowBaseRadius = 2.5 * GLCanvas3D::Axes::Radius; 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); 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. // Set the origin and size for painting of the coordinate system axes.
m_axes.origin = Vec3d(0.0, 0.0, (double)GROUND_Z); m_axes.origin = Vec3d(0.0, 0.0, (double)GROUND_Z);
set_bed_axes_length(0.1 * m_bed.get_bounding_box().max_size()); set_bed_axes_length(0.1 * m_bed.get_bounding_box().max_size());
if (new_shape) if (new_shape)
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
m_requires_zoom_to_bed = true;
#else
zoom_to_bed(); zoom_to_bed();
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
m_dirty = true; m_dirty = true;
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
} }
void GLCanvas3D::set_bed_axes_length(double length) 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) if (m_reload_delayed)
return; return;
#if !ENABLE_REWORKED_BED_SHAPE_CHANGE
set_bed_shape(dynamic_cast<const ConfigOptionPoints*>(m_config->option("bed_shape"))->values); set_bed_shape(dynamic_cast<const ConfigOptionPoints*>(m_config->option("bed_shape"))->values);
#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE
if (m_regenerate_volumes) if (m_regenerate_volumes)
{ {

View file

@ -226,6 +226,10 @@ class GLCanvas3D
public: public:
Bed(); Bed();
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
EType get_type() const { return m_type; }
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
bool is_prusa() const; bool is_prusa() const;
bool is_custom() const; bool is_custom() const;
@ -247,14 +251,20 @@ class GLCanvas3D
void _calc_bounding_box(); void _calc_bounding_box();
void _calc_triangles(const ExPolygon& poly); void _calc_triangles(const ExPolygon& poly);
void _calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox); void _calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox);
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
EType _detect_type(const Pointfs& shape) const;
#else
EType _detect_type() const; EType _detect_type() const;
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
#if ENABLE_PRINT_BED_MODELS #if ENABLE_PRINT_BED_MODELS
void _render_prusa(const std::string &key, float theta, bool useVBOs) const; void _render_prusa(const std::string &key, float theta, bool useVBOs) const;
#else #else
void _render_prusa(const std::string &key, float theta) const; void _render_prusa(const std::string &key, float theta) const;
#endif // ENABLE_PRINT_BED_MODELS #endif // ENABLE_PRINT_BED_MODELS
void _render_custom() const; void _render_custom() const;
#if !ENABLE_REWORKED_BED_SHAPE_CHANGE
static bool _are_equal(const Pointfs& bed_1, const Pointfs& bed_2); static bool _are_equal(const Pointfs& bed_1, const Pointfs& bed_2);
#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE
}; };
struct Axes struct Axes

View file

@ -419,6 +419,10 @@ void Preview::reload_print(bool force)
m_canvas->reset_legend_texture(); m_canvas->reset_legend_texture();
m_loaded = false; m_loaded = false;
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
m_canvas->set_bed_shape(dynamic_cast<const ConfigOptionPoints*>(m_config->option("bed_shape"))->values);
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
if (!IsShown() && !force) if (!IsShown() && !force)
return; return;

View file

@ -3017,13 +3017,20 @@ void Plater::on_extruders_change(int num_extruders)
void Plater::on_config_change(const DynamicPrintConfig &config) void Plater::on_config_change(const DynamicPrintConfig &config)
{ {
bool update_scheduled = false; bool update_scheduled = false;
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
bool bed_shape_changed = false;
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
for (auto opt_key : p->config->diff(config)) { for (auto opt_key : p->config->diff(config)) {
p->config->set_key_value(opt_key, config.option(opt_key)->clone()); p->config->set_key_value(opt_key, config.option(opt_key)->clone());
if (opt_key == "printer_technology") if (opt_key == "printer_technology")
this->set_printer_technology(config.opt_enum<PrinterTechnology>(opt_key)); this->set_printer_technology(config.opt_enum<PrinterTechnology>(opt_key));
else if (opt_key == "bed_shape") { else if (opt_key == "bed_shape") {
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
bed_shape_changed = true;
#else
if (p->view3D) p->view3D->set_bed_shape(p->config->option<ConfigOptionPoints>(opt_key)->values); if (p->view3D) p->view3D->set_bed_shape(p->config->option<ConfigOptionPoints>(opt_key)->values);
if (p->preview) p->preview->set_bed_shape(p->config->option<ConfigOptionPoints>(opt_key)->values); if (p->preview) p->preview->set_bed_shape(p->config->option<ConfigOptionPoints>(opt_key)->values);
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
update_scheduled = true; update_scheduled = true;
} }
else if (boost::starts_with(opt_key, "wipe_tower") || else if (boost::starts_with(opt_key, "wipe_tower") ||
@ -3049,8 +3056,12 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
} }
else if (opt_key == "printer_model") { else if (opt_key == "printer_model") {
// update to force bed selection(for texturing) // update to force bed selection(for texturing)
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
bed_shape_changed = true;
#else
if (p->view3D) p->view3D->set_bed_shape(p->config->option<ConfigOptionPoints>("bed_shape")->values); if (p->view3D) p->view3D->set_bed_shape(p->config->option<ConfigOptionPoints>("bed_shape")->values);
if (p->preview) p->preview->set_bed_shape(p->config->option<ConfigOptionPoints>("bed_shape")->values); if (p->preview) p->preview->set_bed_shape(p->config->option<ConfigOptionPoints>("bed_shape")->values);
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
update_scheduled = true; update_scheduled = true;
} }
else if (opt_key == "host_type" && this->p->printer_technology == ptSLA) { else if (opt_key == "host_type" && this->p->printer_technology == ptSLA) {
@ -3063,6 +3074,14 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
p->sidebar->show_send(prin_host_opt != nullptr && !prin_host_opt->value.empty()); p->sidebar->show_send(prin_host_opt != nullptr && !prin_host_opt->value.empty());
} }
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
if (bed_shape_changed)
{
if (p->view3D) p->view3D->set_bed_shape(p->config->option<ConfigOptionPoints>("bed_shape")->values);
if (p->preview) p->preview->set_bed_shape(p->config->option<ConfigOptionPoints>("bed_shape")->values);
}
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
if (update_scheduled) if (update_scheduled)
update(); update();

View file

@ -497,13 +497,15 @@ void TabSLAMaterial::init_options_list()
void Tab::get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page) void Tab::get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page)
{ {
auto opt = m_options_list.find(opt_key); auto opt = m_options_list.find(opt_key);
if (sys_page) sys_page = (opt->second & osSystemValue) != 0; if (sys_page) sys_page = (opt->second & osSystemValue) != 0;
modified_page |= (opt->second & osInitValue) == 0; modified_page |= (opt->second & osInitValue) == 0;
} }
void Tab::update_changed_tree_ui() void Tab::update_changed_tree_ui()
{ {
if (m_options_list.empty())
return;
auto cur_item = m_treectrl->GetFirstVisibleItem(); auto cur_item = m_treectrl->GetFirstVisibleItem();
if (!cur_item || !m_treectrl->IsVisible(cur_item)) if (!cur_item || !m_treectrl->IsVisible(cur_item))
return; return;
@ -689,9 +691,9 @@ void Tab::update_visibility()
Thaw(); Thaw();
// to update tree items color // to update tree items color
wxTheApp->CallAfter([this]() { // wxTheApp->CallAfter([this]() {
update_changed_tree_ui(); update_changed_tree_ui();
}); // });
} }
Field* Tab::get_field(const t_config_option_key& opt_key, int opt_index/* = -1*/) const Field* Tab::get_field(const t_config_option_key& opt_key, int opt_index/* = -1*/) const