Merge branch 'master' into fs_svg_SPE-1517

This commit is contained in:
Filip Sykala - NTB T15p 2023-09-18 12:19:36 +02:00
commit 66c2011d65
8 changed files with 57 additions and 22 deletions

View File

@ -1,4 +1,5 @@
min_slic3r_version = 2.6.0-alpha0
1.0.4 Updated compatible printer condition.
1.0.3 Updated compatible printer condition.
1.0.2 Updated compatible printer conditions.
1.0.1 Added Prusament PETG Carbon Fiber, Fiberthree F3 PA-GF30 Pro.

View File

@ -2,7 +2,7 @@
[vendor]
name = Templates
config_version = 1.0.3
config_version = 1.0.4
config_update_url = https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/Templates/
templates_profile = 1
@ -11,7 +11,7 @@ templates_profile = 1
[filament:*common*]
cooling = 1
compatible_printers =
compatible_printers_condition = printer_notes!~/.*PRINTER_VENDOR_TRILAB.*/ and printer_notes!~/.*PRINTER_MODEL_MK4IS.*/ and ! (printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and num_extruders>1)
compatible_printers_condition = printer_notes!~/.*NO_TEMPLATES.*/ and printer_notes!~/.*PRINTER_VENDOR_TRILAB.*/ and printer_notes!~/.*PRINTER_MODEL_MK4IS.*/ and ! (printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and num_extruders>1)
end_filament_gcode = "; Filament-specific end gcode"
extrusion_multiplier = 1
filament_loading_speed = 14

View File

@ -904,6 +904,10 @@ size_t ConfigBase::load_from_gcode_string_legacy(ConfigBase& config, const char*
end = start;
}
// Do legacy conversion on a completely loaded dictionary.
// Perform composite conversions, for example merging multiple keys into one key.
config.handle_legacy_composite();
return num_key_value_pairs;
}
@ -1073,6 +1077,10 @@ ConfigSubstitutions ConfigBase::load_from_gcode_file(const std::string &filename
if (key_value_pairs < 80)
throw Slic3r::RuntimeError(format("Suspiciously low number of configuration values extracted from %1%: %2%", filename, key_value_pairs));
// Do legacy conversion on a completely loaded dictionary.
// Perform composite conversions, for example merging multiple keys into one key.
this->handle_legacy_composite();
return std::move(substitutions_ctxt.substitutions);
}
@ -1114,6 +1122,9 @@ ConfigSubstitutions ConfigBase::load_from_binary_gcode_file(const std::string& f
this->set_deserialize(key, value, substitutions_ctxt);
}
// Do legacy conversion on a completely loaded dictionary.
// Perform composite conversions, for example merging multiple keys into one key.
this->handle_legacy_composite();
return std::move(substitutions_ctxt.substitutions);
}

View File

@ -192,7 +192,7 @@ std::string get_error_string(const ThumbnailErrors& errors)
std::string error_str;
if (errors.has(ThumbnailError::InvalidVal))
error_str += "\n - " + format("Invalid input format. Expected vector of dimensions in the following format: \"%1%\"", "XxYxEXT, XxYxEXT, ...");
error_str += "\n - " + format("Invalid input format. Expected vector of dimensions in the following format: \"%1%\"", "XxY/EXT, XxY/EXT, ...");
if (errors.has(ThumbnailError::OutOfRange))
error_str += "\n - Input value is out of range";
if (errors.has(ThumbnailError::InvalidExt))

View File

@ -310,7 +310,7 @@ void PrintConfigDef::init_common_params()
def = this->add("thumbnails", coString);
def->label = L("G-code thumbnails");
def->tooltip = L("Picture sizes to be stored into a .gcode and .sl1 / .sl1s files, in the following format: \"XxYxEXT, XxYxEXT, ...\"");
def->tooltip = L("Picture sizes to be stored into a .gcode and .sl1 / .sl1s files, in the following format: \"XxY/EXT, XxY/EXT, ...\"");
def->mode = comExpert;
def->gui_type = ConfigOptionDef::GUIType::one_string;
def->set_default_value(new ConfigOptionString());

View File

