Allow multiple warnings to be emitted from Print::validate
This commit is contained in:
parent
f25531484b
commit
8431595db8
@ -468,7 +468,7 @@ static inline bool sequential_print_vertical_clearance_valid(const Print &print)
|
|||||||
boost::regex regex_g92e0 { "^[ \\t]*[gG]92[ \\t]*[eE](0(\\.0*)?|\\.0+)[ \\t]*(;.*)?$" };
|
boost::regex regex_g92e0 { "^[ \\t]*[gG]92[ \\t]*[eE](0(\\.0*)?|\\.0+)[ \\t]*(;.*)?$" };
|
||||||
|
|
||||||
// Precondition: Print::validate() requires the Print::apply() to be called its invocation.
|
// Precondition: Print::validate() requires the Print::apply() to be called its invocation.
|
||||||
std::string Print::validate(std::string* warning) const
|
std::string Print::validate(std::vector<std::string>* warnings) const
|
||||||
{
|
{
|
||||||
std::vector<unsigned int> extruders = this->extruders();
|
std::vector<unsigned int> extruders = this->extruders();
|
||||||
|
|
||||||
@ -691,12 +691,12 @@ std::string Print::validate(std::string* warning) const
|
|||||||
|
|
||||||
// Do we have custom support data that would not be used?
|
// Do we have custom support data that would not be used?
|
||||||
// Notify the user in that case.
|
// Notify the user in that case.
|
||||||
if (! object->has_support() && warning) {
|
if (! object->has_support() && warnings) {
|
||||||
for (const ModelVolume* mv : object->model_object()->volumes) {
|
for (const ModelVolume* mv : object->model_object()->volumes) {
|
||||||
bool has_enforcers = mv->is_support_enforcer() ||
|
bool has_enforcers = mv->is_support_enforcer() ||
|
||||||
(mv->is_model_part() && mv->supported_facets.has_facets(*mv, EnforcerBlockerType::ENFORCER));
|
(mv->is_model_part() && mv->supported_facets.has_facets(*mv, EnforcerBlockerType::ENFORCER));
|
||||||
if (has_enforcers) {
|
if (has_enforcers) {
|
||||||
*warning = "_SUPPORTS_OFF";
|
warnings->emplace_back("_SUPPORTS_OFF");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -547,7 +547,7 @@ public:
|
|||||||
bool has_brim() const;
|
bool has_brim() const;
|
||||||
|
|
||||||
// Returns an empty string if valid, otherwise returns an error message.
|
// Returns an empty string if valid, otherwise returns an error message.
|
||||||
std::string validate(std::string* warning = nullptr) const override;
|
std::string validate(std::vector<std::string>* warnings = nullptr) const override;
|
||||||
double skirt_first_layer_height() const;
|
double skirt_first_layer_height() const;
|
||||||
Flow brim_flow() const;
|
Flow brim_flow() const;
|
||||||
Flow skirt_flow() const;
|
Flow skirt_flow() const;
|
||||||
|
@ -418,7 +418,7 @@ public:
|
|||||||
virtual std::vector<ObjectID> print_object_ids() const = 0;
|
virtual std::vector<ObjectID> print_object_ids() const = 0;
|
||||||
|
|
||||||
// Validate the print, return empty string if valid, return error if process() cannot (or should not) be started.
|
// Validate the print, return empty string if valid, return error if process() cannot (or should not) be started.
|
||||||
virtual std::string validate(std::string* warning = nullptr) const { return std::string(); }
|
virtual std::string validate(std::vector<std::string>* warnings = nullptr) const { return std::string(); }
|
||||||
|
|
||||||
enum ApplyStatus {
|
enum ApplyStatus {
|
||||||
// No change after the Print::apply() call.
|
// No change after the Print::apply() call.
|
||||||
|
@ -534,7 +534,7 @@ std::string SLAPrint::output_filename(const std::string &filename_base) const
|
|||||||
return this->PrintBase::output_filename(m_print_config.output_filename_format.value, ".sl1", filename_base, &config);
|
return this->PrintBase::output_filename(m_print_config.output_filename_format.value, ".sl1", filename_base, &config);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SLAPrint::validate(std::string*) const
|
std::string SLAPrint::validate(std::vector<std::string>*) const
|
||||||
{
|
{
|
||||||
for(SLAPrintObject * po : m_objects) {
|
for(SLAPrintObject * po : m_objects) {
|
||||||
|
|
||||||
|
@ -494,7 +494,7 @@ public:
|
|||||||
|
|
||||||
const SLAPrintStatistics& print_statistics() const { return m_print_statistics; }
|
const SLAPrintStatistics& print_statistics() const { return m_print_statistics; }
|
||||||
|
|
||||||
std::string validate(std::string* warning = nullptr) const override;
|
std::string validate(std::vector<std::string>* warnings = nullptr) const override;
|
||||||
|
|
||||||
// An aggregation of SliceRecord-s from all the print objects for each
|
// An aggregation of SliceRecord-s from all the print objects for each
|
||||||
// occupied layer. Slice record levels dont have to match exactly.
|
// occupied layer. Slice record levels dont have to match exactly.
|
||||||
|
@ -549,10 +549,10 @@ bool BackgroundSlicingProcess::empty() const
|
|||||||
return m_print->empty();
|
return m_print->empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string BackgroundSlicingProcess::validate(std::string* warning)
|
std::string BackgroundSlicingProcess::validate(std::vector<std::string>* warnings)
|
||||||
{
|
{
|
||||||
assert(m_print != nullptr);
|
assert(m_print != nullptr);
|
||||||
return m_print->validate(warning);
|
return m_print->validate(warnings);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply config over the print. Returns false, if the new config values caused any of the already
|
// Apply config over the print. Returns false, if the new config values caused any of the already
|
||||||
|
@ -132,7 +132,7 @@ public:
|
|||||||
bool empty() const;
|
bool empty() const;
|
||||||
// Validate the print. Returns an empty string if valid, returns an error message if invalid.
|
// Validate the print. Returns an empty string if valid, returns an error message if invalid.
|
||||||
// Call validate before calling start().
|
// Call validate before calling start().
|
||||||
std::string validate(std::string* warning = nullptr);
|
std::string validate(std::vector<std::string>* warnings = nullptr);
|
||||||
|
|
||||||
// Set the export path of the G-code.
|
// Set the export path of the G-code.
|
||||||
// Once the path is set, the G-code
|
// Once the path is set, the G-code
|
||||||
|
@ -1849,7 +1849,7 @@ struct Plater::priv
|
|||||||
void suppress_snapshots() { m_prevent_snapshots++; }
|
void suppress_snapshots() { m_prevent_snapshots++; }
|
||||||
void allow_snapshots() { m_prevent_snapshots--; }
|
void allow_snapshots() { m_prevent_snapshots--; }
|
||||||
|
|
||||||
void process_validation_warning(const std::string& warning) const;
|
void process_validation_warning(const std::vector<std::string>& warning) const;
|
||||||
|
|
||||||
bool background_processing_enabled() const { return this->get_config_bool("background_processing"); }
|
bool background_processing_enabled() const { return this->get_config_bool("background_processing"); }
|
||||||
void update_print_volume_state();
|
void update_print_volume_state();
|
||||||
@ -3198,12 +3198,12 @@ void Plater::priv::update_print_volume_state()
|
|||||||
this->q->model().update_print_volume_state(this->bed.build_volume());
|
this->q->model().update_print_volume_state(this->bed.build_volume());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::priv::process_validation_warning(const std::string& warning) const
|
void Plater::priv::process_validation_warning(const std::vector<std::string>& warnings) const
|
||||||
{
|
{
|
||||||
if (warning.empty())
|
if (warnings.empty())
|
||||||
notification_manager->close_notification_of_type(NotificationType::ValidateWarning);
|
notification_manager->close_notification_of_type(NotificationType::ValidateWarning);
|
||||||
else {
|
else {
|
||||||
std::string text = warning;
|
std::string text = warnings.front();
|
||||||
std::string hypertext = "";
|
std::string hypertext = "";
|
||||||
std::function<bool(wxEvtHandler*)> action_fn = [](wxEvtHandler*){ return false; };
|
std::function<bool(wxEvtHandler*)> action_fn = [](wxEvtHandler*){ return false; };
|
||||||
|
|
||||||
@ -3279,8 +3279,8 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
|
|||||||
// The delayed error message is no more valid.
|
// The delayed error message is no more valid.
|
||||||
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.
|
// 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::vector<std::string> warnings;
|
||||||
std::string err = background_process.validate(&warning);
|
std::string err = background_process.validate(&warnings);
|
||||||
if (err.empty()) {
|
if (err.empty()) {
|
||||||
notification_manager->set_all_slicing_errors_gray(true);
|
notification_manager->set_all_slicing_errors_gray(true);
|
||||||
notification_manager->close_notification_of_type(NotificationType::ValidateError);
|
notification_manager->close_notification_of_type(NotificationType::ValidateError);
|
||||||
@ -3289,7 +3289,7 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
|
|||||||
|
|
||||||
// Pass a warning from validation and either show a notification,
|
// Pass a warning from validation and either show a notification,
|
||||||
// or hide the old one.
|
// or hide the old one.
|
||||||
process_validation_warning(warning);
|
process_validation_warning(warnings);
|
||||||
if (printer_technology == ptFFF) {
|
if (printer_technology == ptFFF) {
|
||||||
GLCanvas3D* canvas = view3D->get_canvas3d();
|
GLCanvas3D* canvas = view3D->get_canvas3d();
|
||||||
canvas->reset_sequential_print_clearance();
|
canvas->reset_sequential_print_clearance();
|
||||||
@ -3328,8 +3328,8 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
|
|||||||
canvas->request_extra_frame();
|
canvas->request_extra_frame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string warning;
|
std::vector<std::string> warnings;
|
||||||
std::string err = background_process.validate(&warning);
|
std::string err = background_process.validate(&warnings);
|
||||||
if (!err.empty())
|
if (!err.empty())
|
||||||
return return_state;
|
return return_state;
|
||||||
}
|
}
|
||||||
@ -3342,7 +3342,7 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
|
|||||||
//actualizate warnings
|
//actualizate warnings
|
||||||
if (invalidated != Print::APPLY_STATUS_UNCHANGED || background_process.empty()) {
|
if (invalidated != Print::APPLY_STATUS_UNCHANGED || background_process.empty()) {
|
||||||
if (background_process.empty())
|
if (background_process.empty())
|
||||||
process_validation_warning(std::string());
|
process_validation_warning(std::vector<std::string>());
|
||||||
actualize_slicing_warnings(*this->background_process.current_print());
|
actualize_slicing_warnings(*this->background_process.current_print());
|
||||||
actualize_object_warnings(*this->background_process.current_print());
|
actualize_object_warnings(*this->background_process.current_print());
|
||||||
show_warning_dialog = false;
|
show_warning_dialog = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user