Allow to switch to the Simple mode, when all objects are single-parts or have support-modificators only.

+ Object's menu for Advanced and Expert mode are the same now.

+ "wxYES|wxCANCEL" style is changed to "wxOK|wxCANCEL" for MessageDialog.
The reason: wxWidgets implementation for Linux doesn't respects to "wxYES|wxCANCEL" style for MessageDialog.
In this case massage dialog has "wxYES_NO|wxCANCEL" style.
This commit is contained in:
YuSanka 2023-01-23 10:24:17 +01:00
parent f327b805db
commit c16fa93bdb
5 changed files with 38 additions and 15 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);
}

View File

@ -2659,9 +2659,9 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& 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);
_L("Detected advanced data"), wxICON_WARNING | wxOK | wxCANCEL);
if (msg_dlg.ShowModal() == wxID_OK) {
if (wxGetApp().save_mode(comAdvanced))
view3D->set_as_dirty();
}
else
@ -5299,7 +5299,7 @@ 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);
if (wxGetApp().save_mode(comAdvanced))
view3D->set_as_dirty();
}

View File

@ -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);
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);