Add bed exclude area

This commit is contained in:
QIDI TECH
2023-12-29 16:52:37 +08:00
parent 70534de371
commit c09a8dbf2e
13 changed files with 179 additions and 26 deletions

View File

@@ -528,6 +528,8 @@ static std::vector<std::string> s_Preset_printer_options {
"default_print_profile", "inherits",
"remaining_times", "silent_mode",
"machine_limits_usage", "thumbnails", "thumbnails_format",
//Y20
"bed_exclude_area",
//Y16
"chamber_temperature", "auxiliary_fan", "chamber_fan"
};
@@ -1338,6 +1340,8 @@ static const std::set<std::string> independent_from_extruder_number_options = {
"filament_ramming_parameters",
"gcode_substitutions",
"post_process",
//Y20
"bed_exclude_area",
};
bool PresetCollection::is_independent_from_extruder_number_option(const std::string& opt_key)

View File

@@ -60,6 +60,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
"autoemit_temperature_commands",
"avoid_crossing_perimeters",
"avoid_crossing_perimeters_max_detour",
//Y20
"bed_exclude_area",
"bed_shape",
"bed_temperature",
"before_layer_gcode",

View File

@@ -271,6 +271,12 @@ void PrintConfigDef::init_common_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionPoints{ Vec2d(0, 0), Vec2d(200, 0), Vec2d(200, 200), Vec2d(0, 200) });
//Y20
def = this->add("bed_exclude_area", coPoints);
def->label = L("Bed exclude area");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionPoints{ Vec2d(0, 0) });
def = this->add("bed_custom_texture", coString);
def->label = L("Bed custom texture");
def->mode = comAdvanced;
@@ -2589,7 +2595,7 @@ void PrintConfigDef::init_fff_params()
def = this->add("small_perimeter_speed", coFloatOrPercent);
def->label = L("Small perimeters");
def->category = L("Speed");
def->tooltip = L("This separate setting will affect the speed of perimeters having radius <= 6.5mm "
def->tooltip = L("This separate setting will affect the speed of perimeters having radius <= 4mm "
"(usually holes). If expressed as percentage (for example: 80%) it will be calculated "
"on the perimeters speed setting above. Set to zero for auto.");
def->sidetext = L("mm/s or %");

View File

@@ -788,6 +788,8 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
((ConfigOptionBool, avoid_crossing_perimeters))
((ConfigOptionFloatOrPercent, avoid_crossing_perimeters_max_detour))
((ConfigOptionPoints, bed_shape))
//Y20
((ConfigOptionPoints, bed_exclude_area))
((ConfigOptionInts, bed_temperature))
//Y16
((ConfigOptionBool, chamber_temperature))

View File

@@ -31,6 +31,9 @@ static std::string get_option_label(BedShape::Parameter param)
case BedShape::Parameter::RectSize : return L("Size");
case BedShape::Parameter::RectOrigin: return L("Origin");
case BedShape::Parameter::Diameter : return L("Diameter");
//Y20
case BedShape::Parameter::ExcludeMax: return L("Max");
case BedShape::Parameter::ExcludeMin: return L("Min");
default: assert(false); return {};
}
}
@@ -66,6 +69,25 @@ void BedShape::append_option_line(ConfigOptionsGroupShp optgroup, Parameter para
def.tooltip = L("Diameter of the print bed. It is assumed that origin (0,0) is located in the center.");
key = "diameter";
break;
//Y20
case Parameter::ExcludeMax:
def.type = coPoints;
def.set_default_value(new ConfigOptionPoints{ Vec2d(0, 0) });
def.min = 0;
def.max = 1200;
def.label = get_option_label(param);
def.tooltip = L("Max point in X and Y of the exclude area.");
key = "exclude_area_max";
break;
case Parameter::ExcludeMin:
def.type = coPoints;
def.set_default_value(new ConfigOptionPoints{ Vec2d(0, 0) });
def.min = 0;
def.max = 1200;
def.label = get_option_label(param);
def.tooltip = L("Min point in X and Y of the exclude area.");
key = "exclude_area_min";
break;
default:
assert(false);
}
@@ -127,16 +149,23 @@ void BedShape::apply_optgroup_values(ConfigOptionsGroupShp optgroup)
optgroup->set_value("rect_origin" , to_2d(-1 * m_build_volume.bounding_volume().min));
}
}
//Y20
void BedShape::apply_exclude_values(ConfigOptionsGroupShp optgroup)
{
optgroup->set_value("exclude_area_max" , to_2d(m_build_volume.bounding_volume().max));
optgroup->set_value("exclude_area_min" , to_2d(m_build_volume.bounding_volume().min));
}
BedShapeDialog::BedShapeDialog(wxWindow* parent) : DPIDialog(parent, wxID_ANY, _(L("Bed Shape")),
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {}
void BedShapeDialog::build_dialog(const ConfigOptionPoints& default_pt, const ConfigOptionString& custom_texture, const ConfigOptionString& custom_model)
//Y20
void BedShapeDialog::build_dialog(const ConfigOptionPoints& default_pt, const ConfigOptionPoints& exclude_area, const ConfigOptionString& custom_texture, const ConfigOptionString& custom_model)
{
SetFont(wxGetApp().normal_font());
m_panel = new BedShapePanel(this);
m_panel->build_panel(default_pt, custom_texture, custom_model);
//Y20
m_panel->build_panel(default_pt, exclude_area, custom_texture, custom_model);
auto main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(m_panel, 1, wxEXPAND);
@@ -174,11 +203,13 @@ void BedShapeDialog::on_dpi_changed(const wxRect &suggested_rect)
const std::string BedShapePanel::NONE = "None";
const std::string BedShapePanel::EMPTY_STRING = "";
void BedShapePanel::build_panel(const ConfigOptionPoints& default_pt, const ConfigOptionString& custom_texture, const ConfigOptionString& custom_model)
//Y20
void BedShapePanel::build_panel(const ConfigOptionPoints& default_pt, const ConfigOptionPoints& exclude_area, const ConfigOptionString& custom_texture, const ConfigOptionString& custom_model)
{
wxGetApp().UpdateDarkUI(this);
m_shape = default_pt.values;
//Y20
m_exclude_area = exclude_area.values;
m_custom_texture = custom_texture.value.empty() ? NONE : custom_texture.value;
m_custom_model = custom_model.value.empty() ? NONE : custom_model.value;
@@ -223,6 +254,8 @@ void BedShapePanel::build_panel(const ConfigOptionPoints& default_pt, const Conf
optgroup->append_line(line);
activate_options_page(optgroup);
//Y20
wxPanel* exclude_panel = init_exclude_panel();
wxPanel* texture_panel = init_texture_panel();
wxPanel* model_panel = init_model_panel();
@@ -235,6 +268,8 @@ void BedShapePanel::build_panel(const ConfigOptionPoints& default_pt, const Conf
wxSizer* left_sizer = new wxBoxSizer(wxVERTICAL);
left_sizer->Add(sbsizer, 0, wxEXPAND);
//Y20
left_sizer->Add(exclude_panel, 0, wxEXPAND);
left_sizer->Add(texture_panel, 1, wxEXPAND);
left_sizer->Add(model_panel, 1, wxEXPAND);
@@ -245,6 +280,8 @@ void BedShapePanel::build_panel(const ConfigOptionPoints& default_pt, const Conf
SetSizerAndFit(top_sizer);
set_shape(default_pt);
//Y20
set_exclude_area(exclude_area);
update_preview();
}
@@ -273,6 +310,28 @@ void BedShapePanel::activate_options_page(ConfigOptionsGroupShp options_group)
options_group->parent()->SetSizerAndFit(options_group->sizer);
}
//Y20
wxPanel* BedShapePanel::init_exclude_panel()
{
wxPanel* panel = new wxPanel(this);
wxGetApp().UpdateDarkUI(panel, true);
exclude_optgroup = std::make_shared<ConfigOptionsGroup>(panel, _L("Exclude area"));
exclude_optgroup->label_width = 10;
exclude_optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
update_shape();
};
BedShape::append_option_line(exclude_optgroup, BedShape::Parameter::ExcludeMax);
BedShape::append_option_line(exclude_optgroup, BedShape::Parameter::ExcludeMin);
exclude_optgroup->activate();
panel->SetSizerAndFit(exclude_optgroup->sizer);
return panel;
}
wxPanel* BedShapePanel::init_texture_panel()
{
wxPanel* panel = new wxPanel(this);
@@ -437,6 +496,13 @@ void BedShapePanel::set_shape(const ConfigOptionPoints& points)
update_shape();
}
//Y20
void BedShapePanel::set_exclude_area(const ConfigOptionPoints& points)
{
BedShape exclude(points);
exclude.apply_exclude_values(exclude_optgroup);
update_shape();
}
void BedShapePanel::update_preview()
{
@@ -508,6 +574,41 @@ void BedShapePanel::update_shape()
break;
}
//Y20
Vec2d exclude_max(Vec2d::Zero());
Vec2d exclude_min(Vec2d::Zero());
try { exclude_max = boost::any_cast<Vec2d>(exclude_optgroup->get_value("exclude_area_max")); }
catch (const std::exception& /* e */) { return; }
try { exclude_min = boost::any_cast<Vec2d>(exclude_optgroup->get_value("exclude_area_min")); }
catch (const std::exception & /* e */) { return; }
auto e_x = exclude_max(0);
auto e_y = exclude_max(1);
// empty strings or '-' or other things
//if (e_x == 0 || e_y == 0) return;
//double e_x0 = 0.0;
//double e_y0 = 0.0;
//double e_x1 = e_x;
//double e_y1 = e_y;
auto e_dx = exclude_min(0);
auto e_dy = exclude_min(1);
//e_x0 -= e_dx;
//e_x1 -= e_dx;
//e_y0 -= e_dy;
//e_y1 -= e_dy;
//m_exclude_area = { Vec2d(e_x0, e_y0),
// Vec2d(e_x1, e_y0),
// Vec2d(e_x1, e_y1),
// Vec2d(e_x0, e_y1) };
m_exclude_area = { Vec2d(e_dx, e_dy),
Vec2d(e_x, e_dy),
Vec2d(e_x, e_y),
Vec2d(e_dx, e_y) };
update_preview();
}

View File

@@ -30,7 +30,10 @@ struct BedShape
enum class Parameter {
RectSize,
RectOrigin,
Diameter
Diameter,
//Y20
ExcludeMax,
ExcludeMin
};
BedShape(const ConfigOptionPoints& points);
@@ -44,6 +47,8 @@ struct BedShape
wxString get_full_name_with_params();
void apply_optgroup_values(ConfigOptionsGroupShp optgroup);
//Y20
void apply_exclude_values(ConfigOptionsGroupShp optgroup);
private:
BuildVolume m_build_volume;
@@ -57,25 +62,34 @@ class BedShapePanel : public wxPanel
Bed_2D* m_canvas;
std::vector<Vec2d> m_shape;
std::vector<Vec2d> m_loaded_shape;
//Y20
std::vector<Vec2d> m_exclude_area;
std::string m_custom_texture;
std::string m_custom_model;
public:
BedShapePanel(wxWindow* parent) : wxPanel(parent, wxID_ANY), m_custom_texture(NONE), m_custom_model(NONE) {}
void build_panel(const ConfigOptionPoints& default_pt, const ConfigOptionString& custom_texture, const ConfigOptionString& custom_model);
//Y20
void build_panel(const ConfigOptionPoints& default_pt, const ConfigOptionPoints& exclude_area, const ConfigOptionString& custom_texture, const ConfigOptionString& custom_model);
// Returns the resulting bed shape polygon. This value will be stored to the ini file.
const std::vector<Vec2d>& get_shape() const { return m_shape; }
//Y20
const std::vector<Vec2d>& get_exclude_area() const { return m_exclude_area; }
const std::string& get_custom_texture() const { return (m_custom_texture != NONE) ? m_custom_texture : EMPTY_STRING; }
const std::string& get_custom_model() const { return (m_custom_model != NONE) ? m_custom_model : EMPTY_STRING; }
private:
ConfigOptionsGroupShp init_shape_options_page(const wxString& title);
void activate_options_page(ConfigOptionsGroupShp options_group);
//Y20
wxPanel* init_exclude_panel();
ConfigOptionsGroupShp exclude_optgroup;
wxPanel* init_texture_panel();
wxPanel* init_model_panel();
void set_shape(const ConfigOptionPoints& points);
//Y20
void set_exclude_area(const ConfigOptionPoints& points);
void update_preview();
void update_shape();
void load_stl();
@@ -93,10 +107,12 @@ class BedShapeDialog : public DPIDialog
BedShapePanel* m_panel;
public:
BedShapeDialog(wxWindow* parent);
void build_dialog(const ConfigOptionPoints& default_pt, const ConfigOptionString& custom_texture, const ConfigOptionString& custom_model);
//Y20
void build_dialog(const ConfigOptionPoints& default_pt, const ConfigOptionPoints& exclude_area, const ConfigOptionString& custom_texture, const ConfigOptionString& custom_model);
const std::vector<Vec2d>& get_shape() const { return m_panel->get_shape(); }
//Y20
const std::vector<Vec2d>& get_exclude_area() const { return m_panel->get_exclude_area(); }
const std::string& get_custom_texture() const { return m_panel->get_custom_texture(); }
const std::string& get_custom_model() const { return m_panel->get_custom_model(); }

View File

@@ -1828,6 +1828,8 @@ PageBedShape::PageBedShape(ConfigWizard *parent)
append_text(_L("Set the shape of your printer's bed."));
shape_panel->build_panel(*wizard_p()->custom_config->option<ConfigOptionPoints>("bed_shape"),
//Y20
*wizard_p()->custom_config->option<ConfigOptionPoints>("bed_exclude_area"),
*wizard_p()->custom_config->option<ConfigOptionString>("bed_custom_texture"),
*wizard_p()->custom_config->option<ConfigOptionString>("bed_custom_model"));
@@ -1837,9 +1839,13 @@ PageBedShape::PageBedShape(ConfigWizard *parent)
void PageBedShape::apply_custom_config(DynamicPrintConfig &config)
{
const std::vector<Vec2d>& points = shape_panel->get_shape();
//Y20
const std::vector<Vec2d>& exclude_area = shape_panel->get_exclude_area();
const std::string& custom_texture = shape_panel->get_custom_texture();
const std::string& custom_model = shape_panel->get_custom_model();
config.set_key_value("bed_shape", new ConfigOptionPoints(points));
//Y20
config.set_key_value("bed_exclude_area", new ConfigOptionPoints(exclude_area));
config.set_key_value("bed_custom_texture", new ConfigOptionString(custom_texture));
config.set_key_value("bed_custom_model", new ConfigOptionString(custom_model));
}
@@ -3310,7 +3316,8 @@ ConfigWizard::ConfigWizard(wxWindow *parent)
p->load_vendors();
p->custom_config.reset(DynamicPrintConfig::new_from_defaults_keys({
"gcode_flavor", "bed_shape", "bed_custom_texture", "bed_custom_model", "nozzle_diameter", "filament_diameter", "temperature", "bed_temperature",
//Y20
"gcode_flavor", "bed_shape", "bed_exclude_area", "bed_custom_texture", "bed_custom_model", "nozzle_diameter", "filament_diameter", "temperature", "bed_temperature",
}));
p->index = new ConfigWizardIndex(this);

View File

@@ -203,7 +203,8 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt
}
break;
case coPoints:{
if (opt_key == "bed_shape") {
//Y20
if (opt_key == "bed_shape" || opt_key == "bed_exclude_area") {
config.option<ConfigOptionPoints>(opt_key)->values = boost::any_cast<std::vector<Vec2d>>(value);
break;
}

View File

@@ -953,7 +953,8 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
ret = config.option(opt_key)->getInt();
break;
case coPoints:
if (opt_key == "bed_shape")
//Y20
if (opt_key == "bed_shape" || opt_key == "bed_exclude_area")
ret = config.option<ConfigOptionPoints>(opt_key)->values;
else
ret = config.option<ConfigOptionPoints>(opt_key)->get_at(idx);

View File

@@ -4963,15 +4963,21 @@ wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent)
{
BedShapeDialog dlg(this);
dlg.build_dialog(*m_config->option<ConfigOptionPoints>("bed_shape"),
//Y20
*m_config->option<ConfigOptionPoints>("bed_exclude_area"),
*m_config->option<ConfigOptionString>("bed_custom_texture"),
*m_config->option<ConfigOptionString>("bed_custom_model"));
if (dlg.ShowModal() == wxID_OK) {
const std::vector<Vec2d>& shape = dlg.get_shape();
//Y20
const std::vector<Vec2d>& exclude_area = dlg.get_exclude_area();
const std::string& custom_texture = dlg.get_custom_texture();
const std::string& custom_model = dlg.get_custom_model();
if (!shape.empty())
{
load_key_value("bed_shape", shape);
//Y20
load_key_value("bed_exclude_area", exclude_area);
load_key_value("bed_custom_texture", custom_texture);
load_key_value("bed_custom_model", custom_model);
update_changed_ui();
@@ -4984,6 +4990,8 @@ wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent)
{
Search::OptionsSearcher& searcher = wxGetApp().sidebar().get_searcher();
const Search::GroupAndCategory& gc = searcher.get_group_and_category("bed_shape");
//Y20
searcher.add_key("bed_exclude_area", m_type, gc.group, gc.category);
searcher.add_key("bed_custom_texture", m_type, gc.group, gc.category);
searcher.add_key("bed_custom_model", m_type, gc.group, gc.category);
}

View File

@@ -1203,6 +1203,11 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig&
BedShape shape(*config.option<ConfigOptionPoints>(opt_key));
return shape.get_full_name_with_params();
}
//Y20
if (opt_key == "bed_exclude_area") {
BedShape shape(*config.option<ConfigOptionPoints>(opt_key));
return shape.get_full_name_with_params();
}
Vec2d val = config.opt<ConfigOptionPoints>(opt_key)->get_at(opt_idx);
return from_u8((boost::format("[%1%]") % ConfigOptionPoint(val).serialize()).str());

View File

@@ -32,11 +32,11 @@ namespace Slic3r {
namespace GUI {
static const char* URL_CHANGELOG = "https://files.qidi3d.com/?latest=slicer-stable&lng=%1%";
static const char* URL_CHANGELOG = "https://github.com/QIDITECH/QIDISlicer/releases/tag/V%1%";
static const char* URL_DOWNLOAD = "https://www.qidi3d.com/slicerweb&lng=%1%";
static const char* URL_DEV = "https://github.com/qidi3d/QIDISlicer/releases/tag/version_%1%";
static const char* URL_DEV = "https://github.com/QIDITECH/QIDISlicer/releases/tag/version_%1%";
static const std::string CONFIG_UPDATE_WIKI_URL("https://github.com/qidi3d/QIDISlicer/wiki/Slic3r-PE-1.40-configuration-update");
static const std::string CONFIG_UPDATE_WIKI_URL("https://github.com/QIDITECH/QIDISlicer");
// MsgUpdateSlic3r
@@ -478,15 +478,15 @@ MsgDataLegacy::MsgDataLegacy() :
text->Wrap(CONTENT_WIDTH * wxGetApp().em_unit());
content_sizer->Add(text);
content_sizer->AddSpacer(VERT_SPACING);
auto *text2 = new wxStaticText(this, wxID_ANY, _(L("For more information please visit our wiki page:")));
static const wxString url("https://github.com/qidi3d/QIDISlicer/wiki/Slic3r-PE-1.40-configuration-update");
//Y19
//auto *text2 = new wxStaticText(this, wxID_ANY, _(L("For more information please visit our wiki page:")));
//static const wxString url("https://github.com/QIDITECH/QIDISlicer");
// The wiki page name is intentionally not localized:
// TRN %s = QIDISlicer
auto *link = new wxHyperlinkCtrl(this, wxID_ANY, format_wxstr(_L("%s 1.40 configuration update"), SLIC3R_APP_NAME), CONFIG_UPDATE_WIKI_URL);
content_sizer->Add(text2);
content_sizer->Add(link);
content_sizer->AddSpacer(VERT_SPACING);
//auto *link = new wxHyperlinkCtrl(this, wxID_ANY, format_wxstr(_L("%s configuration update"), SLIC3R_APP_NAME), CONFIG_UPDATE_WIKI_URL);
//content_sizer->Add(text2);
//content_sizer->Add(link);
//content_sizer->AddSpacer(VERT_SPACING);
finalize();
}

View File

@@ -34,11 +34,11 @@ WifiConfigDialog::WifiConfigDialog(wxWindow* parent, std::string& file_path, Rem
panel->SetSizer(vsizer);
// TRN Wifi config dialog explanation line 1.
wxStaticText* explain_label1 = new wxStaticText(panel, wxID_ANY, _L("Generate a file to be loaded by a Prusa printer to configure its Wi-Fi connection."));
wxStaticText* explain_label1 = new wxStaticText(panel, wxID_ANY, _L("Generate a file to be loaded by a printer to configure its Wi-Fi connection."));
// TRN Wifi config dialog explanation line 2.
wxStaticText* explain_label2 = new wxStaticText(panel, wxID_ANY, GUI::format_wxstr(_L("Write this file on the USB flash drive. Its name will be %1%."), WIFI_CONFIGFILE_NAME));
// TRN Wifi config dialog explanation line 3.
wxStaticText* explain_label3 = new wxStaticText(panel, wxID_ANY, _L("Your Prusa printer should load this file automatically."));
wxStaticText* explain_label3 = new wxStaticText(panel, wxID_ANY, _L("Your printer should load this file automatically."));
// TRN Wifi config dialog explanation line 4.
wxStaticText* explain_label4 = new wxStaticText(panel, wxID_ANY, _L("Note: This file will contain the SSID and password in plain text."));