Print::validate: added epsilon checks on nozzle and filament diameter validation (https://github.com/prusa3d/PrusaSlicer/issues/2737)

Changed messagebox text after changing extruder diameter with single extruder printers so it is more obvious why it shows

In case nozzle diameters differ and someone checks 'single_extruder_mm', PrusaSlicer asks whether all diameters should be unified. Answering NO did not undo the SEMM check. It does now.
This commit is contained in:
Lukas Matena 2019-08-15 10:35:50 +02:00
parent 36d2a38a2f
commit 15744f021a
2 changed files with 17 additions and 11 deletions

View file

@ -1149,11 +1149,17 @@ std::string Print::validate() const
}
if (this->has_wipe_tower() && ! m_objects.empty()) {
// make sure all extruders use same diameter filament and have the same nozzle diameter
// Make sure all extruders use same diameter filament and have the same nozzle diameter
// EPSILON comparison is used for nozzles and 10 % tolerance is used for filaments
double first_nozzle_diam = m_config.nozzle_diameter.get_at(extruders().front());
double first_filament_diam = m_config.filament_diameter.get_at(extruders().front());
for (const auto& extruder_idx : extruders()) {
if (m_config.nozzle_diameter.get_at(extruder_idx) != m_config.nozzle_diameter.get_at(extruders().front())
|| m_config.filament_diameter.get_at(extruder_idx) != m_config.filament_diameter.get_at(extruders().front()))
return L("The wipe tower is only supported if all extruders have the same nozzle diameter and use filaments of the same diameter.");
double nozzle_diam = m_config.nozzle_diameter.get_at(extruder_idx);
double filament_diam = m_config.filament_diameter.get_at(extruder_idx);
if (nozzle_diam - EPSILON > first_nozzle_diam || nozzle_diam + EPSILON < first_nozzle_diam
|| std::abs((filament_diam-first_filament_diam)/first_filament_diam) > 0.1)
return L("The wipe tower is only supported if all extruders have the same nozzle diameter "
"and use filaments of the same diameter.");
}
if (m_config.gcode_flavor != gcfRepRap && m_config.gcode_flavor != gcfRepetier && m_config.gcode_flavor != gcfMarlin)
@ -1161,10 +1167,6 @@ std::string Print::validate() const
if (! m_config.use_relative_e_distances)
return L("The Wipe Tower is currently only supported with the relative extruder addressing (use_relative_e_distances=1).");
for (size_t i=1; i<m_config.nozzle_diameter.values.size(); ++i)
if (m_config.nozzle_diameter.values[i] != m_config.nozzle_diameter.values[i-1])
return L("All extruders must have the same diameter for the Wipe Tower.");
if (m_objects.size() > 1) {
bool has_custom_layering = false;
std::vector<std::vector<coordf_t>> layer_height_profiles;

View file

@ -2047,14 +2047,17 @@ void TabPrinter::build_fff()
"Do you want to change the diameter for all extruders to first extruder nozzle diameter value?"));
auto dialog = new wxMessageDialog(parent(), msg_text, _(L("Nozzle diameter")), wxICON_WARNING | wxYES_NO);
DynamicPrintConfig new_conf = *m_config;
if (dialog->ShowModal() == wxID_YES) {
DynamicPrintConfig new_conf = *m_config;
for (size_t i = 1; i < nozzle_diameters.size(); i++)
nozzle_diameters[i] = frst_diam;
new_conf.set_key_value("nozzle_diameter", new ConfigOptionFloats(nozzle_diameters));
load_config(new_conf);
}
else
new_conf.set_key_value("single_extruder_multi_material", new ConfigOptionBool(false));
load_config(new_conf);
break;
}
}
@ -2502,7 +2505,8 @@ void TabPrinter::build_unregular_pages()
// if value was changed
if (fabs(nozzle_diameters[extruder_idx == 0 ? 1 : 0] - new_nd) > EPSILON)
{
const wxString msg_text = _(L("Do you want to change the diameter for all extruders?"));
const wxString msg_text = _(L("This is a single extruder multimaterial printer, diameters of all extruders "
"will be set to the new value. Do you want to proceed?"));
auto dialog = new wxMessageDialog(parent(), msg_text, _(L("Nozzle diameter")), wxICON_WARNING | wxYES_NO);
DynamicPrintConfig new_conf = *m_config;