exclude_area and host_type

This commit is contained in:
sunsets
2024-03-01 08:54:32 +08:00
parent ee616bbbb6
commit 1fc08d237c
11 changed files with 90 additions and 39 deletions

View File

@@ -71,11 +71,13 @@ static const t_config_enum_values s_keys_map_MachineLimitsUsage {
}; };
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(MachineLimitsUsage) CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(MachineLimitsUsage)
//B55
static const t_config_enum_values s_keys_map_PrintHostType { static const t_config_enum_values s_keys_map_PrintHostType {
{ "qidilink", htQIDILink }, { "qidilink", htQIDILink },
{ "qidiconnect", htQIDIConnect }, { "qidiconnect", htQIDIConnect },
{ "octoprint", htOctoPrint }, { "octoprint", htOctoPrint },
{ "moonraker", htMoonraker }, { "moonraker", htMoonraker },
{ "moonraker2", htMoonraker2 },
{ "duet", htDuet }, { "duet", htDuet },
{ "flashair", htFlashAir }, { "flashair", htFlashAir },
{ "astrobox", htAstroBox }, { "astrobox", htAstroBox },
@@ -2140,6 +2142,7 @@ void PrintConfigDef::init_fff_params()
def->sidetext = L("mm"); def->sidetext = L("mm");
def->set_default_value(new ConfigOptionFloats { 0.4 }); def->set_default_value(new ConfigOptionFloats { 0.4 });
//B55
def = this->add("host_type", coEnum); def = this->add("host_type", coEnum);
def->label = L("Host Type"); def->label = L("Host Type");
def->tooltip = L("Slic3r can upload G-code files to a printer host. This field must contain " def->tooltip = L("Slic3r can upload G-code files to a printer host. This field must contain "
@@ -2148,7 +2151,8 @@ void PrintConfigDef::init_fff_params()
{ "qidilink", "QIDILink" }, { "qidilink", "QIDILink" },
{ "qidiconnect", "QIDIConnect" }, { "qidiconnect", "QIDIConnect" },
{ "octoprint", "OctoPrint" }, { "octoprint", "OctoPrint" },
{ "moonraker", "Klipper (via Moonraker)" }, { "moonraker", "Klipper (via QIDI)" },
{ "moonraker2", "Klipper (via Moonraker)" },
{ "duet", "Duet" }, { "duet", "Duet" },
{ "flashair", "FlashAir" }, { "flashair", "FlashAir" },
{ "astrobox", "AstroBox" }, { "astrobox", "AstroBox" },

View File

@@ -46,8 +46,9 @@ enum class MachineLimitsUsage {
Count, Count,
}; };
//B55
enum PrintHostType { enum PrintHostType {
htQIDILink, htQIDIConnect, htOctoPrint, htMoonraker, htDuet, htFlashAir, htAstroBox, htRepetier, htMKS htQIDILink, htQIDIConnect, htOctoPrint, htMoonraker, htMoonraker2,htDuet, htFlashAir, htAstroBox, htRepetier, htMKS
}; };
enum AuthorizationType { enum AuthorizationType {

View File

@@ -280,7 +280,16 @@ void BedShapePanel::build_panel(const ConfigOptionPoints& default_pt, const Conf
// right pane with preview canvas // right pane with preview canvas
m_canvas = new Bed_2D(this); m_canvas = new Bed_2D(this);
m_canvas->SetMinSize({ FromDIP(400), FromDIP(400) }); m_canvas->SetMinSize({ FromDIP(400), FromDIP(400) });
m_canvas->Bind(wxEVT_PAINT, [this](wxPaintEvent& e) { m_canvas->repaint(m_shape); }); //B52
m_canvas->Bind(wxEVT_PAINT, [this](wxPaintEvent& e) {
std::vector<Vec2d> tem_shape = m_shape;
if (m_exclude_area.size() > 1) {
for (const auto &point : m_exclude_area) {
tem_shape.push_back({point.x(), point.y()});
}
}
m_canvas->repaint(tem_shape);
});
m_canvas->Bind(wxEVT_SIZE, [this](wxSizeEvent& e) { m_canvas->Refresh(); }); m_canvas->Bind(wxEVT_SIZE, [this](wxSizeEvent& e) { m_canvas->Refresh(); });
wxSizer* left_sizer = new wxBoxSizer(wxVERTICAL); wxSizer* left_sizer = new wxBoxSizer(wxVERTICAL);
@@ -665,12 +674,12 @@ const std::vector<Vec2d> BedShapePanel::update_exclude_area(ConfigOptionsGroupSh
e_area.push_back({exclude_min_1.x(), exclude_min_1.y()}); e_area.push_back({exclude_min_1.x(), exclude_min_1.y()});
e_area.push_back({0, 0}); e_area.push_back({0, 0});
} }
if (e_area.size() > 1) { //if (e_area.size() > 1) {
for (const auto &point : e_area) { // for (const auto &point : e_area) {
m_shape.push_back({point.x(), point.y()}); // m_shape.push_back({point.x(), point.y()});
} // }
} //}
} }
return e_area; return e_area;
} }

View File

@@ -2148,11 +2148,13 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
m_printer_view->AddButton( m_printer_view->AddButton(
printer_name, host, (data->model_id), (data->fullname), printer_name, host, (data->model_id), (data->fullname),
[host, this](wxMouseEvent &event) { [host, this](wxMouseEvent &event) {
wxString formattedHost = wxString::Format("http://%s", host); //B55
wxString formattedHost = host;
//wxString formattedHost = wxString::Format("http://%s", host);
if (!host.Lower().starts_with("http")) if (!host.Lower().starts_with("http"))
wxString formattedHost = wxString::Format("http://%s", host); formattedHost = wxString::Format("http://%s", host);
if (!formattedHost.Lower().ends_with("10088")) //if (!formattedHost.Lower().ends_with("10088"))
formattedHost = wxString::Format("%s:10088", formattedHost); // formattedHost = wxString::Format("%s:10088", formattedHost);
this->m_printer_view->load_url(formattedHost); this->m_printer_view->load_url(formattedHost);
}, },
(data->selected), cfg_t); (data->selected), cfg_t);
@@ -2168,18 +2170,20 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
if (const DynamicPrintConfig *cfg = wxGetApp().preset_bundle->physical_printers.get_selected_printer_config(); cfg) { if (const DynamicPrintConfig *cfg = wxGetApp().preset_bundle->physical_printers.get_selected_printer_config(); cfg) {
const PhysicalPrinter &pp = preset_bundle.physical_printers.get_selected_printer(); const PhysicalPrinter &pp = preset_bundle.physical_printers.get_selected_printer();
wxString host = pp.config.opt_string("print_host"); wxString host = pp.config.opt_string("print_host");
//B55
//B45 //B45
std::regex ipRegex(R"(\b(?:\d{1,3}\.){3}\d{1,3}\b)"); //std::regex ipRegex(R"(\b(?:\d{1,3}\.){3}\d{1,3}\b)");
bool isValidIPAddress = std::regex_match(host.ToStdString(), ipRegex); //bool isValidIPAddress = std::regex_match(host.ToStdString(), ipRegex);
if (host.empty() || !isValidIPAddress) { if (host.empty()) {
tem_host = ""; tem_host = "";
host = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir())); host = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
} }
//B55
else { else {
if (!host.Lower().starts_with("http")) if (!host.Lower().starts_with("http"))
host = wxString::Format("http://%s", host); host = wxString::Format("http://%s", host);
if (!host.Lower().ends_with("10088")) // if (!host.Lower().ends_with("10088"))
host = wxString::Format("%s:10088", host); // host = wxString::Format("%s:10088", host);
} }
if (tem_host != host) { if (tem_host != host) {
//B45 //B45

View File

@@ -509,7 +509,7 @@ void PhysicalPrinterDialog::update(bool printer_change)
text_ctrl* printhost_win = printhost_field ? dynamic_cast<text_ctrl*>(printhost_field->getWindow()) : nullptr; text_ctrl* printhost_win = printhost_field ? dynamic_cast<text_ctrl*>(printhost_field->getWindow()) : nullptr;
if (!m_opened_as_connect && printhost_win && m_last_host_type != htQIDIConnect){ if (!m_opened_as_connect && printhost_win && m_last_host_type != htQIDIConnect){
m_stored_host = printhost_win->GetValue(); m_stored_host = printhost_win->GetValue();
printhost_win->SetValue(L"https://connect.prusa3d.com"); printhost_win->SetValue(L"https://connect.qidi3d.com");
} }
} else { } else {
m_printhost_browse_btn->Show(); m_printhost_browse_btn->Show();
@@ -743,6 +743,19 @@ void PhysicalPrinterDialog::OnOK(wxEvent& event)
Field* printhost_field = m_optgroup->get_field("print_host"); Field* printhost_field = m_optgroup->get_field("print_host");
text_ctrl* printhost_win = printhost_field ? dynamic_cast<text_ctrl*>(printhost_field->getWindow()) : nullptr; text_ctrl* printhost_win = printhost_field ? dynamic_cast<text_ctrl*>(printhost_field->getWindow()) : nullptr;
const auto opt = m_config->option<ConfigOptionEnum<PrintHostType>>("host_type"); const auto opt = m_config->option<ConfigOptionEnum<PrintHostType>>("host_type");
if (opt->value == htMoonraker) {
Field * printhost_field = m_optgroup->get_field("print_host");
text_ctrl *printhost_win = printhost_field ? dynamic_cast<text_ctrl *>(printhost_field->getWindow()) : nullptr;
wxString temp_host = printhost_win->GetValue();
//B55
wxString formattedHost = temp_host;
/* if (!temp_host.Lower().starts_with("http"))
wxString formattedHost = wxString::Format("http://%s", temp_host);*/
if (!formattedHost.Lower().ends_with("10088"))
formattedHost = wxString::Format("%s:10088", formattedHost);
m_optgroup->set_value("print_host", formattedHost, true);
m_optgroup->get_field("print_host")->field_changed();
}
if (opt->value == htQIDIConnect) { if (opt->value == htQIDIConnect) {
if (printhost_win && printhost_win->GetValue() != L"https://connect.qidi3d.com"){ if (printhost_win && printhost_win->GetValue() != L"https://connect.qidi3d.com"){
InfoDialog msg(this, _L("Warning"), _L("URL of QIDIConnect is different from https://connect.qidi3d.com. Do you want to continue?"), true, wxYES_NO); InfoDialog msg(this, _L("Warning"), _L("URL of QIDIConnect is different from https://connect.qidi3d.com. Do you want to continue?"), true, wxYES_NO);

View File

@@ -8167,7 +8167,15 @@ void Plater::set_bed_shape() const
auto bed_shape = p->config->option<ConfigOptionPoints>("bed_shape")->values; auto bed_shape = p->config->option<ConfigOptionPoints>("bed_shape")->values;
auto exclude_area = p->config->option<ConfigOptionPoints>("bed_exclude_area")->values; auto exclude_area = p->config->option<ConfigOptionPoints>("bed_exclude_area")->values;
set_bed_shape(bed_shape, p->config->option<ConfigOptionFloat>("max_print_height")->value,
Pointfs tem_shape = bed_shape;
tem_shape.push_back({0, 0});
for (const auto &point : exclude_area) {
tem_shape.push_back({point.x(), point.y()});
}
tem_shape.push_back({0, 0});
set_bed_shape(tem_shape, p->config->option<ConfigOptionFloat>("max_print_height")->value,
p->config->option<ConfigOptionString>("bed_custom_texture")->value, p->config->option<ConfigOptionString>("bed_custom_texture")->value,
p->config->option<ConfigOptionString>("bed_custom_model")->value, exclude_area); p->config->option<ConfigOptionString>("bed_custom_model")->value, exclude_area);
} }

View File

@@ -380,9 +380,10 @@ void PresetComboBox::open_physical_printer_url()
const PhysicalPrinter &pp = m_preset_bundle->physical_printers.get_selected_printer(); const PhysicalPrinter &pp = m_preset_bundle->physical_printers.get_selected_printer();
std::string host = pp.config.opt_string("print_host"); std::string host = pp.config.opt_string("print_host");
assert(!host.empty()); assert(!host.empty());
// B31 //B55
if (host.find(":10088") == -1) //// B31
host = host + ":10088"; //if (host.find(":10088") == -1)
// host = host + ":10088";
wxGetApp().open_browser_with_warning_dialog(host); wxGetApp().open_browser_with_warning_dialog(host);
} }

View File

@@ -360,10 +360,11 @@ void PrinterWebView::AddButton(const wxString & devi
//customButton->Bind(wxEVT_BUTTON, std::bind(&PrinterWebView::OnCustomButtonClick, this,handler)); //customButton->Bind(wxEVT_BUTTON, std::bind(&PrinterWebView::OnCustomButtonClick, this,handler));
customButton->Bind(wxEVT_BUTTON, [this, ip, customButton](wxCommandEvent &event) { customButton->Bind(wxEVT_BUTTON, [this, ip, customButton](wxCommandEvent &event) {
wxString host = ip; wxString host = ip;
//B55
if (!host.Lower().starts_with("http")) if (!host.Lower().starts_with("http"))
host = wxString::Format("http://%s", host); host = wxString::Format("http://%s", host);
if (!host.Lower().ends_with("10088")) // if (!host.Lower().ends_with("10088"))
host = wxString::Format("%s:10088", host); // host = wxString::Format("%s:10088", host);
load_url(host); load_url(host);
customButton->ResumeStatusThread(); customButton->ResumeStatusThread();
}); });
@@ -540,11 +541,13 @@ void PrinterWebView::OnAddButtonClick(wxCommandEvent &event)
std::string printer_name = printer.name; std::string printer_name = printer.name;
wxString host = printer.config.opt_string("print_host"); wxString host = printer.config.opt_string("print_host");
wxString formattedHost = wxString::Format("http://%s", host); //B55
wxString formattedHost = host;
// wxString formattedHost = wxString::Format("http://%s", host);
if (!host.Lower().starts_with("http")) if (!host.Lower().starts_with("http"))
wxString formattedHost = wxString::Format("http://%s", host); wxString formattedHost = wxString::Format("http://%s", host);
if (!formattedHost.Lower().ends_with("10088")) // if (!formattedHost.Lower().ends_with("10088"))
formattedHost = wxString::Format("%s:10088", formattedHost); // formattedHost = wxString::Format("%s:10088", formattedHost);
std::string fullname = preset_bundle.physical_printers.get_selected_full_printer_name(); std::string fullname = preset_bundle.physical_printers.get_selected_full_printer_name();
std::string preset_name = printer.get_preset_name(fullname); std::string preset_name = printer.get_preset_name(fullname);
@@ -557,8 +560,9 @@ void PrinterWebView::OnAddButtonClick(wxCommandEvent &event)
model_id = preset->config.opt_string("printer_model"); model_id = preset->config.opt_string("printer_model");
} }
boost::regex ipRegex(R"(\b(?:\d{1,3}\.){3}\d{1,3}\b)"); //boost::regex ipRegex(R"(\b(?:\d{1,3}\.){3}\d{1,3}\b)");
bool isValidIPAddress = boost::regex_match(host.ToStdString(), ipRegex); //bool isValidIPAddress = boost::regex_match(host.ToStdString(), ipRegex);
bool isValidIPAddress = true;
DynamicPrintConfig *cfg_t = &(printer.config); DynamicPrintConfig *cfg_t = &(printer.config);
UnSelectedButton(); UnSelectedButton();
@@ -760,8 +764,9 @@ void PrinterWebView::load_url(wxString& url)
//m_web = url; //m_web = url;
m_browser->LoadURL(url); m_browser->LoadURL(url);
//B55
url.Remove(0, 7); url.Remove(0, 7);
url.Remove(url.length() - 6); //url.Remove(url.length() - 6);
for (MachineListButton *button : m_buttons) { for (MachineListButton *button : m_buttons) {
if (url == (button->getIPLabel())) if (url == (button->getIPLabel()))
button->SetSelect(true); button->SetSelect(true);

View File

@@ -62,12 +62,15 @@ std::string substitute_host(const std::string& orig_addr, std::string sub_addr)
return out; return out;
} }
#endif #endif
} } // namespace
Moonraker::Moonraker(DynamicPrintConfig *config) : //B55
m_host(config->opt_string("print_host")), Moonraker::Moonraker(DynamicPrintConfig *config, bool add_port)
m_apikey(config->opt_string("printhost_apikey")), : m_host(add_port ? config->opt_string("print_host").find(":10088") == std::string::npos ? config->opt_string("print_host") + ":10088" :
m_cafile(config->opt_string("printhost_cafile")), config->opt_string("print_host") :
m_ssl_revoke_best_effort(config->opt_bool("printhost_ssl_ignore_revoke")) config->opt_string("print_host"))
, m_apikey(config->opt_string("printhost_apikey"))
, m_cafile(config->opt_string("printhost_cafile"))
, m_ssl_revoke_best_effort(config->opt_bool("printhost_ssl_ignore_revoke"))
{} {}
const char* Moonraker::get_name() const { return "Moonraker"; } const char* Moonraker::get_name() const { return "Moonraker"; }

