OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::PresetPluginConfigService Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/plugin/PluginConfig.hpp>

Public Member Functions

EffectiveCapabilityConfig get_effective_config (const CapabilityConfigDocument &overrides, const PluginCapabilityId &id) const
MutationResult set_preset_override (CapabilityConfigDocument &overrides, const PluginCapabilityId &id, const nlohmann::json &value) const
MutationResult remove_preset_override (CapabilityConfigDocument &overrides, const PluginCapabilityId &id) const

Detailed Description

Member Function Documentation

◆ get_effective_config()

EffectiveCapabilityConfig Slic3r::PresetPluginConfigService::get_effective_config ( const CapabilityConfigDocument & overrides,
const PluginCapabilityId & id ) const
404{
405 EffectiveCapabilityConfig result;
406 result.id = id;
407 result.running_plugin_version = running_plugin_version(id.plugin_key);
408
409 const auto base = PluginManager::instance().get_config().get_config(id);
410 result.has_base_config = base.has_value();
411
412 if (const auto entry = overrides.find(result.id)) {
413 result.has_preset_override = true;
414 result.config = entry->config;
415 result.stored_plugin_version = entry->plugin_version;
416 return result;
417 }
418
419 if (result.has_base_config) {
420 result.config = base->config;
421 result.stored_plugin_version = base->plugin_version;
422 }
423 return result;
424}
std::optional< CapabilityConfigEntry > get_config(const PluginCapabilityId &id) const
Definition PluginConfig.cpp:313
static PluginManager & instance()
Definition PluginManager.cpp:74
PluginConfig & get_config()
Definition PluginManager.hpp:139
std::string running_plugin_version(const std::string &plugin_key)
Definition PluginConfig.cpp:78

References Slic3r::EffectiveCapabilityConfig::config, Slic3r::CapabilityConfigDocument::find(), Slic3r::PluginConfig::get_config(), Slic3r::PluginManager::get_config(), Slic3r::EffectiveCapabilityConfig::has_base_config, Slic3r::EffectiveCapabilityConfig::has_preset_override, Slic3r::EffectiveCapabilityConfig::id, Slic3r::PluginManager::instance(), Slic3r::EffectiveCapabilityConfig::running_plugin_version, and Slic3r::EffectiveCapabilityConfig::stored_plugin_version.

Referenced by Slic3r::active_capability_config(), remove_preset_override(), and set_preset_override().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_preset_override()

MutationResult Slic3r::PresetPluginConfigService::remove_preset_override ( CapabilityConfigDocument & overrides,
const PluginCapabilityId & id ) const
452{
453 MutationResult result;
454 result.ok = true;
455 result.changed = overrides.erase(id);
456 result.effective = get_effective_config(overrides, id);
457 return result;
458}
EffectiveCapabilityConfig get_effective_config(const CapabilityConfigDocument &overrides, const PluginCapabilityId &id) const
Definition PluginConfig.cpp:402

References Slic3r::MutationResult::changed, Slic3r::MutationResult::effective, Slic3r::CapabilityConfigDocument::erase(), get_effective_config(), and Slic3r::MutationResult::ok.

Here is the call graph for this function:

◆ set_preset_override()

MutationResult Slic3r::PresetPluginConfigService::set_preset_override ( CapabilityConfigDocument & overrides,
const PluginCapabilityId & id,
const nlohmann::json & value ) const
429{
430 MutationResult result;
431 const std::string version = running_plugin_version(id.plugin_key);
432
433 // A no-op is a successful unchanged result: re-saving the displayed value must not mark the
434 // preset dirty.
435 const auto existing = overrides.find(id);
436 if (existing && existing->config == value && existing->plugin_version == version) {
437 result.ok = true;
438 result.effective = get_effective_config(overrides, id);
439 return result;
440 }
441
442 overrides.upsert({id, version, value});
443
444 result.ok = true;
445 result.changed = true;
446 result.effective = get_effective_config(overrides, id);
447 return result;
448}

References Slic3r::MutationResult::changed, Slic3r::MutationResult::effective, Slic3r::CapabilityConfigDocument::find(), get_effective_config(), Slic3r::MutationResult::ok, and Slic3r::CapabilityConfigDocument::upsert().

Here is the call graph for this function:

The documentation for this class was generated from the following files: