From 902bcf7f710cb689cbe6d3cc2c193b37b2d28bbb Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 18 Mar 2019 09:42:34 +0100 Subject: [PATCH 1/5] Fix of #1978 --- src/libslic3r/GCode/Analyzer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/GCode/Analyzer.cpp b/src/libslic3r/GCode/Analyzer.cpp index f1f828776..d1ad4f575 100644 --- a/src/libslic3r/GCode/Analyzer.cpp +++ b/src/libslic3r/GCode/Analyzer.cpp @@ -726,7 +726,7 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ GCodePreviewData::Range volumetric_rate_range; // to avoid to call the callback too often - unsigned int cancel_callback_threshold = (unsigned int)extrude_moves->second.size() / 25; + unsigned int cancel_callback_threshold = (unsigned int)std::max((int)extrude_moves->second.size() / 25, 1); unsigned int cancel_callback_curr = 0; // constructs the polylines while traversing the moves @@ -807,7 +807,7 @@ void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data, s GCodePreviewData::Range feedrate_range; // to avoid to call the callback too often - unsigned int cancel_callback_threshold = (unsigned int)travel_moves->second.size() / 25; + unsigned int cancel_callback_threshold = (unsigned int)std::max((int)travel_moves->second.size() / 25, 1); unsigned int cancel_callback_curr = 0; // constructs the polylines while traversing the moves @@ -864,7 +864,7 @@ void GCodeAnalyzer::_calc_gcode_preview_retractions(GCodePreviewData& preview_da return; // to avoid to call the callback too often - unsigned int cancel_callback_threshold = (unsigned int)retraction_moves->second.size() / 25; + unsigned int cancel_callback_threshold = (unsigned int)std::max((int)retraction_moves->second.size() / 25, 1); unsigned int cancel_callback_curr = 0; for (const GCodeMove& move : retraction_moves->second) @@ -886,7 +886,7 @@ void GCodeAnalyzer::_calc_gcode_preview_unretractions(GCodePreviewData& preview_ return; // to avoid to call the callback too often - unsigned int cancel_callback_threshold = (unsigned int)unretraction_moves->second.size() / 25; + unsigned int cancel_callback_threshold = (unsigned int)std::max((int)unretraction_moves->second.size() / 25, 1); unsigned int cancel_callback_curr = 0; for (const GCodeMove& move : unretraction_moves->second) From 710bb66dfc39dad6e13a45329bce4de7acf18c7d Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 18 Mar 2019 10:10:11 +0100 Subject: [PATCH 2/5] Fixed assert in imgui when starting Slic3r for the 1st time (no config data saved on disk) --- src/slic3r/GUI/GLCanvas3D.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index dac370b54..94d26fea6 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -4159,8 +4159,11 @@ void GLCanvas3D::render() return; if (m_bed.get_shape().empty()) + { // this happens at startup when no data is still saved under <>\AppData\Roaming\Slic3rPE post_event(SimpleEvent(EVT_GLCANVAS_UPDATE_BED_SHAPE)); + return; + } if (m_camera.requires_zoom_to_bed) { From fe91edc5216175f8becfeb68552865fcaa3d6ad2 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 18 Mar 2019 10:18:24 +0100 Subject: [PATCH 3/5] Set MinSize() in respect to em_unit --- src/slic3r/GUI/MainFrame.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 1d1982ffa..9e54b9b36 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -56,7 +56,8 @@ wxFrame(NULL, wxID_ANY, SLIC3R_BUILD, wxDefaultPosition, wxDefaultSize, wxDEFAUL // initialize default width_unit according to the width of the one symbol ("x") of the current system font const wxSize size = GetTextExtent("m"); - wxGetApp().set_em_unit(size.x-1); +// wxGetApp().set_em_unit(size.x-1); + wxGetApp().set_em_unit(std::max(10, size.x - 1)); // initialize tabpanel and menubar init_tabpanel(); @@ -76,12 +77,14 @@ wxFrame(NULL, wxID_ANY, SLIC3R_BUILD, wxDefaultPosition, wxDefaultSize, wxDEFAUL sizer->SetSizeHints(this); SetSizer(sizer); Fit(); + + const wxSize min_size = wxSize(76*wxGetApp().em_unit(), 49*wxGetApp().em_unit()); #ifdef __APPLE__ // Using SetMinSize() on Mac messes up the window position in some cases // cf. https://groups.google.com/forum/#!topic/wx-users/yUKPBBfXWO0 - SetSize(wxSize(760, 490)); + SetSize(min_size/*wxSize(760, 490)*/); #else - SetMinSize(wxSize(760, 490)); + SetMinSize(min_size/*wxSize(760, 490)*/); SetSize(GetMinSize()); #endif Layout(); From feb2041c7b8fce8fd5a73eef1548f3361029d159 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 18 Mar 2019 10:47:01 +0100 Subject: [PATCH 4/5] Context menu in 3D scene shown on right mouse up event --- src/slic3r/GUI/GLCanvas3D.cpp | 67 ++++++++++++++++------------------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 94d26fea6..dff68d21d 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -5264,42 +5264,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) m_moving = true; } } - else if (evt.RightDown()) - { - m_mouse.position = pos.cast(); - // forces a frame render to ensure that m_hover_volume_id is updated even when the user right clicks while - // the context menu is already shown - render(); - if (m_hover_volume_id != -1) - { - // if right clicking on volume, propagate event through callback (shows context menu) - if (m_volumes.volumes[m_hover_volume_id]->hover - && !m_volumes.volumes[m_hover_volume_id]->is_wipe_tower // no context menu for the wipe tower - && m_gizmos.get_current_type() != Gizmos::SlaSupports) // disable context menu when the gizmo is open - { - // forces the selection of the volume - /** #ys_FIXME_to_delete after testing: - * Next condition allows a multiple instance selection for the context menu, - * which has no reason. So it's commented till next testing - */ -// if (!m_selection.is_multiple_full_instance()) // #ys_FIXME_to_delete - m_selection.add(m_hover_volume_id); - m_gizmos.update_on_off_state(m_selection); - post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT)); - _update_gizmos_data(); - wxGetApp().obj_manipul()->update_settings_value(m_selection); - // forces a frame render to update the view before the context menu is shown - render(); - - Vec2d logical_pos = pos.cast(); -#if ENABLE_RETINA_GL - const float factor = m_retina_helper->get_scale_factor(); - logical_pos = logical_pos.cwiseQuotient(Vec2d(factor, factor)); -#endif // ENABLE_RETINA_GL - post_event(Vec2dEvent(EVT_GLCANVAS_RIGHT_CLICK, logical_pos)); - } - } - } } } } @@ -5521,6 +5485,37 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) post_event(SimpleEvent(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED)); m_camera.set_scene_box(scene_bounding_box()); } + else if (evt.RightUp()) + { + m_mouse.position = pos.cast(); + // forces a frame render to ensure that m_hover_volume_id is updated even when the user right clicks while + // the context menu is already shown + render(); + if (m_hover_volume_id != -1) + { + // if right clicking on volume, propagate event through callback (shows context menu) + if (m_volumes.volumes[m_hover_volume_id]->hover + && !m_volumes.volumes[m_hover_volume_id]->is_wipe_tower // no context menu for the wipe tower + && m_gizmos.get_current_type() != Gizmos::SlaSupports) // disable context menu when the gizmo is open + { + // forces the selection of the volume + m_selection.add(m_hover_volume_id); + m_gizmos.update_on_off_state(m_selection); + post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT)); + _update_gizmos_data(); + wxGetApp().obj_manipul()->update_settings_value(m_selection); + // forces a frame render to update the view before the context menu is shown + render(); + + Vec2d logical_pos = pos.cast(); +#if ENABLE_RETINA_GL + const float factor = m_retina_helper->get_scale_factor(); + logical_pos = logical_pos.cwiseQuotient(Vec2d(factor, factor)); +#endif // ENABLE_RETINA_GL + post_event(Vec2dEvent(EVT_GLCANVAS_RIGHT_CLICK, logical_pos)); + } + } + } m_moving = false; m_mouse.drag.move_volume_idx = -1; From 0d9a74bb6d9406e438308a801a231c4699a6c8bf Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Mon, 18 Mar 2019 10:48:23 +0100 Subject: [PATCH 5/5] Fix for ugly code. --- src/libslic3r/SLA/SLASupportTree.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp index 437f07fcb..a5fcaf3f3 100644 --- a/src/libslic3r/SLA/SLASupportTree.cpp +++ b/src/libslic3r/SLA/SLASupportTree.cpp @@ -755,9 +755,12 @@ public: return m_compact_bridges; } - template inline - typename std::enable_if::value, const Pillar&>::type - pillar(T id) const { assert(id >= 0); return m_pillars.at(size_t(id)); } + template inline const Pillar& pillar(T id) const { + static_assert(std::is_integral::value, "Invalid index type"); + assert(id >= 0 && id < m_pillars.size() && + id < std::numerix_limits::max()); + return m_pillars[size_t(id)]; + } const Pad& create_pad(const TriangleMesh& object_supports, const ExPolygons& baseplate,