@ -382,7 +382,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
set_value(str_out, true);
wxString error_str;
if (errors.has(ThumbnailError::InvalidVal))
error_str += format_wxstr(_L("Invalid input format. Expected vector of dimensions in the following format: \"%1%\""), "XxYxEXT, XxYxEXT, ...");
error_str += format_wxstr(_L("Invalid input format. Expected vector of dimensions in the following format: \"%1%\""), "XxY/EXT, XxY/EXT, ...");
if (errors.has(ThumbnailError::OutOfRange)) {
if (!error_str.empty())
error_str += "\n\n";

View File

@ -4544,22 +4544,24 @@ void SubstitutionManager::init(DynamicPrintConfig* config, wxWindow* parent, wxF
m_parent = parent;
m_grid_sizer = grid_sizer;
m_em = em_unit(parent);
m_substitutions = m_config->option<ConfigOptionStrings>("gcode_substitutions")->values;
}
void SubstitutionManager::validate_lenth()
{
std::vector<std::string>& substitutions = m_config->option<ConfigOptionStrings>("gcode_substitutions")->values;
if ((substitutions.size() % 4) != 0) {
if ((m_substitutions.size() % 4) != 0) {
WarningDialog(m_parent, "Value of gcode_substitutions parameter will be cut to valid length",
"Invalid length of gcode_substitutions parameter").ShowModal();
substitutions.resize(substitutions.size() - (substitutions.size() % 4));
m_substitutions.resize(m_substitutions.size() - (m_substitutions.size() % 4));
// save changes from m_substitutions to config
m_config->option<ConfigOptionStrings>("gcode_substitutions")->values = m_substitutions;
}
}
bool SubstitutionManager::is_compatibile_with_ui()
{
const std::vector<std::string>& substitutions = m_config->option<ConfigOptionStrings>("gcode_substitutions")->values;
if (int(substitutions.size() / 4) != m_grid_sizer->GetEffectiveRowsCount() - 1) {
if (int(m_substitutions.size() / 4) != m_grid_sizer->GetEffectiveRowsCount() - 1) {
ErrorDialog(m_parent, "Invalid compatibility between UI and BE", false).ShowModal();
return false;
}
@ -4568,8 +4570,7 @@ bool SubstitutionManager::is_compatibile_with_ui()
bool SubstitutionManager::is_valid_id(int substitution_id, const wxString& message)
{
const std::vector<std::string>& substitutions = m_config->option<ConfigOptionStrings>("gcode_substitutions")->values;
if (int(substitutions.size() / 4) < substitution_id) {
if (int(m_substitutions.size() / 4) < substitution_id) {
ErrorDialog(m_parent, message, false).ShowModal();
return false;
}
@ -4600,8 +4601,11 @@ void SubstitutionManager::delete_substitution(int substitution_id)
return;
// delete substitution
std::vector<std::string>& substitutions = m_config->option<ConfigOptionStrings>("gcode_substitutions")->values;
substitutions.erase(std::next(substitutions.begin(), substitution_id * 4), std::next(substitutions.begin(), substitution_id * 4 + 4));
m_substitutions.erase(std::next(m_substitutions.begin(), substitution_id * 4), std::next(m_substitutions.begin(), substitution_id * 4 + 4));
// save changes from m_substitutions to config
m_config->option<ConfigOptionStrings>("gcode_substitutions")->values = m_substitutions;
call_ui_update();
// update grid_sizer
@ -4620,15 +4624,16 @@ void SubstitutionManager::add_substitution( int substitution_id,
if (substitution_id < 0) {
if (m_grid_sizer->IsEmpty()) {
create_legend();
substitution_id = 0;
}
substitution_id = m_grid_sizer->GetEffectiveRowsCount() - 1;
// create new substitution
// it have to be added to config too
std::vector<std::string>& substitutions = m_config->option<ConfigOptionStrings>("gcode_substitutions")->values;
for (size_t i = 0; i < 4; i ++)
substitutions.push_back(std::string());
m_substitutions.push_back(std::string());
// save changes from config to m_substitutions
m_config->option<ConfigOptionStrings>("gcode_substitutions")->values = m_substitutions;
call_after_layout = true;
}
@ -4690,6 +4695,14 @@ void SubstitutionManager::add_substitution( int substitution_id,
auto chb_match_single_line = new wxCheckBox(m_parent, wxID_ANY, _L("Match single line"));
chb_match_single_line->SetValue(match_single_line);
chb_match_single_line->Show(regexp);
chb_match_single_line->Bind(wxEVT_SHOW, [chb_match_single_line, chb_regexp](wxShowEvent& evt) {
if (evt.IsShown() && !chb_regexp->GetValue()) {
// To avoid a case, when ShowAll() is called for m_grid_sizer but chb_match_single_line have to be hidden
chb_match_single_line->Hide();
}
});
params_sizer->Add(chb_match_single_line, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT, m_em);
for (wxCheckBox* chb : std::initializer_list<wxCheckBox*>{ chb_regexp, chb_case_insensitive, chb_whole_word, chb_match_single_line }) {
@ -4725,10 +4738,17 @@ void SubstitutionManager::add_substitution( int substitution_id,
void SubstitutionManager::update_from_config()
{
std::vector<std::string>& subst = m_config->option<ConfigOptionStrings>("gcode_substitutions")->values;
if (m_substitutions == subst && m_grid_sizer->IsShown(1)) {
// "gcode_substitutions" values didn't changed in config. There is no need to update/recreate controls
return;
}
m_substitutions = subst;
if (!m_grid_sizer->IsEmpty())
m_grid_sizer->Clear(true);
std::vector<std::string>& subst = m_config->option<ConfigOptionStrings>("gcode_substitutions")->values;
if (subst.empty())
hide_delete_all_btn();
else
@ -4745,6 +4765,7 @@ void SubstitutionManager::update_from_config()
void SubstitutionManager::delete_all()
{
m_substitutions.clear();
m_config->option<ConfigOptionStrings>("gcode_substitutions")->values.clear();
call_ui_update();
@ -4756,13 +4777,13 @@ void SubstitutionManager::delete_all()
void SubstitutionManager::edit_substitution(int substitution_id, int opt_pos, const std::string& value)
{
std::vector<std::string>& substitutions = m_config->option<ConfigOptionStrings>("gcode_substitutions")->values;
validate_lenth();
if(!is_compatibile_with_ui() || !is_valid_id(substitution_id, "Invalid substitution_id to edit"))
return;
substitutions[substitution_id * 4 + opt_pos] = value;
m_substitutions[substitution_id * 4 + opt_pos] = value;
// save changes from m_substitutions to config
m_config->option<ConfigOptionStrings>("gcode_substitutions")->values = m_substitutions;
call_ui_update();
}

View File

@ -70,6 +70,8 @@ class SubstitutionManager
std::function<void()> m_cb_edited_substitution{ nullptr };
std::function<void()> m_cb_hide_delete_all_btn{ nullptr };
std::vector<std::string> m_substitutions;
void validate_lenth();
bool is_compatibile_with_ui();
bool is_valid_id(int substitution_id, const wxString& message);