Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_gcode_window

This commit is contained in:
enricoturri1966 2021-03-04 13:24:08 +01:00
commit 252aa9b229
18 changed files with 560 additions and 213 deletions

View file

@ -430,10 +430,10 @@ bool BackgroundSlicingProcess::empty() const
return m_print->empty();
}
std::string BackgroundSlicingProcess::validate()
std::string BackgroundSlicingProcess::validate(std::string* warning)
{
assert(m_print != nullptr);
return m_print->validate();
return m_print->validate(warning);
}
// Apply config over the print. Returns false, if the new config values caused any of the already

View file

@ -131,7 +131,7 @@ public:
bool empty() const;
// Validate the print. Returns an empty string if valid, returns an error message if invalid.
// Call validate before calling start().
std::string validate();
std::string validate(std::string* warning = nullptr);
// Set the export path of the G-code.
// Once the path is set, the G-code

View file

@ -16,6 +16,7 @@
#include "slic3r/GUI/GUI_ObjectSettings.hpp"
#include "slic3r/GUI/GUI_ObjectList.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/NotificationManager.hpp"
#include "libslic3r/PresetBundle.hpp"
#include "libslic3r/SLAPrint.hpp"
@ -1161,6 +1162,7 @@ void GLGizmoSlaSupports::disable_editing_mode()
m_c->instances_hider()->show_supports(true);
m_parent.set_as_dirty();
}
wxGetApp().plater()->get_notification_manager()->close_notification_of_type(NotificationType::QuitSLAManualMode);
}

View file

@ -1147,9 +1147,11 @@ bool GLGizmosManager::is_in_editing_mode(bool error_notification) const
return false;
if (error_notification)
wxGetApp().plater()->get_notification_manager()->push_slicing_error_notification(
_u8L("You are currently editing SLA support points. Please, apply or discard "
"your changes first."));
wxGetApp().plater()->get_notification_manager()->push_notification(
NotificationType::QuitSLAManualMode,
NotificationManager::NotificationLevel::ErrorNotification,
_u8L("You are currently editing SLA support points. Please, "
"apply or discard your changes first."));
return true;
}

View file

@ -71,7 +71,11 @@ enum class NotificationType
// Notification that custom supports/seams were deleted after mesh repair.
CustomSupportsAndSeamRemovedAfterRepair,
// Notification that auto adding of color changes is impossible
EmptyAutoColorChange
EmptyAutoColorChange,
// Notification emitted by Print::validate
PrintValidateWarning,
// Notification telling user to quit SLA supports manual editing
QuitSLAManualMode
};
class NotificationManager

View file

@ -1599,6 +1599,8 @@ struct Plater::priv
void suppress_snapshots() { this->m_prevent_snapshots++; }
void allow_snapshots() { this->m_prevent_snapshots--; }
void process_validation_warning(const std::string& warning) const;
bool background_processing_enabled() const { return this->get_config("background_processing") == "1"; }
void update_print_volume_state();
void schedule_background_process();
@ -2787,6 +2789,41 @@ void Plater::priv::update_print_volume_state()
this->q->model().update_print_volume_state(print_volume);
}
void Plater::priv::process_validation_warning(const std::string& warning) const
{
if (warning.empty())
notification_manager->close_notification_of_type(NotificationType::PrintValidateWarning);
else {
std::string text = warning;
std::string hypertext = "";
std::function<bool(wxEvtHandler*)> action_fn = [](wxEvtHandler*){ return false; };
if (text == "_SUPPORTS_OFF") {
text = _u8L("An object has custom support enforcers which will not be used "
"because supports are disabled.")+"\n";
hypertext = _u8L("Enable supports for enforcers only");
action_fn = [](wxEvtHandler*) {
Tab* print_tab = wxGetApp().get_tab(Preset::TYPE_PRINT);
assert(print_tab);
DynamicPrintConfig& config = wxGetApp().preset_bundle->prints.get_edited_preset().config;
config.set_key_value("support_material", new ConfigOptionBool(true));
config.set_key_value("support_material_auto", new ConfigOptionBool(false));
print_tab->on_value_change("support_material", config.opt_bool("support_material"));
print_tab->on_value_change("support_material_auto", config.opt_bool("support_material_auto"));
return true;
};
}
notification_manager->push_notification(
NotificationType::PrintValidateWarning,
NotificationManager::NotificationLevel::ImportantNotification,
text, hypertext, action_fn
);
}
}
// Update background processing thread from the current config and Model.
// Returns a bitmask of UpdateBackgroundProcessReturnState.
unsigned int Plater::priv::update_background_process(bool force_validation, bool postpone_error_messages)
@ -2829,17 +2866,23 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
// The delayed error message is no more valid.
this->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 err = this->background_process.validate();
std::string warning;
std::string err = this->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())
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);
} else {
// The print is not valid.
// Show error as notification.
notification_manager->push_slicing_error_notification(err);
return_state |= UPDATE_BACKGROUND_PROCESS_INVALID;
}
} else if (! this->delayed_error_message.empty()) {
// Reusing the old state.
return_state |= UPDATE_BACKGROUND_PROCESS_INVALID;
@ -5385,7 +5428,9 @@ void Plater::export_amf()
void Plater::export_3mf(const boost::filesystem::path& output_path)
{
if (p->model.objects.empty()) { return; }
if (p->model.objects.empty()
|| canvas3D()->get_gizmos_manager().is_in_editing_mode(true))
return;
wxString path;
bool export_config = true;