mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-19 04:37:52 -06:00
Fix of a selection of default print / filament / sla print / sla material
profile after wizard closes for the first time with the first printer installed.
This commit is contained in:
parent
a94de05499
commit
1f5b7fc162
2 changed files with 28 additions and 16 deletions
|
@ -1484,11 +1484,15 @@ void PresetBundle::update_compatible(PresetSelectCompatibleType select_other_pri
|
||||||
|
|
||||||
int operator()(const Preset &preset) const
|
int operator()(const Preset &preset) const
|
||||||
{
|
{
|
||||||
return (! m_prefered_alias.empty() && m_prefered_alias == preset.alias) ?
|
return
|
||||||
// Matching an alias, always take this preset with priority.
|
preset.is_default || preset.is_external ?
|
||||||
std::numeric_limits<int>::max() :
|
// Don't match any properties of the "-- default --" profile or the external profiles when switching printer profile.
|
||||||
// Otherwise take the prefered profile, or the first compatible.
|
0 :
|
||||||
preset.name == m_prefered_name;
|
! m_prefered_alias.empty() && m_prefered_alias == preset.alias ?
|
||||||
|
// Matching an alias, always take this preset with priority.
|
||||||
|
std::numeric_limits<int>::max() :
|
||||||
|
// Otherwise take the prefered profile, or the first compatible.
|
||||||
|
preset.name == m_prefered_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1500,11 +1504,14 @@ void PresetBundle::update_compatible(PresetSelectCompatibleType select_other_pri
|
||||||
class PreferedPrintProfileMatch : public PreferedProfileMatch
|
class PreferedPrintProfileMatch : public PreferedProfileMatch
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PreferedPrintProfileMatch(const Preset &preset, const std::string &prefered_name) :
|
PreferedPrintProfileMatch(const Preset *preset, const std::string &prefered_name) :
|
||||||
PreferedProfileMatch(preset.alias, prefered_name), m_prefered_layer_height(preset.config.opt_float("layer_height")) {}
|
PreferedProfileMatch(preset ? preset->alias : std::string(), prefered_name), m_prefered_layer_height(preset ? preset->config.opt_float("layer_height") : 0) {}
|
||||||
|
|
||||||
int operator()(const Preset &preset) const
|
int operator()(const Preset &preset) const
|
||||||
{
|
{
|
||||||
|
// Don't match any properties of the "-- default --" profile or the external profiles when switching printer profile.
|
||||||
|
if (preset.is_default || preset.is_external)
|
||||||
|
return 0;
|
||||||
int match_quality = PreferedProfileMatch::operator()(preset);
|
int match_quality = PreferedProfileMatch::operator()(preset);
|
||||||
if (match_quality < std::numeric_limits<int>::max()) {
|
if (match_quality < std::numeric_limits<int>::max()) {
|
||||||
match_quality += 1;
|
match_quality += 1;
|
||||||
|
@ -1528,6 +1535,9 @@ void PresetBundle::update_compatible(PresetSelectCompatibleType select_other_pri
|
||||||
|
|
||||||
int operator()(const Preset &preset) const
|
int operator()(const Preset &preset) const
|
||||||
{
|
{
|
||||||
|
// Don't match any properties of the "-- default --" profile or the external profiles when switching printer profile.
|
||||||
|
if (preset.is_default || preset.is_external)
|
||||||
|
return 0;
|
||||||
int match_quality = PreferedProfileMatch::operator()(preset);
|
int match_quality = PreferedProfileMatch::operator()(preset);
|
||||||
if (match_quality < std::numeric_limits<int>::max()) {
|
if (match_quality < std::numeric_limits<int>::max()) {
|
||||||
match_quality += 1;
|
match_quality += 1;
|
||||||
|
@ -1545,14 +1555,17 @@ void PresetBundle::update_compatible(PresetSelectCompatibleType select_other_pri
|
||||||
class PreferedFilamentsProfileMatch
|
class PreferedFilamentsProfileMatch
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PreferedFilamentsProfileMatch(const Preset &preset, const std::vector<std::string> &prefered_names) :
|
PreferedFilamentsProfileMatch(const Preset *preset, const std::vector<std::string> &prefered_names) :
|
||||||
m_prefered_alias(preset.alias),
|
m_prefered_alias(preset ? preset->alias : std::string()),
|
||||||
m_prefered_filament_type(preset.config.opt_string("filament_type", 0)),
|
m_prefered_filament_type(preset ? preset->config.opt_string("filament_type", 0) : std::string()),
|
||||||
m_prefered_names(prefered_names)
|
m_prefered_names(prefered_names)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
int operator()(const Preset &preset) const
|
int operator()(const Preset &preset) const
|
||||||
{
|
{
|
||||||
|
// Don't match any properties of the "-- default --" profile or the external profiles when switching printer profile.
|
||||||
|
if (preset.is_default || preset.is_external)
|
||||||
|
return 0;
|
||||||
if (! m_prefered_alias.empty() && m_prefered_alias == preset.alias)
|
if (! m_prefered_alias.empty() && m_prefered_alias == preset.alias)
|
||||||
// Matching an alias, always take this preset with priority.
|
// Matching an alias, always take this preset with priority.
|
||||||
return std::numeric_limits<int>::max();
|
return std::numeric_limits<int>::max();
|
||||||
|
@ -1575,7 +1588,7 @@ void PresetBundle::update_compatible(PresetSelectCompatibleType select_other_pri
|
||||||
assert(printer_preset.config.has("default_filament_profile"));
|
assert(printer_preset.config.has("default_filament_profile"));
|
||||||
const std::vector<std::string> &prefered_filament_profiles = printer_preset.config.option<ConfigOptionStrings>("default_filament_profile")->values;
|
const std::vector<std::string> &prefered_filament_profiles = printer_preset.config.option<ConfigOptionStrings>("default_filament_profile")->values;
|
||||||
this->prints.update_compatible(printer_preset_with_vendor_profile, nullptr, select_other_print_if_incompatible,
|
this->prints.update_compatible(printer_preset_with_vendor_profile, nullptr, select_other_print_if_incompatible,
|
||||||
PreferedPrintProfileMatch(this->prints.get_edited_preset(), printer_preset.config.opt_string("default_print_profile")));
|
PreferedPrintProfileMatch(this->prints.get_selected_idx() == size_t(-1) ? nullptr : &this->prints.get_edited_preset(), printer_preset.config.opt_string("default_print_profile")));
|
||||||
const PresetWithVendorProfile print_preset_with_vendor_profile = this->prints.get_edited_preset_with_vendor_profile();
|
const PresetWithVendorProfile print_preset_with_vendor_profile = this->prints.get_edited_preset_with_vendor_profile();
|
||||||
// Remember whether the filament profiles were compatible before updating the filament compatibility.
|
// Remember whether the filament profiles were compatible before updating the filament compatibility.
|
||||||
std::vector<char> filament_preset_was_compatible(this->filament_presets.size(), false);
|
std::vector<char> filament_preset_was_compatible(this->filament_presets.size(), false);
|
||||||
|
@ -1585,7 +1598,7 @@ void PresetBundle::update_compatible(PresetSelectCompatibleType select_other_pri
|
||||||
}
|
}
|
||||||
// First select a first compatible profile for the preset editor.
|
// First select a first compatible profile for the preset editor.
|
||||||
this->filaments.update_compatible(printer_preset_with_vendor_profile, &print_preset_with_vendor_profile, select_other_filament_if_incompatible,
|
this->filaments.update_compatible(printer_preset_with_vendor_profile, &print_preset_with_vendor_profile, select_other_filament_if_incompatible,
|
||||||
PreferedFilamentsProfileMatch(this->filaments.get_edited_preset(), prefered_filament_profiles));
|
PreferedFilamentsProfileMatch(this->filaments.get_selected_idx() == size_t(-1) ? nullptr : &this->filaments.get_edited_preset(), prefered_filament_profiles));
|
||||||
if (select_other_filament_if_incompatible != PresetSelectCompatibleType::Never) {
|
if (select_other_filament_if_incompatible != PresetSelectCompatibleType::Never) {
|
||||||
// Verify validity of the current filament presets.
|
// Verify validity of the current filament presets.
|
||||||
const std::string prefered_filament_profile = prefered_filament_profiles.empty() ? std::string() : prefered_filament_profiles.front();
|
const std::string prefered_filament_profile = prefered_filament_profiles.empty() ? std::string() : prefered_filament_profiles.front();
|
||||||
|
@ -1612,10 +1625,10 @@ void PresetBundle::update_compatible(PresetSelectCompatibleType select_other_pri
|
||||||
assert(printer_preset.config.has("default_sla_print_profile"));
|
assert(printer_preset.config.has("default_sla_print_profile"));
|
||||||
assert(printer_preset.config.has("default_sla_material_profile"));
|
assert(printer_preset.config.has("default_sla_material_profile"));
|
||||||
this->sla_prints.update_compatible(printer_preset_with_vendor_profile, nullptr, select_other_print_if_incompatible,
|
this->sla_prints.update_compatible(printer_preset_with_vendor_profile, nullptr, select_other_print_if_incompatible,
|
||||||
PreferedPrintProfileMatch(this->sla_prints.get_edited_preset(), printer_preset.config.opt_string("default_sla_print_profile")));
|
PreferedPrintProfileMatch(this->sla_prints.get_selected_idx() == size_t(-1) ? nullptr : &this->sla_prints.get_edited_preset(), printer_preset.config.opt_string("default_sla_print_profile")));
|
||||||
const PresetWithVendorProfile sla_print_preset_with_vendor_profile = this->sla_prints.get_edited_preset_with_vendor_profile();
|
const PresetWithVendorProfile sla_print_preset_with_vendor_profile = this->sla_prints.get_edited_preset_with_vendor_profile();
|
||||||
this->sla_materials.update_compatible(printer_preset_with_vendor_profile, &sla_print_preset_with_vendor_profile, select_other_filament_if_incompatible,
|
this->sla_materials.update_compatible(printer_preset_with_vendor_profile, &sla_print_preset_with_vendor_profile, select_other_filament_if_incompatible,
|
||||||
PreferedProfileMatch(this->sla_materials.get_edited_preset().alias, printer_preset.config.opt_string("default_sla_material_profile")));
|
PreferedProfileMatch(this->sla_materials.get_selected_idx() == size_t(-1) ? std::string() : this->sla_materials.get_edited_preset().alias, printer_preset.config.opt_string("default_sla_material_profile")));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
|
|
|
@ -26,8 +26,7 @@ public:
|
||||||
|
|
||||||
// Load ini files of all types (print, filament, printer) from Slic3r::data_dir() / presets.
|
// Load ini files of all types (print, filament, printer) from Slic3r::data_dir() / presets.
|
||||||
// Load selections (current print, current filaments, current printer) from config.ini
|
// Load selections (current print, current filaments, current printer) from config.ini
|
||||||
// This is done just once on application start up.
|
void load_presets(AppConfig &config, const std::string &preferred_model_id = std::string());
|
||||||
void load_presets(AppConfig &config, const std::string &preferred_model_id = "");
|
|
||||||
|
|
||||||
// Export selections (current print, current filaments, current printer) into config.ini
|
// Export selections (current print, current filaments, current printer) into config.ini
|
||||||
void export_selections(AppConfig &config);
|
void export_selections(AppConfig &config);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue