FIX: CLI: fix the crash issue caused by get_min_flush_volumes
JIRA: no jira Change-Id: I0d5bfd605e51ebddac8fddc4d83dab5055b0fbf2
This commit is contained in:
parent
ffd292a62c
commit
37d49a4bf5
|
@ -2648,7 +2648,7 @@ int CLI::run(int argc, char **argv)
|
||||||
//set multiplier to 1?
|
//set multiplier to 1?
|
||||||
m_print_config.option<ConfigOptionFloat>("flush_multiplier", true)->set(new ConfigOptionFloat(1.f));
|
m_print_config.option<ConfigOptionFloat>("flush_multiplier", true)->set(new ConfigOptionFloat(1.f));
|
||||||
|
|
||||||
const std::vector<int>& min_flush_volumes = Slic3r::GUI::get_min_flush_volumes();
|
const std::vector<int>& min_flush_volumes = Slic3r::GUI::get_min_flush_volumes(m_print_config);
|
||||||
|
|
||||||
if (filament_is_support->size() != project_filament_count)
|
if (filament_is_support->size() != project_filament_count)
|
||||||
{
|
{
|
||||||
|
|
|
@ -463,37 +463,63 @@ void Sidebar::priv::hide_rich_tip(wxButton* btn)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<int> get_min_flush_volumes()
|
std::vector<int> get_min_flush_volumes(const DynamicPrintConfig& full_config)
|
||||||
{
|
{
|
||||||
std::vector<int>extra_flush_volumes;
|
std::vector<int>extra_flush_volumes;
|
||||||
const auto& full_config = wxGetApp().preset_bundle->full_config();
|
//const auto& full_config = wxGetApp().preset_bundle->full_config();
|
||||||
auto& printer_config = wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
//auto& printer_config = wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||||
|
|
||||||
ConfigOption* nozzle_volume_opt = printer_config.option("nozzle_volume");
|
const ConfigOption* nozzle_volume_opt = full_config.option("nozzle_volume");
|
||||||
int nozzle_volume_val = nozzle_volume_opt ? (int)nozzle_volume_opt->getFloat() : 0;
|
int nozzle_volume_val = nozzle_volume_opt ? (int)nozzle_volume_opt->getFloat() : 0;
|
||||||
|
|
||||||
int machine_enabled_level = printer_config.option<ConfigOptionInt>("enable_long_retraction_when_cut")->value;
|
const ConfigOptionInt* enable_long_retraction_when_cut_opt = full_config.option<ConfigOptionInt>("enable_long_retraction_when_cut");
|
||||||
bool machine_activated = printer_config.option<ConfigOptionBools>("long_retractions_when_cut")->values[0] == 1;
|
int machine_enabled_level = 0;
|
||||||
|
if (enable_long_retraction_when_cut_opt) {
|
||||||
|
machine_enabled_level = enable_long_retraction_when_cut_opt->value;
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": get enable_long_retraction_when_cut from config, value=%1%")%machine_enabled_level;
|
||||||
|
}
|
||||||
|
const ConfigOptionBools* long_retractions_when_cut_opt = full_config.option<ConfigOptionBools>("long_retractions_when_cut");
|
||||||
|
bool machine_activated = false;
|
||||||
|
if (long_retractions_when_cut_opt) {
|
||||||
|
machine_activated = long_retractions_when_cut_opt->values[0] == 1;
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": get long_retractions_when_cut from config, value=%1%, activated=%2%")%long_retractions_when_cut_opt->values[0] %machine_activated;
|
||||||
|
}
|
||||||
|
|
||||||
auto filament_retraction_distance_when_cut = full_config.option<ConfigOptionFloats>("filament_retraction_distances_when_cut");
|
size_t filament_size = full_config.option<ConfigOptionFloats>("filament_diameter")->values.size();
|
||||||
auto printer_retraction_distance_when_cut = full_config.option<ConfigOptionFloats>("retraction_distances_when_cut");
|
std::vector<double> filament_retraction_distance_when_cut(filament_size, 18.0f), printer_retraction_distance_when_cut(filament_size, 18.0f);
|
||||||
auto filament_long_retractions_when_cut = full_config.option<ConfigOptionBools>("filament_long_retractions_when_cut");
|
std::vector<unsigned char> filament_long_retractions_when_cut(filament_size, 0);
|
||||||
|
const ConfigOptionFloats* filament_retraction_distances_when_cut_opt = full_config.option<ConfigOptionFloats>("filament_retraction_distances_when_cut");
|
||||||
|
if (filament_retraction_distances_when_cut_opt) {
|
||||||
|
filament_retraction_distance_when_cut = filament_retraction_distances_when_cut_opt->values;
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": get filament_retraction_distance_when_cut from config, size=%1%, values=%2%")%filament_retraction_distance_when_cut.size() %filament_retraction_distances_when_cut_opt->serialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
const ConfigOptionFloats* printer_retraction_distance_when_cut_opt = full_config.option<ConfigOptionFloats>("retraction_distances_when_cut");
|
||||||
|
if (printer_retraction_distance_when_cut_opt) {
|
||||||
|
printer_retraction_distance_when_cut = printer_retraction_distance_when_cut_opt->values;
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": get retraction_distances_when_cut from config, size=%1%, values=%2%")%printer_retraction_distance_when_cut.size() %printer_retraction_distance_when_cut_opt->serialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
const ConfigOptionBools* filament_long_retractions_when_cut_opt = full_config.option<ConfigOptionBools>("filament_long_retractions_when_cut");
|
||||||
|
if (filament_long_retractions_when_cut_opt) {
|
||||||
|
filament_long_retractions_when_cut = filament_long_retractions_when_cut_opt->values;
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": get filament_long_retractions_when_cut from config, size=%1%, values=%2%")%filament_long_retractions_when_cut.size() %filament_long_retractions_when_cut_opt->serialize();
|
||||||
|
}
|
||||||
|
|
||||||
size_t filament_size = filament_retraction_distance_when_cut->values.size();
|
|
||||||
for (size_t idx = 0; idx < filament_size; ++idx) {
|
for (size_t idx = 0; idx < filament_size; ++idx) {
|
||||||
int extra_flush_volume = nozzle_volume_val;
|
int extra_flush_volume = nozzle_volume_val;
|
||||||
int retract_length = machine_enabled_level && machine_activated ? printer_retraction_distance_when_cut->values[0] : 0;
|
int retract_length = machine_enabled_level && machine_activated ? printer_retraction_distance_when_cut[0] : 0;
|
||||||
|
|
||||||
char filament_activated = filament_long_retractions_when_cut->values[idx];
|
unsigned char filament_activated = filament_long_retractions_when_cut[idx];
|
||||||
double filament_retract_length = filament_retraction_distance_when_cut->values[idx];
|
double filament_retract_length = filament_retraction_distance_when_cut[idx];
|
||||||
|
|
||||||
if (filament_activated == 0)
|
if (filament_activated == 0)
|
||||||
retract_length = 0;
|
retract_length = 0;
|
||||||
else if (filament_activated == 1 && machine_enabled_level == LongRectrationLevel::EnableFilament) {
|
else if (filament_activated == 1 && machine_enabled_level == LongRectrationLevel::EnableFilament) {
|
||||||
if (!std::isnan(filament_retract_length))
|
if (!std::isnan(filament_retract_length))
|
||||||
retract_length = (int)filament_retraction_distance_when_cut->values[idx];
|
retract_length = (int)filament_retraction_distance_when_cut[idx];
|
||||||
else
|
else
|
||||||
retract_length = printer_retraction_distance_when_cut->values[0];
|
retract_length = printer_retraction_distance_when_cut[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
extra_flush_volume -= PI * 1.75 * 1.75 / 4 * retract_length;
|
extra_flush_volume -= PI * 1.75 * 1.75 / 4 * retract_length;
|
||||||
|
@ -823,7 +849,8 @@ Sidebar::Sidebar(Plater *parent)
|
||||||
float flush_multiplier = flush_multi_opt ? flush_multi_opt->getFloat() : 1.f;
|
float flush_multiplier = flush_multi_opt ? flush_multi_opt->getFloat() : 1.f;
|
||||||
|
|
||||||
const std::vector<std::string> extruder_colours = wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
const std::vector<std::string> extruder_colours = wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
||||||
const auto& extra_flush_volumes = get_min_flush_volumes();
|
const auto& full_config = wxGetApp().preset_bundle->full_config();
|
||||||
|
const auto& extra_flush_volumes = get_min_flush_volumes(full_config);
|
||||||
WipingDialog dlg(parent, cast<float>(init_matrix), cast<float>(init_extruders), extruder_colours, extra_flush_volumes, flush_multiplier);
|
WipingDialog dlg(parent, cast<float>(init_matrix), cast<float>(init_extruders), extruder_colours, extra_flush_volumes, flush_multiplier);
|
||||||
if (dlg.ShowModal() == wxID_OK) {
|
if (dlg.ShowModal() == wxID_OK) {
|
||||||
std::vector<float> matrix = dlg.get_matrix();
|
std::vector<float> matrix = dlg.get_matrix();
|
||||||
|
@ -1963,13 +1990,14 @@ void Sidebar::auto_calc_flushing_volumes(const int modify_id)
|
||||||
auto& preset_bundle = wxGetApp().preset_bundle;
|
auto& preset_bundle = wxGetApp().preset_bundle;
|
||||||
auto& project_config = preset_bundle->project_config;
|
auto& project_config = preset_bundle->project_config;
|
||||||
auto& printer_config = preset_bundle->printers.get_edited_preset().config;
|
auto& printer_config = preset_bundle->printers.get_edited_preset().config;
|
||||||
|
const auto& full_config = wxGetApp().preset_bundle->full_config();
|
||||||
auto& ams_multi_color_filament = preset_bundle->ams_multi_color_filment;
|
auto& ams_multi_color_filament = preset_bundle->ams_multi_color_filment;
|
||||||
auto& ams_filament_list = preset_bundle->filament_ams_list;
|
auto& ams_filament_list = preset_bundle->filament_ams_list;
|
||||||
|
|
||||||
const std::vector<double>& init_matrix = (project_config.option<ConfigOptionFloats>("flush_volumes_matrix"))->values;
|
const std::vector<double>& init_matrix = (project_config.option<ConfigOptionFloats>("flush_volumes_matrix"))->values;
|
||||||
const std::vector<double>& init_extruders = (project_config.option<ConfigOptionFloats>("flush_volumes_vector"))->values;
|
const std::vector<double>& init_extruders = (project_config.option<ConfigOptionFloats>("flush_volumes_vector"))->values;
|
||||||
|
|
||||||
const std::vector<int>& min_flush_volumes= get_min_flush_volumes();
|
const std::vector<int>& min_flush_volumes= get_min_flush_volumes(full_config);
|
||||||
|
|
||||||
ConfigOptionFloat* flush_multi_opt = project_config.option<ConfigOptionFloat>("flush_multiplier");
|
ConfigOptionFloat* flush_multi_opt = project_config.option<ConfigOptionFloat>("flush_multiplier");
|
||||||
float flush_multiplier = flush_multi_opt ? flush_multi_opt->getFloat() : 1.f;
|
float flush_multiplier = flush_multi_opt ? flush_multi_opt->getFloat() : 1.f;
|
||||||
|
|
|
@ -777,7 +777,7 @@ private:
|
||||||
bool m_was_scheduled;
|
bool m_was_scheduled;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<int> get_min_flush_volumes();
|
std::vector<int> get_min_flush_volumes(const DynamicPrintConfig& full_config);
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue