Tech ENABLE_SEQUENTIAL_LIMITS -> 1st installment of visualization of objects clearance for sequential prints

This commit is contained in:
enricoturri1966 2021-05-11 13:12:25 +02:00
parent 9537c4e8d0
commit 75677ba810
14 changed files with 889 additions and 87 deletions

View file

@ -2828,12 +2828,12 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
// 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.
this->background_process_timer.Stop();
background_process_timer.Stop();
// Update the "out of print bed" state of ModelInstances.
this->update_print_volume_state();
update_print_volume_state();
// Apply new config to the possibly running background task.
bool was_running = this->background_process.running();
Print::ApplyStatus invalidated = this->background_process.apply(this->q->model(), wxGetApp().preset_bundle->full_config());
bool was_running = background_process.running();
Print::ApplyStatus invalidated = background_process.apply(q->model(), wxGetApp().preset_bundle->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())
@ -2842,40 +2842,56 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
if (invalidated == Print::APPLY_STATUS_INVALIDATED) {
// Some previously calculated data on the Print was invalidated.
// Hide the slicing results, as the current slicing status is no more valid.
this->sidebar->show_sliced_info_sizer(false);
sidebar->show_sliced_info_sizer(false);
// Reset preview canvases. If the print has been invalidated, the preview canvases will be cleared.
// Otherwise they will be just refreshed.
if (this->preview != nullptr) {
if (preview != nullptr) {
// If the preview is not visible, the following line just invalidates the preview,
// but the G-code paths or SLA preview are calculated first once the preview is made visible.
reset_gcode_toolpaths();
this->preview->reload_print();
preview->reload_print();
}
// In FDM mode, we need to reload the 3D scene because of the wipe tower preview box.
// In SLA mode, we need to reload the 3D scene every time to show the support structures.
if (this->printer_technology == ptSLA || (this->printer_technology == ptFFF && this->config->opt_bool("wipe_tower")))
if (printer_technology == ptSLA || (printer_technology == ptFFF && config->opt_bool("wipe_tower")))
return_state |= UPDATE_BACKGROUND_PROCESS_REFRESH_SCENE;
}
if ((invalidated != Print::APPLY_STATUS_UNCHANGED || force_validation) && ! this->background_process.empty()) {
if ((invalidated != Print::APPLY_STATUS_UNCHANGED || force_validation) && ! background_process.empty()) {
// The delayed error message is no more valid.
this->delayed_error_message.clear();
delayed_error_message.clear();
// The state of the Print changed, and it is non-zero. Let's validate it and give the user feedback on errors.
std::string warning;
std::string err = this->background_process.validate(&warning);
std::string err = background_process.validate(&warning);
if (err.empty()) {
notification_manager->set_all_slicing_errors_gray(true);
if (invalidated != Print::APPLY_STATUS_UNCHANGED && this->background_processing_enabled())
if (invalidated != Print::APPLY_STATUS_UNCHANGED && background_processing_enabled())
return_state |= UPDATE_BACKGROUND_PROCESS_RESTART;
// Pass a warning from validation and either show a notification,
// or hide the old one.
process_validation_warning(warning);
#if ENABLE_SEQUENTIAL_LIMITS
if (printer_technology == ptFFF) {
view3D->get_canvas3d()->set_sequential_print_clearance(Polygons());
view3D->get_canvas3d()->set_as_dirty();
view3D->get_canvas3d()->request_extra_frame();
}
#endif // ENABLE_SEQUENTIAL_LIMITS
} else {
// The print is not valid.
// Show error as notification.
notification_manager->push_slicing_error_notification(err);
return_state |= UPDATE_BACKGROUND_PROCESS_INVALID;
#if ENABLE_SEQUENTIAL_LIMITS
if (printer_technology == ptFFF) {
const Print* print = background_process.fff_print();
Polygons polygons;
if (print->config().complete_objects)
Print::sequential_print_horizontal_clearance_valid(*print, &polygons);
view3D->get_canvas3d()->set_sequential_print_clearance(polygons);
}
#endif // ENABLE_SEQUENTIAL_LIMITS
}
} else if (! this->delayed_error_message.empty()) {
@ -3011,8 +3027,7 @@ void Plater::priv::update_fff_scene()
if (this->preview != nullptr)
this->preview->reload_print();
// In case this was MM print, wipe tower bounding box on 3D tab might need redrawing with exact depth:
view3D->reload_scene(true);
view3D->reload_scene(true);
}
void Plater::priv::update_sla_scene()