mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
Limit visibility of custom filament profiles based on OrcaFilamentLibrary to currently selected printer only (#8779)
Set compatible_printers when creating custom filament profiles so that this custom profile won't be visible automatically for all printers.
This commit is contained in:
parent
c150bbf61c
commit
312ddaa8fb
3 changed files with 18 additions and 4 deletions
|
@ -2235,7 +2235,7 @@ std::map<std::string, std::vector<Preset const *>> PresetCollection::get_filamen
|
||||||
}
|
}
|
||||||
|
|
||||||
//BBS: add project embedded preset logic
|
//BBS: add project embedded preset logic
|
||||||
void PresetCollection::save_current_preset(const std::string &new_name, bool detach, bool save_to_project, Preset* _curr_preset)
|
void PresetCollection::save_current_preset(const std::string &new_name, bool detach, bool save_to_project, Preset* _curr_preset, const Preset* _current_printer)
|
||||||
{
|
{
|
||||||
Preset curr_preset = _curr_preset ? *_curr_preset : m_edited_preset;
|
Preset curr_preset = _curr_preset ? *_curr_preset : m_edited_preset;
|
||||||
//BBS: add lock logic for sync preset in background
|
//BBS: add lock logic for sync preset in background
|
||||||
|
@ -2303,6 +2303,14 @@ void PresetCollection::save_current_preset(const std::string &new_name, bool det
|
||||||
} else if (is_base_preset(preset)) {
|
} else if (is_base_preset(preset)) {
|
||||||
inherits = old_name;
|
inherits = old_name;
|
||||||
}
|
}
|
||||||
|
// Orca: check if compatible_printers exists and is not empty, set it to the current printer if it is empty
|
||||||
|
if (nullptr != _current_printer && preset.is_system && m_type == Preset::TYPE_FILAMENT) {
|
||||||
|
ConfigOptionStrings* compatible_printers = preset.config.option<ConfigOptionStrings>("compatible_printers");
|
||||||
|
if (compatible_printers && compatible_printers->values.empty()) {
|
||||||
|
compatible_printers->values.push_back(_current_printer->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
preset.is_default = false;
|
preset.is_default = false;
|
||||||
preset.is_system = false;
|
preset.is_system = false;
|
||||||
preset.is_external = false;
|
preset.is_external = false;
|
||||||
|
|
|
@ -522,7 +522,7 @@ public:
|
||||||
// a new preset is stored into the list of presets.
|
// a new preset is stored into the list of presets.
|
||||||
// All presets are marked as not modified and the new preset is activated.
|
// All presets are marked as not modified and the new preset is activated.
|
||||||
//BBS: add project embedded preset logic
|
//BBS: add project embedded preset logic
|
||||||
void save_current_preset(const std::string &new_name, bool detach = false, bool save_to_project = false, Preset* _curr_preset = nullptr);
|
void save_current_preset(const std::string &new_name, bool detach = false, bool save_to_project = false, Preset* _curr_preset = nullptr, const Preset* _current_printer = nullptr);
|
||||||
|
|
||||||
// Delete the current preset, activate the first visible preset.
|
// Delete the current preset, activate the first visible preset.
|
||||||
// returns true if the preset was deleted successfully.
|
// returns true if the preset was deleted successfully.
|
||||||
|
@ -566,6 +566,8 @@ public:
|
||||||
Preset& get_edited_preset() { return m_edited_preset; }
|
Preset& get_edited_preset() { return m_edited_preset; }
|
||||||
const Preset& get_edited_preset() const { return m_edited_preset; }
|
const Preset& get_edited_preset() const { return m_edited_preset; }
|
||||||
|
|
||||||
|
const Preset& get_selected_preset_base() const { return *get_preset_base(m_presets[m_idx_selected]); }
|
||||||
|
|
||||||
// Return the last saved preset.
|
// Return the last saved preset.
|
||||||
// const Preset& get_saved_preset() const { return m_saved_preset; }
|
// const Preset& get_saved_preset() const { return m_saved_preset; }
|
||||||
|
|
||||||
|
|
|
@ -5561,8 +5561,12 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach, bool save_to_proje
|
||||||
exist_preset = true;
|
exist_preset = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the preset into Slic3r::data_dir / presets / section_name / preset_name.ini
|
Preset* _current_printer = nullptr;
|
||||||
m_presets->save_current_preset(name, detach, save_to_project);
|
if (m_presets->type() == Preset::TYPE_FILAMENT) {
|
||||||
|
_current_printer = const_cast<Preset*>(&wxGetApp().preset_bundle->printers.get_selected_preset_base());
|
||||||
|
}
|
||||||
|
// Save the preset into Slic3r::data_dir / presets / section_name / preset_name.json
|
||||||
|
m_presets->save_current_preset(name, detach, save_to_project, nullptr, _current_printer);
|
||||||
|
|
||||||
//BBS create new settings
|
//BBS create new settings
|
||||||
new_preset = m_presets->find_preset(name, false, true);
|
new_preset = m_presets->find_preset(name, false, true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue