mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 02:22:17 +00:00
FIX:STEP mesh crashes in specific language
1.fix dark model 2.fix reload file 3.fix macos ui jira: STUDIO-8722 Change-Id: I17c723cbf88b97b187c72fbc6f65fc2da591465f (cherry picked from commit 6c48a8e40b3a28859d5883b13106683cbe61c73d)
This commit is contained in:
@@ -4156,10 +4156,10 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||
filament_ids.clear();
|
||||
}
|
||||
};
|
||||
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"));
|
||||
if (boost::iends_with(path.string(), ".stp") ||
|
||||
boost::iends_with(path.string(), ".step")) {
|
||||
double linear = string_to_double_decimal_point(wxGetApp().app_config->get("linear_defletion"));
|
||||
double angle = string_to_double_decimal_point(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)
|
||||
{
|
||||
@@ -4187,7 +4187,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||
},
|
||||
[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);
|
||||
StepMeshDialog mesh_dlg(nullptr, file, linear, angle);
|
||||
if (mesh_dlg.ShowModal() == wxID_OK) {
|
||||
linear_value = mesh_dlg.get_linear_defletion();
|
||||
angle_value = mesh_dlg.get_angle_defletion();
|
||||
@@ -5960,8 +5960,16 @@ void Plater::priv::reload_from_disk()
|
||||
std::vector<Preset*> project_presets;
|
||||
|
||||
// BBS: backup
|
||||
new_model = Model::read_from_file(path, nullptr, nullptr, LoadStrategy::AddDefaultInstances | LoadStrategy::LoadModel, &plate_data, &project_presets, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr, 0, obj_color_fun);
|
||||
if (boost::iends_with(path, ".stp") ||
|
||||
boost::iends_with(path, ".step")) {
|
||||
double linear = string_to_double_decimal_point(wxGetApp().app_config->get("linear_defletion"));
|
||||
double angle = string_to_double_decimal_point(wxGetApp().app_config->get("angle_defletion"));
|
||||
new_model = Model::read_from_step(path, LoadStrategy::AddDefaultInstances | LoadStrategy::LoadModel, nullptr, nullptr, nullptr, linear, angle);
|
||||
}else {
|
||||
new_model = Model::read_from_file(path, nullptr, nullptr, LoadStrategy::AddDefaultInstances | LoadStrategy::LoadModel, &plate_data, &project_presets, nullptr, nullptr, nullptr, nullptr, nullptr, 0, obj_color_fun);
|
||||
}
|
||||
|
||||
|
||||
for (ModelObject* model_object : new_model.objects)
|
||||
{
|
||||
model_object->center_around_origin();
|
||||
|
||||
@@ -66,7 +66,7 @@ bool StepMeshDialog:: validate_number_range(const wxString& value, double min, d
|
||||
return (num >= min && num <= max);
|
||||
}
|
||||
|
||||
StepMeshDialog::StepMeshDialog(wxWindow* parent, Slic3r::Step& file)
|
||||
StepMeshDialog::StepMeshDialog(wxWindow* parent, Slic3r::Step& file, double linear_init, double angle_init)
|
||||
: DPIDialog(parent ? parent : static_cast<wxWindow *>(wxGetApp().mainframe),
|
||||
wxID_ANY,
|
||||
_(L("Step file import parameters")),
|
||||
@@ -74,6 +74,9 @@ StepMeshDialog::StepMeshDialog(wxWindow* parent, Slic3r::Step& file)
|
||||
wxDefaultSize,
|
||||
wxDEFAULT_DIALOG_STYLE /* | wxRESIZE_BORDER*/), m_file(file)
|
||||
{
|
||||
m_linear_last = wxString::Format("%.3f", linear_init);
|
||||
m_angle_last = wxString::Format("%.2f", angle_init);
|
||||
|
||||
Bind(wxEVT_THREAD_DONE, &StepMeshDialog::on_task_done, this);
|
||||
|
||||
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico")
|
||||
@@ -85,17 +88,16 @@ StepMeshDialog::StepMeshDialog(wxWindow* parent, Slic3r::Step& file)
|
||||
wxBoxSizer* bSizer = new wxBoxSizer(wxVERTICAL);
|
||||
bSizer->SetMinSize(wxSize(MIN_DIALOG_WIDTH, -1));
|
||||
|
||||
auto image_bitmap = create_scaled_bitmap("step_mesh_info", this, FromDIP(120), false, std::string(), false, false, true);
|
||||
int image_width = image_bitmap.GetWidth();
|
||||
int image_height = image_bitmap.GetHeight();
|
||||
wxPanel* overlay_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, image_bitmap.GetSize(), wxTAB_TRAVERSAL);
|
||||
auto image_bitmap = create_scaled_bitmap("step_mesh_info", this, FromDIP(120));
|
||||
|
||||
wxPanel* overlay_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(image_bitmap.GetWidth()), FromDIP(image_bitmap.GetHeight())), wxTAB_TRAVERSAL);
|
||||
overlay_panel->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
wxStaticBitmap *image = new wxStaticBitmap(overlay_panel, wxID_ANY, image_bitmap, wxDefaultPosition, wxDefaultSize, 0);
|
||||
|
||||
CenteredStaticText* text_1 = new CenteredStaticText (overlay_panel, wxID_ANY, _L("Rough"),
|
||||
CenteredStaticText* text_1 = new CenteredStaticText (overlay_panel, wxID_ANY, _L("Smooth"),
|
||||
wxPoint(overlay_panel->GetSize().GetWidth() / 6,
|
||||
overlay_panel->GetSize().GetHeight() / 2));
|
||||
CenteredStaticText* text_2 = new CenteredStaticText(overlay_panel, wxID_ANY, _L("Smooth"),
|
||||
CenteredStaticText* text_2 = new CenteredStaticText(overlay_panel, wxID_ANY, _L("Rough"),
|
||||
wxPoint(overlay_panel->GetSize().GetWidth() * 5 / 6,
|
||||
overlay_panel->GetSize().GetHeight() / 2));
|
||||
CenteredStaticText* text_3 = new CenteredStaticText(overlay_panel, wxID_ANY, _L("Reduce Linear"),
|
||||
@@ -104,10 +106,10 @@ StepMeshDialog::StepMeshDialog(wxWindow* parent, Slic3r::Step& file)
|
||||
CenteredStaticText* text_4 = new CenteredStaticText(overlay_panel, wxID_ANY, _L("Reduce Angle"),
|
||||
wxPoint(overlay_panel->GetSize().GetWidth() / 2,
|
||||
overlay_panel->GetSize().GetHeight() * 2 / 3));
|
||||
CenteredStaticText* text_5 = new CenteredStaticText(overlay_panel, wxID_ANY, _L("Fewer faces"),
|
||||
CenteredStaticText* text_5 = new CenteredStaticText(overlay_panel, wxID_ANY, _L("More faces"),
|
||||
wxPoint(overlay_panel->GetSize().GetWidth() / 6,
|
||||
overlay_panel->GetSize().GetHeight() * 2.8 / 3));
|
||||
CenteredStaticText* text_6 = new CenteredStaticText(overlay_panel, wxID_ANY, _L("More faces"),
|
||||
CenteredStaticText* text_6 = new CenteredStaticText(overlay_panel, wxID_ANY, _L("Fewer faces"),
|
||||
wxPoint(overlay_panel->GetSize().GetWidth() * 5 / 6,
|
||||
overlay_panel->GetSize().GetHeight() * 2.8 / 3));
|
||||
|
||||
@@ -251,8 +253,8 @@ StepMeshDialog::StepMeshDialog(wxWindow* parent, Slic3r::Step& file)
|
||||
if (m_checkbox->IsChecked()) {
|
||||
wxGetApp().app_config->set_bool("enable_step_mesh_setting", false);
|
||||
}
|
||||
wxGetApp().app_config->set("linear_defletion", std::to_string(get_linear_defletion()));
|
||||
wxGetApp().app_config->set("angle_defletion", std::to_string(get_angle_defletion()));
|
||||
wxGetApp().app_config->set("linear_defletion", float_to_string_decimal_point(get_linear_defletion(), 3));
|
||||
wxGetApp().app_config->set("angle_defletion", float_to_string_decimal_point(get_angle_defletion(), 2));
|
||||
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
|
||||
@@ -11,20 +11,14 @@ class Button;
|
||||
class StepMeshDialog : public Slic3r::GUI::DPIDialog
|
||||
{
|
||||
public:
|
||||
StepMeshDialog(wxWindow* parent, Slic3r::Step& file);
|
||||
StepMeshDialog(wxWindow* parent, Slic3r::Step& file, double linear_init, double angle_init);
|
||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||
inline double get_linear_init() {
|
||||
return std::stod(Slic3r::GUI::wxGetApp().app_config->get("linear_defletion"));
|
||||
}
|
||||
inline double get_angle_init() {
|
||||
return std::stod(Slic3r::GUI::wxGetApp().app_config->get("angle_defletion"));
|
||||
}
|
||||
inline double get_linear_defletion() {
|
||||
double value;
|
||||
if (m_linear_last.ToDouble(&value)) {
|
||||
return value;
|
||||
}else {
|
||||
return get_linear_init();
|
||||
return m_last_linear;
|
||||
}
|
||||
}
|
||||
inline double get_angle_defletion() {
|
||||
@@ -32,7 +26,7 @@ public:
|
||||
if (m_angle_last.ToDouble(&value)) {
|
||||
return value;
|
||||
} else {
|
||||
return get_angle_init();
|
||||
return m_last_angle;
|
||||
}
|
||||
}
|
||||
private:
|
||||
@@ -40,8 +34,8 @@ private:
|
||||
Button* m_button_ok = nullptr;
|
||||
Button* m_button_cancel = nullptr;
|
||||
wxCheckBox* m_checkbox = nullptr;
|
||||
wxString m_linear_last = wxString::Format("%.3f", get_linear_init());
|
||||
wxString m_angle_last = wxString::Format("%.2f", get_angle_init());
|
||||
wxString m_linear_last;
|
||||
wxString m_angle_last;
|
||||
wxStaticText* mesh_face_number_text;
|
||||
double m_last_linear;
|
||||
double m_last_angle;
|
||||
|
||||
Reference in New Issue
Block a user