View File

@@ -19,7 +19,8 @@ class Http;
class Moonraker : public PrintHost class Moonraker : public PrintHost
{ {
public: public:
Moonraker(DynamicPrintConfig *config); //B55
Moonraker(DynamicPrintConfig *config, bool add_port);
~Moonraker() override = default; ~Moonraker() override = default;
const char* get_name() const override; const char* get_name() const override;

View File

@@ -46,6 +46,7 @@ PrintHost* PrintHost::get_print_host(DynamicPrintConfig *config)
const auto opt = config->option<ConfigOptionEnum<PrintHostType>>("host_type"); const auto opt = config->option<ConfigOptionEnum<PrintHostType>>("host_type");
const auto host_type = opt != nullptr ? opt->value : htOctoPrint; const auto host_type = opt != nullptr ? opt->value : htOctoPrint;
//B55
switch (host_type) { switch (host_type) {
case htOctoPrint: return new OctoPrint(config); case htOctoPrint: return new OctoPrint(config);
case htDuet: return new Duet(config); case htDuet: return new Duet(config);
@@ -55,7 +56,8 @@ PrintHost* PrintHost::get_print_host(DynamicPrintConfig *config)
case htQIDILink: return new QIDILink(config); case htQIDILink: return new QIDILink(config);
case htQIDIConnect: return new QIDIConnect(config); case htQIDIConnect: return new QIDIConnect(config);
case htMKS: return new MKS(config); case htMKS: return new MKS(config);
case htMoonraker: return new Moonraker(config); case htMoonraker: return new Moonraker(config,true);
case htMoonraker2: return new Moonraker(config,false);
default: return nullptr; default: return nullptr;
} }
} else { } else {