Merge remote-tracking branch 'origin/master' into pm_anchor_bridges_on_sparse_infill

This commit is contained in:
PavelMikus 2023-03-02 15:13:53 +01:00
commit 40e8003eda
11 changed files with 64 additions and 69 deletions

View file

@ -3270,9 +3270,6 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix)
{ {
ConfigOptionDef* def; ConfigOptionDef* def;
constexpr const char * pretext_unavailable = L("Unavailable for this method.\n");
std::string pretext;
def = this->add(prefix + "support_head_front_diameter", coFloat); def = this->add(prefix + "support_head_front_diameter", coFloat);
def->label = L("Pinhead front diameter"); def->label = L("Pinhead front diameter");
def->category = L("Supports"); def->category = L("Supports");
@ -3322,13 +3319,9 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix)
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionPercent(50)); def->set_default_value(new ConfigOptionPercent(50));
pretext = "";
if (prefix == "branching")
pretext = pretext_unavailable;
def = this->add(prefix + "support_max_bridges_on_pillar", coInt); def = this->add(prefix + "support_max_bridges_on_pillar", coInt);
def->label = L("Max bridges on a pillar"); def->label = L("Max bridges on a pillar");
def->tooltip = pretext + L( def->tooltip = L(
"Maximum number of bridges that can be placed on a pillar. Bridges " "Maximum number of bridges that can be placed on a pillar. Bridges "
"hold support point pinheads and connect to pillars as small branches."); "hold support point pinheads and connect to pillars as small branches.");
def->min = 0; def->min = 0;
@ -3336,14 +3329,10 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix)
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionInt(prefix == "branching" ? 2 : 3)); def->set_default_value(new ConfigOptionInt(prefix == "branching" ? 2 : 3));
pretext = "";
if (prefix.empty())
pretext = pretext_unavailable;
def = this->add(prefix + "support_max_weight_on_model", coFloat); def = this->add(prefix + "support_max_weight_on_model", coFloat);
def->label = L("Max weight on model"); def->label = L("Max weight on model");
def->category = L("Supports"); def->category = L("Supports");
def->tooltip = pretext + L( def->tooltip = L(
"Maximum weight of sub-trees that terminate on the model instead of the print bed. The weight is the sum of the lenghts of all " "Maximum weight of sub-trees that terminate on the model instead of the print bed. The weight is the sum of the lenghts of all "
"branches emanating from the endpoint."); "branches emanating from the endpoint.");
def->sidetext = L("mm"); def->sidetext = L("mm");
@ -3351,13 +3340,9 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix)
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(10.)); def->set_default_value(new ConfigOptionFloat(10.));
pretext = "";
if (prefix == "branching")
pretext = pretext_unavailable;
def = this->add(prefix + "support_pillar_connection_mode", coEnum); def = this->add(prefix + "support_pillar_connection_mode", coEnum);
def->label = L("Pillar connection mode"); def->label = L("Pillar connection mode");
def->tooltip = pretext + L("Controls the bridge type between two neighboring pillars." def->tooltip = L("Controls the bridge type between two neighboring pillars."
" Can be zig-zag, cross (double zig-zag) or dynamic which" " Can be zig-zag, cross (double zig-zag) or dynamic which"
" will automatically switch between the first two depending" " will automatically switch between the first two depending"
" on the distance of the two pillars."); " on the distance of the two pillars.");
@ -3378,11 +3363,7 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix)
def->label = L("Pillar widening factor"); def->label = L("Pillar widening factor");
def->category = L("Supports"); def->category = L("Supports");
pretext = ""; def->tooltip =
if (prefix.empty())
pretext = pretext_unavailable;
def->tooltip = pretext +
L("Merging bridges or pillars into another pillars can " L("Merging bridges or pillars into another pillars can "
"increase the radius. Zero means no increase, one means " "increase the radius. Zero means no increase, one means "
"full increase. The exact amount of increase is unspecified and can " "full increase. The exact amount of increase is unspecified and can "
@ -3449,14 +3430,10 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix)
def->set_default_value(new ConfigOptionFloat(default_val)); def->set_default_value(new ConfigOptionFloat(default_val));
pretext = "";
if (prefix == "branching")
pretext = pretext_unavailable;
def = this->add(prefix + "support_max_pillar_link_distance", coFloat); def = this->add(prefix + "support_max_pillar_link_distance", coFloat);
def->label = L("Max pillar linking distance"); def->label = L("Max pillar linking distance");
def->category = L("Supports"); def->category = L("Supports");
def->tooltip = pretext + L("The max distance of two pillars to get linked with each other." def->tooltip = L("The max distance of two pillars to get linked with each other."
" A zero value will prohibit pillar cascading."); " A zero value will prohibit pillar cascading.");
def->sidetext = L("mm"); def->sidetext = L("mm");
def->min = 0; // 0 means no linking def->min = 0; // 0 means no linking

View file

@ -175,24 +175,20 @@ void Field::on_back_to_sys_value()
wxString Field::get_tooltip_text(const wxString& default_string) wxString Field::get_tooltip_text(const wxString& default_string)
{ {
wxString tooltip_text(""); if (m_opt.tooltip.empty())
wxString tooltip = _(m_opt.tooltip); return "";
edit_tooltip(tooltip);
std::string opt_id = m_opt_id; std::string opt_id = m_opt_id;
auto hash_pos = opt_id.find("#"); auto hash_pos = opt_id.find('#');
if (hash_pos != std::string::npos) { if (hash_pos != std::string::npos) {
opt_id.replace(hash_pos, 1,"["); opt_id.replace(hash_pos, 1,"[");
opt_id += "]"; opt_id += "]";
} }
if (tooltip.length() > 0) return from_u8(m_opt.tooltip) + "\n" + _L("default value") + "\t: " +
tooltip_text = tooltip + "\n" + _(L("default value")) + "\t: " +
(boost::iends_with(opt_id, "_gcode") ? "\n" : "") + default_string + (boost::iends_with(opt_id, "_gcode") ? "\n" : "") + default_string +
(boost::iends_with(opt_id, "_gcode") ? "" : "\n") + (boost::iends_with(opt_id, "_gcode") ? "" : "\n") +
_(L("parameter name")) + "\t: " + opt_id; _L("parameter name") + "\t: " + opt_id;
return tooltip_text;
} }
bool Field::is_matched(const std::string& string, const std::string& pattern) bool Field::is_matched(const std::string& string, const std::string& pattern)

View file

@ -1368,7 +1368,7 @@ bool GUI_App::on_init_inner()
// and wxEVT_SET_FOCUS before GUI_App::post_init is called) wasn't called before GUI_App::post_init and OpenGL wasn't initialized. // and wxEVT_SET_FOCUS before GUI_App::post_init is called) wasn't called before GUI_App::post_init and OpenGL wasn't initialized.
// Since issue #9774 Where same problem occured on MacOS Ventura, we decided to have this check on MacOS as well. // Since issue #9774 Where same problem occured on MacOS Ventura, we decided to have this check on MacOS as well.
#ifdef __linux__ || __APPLE__ #if defined(__linux__) || defined(__APPLE__)
if (!m_post_initialized && m_opengl_initialized) { if (!m_post_initialized && m_opengl_initialized) {
#else #else
if (!m_post_initialized) { if (!m_post_initialized) {

View file

@ -118,6 +118,20 @@ OptionsGroup::OptionsGroup( wxWindow* _parent, const wxString& title,
{ {
} }
Option::Option(const ConfigOptionDef& _opt, t_config_option_key id) : opt(_opt), opt_id(id)
{
if (!opt.tooltip.empty()) {
wxString tooltip;
if (opt.opt_key.rfind("branching", 0) == 0)
tooltip = _L("Unavailable for this method.") + "\n";
tooltip += _(opt.tooltip);
edit_tooltip(tooltip);
opt.tooltip = into_u8(tooltip);
}
}
void Line::clear() void Line::clear()
{ {
if (near_label_widget_win) if (near_label_widget_win)
@ -517,9 +531,8 @@ void OptionsGroup::clear(bool destroy_custom_ctrl)
Line OptionsGroup::create_single_option_line(const Option& option, const std::string& path/* = std::string()*/) const Line OptionsGroup::create_single_option_line(const Option& option, const std::string& path/* = std::string()*/) const
{ {
wxString tooltip = _(option.opt.tooltip); Line retval{ _(option.opt.label), from_u8(option.opt.tooltip) };
edit_tooltip(tooltip);
Line retval{ _(option.opt.label), tooltip };
retval.label_path = path; retval.label_path = path;
retval.append_option(option); retval.append_option(option);
return retval; return retval;

View file

@ -47,8 +47,7 @@ struct Option {
return (rhs.opt_id == this->opt_id); return (rhs.opt_id == this->opt_id);
} }
Option(const ConfigOptionDef& _opt, t_config_option_key id) : Option(const ConfigOptionDef& _opt, t_config_option_key id);
opt(_opt), opt_id(id) {}
}; };
using t_option = std::unique_ptr<Option>; //! using t_option = std::unique_ptr<Option>; //!

View file

@ -6948,18 +6948,19 @@ void Plater::send_gcode()
upload_job.printhost->get_groups(groups); upload_job.printhost->get_groups(groups);
} }
// PrusaLink specific: Query the server for the list of file groups. // PrusaLink specific: Query the server for the list of file groups.
wxArrayString storage; wxArrayString storage_paths;
wxArrayString storage_names;
{ {
wxBusyCursor wait; wxBusyCursor wait;
try { try {
upload_job.printhost->get_storage(storage); upload_job.printhost->get_storage(storage_paths, storage_names);
} catch (const Slic3r::IOError& ex) { } catch (const Slic3r::IOError& ex) {
show_error(this, ex.what(), false); show_error(this, ex.what(), false);
return; return;
} }
} }
PrintHostSendDialog dlg(default_output_file, upload_job.printhost->get_post_upload_actions(), groups, storage); PrintHostSendDialog dlg(default_output_file, upload_job.printhost->get_post_upload_actions(), groups, storage_paths, storage_names);
if (dlg.ShowModal() == wxID_OK) { if (dlg.ShowModal() == wxID_OK) {
upload_job.upload_data.upload_path = dlg.filename(); upload_job.upload_data.upload_path = dlg.filename();
upload_job.upload_data.post_action = dlg.post_action(); upload_job.upload_data.post_action = dlg.post_action();

View file

@ -38,13 +38,14 @@ static const char *CONFIG_KEY_PATH = "printhost_path";
static const char *CONFIG_KEY_GROUP = "printhost_group"; static const char *CONFIG_KEY_GROUP = "printhost_group";
static const char* CONFIG_KEY_STORAGE = "printhost_storage"; static const char* CONFIG_KEY_STORAGE = "printhost_storage";
PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUploadActions post_actions, const wxArrayString &groups, const wxArrayString& storage) PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUploadActions post_actions, const wxArrayString &groups, const wxArrayString& storage_paths, const wxArrayString& storage_names)
: MsgDialog(static_cast<wxWindow*>(wxGetApp().mainframe), _L("Send G-Code to printer host"), _L("Upload to Printer Host with the following filename:"), 0) // Set style = 0 to avoid default creation of the "OK" button. : MsgDialog(static_cast<wxWindow*>(wxGetApp().mainframe), _L("Send G-Code to printer host"), _L("Upload to Printer Host with the following filename:"), 0) // Set style = 0 to avoid default creation of the "OK" button.
// All buttons will be added later in this constructor // All buttons will be added later in this constructor
, txt_filename(new wxTextCtrl(this, wxID_ANY)) , txt_filename(new wxTextCtrl(this, wxID_ANY))
, combo_groups(!groups.IsEmpty() ? new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, groups, wxCB_READONLY) : nullptr) , combo_groups(!groups.IsEmpty() ? new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, groups, wxCB_READONLY) : nullptr)
, combo_storage(storage.GetCount() > 1 ? new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, storage, wxCB_READONLY) : nullptr) , combo_storage(storage_names.GetCount() > 1 ? new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, storage_names, wxCB_READONLY) : nullptr)
, post_upload_action(PrintHostPostUploadAction::None) , post_upload_action(PrintHostPostUploadAction::None)
, m_paths(storage_paths)
{ {
#ifdef __APPLE__ #ifdef __APPLE__
txt_filename->OSXDisableAllSmartSubstitutions(); txt_filename->OSXDisableAllSmartSubstitutions();
@ -73,15 +74,15 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUplo
auto* label_group = new wxStaticText(this, wxID_ANY, _L("Upload to storage:")); auto* label_group = new wxStaticText(this, wxID_ANY, _L("Upload to storage:"));
content_sizer->Add(label_group); content_sizer->Add(label_group);
content_sizer->Add(combo_storage, 0, wxBOTTOM, 2 * VERT_SPACING); content_sizer->Add(combo_storage, 0, wxBOTTOM, 2 * VERT_SPACING);
combo_storage->SetValue(storage.front()); combo_storage->SetValue(storage_names.front());
wxString recent_storage = from_u8(app_config->get("recent", CONFIG_KEY_STORAGE)); wxString recent_storage = from_u8(app_config->get("recent", CONFIG_KEY_STORAGE));
if (!recent_storage.empty()) if (!recent_storage.empty())
combo_storage->SetValue(recent_storage); combo_storage->SetValue(recent_storage);
} else if (storage.GetCount() == 1){ } else if (storage_names.GetCount() == 1){
// PrusaLink specific: Show which storage has been detected. // PrusaLink specific: Show which storage has been detected.
auto* label_group = new wxStaticText(this, wxID_ANY, _L("Upload to storage: ") + storage.front()); auto* label_group = new wxStaticText(this, wxID_ANY, _L("Upload to storage: ") + storage_names.front());
content_sizer->Add(label_group); content_sizer->Add(label_group);
m_preselected_storage = storage.front(); m_preselected_storage = storage_paths.front();
} }
@ -196,7 +197,9 @@ std::string PrintHostSendDialog::storage() const
{ {
if (!combo_storage) if (!combo_storage)
return GUI::format("%1%", m_preselected_storage); return GUI::format("%1%", m_preselected_storage);
return boost::nowide::narrow(combo_storage->GetValue()); if (combo_storage->GetSelection() < 0 || combo_storage->GetSelection() >= m_paths.size())
return {};
return boost::nowide::narrow(m_paths[combo_storage->GetSelection()]);
} }
void PrintHostSendDialog::EndModal(int ret) void PrintHostSendDialog::EndModal(int ret)
@ -226,8 +229,6 @@ void PrintHostSendDialog::EndModal(int ret)
MsgDialog::EndModal(ret); MsgDialog::EndModal(ret);
} }
wxDEFINE_EVENT(EVT_PRINTHOST_PROGRESS, PrintHostQueueDialog::Event); wxDEFINE_EVENT(EVT_PRINTHOST_PROGRESS, PrintHostQueueDialog::Event);
wxDEFINE_EVENT(EVT_PRINTHOST_ERROR, PrintHostQueueDialog::Event); wxDEFINE_EVENT(EVT_PRINTHOST_ERROR, PrintHostQueueDialog::Event);
wxDEFINE_EVENT(EVT_PRINTHOST_CANCEL, PrintHostQueueDialog::Event); wxDEFINE_EVENT(EVT_PRINTHOST_CANCEL, PrintHostQueueDialog::Event);

