Merge remote-tracking branch 'remotes/origin/master' into vb_ensurovani

This commit is contained in:
Vojtech Bubnik 2023-01-03 12:58:25 +01:00
commit 4f24945727
5 changed files with 31 additions and 8 deletions

View File

@ -4188,6 +4188,8 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
wxGetApp().preset_bundle->set_filament_preset(idx, preset_name);
}
std::string last_selected_ph_printer_name = combo->get_selected_ph_printer_name();
bool select_preset = !combo->selection_is_changed_according_to_physical_printers();
// TODO: ?
if (preset_type == Preset::TYPE_FILAMENT && sidebar->is_multifilament()) {
@ -4196,7 +4198,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
}
else if (select_preset) {
wxWindowUpdateLocker noUpdates(sidebar->presets_panel());
wxGetApp().get_tab(preset_type)->select_preset(preset_name);
wxGetApp().get_tab(preset_type)->select_preset(preset_name, false, last_selected_ph_printer_name);
}
if (preset_type != Preset::TYPE_PRINTER || select_preset) {

View File

@ -666,6 +666,18 @@ void PlaterPresetComboBox::OnSelect(wxCommandEvent &evt)
evt.Skip();
}
std::string PlaterPresetComboBox::get_selected_ph_printer_name() const
{
if (m_type != Preset::TYPE_PRINTER)
return {};
const PhysicalPrinterCollection& physical_printers = m_preset_bundle->physical_printers;
if (physical_printers.has_selection())
return physical_printers.get_selected_full_printer_name();
return {};
}
void PlaterPresetComboBox::switch_to_tab()
{
Tab* tab = wxGetApp().get_tab(m_type);

View File

@ -164,6 +164,8 @@ public:
void sys_color_changed() override;
void OnSelect(wxCommandEvent& evt) override;
std::string get_selected_ph_printer_name() const;
private:
int m_extruder_idx = -1;
};

View File

@ -2978,6 +2978,10 @@ void TabPrinter::activate_selected_page(std::function<void()> throw_if_canceled)
void TabPrinter::clear_pages()
{
Tab::clear_pages();
m_machine_limits_description_line = nullptr;
m_fff_print_host_upload_description_line = nullptr;
m_sla_print_host_upload_description_line = nullptr;
}
void TabPrinter::toggle_options()
@ -3402,7 +3406,7 @@ void Tab::select_preset(std::string preset_name, bool delete_current /*=false*/,
// If preset selection was canceled and previously was selected physical printer, we should select it back
m_preset_bundle->physical_printers.select_printer(last_selected_ph_printer_name);
}
if (m_preset_bundle->physical_printers.has_selection()) {
else if (m_preset_bundle->physical_printers.has_selection()) {
// If preset selection was canceled and physical printer was selected
// we must disable selection marker for the physical printers
m_preset_bundle->physical_printers.unselect_printer();

View File

@ -1571,6 +1571,13 @@ void DiffPresetDialog::create_tree()
m_tree->GetColumn(DiffModel::colToggle)->SetHidden(true);
}
static std::array<Preset::Type, 3> types_list(PrinterTechnology pt)
{
if (pt == ptFFF)
return { Preset::TYPE_PRINTER, Preset::TYPE_PRINT, Preset::TYPE_FILAMENT };
return { Preset::TYPE_PRINTER, Preset::TYPE_SLA_PRINT, Preset::TYPE_SLA_MATERIAL };
}
void DiffPresetDialog::create_buttons()
{
wxFont font = this->GetFont().Scaled(1.4f);
@ -1598,8 +1605,7 @@ void DiffPresetDialog::create_buttons()
bool enable = m_tree->has_selection();
if (enable) {
if (m_view_type == Preset::TYPE_INVALID) {
for (const Preset::Type& type : (m_pr_technology == ptFFF ? std::initializer_list<Preset::Type>{Preset::TYPE_PRINTER, Preset::TYPE_PRINT, Preset::TYPE_FILAMENT} :
std::initializer_list<Preset::Type>{ Preset::TYPE_PRINTER, Preset::TYPE_SLA_PRINT, Preset::TYPE_SLA_MATERIAL }))
for (const Preset::Type& type : types_list(m_pr_technology))
if (!enable_transfer(type)) {
enable = false;
break;
@ -2024,10 +2030,7 @@ bool DiffPresetDialog::is_save_confirmed()
std::vector<Preset::Type> types_for_save;
const auto list = m_pr_technology == ptFFF ? std::initializer_list<Preset::Type>{Preset::TYPE_PRINTER, Preset::TYPE_PRINT, Preset::TYPE_FILAMENT} :
std::initializer_list<Preset::Type>{ Preset::TYPE_PRINTER, Preset::TYPE_SLA_PRINT, Preset::TYPE_SLA_MATERIAL };
for (const Preset::Type& type : list) {
for (const Preset::Type& type : types_list(m_pr_technology)) {
if (!m_tree->options(type, true).empty()) {
types_for_save.emplace_back(type);
presets_to_save.emplace_back(PresetToSave{ type, get_left_preset_name(type), get_right_preset_name(type), get_right_preset_name(type) });