ENH: CLI: optimize the logic for message

1. treat the critical slicing warnings as error
2. save more information into result
including the triangle counts and the non-critical warnings

JIRA: STUDIO-4217

Change-Id: I25b746d06c9a1ef2d642c67852577982a2986322
(cherry picked from commit 1d9707ed04cbb6dc12b440b70f3581c619136ac3)
This commit is contained in:
lane.wei 2023-08-25 16:58:36 +08:00 committed by Lane.Wei
parent 82791b0320
commit bf8ac4c436
4 changed files with 182 additions and 100 deletions

View file

@ -110,11 +110,11 @@ void PrintBase::set_status(int percent, const std::string &message, unsigned in
BOOST_LOG_TRIVIAL(debug) <<boost::format("Percent %1%: %2%\n")%percent %message.c_str();
}
void PrintBase::status_update_warnings(int step, PrintStateBase::WarningLevel /* warning_level */,
void PrintBase::status_update_warnings(int step, PrintStateBase::WarningLevel warning_level,
const std::string &message, const PrintObjectBase* print_object, PrintStateBase::SlicingNotificationType message_id)
{
if (this->m_status_callback) {
auto status = print_object ? SlicingStatus(*print_object, step, message, message_id) : SlicingStatus(*this, step, message, message_id);
auto status = print_object ? SlicingStatus(*print_object, step, message, message_id, warning_level) : SlicingStatus(*this, step, message, message_id, warning_level);
m_status_callback(status);
}
else if (! message.empty())
@ -122,12 +122,12 @@ void PrintBase::status_update_warnings(int step, PrintStateBase::WarningLevel /*
}
//BBS: add PrintObject id into slicing status
void PrintBase::status_update_warnings(int step, PrintStateBase::WarningLevel /* warning_level */,
void PrintBase::status_update_warnings(int step, PrintStateBase::WarningLevel warning_level,
const std::string& message, PrintObjectBase &object, PrintStateBase::SlicingNotificationType message_id)
{
//BBS: add object it into slicing status
if (this->m_status_callback) {
m_status_callback(SlicingStatus(object, step, message, message_id));
m_status_callback(SlicingStatus(object, step, message, message_id, warning_level));
}
else if (!message.empty())
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", PrintObject warning: %1%\n")% message.c_str();

View file

@ -431,18 +431,18 @@ public:
struct SlicingStatus {
SlicingStatus(int percent, const std::string &text, unsigned int flags = 0, int warning_step = -1,
PrintStateBase::SlicingNotificationType msg_type = PrintStateBase::SlicingDefaultNotification) :
percent(percent), text(text), flags(flags), warning_step(warning_step), message_type(msg_type)
PrintStateBase::SlicingNotificationType msg_type = PrintStateBase::SlicingDefaultNotification, PrintStateBase::WarningLevel warning_level = PrintStateBase::WarningLevel::NON_CRITICAL) :
percent(percent), text(text), flags(flags), warning_step(warning_step), message_type(msg_type), warning_level(warning_level)
{
}
SlicingStatus(const PrintBase &print, int warning_step, const std::string& text,
PrintStateBase::SlicingNotificationType msg_type = PrintStateBase::SlicingDefaultNotification) :
flags(UPDATE_PRINT_STEP_WARNINGS), warning_object_id(print.id()), text(text), warning_step(warning_step), message_type(msg_type)
PrintStateBase::SlicingNotificationType msg_type = PrintStateBase::SlicingDefaultNotification, PrintStateBase::WarningLevel warning_level = PrintStateBase::WarningLevel::NON_CRITICAL) :
flags(UPDATE_PRINT_STEP_WARNINGS), warning_object_id(print.id()), text(text), warning_step(warning_step), message_type(msg_type), warning_level(warning_level)
{
}
SlicingStatus(const PrintObjectBase &print_object, int warning_step, const std::string& text,
PrintStateBase::SlicingNotificationType msg_type = PrintStateBase::SlicingDefaultNotification) :
flags(UPDATE_PRINT_OBJECT_STEP_WARNINGS), warning_object_id(print_object.id()), text(text), warning_step(warning_step), message_type(msg_type)
PrintStateBase::SlicingNotificationType msg_type = PrintStateBase::SlicingDefaultNotification, PrintStateBase::WarningLevel warning_level = PrintStateBase::WarningLevel::NON_CRITICAL) :
flags(UPDATE_PRINT_OBJECT_STEP_WARNINGS), warning_object_id(print_object.id()), text(text), warning_step(warning_step), message_type(msg_type), warning_level(warning_level)
{
}
int percent { -1 };
@ -466,6 +466,7 @@ public:
int warning_step { -1 };
PrintStateBase::SlicingNotificationType message_type {PrintStateBase::SlicingDefaultNotification};
PrintStateBase::WarningLevel warning_level {PrintStateBase::WarningLevel::NON_CRITICAL};
};
typedef std::function<void(const SlicingStatus&)> status_callback_type;
// Default status console print out in the form of percent => message.
@ -532,7 +533,7 @@ protected:
void status_update_warnings(int step, PrintStateBase::WarningLevel warning_level,
const std::string &message, const PrintObjectBase* print_object = nullptr, PrintStateBase::SlicingNotificationType message_id = PrintStateBase::SlicingDefaultNotification);
//BBS: add api to update printobject's warnings
void status_update_warnings(int step, PrintStateBase::WarningLevel /* warning_level */,
void status_update_warnings(int step, PrintStateBase::WarningLevel warning_level,
const std::string& message, PrintObjectBase &object, PrintStateBase::SlicingNotificationType message_id = PrintStateBase::SlicingDefaultNotification);
// If the background processing stop was requested, throw CanceledException.

View file

@ -477,7 +477,10 @@ void PrintObject::generate_support_material()
{LargeOverhang,L("large overhangs")} };
std::string warning_message = format(L("It seems object %s has %s. Please re-orient the object or enable support generation."),
this->model_object()->name, reasons[sntype]);
this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, warning_message, PrintStateBase::SlicingNeedSupportOn);
if (SharpTail == sntype)
this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, warning_message, PrintStateBase::SlicingNeedSupportOn);
else
this->active_step_add_warning(PrintStateBase::WarningLevel::NON_CRITICAL, warning_message, PrintStateBase::SlicingNeedSupportOn);
}
#if 0
@ -795,7 +798,7 @@ bool PrintObject::invalidate_state_by_config_options(
} else if (
opt_key == "bottom_shell_layers"
|| opt_key == "top_shell_layers") {
steps.emplace_back(posPrepareInfill);
const auto *old_shell_layers = old_config.option<ConfigOptionInt>(opt_key);
@ -807,7 +810,7 @@ bool PrintObject::invalidate_state_by_config_options(
if (value_changed && this->object_extruders().size() > 1) {
steps.emplace_back(posSlice);
}
}
else if (m_print->config().spiral_mode && opt_key == "bottom_shell_layers") {
// Changing the number of bottom layers when a spiral vase is enabled requires re-slicing the object again.
// Otherwise, holes in the bottom layers could be filled, as is reported in GH #5528.