Prusa 2.7.1

This commit is contained in:
sunsets
2023-12-28 10:57:18 +08:00
parent 0a3c63dcb1
commit ab227dba3c
20 changed files with 197 additions and 151 deletions

View File

@@ -198,9 +198,10 @@ wxString Field::get_tooltip_text(const wxString& default_string)
opt_id += "]";
}
bool newline_after_name = boost::iends_with(opt_id, "_gcode") && opt_id != "binary_gcode";
return from_u8(m_opt.tooltip) + "\n" + _L("default value") + "\t: " +
(boost::iends_with(opt_id, "_gcode") ? "\n" : "") + default_string +
(boost::iends_with(opt_id, "_gcode") ? "" : "\n") +
(newline_after_name ? "\n" : "") + default_string +
(newline_after_name ? "" : "\n") +
_L("parameter name") + "\t: " + opt_id;
}

View File

@@ -2023,7 +2023,7 @@ void GLCanvas3D::render()
}
#if ENABLE_BINARIZED_GCODE_DEBUG_WINDOW
if (wxGetApp().plater()->is_view3D_shown() && current_printer_technology() != ptSLA && fff_print()->config().gcode_binary)
if (wxGetApp().plater()->is_view3D_shown() && current_printer_technology() != ptSLA && fff_print()->config().binary_gcode)
show_binary_gcode_debug_window();
#endif // ENABLE_BINARIZED_GCODE_DEBUG_WINDOW
std::string tooltip;

View File

@@ -220,7 +220,7 @@ bool GLGizmoSVG::create_volume(std::string_view svg_file, const Vec2d &mouse_pos
}
bool GLGizmoSVG::is_svg(const ModelVolume &volume) {
return volume.emboss_shape.has_value();
return volume.emboss_shape.has_value() && volume.emboss_shape->svg_file.has_value();
}
bool GLGizmoSVG::is_svg_object(const ModelVolume &volume) {
@@ -1174,6 +1174,7 @@ void GLGizmoSVG::set_volume_by_selection()
// calculate scale for height and depth inside of scaled object instance
calculate_scale(); // must be before calculation of tesselation
// checking that exist is inside of function "is_svg"
EmbossShape &es = *volume->emboss_shape;
EmbossShape::SvgFile &svg_file = *es.svg_file;
if (svg_file.image == nullptr) {

View File

@@ -264,6 +264,13 @@ ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg, const std::funct
{
create(m_content, 84);
}
HtmlCapableRichMessageDialog::HtmlCapableRichMessageDialog(wxWindow *parent,
const wxString &msg,
const wxString &caption,
long style,
const std::function<void(const std::string &)> &on_link_clicked)
: RichMessageDialogBase(parent, HtmlContent{msg, false, true, on_link_clicked}, caption, style)
{}
// WarningDialog
WarningDialog::WarningDialog(wxWindow *parent,
@@ -289,19 +296,29 @@ MessageDialog::MessageDialog(wxWindow* parent,
add_msg_content(this, content_sizer, HtmlContent{ get_wraped_wxString(message) });
finalize();
}
#endif
// RichMessageDialog
// RichMessageDialogBase
RichMessageDialog::RichMessageDialog(wxWindow* parent,
RichMessageDialogBase::RichMessageDialogBase(wxWindow* parent,
const wxString& message,
const wxString& caption/* = wxEmptyString*/,
long style/* = wxOK*/)
: RichMessageDialogBase(parent, HtmlContent{get_wraped_wxString(message)}, caption, style)
{}
RichMessageDialogBase::RichMessageDialogBase(wxWindow* parent, const HtmlContent& content, const wxString& caption, long style)
: MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, wxEmptyString, style)
{
add_msg_content(this, content_sizer, HtmlContent{ get_wraped_wxString(message) });
m_content = content; // We need a copy for the on_link_clicked lambda.
add_msg_content(this, content_sizer, m_content);
#ifdef _WIN32 // See comment in the header where m_checkBox is defined.
m_checkBox = new ::CheckBox(this, m_checkBoxText);
#else
m_checkBox = new wxCheckBox(this, wxID_ANY, m_checkBoxText);
#endif
wxGetApp().UpdateDarkUI(m_checkBox);
m_checkBox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) { m_checkBoxValue = m_checkBox->GetValue(); });
@@ -310,7 +327,7 @@ RichMessageDialog::RichMessageDialog(wxWindow* parent,
finalize();
}
int RichMessageDialog::ShowModal()
int RichMessageDialogBase::ShowModal()
{
if (m_checkBoxText.IsEmpty())
m_checkBox->Hide();
@@ -322,7 +339,6 @@ int RichMessageDialog::ShowModal()
return wxDialog::ShowModal();
}
#endif
// InfoDialog

View File

@@ -101,58 +101,31 @@ public:
wxString get_wraped_wxString(const wxString& text_in, size_t line_len = 80);
#ifdef _WIN32
// Generic static line, used intead of wxStaticLine
class StaticLine: public wxTextCtrl
{
public:
StaticLine( wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxLI_HORIZONTAL,
const wxString& name = wxString::FromAscii(wxTextCtrlNameStr))
: wxTextCtrl(parent, id, wxEmptyString, pos, size!=wxDefaultSize ? size : (style == wxLI_HORIZONTAL ? wxSize(10, 1) : wxSize(1, 10)), wxSIMPLE_BORDER, wxDefaultValidator, name)
{
this->Enable(false);
}
~StaticLine() {}
};
// Generic message dialog, used intead of wxMessageDialog
class MessageDialog : public MsgDialog
{
public:
// NOTE! Don't change a signature of contsrucor. It have to be tha same as for wxMessageDialog
MessageDialog( wxWindow *parent,
const wxString& message,
const wxString& caption = wxEmptyString,
long style = wxOK);
MessageDialog(MessageDialog&&) = delete;
MessageDialog(const MessageDialog&) = delete;
MessageDialog &operator=(MessageDialog&&) = delete;
MessageDialog &operator=(const MessageDialog&) = delete;
virtual ~MessageDialog() = default;
};
// Generic rich message dialog, used intead of wxRichMessageDialog
class RichMessageDialog : public MsgDialog
class RichMessageDialogBase : public MsgDialog
{
// Using CheckBox causes some weird sizer-related issues on Linux and macOS. To get around the problem before
// we find a better fix, we will fallback to wxCheckBox in this dialog. This makes little difference for most dialogs,
// We currently only use this class as a base for HtmlCapableRichMessageDialog on Linux and macOS. The normal
// RichMessageDialog is just an alias for wxRichMessageDialog on these platforms.
#ifdef _WIN32
CheckBox* m_checkBox{ nullptr };
#else
wxCheckBox* m_checkBox{ nullptr };
#endif
wxString m_checkBoxText;
bool m_checkBoxValue{ false };
public:
// NOTE! Don't change a signature of contsrucor. It have to be tha same as for wxRichMessageDialog
RichMessageDialog( wxWindow *parent,
const wxString& message,
const wxString& caption = wxEmptyString,
long style = wxOK);
RichMessageDialog(RichMessageDialog&&) = delete;
RichMessageDialog(const RichMessageDialog&) = delete;
RichMessageDialog &operator=(RichMessageDialog&&) = delete;
RichMessageDialog &operator=(const RichMessageDialog&) = delete;
virtual ~RichMessageDialog() = default;
RichMessageDialogBase(wxWindow* parent, const wxString& message, const wxString& caption = wxEmptyString, long style = wxOK);
RichMessageDialogBase(wxWindow* parent, const HtmlContent& content, const wxString& caption = wxEmptyString, long style = wxOK);
RichMessageDialogBase(RichMessageDialogBase&&) = delete;
RichMessageDialogBase(const RichMessageDialogBase&) = delete;
RichMessageDialogBase &operator=(RichMessageDialogBase&&) = delete;
RichMessageDialogBase &operator=(const RichMessageDialogBase&) = delete;
virtual ~RichMessageDialogBase() = default;
int ShowModal() override;
@@ -273,7 +246,44 @@ private:
m_ok,
m_cancel,
m_help;
HtmlContent m_content;
};
#ifdef _WIN32
// Generic static line, used intead of wxStaticLine
class StaticLine: public wxTextCtrl
{
public:
StaticLine( wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxLI_HORIZONTAL,
const wxString& name = wxString::FromAscii(wxTextCtrlNameStr))
: wxTextCtrl(parent, id, wxEmptyString, pos, size!=wxDefaultSize ? size : (style == wxLI_HORIZONTAL ? wxSize(10, 1) : wxSize(1, 10)), wxSIMPLE_BORDER, wxDefaultValidator, name)
{
this->Enable(false);
}
~StaticLine() {}
};
// Generic message dialog, used intead of wxMessageDialog
class MessageDialog : public MsgDialog
{
public:
// NOTE! Don't change a signature of contsrucor. It have to be tha same as for wxMessageDialog
MessageDialog(wxWindow *parent,
const wxString& message,
const wxString& caption = wxEmptyString,
long style = wxOK);
MessageDialog(MessageDialog &&) = delete;
MessageDialog(const MessageDialog &) = delete;
MessageDialog &operator=(MessageDialog &&) = delete;
MessageDialog &operator=(const MessageDialog &) = delete;
virtual ~MessageDialog() = default;
};
using RichMessageDialog = RichMessageDialogBase;
#else
// just a wrapper for wxStaticLine to use the same code on all platforms
class StaticLine : public wxStaticLine
@@ -315,6 +325,15 @@ public:
};
#endif
class HtmlCapableRichMessageDialog : public RichMessageDialogBase
{
public:
HtmlCapableRichMessageDialog(wxWindow *parent, const wxString &msg, const wxString& caption, long style, const std::function<void(const std::string &)> &on_link_clicked);
~HtmlCapableRichMessageDialog() {}
private:
HtmlContent m_content;
};
// Generic info dialog, used for displaying exceptions
class InfoDialog : public MsgDialog
{

View File

@@ -964,7 +964,7 @@ Sidebar::Sidebar(Plater *parent)
enable_buttons(false);
auto *btns_sizer = new wxBoxSizer(wxVERTICAL);
auto *btns_sizer = new wxBoxSizer(wxHORIZONTAL);
auto* complect_btns_sizer = new wxBoxSizer(wxHORIZONTAL);
complect_btns_sizer->Add(p->btn_export_gcode, 1, wxEXPAND);
@@ -973,8 +973,8 @@ Sidebar::Sidebar(Plater *parent)
// complect_btns_sizer->Add(p->btn_eject_device);
btns_sizer->Add(p->btn_reslice, 0, wxEXPAND | wxTOP, margin_5);
btns_sizer->Add(complect_btns_sizer, 0, wxEXPAND | wxTOP, margin_5);
btns_sizer->Add(p->btn_reslice, 1, wxEXPAND | wxTOP | wxBOTTOM, margin_5);
btns_sizer->Add(complect_btns_sizer, 1, wxEXPAND | wxTOP | wxBOTTOM, margin_5);
auto *sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(p->scrolled, 1, wxEXPAND);
@@ -3333,6 +3333,10 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
// bitmap of enum UpdateBackgroundProcessReturnState
unsigned int return_state = 0;
// Get the config ready. The binary gcode flag depends on Preferences, which the backend has no access to.
DynamicPrintConfig full_config = wxGetApp().preset_bundle->full_config();
if (full_config.has("binary_gcode")) // needed for SLA
full_config.set("binary_gcode", bool(full_config.opt_bool("binary_gcode") & wxGetApp().app_config->get_bool("use_binary_gcode_when_supported")));
// If the update_background_process() was not called by the timer, kill the timer,
// so the update_restart_background_process() will not be called again in vain.
background_process_timer.Stop();
@@ -3340,7 +3344,7 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
update_print_volume_state();
// Apply new config to the possibly running background task.
bool was_running = background_process.running();
Print::ApplyStatus invalidated = background_process.apply(q->model(), wxGetApp().preset_bundle->full_config());
Print::ApplyStatus invalidated = background_process.apply(q->model(), full_config);
// Just redraw the 3D canvas without reloading the scene to consume the update of the layer height profile.
if (view3D->is_layers_editing_enabled())
@@ -6642,7 +6646,7 @@ ProjectDropDialog::ProjectDropDialog(const std::string& filename)
main_sizer->Add(stb_sizer, 1, wxEXPAND | wxRIGHT | wxLEFT, 10);
wxBoxSizer* bottom_sizer = new wxBoxSizer(wxHORIZONTAL);
wxCheckBox* check = new wxCheckBox(this, wxID_ANY, _L("Don't show again"));
::CheckBox* check = new ::CheckBox(this, _L("Don't show again"));
check->Bind(wxEVT_CHECKBOX, [](wxCommandEvent& evt) {
wxGetApp().app_config->set("show_drop_project_dialog", evt.IsChecked() ? "0" : "1");
});
@@ -7126,14 +7130,14 @@ static wxString check_binary_vs_ascii_gcode_extension(PrinterTechnology pt, cons
if (binary_output && ascii_extension) {
// TRN The placeholder %1% is the file extension the user has selected.
err_out = format_wxstr(_L("Cannot save binary G-code with %1% extension.\n\n"
"Use <a href=%2%>a different extension</a> or disable <a href=%3%>binary G-code export</a> "
"in Print Settings."), ext, "output_filename_format;print", "gcode_binary;print");
"Use a different extension or disable <a href=%2%>binary G-code export</a> "
"in Printer Settings."), ext, "binary_gcode;printer");
}
if (!binary_output && binary_extension) {
// TRN The placeholder %1% is the file extension the user has selected.
err_out = format_wxstr(_L("Cannot save ASCII G-code with %1% extension.\n\n"
"Use <a href=%2%>a different extension</a> or enable <a href=%3%>binary G-code export</a> "
"in Print Settings."), ext, "output_filename_format;print", "gcode_binary;print");
"Use a different extension or enable <a href=%2%>binary G-code export</a> "
"in Printer Settings."), ext, "binary_gcode;printer");
}
}
return err_out;
@@ -7157,9 +7161,15 @@ static void alert_when_exporting_binary_gcode(bool binary_output, const std::str
const std::string option_key = "dont_warn_about_firmware_version_when_exporting_binary_gcode";
if (app_config->get(option_key) != "1") {
RichMessageDialog dialog(parent, _L("You are exporting binary G-code for a Prusa printer. Please, make sure that your printer "
"is running firmware version 5.1.0-alpha2 or later. Older firmwares are not able to handle binary G-codes."),
_L("Exporting binary G-code"), wxICON_WARNING | wxOK);
const wxString url = "https://qidi.io/binary-gcode";
HtmlCapableRichMessageDialog dialog(parent,
format_wxstr(_L("You are exporting binary G-code for a QIDI printer. "
"Binary G-code enables significantly faster uploads. "
"Ensure that your printer is running firmware version 5.1.0 or newer, as older versions do not support binary G-codes.\n\n"
"To learn more about binary G-code, visit <a href=%1%>%1%</a>."),
url),
_L("Warning"), wxOK,
[&url](const std::string&) { wxGetApp().open_browser_with_warning_dialog(url); });
dialog.ShowCheckBox(_L("Don't show again"));
if (dialog.ShowModal() == wxID_OK && dialog.IsCheckBoxChecked())
app_config->set(option_key, "1");
@@ -7229,7 +7239,11 @@ void Plater::export_gcode(bool prefer_removable)
_L("The following characters are not allowed by a FAT file system:") + " <>:/\\|?*\"";
return true;
}
err_out = check_binary_vs_ascii_gcode_extension(printer_technology(), ext, wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("gcode_binary"));
if (this->printer_technology() == ptFFF) {
bool supports_binary = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_bool("binary_gcode");
bool uses_binary = wxGetApp().app_config->get_bool("use_binary_gcode_when_supported");
err_out = check_binary_vs_ascii_gcode_extension(printer_technology(), ext, supports_binary && uses_binary);
}
return !err_out.IsEmpty();
};
@@ -7237,8 +7251,10 @@ void Plater::export_gcode(bool prefer_removable)
if (check_for_error(output_path, error_str)) {
ErrorDialog(this, error_str, [this](const std::string& key) -> void { sidebar().jump_to_option(key); }).ShowModal();
output_path.clear();
} else {
alert_when_exporting_binary_gcode(wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("gcode_binary"),
} else if (printer_technology() == ptFFF) {
bool supports_binary = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_bool("binary_gcode");
bool uses_binary = wxGetApp().app_config->get_bool("use_binary_gcode_when_supported");
alert_when_exporting_binary_gcode(supports_binary && uses_binary,
wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_string("printer_notes"));
}
}
@@ -7785,18 +7801,21 @@ void Plater::send_gcode()
PrintHostSendDialog dlg(default_output_file, upload_job.printhost->get_post_upload_actions(), groups, storage_paths, storage_names);
if (dlg.ShowModal() == wxID_OK) {
{
if (printer_technology() == ptFFF) {
const std::string ext = boost::algorithm::to_lower_copy(dlg.filename().extension().string());
const bool binary_output = wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("gcode_binary");
const bool binary_output = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_bool("binary_gcode") &&
wxGetApp().app_config->get_bool("use_binary_gcode_when_supported");
const wxString error_str = check_binary_vs_ascii_gcode_extension(printer_technology(), ext, binary_output);
if (! error_str.IsEmpty()) {
ErrorDialog(this, error_str, t_kill_focus([](const std::string& key) -> void { wxGetApp().sidebar().jump_to_option(key); })).ShowModal();
return;
}
bool supports_binary = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_bool("binary_gcode");
bool uses_binary = wxGetApp().app_config->get_bool("use_binary_gcode_when_supported");
alert_when_exporting_binary_gcode(supports_binary && uses_binary,
wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_string("printer_notes"));
}
alert_when_exporting_binary_gcode(wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("gcode_binary"),
wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_string("printer_notes"));
upload_job.upload_data.upload_path = dlg.filename();
upload_job.upload_data.post_action = dlg.post_action();
upload_job.upload_data.group = dlg.group();

View File

@@ -616,6 +616,10 @@ void PreferencesDialog::build()
};
append_bool_option(m_optgroup_other, "use_binary_gcode_when_supported", L("Use binary G-code when the printer supports it"),
L("If the 'Supports binary G-code' option is enabled in Printer Settings, "
"checking this option will result in the export of G-code in binary format."),
app_config->get_bool("use_binary_gcode_when_supported"));
append_bool_option(m_optgroup_other, "suppress_hyperlinks",
L("Suppress to open hyperlink in browser"),
L("If enabled, QIDISlicer will not open a hyperlinks in your browser."),

View File

@@ -1698,34 +1698,8 @@ void TabPrint::build()
Option option = optgroup->get_option("output_filename_format");
option.opt.full_width = true;
optgroup->append_single_option_line(option);
optgroup->append_single_option_line("gcode_binary");
optgroup->m_on_change = [this](const t_config_option_key& opt_key, boost::any value)
{
if (opt_key == "gcode_binary") {
const bool is_binary = m_config->opt_bool("gcode_binary");
std::string output_filename_format = m_config->opt_string("output_filename_format");
bool modified = false;
if (is_binary && boost::iends_with(output_filename_format, ".gcode")) {
output_filename_format = output_filename_format.substr(0, output_filename_format.length() - 5) + "bgcode";
modified = true;
}
else if (!is_binary && boost::iends_with(output_filename_format, ".bgcode")) {
output_filename_format = output_filename_format.substr(0, output_filename_format.length() - 6) + "gcode";
modified = true;
}
if (modified) {
DynamicPrintConfig new_conf = *m_config;
auto off_option = static_cast<ConfigOptionString*>(m_config->option("output_filename_format")->clone());
off_option->value = output_filename_format;
new_conf.set_key_value("output_filename_format", off_option);
load_config(new_conf);
}
}
update_dirty();
update();
};
optgroup = page->new_optgroup(L("Other"));
@@ -2752,6 +2726,7 @@ void TabPrinter::build_fff()
optgroup->append_single_option_line("silent_mode");
optgroup->append_single_option_line("remaining_times");
optgroup->append_single_option_line("binary_gcode");
optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
wxTheApp->CallAfter([this, opt_key, value]() {