From 5a2669dcc2aaf5d2bb548b031b73e72058c78b51 Mon Sep 17 00:00:00 2001 From: "salt.wei" Date: Mon, 25 Jul 2022 18:32:05 +0800 Subject: [PATCH] ENH: privide setting option of exclude_area As title. User can delete the value to enable 256x256 printable size Signed-off-by: salt.wei Change-Id: Ia10454b7a7a1b28c04d8d41df9f3251875f6e74e --- src/libslic3r/PrintConfig.cpp | 8 +++++--- src/slic3r/GUI/Field.cpp | 14 +++++++++++--- src/slic3r/GUI/GUI.cpp | 2 +- src/slic3r/GUI/OptionsGroup.cpp | 4 ++++ src/slic3r/GUI/PartPlate.hpp | 1 + src/slic3r/GUI/Plater.cpp | 4 +++- src/slic3r/GUI/Tab.cpp | 8 +++++--- 7 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 9fdd1b375..905d33295 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -264,8 +264,11 @@ void PrintConfigDef::init_common_params() //BBS: add "bed_exclude_area" def = this->add("bed_exclude_area", coPoints); def->label = L("Bed exclude area"); - def->mode = comDevelop; - def->set_default_value(new ConfigOptionPoints{}); + def->tooltip = L("Bed exclude area that can't used as printable area in X-Y plane. For example, the bottom left area which is used to cut filament in X1 when printing multi colors with AMS. " + "The area is expressed as polygon by points in following format: \"XxY, XxY, ...\""); + def->mode = comAdvanced; + def->gui_type = ConfigOptionDef::GUIType::one_string; + def->set_default_value(new ConfigOptionPoints{ Vec2d(0, 0) }); def = this->add("elefant_foot_compensation", coFloat); def->label = L("Elephant foot compensation"); @@ -290,7 +293,6 @@ void PrintConfigDef::init_common_params() def->sidetext = L("mm"); def->min = 0; def->max = 1000; - def->readonly = true; def->mode = comSimple; def->set_default_value(new ConfigOptionFloat(100.0)); diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index de94173dd..75720dda0 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -374,9 +374,17 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true if (x_str.ToDouble(&x) && thumbnail.HasMoreTokens()) { wxString y_str = thumbnail.GetNextToken(); if (y_str.ToDouble(&y) && !thumbnail.HasMoreTokens()) { - if (0 < x && x < 1000 && 0 < y && y < 1000) { - out_values.push_back(Vec2d(x, y)); - continue; + if (m_opt_id == "bed_exclude_area") { + if (0 <= x && x <= 256 && 0 <= y && y <= 256) { + out_values.push_back(Vec2d(x, y)); + continue; + } + } + else { + if (0 < x && x < 1000 && 0 < y && y < 1000) { + out_values.push_back(Vec2d(x, y)); + continue; + } } out_of_range_val = true; break; diff --git a/src/slic3r/GUI/GUI.cpp b/src/slic3r/GUI/GUI.cpp index 7add74819..4c302392b 100644 --- a/src/slic3r/GUI/GUI.cpp +++ b/src/slic3r/GUI/GUI.cpp @@ -197,7 +197,7 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt } break; case coPoints:{ - if (opt_key == "printable_area") { + if (opt_key == "printable_area" || opt_key == "bed_exclude_area") { config.option(opt_key)->values = boost::any_cast>(value); break; } diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index fe16aac3c..53af54745 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -1022,6 +1022,8 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config case coPoints: if (opt_key == "printable_area") ret = config.option(opt_key)->values; + else if (opt_key == "bed_exclude_area") + ret = get_thumbnails_string(config.option(opt_key)->values); else ret = config.option(opt_key)->get_at(idx); break; @@ -1130,6 +1132,8 @@ boost::any ConfigOptionsGroup::get_config_value2(const DynamicPrintConfig& confi case coPoints: if (opt_key == "printable_area") ret = config.option(opt_key)->values; + else if (opt_key == "bed_exclude_area") + ret = get_thumbnails_string(config.option(opt_key)->values); else ret = config.option(opt_key)->get_at(idx); break; diff --git a/src/slic3r/GUI/PartPlate.hpp b/src/slic3r/GUI/PartPlate.hpp index 7bcaa0675..b0a29125c 100644 --- a/src/slic3r/GUI/PartPlate.hpp +++ b/src/slic3r/GUI/PartPlate.hpp @@ -520,6 +520,7 @@ public: Vec3d get_current_plate_origin() { return compute_origin(m_current_plate, m_plate_cols); } Vec2d get_current_shape_position() { return compute_shape_position(m_current_plate, m_plate_cols); } + Pointfs get_exclude_area() { return m_exclude_areas; } //select plate int select_plate(int index); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 5e0e1d0b8..107be515d 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -5879,7 +5879,9 @@ void Plater::priv::set_bed_shape(const Pointfs& shape, const Pointfs& exclude_ar partplate_list.get_height_limits(prev_height_lid, prev_height_rod); double height_to_lid = config->opt_float("extruder_clearance_height_to_lid"); double height_to_rod = config->opt_float("extruder_clearance_height_to_rod"); - new_shape |= (height_to_lid != prev_height_lid) || (height_to_rod != prev_height_rod); + + Pointfs prev_exclude_areas = partplate_list.get_exclude_area(); + new_shape |= (height_to_lid != prev_height_lid) || (height_to_rod != prev_height_rod) || (prev_exclude_areas != exclude_areas); if (new_shape) { if (view3D) view3D->bed_shape_changed(); if (preview) preview->bed_shape_changed(); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 1b591d16e..82ba27a87 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -851,7 +851,7 @@ void TabPrinter::init_options_list() for (const std::string& opt_key : m_config->keys()) { - if (opt_key == "printable_area") { + if (opt_key == "printable_area" || opt_key == "bed_exclude_area") { m_options_list.emplace(opt_key, m_opt_status_value); continue; } @@ -2677,7 +2677,9 @@ void TabPrinter::build_fff() //create_line_with_widget(optgroup.get(), "printable_area", "custom-svg-and-png-bed-textures_124612", [this](wxWindow* parent) { // return create_bed_shape_widget(parent); //}); - + Option option = optgroup->get_option("bed_exclude_area"); + option.opt.full_width = true; + optgroup->append_single_option_line(option); optgroup->append_single_option_line("printable_height"); optgroup->append_single_option_line("nozzle_volume"); // BBS @@ -2793,7 +2795,7 @@ void TabPrinter::build_fff() optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { validate_custom_gcode_cb(this, optgroup, opt_key, value); }; - Option option = optgroup->get_option("machine_start_gcode"); + option = optgroup->get_option("machine_start_gcode"); option.opt.full_width = true; option.opt.is_code = true; option.opt.height = gcode_field_height;//150;