Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorenricoturri1966 <enricoturri@seznam.cz>2022-01-04 11:57:45 +0300
committerenricoturri1966 <enricoturri@seznam.cz>2022-01-04 11:57:45 +0300
commit0df7efe462f2b09da216f1caa219816dd6269af6 (patch)
treee63c2e66e3412ad6a8d2b10a4feb5209ad961900 /src/slic3r/GUI
parenta554f1fb089ccbc6fee995571091054703ca181d (diff)
#7550 - Fixed error message when trying to import an invalid stl for commands 'Reload from disk' and 'Replace with STL'
Diffstat (limited to 'src/slic3r/GUI')
-rw-r--r--src/slic3r/GUI/Plater.cpp51
1 files changed, 42 insertions, 9 deletions
diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp
index b3ec46425..3f5e74ffd 100644
--- a/src/slic3r/GUI/Plater.cpp
+++ b/src/slic3r/GUI/Plater.cpp
@@ -3378,11 +3378,39 @@ void Plater::priv::update_sla_scene()
this->update_restart_background_process(true, true);
}
+// class used to show a wxBusyCursor and a wxBusyInfo
+// and hide them on demand
+class Busy
+{
+ wxWindow* m_parent{ nullptr };
+ std::unique_ptr<wxBusyCursor> m_cursor;
+ std::unique_ptr<wxBusyInfo> m_dlg;
+
+public:
+ Busy(const wxString& message, wxWindow* parent = nullptr) {
+ m_parent = parent;
+ m_cursor = std::make_unique<wxBusyCursor>();
+ m_dlg = std::make_unique<wxBusyInfo>(message, m_parent);
+ }
+
+ ~Busy() { reset(); }
+
+ void update(const wxString& message) {
+ // this is ugly but necessary because the call to wxBusyInfo::UpdateLabel() is not working [WX 3.1.4]
+ m_dlg = std::make_unique<wxBusyInfo>(message, m_parent);
+// m_dlg->UpdateLabel(message);
+ }
+
+ void reset() {
+ m_cursor.reset();
+ m_dlg.reset();
+ }
+};
+
bool Plater::priv::replace_volume_with_stl(int object_idx, int volume_idx, const fs::path& new_path, const wxString& snapshot)
{
const std::string path = new_path.string();
- wxBusyCursor wait;
- wxBusyInfo info(_L("Replace from:") + " " + from_u8(path), q->get_current_canvas3D()->get_wxglcanvas());
+ Busy busy(_L("Replace from:") + " " + from_u8(path), q->get_current_canvas3D()->get_wxglcanvas());
Model new_model;
try {
@@ -3392,8 +3420,10 @@ bool Plater::priv::replace_volume_with_stl(int object_idx, int volume_idx, const
model_object->ensure_on_bed();
}
}
- catch (std::exception&) {
+ catch (std::exception& e) {
// error while loading
+ busy.reset();
+ GUI::show_error(q, e.what());
return false;
}
@@ -3617,12 +3647,13 @@ void Plater::priv::reload_from_disk()
std::vector<wxString> fail_list;
+ Busy busy(_L("Reload from:"), q->get_current_canvas3D()->get_wxglcanvas());
+
// load one file at a time
for (size_t i = 0; i < input_paths.size(); ++i) {
const auto& path = input_paths[i].string();
- wxBusyCursor wait;
- wxBusyInfo info(_L("Reload from:") + " " + from_u8(path), q->get_current_canvas3D()->get_wxglcanvas());
+ busy.update(_L("Reload from:") + " " + from_u8(path));
Model new_model;
try
@@ -3633,9 +3664,11 @@ void Plater::priv::reload_from_disk()
model_object->ensure_on_bed();
}
}
- catch (std::exception&)
+ catch (std::exception& e)
{
// error while loading
+ busy.reset();
+ GUI::show_error(q, e.what());
return;
}
@@ -3710,15 +3743,15 @@ void Plater::priv::reload_from_disk()
}
}
+ busy.reset();
+
for (size_t i = 0; i < replace_paths.size(); ++i) {
const auto& path = replace_paths[i].string();
for (const SelectedVolume& sel_v : selected_volumes) {
ModelObject* old_model_object = model.objects[sel_v.object_idx];
ModelVolume* old_volume = old_model_object->volumes[sel_v.volume_idx];
bool has_source = !old_volume->source.input_file.empty() && boost::algorithm::iequals(fs::path(old_volume->source.input_file).filename().string(), fs::path(path).filename().string());
- if (!replace_volume_with_stl(sel_v.object_idx, sel_v.volume_idx, path, "")) {
- fail_list.push_back(from_u8(has_source ? old_volume->source.input_file : old_volume->name));
- }
+ replace_volume_with_stl(sel_v.object_idx, sel_v.volume_idx, path, "");
}
}