From 1fbbaaae9bf2cdbd56ada1a0def59d1f691c1c2d Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 7 Mar 2023 12:30:23 +0100 Subject: [PATCH 1/6] Fixed several warnings --- src/libslic3r/Config.hpp | 12 +++---- src/libslic3r/GCode/WipeTower.cpp | 6 ++-- src/libslic3r/Geometry/MedialAxis.cpp | 4 ++- src/libslic3r/LayerRegion.cpp | 2 +- src/libslic3r/Model.cpp | 1 - src/libslic3r/PrintObject.cpp | 2 +- src/libslic3r/SLAPrint.cpp | 2 +- src/libslic3r/SLAPrintSteps.cpp | 2 +- src/libslic3r/TriangleMesh.cpp | 2 +- src/libslic3r/TriangleMeshSlicer.cpp | 6 +++- src/slic3r/GUI/Field.cpp | 16 ++++----- src/slic3r/GUI/Gizmos/GLGizmoCut.cpp | 50 --------------------------- src/slic3r/GUI/PrintHostDialogs.cpp | 2 +- src/slic3r/Utils/Bonjour.cpp | 2 +- src/slic3r/Utils/TCPConsole.cpp | 8 ++--- 15 files changed, 36 insertions(+), 81 deletions(-) diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index a1013f1fc7..538580d506 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -1736,7 +1736,7 @@ private: void set_values(const std::initializer_list il) { m_values.clear(); m_values.reserve(il.size()); - for (const std::string_view p : il) + for (const std::string_view& p : il) m_values.emplace_back(p); assert(m_labels.empty() || m_labels.size() == m_values.size()); } @@ -1745,7 +1745,7 @@ private: m_values.reserve(il.size()); m_labels.clear(); m_labels.reserve(il.size()); - for (const std::pair p : il) { + for (const std::pair& p : il) { m_values.emplace_back(p.first); m_labels.emplace_back(p.second); } @@ -1753,7 +1753,7 @@ private: void set_labels(const std::initializer_list il) { m_labels.clear(); m_labels.reserve(il.size()); - for (const std::string_view p : il) + for (const std::string_view& p : il) m_labels.emplace_back(p); assert(m_values.empty() || m_labels.size() == m_values.size()); } @@ -1762,9 +1762,9 @@ private: // Check whether def.enum_values contains all the values of def.enum_keys_map and // that they are sorted by their ordinary values. m_values_ordinary = true; - for (const std::pair& key : *m_enum_keys_map) { - assert(key.second >= 0); - if (key.second >= this->values().size() || this->value(key.second) != key.first) { + for (const auto& [enum_name, enum_int] : *m_enum_keys_map) { + assert(enum_int >= 0); + if (enum_int >= int(this->values().size()) || this->value(enum_int) != enum_name) { m_values_ordinary = false; break; } diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index 237ec3604d..4f4871366a 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -929,7 +929,7 @@ void WipeTower::toolchange_Unload( writer.retract(-m_cooling_tube_length/2.f+m_parking_pos_retraction-m_cooling_tube_retraction, 2000); } - // this is to align ramming and future wiping extrusions, so the future y-steps can be uniform from the start: + // this is to align ramming and future wiping extrusions, so the future y-steps can be uniform from the start: // the perimeter_width will later be subtracted, it is there to not load while moving over just extruded material Vec2f pos = Vec2f(end_of_ramming.x(), end_of_ramming.y() + (y_step/m_extra_spacing-m_perimeter_width) / 2.f + m_perimeter_width); if (m_semm) @@ -937,8 +937,8 @@ void WipeTower::toolchange_Unload( else writer.set_position(pos); - writer.resume_preview() - .flush_planner_queue(); + writer.resume_preview() + .flush_planner_queue(); } // Change the tool, set a speed override for soluble and flex materials. diff --git a/src/libslic3r/Geometry/MedialAxis.cpp b/src/libslic3r/Geometry/MedialAxis.cpp index 39677c9285..0f9d81da66 100644 --- a/src/libslic3r/Geometry/MedialAxis.cpp +++ b/src/libslic3r/Geometry/MedialAxis.cpp @@ -444,7 +444,9 @@ private: MedialAxis::MedialAxis(double min_width, double max_width, const ExPolygon &expolygon) : m_expolygon(expolygon), m_lines(expolygon.lines()), m_min_width(min_width), m_max_width(max_width) -{} +{ + (void)m_expolygon; // supress unused variable warning +} void MedialAxis::build(ThickPolylines* polylines) { diff --git a/src/libslic3r/LayerRegion.cpp b/src/libslic3r/LayerRegion.cpp index 0adc8f4cf8..6017f393e7 100644 --- a/src/libslic3r/LayerRegion.cpp +++ b/src/libslic3r/LayerRegion.cpp @@ -356,7 +356,7 @@ void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Poly shell_width += perimeter_flow.scaled_spacing() * (num_perimeters - 1); } else { // TODO: Maybe there is better solution when printing with zero perimeters, but this works reasonably well, given the situation - shell_width = SCALED_EPSILON; + shell_width = float(SCALED_EPSILON); } // Scaled expansions of the respective external surfaces. diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 6024cd7754..c21f6bd2b5 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -889,7 +889,6 @@ const BoundingBoxf3& ModelObject::bounding_box_exact() const if (! m_bounding_box_exact_valid) { m_bounding_box_exact_valid = true; m_min_max_z_valid = true; - BoundingBoxf3 raw_bbox = this->raw_mesh_bounding_box(); m_bounding_box_exact.reset(); for (size_t i = 0; i < this->instances.size(); ++ i) m_bounding_box_exact.merge(this->instance_bounding_box(i)); diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 005309e7c3..b9552a2ef1 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -1774,7 +1774,7 @@ void PrintObject::bridge_over_infill() Polygons infill_region = to_polygons(r->fill_expolygons()); Polygons deep_infill_area = closing(infill_region, scale_(0.01), scale_(0.01) + 4.0 * flow.scaled_spacing()); Polygons solid_supported_area = expand(not_sparse_infill, 4.0 * flow.scaled_spacing()); - infill_and_deep_infill_polygons_per_region[r] = {closing(infill_region, scale_(0.1)), + infill_and_deep_infill_polygons_per_region[r] = {closing(infill_region, float(scale_(0.1))), intersection(lower_layers_sparse_infill, diff(deep_infill_area, solid_supported_area))}; } diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index abf8b5216a..202da5e003 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -1077,7 +1077,7 @@ SLAPrintObject::get_parts_to_slice(SLAPrintObjectStep untilstep) const std::vector ret; - for (int step = 0; step < s; ++step) { + for (unsigned int step = 0; step < s; ++step) { auto r = m_mesh_to_slice.equal_range(SLAPrintObjectStep(step)); csg::copy_csgrange_shallow(Range{r.first, r.second}, std::back_inserter(ret)); } diff --git a/src/libslic3r/SLAPrintSteps.cpp b/src/libslic3r/SLAPrintSteps.cpp index 92260deecb..3381304544 100644 --- a/src/libslic3r/SLAPrintSteps.cpp +++ b/src/libslic3r/SLAPrintSteps.cpp @@ -180,7 +180,7 @@ indexed_triangle_set SLAPrint::Steps::generate_preview_vdb( auto r = range(po.m_mesh_to_slice); auto grid = csg::voxelize_csgmesh(r, voxparams); auto m = grid ? grid_to_mesh(*grid, 0., 0.01) : indexed_triangle_set{}; - float loss_less_max_error = 1e-6; + float loss_less_max_error = float(1e-6); its_quadric_edge_collapse(m, 0U, &loss_less_max_error); return m; diff --git a/src/libslic3r/TriangleMesh.cpp b/src/libslic3r/TriangleMesh.cpp index 4d9dff3452..d35251d205 100644 --- a/src/libslic3r/TriangleMesh.cpp +++ b/src/libslic3r/TriangleMesh.cpp @@ -1114,7 +1114,7 @@ indexed_triangle_set its_make_sphere(double radius, double fa) std::vector> divided_triangles(indices.size()); std::vector new_neighbors(4*indices.size()); - size_t orig_indices_size = indices.size(); + int orig_indices_size = int(indices.size()); for (int i=0; i(window, m_opt.type) ) - // on_kill_focus() cause a call of OptionsGroup::reload_config(), - // Thus, do it only when it's really needed (when undefined value was input) + if (!is_defined_input_value(window, m_opt.type) ) + // on_kill_focus() cause a call of OptionsGroup::reload_config(), + // Thus, do it only when it's really needed (when undefined value was input) on_kill_focus(); - else if (value_was_changed()) + else if (value_was_changed()) on_change_field(); } @@ -931,8 +931,8 @@ boost::any& SpinCtrl::get_value() if (spin->GetTextValue() == na_value(true)) return m_value; - int value = spin->GetValue(); - return m_value = value; + int value = spin->GetValue(); + return m_value = value; } void SpinCtrl::propagate_value() @@ -946,7 +946,7 @@ void SpinCtrl::propagate_value() if (tmp_value == UNDEF_VALUE) { on_kill_focus(); - } else { + } else { #ifdef __WXOSX__ // check input value for minimum if (m_opt.min > 0 && tmp_value < m_opt.min) { @@ -1152,7 +1152,7 @@ void Choice::set_value(const std::string& value, bool change_event) //! Redunda field->SetSelection(*opt); else field->SetValue(value); - m_disable_change_event = false; + m_disable_change_event = false; } void Choice::set_value(const boost::any& value, bool change_event) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index 820e35a375..3ba67e60e7 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -64,26 +64,6 @@ static GLModel::Geometry its_make_line(Vec3f beg_pos, Vec3f end_pos) return init_data; } -// Generates mesh for a square plane -static GLModel::Geometry its_make_square_plane(float radius) -{ - GLModel::Geometry init_data; - init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3 }; - init_data.reserve_vertices(4); - init_data.reserve_indices(6); - - // vertices - init_data.add_vertex(Vec3f(-radius, -radius, 0.0)); - init_data.add_vertex(Vec3f(radius , -radius, 0.0)); - init_data.add_vertex(Vec3f(radius , radius , 0.0)); - init_data.add_vertex(Vec3f(-radius, radius , 0.0)); - - // indices - init_data.add_triangle(0, 1, 2); - init_data.add_triangle(2, 3, 0); - return init_data; -} - //! -- #ysFIXME those functions bodies are ported from GizmoRotation // Generates mesh for a circle static void init_from_circle(GLModel& model, double radius) @@ -627,36 +607,6 @@ bool GLGizmoCut3D::render_reset_button(const std::string& label_id, const std::s return revert; } -static Vec2d ndc_to_ss(const Vec3d& ndc, const std::array& viewport) { - const double half_w = 0.5 * double(viewport[2]); - const double half_h = 0.5 * double(viewport[3]); - return { half_w * ndc.x() + double(viewport[0]) + half_w, half_h * ndc.y() + double(viewport[1]) + half_h }; -}; -static Vec3d clip_to_ndc(const Vec4d& clip) { - return Vec3d(clip.x(), clip.y(), clip.z()) / clip.w(); -} -static Vec4d world_to_clip(const Vec3d& world, const Matrix4d& projection_view_matrix) { - return projection_view_matrix * Vec4d(world.x(), world.y(), world.z(), 1.0); -} -static Vec2d world_to_ss(const Vec3d& world, const Matrix4d& projection_view_matrix, const std::array& viewport) { - return ndc_to_ss(clip_to_ndc(world_to_clip(world, projection_view_matrix)), viewport); -} - -static wxString get_label(Vec3d vec) -{ - wxString str = "x=" + double_to_string(vec.x(), 2) + - ", y=" + double_to_string(vec.y(), 2) + - ", z=" + double_to_string(vec.z(), 2); - return str; -} - -static wxString get_label(Vec2d vec) -{ - wxString str = "x=" + double_to_string(vec.x(), 2) + - ", y=" + double_to_string(vec.y(), 2); - return str; -} - void GLGizmoCut3D::render_cut_plane() { if (cut_line_processing()) diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp index 982fe99a7a..f986a15522 100644 --- a/src/slic3r/GUI/PrintHostDialogs.cpp +++ b/src/slic3r/GUI/PrintHostDialogs.cpp @@ -197,7 +197,7 @@ std::string PrintHostSendDialog::storage() const { if (!combo_storage) return GUI::format("%1%", m_preselected_storage); - if (combo_storage->GetSelection() < 0 || combo_storage->GetSelection() >= m_paths.size()) + if (combo_storage->GetSelection() < 0 || combo_storage->GetSelection() >= int(m_paths.size())) return {}; return boost::nowide::narrow(m_paths[combo_storage->GetSelection()]); } diff --git a/src/slic3r/Utils/Bonjour.cpp b/src/slic3r/Utils/Bonjour.cpp index e357083816..0701695eff 100644 --- a/src/slic3r/Utils/Bonjour.cpp +++ b/src/slic3r/Utils/Bonjour.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include using boost::optional; using boost::system::error_code; diff --git a/src/slic3r/Utils/TCPConsole.cpp b/src/slic3r/Utils/TCPConsole.cpp index 3c943cc632..277e3c0d5c 100644 --- a/src/slic3r/Utils/TCPConsole.cpp +++ b/src/slic3r/Utils/TCPConsole.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -41,7 +41,7 @@ void TCPConsole::transmit_next_command() boost::asio::async_write( m_socket, boost::asio::buffer(m_send_buffer), - boost::bind(&TCPConsole::handle_write, this, _1, _2) + boost::bind(&TCPConsole::handle_write, this, boost::placeholders::_1, boost::placeholders::_2) ); } @@ -52,7 +52,7 @@ void TCPConsole::wait_next_line() m_socket, m_recv_buffer, m_newline, - boost::bind(&TCPConsole::handle_read, this, _1, _2) + boost::bind(&TCPConsole::handle_read, this, boost::placeholders::_1, boost::placeholders::_2) ); } @@ -157,7 +157,7 @@ bool TCPConsole::run_queue() auto endpoints = m_resolver.resolve(m_host_name, m_port_name); m_socket.async_connect(endpoints->endpoint(), - boost::bind(&TCPConsole::handle_connect, this, _1) + boost::bind(&TCPConsole::handle_connect, this, boost::placeholders::_1) ); // Loop until we get any reasonable result. Negative result is also result. From e403c0e69c6a3a5fb5dcf5fa5becb06d27f2d4ee Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 7 Mar 2023 15:27:57 +0100 Subject: [PATCH 2/6] Fix for #9770 - Filament type not user editable, dropdown only Follow-up 917c9ad4 --- src/slic3r/GUI/Field.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index ecb7d61907..c6ffa46ec4 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -988,7 +988,6 @@ void Choice::BUILD() { choice_ctrl* temp; if (m_opt.gui_type != ConfigOptionDef::GUIType::undefined - && m_opt.gui_type != ConfigOptionDef::GUIType::select_open && m_opt.gui_type != ConfigOptionDef::GUIType::select_close) { m_is_editable = true; temp = new choice_ctrl(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxTE_PROCESS_ENTER); From 6734ad6c3cfa9bf9e4c37502d9d133b84a480113 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 7 Mar 2023 17:06:42 +0100 Subject: [PATCH 3/6] Code cleaning --- src/slic3r/GUI/wxExtensions.cpp | 39 --------------------------------- src/slic3r/GUI/wxExtensions.hpp | 7 ------ 2 files changed, 46 deletions(-) diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index e528191aa7..d4bd27c056 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -458,44 +458,6 @@ wxBitmapBundle* get_solid_bmp_bundle(int width, int height, const std::string& c #endif // __WXGTK2__ } -// win is used to get a correct em_unit value -// It's important for bitmaps of dialogs. -// if win == nullptr, em_unit value of MainFrame will be used -wxBitmap create_scaled_bitmap( const std::string& bmp_name_in, - wxWindow *win/* = nullptr*/, - const int px_cnt/* = 16*/, - const bool grayscale/* = false*/, - const std::string& new_color/* = std::string()*/, // color witch will used instead of orange - const bool menu_bitmap/* = false*/) -{ - static Slic3r::GUI::BitmapCache cache; - - unsigned int width = 0; - unsigned int height = (unsigned int)(em_unit(win) * px_cnt * 0.1f + 0.5f); - - std::string bmp_name = bmp_name_in; - boost::replace_last(bmp_name, ".png", ""); - - bool dark_mode = -#ifdef _WIN32 - menu_bitmap ? Slic3r::GUI::check_dark_mode() : -#endif - Slic3r::GUI::wxGetApp().dark_mode(); - - // Try loading an SVG first, then PNG if SVG is not found: - wxBitmap *bmp = cache.load_svg(bmp_name, width, height, grayscale, dark_mode, new_color); - if (bmp == nullptr) { - bmp = cache.load_png(bmp_name, width, height, grayscale); - } - - if (bmp == nullptr) { - // Neither SVG nor PNG has been found, raise error - throw Slic3r::RuntimeError("Could not load bitmap: " + bmp_name); - } - - return *bmp; -} - std::vector get_extruder_color_icons(bool thin_icon/* = false*/) { // Create the bitmap with color bars. @@ -742,7 +704,6 @@ void ModeButton::sys_color_changed() ModeSizer::ModeSizer(wxWindow *parent, int hgap/* = 0*/) : wxFlexGridSizer(3, 0, hgap), - m_parent(parent), m_hgap_unscaled((double)(hgap)/em_unit(parent)) { SetFlexibleDirection(wxHORIZONTAL); diff --git a/src/slic3r/GUI/wxExtensions.hpp b/src/slic3r/GUI/wxExtensions.hpp index 5b15b34700..00f117e671 100644 --- a/src/slic3r/GUI/wxExtensions.hpp +++ b/src/slic3r/GUI/wxExtensions.hpp @@ -54,11 +54,6 @@ wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name, int px_cnt = 16, con wxBitmapBundle* get_empty_bmp_bundle(int width, int height); wxBitmapBundle* get_solid_bmp_bundle(int width, int height, const std::string& color); -wxBitmap create_scaled_bitmap(const std::string& bmp_name, wxWindow *win = nullptr, - const int px_cnt = 16, const bool grayscale = false, - const std::string& new_color = std::string(), // color witch will used instead of orange - const bool menu_bitmap = false); - std::vector get_extruder_color_icons(bool thin_icon = false); namespace Slic3r { @@ -172,7 +167,6 @@ private: wxBitmap m_bitmap = wxBitmap(); std::string m_icon_name = ""; int m_px_cnt {16}; - bool m_grayscale {false}; }; @@ -338,7 +332,6 @@ public: private: std::vector m_mode_btns; - wxWindow* m_parent {nullptr}; double m_hgap_unscaled; }; From 54ea675473f38f26cee234b948006723fcf83a08 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Wed, 8 Mar 2023 09:21:59 +0100 Subject: [PATCH 4/6] Generation of procedural model for wipe tower reverted to old implementation, as the raycasted picking does not require it to be watertight anymore --- src/slic3r/GUI/3DScene.cpp | 210 ++++--------------------------------- 1 file changed, 23 insertions(+), 187 deletions(-) diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 588aca51fb..c25bff45de 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -511,202 +511,38 @@ int GLVolumeCollection::load_wipe_tower_preview( // We'll now create the box with jagged edge. y-coordinates of the pre-generated model // are shifted so that the front edge has y=0 and centerline of the back edge has y=depth: - // We split the box in three main pieces, - // the two laterals are identical and the central is the one containing the jagged geometry - - // lateral parts generator - auto generate_lateral = [&](float min_x, float max_x) { - const std::vector vertices = { - { min_x, -(depth + brim_width), 0.0f }, - { max_x, -(depth + brim_width), 0.0f }, - { min_x, -(depth + brim_width), scaled_brim_height }, - { max_x, -(depth + brim_width), scaled_brim_height }, - { min_x, -depth, scaled_brim_height }, - { max_x, -depth, scaled_brim_height }, - { min_x, -depth, 1.0f }, - { max_x, -depth, 1.0f }, - { min_x, 0.0f, 1.0f }, - { max_x, 0.0f, 1.0f }, - { min_x, 0.0f, scaled_brim_height }, - { max_x, 0.0f, scaled_brim_height }, - { min_x, brim_width, scaled_brim_height }, - { max_x, brim_width, scaled_brim_height }, - { min_x, brim_width, 0.0f }, - { max_x, brim_width, 0.0f } - }; - const std::vector triangles = { - { 0, 1, 3 }, { 0, 3, 2 }, { 2, 3, 5 }, { 2, 5, 4 }, { 4, 5, 7 }, { 4, 7, 6 }, { 6, 7, 9 }, { 6, 9, 8 }, - { 8, 9, 11 }, { 8, 11, 10 }, { 10, 11, 13 }, { 10, 13, 12 }, { 12, 13, 15 }, { 12, 15, 14 }, { 14, 15, 1 }, { 14, 1, 0 } - }; - - indexed_triangle_set its; - its.vertices.reserve(vertices.size()); - for (const Vec3f& v : vertices) { - its.vertices.emplace_back(v.x(), v.y() + depth, v.z()); - } - its.indices.reserve(triangles.size()); - for (const Vec3i& t : triangles) { - its.indices.emplace_back(t); - } - return its; - }; - - // central parts generator - auto generate_central = [&]() { - const std::vector vertices = { - // this part is not watertight to avoid to have different geometries for the cases - // brim_width < 10.0 - // brim_width == 10.0 - // brim_width > 10.0 - { 38.453f, -(depth + brim_width), 0.0f }, - { 61.547f, -(depth + brim_width), 0.0f }, - { 38.453f, -(depth + brim_width), scaled_brim_height }, - { 61.547f, -(depth + brim_width), scaled_brim_height }, - { 38.453f, -depth, scaled_brim_height }, - { 61.547f, -depth, scaled_brim_height }, - { 38.453f, -depth, 1.0f }, - { 61.547f, -depth, 1.0f }, - { 38.453f, 0.0f, 1.0f }, - { 44.2265f, 10.0f, 1.0f }, - { 50.0f, 0.0f, 1.0f }, - { 55.7735f, -10.0f, 1.0f }, - { 61.547f, 0.0f, 1.0f }, - { 38.453f, 0.0f, scaled_brim_height }, - { 44.2265f, 10.0f, scaled_brim_height }, - { 50.0f, 0.0f, scaled_brim_height }, - { 55.7735f, -10.0f, scaled_brim_height }, - { 61.547f, 0.0f, scaled_brim_height }, - { 38.453f, 0.0f, 0.0f }, - { 44.2265f, 10.0f, 0.0f }, - { 50.0f, 0.0f, 0.0f }, - { 55.7735f, -10.0f, 0.0f }, - { 61.547f, 0.0f, 0.0f }, - { 38.453f, brim_width, scaled_brim_height }, - { 61.547f, brim_width, scaled_brim_height }, - { 38.453f, brim_width, 0.0f }, - { 61.547f, brim_width, 0.0f }, - }; - - const std::vector triangles = { - { 0, 1, 3 }, { 0, 3, 2 }, { 2, 3, 5 }, { 2, 5, 4 }, { 4, 5, 7 }, { 4, 7, 6 }, - { 6, 7, 11 }, { 6, 11, 10 }, { 6, 10, 8 }, { 8, 10, 9 }, { 11, 7, 12 }, { 14, 13, 8 }, - { 14, 8, 9 }, { 19, 18, 13 }, { 19, 13, 14 }, { 15, 14, 9 }, { 15, 9, 10 }, { 20, 19, 14 }, - { 20, 14, 15 }, { 16, 15, 10 }, { 16, 10, 11 }, { 21, 20, 15 }, { 21, 15, 16 }, { 17, 16, 11 }, - { 17, 11, 12 }, { 22, 21, 16 }, { 22, 16, 17 }, { 15, 16, 17 }, { 13, 15, 23 }, { 15, 17, 24 }, - { 15, 24, 23 }, { 26, 25, 23 }, { 26, 23, 24 }, { 0, 25, 1 }, { 1, 25, 26 }, { 20, 18, 19 } - }; - - indexed_triangle_set its; - its.vertices.reserve(vertices.size()); - for (const Vec3f& v : vertices) { - its.vertices.emplace_back(v.x(), v.y() + depth, v.z()); - } - its.indices.reserve(triangles.size()); - for (const Vec3i& t : triangles) { - its.indices.emplace_back(t); - } - return its; - }; - - TriangleMesh tooth_mesh; - indexed_triangle_set data = generate_lateral(0.0f, 38.453f); - tooth_mesh.merge(TriangleMesh(std::move(data))); - data = generate_central(); - tooth_mesh.merge(TriangleMesh(std::move(data))); - data = generate_lateral(61.547f, 100.0f); - tooth_mesh.merge(TriangleMesh(std::move(data))); + float out_points_idx[][3] = { { 0, -depth, 0 }, { 0, 0, 0 }, { 38.453f, 0, 0 }, { 61.547f, 0, 0 }, { 100.0f, 0, 0 }, { 100.0f, -depth, 0 }, { 55.7735f, -10.0f, 0 }, { 44.2265f, 10.0f, 0 }, + { 38.453f, 0, 1 }, { 0, 0, 1 }, { 0, -depth, 1 }, { 100.0f, -depth, 1 }, { 100.0f, 0, 1 }, { 61.547f, 0, 1 }, { 55.7735f, -10.0f, 1 }, { 44.2265f, 10.0f, 1 } }; + static constexpr const int out_facets_idx[][3] = { + { 0, 1, 2 }, { 3, 4, 5 }, { 6, 5, 0 }, { 3, 5, 6 }, { 6, 2, 7 }, { 6, 0, 2 }, { 8, 9, 10 }, { 11, 12, 13 }, { 10, 11, 14 }, { 14, 11, 13 }, { 15, 8, 14 }, + { 8, 10, 14 }, { 3, 12, 4 }, { 3, 13, 12 }, { 6, 13, 3 }, { 6, 14, 13 }, { 7, 14, 6 }, { 7, 15, 14 }, { 2, 15, 7 }, { 2, 8, 15 }, { 1, 8, 2 }, { 1, 9, 8 }, + { 0, 9, 1 }, { 0, 10, 9 }, { 5, 10, 0 }, { 5, 11, 10 }, { 4, 11, 5 }, { 4, 12, 11 } }; + indexed_triangle_set its; + for (int i = 0; i < 16; ++i) + its.vertices.emplace_back(out_points_idx[i][0] / (100.f / min_width), out_points_idx[i][1] + depth, out_points_idx[i][2]); + its.indices.reserve(28); + for (const int* face : out_facets_idx) + its.indices.emplace_back(face); + TriangleMesh tooth_mesh(std::move(its)); // We have the mesh ready. It has one tooth and width of min_width. We will now // append several of these together until we are close to the required width // of the block. Than we can scale it precisely. - const size_t n = std::max(1, int(width / min_width)); // How many shall be merged? + size_t n = std::max(1, int(width / min_width)); // How many shall be merged? for (size_t i = 0; i < n; ++i) { mesh.merge(tooth_mesh); - tooth_mesh.translate(100.0f, 0.0f, 0.0f); + tooth_mesh.translate(min_width, 0.f, 0.f); } - // Now we add the caps along the X axis - const float scaled_brim_width_x = brim_width * n * width / min_width; - auto generate_negx_cap = [&]() { - const std::vector vertices = { - { -scaled_brim_width_x, -(depth + brim_width), 0.0f }, - { 0.0f, -(depth + brim_width), 0.0f }, - { -scaled_brim_width_x, -(depth + brim_width), scaled_brim_height }, - { 0.0f, -(depth + brim_width), scaled_brim_height }, - { 0.0f, -depth, scaled_brim_height }, - { 0.0f, -depth, 1.0f }, - { 0.0f, 0.0f, 1.0f }, - { 0.0f, 0.0f, scaled_brim_height }, - { 0.0f, brim_width, scaled_brim_height }, - { -scaled_brim_width_x, brim_width, scaled_brim_height }, - { 0.0f, brim_width, 0.0f }, - { -scaled_brim_width_x, brim_width, 0.0f } - }; - - const std::vector triangles = { - { 0, 1, 3 }, { 0, 3, 2 }, { 2, 3, 4 }, { 2, 4, 9 }, { 9, 4, 7 }, { 9, 7, 8 }, { 9, 8, 10 }, { 9, 10, 11 }, - { 11, 10, 1 }, { 11, 1, 0 }, { 11, 0, 2 }, { 11, 2, 9 }, { 7, 4, 5 }, { 7, 5, 6 } - }; - - indexed_triangle_set its; - its.vertices.reserve(vertices.size()); - for (const Vec3f& v : vertices) { - its.vertices.emplace_back(v.x(), v.y() + depth, v.z()); - } - its.indices.reserve(triangles.size()); - for (const Vec3i& t : triangles) { - its.indices.emplace_back(t); - } - return its; - }; - - auto generate_posx_cap = [&]() { - const float posx_cap_x = n * 100.0f; - const std::vector vertices = { - { posx_cap_x, -(depth + brim_width), 0.0f }, - { posx_cap_x + scaled_brim_width_x, -(depth + brim_width), 0.0f }, - { posx_cap_x, -(depth + brim_width), scaled_brim_height }, - { posx_cap_x + scaled_brim_width_x, -(depth + brim_width), scaled_brim_height }, - { posx_cap_x, -depth, scaled_brim_height }, - { posx_cap_x, -depth, 1.0f }, - { posx_cap_x, 0.0f, 1.0f }, - { posx_cap_x, 0.0f, scaled_brim_height }, - { posx_cap_x, brim_width, scaled_brim_height }, - { posx_cap_x + scaled_brim_width_x, brim_width, scaled_brim_height }, - { posx_cap_x, brim_width, 0.0f }, - { posx_cap_x + scaled_brim_width_x, brim_width, 0.0f } - }; - - const std::vector triangles = { - { 0, 1, 3 }, { 0, 3, 2 }, { 2, 3, 4 }, { 4, 3, 9 }, { 4, 9, 7 }, { 7, 9, 8 }, { 8, 9, 11 }, { 8, 11, 10 }, - { 10, 11, 1 }, { 10, 1, 0 }, { 1, 11, 9 }, { 1, 9, 3 }, { 4, 7, 6 }, { 4, 6, 5 } - }; - - indexed_triangle_set its; - its.vertices.reserve(vertices.size()); - for (const Vec3f& v : vertices) { - its.vertices.emplace_back(v.x(), v.y() + depth, v.z()); - } - its.indices.reserve(triangles.size()); - for (const Vec3i& t : triangles) { - its.indices.emplace_back(t); - } - return its; - }; - - data = generate_negx_cap(); - mesh.merge(TriangleMesh(std::move(data))); - data = generate_posx_cap(); - mesh.merge(TriangleMesh(std::move(data))); - mesh.scale(Vec3f(width / (n * 100.0f), 1.0f, height)); // Scaling to proper width - } - else { - mesh = make_cube(width, depth, height - brim_height); - mesh.translate(0.0f, 0.0f, brim_height); - TriangleMesh brim_mesh = make_cube(width + 2.0f * brim_width, depth + 2.0f * brim_width, brim_height); - brim_mesh.translate(-brim_width, -brim_width, 0.0f); - mesh.merge(brim_mesh); + mesh.scale(Vec3f(width / (n * min_width), 1.f, height)); // Scaling to proper width } + else + mesh = make_cube(width, depth, height); + + // We'll make another mesh to show the brim (fixed layer height): + TriangleMesh brim_mesh = make_cube(width + 2.f * brim_width, depth + 2.f * brim_width, 0.2f); + brim_mesh.translate(-brim_width, -brim_width, 0.f); + mesh.merge(brim_mesh); volumes.emplace_back(new GLVolume(color)); GLVolume& v = *volumes.back(); From 2a6f53ce359109025c41949da3bbf5b8ce07b4e0 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 8 Mar 2023 09:51:39 +0100 Subject: [PATCH 5/6] Code cleaning --- src/slic3r/GUI/ConfigManipulation.cpp | 2 -- src/slic3r/GUI/PhysicalPrinterDialog.cpp | 1 - src/slic3r/GUI/Preferences.cpp | 19 ------------------- 3 files changed, 22 deletions(-) diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index 5129cdc61b..5eb1d2087e 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -113,8 +113,6 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con } } - auto style = config->opt_enum("support_material_style"); - if (config->opt_bool("wipe_tower") && config->opt_bool("support_material") && // Organic supports are always synchronized with object layers as of now. config->opt_enum("support_material_style") != smsOrganic) { diff --git a/src/slic3r/GUI/PhysicalPrinterDialog.cpp b/src/slic3r/GUI/PhysicalPrinterDialog.cpp index 25f8bea62e..2156401488 100644 --- a/src/slic3r/GUI/PhysicalPrinterDialog.cpp +++ b/src/slic3r/GUI/PhysicalPrinterDialog.cpp @@ -633,7 +633,6 @@ void PhysicalPrinterDialog::update_host_type(bool printer_change) Choice* choice = dynamic_cast(ht); choice->set_values(types); - int dif = (int)ht->m_opt.enum_def->values().size() - (int)types.size(); int index_in_choice = (printer_change ? std::clamp(last_in_conf - ((int)ht->m_opt.enum_def->values().size() - (int)types.size()), 0, (int)ht->m_opt.enum_def->values().size() - 1) : last_in_conf); choice->set_value(index_in_choice); if (link.supported && link.label == _(ht->m_opt.enum_def->label(index_in_choice))) diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index ae884ce4aa..0d5bf0f8c5 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -188,25 +188,6 @@ static void append_enum_option( std::shared_ptr optgroup, wxGetApp().sidebar().get_searcher().add_key(opt_key, Preset::TYPE_PREFERENCES, optgroup->config_category(), L("Preferences")); } -static void append_string_option(std::shared_ptr optgroup, - const std::string& opt_key, - const std::string& label, - const std::string& tooltip, - const std::string& def_val, - ConfigOptionMode mode = comSimple) -{ - ConfigOptionDef def = { opt_key, coString }; - def.label = label; - def.tooltip = tooltip; - def.mode = mode; - def.set_default_value(new ConfigOptionString{ def_val }); - Option option(def, opt_key); - optgroup->append_single_option_line(option); - - // fill data to the Search Dialog - wxGetApp().sidebar().get_searcher().add_key(opt_key, Preset::TYPE_PREFERENCES, optgroup->config_category(), L("Preferences")); -} - static void append_preferences_option_to_searcher(std::shared_ptr optgroup, const std::string& opt_key, const wxString& label) From 7e51f85394bb14ae5a0ffca0c8a7519224de0d70 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 8 Mar 2023 11:17:07 +0100 Subject: [PATCH 6/6] MeasurementTool: Deleted unnecessary localization markers Related to #9768,point 4 --- src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp index 2c1b2cf766..80520651da 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp @@ -1937,19 +1937,19 @@ void GLGizmoMeasure::on_render_input_window(float x, float y, float bottom_limit ); if (m_mode == EMode::FeatureSelection && m_hover_id != -1) { - add_strings_row_to_table(*m_imgui, _u8L("Shift"), ImGuiWrapper::COL_ORANGE_LIGHT, _u8L("Enable point selection"), ImGui::GetStyleColorVec4(ImGuiCol_Text)); + add_strings_row_to_table(*m_imgui, "Shift", ImGuiWrapper::COL_ORANGE_LIGHT, _u8L("Enable point selection"), ImGui::GetStyleColorVec4(ImGuiCol_Text)); ++row_count; } if (m_selected_features.first.feature.has_value()) { - add_strings_row_to_table(*m_imgui, _u8L("Delete"), ImGuiWrapper::COL_ORANGE_LIGHT, _u8L("Restart selection"), ImGui::GetStyleColorVec4(ImGuiCol_Text)); + add_strings_row_to_table(*m_imgui, "Delete", ImGuiWrapper::COL_ORANGE_LIGHT, _u8L("Restart selection"), ImGui::GetStyleColorVec4(ImGuiCol_Text)); ++row_count; } if (m_selected_features.first.feature.has_value() || m_selected_features.second.feature.has_value()) { add_row_to_table( [this]() { - m_imgui->text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, _u8L("Esc")); + m_imgui->text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Esc"); }, [this]() { m_imgui->text_colored(ImGui::GetStyleColorVec4(ImGuiCol_Text), _u8L("Unselect"));