diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 8442194f21..f43633f478 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -790,10 +790,8 @@ void GLCanvas3D::Tooltip::render(const Vec2d& mouse_position, GLCanvas3D& canvas } #if ENABLE_SEQUENTIAL_LIMITS -void GLCanvas3D::SequentialPrintClearance::set(const Polygons& polygons, bool fill) +void GLCanvas3D::SequentialPrintClearance::set_polygons(const Polygons& polygons) { - m_render_fill = fill; - m_perimeter.reset(); m_fill.reset(); if (polygons.empty()) @@ -805,7 +803,7 @@ void GLCanvas3D::SequentialPrintClearance::set(const Polygons& polygons, bool fi } size_t vertices_count = 3 * triangles_count; - if (fill) { + if (m_render_fill) { GLModel::InitializationData fill_data; GLModel::InitializationData::Entity entity; entity.type = GLModel::PrimitiveType::Triangles; @@ -896,6 +894,9 @@ wxDEFINE_EVENT(EVT_GLCANVAS_WIPETOWER_MOVED, Vec3dEvent); wxDEFINE_EVENT(EVT_GLCANVAS_WIPETOWER_ROTATED, Vec3dEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event); wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>); +#if ENABLE_SEQUENTIAL_LIMITS +wxDEFINE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_STARTED, SimpleEvent); +#endif // ENABLE_SEQUENTIAL_LIMITS wxDEFINE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_BED_SHAPE, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_TAB, SimpleEvent); @@ -1468,9 +1469,7 @@ void GLCanvas3D::render() _render_selection(); _render_bed(!camera.is_looking_downward(), true); #if ENABLE_SEQUENTIAL_LIMITS - if (m_gizmos.get_current_type() == GLGizmosManager::EType::Undefined && - !m_layers_editing.is_enabled()) - _render_sequential_clearance(); + _render_sequential_clearance(); #endif // ENABLE_SEQUENTIAL_LIMITS #if ENABLE_RENDER_SELECTION_CENTER _render_selection_center(); @@ -3429,7 +3428,7 @@ void GLCanvas3D::do_move(const std::string& snapshot_type) post_event(Vec3dEvent(EVT_GLCANVAS_WIPETOWER_MOVED, std::move(wipe_tower_origin))); #if ENABLE_SEQUENTIAL_LIMITS - set_sequential_print_clearance(Polygons(), false); + reset_sequential_print_clearance(); #endif // ENABLE_SEQUENTIAL_LIMITS m_dirty = true; @@ -3784,6 +3783,9 @@ void GLCanvas3D::update_sequential_clearance() if (current_printer_technology() != ptFFF || !fff_print()->config().complete_objects) return; + if (m_layers_editing.is_enabled() || m_gizmos.is_dragging()) + return; + // collects instance transformations from volumes // first define temporary cache unsigned int instances_count = 0; @@ -3861,7 +3863,9 @@ void GLCanvas3D::update_sequential_clearance() } // sends instances 2d hulls to be rendered - set_sequential_print_clearance(polygons, false); + set_sequential_print_clearance_visible(true); + set_sequential_print_clearance_render_fill(false); + set_sequential_print_clearance_polygons(polygons); } #endif // ENABLE_SEQUENTIAL_LIMITS @@ -5115,6 +5119,20 @@ void GLCanvas3D::_render_selection() const #if ENABLE_SEQUENTIAL_LIMITS void GLCanvas3D::_render_sequential_clearance() const { + if (m_layers_editing.is_enabled() || m_gizmos.is_dragging()) + return; + + switch (m_gizmos.get_current_type()) + { + case GLGizmosManager::EType::Flatten: + case GLGizmosManager::EType::Cut: + case GLGizmosManager::EType::Hollow: + case GLGizmosManager::EType::SlaSupports: + case GLGizmosManager::EType::FdmSupports: + case GLGizmosManager::EType::Seam: { return; } + default: { break; } + } + m_sequential_print_clearance.render(); } #endif // ENABLE_SEQUENTIAL_LIMITS diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index c0ef83b727..ace660435b 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -120,6 +120,9 @@ wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_SCALED, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_WIPETOWER_ROTATED, Vec3dEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event); wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>); +#if ENABLE_SEQUENTIAL_LIMITS +wxDECLARE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_STARTED, SimpleEvent); +#endif // ENABLE_SEQUENTIAL_LIMITS wxDECLARE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_BED_SHAPE, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_TAB, SimpleEvent); @@ -502,11 +505,14 @@ private: GLModel m_fill; GLModel m_perimeter; bool m_render_fill{ true }; + bool m_visible{ false }; std::vector m_hull_2d_cache; public: - void set(const Polygons& polygons, bool fill); + void set_polygons(const Polygons& polygons); + void set_render_fill(bool render_fill) { m_render_fill = render_fill; } + void set_visible(bool visible) { m_visible = visible; } void render() const; friend class GLCanvas3D; @@ -758,7 +764,24 @@ public: } #if ENABLE_SEQUENTIAL_LIMITS - void set_sequential_print_clearance(const Polygons& polygons, bool fill) { m_sequential_print_clearance.set(polygons, fill); } + void reset_sequential_print_clearance() { + m_sequential_print_clearance.set_visible(false); + m_sequential_print_clearance.set_render_fill(false); + m_sequential_print_clearance.set_polygons(Polygons()); + } + + void set_sequential_print_clearance_visible(bool visible) { + m_sequential_print_clearance.set_visible(visible); + } + + void set_sequential_print_clearance_render_fill(bool render_fill) { + m_sequential_print_clearance.set_render_fill(render_fill); + } + + void set_sequential_print_clearance_polygons(const Polygons& polygons) { + m_sequential_print_clearance.set_polygons(polygons); + } + void update_sequential_clearance(); #endif // ENABLE_SEQUENTIAL_LIMITS diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index d1d2b277ec..e72dd63daf 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -635,6 +635,11 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt) selection.start_dragging(); start_dragging(); +#if ENABLE_SEQUENTIAL_LIMITS + // Let the plater know that the dragging started + m_parent.post_event(SimpleEvent(EVT_GLCANVAS_MOUSE_DRAGGING_STARTED)); +#endif // ENABLE_SEQUENTIAL_LIMITS + if (m_current == Flatten) { // Rotate the object so the normal points downward: m_parent.do_flatten(get_flattening_normal(), L("Gizmo-Place on Face")); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index d4718e32f5..e83f679858 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1702,6 +1702,9 @@ struct Plater::priv void on_wipetower_moved(Vec3dEvent&); void on_wipetower_rotated(Vec3dEvent&); void on_update_geometry(Vec3dsEvent<2>&); +#if ENABLE_SEQUENTIAL_LIMITS + void on_3dcanvas_mouse_dragging_started(SimpleEvent&); +#endif // ENABLE_SEQUENTIAL_LIMITS void on_3dcanvas_mouse_dragging_finished(SimpleEvent&); void show_action_buttons(const bool is_ready_to_slice) const; @@ -1878,6 +1881,9 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) view3D_canvas->Bind(EVT_GLCANVAS_INSTANCE_SCALED, [this](SimpleEvent&) { update(); }); view3D_canvas->Bind(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, [this](Event& evt) { this->sidebar->enable_buttons(evt.data); }); view3D_canvas->Bind(EVT_GLCANVAS_UPDATE_GEOMETRY, &priv::on_update_geometry, this); +#if ENABLE_SEQUENTIAL_LIMITS + view3D_canvas->Bind(EVT_GLCANVAS_MOUSE_DRAGGING_STARTED, &priv::on_3dcanvas_mouse_dragging_started, this); +#endif // ENABLE_SEQUENTIAL_LIMITS view3D_canvas->Bind(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, &priv::on_3dcanvas_mouse_dragging_finished, this); view3D_canvas->Bind(EVT_GLCANVAS_TAB, [this](SimpleEvent&) { select_next_view_3D(); }); view3D_canvas->Bind(EVT_GLCANVAS_RESETGIZMOS, [this](SimpleEvent&) { reset_all_gizmos(); }); @@ -2731,7 +2737,7 @@ void Plater::priv::reset() gcode_result.reset(); #if ENABLE_SEQUENTIAL_LIMITS - view3D->get_canvas3d()->set_sequential_print_clearance(Polygons(), false); + view3D->get_canvas3d()->reset_sequential_print_clearance(); #endif // ENABLE_SEQUENTIAL_LIMITS // Stop and reset the Print content. @@ -2943,7 +2949,7 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool process_validation_warning(warning); #if ENABLE_SEQUENTIAL_LIMITS if (printer_technology == ptFFF) { - view3D->get_canvas3d()->set_sequential_print_clearance(Polygons(), false); + view3D->get_canvas3d()->reset_sequential_print_clearance(); view3D->get_canvas3d()->set_as_dirty(); view3D->get_canvas3d()->request_extra_frame(); } @@ -2959,7 +2965,9 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool Polygons polygons; if (print->config().complete_objects) Print::sequential_print_horizontal_clearance_valid(*print, &polygons); - view3D->get_canvas3d()->set_sequential_print_clearance(polygons, true); + view3D->get_canvas3d()->set_sequential_print_clearance_visible(true); + view3D->get_canvas3d()->set_sequential_print_clearance_render_fill(true); + view3D->get_canvas3d()->set_sequential_print_clearance_polygons(polygons); } #endif // ENABLE_SEQUENTIAL_LIMITS } @@ -3864,13 +3872,20 @@ void Plater::priv::on_update_geometry(Vec3dsEvent<2>&) // TODO } +#if ENABLE_SEQUENTIAL_LIMITS +void Plater::priv::on_3dcanvas_mouse_dragging_started(SimpleEvent&) +{ + view3D->get_canvas3d()->reset_sequential_print_clearance(); +} +#endif // ENABLE_SEQUENTIAL_LIMITS + // Update the scene from the background processing, // if the update message was received during mouse manipulation. void Plater::priv::on_3dcanvas_mouse_dragging_finished(SimpleEvent&) { - if (this->delayed_scene_refresh) { - this->delayed_scene_refresh = false; - this->update_sla_scene(); + if (delayed_scene_refresh) { + delayed_scene_refresh = false; + update_sla_scene(); } }