diff --git a/src/libslic3r/GCode/Analyzer.cpp b/src/libslic3r/GCode/Analyzer.cpp index f1f828776f..d1ad4f5752 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) diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp index 437f07fcbc..a5fcaf3f36 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, diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 14c1d4b8cc..68a8cef3a5 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -4183,8 +4183,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) { @@ -5338,42 +5341,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)); - } - } - } } } } @@ -5619,6 +5586,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; diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 1d1982ffaa..9e54b9b363 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();