event invalidate plater emitted after toolpath outside check

This commit is contained in:
David Kocik 2021-10-18 14:24:59 +02:00
parent aa47729c47
commit 012e987389
3 changed files with 19 additions and 4 deletions

View File

@ -884,6 +884,7 @@ wxDEFINE_EVENT(EVT_GLCANVAS_FORCE_UPDATE, SimpleEvent);
wxDEFINE_EVENT(EVT_GLCANVAS_WIPETOWER_MOVED, Vec3dEvent); wxDEFINE_EVENT(EVT_GLCANVAS_WIPETOWER_MOVED, Vec3dEvent);
wxDEFINE_EVENT(EVT_GLCANVAS_WIPETOWER_ROTATED, Vec3dEvent); wxDEFINE_EVENT(EVT_GLCANVAS_WIPETOWER_ROTATED, Vec3dEvent);
wxDEFINE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event<bool>); wxDEFINE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event<bool>);
wxDEFINE_EVENT(EVT_GLCANVAS_INVALIDATE_PLATER, SimpleEvent);
wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>); wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>);
wxDEFINE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_STARTED, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_STARTED, SimpleEvent);
wxDEFINE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent);
@ -6423,6 +6424,8 @@ void GLCanvas3D::_set_warning_notification_if_needed(EWarning warning)
} }
_set_warning_notification(warning, show); _set_warning_notification(warning, show);
if (show)
post_event(SimpleEvent(EVT_GLCANVAS_INVALIDATE_PLATER));
} }
std::vector<std::array<float, 4>> GLCanvas3D::_parse_colors(const std::vector<std::string>& colors) std::vector<std::array<float, 4>> GLCanvas3D::_parse_colors(const std::vector<std::string>& colors)

View File

@ -157,6 +157,7 @@ wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_ROTATED, SimpleEvent);
wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_SCALED, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_SCALED, SimpleEvent);
wxDECLARE_EVENT(EVT_GLCANVAS_WIPETOWER_ROTATED, Vec3dEvent); wxDECLARE_EVENT(EVT_GLCANVAS_WIPETOWER_ROTATED, Vec3dEvent);
wxDECLARE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event<bool>); wxDECLARE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event<bool>);
wxDECLARE_EVENT(EVT_GLCANVAS_INVALIDATE_PLATER, SimpleEvent);
wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>); wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>);
wxDECLARE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_STARTED, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_STARTED, SimpleEvent);
wxDECLARE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent);

View File

@ -1790,6 +1790,8 @@ struct Plater::priv
void on_layer_editing_toggled(bool enable); void on_layer_editing_toggled(bool enable);
void on_slicing_began(); void on_slicing_began();
void invalidate_plater();
void clear_warnings(); void clear_warnings();
void add_warning(const Slic3r::PrintStateBase::Warning &warning, size_t oid); void add_warning(const Slic3r::PrintStateBase::Warning &warning, size_t oid);
// Update notification manager with the current state of warnings produced by the background process (slicing). // Update notification manager with the current state of warnings produced by the background process (slicing).
@ -2036,6 +2038,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
preview->move_moves_slider(evt); preview->move_moves_slider(evt);
}); });
preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_EDIT_COLOR_CHANGE, [this](wxKeyEvent& evt) { preview->edit_layers_slider(evt); }); preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_EDIT_COLOR_CHANGE, [this](wxKeyEvent& evt) { preview->edit_layers_slider(evt); });
preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_INVALIDATE_PLATER, [this](SimpleEvent&) { this->invalidate_plater(); });
if (wxGetApp().is_gcode_viewer()) if (wxGetApp().is_gcode_viewer())
preview->Bind(EVT_GLCANVAS_RELOAD_FROM_DISK, [this](SimpleEvent&) { this->q->reload_gcode_from_disk(); }); preview->Bind(EVT_GLCANVAS_RELOAD_FROM_DISK, [this](SimpleEvent&) { this->q->reload_gcode_from_disk(); });
@ -4099,6 +4102,15 @@ bool Plater::priv::warnings_dialog()
return res == wxID_OK; return res == wxID_OK;
} }
void Plater::priv::invalidate_plater()
{
const wxString invalid_str = _L("Invalid data");
for (auto btn : { ActionButtonType::abReslice, ActionButtonType::abSendGCode, ActionButtonType::abExport })
sidebar->set_btn_label(btn, invalid_str);
process_completed_with_error = true;
}
void Plater::priv::on_process_completed(SlicingProcessCompletedEvent &evt) void Plater::priv::on_process_completed(SlicingProcessCompletedEvent &evt)
{ {
// Stop the background task, wait until the thread goes into the "Idle" state. // Stop the background task, wait until the thread goes into the "Idle" state.
@ -4129,10 +4141,7 @@ void Plater::priv::on_process_completed(SlicingProcessCompletedEvent &evt)
// this->statusbar()->set_status_text(from_u8(message.first)); // this->statusbar()->set_status_text(from_u8(message.first));
if (evt.invalidate_plater()) if (evt.invalidate_plater())
{ {
const wxString invalid_str = _L("Invalid data"); invalidate_plater();
for (auto btn : { ActionButtonType::abReslice, ActionButtonType::abSendGCode, ActionButtonType::abExport })
sidebar->set_btn_label(btn, invalid_str);
process_completed_with_error = true;
} }
has_error = true; has_error = true;
} }
@ -5637,9 +5646,11 @@ void Plater::export_gcode(bool prefer_removable)
if (canvas3D()->get_gizmos_manager().is_in_editing_mode(true)) if (canvas3D()->get_gizmos_manager().is_in_editing_mode(true))
return; return;
select_view_3D("Preview");
if (p->process_completed_with_error) if (p->process_completed_with_error)
return; return;
// If possible, remove accents from accented latin characters. // If possible, remove accents from accented latin characters.
// This function is useful for generating file names to be processed by legacy firmwares. // This function is useful for generating file names to be processed by legacy firmwares.