View file

@ -26,7 +26,7 @@ namespace GUI {
class PrintHostSendDialog : public GUI::MsgDialog class PrintHostSendDialog : public GUI::MsgDialog
{ {
public: public:
PrintHostSendDialog(const boost::filesystem::path &path, PrintHostPostUploadActions post_actions, const wxArrayString& groups, const wxArrayString& storage); PrintHostSendDialog(const boost::filesystem::path &path, PrintHostPostUploadActions post_actions, const wxArrayString& groups, const wxArrayString& storage_paths, const wxArrayString& storage_names);
boost::filesystem::path filename() const; boost::filesystem::path filename() const;
PrintHostPostUploadAction post_action() const; PrintHostPostUploadAction post_action() const;
std::string group() const; std::string group() const;
@ -40,6 +40,7 @@ private:
PrintHostPostUploadAction post_upload_action; PrintHostPostUploadAction post_upload_action;
wxString m_valid_suffix; wxString m_valid_suffix;
wxString m_preselected_storage; wxString m_preselected_storage;
wxArrayString m_paths;
}; };

View file

@ -273,7 +273,6 @@ bool OctoPrint::test(wxString& msg) const
return res; return res;
} }
wxString OctoPrint::get_test_ok_msg () const wxString OctoPrint::get_test_ok_msg () const
{ {
return _(L("Connection to OctoPrint works correctly.")); return _(L("Connection to OctoPrint works correctly."));
@ -685,7 +684,7 @@ bool PrusaLink::test(wxString& msg) const
return res; return res;
} }
bool PrusaLink::get_storage(wxArrayString& output) const bool PrusaLink::get_storage(wxArrayString& storage_path, wxArrayString& storage_name) const
{ {
const char* name = get_name(); const char* name = get_name();
@ -693,17 +692,22 @@ bool PrusaLink::get_storage(wxArrayString& output) const
auto url = make_url("api/v1/storage"); auto url = make_url("api/v1/storage");
wxString error_msg; wxString error_msg;
struct StorageInfo{ struct StorageInfo {
wxString path;
wxString name; wxString name;
bool read_only; bool read_only = false;
long long free_space; long long free_space = -1;
}; };
std::vector<StorageInfo> storage; std::vector<StorageInfo> storage;
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Get storage at: %2%") % name % url; BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Get storage at: %2%") % name % url;
wxString wlang = GUI::wxGetApp().current_language_code();
std::string lang = GUI::format(wlang.SubString(0, 1));
auto http = Http::get(std::move(url)); auto http = Http::get(std::move(url));
set_auth(http); set_auth(http);
http.header("Accept-Language", lang);
http.on_error([&](std::string body, std::string error, unsigned status) { http.on_error([&](std::string body, std::string error, unsigned status) {
BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting storage: %2%, HTTP %3%, body: `%4%`") % name % error % status % body; BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting storage: %2%, HTTP %3%, body: `%4%`") % name % error % status % body;
error_msg = L"\n\n" + boost::nowide::widen(error); error_msg = L"\n\n" + boost::nowide::widen(error);
@ -731,6 +735,7 @@ bool PrusaLink::get_storage(wxArrayString& output) const
} }
// each storage has own subtree of storage_list // each storage has own subtree of storage_list
for (const auto& section : ptree.front().second) { for (const auto& section : ptree.front().second) {
const auto name = section.second.get_optional<std::string>("name");
const auto path = section.second.get_optional<std::string>("path"); const auto path = section.second.get_optional<std::string>("path");
const auto space = section.second.get_optional<std::string>("free_space"); const auto space = section.second.get_optional<std::string>("free_space");
const auto read_only = section.second.get_optional<bool>("read_only"); const auto read_only = section.second.get_optional<bool>("read_only");
@ -738,7 +743,8 @@ bool PrusaLink::get_storage(wxArrayString& output) const
const auto available = section.second.get_optional<bool>("available"); const auto available = section.second.get_optional<bool>("available");
if (path && (!available || *available)) { if (path && (!available || *available)) {
StorageInfo si; StorageInfo si;
si.name = boost::nowide::widen(*path); si.path = boost::nowide::widen(*path);
si.name = name ? boost::nowide::widen(*name) : wxString();
// If read_only is missing, assume it is NOT read only. // If read_only is missing, assume it is NOT read only.
// si.read_only = read_only ? *read_only : false; // version without "ro" // si.read_only = read_only ? *read_only : false; // version without "ro"
si.read_only = (read_only ? *read_only : (ro ? *ro : false)); si.read_only = (read_only ? *read_only : (ro ? *ro : false));
@ -759,16 +765,17 @@ bool PrusaLink::get_storage(wxArrayString& output) const
.perform_sync(); .perform_sync();
for (const auto& si : storage) { for (const auto& si : storage) {
if (!si.read_only && si.free_space > 0) if (!si.read_only && si.free_space > 0) {
output.push_back(si.name); storage_path.push_back(si.path);
storage_name.push_back(si.name);
}
} }
if (res && output.empty()) if (res && storage_path.empty()) {
{
if (!storage.empty()) { // otherwise error_msg is already filled if (!storage.empty()) { // otherwise error_msg is already filled
error_msg = L"\n\n" + _L("Storages found:") + L" \n"; error_msg = L"\n\n" + _L("Storages found:") + L" \n";
for (const auto& si : storage) { for (const auto& si : storage) {
error_msg += si.name + L" : " + (si.read_only ? _L("read only") : _L("no free space")) + L"\n"; error_msg += si.path + L" : " + (si.read_only ? _L("read only") : _L("no free space")) + L"\n";
} }
} }
std::string message = GUI::format(_L("Upload has failed. There is no suitable storage found at %1%.%2%"), m_host, error_msg); std::string message = GUI::format(_L("Upload has failed. There is no suitable storage found at %1%.%2%"), m_host, error_msg);

View file

@ -94,7 +94,7 @@ public:
virtual PrintHostPostUploadActions get_post_upload_actions() const override { return PrintHostPostUploadAction::StartPrint; } virtual PrintHostPostUploadActions get_post_upload_actions() const override { return PrintHostPostUploadAction::StartPrint; }
// gets possible storage to be uploaded to. This allows different printer to have different storage. F.e. local vs sdcard vs usb. // gets possible storage to be uploaded to. This allows different printer to have different storage. F.e. local vs sdcard vs usb.
bool get_storage(wxArrayString& /* storage */) const override; bool get_storage(wxArrayString& storage_path, wxArrayString& storage_name) const override;
protected: protected:
bool test(wxString& curl_msg) const override; bool test(wxString& curl_msg) const override;
bool validate_version_text(const boost::optional<std::string>& version_text) const override; bool validate_version_text(const boost::optional<std::string>& version_text) const override;

View file

@ -66,7 +66,7 @@ public:
virtual bool get_printers(wxArrayString & /* printers */) const { return false; } virtual bool get_printers(wxArrayString & /* printers */) const { return false; }
// Support for PrusaLink uploading to different storage. Not supported by other print hosts. // Support for PrusaLink uploading to different storage. Not supported by other print hosts.
// Returns false if not supported or fail. // Returns false if not supported or fail.
virtual bool get_storage(wxArrayString& /* storage */) const { return false; } virtual bool get_storage(wxArrayString& /*storage_path*/, wxArrayString& /*storage_name*/) const { return false; }
static PrintHost* get_print_host(DynamicPrintConfig *config); static PrintHost* get_print_host(DynamicPrintConfig *config);