From 241d097d2ecaec3f33b1d4c2091ca52de9f86b63 Mon Sep 17 00:00:00 2001 From: yw4z Date: Mon, 5 May 2025 13:53:46 +0300 Subject: [PATCH 1/9] Match style of checkboxes on Material Settings > Setting Overrides (#9551) init --- src/slic3r/GUI/Tab.cpp | 7 ++----- src/slic3r/GUI/Tab.hpp | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 6f0119ce65..f27447f999 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3167,11 +3167,8 @@ void TabFilament::add_filament_overrides_page() line = optgroup->create_single_option_line(optgroup->get_option(opt_key)); line.near_label_widget = [this, optgroup_wk = ConfigOptionsGroupWkp(optgroup), opt_key, opt_index](wxWindow* parent) { - wxCheckBox* check_box = new wxCheckBox(parent, wxID_ANY, ""); - - check_box->Bind( - wxEVT_CHECKBOX, - [this, optgroup_wk, opt_key, opt_index](wxCommandEvent& evt) { + auto check_box = new ::CheckBox(parent); // ORCA modernize checkboxes + check_box->Bind(wxEVT_TOGGLEBUTTON, [this, optgroup_wk, opt_key, opt_index](wxCommandEvent& evt) { const bool is_checked = evt.IsChecked(); if (auto optgroup_sh = optgroup_wk.lock(); optgroup_sh) { if (Field *field = optgroup_sh->get_fieldc(opt_key, opt_index); field != nullptr) { diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index 5f5081fe54..9161740239 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -40,6 +40,7 @@ #include "ParamsPanel.hpp" #include "Widgets/RoundedRectangle.hpp" #include "Widgets/TextInput.hpp" +#include "Widgets/CheckBox.hpp" // ORCA class TabCtrl; @@ -557,7 +558,7 @@ private: void update_filament_overrides_page(const DynamicPrintConfig* printers_config); void update_volumetric_flow_preset_hints(); - std::map m_overrides_options; + std::map m_overrides_options; public: //BBS: GUI refactor From 13225c817a0c2eed430203995d222b156bc3deb8 Mon Sep 17 00:00:00 2001 From: yw4z Date: Wed, 7 May 2025 18:33:33 +0300 Subject: [PATCH 2/9] Increase size of layer mode button on preview tab (#9554) * Update IMSlider.cpp * fix slider positions --- src/slic3r/GUI/IMSlider.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/IMSlider.cpp b/src/slic3r/GUI/IMSlider.cpp index 7d594335b5..dff76b2abe 100644 --- a/src/slic3r/GUI/IMSlider.cpp +++ b/src/slic3r/GUI/IMSlider.cpp @@ -21,7 +21,7 @@ static const float HORIZONTAL_SLIDER_WINDOW_HEIGHT = 64.0f; static const float VERTICAL_SLIDER_WINDOW_WIDTH = 160.0f; static const float GROOVE_WIDTH = 12.0f; static const ImVec2 ONE_LAYER_MARGIN = ImVec2(20.0f, 20.0f); -static const ImVec2 ONE_LAYER_BUTTON_SIZE = ImVec2(28.0f, 28.0f); +static const ImVec2 ONE_LAYER_BUTTON_SIZE = ImVec2(56.0f, 56.0f); static const ImU32 BACKGROUND_COLOR_DARK = IM_COL32(65, 65, 71, 255); static const ImU32 BACKGROUND_COLOR_LIGHT = IM_COL32(255, 255, 255, 255); @@ -145,14 +145,14 @@ bool IMSlider::init_texture() bool result = true; if (!is_horizontal()) { // BBS init image texture id - result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_on.svg", 24, 24, m_one_layer_on_id); - result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_on_hover.svg", 28, 28, m_one_layer_on_hover_id); - result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_off.svg", 28, 28, m_one_layer_off_id); - result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_off_hover.svg", 28, 28, m_one_layer_off_hover_id); - result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_on_dark.svg", 24, 24, m_one_layer_on_dark_id); - result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_on_hover_dark.svg", 28, 28, m_one_layer_on_hover_dark_id); - result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_off_dark.svg", 28, 28, m_one_layer_off_dark_id); - result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_off_hover_dark.svg", 28, 28, m_one_layer_off_hover_dark_id); + result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_on.svg", 56, 56, m_one_layer_on_id); + result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_on_hover.svg", 56, 56, m_one_layer_on_hover_id); + result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_off.svg", 56, 56, m_one_layer_off_id); + result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_off_hover.svg", 56, 56, m_one_layer_off_hover_id); + result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_on_dark.svg", 56, 56, m_one_layer_on_dark_id); + result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_on_hover_dark.svg", 56, 56, m_one_layer_on_hover_dark_id); + result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_off_dark.svg", 56, 56, m_one_layer_off_dark_id); + result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_off_hover_dark.svg", 56, 56, m_one_layer_off_hover_dark_id); result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/im_gcode_pause.svg", 14, 14, m_pause_icon_id); result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/im_gcode_custom.svg", 14, 14, m_custom_icon_id); result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/im_slider_delete.svg", 14, 14, m_delete_icon_id); @@ -492,7 +492,7 @@ bool IMSlider::horizontal_slider(const char* str_id, int* value, int v_min, int const ImU32 handle_border_clr = m_is_dark ? BACKGROUND_COLOR_DARK : BACKGROUND_COLOR_LIGHT; // calculate groove size - const ImVec2 groove_start = ImVec2(pos.x + handle_dummy_width, pos.y + size.y - ONE_LAYER_MARGIN.y * m_scale - ONE_LAYER_BUTTON_SIZE.y * m_scale * 0.5f - GROOVE_WIDTH * m_scale * 0.5f); + const ImVec2 groove_start = ImVec2(pos.x + handle_dummy_width, pos.y + size.y - ONE_LAYER_MARGIN.y * m_scale - (ONE_LAYER_BUTTON_SIZE.y / 2) * m_scale * 0.5f - GROOVE_WIDTH * m_scale * 0.5f); const ImVec2 groove_size = ImVec2(size.x - 2 * handle_dummy_width - text_right_dummy, GROOVE_WIDTH * m_scale); const ImRect groove = ImRect(groove_start, groove_start + groove_size); const ImRect bg_rect = ImRect(groove.Min - ImVec2(6.0f, 6.0f) * m_scale, groove.Max + ImVec2(6.0f, 6.0f) * m_scale); @@ -872,7 +872,7 @@ bool IMSlider::vertical_slider(const char* str_id, int* higher_value, int* lower const ImU32 handle_clr = BRAND_COLOR; const ImU32 handle_border_clr = m_is_dark ? BACKGROUND_COLOR_DARK : BACKGROUND_COLOR_LIGHT; // calculate slider groove size - const ImVec2 groove_start = ImVec2(pos.x + size.x - ONE_LAYER_MARGIN.x * m_scale - ONE_LAYER_BUTTON_SIZE.x * m_scale * 0.5f - GROOVE_WIDTH * m_scale * 0.5f, pos.y + text_dummy_height); + const ImVec2 groove_start = ImVec2(pos.x + size.x - ONE_LAYER_MARGIN.x * m_scale - (ONE_LAYER_BUTTON_SIZE.x / 2) * m_scale * 0.5f - GROOVE_WIDTH * m_scale * 0.5f, pos.y + text_dummy_height); const ImVec2 groove_size = ImVec2(GROOVE_WIDTH * m_scale, size.y - 2 * text_dummy_height); const ImRect groove = ImRect(groove_start, groove_start + groove_size); const ImRect bg_rect = ImRect(groove.Min - ImVec2(6.0f, 6.0f) * m_scale, groove.Max + ImVec2(6.0f, 6.0f) * m_scale); From 92b31a6435634e19392820315eba3391d8c59654 Mon Sep 17 00:00:00 2001 From: yw4z Date: Thu, 8 May 2025 07:33:57 +0300 Subject: [PATCH 3/9] Improve quality of bed name / number texture (#9535) * init * update * update * update * update * update * Update PartPlate.cpp --- resources/images/plate_name_edit.svg | 2 +- resources/images/plate_name_edit_dark.svg | 2 +- resources/images/plate_name_edit_hover.svg | 2 +- .../images/plate_name_edit_hover_dark.svg | 2 +- src/slic3r/GUI/PartPlate.cpp | 70 ++++++++++++------- 5 files changed, 47 insertions(+), 31 deletions(-) diff --git a/resources/images/plate_name_edit.svg b/resources/images/plate_name_edit.svg index 54a607d222..c7ecc2f1af 100644 --- a/resources/images/plate_name_edit.svg +++ b/resources/images/plate_name_edit.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/resources/images/plate_name_edit_dark.svg b/resources/images/plate_name_edit_dark.svg index 729cb18431..5207d63a86 100644 --- a/resources/images/plate_name_edit_dark.svg +++ b/resources/images/plate_name_edit_dark.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/resources/images/plate_name_edit_hover.svg b/resources/images/plate_name_edit_hover.svg index 66befdaebd..eb8dd62d4a 100644 --- a/resources/images/plate_name_edit_hover.svg +++ b/resources/images/plate_name_edit_hover.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/resources/images/plate_name_edit_hover_dark.svg b/resources/images/plate_name_edit_hover_dark.svg index 0382c829ff..c6d417a258 100644 --- a/resources/images/plate_name_edit_hover_dark.svg +++ b/resources/images/plate_name_edit_hover_dark.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index fc9b851893..0c79b38e38 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -53,7 +53,7 @@ static unsigned int GLOBAL_PLATE_INDEX = 0; static const double LOGICAL_PART_PLATE_GAP = 1. / 5.; static const int PARTPLATE_ICON_SIZE = 16; -static const int PARTPLATE_EDIT_PLATE_NAME_ICON_SIZE = 12; +static const int PARTPLATE_EDIT_PLATE_NAME_ICON_SIZE = 9; // ORCA this also scales height of plate name static const int PARTPLATE_ICON_GAP_TOP = 3; static const int PARTPLATE_ICON_GAP_LEFT = 3; static const int PARTPLATE_ICON_GAP_Y = 5; @@ -570,21 +570,25 @@ void PartPlate::calc_vertex_for_plate_name_edit_icon(GLTexture *texture, int ind ExPolygon poly; auto bed_ext = get_extents(m_shape); Vec2d p = bed_ext[3]; - auto factor = bed_ext.size()(1) / 200.0; - float width = 0.f; - float height = PARTPLATE_EDIT_PLATE_NAME_ICON_SIZE * factor; - float offset_x = 1 * factor; - float offset_y = PARTPLATE_TEXT_OFFSET_Y * factor; + float factor = bed_ext.size()(1) / 200.0; + float icon_sz = factor * PARTPLATE_EDIT_PLATE_NAME_ICON_SIZE; + float width = icon_sz; + float height = icon_sz; + float offset_y = factor * PARTPLATE_TEXT_OFFSET_Y; + float name_width; if (texture && texture->get_width() > 0 && texture->get_height()) - width = int(factor * (texture->get_original_width() * 16) / texture->get_height()); + // original width give correct ratio in here since rendering width can be much higher because of next_highest_power_of_2 for rendering + name_width = icon_sz * texture->m_original_width / texture->get_height(); - p += Vec2d(width + offset_x, offset_y + height); + //if (m_plater && m_plater->get_build_volume_type() == BuildVolume_Type::Circle) + // px = scale_(bed_ext.center()(0)) + m_name_texture_width * 0.50 - height * 0.50; + p += Vec2d(name_width, offset_y); - poly.contour.append({ scale_(p(0)) , scale_(p(1) - height) }); - poly.contour.append({ scale_(p(0) + height), scale_(p(1) - height) }); - poly.contour.append({ scale_(p(0) + height), scale_(p(1)) }); - poly.contour.append({ scale_(p(0)) , scale_(p(1)) }); + poly.contour.append({ scale_(p(0) ), scale_(p(1) ) }); + poly.contour.append({ scale_(p(0) + width), scale_(p(1) ) }); + poly.contour.append({ scale_(p(0) + width), scale_(p(1) + height) }); + poly.contour.append({ scale_(p(0) ), scale_(p(1) + height) }); if (!init_model_from_poly(model.model, poly, GROUND_Z)) BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Unable to generate geometry buffers for icons\n"; @@ -1869,25 +1873,34 @@ void PartPlate::generate_plate_name_texture() // generate m_name_texture texture from m_name with generate_from_text_string m_name_texture.reset(); auto text = m_name.empty()? _L("Untitled") : from_u8(m_name); - wxCoord w, h; - auto* font = &Label::Head_32; + // ORCA also scale font size to prevent low res texture + int size = wxGetApp().em_unit() * PARTPLATE_EDIT_PLATE_NAME_ICON_SIZE; + auto l = Label::sysFont(size, true); + wxFont* font = &l; wxColour foreground(0xf2, 0x75, 0x4e, 0xff); if (!m_name_texture.generate_from_text_string(text.ToUTF8().data(), *font, *wxBLACK, foreground)) BOOST_LOG_TRIVIAL(error) << "PartPlate::generate_plate_name_texture(): generate_from_text_string() failed"; - auto bed_ext = get_extents(m_shape); - auto factor = bed_ext.size()(1) / 200.0; - ExPolygon poly; - float offset_x = 1 * factor; - float offset_y = PARTPLATE_TEXT_OFFSET_Y * factor; - w = int(factor * (m_name_texture.get_width() * 16) / m_name_texture.get_height()); - h = int(factor * 16); - Vec2d p = bed_ext[3] + Vec2d(0, 1 + h * m_name_texture.m_original_height / m_name_texture.get_height()); - poly.contour.append({ scale_(p(0) + offset_x) , scale_(p(1) - h + offset_y) }); - poly.contour.append({ scale_(p(0) + w - offset_x), scale_(p(1) - h + offset_y) }); - poly.contour.append({ scale_(p(0) + w - offset_x), scale_(p(1) - offset_y) }); - poly.contour.append({ scale_(p(0) + offset_x) , scale_(p(1) - offset_y) }); + + ExPolygon poly; + auto bed_ext = get_extents(m_shape); + Vec2d p = bed_ext[3]; + float factor = bed_ext.size()(1) / 200.0; + float icon_sz = factor * PARTPLATE_EDIT_PLATE_NAME_ICON_SIZE; + float width = icon_sz * m_name_texture.get_width() / m_name_texture.get_height(); // icon size * text_bb_ratio + float height = icon_sz; // scale with icon size to preserve ratio while system scaling + float offset_y = factor * PARTPLATE_TEXT_OFFSET_Y; + + //if (m_plater && m_plater->get_build_volume_type() == BuildVolume_Type::Circle) + // px = scale_(bed_ext.center()(0)) - (width + height) / 2.00; + + p += Vec2d(0, offset_y); + + poly.contour.append({ scale_(p(0) ), scale_(p(1) ) }); + poly.contour.append({ scale_(p(0) + width), scale_(p(1) ) }); + poly.contour.append({ scale_(p(0) + width), scale_(p(1) + height) }); + poly.contour.append({ scale_(p(0) ), scale_(p(1) + height) }); if (!init_model_from_poly(m_plate_name_icon, poly, GROUND_Z)) BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Unable to generate geometry buffers for icons\n"; @@ -3367,7 +3380,10 @@ void PartPlateList::generate_icon_textures() } std::string text_str = "01"; - wxFont* font = find_font(text_str,32); + // ORCA also scale font size to prevent low res texture + int size = wxGetApp().em_unit() * PARTPLATE_ICON_SIZE; + auto l = Label::sysFont(int(size), true); + wxFont* font = &l; for (int i = 0; i < MAX_PLATE_COUNT; i++) { if (m_idx_textures[i].get_id() == 0) { From f0384e7bc37e6eb0818046ec07eee7966f6e96f2 Mon Sep 17 00:00:00 2001 From: yw4z Date: Thu, 8 May 2025 11:00:48 +0300 Subject: [PATCH 4/9] Color & shape improvements for Axes (#9495) init --- src/imguizmo/ImGuizmo.cpp | 8 +-- src/libslic3r/Color.hpp | 12 ++--- src/slic3r/GUI/2DBed.cpp | 24 ++++----- src/slic3r/GUI/3DBed.cpp | 5 +- src/slic3r/GUI/3DBed.hpp | 2 +- src/slic3r/GUI/GLCanvas3D.cpp | 6 +-- src/slic3r/GUI/Gizmos/GLGizmoBase.cpp | 28 +++++----- src/slic3r/GUI/Gizmos/GLGizmoCut.cpp | 16 +++--- .../GUI/Gizmos/GizmoObjectManipulation.cpp | 51 +++++++++---------- 9 files changed, 77 insertions(+), 75 deletions(-) diff --git a/src/imguizmo/ImGuizmo.cpp b/src/imguizmo/ImGuizmo.cpp index c8e2ddb183..64f30ff73a 100644 --- a/src/imguizmo/ImGuizmo.cpp +++ b/src/imguizmo/ImGuizmo.cpp @@ -3029,11 +3029,12 @@ namespace IMGUIZMO_NAMESPACE ImVec4 directionColorV = gContext.mStyle.Colors[DIRECTION_X + i]; if (!visible) { - directionColorV.w *= 0.3f; + directionColorV.w *= 0.35f; } - ImU32 directionColor = ImGui::ColorConvertFloat4ToU32(directionColorV) | IM_COL32(0x80, 0x80, 0x80, 0x00); + ImU32 directionColor = ImGui::ColorConvertFloat4ToU32(directionColorV); // | IM_COL32(0x80, 0x80, 0x80, 0x00); drawList->AddLine(baseSSpace, worldDirSSpace, directionColor, gContext.mStyle.TranslationLineThickness); + /* ORCA Dont draw arrow heads // Arrow head begin ImVec2 dir(baseSSpace - worldDirSSpace); @@ -3045,9 +3046,10 @@ namespace IMGUIZMO_NAMESPACE ImVec2 a(worldDirSSpace + dir); drawList->AddTriangleFilled(worldDirSSpace - dir, a + ortogonalDir, a - ortogonalDir, directionColor); // Arrow head end + */ // Axis text - ImVec2 labelSSpace = worldToPos(origin + dirAxis * 1.3f, res, position, size); + ImVec2 labelSSpace = worldToPos(origin + dirAxis * 1.2f, res, position, size); ImVec2 labelSize = ImGui::CalcTextSize(gContext.mStyle.AxisLabels[i]); drawList->AddText(labelSSpace - labelSize * 0.5, directionColor, gContext.mStyle.AxisLabels[i]); } diff --git a/src/libslic3r/Color.hpp b/src/libslic3r/Color.hpp index c3c0d49e84..cd1e82d794 100644 --- a/src/libslic3r/Color.hpp +++ b/src/libslic3r/Color.hpp @@ -69,9 +69,9 @@ public: static const ColorRGB ORCA() { return {0.0f, 150.f / 255.0f, 136.0f / 255}; } static const ColorRGB WARNING() { return {241.0f / 255, 117.f / 255.0f, 78.0f / 255}; } - static const ColorRGB X() { return { 0.75f, 0.0f, 0.0f }; } - static const ColorRGB Y() { return { 0.0f, 0.75f, 0.0f }; } - static const ColorRGB Z() { return { 0.0f, 0.0f, 0.75f }; } + static const ColorRGB X() { return { 255 / 255.f, 60 / 255.f, 91 / 255.f};} + static const ColorRGB Y() { return { 100 / 255.f, 200 / 255.f, 24 / 255.f};} + static const ColorRGB Z() { return { 47 / 255.f, 136 / 255.f, 233 / 255.f};} }; class ColorRGBA @@ -140,9 +140,9 @@ public: static const ColorRGBA WHITE() { return { 1.0f, 1.0f, 1.0f, 1.0f }; } static const ColorRGBA ORCA() { return {0.0f, 150.f / 255.0f, 136.0f / 255, 1.0f}; } - static const ColorRGBA X() { return { 0.75f, 0.0f, 0.0f, 1.0f }; } - static const ColorRGBA Y() { return { 0.0f, 0.75f, 0.0f, 1.0f }; } - static const ColorRGBA Z() { return { 0.0f, 0.0f, 0.75f, 1.0f }; } + static const ColorRGBA X() { return { ColorRGB::X().r(), ColorRGB::X().g(), ColorRGB::X().b(), 1.f };} + static const ColorRGBA Y() { return { ColorRGB::Y().r(), ColorRGB::Y().g(), ColorRGB::Y().b(), 1.f };} + static const ColorRGBA Z() { return { ColorRGB::Z().r(), ColorRGB::Z().g(), ColorRGB::Z().b(), 1.f };} }; ColorRGB operator * (float value, const ColorRGB& other); diff --git a/src/slic3r/GUI/2DBed.cpp b/src/slic3r/GUI/2DBed.cpp index ad7fdb8049..1e9f316c56 100644 --- a/src/slic3r/GUI/2DBed.cpp +++ b/src/slic3r/GUI/2DBed.cpp @@ -189,25 +189,25 @@ void Bed_2D::repaint(const std::vector& shape) auto axes_len = 5 * wxGetApp().em_unit(); // scale axis auto arrow_len = 6; auto arrow_angle = Geometry::deg2rad(45.0); - dc.SetPen(wxPen(wxColour(255, 0, 0), 2, wxPENSTYLE_SOLID)); // red + dc.SetPen(wxPen(wxColour(encode_color(ColorRGB::X())), 2, wxPENSTYLE_SOLID)); // red // ORCA match axis colors auto x_end = Vec2d(origin_px(0) + axes_len, origin_px(1)); dc.DrawLine(wxPoint(origin_px(0), origin_px(1)), wxPoint(x_end(0), x_end(1))); - for (auto angle : { -arrow_angle, arrow_angle }) { - Vec2d end = Eigen::Translation2d(x_end) * Eigen::Rotation2Dd(angle) * Eigen::Translation2d(- x_end) * Eigen::Vector2d(x_end(0) - arrow_len, x_end(1)); - dc.DrawLine(wxPoint(x_end(0), x_end(1)), wxPoint(end(0), end(1))); - } + //for (auto angle : { -arrow_angle, arrow_angle }) { // ORCA dont draw arrows + // Vec2d end = Eigen::Translation2d(x_end) * Eigen::Rotation2Dd(angle) * Eigen::Translation2d(- x_end) * Eigen::Vector2d(x_end(0) - arrow_len, x_end(1)); + // dc.DrawLine(wxPoint(x_end(0), x_end(1)), wxPoint(end(0), end(1))); + //} - dc.SetPen(wxPen(wxColour(0, 255, 0), 2, wxPENSTYLE_SOLID)); // green + dc.SetPen(wxPen(wxColour(encode_color(ColorRGB::Y())), 2, wxPENSTYLE_SOLID)); // green // ORCA match axis colors auto y_end = Vec2d(origin_px(0), origin_px(1) - axes_len); dc.DrawLine(wxPoint(origin_px(0), origin_px(1)), wxPoint(y_end(0), y_end(1))); - for (auto angle : { -arrow_angle, arrow_angle }) { - Vec2d end = Eigen::Translation2d(y_end) * Eigen::Rotation2Dd(angle) * Eigen::Translation2d(- y_end) * Eigen::Vector2d(y_end(0), y_end(1) + arrow_len); - dc.DrawLine(wxPoint(y_end(0), y_end(1)), wxPoint(end(0), end(1))); - } + //for (auto angle : { -arrow_angle, arrow_angle }) { // ORCA dont draw arrows + // Vec2d end = Eigen::Translation2d(y_end) * Eigen::Rotation2Dd(angle) * Eigen::Translation2d(- y_end) * Eigen::Vector2d(y_end(0), y_end(1) + arrow_len); + // dc.DrawLine(wxPoint(y_end(0), y_end(1)), wxPoint(end(0), end(1))); + //} // draw origin - dc.SetPen(wxPen(wxColour(0, 0, 0), 1, wxPENSTYLE_SOLID)); - dc.SetBrush(wxBrush(wxColour(0, 0, 0), wxBRUSHSTYLE_SOLID)); + dc.SetPen(wxPen(wxColour(encode_color(ColorRGB::Z())), 1, wxPENSTYLE_SOLID)); // ORCA match axis colors + dc.SetBrush(wxBrush(wxColour(encode_color(ColorRGB::Z())), wxBRUSHSTYLE_SOLID)); // ORCA match axis colors dc.DrawCircle(origin_px(0), origin_px(1), 3); static const auto origin_label = wxString("(0,0)"); diff --git a/src/slic3r/GUI/3DBed.cpp b/src/slic3r/GUI/3DBed.cpp index 5686375098..e462dc6534 100644 --- a/src/slic3r/GUI/3DBed.cpp +++ b/src/slic3r/GUI/3DBed.cpp @@ -218,9 +218,10 @@ void Bed3D::Axes::render() }; if (!m_arrow.is_initialized()) - m_arrow.init_from(stilized_arrow(16, DefaultTipRadius, DefaultTipLength, DefaultStemRadius, m_stem_length)); + //m_arrow.init_from(stilized_arrow(16, DefaultTipRadius, DefaultTipLength, DefaultStemRadius, m_stem_length)); + m_arrow.init_from(smooth_cylinder(16, /*Radius*/ m_stem_length / 75.f, m_stem_length)); // ORCA use simple cylinder and scale thickness depends on length - GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light"); + GLShaderProgram* shader = wxGetApp().get_shader("flat"); // ORCA dont use shading to get closer color tone if (shader == nullptr) return; diff --git a/src/slic3r/GUI/3DBed.hpp b/src/slic3r/GUI/3DBed.hpp index c138e8c8dc..fc4560ae72 100644 --- a/src/slic3r/GUI/3DBed.hpp +++ b/src/slic3r/GUI/3DBed.hpp @@ -80,7 +80,7 @@ public: m_stem_length = length; m_arrow.reset(); } - float get_total_length() const { return m_stem_length + DefaultTipLength; } + float get_total_length() const { return m_stem_length; } // + DefaultTipLength; } // ORCA axis without arrow void render(); }; diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 1955298e65..7de6926d3c 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -5767,9 +5767,9 @@ void GLCanvas3D::_render_3d_navigator() style.Colors[ImGuizmo::COLOR::DIRECTION_Z] = ImGuiWrapper::to_ImVec4(ColorRGBA::X()); style.Colors[ImGuizmo::COLOR::TEXT] = m_is_dark ? ImVec4(224 / 255.f, 224 / 255.f, 224 / 255.f, 1.f) : ImVec4(.2f, .2f, .2f, 1.0f); style.Colors[ImGuizmo::COLOR::FACE] = m_is_dark ? ImVec4(0.23f, 0.23f, 0.23f, 1.f) : ImVec4(0.77f, 0.77f, 0.77f, 1); - strcpy(style.AxisLabels[ImGuizmo::Axis::Axis_X], "y"); - strcpy(style.AxisLabels[ImGuizmo::Axis::Axis_Y], "z"); - strcpy(style.AxisLabels[ImGuizmo::Axis::Axis_Z], "x"); + strcpy(style.AxisLabels[ImGuizmo::Axis::Axis_X], "Y"); // ORCA use uppercase to match text on tranform widgets + strcpy(style.AxisLabels[ImGuizmo::Axis::Axis_Y], "Z"); // ORCA use uppercase to match text on tranform widgets + strcpy(style.AxisLabels[ImGuizmo::Axis::Axis_Z], "X"); // ORCA use uppercase to match text on tranform widgets strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_FRONT], _utf8("Front").c_str()); strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_BACK], _utf8("Back").c_str()); strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_TOP], _utf8("Top").c_str()); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp index 0b68e64150..1031110fa8 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp @@ -26,16 +26,16 @@ ColorRGBA GLGizmoBase::DEFAULT_BASE_COLOR = { 0.625f, 0.625f, 0.625f, 1.0f }; ColorRGBA GLGizmoBase::DEFAULT_DRAG_COLOR = { 1.0f, 1.0f, 1.0f, 1.0f }; ColorRGBA GLGizmoBase::DEFAULT_HIGHLIGHT_COLOR = {1.0f, 0.38f, 0.0f, 1.0f}; std::array GLGizmoBase::AXES_HOVER_COLOR = {{ - { 0.7f, 0.0f, 0.0f, 1.0f }, - { 0.0f, 0.7f, 0.0f, 1.0f }, - { 0.0f, 0.0f, 0.7f, 1.0f } - }}; + {ColorRGBA::X().r() * 1.2f, ColorRGBA::X().g() * 1.4f, ColorRGBA::X().b() * 1.4f, 1.0f}, + {ColorRGBA::Y().r() * 1.2f, ColorRGBA::Y().g() * 1.2f, ColorRGBA::Y().b() * 1.2f, 1.0f}, + {ColorRGBA::Z().r() * 1.2f, ColorRGBA::Z().g() * 1.2f, ColorRGBA::Z().b() * 1.2f, 1.0f}, +}}; std::array GLGizmoBase::AXES_COLOR = {{ - { 1.0, 0.0f, 0.0f, 1.0f }, - { 0.0f, 1.0f, 0.0f, 1.0f }, - { 0.0f, 0.0f, 1.0f, 1.0f } - }}; + ColorRGBA::X(), + ColorRGBA::Y(), + ColorRGBA::Z() +}}; ColorRGBA GLGizmoBase::CONSTRAINED_COLOR = {0.5f, 0.5f, 0.5f, 1.0f}; ColorRGBA GLGizmoBase::FLATTEN_COLOR = {0.96f, 0.93f, 0.93f, 0.5f}; @@ -257,37 +257,37 @@ void GLGizmoBase::render_cross_mark(const Vec3f &target, bool is_single) render_line( {target(0) - half_length, target(1), target(2)}, {target(0) + half_length, target(1), target(2)}, - ColorRGBA::RED()); + ColorRGBA::X()); // ORCA match axis colors } else { render_line( {target(0), target(1), target(2)}, {target(0) + half_length, target(1), target(2)}, - ColorRGBA::RED()); + ColorRGBA::X()); // ORCA match axis colors } // draw line for y axis if (!is_single) { render_line( {target(0), target(1) - half_length, target(2)}, {target(0), target(1) + half_length, target(2)}, - ColorRGBA::GREEN()); + ColorRGBA::Y()); // ORCA match axis colors } else { render_line( {target(0), target(1), target(2)}, {target(0), target(1) + half_length, target(2)}, - ColorRGBA::GREEN()); + ColorRGBA::Y()); // ORCA match axis colors } // draw line for z axis if (!is_single) { render_line( {target(0), target(1), target(2) - half_length}, {target(0), target(1), target(2) + half_length}, - ColorRGBA::BLUE()); + ColorRGBA::Z()); // ORCA match axis colors } else { render_line( {target(0), target(1), target(2)}, {target(0), target(1), target(2) + half_length}, - ColorRGBA::BLUE()); + ColorRGBA::Z()); // ORCA match axis colors } } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index 53e1ab1cad..8af9eda3c0 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -1046,8 +1046,8 @@ void GLGizmoCut3D::render_cut_plane_grabbers() // render sphere grabber size = m_dragging ? get_dragging_half_size(mean_size) : get_half_size(mean_size); - color = m_hover_id == Y ? complementary(ColorRGBA::GREEN()) : - m_hover_id == X ? complementary(ColorRGBA::RED()) : + color = m_hover_id == Y ? ColorRGBA::Y() : // ORCA match axis colors + m_hover_id == X ? ColorRGBA::X() : // ORCA match axis colors m_hover_id == Z ? GRABBER_COLOR : ColorRGBA::GRAY(); render_model(m_sphere.model, color, view_matrix * translation_transform(m_grabber_connection_len * Vec3d::UnitZ()) * scale_transform(size)); } @@ -1060,7 +1060,8 @@ void GLGizmoCut3D::render_cut_plane_grabbers() { size = m_dragging && m_hover_id == X ? get_dragging_half_size(mean_size) : get_half_size(mean_size); const Vec3d cone_scale = Vec3d(0.75 * size, 0.75 * size, 1.8 * size); - color = m_hover_id == X ? complementary(ColorRGBA::RED()) : ColorRGBA::RED(); + //color = m_hover_id == X ? complementary(ColorRGBA::X()) : ColorRGBA::X(); + color = ColorRGBA::X(); // ORCA match axis colors if (m_hover_id == X) { render_grabber_connection(color, view_matrix); @@ -1079,7 +1080,8 @@ void GLGizmoCut3D::render_cut_plane_grabbers() { size = m_dragging && m_hover_id == Y ? get_dragging_half_size(mean_size) : get_half_size(mean_size); const Vec3d cone_scale = Vec3d(0.75 * size, 0.75 * size, 1.8 * size); - color = m_hover_id == Y ? complementary(ColorRGBA::GREEN()) : ColorRGBA::GREEN(); + //color = m_hover_id == Y ? complementary(ColorRGBA::Y()) : ColorRGBA::Y(); + color = ColorRGBA::Y(); // ORCA match axis colors if (m_hover_id == Y) { render_grabber_connection(color, view_matrix); @@ -1099,7 +1101,7 @@ void GLGizmoCut3D::render_cut_plane_grabbers() if (no_xy_grabber_hovered || m_hover_id == CutPlaneZRotation) { size = 0.75 * (m_dragging ? get_dragging_half_size(mean_size) : get_half_size(mean_size)); - color = ColorRGBA::BLUE(); + color = ColorRGBA::Z(); // ORCA match axis colors const ColorRGBA cp_color = m_hover_id == CutPlaneZRotation ? color : m_plane.model.get_color(); const double grabber_shift = -1.75 * m_grabber_connection_len; @@ -1126,7 +1128,7 @@ void GLGizmoCut3D::render_cut_plane_grabbers() if (no_xy_grabber_hovered || m_hover_id == CutPlaneXMove) { size = (m_dragging ? get_dragging_half_size(mean_size) : get_half_size(mean_size)); - color = m_hover_id == CutPlaneXMove ? ColorRGBA::RED() : m_plane.model.get_color(); + color = m_hover_id == CutPlaneXMove ? ColorRGBA::X() : m_plane.model.get_color(); // ORCA match axis colors render_grabber_connection(GRABBER_COLOR, view_matrix * rotation_transform(0.5 * PI * Vec3d::UnitY()), 0.75); @@ -1144,7 +1146,7 @@ void GLGizmoCut3D::render_cut_plane_grabbers() if (m_groove.angle > 0.0f && (no_xy_grabber_hovered || m_hover_id == CutPlaneYMove)) { size = (m_dragging ? get_dragging_half_size(mean_size) : get_half_size(mean_size)); - color = m_hover_id == CutPlaneYMove ? ColorRGBA::GREEN() : m_plane.model.get_color(); + color = m_hover_id == CutPlaneYMove ? ColorRGBA::Y() : m_plane.model.get_color(); // ORCA match axis colors render_grabber_connection(GRABBER_COLOR, view_matrix * rotation_transform(-0.5 * PI * Vec3d::UnitX()), 0.75); diff --git a/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp b/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp index be2448e987..cf4e68042f 100644 --- a/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp +++ b/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp @@ -874,15 +874,14 @@ void GizmoObjectManipulation::do_render_move_window(ImGuiWrapper *imgui_wrapper, } ImGuiWrapper::pop_combo_style(); caption_max = combox_content_size - 4 * space_size; - ImGui::SameLine(caption_max + index * space_size); - ImGui::PushItemWidth(unit_size); - ImGui::TextAlignCenter("X"); - ImGui::SameLine(caption_max + unit_size + (++index) * space_size); - ImGui::PushItemWidth(unit_size); - ImGui::TextAlignCenter("Y"); - ImGui::SameLine(caption_max + (++index_unit) * unit_size + (++index) * space_size); - ImGui::PushItemWidth(unit_size); - ImGui::TextAlignCenter("Z"); + // ORCA use TextColored to match axes color + float offset_to_center = (unit_size - ImGui::CalcTextSize("O").x) / 2; + ImGui::SameLine(caption_max + index * space_size + offset_to_center); + ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::X()),"X"); + ImGui::SameLine(caption_max + unit_size + (++index) * space_size + offset_to_center); + ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::Y()),"Y"); + ImGui::SameLine(caption_max + (++index_unit) * unit_size + (++index) * space_size + offset_to_center); + ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::Z()),"Z"); index = 1; index_unit = 1; @@ -1003,15 +1002,14 @@ void GizmoObjectManipulation::do_render_rotate_window(ImGuiWrapper *imgui_wrappe unsigned int current_active_id = ImGui::GetActiveID(); ImGui::PushItemWidth(caption_max); imgui_wrapper->text(_L("World coordinates")); - ImGui::SameLine(caption_max + index * space_size); - ImGui::PushItemWidth(unit_size); - ImGui::TextAlignCenter("X"); - ImGui::SameLine(caption_max + unit_size + (++index) * space_size); - ImGui::PushItemWidth(unit_size); - ImGui::TextAlignCenter("Y"); - ImGui::SameLine(caption_max + (++index_unit) * unit_size + (++index) * space_size); - ImGui::PushItemWidth(unit_size); - ImGui::TextAlignCenter("Z"); + // ORCA use TextColored to match axes color + float offset_to_center = (unit_size - ImGui::CalcTextSize("O").x) / 2; + ImGui::SameLine(caption_max + index * space_size + offset_to_center); + ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::X()),"X"); + ImGui::SameLine(caption_max + unit_size + (++index) * space_size + offset_to_center); + ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::Y()),"Y"); + ImGui::SameLine(caption_max + (++index_unit) * unit_size + (++index) * space_size + offset_to_center); + ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::Z()),"Z"); index = 1; index_unit = 1; @@ -1224,15 +1222,14 @@ void GizmoObjectManipulation::do_render_scale_input_window(ImGuiWrapper* imgui_w ImGuiWrapper::pop_combo_style(); caption_max = combox_content_size - 4 * space_size; //ImGui::Dummy(ImVec2(caption_max, -1)); - ImGui::SameLine(caption_max + space_size); - ImGui::PushItemWidth(unit_size); - ImGui::TextAlignCenter("X"); - ImGui::SameLine(caption_max + unit_size + index * space_size); - ImGui::PushItemWidth(unit_size); - ImGui::TextAlignCenter("Y"); - ImGui::SameLine(caption_max + (++index_unit) * unit_size + (++index) * space_size); - ImGui::PushItemWidth(unit_size); - ImGui::TextAlignCenter("Z"); + // ORCA use TextColored to match axes color + float offset_to_center = (unit_size - ImGui::CalcTextSize("O").x) / 2; + ImGui::SameLine(caption_max + space_size + offset_to_center); + ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::X()),"X"); + ImGui::SameLine(caption_max + unit_size + index * space_size + offset_to_center); + ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::Y()),"Y"); + ImGui::SameLine(caption_max + (++index_unit) * unit_size + (++index) * space_size + offset_to_center); + ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::Z()),"Z"); index = 2; index_unit = 1; From 9b18c82bfbdf8e607a930f0f2d095728c359270d Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Fri, 9 May 2025 22:47:18 +0800 Subject: [PATCH 5/9] Fix crash when `start_extruder_id` is empty (#9584) Fix crash when `start_extruder_id` is empty (SoftFever/OrcaSlicer#9580) --- src/libslic3r/GCode/ToolOrdering.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libslic3r/GCode/ToolOrdering.cpp b/src/libslic3r/GCode/ToolOrdering.cpp index 0a51971320..debdb863d0 100644 --- a/src/libslic3r/GCode/ToolOrdering.cpp +++ b/src/libslic3r/GCode/ToolOrdering.cpp @@ -38,7 +38,7 @@ static std::vector solve_extruder_order(const std::vector Date: Fri, 9 May 2025 17:54:35 +0300 Subject: [PATCH 6/9] Fix filament type parameter box uses wrong width (#9582) * Update Tab.cpp * Update Tab.cpp --- src/slic3r/GUI/Tab.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index f27447f999..14b890ff00 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3308,10 +3308,7 @@ void TabFilament::build() auto page = add_options_page(L("Filament"), "custom-gcode_filament"); // ORCA: icon only visible on placeholders //BBS auto optgroup = page->new_optgroup(L("Basic information"), L"param_information"); - // Set size as all another fields for a better alignment - Option option = optgroup->get_option("filament_type"); - option.opt.width = Field::def_width(); - optgroup->append_single_option_line(option); + optgroup->append_single_option_line("filament_type"); // ORCA use same width with other elements optgroup->append_single_option_line("filament_vendor"); optgroup->append_single_option_line("filament_soluble"); // BBS @@ -3356,7 +3353,7 @@ void TabFilament::build() optgroup->append_single_option_line("adaptive_pressure_advance_overhangs"); optgroup->append_single_option_line("adaptive_pressure_advance_bridges"); - option = optgroup->get_option("adaptive_pressure_advance_model"); + Option option = optgroup->get_option("adaptive_pressure_advance_model"); option.opt.full_width = true; option.opt.is_code = true; option.opt.height = 15; From b0b6e000f214e586699809d3fa15ea57c2001155 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Fri, 9 May 2025 22:58:46 +0800 Subject: [PATCH 7/9] Don't show "remember my choice" on 3mf open dialog (#9547) Don't show "remember my choice" on 3mf open dialog (SoftFever/OrcaSlicer#9108) Lots of people accidentally checked it without realizing the consequences, now we make it more explicit by only allowing change this in preference settings. --- src/slic3r/GUI/Plater.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 7c2c72800a..08c7e36d14 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -10882,12 +10882,13 @@ ProjectDropDialog::ProjectDropDialog(const std::string &filename) m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, 10); wxBoxSizer *m_sizer_bottom = new wxBoxSizer(wxHORIZONTAL); - wxBoxSizer *m_sizer_left = new wxBoxSizer(wxHORIZONTAL); - - auto dont_show_again = create_remember_checkbox(_L("Remember my choice."), this, _L("This option can be changed later in preferences, under 'Load Behaviour'.")); - m_sizer_left->Add(dont_show_again, 0, wxALL, 5); - - m_sizer_bottom->Add(m_sizer_left, 0, wxEXPAND, 5); + // Orca: hide the "Don't show again" checkbox, people keeps accidentally checked this then forgot + // wxBoxSizer *m_sizer_left = new wxBoxSizer(wxHORIZONTAL); + // + // auto dont_show_again = create_remember_checkbox(_L("Remember my choice."), this, _L("This option can be changed later in preferences, under 'Load Behaviour'.")); + // m_sizer_left->Add(dont_show_again, 0, wxALL, 5); + // + // m_sizer_bottom->Add(m_sizer_left, 0, wxEXPAND, 5); m_sizer_bottom->Add(0, 0, 1, wxEXPAND, 5); wxBoxSizer *m_sizer_right = new wxBoxSizer(wxHORIZONTAL); From 0c4f778ddbc5c26e3df043f4a17ffcc22a3dacfa Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Fri, 9 May 2025 22:59:18 +0800 Subject: [PATCH 8/9] Fix crash when switching back to prepare tab after clicking the support paint icon in preview (#9417) --- src/slic3r/GUI/Plater.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 08c7e36d14..414ea397e6 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -6413,7 +6413,7 @@ void Plater::priv::set_current_panel(wxPanel* panel, bool no_slice) if (current_panel == view3D) { if (old_panel == preview) preview->get_canvas3d()->unbind_event_handlers(); - else if (old_panel == assemble_view) + else if (old_panel == assemble_view) { assemble_view->get_canvas3d()->unbind_event_handlers(); GLCanvas3D* assemble_canvas = assemble_view->get_canvas3d(); @@ -6427,6 +6427,7 @@ void Plater::priv::set_current_panel(wxPanel* panel, bool no_slice) view3d_selection.add(real_idx, false); } } + } view3D->get_canvas3d()->bind_event_handlers(); From 0cc495b425bc7d7d355785f63befab65111f51b7 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Fri, 9 May 2025 23:00:27 +0800 Subject: [PATCH 9/9] Make Custom GCode Editor resizable (#9405) * Make gcode editor window resizable * Make param list expands with the window * Make dialog shrinkable and give it a proper initial size * Revert "Hardcode Location of Add Button" This reverts commit aef74ab0050783bfaf7d67f531dd6877008e843c. * Make sure the dialog fits inside current screen * Fix compile error --- src/slic3r/GUI/EditGCodeDialog.cpp | 15 +++++++++------ src/slic3r/GUI/GUI_Utils.cpp | 14 ++++++++++++++ src/slic3r/GUI/GUI_Utils.hpp | 6 ++++++ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/EditGCodeDialog.cpp b/src/slic3r/GUI/EditGCodeDialog.cpp index c0776c7851..bc47cce4d9 100644 --- a/src/slic3r/GUI/EditGCodeDialog.cpp +++ b/src/slic3r/GUI/EditGCodeDialog.cpp @@ -35,7 +35,7 @@ namespace GUI { //------------------------------------------ EditGCodeDialog::EditGCodeDialog(wxWindow* parent, const std::string& key, const std::string& value) : - DPIDialog(parent, wxID_ANY, format_wxstr(_L("Edit Custom G-code (%1%)"), key), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE/* | wxRESIZE_BORDER*/) + DPIDialog(parent, wxID_ANY, format_wxstr(_L("Edit Custom G-code (%1%)"), key), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { SetFont(wxGetApp().normal_font()); SetBackgroundColour(*wxWHITE); @@ -68,15 +68,15 @@ EditGCodeDialog::EditGCodeDialog(wxWindow* parent, const std::string& key, const param_sizer->Add(m_search_bar, 0, wxEXPAND | wxALL, border); - m_params_list = new ParamsViewCtrl(this, wxSize(em * 45, em * 70)); + m_params_list = new ParamsViewCtrl(this, wxDefaultSize); m_params_list->SetFont(wxGetApp().code_font()); wxGetApp().UpdateDarkUI(m_params_list); - param_sizer->Add(m_params_list, 0, wxEXPAND | wxALL, border); + param_sizer->Add(m_params_list, 1, wxEXPAND | wxALL, border); m_add_btn = new ScalableButton(this, wxID_ANY, "add_copies"); m_add_btn->SetToolTip(_L("Add selected placeholder to G-code")); - m_gcode_editor = new wxTextCtrl(this, wxID_ANY, value, wxDefaultPosition, wxSize(em * 75, em * 70), wxTE_MULTILINE + m_gcode_editor = new wxTextCtrl(this, wxID_ANY, value, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE #ifdef _WIN32 | wxBORDER_SIMPLE #endif @@ -86,12 +86,12 @@ EditGCodeDialog::EditGCodeDialog(wxWindow* parent, const std::string& key, const wxGetApp().UpdateDarkUI(m_gcode_editor); grid_sizer->Add(param_sizer, 1, wxEXPAND); - grid_sizer->Add(m_add_btn, 0, wxTOP, m_params_list->GetSize().y/2); + grid_sizer->Add(m_add_btn, 0, wxALIGN_CENTER_VERTICAL); grid_sizer->Add(m_gcode_editor, 2, wxEXPAND); grid_sizer->AddGrowableRow(0, 1); grid_sizer->AddGrowableCol(0, 1); - grid_sizer->AddGrowableCol(2, 1); + grid_sizer->AddGrowableCol(2, 2); m_param_label = new wxStaticText(this, wxID_ANY, _L("Select placeholder")); m_param_label->SetFont(wxGetApp().bold_font()); @@ -115,6 +115,9 @@ EditGCodeDialog::EditGCodeDialog(wxWindow* parent, const std::string& key, const topSizer->SetSizeHints(this); this->Fit(); + + fit_in_display(*this, {100 * em, 70 * em}); + this->Layout(); this->CenterOnScreen(); diff --git a/src/slic3r/GUI/GUI_Utils.cpp b/src/slic3r/GUI/GUI_Utils.cpp index 56c1ce6bc1..0cbadc8e8c 100644 --- a/src/slic3r/GUI/GUI_Utils.cpp +++ b/src/slic3r/GUI/GUI_Utils.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "libslic3r/Config.hpp" @@ -481,5 +482,18 @@ bool generate_image(const std::string &filename, wxImage &image, wxSize img_size std::deque dialogStack; +void fit_in_display(wxTopLevelWindow& window, wxSize desired_size) +{ + const auto display_size = wxDisplay(window.GetParent()).GetClientArea(); + if (desired_size.GetWidth() > display_size.GetWidth()) { + desired_size.SetWidth(display_size.GetWidth() * 4 / 5); + } + if (desired_size.GetHeight() > display_size.GetHeight()) { + desired_size.SetHeight(display_size.GetHeight() * 4 / 5); + } + + window.SetSize(desired_size); +} + } } diff --git a/src/slic3r/GUI/GUI_Utils.hpp b/src/slic3r/GUI/GUI_Utils.hpp index 66b4c96230..cbfd4e3155 100644 --- a/src/slic3r/GUI/GUI_Utils.hpp +++ b/src/slic3r/GUI/GUI_Utils.hpp @@ -498,6 +498,12 @@ int get_dpi_for_window(const wxWindow *window); void dataview_remove_insets(wxDataViewCtrl* dv); #endif +/// +/// Make sure the given window fits inside current display +/// +void fit_in_display(wxTopLevelWindow& window, wxSize desired_size); + + }} #endif