ENH: add filament alias to a print warning

Change-Id: Ie7a2e0cbdd016c2120c46cde9a92a93baffbe832
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2022-11-16 10:15:04 +08:00 committed by Lane.Wei
parent 8f9d8b55eb
commit bdab8a28c9
4 changed files with 47 additions and 3 deletions

View File

@ -1098,9 +1098,15 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons*
break;
}
}
return { format(L("Plate %d: %s does not support filament %s.\n"), this->get_plate_index() + 1,
L(bed_type_name), extruder_id + 1) };
StringObjectException except;
except.string = format(L("Plate %d: %s does not support filament %s\n"), this->get_plate_index() + 1, L(bed_type_name), extruder_id + 1);
except.type = STRING_EXCEPT_FILAMENT_NOT_MATCH_BED_TYPE;
except.params.push_back(std::to_string(this->get_plate_index() + 1));
except.params.push_back(L(bed_type_name));
except.params.push_back(std::to_string(extruder_id+1));
except.object = nullptr;
return except;
}
}
}

View File

@ -16,12 +16,20 @@
namespace Slic3r {
enum StringExceptionType {
STRING_EXCEPT_NOT_DEFINED = 0,
STRING_EXCEPT_FILAMENT_NOT_MATCH_BED_TYPE = 1,
STRING_EXCEPT_COUNT
};
// BBS: error with object
struct StringObjectException
{
std::string string;
ObjectBase const *object = nullptr;
std::string opt_key;
StringExceptionType type; // warning type for tips
std::vector<std::string> params; // warning params for tips
};
class CanceledException : public std::exception

View File

@ -4103,6 +4103,8 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
Polygons polygons;
std::vector<std::pair<Polygon, float>> height_polygons;
StringObjectException err = background_process.validate(&warning, &polygons, &height_polygons);
// update string by type
q->post_process_string_object_exception(err);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": validate err=%1%, warning=%2%")%err.string%warning.string;
if (err.string.empty()) {
@ -10426,6 +10428,8 @@ void Plater::validate_current_plate(bool& model_fits, bool& validate_error)
Polygons polygons;
std::vector<std::pair<Polygon, float>> height_polygons;
StringObjectException err = p->background_process.validate(&warning, &polygons, &height_polygons);
// update string by type
post_process_string_object_exception(err);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": validate err=%1%, warning=%2%, model_fits %3%")%err.string%warning.string %model_fits;
if (err.string.empty()) {
@ -10754,6 +10758,29 @@ bool Plater::show_publish_dialog(bool show)
return p->show_publish_dlg(show);
}
void Plater::post_process_string_object_exception(StringObjectException &err)
{
if (err.type == StringExceptionType::STRING_EXCEPT_FILAMENT_NOT_MATCH_BED_TYPE) {
try {
int extruder_id = atoi(err.params[2].c_str()) - 1;
if (extruder_id < wxGetApp().preset_bundle->filament_presets.size()) {
std::string filament_name = wxGetApp().preset_bundle->filament_presets[extruder_id];
for (auto filament : wxGetApp().preset_bundle->filaments) {
if (filament.name == filament_name) {
filament_name = filament.alias;
break;
}
}
err.string = format(L("Plate %d: %s does not support filament %s (%s).\n"), err.params[0], err.params[1], err.params[2], filament_name);
}
} catch (...) {
;
}
}
return;
}
#if ENABLE_ENVIRONMENT_MAP
void Plater::init_environment_texture()
{

View File

@ -22,6 +22,7 @@
#include "Jobs/PrintJob.hpp"
#include "Jobs/SendJob.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/PrintBase.hpp"
#define FILAMENT_SYSTEM_COLORS_NUM 16
@ -504,6 +505,8 @@ public:
void show_object_info();
//BBS
bool show_publish_dialog(bool show = true);
//BBS: post process string object exception strings by warning types
void post_process_string_object_exception(StringObjectException &err);
#if ENABLE_ENVIRONMENT_MAP
void init_environment_texture();