diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 56b2d2eb1..e9c912da2 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -2324,13 +2324,33 @@ ConfigOptionMode GUI_App::get_mode() mode == "simple" ? comSimple : comAdvanced; } -void GUI_App::save_mode(const /*ConfigOptionMode*/int mode) +bool GUI_App::save_mode(const /*ConfigOptionMode*/int mode) { const std::string mode_str = mode == comExpert ? "expert" : mode == comSimple ? "simple" : "advanced"; + + auto can_switch_to_simple = [](Model& model) { + for (const ModelObject* model_object : model.objects) + if (model_object->volumes.size() > 1) { + for (size_t i = 1; i < model_object->volumes.size(); ++i) + if (!model_object->volumes[i]->is_support_modifier()) + return false; + } + return true; + }; + + if (mode == comSimple && !can_switch_to_simple(model())) { + show_info(nullptr, + _L("Simple mode supports manipulation with single-part object(s)\n" + "or object(s) with support modifiers only.") + "\n\n" + + _L("Please check your object list before mode changing."), + _L("Change application mode")); + return false; + } app_config->set("view_mode", mode_str); app_config->save(); update_mode(); + return true; } // Update view mode according to selected menu diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 81382d092..70d72d5e3 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -263,7 +263,7 @@ public: Tab* get_tab(Preset::Type type); ConfigOptionMode get_mode(); - void save_mode(const /*ConfigOptionMode*/int mode) ; + bool save_mode(const /*ConfigOptionMode*/int mode) ; void update_mode(); void add_config_menu(wxMenuBar *menu); diff --git a/src/slic3r/GUI/GUI_Factories.cpp b/src/slic3r/GUI/GUI_Factories.cpp index 3e01de834..4c41fd72a 100644 --- a/src/slic3r/GUI/GUI_Factories.cpp +++ b/src/slic3r/GUI/GUI_Factories.cpp @@ -465,19 +465,19 @@ void MenuFactory::append_menu_item_delete(wxMenu* menu) } -wxMenu* MenuFactory::append_submenu_add_generic(wxMenu* menu, ModelVolumeType type) { +wxMenu* MenuFactory::append_submenu_add_generic(wxMenu* menu, ModelVolumeType type) +{ auto sub_menu = new wxMenu; const ConfigOptionMode mode = wxGetApp().get_mode(); - if (mode == comExpert && type != ModelVolumeType::INVALID || - mode == comAdvanced && type == ModelVolumeType::MODEL_PART) { + if (mode > comSimple) { append_menu_item(sub_menu, wxID_ANY, _L("Load") + " " + dots, "", [type](wxCommandEvent&) { obj_list()->load_subobject(type); }, "", menu); sub_menu->AppendSeparator(); } - if (!(type == ModelVolumeType::MODEL_PART && mode == comAdvanced)) + //if (!(type == ModelVolumeType::MODEL_PART && mode == comAdvanced)) for (auto& item : { L("Box"), L("Cylinder"), L("Sphere"), L("Slab") }) { if (type == ModelVolumeType::INVALID && strncmp(item, "Slab", 4) == 0) @@ -527,6 +527,7 @@ void MenuFactory::append_menu_item_add_text(wxMenu* menu, ModelVolumeType type, ) { wxString item_name = is_submenu_item ? "" : _(ADD_VOLUME_MENU_ITEMS[int(type)].first) + ": "; item_name += _L("Text"); + menu->AppendSeparator(); const std::string icon_name = is_submenu_item ? "" : ADD_VOLUME_MENU_ITEMS[int(type)].second; append_menu_item(menu, wxID_ANY, item_name, "", add_text, icon_name, menu); } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 1b2198111..af04d5865 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2659,10 +2659,10 @@ std::vector Plater::priv::load_files(const std::vector& input_ } if ((wxGetApp().get_mode() == comSimple) && (type_3mf || type_any_amf) && model_has_advanced_features(model)) { MessageDialog msg_dlg(q, _L("This file cannot be loaded in a simple mode. Do you want to switch to an advanced mode?")+"\n", - _L("Detected advanced data"), wxICON_WARNING | wxYES | wxCANCEL); - if (msg_dlg.ShowModal() == wxID_YES) { - Slic3r::GUI::wxGetApp().save_mode(comAdvanced); - view3D->set_as_dirty(); + _L("Detected advanced data"), wxICON_WARNING | wxOK | wxCANCEL); + if (msg_dlg.ShowModal() == wxID_OK) { + if (wxGetApp().save_mode(comAdvanced)) + view3D->set_as_dirty(); } else return obj_idxs; @@ -5299,8 +5299,8 @@ void Plater::priv::update_after_undo_redo(const UndoRedo::Snapshot& snapshot, bo if (wxGetApp().get_mode() == comSimple && model_has_advanced_features(this->model)) { // If the user jumped to a snapshot that require user interface with advanced features, switch to the advanced mode without asking. // There is a little risk of surprising the user, as he already must have had the advanced or expert mode active for such a snapshot to be taken. - Slic3r::GUI::wxGetApp().save_mode(comAdvanced); - view3D->set_as_dirty(); + if (wxGetApp().save_mode(comAdvanced)) + view3D->set_as_dirty(); } // this->update() above was called with POSTPONE_VALIDATION_ERROR_MESSAGE, so that if an error message was generated when updating the back end, it would not open immediately, diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index bd2949cbf..e528191aa 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -747,9 +747,11 @@ ModeSizer::ModeSizer(wxWindow *parent, int hgap/* = 0*/) : { SetFlexibleDirection(wxHORIZONTAL); - auto modebtnfn = [](wxCommandEvent &event, int mode_id) { - Slic3r::GUI::wxGetApp().save_mode(mode_id); - event.Skip(); + auto modebtnfn = [this](wxCommandEvent &event, int mode_id) { + if (Slic3r::GUI::wxGetApp().save_mode(mode_id)) + event.Skip(); + else + SetMode(Slic3r::GUI::wxGetApp().get_mode()); }; m_mode_btns.reserve(3);