From 32a353058f038fd039dec9df7f339648aa92c34a Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 22 Apr 2020 12:49:52 +0200 Subject: [PATCH] Fixed few warnings --- src/libslic3r/Fill/FillRectilinear2.cpp | 34 ++++++++++++------------- src/libslic3r/GCodeTimeEstimator.cpp | 2 +- src/slic3r/GUI/AppConfig.cpp | 10 ++++---- src/slic3r/GUI/Camera.cpp | 3 --- src/slic3r/GUI/DoubleSlider.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoScale.cpp | 1 - src/slic3r/GUI/KBShortcutsDialog.cpp | 9 ------- src/slic3r/GUI/Preset.cpp | 2 +- src/slic3r/GUI/PresetHints.cpp | 3 +-- src/slic3r/GUI/Tab.cpp | 34 ++++++++++++------------- src/slic3r/GUI/fts_fuzzy_match.h | 2 +- 11 files changed, 44 insertions(+), 58 deletions(-) diff --git a/src/libslic3r/Fill/FillRectilinear2.cpp b/src/libslic3r/Fill/FillRectilinear2.cpp index d83249939..5b862e8cb 100644 --- a/src/libslic3r/Fill/FillRectilinear2.cpp +++ b/src/libslic3r/Fill/FillRectilinear2.cpp @@ -901,7 +901,7 @@ static void connect_segment_intersections_by_contours( const SegmentedIntersectionLine *il_prev = i_vline > 0 ? &segs[i_vline - 1] : nullptr; const SegmentedIntersectionLine *il_next = i_vline + 1 < segs.size() ? &segs[i_vline + 1] : nullptr; - for (int i_intersection = 0; i_intersection < il.intersections.size(); ++ i_intersection) { + for (int i_intersection = 0; i_intersection < int(il.intersections.size()); ++ i_intersection) { SegmentIntersection &itsct = il.intersections[i_intersection]; const Polygon &poly = poly_with_offset.contour(itsct.iContour); const bool forward = itsct.is_low(); // == poly_with_offset.is_contour_ccw(intrsctn->iContour); @@ -914,7 +914,7 @@ static void connect_segment_intersections_by_contours( int iprev = -1; int d_prev = std::numeric_limits::max(); if (il_prev) { - for (int i = 0; i < il_prev->intersections.size(); ++ i) { + for (int i = 0; i < int(il_prev->intersections.size()); ++ i) { const SegmentIntersection &itsct2 = il_prev->intersections[i]; if (itsct.iContour == itsct2.iContour && itsct.type == itsct2.type) { // The intersection points lie on the same contour and have the same orientation. @@ -932,7 +932,7 @@ static void connect_segment_intersections_by_contours( int inext = -1; int d_next = std::numeric_limits::max(); if (il_next) { - for (int i = 0; i < il_next->intersections.size(); ++ i) { + for (int i = 0; i < int(il_next->intersections.size()); ++ i) { const SegmentIntersection &itsct2 = il_next->intersections[i]; if (itsct.iContour == itsct2.iContour && itsct.type == itsct2.type) { // The intersection points lie on the same contour and have the same orientation. @@ -950,7 +950,7 @@ static void connect_segment_intersections_by_contours( bool same_prev = false; bool same_next = false; // Does the perimeter intersect the current vertical line above intrsctn? - for (int i = 0; i < il.intersections.size(); ++ i) + for (int i = 0; i < int(il.intersections.size()); ++ i) if (const SegmentIntersection &it2 = il.intersections[i]; i != i_intersection && it2.iContour == itsct.iContour && it2.type != itsct.type) { int d = distance_of_segmens(poly, it2.iSegment, itsct.iSegment, forward); @@ -1040,7 +1040,7 @@ static void connect_segment_intersections_by_contours( } // Make the LinkQuality::Invalid symmetric on vertical connections. - for (int i_intersection = 0; i_intersection < il.intersections.size(); ++ i_intersection) { + for (int i_intersection = 0; i_intersection < int(il.intersections.size()); ++ i_intersection) { SegmentIntersection &it = il.intersections[i_intersection]; if (it.has_left_vertical() && it.prev_on_contour_quality == SegmentIntersection::LinkQuality::Invalid) { SegmentIntersection &it2 = il.intersections[it.left_vertical()]; @@ -1157,9 +1157,9 @@ static void traverse_graph_generate_polylines( { // For each outer only chords, measure their maximum distance to the bow of the outer contour. // Mark an outer only chord as consumed, if the distance is low. - for (int i_vline = 0; i_vline < segs.size(); ++ i_vline) { + for (int i_vline = 0; i_vline < int(segs.size()); ++ i_vline) { SegmentedIntersectionLine &vline = segs[i_vline]; - for (int i_intersection = 0; i_intersection + 1 < vline.intersections.size(); ++ i_intersection) { + for (int i_intersection = 0; i_intersection + 1 < int(vline.intersections.size()); ++ i_intersection) { if (vline.intersections[i_intersection].type == SegmentIntersection::OUTER_LOW && vline.intersections[i_intersection + 1].type == SegmentIntersection::OUTER_HIGH) { bool consumed = false; @@ -1189,14 +1189,14 @@ static void traverse_graph_generate_polylines( if (i_intersection == -1) { // The path has been interrupted. Find a next starting point, closest to the previous extruder position. coordf_t dist2min = std::numeric_limits().max(); - for (int i_vline2 = 0; i_vline2 < segs.size(); ++ i_vline2) { + for (int i_vline2 = 0; i_vline2 < int(segs.size()); ++ i_vline2) { const SegmentedIntersectionLine &vline = segs[i_vline2]; if (! vline.intersections.empty()) { assert(vline.intersections.size() > 1); // Even number of intersections with the loops. assert((vline.intersections.size() & 1) == 0); assert(vline.intersections.front().type == SegmentIntersection::OUTER_LOW); - for (int i = 0; i < vline.intersections.size(); ++ i) { + for (int i = 0; i < int(vline.intersections.size()); ++ i) { const SegmentIntersection& intrsctn = vline.intersections[i]; if (intrsctn.is_outer()) { assert(intrsctn.is_low() || i > 0); @@ -1674,13 +1674,13 @@ static std::vector generate_montonous_regions(std::vector generate_montonous_regions(std::vectorconsumed_vertical_up = true; int num_lines = 1; - while (++ i_vline < segs.size()) { + while (++ i_vline < int(segs.size())) { SegmentedIntersectionLine &vline_left = segs[i_vline - 1]; SegmentedIntersectionLine &vline_right = segs[i_vline]; std::pair right = right_overlap(left, vline_left, vline_right); @@ -1860,7 +1860,7 @@ static void connect_monotonous_regions(std::vector ®ions, c } } } - if (region.right.vline + 1 < segs.size()) { + if (region.right.vline + 1 < int(segs.size())) { auto &vline = segs[region.right.vline]; auto &vline_right = segs[region.right.vline + 1]; auto [rbegin, rend] = right_overlap(vline.intersections[region.right.low], vline.intersections[region.right.high], vline, vline_right); @@ -2100,7 +2100,7 @@ static std::vector chain_monotonous_regions( AntPath &path2 = path_matrix(region, dir, *next, true); if (path1.visibility > next_candidate.probability) next_candidate = { next, &path1, &path1, path1.visibility, false }; - if (path2.visibility > next_candidate.probability) + if (path2.visibility > next_candidate.probability) next_candidate = { next, &path2, &path2, path2.visibility, true }; } } @@ -2111,7 +2111,7 @@ static std::vector chain_monotonous_regions( AntPath &path2 = path_matrix(region, dir, *next, true); if (path1.visibility > next_candidate.probability) next_candidate = { next, &path1, &path1, path1.visibility, false }; - if (path2.visibility > next_candidate.probability) + if (path2.visibility > next_candidate.probability) next_candidate = { next, &path2, &path2, path2.visibility, true }; } } diff --git a/src/libslic3r/GCodeTimeEstimator.cpp b/src/libslic3r/GCodeTimeEstimator.cpp index 6d7f5f659..f6f602d6c 100644 --- a/src/libslic3r/GCodeTimeEstimator.cpp +++ b/src/libslic3r/GCodeTimeEstimator.cpp @@ -282,7 +282,7 @@ namespace Slic3r { }; GCodeReader parser; - unsigned int g1_lines_count = 0; + int g1_lines_count = 0; int normal_g1_line_id = 0; float normal_last_recorded_time = 0.0f; int silent_g1_line_id = 0; diff --git a/src/slic3r/GUI/AppConfig.cpp b/src/slic3r/GUI/AppConfig.cpp index 0f603c265..ba13a25d8 100644 --- a/src/slic3r/GUI/AppConfig.cpp +++ b/src/slic3r/GUI/AppConfig.cpp @@ -300,13 +300,13 @@ void AppConfig::set_mouse_device(const std::string& name, double translation_spe std::vector AppConfig::get_mouse_device_names() const { - static constexpr char *prefix = "mouse_device:"; - static constexpr size_t prefix_len = 13; // strlen(prefix); reports error C2131: expression did not evaluate to a constant on VS2019 - std::vector out; + static constexpr const char *prefix = "mouse_device:"; + static const size_t prefix_len = strlen(prefix); + std::vector out; for (const std::pair>& key_value_pair : m_storage) - if (boost::starts_with(key_value_pair.first, "mouse_device:") && key_value_pair.first.size() > prefix_len) + if (boost::starts_with(key_value_pair.first, prefix) && key_value_pair.first.size() > prefix_len) out.emplace_back(key_value_pair.first.substr(prefix_len)); - return out; + return out; } void AppConfig::update_config_dir(const std::string &dir) diff --git a/src/slic3r/GUI/Camera.cpp b/src/slic3r/GUI/Camera.cpp index 7ae4a7a1b..ac32767c4 100644 --- a/src/slic3r/GUI/Camera.cpp +++ b/src/slic3r/GUI/Camera.cpp @@ -425,9 +425,6 @@ double Camera::calc_zoom_to_bounding_box_factor(const BoundingBoxf3& box, double if ((dx <= 0.0) || (dy <= 0.0)) return -1.0f; - double med_x = 0.5 * (max_x + min_x); - double med_y = 0.5 * (max_y + min_y); - dx *= margin_factor; dy *= margin_factor; diff --git a/src/slic3r/GUI/DoubleSlider.hpp b/src/slic3r/GUI/DoubleSlider.hpp index bf8f54d6c..6fc5a61c1 100644 --- a/src/slic3r/GUI/DoubleSlider.hpp +++ b/src/slic3r/GUI/DoubleSlider.hpp @@ -22,7 +22,7 @@ namespace DoubleSlider { /* For exporting GCode in GCodeWriter is used XYZF_NUM(val) = PRECISION(val, 3) for XYZ values. * So, let use same value as a permissible error for layer height. */ -static double epsilon() { return 0.0011;} +constexpr double epsilon() { return 0.0011; } // custom message the slider sends to its parent to notify a tick-change: wxDECLARE_EVENT(wxCUSTOMEVT_TICKSCHANGED, wxEvent); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp b/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp index 80cc16ba2..fa2069d0a 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp @@ -26,7 +26,6 @@ std::string GLGizmoScale3D::get_tooltip() const bool single_instance = selection.is_single_full_instance(); bool single_volume = selection.is_single_modifier() || selection.is_single_volume(); - bool single_selection = single_instance || single_volume; Vec3f scale = 100.0f * Vec3f::Ones(); if (single_instance) diff --git a/src/slic3r/GUI/KBShortcutsDialog.cpp b/src/slic3r/GUI/KBShortcutsDialog.cpp index 9f31d23d8..556b610e9 100644 --- a/src/slic3r/GUI/KBShortcutsDialog.cpp +++ b/src/slic3r/GUI/KBShortcutsDialog.cpp @@ -25,15 +25,6 @@ #include #endif // BOOK_TYPE -#if ENABLE_SCROLLABLE -static wxSize get_screen_size(wxWindow* window) -{ - const auto idx = wxDisplay::GetFromWindow(window); - wxDisplay display(idx != wxNOT_FOUND ? idx : 0u); - return display.GetClientArea().GetSize(); -} -#endif // ENABLE_SCROLLABLE - namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index a1f83141a..16a15f1e8 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -962,7 +962,7 @@ void PresetCollection::load_bitmap_add(const std::string &file_name) const Preset* PresetCollection::get_selected_preset_parent() const { - if (this->get_selected_idx() == -1) + if (this->get_selected_idx() == size_t(-1)) // This preset collection has no preset activated yet. Only the get_edited_preset() is valid. return nullptr; diff --git a/src/slic3r/GUI/PresetHints.cpp b/src/slic3r/GUI/PresetHints.cpp index 22fa09f6c..24afeb526 100644 --- a/src/slic3r/GUI/PresetHints.cpp +++ b/src/slic3r/GUI/PresetHints.cpp @@ -296,9 +296,8 @@ std::string PresetHints::top_bottom_shell_thickness_explanation(const PresetBund double bottom_solid_min_thickness = print_config.opt_float("bottom_solid_min_thickness"); double layer_height = print_config.opt_float("layer_height"); bool variable_layer_height = printer_config.opt_bool("variable_layer_height"); - //FIXME the following lines take into account the 1st extruder only. + //FIXME the following line takes into account the 1st extruder only. double min_layer_height = variable_layer_height ? Slicing::min_layer_height_from_nozzle(printer_config, 1) : layer_height; - double max_layer_height = variable_layer_height ? Slicing::max_layer_height_from_nozzle(printer_config, 1) : layer_height; if (layer_height <= 0.f) { out += _utf8(L("Top / bottom shell thickness hint: Not available due to invalid layer height.")); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index da48224b3..3b78b2c9a 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3297,28 +3297,28 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach) wxGetApp().plater()->force_filament_colors_update(); { - // Profile compatiblity is updated first when the profile is saved. - // Update profile selection combo boxes at the depending tabs to reflect modifications in profile compatibility. - std::vector dependent; - switch (m_type) { - case Preset::TYPE_PRINT: - dependent = { Preset::TYPE_FILAMENT }; - break; - case Preset::TYPE_SLA_PRINT: - dependent = { Preset::TYPE_SLA_MATERIAL }; - break; - case Preset::TYPE_PRINTER: + // Profile compatiblity is updated first when the profile is saved. + // Update profile selection combo boxes at the depending tabs to reflect modifications in profile compatibility. + std::vector dependent; + switch (m_type) { + case Preset::TYPE_PRINT: + dependent = { Preset::TYPE_FILAMENT }; + break; + case Preset::TYPE_SLA_PRINT: + dependent = { Preset::TYPE_SLA_MATERIAL }; + break; + case Preset::TYPE_PRINTER: if (static_cast(this)->m_printer_technology == ptFFF) dependent = { Preset::TYPE_PRINT, Preset::TYPE_FILAMENT }; else dependent = { Preset::TYPE_SLA_PRINT, Preset::TYPE_SLA_MATERIAL }; - break; + break; default: - break; - } - for (Preset::Type preset_type : dependent) - wxGetApp().get_tab(preset_type)->update_tab_ui(); - } + break; + } + for (Preset::Type preset_type : dependent) + wxGetApp().get_tab(preset_type)->update_tab_ui(); + } } // Called for a currently selected preset. diff --git a/src/slic3r/GUI/fts_fuzzy_match.h b/src/slic3r/GUI/fts_fuzzy_match.h index e692232cc..34b2bbc5a 100644 --- a/src/slic3r/GUI/fts_fuzzy_match.h +++ b/src/slic3r/GUI/fts_fuzzy_match.h @@ -120,7 +120,7 @@ namespace fts { char *end = Slic3r::fold_to_ascii(*str, tmp); char *c = tmp; for (const wchar_t* d = pattern; c != end && *d != 0 && wchar_t(std::tolower(*c)) == std::tolower(*d); ++c, ++d); - if (c == end) { + if (c == end) { folded_match = true; num_matched = end - tmp; }