ENH:Add 'Don't show again' to the step mesh

jira: STUDIO-8606
Change-Id: I2382b9052e2c994a458ad36ca61eb94c517927c6
(cherry picked from commit 0cce6619ce12aa8540f6dfca6d9ee79ffba65c19)
This commit is contained in:
Mack 2024-11-08 21:06:57 +08:00 committed by Noisyfox
parent 65e5b193e1
commit 0bc2444079
10 changed files with 154 additions and 76 deletions

View file

@ -4156,45 +4156,22 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
filament_ids.clear();
}
};
auto step_mesh = [this, &path, &is_user_cancel](Slic3r::Step& file, double& linear_value, double& angle_value)-> int {
if (boost::iends_with(path.string(), ".step") ||
boost::iends_with(path.string(), ".stp")){
StepMeshDialog mesh_dlg(nullptr, file);
if (mesh_dlg.ShowModal() == wxID_OK) {
linear_value = mesh_dlg.get_linear_defletion();
angle_value = mesh_dlg.get_angle_defletion();
return 1;
}
}
is_user_cancel = true;
return -1;
};
model = Slic3r::Model:: read_from_file(
path.string(), nullptr, nullptr, strategy, &plate_data, &project_presets, &is_xxx, &file_version, nullptr,
[this, &dlg, real_filename, &progress_percent, &file_percent, INPUT_FILES_RATIO, total_files, i, &designer_model_id, &designer_country_code](int current, int total, bool &cancel, std::string &mode_id, std::string &code)
{
designer_model_id = mode_id;
designer_country_code = code;
bool cont = true;
float percent_float = (100.0f * (float)i / (float)total_files) + INPUT_FILES_RATIO * 100.0f * ((float)current / (float)total) / (float)total_files;
BOOST_LOG_TRIVIAL(trace) << "load_stl_file: percent(float)=" << percent_float << ", curr = " << current << ", total = " << total;
progress_percent = (int)percent_float;
wxString msg = wxString::Format(_L("Loading file: %s"), from_path(real_filename));
cont = dlg.Update(progress_percent, msg);
cancel = !cont;
},
[this, &dlg, real_filename, &progress_percent, &file_percent, step_percent, INPUT_FILES_RATIO, total_files, i](int load_stage, int current, int total, bool &cancel)
{
bool cont = true;
float percent_float = (100.0f * (float)i / (float)total_files) + INPUT_FILES_RATIO * ((float)step_percent[load_stage] + (float)current * (float)(step_percent[load_stage + 1] - step_percent[load_stage]) / (float)total) / (float)total_files;
BOOST_LOG_TRIVIAL(trace) << "load_step_file: percent(float)=" << percent_float << ", stage = " << load_stage << ", curr = " << current << ", total = " << total;
progress_percent = (int)percent_float;
wxString msg = wxString::Format(_L("Loading file: %s"), from_path(real_filename));
cont = dlg.Update(progress_percent, msg);
cancel = !cont;
},
[](int isUtf8StepFile) {
if (boost::algorithm::iends_with(path.string(), ".stp") ||
boost::algorithm::iends_with(path.string(), ".step")) {
double linear = std::stod(wxGetApp().app_config->get("linear_defletion"));
double angle = std::stod(wxGetApp().app_config->get("angle_defletion"));
model = Slic3r::Model:: read_from_step(path.string(), strategy,
[this, &dlg, real_filename, &progress_percent, &file_percent, step_percent, INPUT_FILES_RATIO, total_files, i](int load_stage, int current, int total, bool &cancel)
{
bool cont = true;
float percent_float = (100.0f * (float)i / (float)total_files) + INPUT_FILES_RATIO * ((float)step_percent[load_stage] + (float)current * (float)(step_percent[load_stage + 1] - step_percent[load_stage]) / (float)total) / (float)total_files;
BOOST_LOG_TRIVIAL(trace) << "load_step_file: percent(float)=" << percent_float << ", stage = " << load_stage << ", curr = " << current << ", total = " << total;
progress_percent = (int)percent_float;
wxString msg = wxString::Format(_L("Loading file: %s"), from_path(real_filename));
cont = dlg.Update(progress_percent, msg);
cancel = !cont;
},
[](int isUtf8StepFile) {
if (!isUtf8StepFile) {
const auto no_warn = wxGetApp().app_config->get_bool("step_not_utf8_no_warn");
if (!no_warn) {
@ -4208,8 +4185,40 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
}
}
},
nullptr, 0, obj_color_fun, step_mesh);
[this, &path, &is_user_cancel, &linear, &angle](Slic3r::Step& file, double& linear_value, double& angle_value)-> int {
if (wxGetApp().app_config->get_bool("enable_step_mesh_setting")) {
StepMeshDialog mesh_dlg(nullptr, file);
if (mesh_dlg.ShowModal() == wxID_OK) {
linear_value = mesh_dlg.get_linear_defletion();
angle_value = mesh_dlg.get_angle_defletion();
return 1;
}
}else {
linear_value = linear;
angle_value = angle;
return 1;
}
is_user_cancel = true;
return -1;
}, linear, angle);
}else {
model = Slic3r::Model:: read_from_file(
path.string(), nullptr, nullptr, strategy, &plate_data, &project_presets, &is_xxx, &file_version, nullptr,
[this, &dlg, real_filename, &progress_percent, &file_percent, INPUT_FILES_RATIO, total_files, i, &designer_model_id, &designer_country_code](int current, int total, bool &cancel, std::string &mode_id, std::string &code)
{
designer_model_id = mode_id;
designer_country_code = code;
bool cont = true;
float percent_float = (100.0f * (float)i / (float)total_files) + INPUT_FILES_RATIO * 100.0f * ((float)current / (float)total) / (float)total_files;
BOOST_LOG_TRIVIAL(trace) << "load_stl_file: percent(float)=" << percent_float << ", curr = " << current << ", total = " << total;
progress_percent = (int)percent_float;
wxString msg = wxString::Format(_L("Loading file: %s"), from_path(real_filename));
cont = dlg.Update(progress_percent, msg);
cancel = !cont;
},
nullptr, 0, obj_color_fun);
}
if (designer_model_id.empty() && boost::algorithm::iends_with(path.string(), ".stl")) {
read_binary_stl(path.string(), designer_model_id, designer_country_code);
@ -5952,7 +5961,7 @@ void Plater::priv::reload_from_disk()
// BBS: backup
new_model = Model::read_from_file(path, nullptr, nullptr, LoadStrategy::AddDefaultInstances | LoadStrategy::LoadModel, &plate_data, &project_presets, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, 0, obj_color_fun);
nullptr, nullptr, nullptr, nullptr, 0, obj_color_fun);
for (ModelObject* model_object : new_model.objects)
{
model_object->center_around_origin();