mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 23:17:35 -06:00
QoL: Port profile value transfer on profile diff dialog from PrusaSlicer (#3737)
* DiffDialog: Implemented a transfer of options from one preset to another Related to [Feature Request] #5384 - Copy values in Profile comparaison dialog Cherry-picked from prusa3d/PrusaSlicer@0b8d7380ff Co-authored-by: YuSanka <yusanka@gmail.com> * Remove save button * Sync with latest PS * Use Orca button style * Show tips about trasnfer disabled --------- Co-authored-by: YuSanka <yusanka@gmail.com>
This commit is contained in:
parent
48541be681
commit
55b6f2a588
13 changed files with 422 additions and 108 deletions
|
@ -1,3 +1,22 @@
|
|||
///|/ Copyright (c) Prusa Research 2017 - 2023 Oleksandra Iushchenko @YuSanka, Lukáš Matěna @lukasmatena, Lukáš Hejl @hejllukas, Vojtěch Bubník @bubnikv, Pavel Mikuš @Godrak, Tomáš Mészáros @tamasmeszaros, David Kocík @kocikdav, Enrico Turri @enricoturri1966, Vojtěch Král @vojtechkral
|
||||
///|/ Copyright (c) 2021 Martin Budden
|
||||
///|/ Copyright (c) 2021 Ilya @xorza
|
||||
///|/ Copyright (c) 2019 John Drake @foxox
|
||||
///|/ Copyright (c) 2019 Matthias Urlichs @smurfix
|
||||
///|/ Copyright (c) 2019 Thomas Moore
|
||||
///|/ Copyright (c) 2019 Sijmen Schoon
|
||||
///|/ Copyright (c) 2018 Martin Loidl @LoidlM
|
||||
///|/
|
||||
///|/ ported from lib/Slic3r/GUI/Tab.pm:
|
||||
///|/ Copyright (c) Prusa Research 2016 - 2018 Vojtěch Bubník @bubnikv, Lukáš Matěna @lukasmatena
|
||||
///|/ Copyright (c) 2015 - 2017 Joseph Lenox @lordofhyphens
|
||||
///|/ Copyright (c) Slic3r 2012 - 2016 Alessandro Ranellucci @alranel
|
||||
///|/ Copyright (c) 2016 Chow Loong Jin @hyperair
|
||||
///|/ Copyright (c) 2012 QuantumConcepts
|
||||
///|/ Copyright (c) 2012 Henrik Brix Andersen @henrikbrixandersen
|
||||
///|/
|
||||
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
// #include "libslic3r/GCodeSender.hpp"
|
||||
//#include "slic3r/Utils/Serial.hpp"
|
||||
#include "Tab.hpp"
|
||||
|
@ -1692,9 +1711,9 @@ void Tab::apply_searcher()
|
|||
wxGetApp().sidebar().get_searcher().apply(m_config, m_type, m_mode);
|
||||
}
|
||||
|
||||
void Tab::cache_config_diff(const std::vector<std::string>& selected_options)
|
||||
void Tab::cache_config_diff(const std::vector<std::string>& selected_options, const DynamicPrintConfig* config/* = nullptr*/)
|
||||
{
|
||||
m_cache_config.apply_only(m_presets->get_edited_preset().config, selected_options);
|
||||
m_cache_config.apply_only(config ? *config : m_presets->get_edited_preset().config, selected_options);
|
||||
}
|
||||
|
||||
void Tab::apply_config_from_cache()
|
||||
|
@ -5076,6 +5095,32 @@ void Tab::compare_preset()
|
|||
wxGetApp().mainframe->diff_dialog.show(m_type);
|
||||
}
|
||||
|
||||
void Tab::transfer_options(const std::string &name_from, const std::string &name_to, std::vector<std::string> options)
|
||||
{
|
||||
if (options.empty())
|
||||
return;
|
||||
|
||||
Preset* preset_from = m_presets->find_preset(name_from);
|
||||
Preset* preset_to = m_presets->find_preset(name_to);
|
||||
|
||||
if (m_type == Preset::TYPE_PRINTER) {
|
||||
auto it = std::find(options.begin(), options.end(), "extruders_count");
|
||||
if (it != options.end()) {
|
||||
// erase "extruders_count" option from the list
|
||||
options.erase(it);
|
||||
// cache the extruders count
|
||||
static_cast<TabPrinter*>(this)->cache_extruder_cnt(&preset_from->config);
|
||||
}
|
||||
}
|
||||
cache_config_diff(options, &preset_from->config);
|
||||
|
||||
if (name_to != m_presets->get_edited_preset().name )
|
||||
select_preset(preset_to->name);
|
||||
|
||||
apply_config_from_cache();
|
||||
load_current_preset();
|
||||
}
|
||||
|
||||
// Save the current preset into file.
|
||||
// This removes the "dirty" flag of the preset, possibly creates a new preset under a new name,
|
||||
// and activates the new preset.
|
||||
|
@ -5513,13 +5558,15 @@ wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent)
|
|||
return sizer;
|
||||
}
|
||||
|
||||
void TabPrinter::cache_extruder_cnt()
|
||||
void TabPrinter::cache_extruder_cnt(const DynamicPrintConfig* config/* = nullptr*/)
|
||||
{
|
||||
if (m_presets->get_edited_preset().printer_technology() == ptSLA)
|
||||
const DynamicPrintConfig& cached_config = config ? *config : m_presets->get_edited_preset().config;
|
||||
if (Preset::printer_technology(cached_config) == ptSLA)
|
||||
return;
|
||||
|
||||
// BBS. Get extruder count from preset instead of m_extruders_count.
|
||||
m_cache_extruder_count = dynamic_cast<ConfigOptionFloats*>((m_presets->get_edited_preset().config).option("nozzle_diameter"))->values.size();
|
||||
// get extruders count
|
||||
auto* nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(cached_config.option("nozzle_diameter"));
|
||||
m_cache_extruder_count = nozzle_diameter->values.size(); //m_extruders_count;
|
||||
}
|
||||
|
||||
bool TabPrinter::apply_extruder_cnt_from_cache()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue