diff options
author | bubnikv <bubnikv@gmail.com> | 2020-02-27 13:44:01 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2020-02-27 13:44:12 +0300 |
commit | b4d0d9610e23ad46b9f4ad6b32467f527611aa71 (patch) | |
tree | 7e769995d395629db485a6ef005390b60334cc6a /src/slic3r/GUI/Tab.cpp | |
parent | f053869b564c04f26a3573a8f3552f9489336d7d (diff) |
Various changes in handling of profile compatiblilities
and the "show incompatible profiles" option.
It was not able to select the incompatible Print profile, which is
possible now.
(see Cannot select incompatible printer profile #3715)
When the Printer profile derived from the Prusa3D system profile was
active or a system Prusa3D profile was active, and when the Print profile
with the removed "inherits" field was active (or any other profile
derived from the "-- default --" profile was active), then the filament
selector offered just the profiles with the removed "inherits" field
(or any other profile derived from the "-- default--") profile.
This behavior has been now changed, so that in this scenario the Filament selector
will offer the Prusa3D vendor profiles compatible with the active Print
and Printer profile as well as the user profiles.
Slicer was also changed to keep an incompatible preset selected
at its respective tab if its respective "Red flag" is enabled.
For example, if an incompatible Print preset is selected and a Printer
profile is switched to another one which is not compatible with the active
Print preset that was red already, the active Print preset is
not switched if the Print "Red flag" is active. However, if the Print profile
was compatible before the Printer profile is switched and now the Print
profile becomes incompatible, another compatible Print profile is selected.
A likely bug in wxWidgets was worked around when switching a Print preset
on Plater, if the last item in the Print preset was active and incompatible,
and another Print preset was selected by the user. On Windows, an CBN_EDITCHANGE
is sent just after combo box selection change event and the CBN_EDITCHANGE
holds an index of the combo box item, which will be removed by the 1st event,
therefore leading to an assert in wxWidgets on CBN_EDITCHANGE. The workaround
is to disable processing of CBN_EDITCHANGE on Windows for the Plater
preset selection combo boxes.
Diffstat (limited to 'src/slic3r/GUI/Tab.cpp')
-rw-r--r-- | src/slic3r/GUI/Tab.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index fefc8e113..19d085420 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -38,8 +38,6 @@ namespace GUI { wxDEFINE_EVENT(EVT_TAB_VALUE_CHANGED, wxCommandEvent); wxDEFINE_EVENT(EVT_TAB_PRESETS_CHANGED, SimpleEvent); -// Tab::Tab(wxNotebook* parent, const wxString& title, const char* name) : -// m_parent(parent), m_title(title), m_name(name) Tab::Tab(wxNotebook* parent, const wxString& title, Preset::Type type) : m_parent(parent), m_title(title), m_type(type) { @@ -264,7 +262,7 @@ void Tab::create_preset_tab() // Initialize the DynamicPrintConfig by default keys/values. build(); rebuild_page_tree(); - m_complited = true; + m_completed = true; } void Tab::add_scaled_button(wxWindow* parent, @@ -833,7 +831,7 @@ void Tab::load_key_value(const std::string& opt_key, const boost::any& value, bo // Mark the print & filament enabled if they are compatible with the currently selected preset. if (opt_key == "compatible_printers" || opt_key == "compatible_prints") { // Don't select another profile if this profile happens to become incompatible. - m_preset_bundle->update_compatible(false); + m_preset_bundle->update_compatible(PresetSelectCompatibleType::Never); } m_presets->update_dirty_ui(m_presets_choice); on_presets_changed(); @@ -2778,6 +2776,7 @@ void Tab::select_preset(std::string preset_name, bool delete_current) bool print_tab = m_presets->type() == Preset::TYPE_PRINT || m_presets->type() == Preset::TYPE_SLA_PRINT; bool printer_tab = m_presets->type() == Preset::TYPE_PRINTER; bool canceled = false; + bool technology_changed = false; m_dependent_tabs = {}; if (current_dirty && ! may_discard_current_dirty_preset()) { canceled = true; @@ -2786,10 +2785,12 @@ void Tab::select_preset(std::string preset_name, bool delete_current) // are compatible with the new print. // If it is not compatible and the current filament or SLA material are dirty, let user decide // whether to discard the changes or keep the current print selection. - PrinterTechnology printer_technology = m_preset_bundle->printers.get_edited_preset().printer_technology(); + PresetWithVendorProfile printer_profile = m_preset_bundle->printers.get_edited_preset_with_vendor_profile(); + PrinterTechnology printer_technology = printer_profile.preset.printer_technology(); PresetCollection &dependent = (printer_technology == ptFFF) ? m_preset_bundle->filaments : m_preset_bundle->sla_materials; bool old_preset_dirty = dependent.current_is_dirty(); - bool new_preset_compatible = is_compatible_with_print(dependent.get_edited_preset_with_vendor_profile(), m_presets->get_preset_with_vendor_profile(*m_presets->find_preset(preset_name, true))); + bool new_preset_compatible = is_compatible_with_print(dependent.get_edited_preset_with_vendor_profile(), + m_presets->get_preset_with_vendor_profile(*m_presets->find_preset(preset_name, true)), printer_profile); if (! canceled) canceled = old_preset_dirty && ! new_preset_compatible && ! may_discard_current_dirty_preset(&dependent, preset_name); if (! canceled) { @@ -2842,6 +2843,8 @@ void Tab::select_preset(std::string preset_name, bool delete_current) } } } + if (! canceled) + technology_changed = old_printer_technology != new_printer_technology; } if (! canceled && delete_current) { @@ -2870,8 +2873,15 @@ void Tab::select_preset(std::string preset_name, bool delete_current) // Mark the print & filament enabled if they are compatible with the currently selected preset. // The following method should not discard changes of current print or filament presets on change of a printer profile, // if they are compatible with the current printer. + auto update_compatible_type = [](bool technology_changed, bool on_page, bool show_incompatible_presets) { + return technology_changed ? PresetSelectCompatibleType::Always : + on_page ? PresetSelectCompatibleType::Never : + (show_incompatible_presets ? PresetSelectCompatibleType::OnlyIfWasCompatible : PresetSelectCompatibleType::Always); + }; if (current_dirty || delete_current || print_tab || printer_tab) - m_preset_bundle->update_compatible(true); + m_preset_bundle->update_compatible( + update_compatible_type(technology_changed, print_tab, (print_tab ? this : wxGetApp().get_tab(Preset::TYPE_PRINT))->m_show_incompatible_presets), + update_compatible_type(technology_changed, false, wxGetApp().get_tab(Preset::TYPE_FILAMENT)->m_show_incompatible_presets)); // Initialize the UI from the current preset. if (printer_tab) static_cast<TabPrinter*>(this)->update_pages(); @@ -3084,7 +3094,7 @@ void Tab::save_preset(std::string name /*= ""*/) // Save the preset into Slic3r::data_dir / presets / section_name / preset_name.ini m_presets->save_current_preset(name); // Mark the print & filament enabled if they are compatible with the currently selected preset. - m_preset_bundle->update_compatible(false); + m_preset_bundle->update_compatible(PresetSelectCompatibleType::Never); // Add the new item into the UI component, remove dirty flags and activate the saved item. update_tab_ui(); // Update the selection boxes at the plater. |