diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index 27adf8fd3..7dcc427bf 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -188,7 +188,7 @@ public: void assign(const LayerHeightProfile &rhs) { if (! this->timestamp_matches(rhs)) { m_data = rhs.m_data; this->copy_timestamp(rhs); } } void assign(LayerHeightProfile &&rhs) { if (! this->timestamp_matches(rhs)) { m_data = std::move(rhs.m_data); this->copy_timestamp(rhs); } } - std::vector get() const throw() { return m_data; } + const std::vector& get() const throw() { return m_data; } bool empty() const throw() { return m_data.empty(); } void set(const std::vector &data) { if (m_data != data) { m_data = data; this->touch(); } } void set(std::vector &&data) { if (m_data != data) { m_data = std::move(data); this->touch(); } } diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index c6d21015b..e377eac93 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -2595,7 +2595,7 @@ bool PrintObject::update_layer_height_profile(const ModelObject &model_object, c if (layer_height_profile.empty()) { // use the constructor because the assignement is crashing on ASAN OsX - layer_height_profile = std::vector(model_object.layer_height_profile.get()); + layer_height_profile = model_object.layer_height_profile.get(); // layer_height_profile = model_object.layer_height_profile; // The layer height returned is sampled with high density for the UI layer height painting // and smoothing tool to work. diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index d3bbe9d15..0dc527648 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -132,6 +132,9 @@ void GLCanvas3D::LayersEditing::set_config(const DynamicPrintConfig* config) delete m_slicing_parameters; m_slicing_parameters = nullptr; m_layers_texture.valid = false; + + m_layer_height_profile.clear(); + m_layer_height_profile_modified = false; } void GLCanvas3D::LayersEditing::select_object(const Model &model, int object_id) @@ -141,6 +144,7 @@ void GLCanvas3D::LayersEditing::select_object(const Model &model, int object_id) // Changing maximum height of an object will invalidate the layer heigth editing profile. // m_model_object->bounding_box() is cached, therefore it is cheap even if this method is called frequently. const float new_max_z = (model_object_new == nullptr) ? 0.0f : static_cast(model_object_new->max_z()); + if (m_model_object != model_object_new || this->last_object_id != object_id || m_object_max_z != new_max_z || (model_object_new != nullptr && m_model_object->id() != model_object_new->id())) { m_layer_height_profile.clear(); @@ -543,10 +547,10 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D& canvas, const G void GLCanvas3D::LayersEditing::adjust_layer_height_profile() { - this->update_slicing_parameters(); - PrintObject::update_layer_height_profile(*m_model_object, *m_slicing_parameters, m_layer_height_profile); - Slic3r::adjust_layer_height_profile(*m_slicing_parameters, m_layer_height_profile, this->last_z, this->strength, this->band_width, this->last_action); - m_layer_height_profile_modified = true; + this->update_slicing_parameters(); + PrintObject::update_layer_height_profile(*m_model_object, *m_slicing_parameters, m_layer_height_profile); + Slic3r::adjust_layer_height_profile(*m_slicing_parameters, m_layer_height_profile, this->last_z, this->strength, this->band_width, this->last_action); + m_layer_height_profile_modified = true; m_layers_texture.valid = false; } @@ -581,14 +585,15 @@ void GLCanvas3D::LayersEditing::smooth_layer_height_profile(GLCanvas3D& canvas, void GLCanvas3D::LayersEditing::generate_layer_height_texture() { - this->update_slicing_parameters(); - // Always try to update the layer height profile. + this->update_slicing_parameters(); + // Always try to update the layer height profile. bool update = ! m_layers_texture.valid; if (PrintObject::update_layer_height_profile(*m_model_object, *m_slicing_parameters, m_layer_height_profile)) { // Initialized to the default value. m_layer_height_profile_modified = false; update = true; } + // Update if the layer height profile was changed, or when the texture is not valid. if (! update && ! m_layers_texture.data.empty() && m_layers_texture.cells > 0) // Texture is valid, don't update. @@ -615,8 +620,8 @@ void GLCanvas3D::LayersEditing::accept_changes(GLCanvas3D& canvas) if (m_layer_height_profile_modified) { wxGetApp().plater()->take_snapshot(_L("Variable layer height - Manual edit")); const_cast(m_model_object)->layer_height_profile.set(m_layer_height_profile); - canvas.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS)); wxGetApp().obj_list()->update_info_items(last_object_id); + wxGetApp().plater()->schedule_background_process(); } } m_layer_height_profile_modified = false; diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index bd2208fd5..f61f3332d 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -926,8 +926,8 @@ void ObjectList::OnContextMenu(wxDataViewEvent& evt) // Do not show the context menu if the user pressed the right mouse button on the 3D scene and released it on the objects list GLCanvas3D* canvas = wxGetApp().plater()->canvas3D(); bool evt_context_menu = (canvas != nullptr) ? !canvas->is_mouse_dragging() : true; - if (!evt_context_menu) - canvas->mouse_up_cleanup(); +// if (!evt_context_menu) +// canvas->mouse_up_cleanup(); list_manipulation(mouse_pos, evt_context_menu); }