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

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/AppConfig.hpp>

Collaboration diagram for Slic3r::AppConfig:

Public Types

enum class  EAppMode : unsigned char { Editor , GCodeViewer }
typedef std::map< std::string, std::map< std::string, std::set< std::string > > > VendorMap
typedef std::map< std::string, std::map< std::string, std::string > > MachineSettingMap

Public Member Functions

 AppConfig ()
std::string get_language_code ()
std::string get_hms_host ()
bool get_stealth_mode ()
bool get_hide_login_side_panel ()
void reset ()
void set_defaults ()
std::string load (bool read_only=false)
std::string load_if_exists ()
void save ()
bool dirty () const
bool save_due () const
void set_dirty ()
bool get (const std::string &section, const std::string &key, std::string &value) const
std::string get (const std::string &section, const std::string &key) const
std::string get (const std::string &key) const
bool get_bool (const std::string &section, const std::string &key) const
bool get_bool (const std::string &key) const
void set (const std::string &section, const std::string &key, const std::string &value)
void set_str (const std::string &section, const std::string &key, const std::string &value)
void set (const std::string &section, const std::string &key, const char *value)
void set (const std::string &section, const std::string &key, bool value)
void set (const std::string &key, const std::string &value)
void set_bool (const std::string &key, const bool &value)
bool has (const std::string &section, const std::string &key) const
bool has (const std::string &key) const
void erase (const std::string &section, const std::string &key)
bool has_section (const std::string &section) const
const std::map< std::string, std::string > & get_section (const std::string &section) const
void set_section (const std::string &section, const std::map< std::string, std::string > &data)
void clear_section (const std::string &section)
bool get_variant (const std::string &vendor, const std::string &model, const std::string &variant) const
void set_variant (const std::string &vendor, const std::string &model, const std::string &variant, bool enable)
void set_vendors (const AppConfig &from)
void set_vendors (const VendorMap &vendors)
void set_vendors (VendorMap &&vendors)
const VendorMap & vendors () const
bool has_printer_settings (std::string printer) const
void clear_printer_settings (std::string printer)
bool has_printer_setting (std::string printer, std::string name)
std::string get_printer_setting (std::string printer, std::string name)
void set_printer_setting (std::string printer, std::string name, std::string value)
const std::map< std::string, BBLocalMachine > & get_local_machines () const
void erase_local_machine (std::string dev_id)
void update_local_machine (const BBLocalMachine &machine)
void clear_local_machine_access_code (const std::string &dev_id, const std::string &agent_id)
const std::vector< std::string > & get_filament_presets () const
void set_filament_presets (const std::vector< std::string > &filament_presets)
const std::vector< std::string > & get_filament_colors () const
void set_filament_colors (const std::vector< std::string > &filament_colors)
const std::vector< PrinterCaliInfo > & get_printer_cali_infos () const
void save_printer_cali_infos (const PrinterCaliInfo &cali_info, bool need_change_status=true)
std::string get_last_dir () const
void update_config_dir (const std::string &dir)
void update_skein_dir (const std::string &dir)
std::string get_last_output_dir (const std::string &alt, const bool removable=false) const
void update_last_output_dir (const std::string &dir, const bool removable=false)
std::string get_last_backup_dir () const
void update_last_backup_dir (const std::string &dir)
std::string get_region ()
std::string get_country_code ()
bool is_engineering_region ()
void save_custom_color_to_config (const std::vector< std::string > &colors)
std::vector< std::string > get_custom_color_from_config ()
void save_nozzle_volume_types_to_config (const std::string &printer_name, const std::string &nozzle_volume_types)
std::string get_nozzle_volume_types_from_config (const std::string &printer_name)
void reset_selections ()
std::string config_path ()
std::string lock_path ()
bool legacy_datadir () const
void set_legacy_datadir (bool value)
std::string version_check_url () const
std::string profile_update_url () const
Semver orig_version () const
bool exists ()
void set_loading_path (const std::string &path)
std::string loading_path ()
std::vector< std::string > get_recent_projects () const
void set_recent_projects (const std::vector< std::string > &recent_projects)
void set_mouse_device (const std::string &name, double translation_speed, double translation_deadzone, float rotation_speed, float rotation_deadzone, double zoom_speed, bool swap_yz, bool invert_x, bool invert_y, bool invert_z, bool invert_yaw, bool invert_pitch, bool invert_roll)
std::vector< std::string > get_mouse_device_names () const
bool get_mouse_device_translation_speed (const std::string &name, double &speed) const
bool get_mouse_device_translation_deadzone (const std::string &name, double &deadzone) const
bool get_mouse_device_rotation_speed (const std::string &name, float &speed) const
bool get_mouse_device_rotation_deadzone (const std::string &name, float &deadzone) const
bool get_mouse_device_zoom_speed (const std::string &name, double &speed) const
bool get_mouse_device_swap_yz (const std::string &name, bool &swap) const
bool get_mouse_device_invert_x (const std::string &name, bool &invert) const
bool get_mouse_device_invert_y (const std::string &name, bool &invert) const
bool get_mouse_device_invert_z (const std::string &name, bool &invert) const
bool get_mouse_device_invert_yaw (const std::string &name, bool &invert) const
bool get_mouse_device_invert_pitch (const std::string &name, bool &invert) const
bool get_mouse_device_invert_roll (const std::string &name, bool &invert) const
std::string get_network_plugin_version () const
void set_network_plugin_version (const std::string &version)
int get_plugin_pages_visible_count () const
int get_speed_dial_recent_count () const
std::vector< std::string > get_skipped_network_versions () const
void add_skipped_network_version (const std::string &version)
bool is_network_version_skipped (const std::string &version) const
void clear_skipped_network_versions ()
bool is_network_update_prompt_disabled () const
void set_network_update_prompt_disabled (bool disabled)
bool should_remind_network_update_later () const
void set_remind_network_update_later (bool remind)
void clear_remind_network_update_later ()
std::vector< std::string > get_cloud_providers () const
void set_cloud_providers (const std::vector< std::string > &providers)
bool has_cloud_provider (const std::string &provider) const
void add_cloud_provider (const std::string &provider)
void remove_cloud_provider (const std::string &provider)

Static Public Attributes

static const std::string SECTION_FILAMENTS = "filaments"
static const std::string SECTION_MATERIALS = "sla_materials"
static const std::string SECTION_EMBOSS_STYLE = "font"

Private Member Functions

template<typename T>
bool get_3dmouse_device_numeric_value (const std::string &device_name, const char *parameter_name, T &out) const
bool write_config_file (const std::string &path, std::string body, const std::string &checksum_source)

Private Attributes

EAppMode m_mode { EAppMode::Editor }
std::map< std::string, std::map< std::string, std::string > > m_storage
VendorMap m_vendors
MachineSettingMap m_printer_settings
bool m_dirty
std::chrono::steady_clock::time_point m_retry_save_at {}
Semver m_orig_version
bool m_legacy_datadir
std::string m_loading_path
std::vector< std::string > m_filament_presets
std::vector< std::string > m_filament_colors
std::vector< std::string > m_filament_multi_colors
std::vector< std::string > m_filament_color_types
std::vector< PrinterCaliInfo > m_printer_cali_infos
std::map< std::string, BBLocalMachine > m_local_machines

Detailed Description

Member Typedef Documentation

◆ MachineSettingMap

typedef std::map<std::string, std::map<std::string, std::string> > Slic3r::AppConfig::MachineSettingMap

◆ VendorMap

typedef std::map<std::string, std::map<std::string, std::set<std::string> > > Slic3r::AppConfig::VendorMap

Member Enumeration Documentation

◆ EAppMode

enum class Slic3r::AppConfig::EAppMode : unsigned char
strong
Enumerator
Editor 
GCodeViewer 
103 {
104 Editor,
106 };
@ GCodeViewer
Definition Process.cpp:38

Constructor & Destructor Documentation

◆ AppConfig()

Slic3r::AppConfig::AppConfig ( )
inlineexplicit
109 :
110 m_dirty(false),
113 m_legacy_datadir(false)
114 {
115 this->reset();
116 }
void reset()
Definition AppConfig.cpp:122
bool m_legacy_datadir
Definition AppConfig.hpp:479
Semver m_orig_version
Definition AppConfig.hpp:477
@ Editor
Definition AppConfig.hpp:104
EAppMode m_mode
Definition AppConfig.hpp:457
bool m_dirty
Definition AppConfig.hpp:472
static const Semver invalid()
Definition Semver.hpp:81

References m_dirty, m_legacy_datadir, m_mode, m_orig_version, and reset().

Referenced by set_vendors().

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

Member Function Documentation

◆ add_cloud_provider()

void Slic3r::AppConfig::add_cloud_provider ( const std::string & provider)
1870{
1871 auto providers = get_cloud_providers();
1872 if (std::find(providers.begin(), providers.end(), provider) == providers.end()) {
1873 providers.push_back(provider);
1874 set_cloud_providers(providers);
1875 }
1876}
void set_cloud_providers(const std::vector< std::string > &providers)
Definition AppConfig.cpp:1853
std::vector< std::string > get_cloud_providers() const
Definition AppConfig.cpp:1831

References get_cloud_providers(), and set_cloud_providers().

Here is the call graph for this function:

◆ add_skipped_network_version()

void Slic3r::AppConfig::add_skipped_network_version ( const std::string & version)
1782{
1783 auto skipped = get_skipped_network_versions();
1784 if (std::find(skipped.begin(), skipped.end(), version) == skipped.end()) {
1785 skipped.push_back(version);
1786 std::string joined;
1787 for (size_t i = 0; i < skipped.size(); ++i) {
1788 if (i > 0) joined += ";";
1789 joined += skipped[i];
1790 }
1792 }
1793}
#define SETTING_NETWORK_PLUGIN_SKIPPED_VERSIONS
Definition AppConfig.hpp:29
std::vector< std::string > get_skipped_network_versions() const
Definition AppConfig.cpp:1765
void set(const std::string &section, const std::string &key, const std::string &value)
Definition AppConfig.hpp:167

References get_skipped_network_versions(), set(), and SETTING_NETWORK_PLUGIN_SKIPPED_VERSIONS.

Here is the call graph for this function:

◆ clear_local_machine_access_code()

void Slic3r::AppConfig::clear_local_machine_access_code ( const std::string & dev_id,
const std::string & agent_id )
1394{
1395 // Unscoped credentials predate printer agents and belong to the legacy BBL agent.
1396 const bool is_bbl_agent = agent_id.empty() || agent_id == "bbl";
1397 auto it = m_local_machines.find(dev_id);
1398 if (it != m_local_machines.end()) {
1399 const std::string& stored_agent = it->second.printer_agent_id;
1400 if (stored_agent == agent_id || (is_bbl_agent && (stored_agent.empty() || stored_agent == "bbl"))) {
1401 if (!it->second.access_code.empty()) {
1402 it->second.access_code.clear();
1403 m_dirty = true;
1404 }
1405 }
1406 }
1407 if (is_bbl_agent) {
1408 erase("access_code", dev_id);
1409 erase("user_access_code", dev_id);
1410 }
1411}
std::map< std::string, BBLocalMachine > m_local_machines
Definition AppConfig.hpp:490
void erase(const std::string &section, const std::string &key)
Definition AppConfig.hpp:233

References erase(), m_dirty, and m_local_machines.

Referenced by Slic3r::MachineObject::set_access_code().

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

◆ clear_printer_settings()

void Slic3r::AppConfig::clear_printer_settings ( std::string printer)
inline
264 {
265 m_printer_settings.erase(printer);
266 m_dirty = true;
267 }
MachineSettingMap m_printer_settings
Definition AppConfig.hpp:465

References m_dirty, and m_printer_settings.

Referenced by Slic3r::PresetBundle::export_selections().

Here is the caller graph for this function:

◆ clear_remind_network_update_later()

void Slic3r::AppConfig::clear_remind_network_update_later ( )
1827{
1829}
#define SETTING_NETWORK_PLUGIN_REMIND_LATER
Definition AppConfig.hpp:31
void set_bool(const std::string &key, const bool &value)
Definition AppConfig.hpp:217

References set_bool(), and SETTING_NETWORK_PLUGIN_REMIND_LATER.

Here is the call graph for this function:

◆ clear_section()

void Slic3r::AppConfig::clear_section ( const std::string & section)
inline
249 { m_storage[section].clear(); }
std::map< std::string, std::map< std::string, std::string > > m_storage
Definition AppConfig.hpp:459

References m_storage.

Referenced by Slic3r::GUI::Config::Snapshot::export_selections(), Slic3r::PresetBundle::export_selections(), Slic3r::GUI::GuideFrame::run(), and anonymous_namespace{EmbossStyleManager.cpp}::store_styles().

Here is the caller graph for this function:

◆ clear_skipped_network_versions()

void Slic3r::AppConfig::clear_skipped_network_versions ( )

References set(), and SETTING_NETWORK_PLUGIN_SKIPPED_VERSIONS.

Here is the call graph for this function:

◆ config_path()

std::string Slic3r::AppConfig::config_path ( )
1907{
1908#ifdef USE_JSON_CONFIG
1909 std::string path = (m_mode == EAppMode::Editor) ?
1910 (boost::filesystem::path(Slic3r::data_dir()) / (SLIC3R_APP_KEY ".conf")).make_preferred().string() :
1911 (boost::filesystem::path(Slic3r::data_dir()) / (GCODEVIEWER_APP_KEY ".conf")).make_preferred().string();
1912#else
1913 std::string path = (m_mode == EAppMode::Editor) ?
1914 (boost::filesystem::path(Slic3r::data_dir()) / (SLIC3R_APP_KEY ".ini")).make_preferred().string() :
1915 (boost::filesystem::path(Slic3r::data_dir()) / (GCODEVIEWER_APP_KEY ".ini")).make_preferred().string();
1916#endif
1917
1918 return path;
1919}
#define GCODEVIEWER_APP_KEY
Definition libslic3r.h:13
const std::string & data_dir()
Definition utils.cpp:365

References Slic3r::data_dir(), Editor, GCODEVIEWER_APP_KEY, and m_mode.

Referenced by exists(), loading_path(), lock_path(), and save().

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

◆ dirty()

bool Slic3r::AppConfig::dirty ( ) const
inline
138{ return m_dirty; }

References m_dirty.

◆ erase()

void Slic3r::AppConfig::erase ( const std::string & section,
const std::string & key )
inline
234 {
235 auto it = m_storage.find(section);
236 if (it != m_storage.end()) {
237 it->second.erase(key);
238 m_dirty = true;
239 }
240 }

References m_dirty, and m_storage.

Referenced by clear_local_machine_access_code(), Slic3r::instance_id::anonymous_namespace{InstanceID.cpp}::prune_config_value(), Slic3r::GUI::ShortcutRegistry::save(), Slic3r::MachineObject::set_access_code(), and set_defaults().

Here is the caller graph for this function:

◆ erase_local_machine()

void Slic3r::AppConfig::erase_local_machine ( std::string dev_id)
inline
285 {
286 auto it = m_local_machines.find(dev_id);
287 if (it != m_local_machines.end()) {
288 m_local_machines.erase(it);
289 m_dirty = true;
290 }
291 }

References m_dirty, and m_local_machines.

Referenced by Slic3r::DeviceManager::load_local_machines_from_config(), and Slic3r::DeviceManager::update_local_machine().

Here is the caller graph for this function:

◆ exists()

bool Slic3r::AppConfig::exists ( )
1936{
1937 return boost::filesystem::exists(config_path());
1938}
std::string config_path()
Definition AppConfig.cpp:1906

References config_path().

Here is the call graph for this function:

◆ get() [1/3]

std::string Slic3r::AppConfig::get ( const std::string & key) const
inline
162 { std::string value; this->get("app", key, value); return value; }
bool get(const std::string &section, const std::string &key, std::string &value) const
Definition AppConfig.hpp:147

References get().

Here is the call graph for this function:

◆ get() [2/3]

std::string Slic3r::AppConfig::get ( const std::string & section,
const std::string & key ) const
inline
160 { std::string value; this->get(section, key, value); return value; }

References get().

Here is the call graph for this function:

◆ get() [3/3]

bool Slic3r::AppConfig::get ( const std::string & section,
const std::string & key,
std::string & value ) const
inline
148 {
149 value.clear();
150 auto it = m_storage.find(section);
151 if (it == m_storage.end())
152 return false;
153 auto it2 = it->second.find(key);
154 if (it2 == it->second.end())
155 return false;
156 value = it2->second;
157 return true;
158 }

References m_storage.

Referenced by Slic3r::GUI::ColorPickerDialog::ColorPickerDialog(), Slic3r::GUI::Sidebar::Sidebar(), Slic3r::GUI::Plater::priv::auto_slice_delay_seconds(), Slic3r::anonymous_namespace{PluginHostPresets.cpp}::bind_filament_target(), Slic3r::MachineObject::can_use_emmc_print(), Slic3r::OrcaCloudServiceAgent::configure_urls(), Slic3r::GUI::PreferencesDialog::create_item_region_combobox(), Slic3r::PresetBundle::export_selections(), Slic3r::GUI::Plater::export_stl(), get(), get(), anonymous_namespace{DevManager.cpp}::get_access_code_with_legacy_fallback(), get_bool(), get_cloud_providers(), get_hms_host(), get_language_code(), get_network_plugin_version(), Slic3r::GUI::Sidebar::priv::get_nozzle_options(), get_plugin_pages_visible_count(), get_region(), get_skipped_network_versions(), get_speed_dial_recent_count(), Slic3r::GUI::GUI_Run(), Slic3r::PresetBundle::import_presets(), Slic3r::GUI::CrealityPrintHostSendDialog::init(), Slic3r::GUI::ElegooPrintHostSendDialog::init(), Slic3r::GUI::FlashforgePrintHostSendDialog::init(), Slic3r::GUI::PrintHostSendDialog::init(), Slic3r::GUI::ConnectPrinterDialog::init_bitmap(), is_engineering_region(), Slic3r::GUI::Config::SnapshotDB::is_on_snapshot(), Slic3r::anonymous_namespace{PluginHostPresets.cpp}::list_bundle_ids(), load(), Slic3r::GUI::anonymous_namespace{ColorPickerDialog.cpp}::load_color_picker_favorites(), Slic3r::load_mixed_filament_settings(), Slic3r::GUI::SelectMachineDialog::load_option_vals(), Slic3r::PresetBundle::load_presets(), Slic3r::PresetBundle::load_selections(), Slic3r::anonymous_namespace{ElegooLink.cpp}::load_sn_from_config(), profile_update_url(), Slic3r::instance_id::anonymous_namespace{InstanceID.cpp}::read_config_value(), Slic3r::anonymous_namespace{PluginHostPresets.cpp}::reload_local_bundle(), Slic3r::PresetBundle::remove_users_preset(), Slic3r::GUI::anonymous_namespace{SceneBenchmark.cpp}::SceneBenchmarkDialog::report(), Slic3r::GUI::anonymous_namespace{ColorPickerDialog.cpp}::save_color_picker_favorites(), Slic3r::PresetBundle::save_user_presets(), Slic3r::GUI::Plater::send_gcode(), set_defaults(), Slic3r::GUI::Config::SnapshotDB::take_snapshot(), Slic3r::PresetBundle::update_subscribed_presets(), Slic3r::GUI::SyncAmsInfoDialog::update_timelapse_enable_status(), version_check_url(), and Slic3r::instance_id::anonymous_namespace{InstanceID.cpp}::write_config_value().

◆ get_3dmouse_device_numeric_value()

template<typename T>
bool Slic3r::AppConfig::get_3dmouse_device_numeric_value ( const std::string & device_name,
const char * parameter_name,
T & out ) const
inlineprivate
444 {
445 std::string key = std::string("mouse_device:") + device_name;
446 auto it = m_storage.find(key);
447 if (it == m_storage.end())
448 return false;
449 auto it_val = it->second.find(parameter_name);
450 if (it_val == it->second.end())
451 return false;
452 out = T(string_to_double_decimal_point(it_val->second));
453 return true;
454 }
double string_to_double_decimal_point(const std::string_view str, size_t *pos)
Definition LocalesUtils.cpp:86

References m_storage, and Slic3r::string_to_double_decimal_point().

Referenced by get_mouse_device_invert_pitch(), get_mouse_device_invert_roll(), get_mouse_device_invert_x(), get_mouse_device_invert_y(), get_mouse_device_invert_yaw(), get_mouse_device_invert_z(), get_mouse_device_rotation_deadzone(), get_mouse_device_rotation_speed(), get_mouse_device_swap_yz(), get_mouse_device_translation_deadzone(), get_mouse_device_translation_speed(), and get_mouse_device_zoom_speed().

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

◆ get_bool() [1/2]

bool Slic3r::AppConfig::get_bool ( const std::string & key) const
inline
166 { return this->get_bool("app", key); }
bool get_bool(const std::string &section, const std::string &key) const
Definition AppConfig.hpp:163

References get_bool().

Here is the call graph for this function:

◆ get_bool() [2/2]

bool Slic3r::AppConfig::get_bool ( const std::string & section,
const std::string & key ) const
inline

◆ get_cloud_providers()

std::vector< std::string > Slic3r::AppConfig::get_cloud_providers ( ) const
1832{
1833 std::vector<std::string> result;
1834 std::string providers = get(SETTING_CLOUD_PROVIDERS);
1835 if (providers.empty()) {
1836 result.push_back("orca");
1837 return result;
1838 }
1839
1840 std::stringstream ss(providers);
1841 std::string provider;
1842 while (std::getline(ss, provider, ';')) {
1843 if (!provider.empty())
1844 result.push_back(provider);
1845 }
1846 // Ensure "orca" is always present
1847 if (std::find(result.begin(), result.end(), "orca") == result.end()) {
1848 result.insert(result.begin(), "orca");
1849 }
1850 return result;
1851}
#define SETTING_CLOUD_PROVIDERS
Definition AppConfig.hpp:33

References get(), and SETTING_CLOUD_PROVIDERS.

Referenced by add_cloud_provider(), Slic3r::create_agent_from_config(), has_cloud_provider(), and remove_cloud_provider().

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

◆ get_country_code()

std::string Slic3r::AppConfig::get_country_code ( )
1633{
1634 std::string region = get_region();
1635// #if !BBL_RELEASE_TO_PUBLIC
1636// if (is_engineering_region()) { return region; }
1637// #endif
1638 if (region == "CHN" || region == "China")
1639 return "CN";
1640 else if (region == "USA")
1641 return "US";
1642 else if (region == "Asia-Pacific")
1643 return "Others";
1644 else if (region == "Europe")
1645 return "US";
1646 else if (region == "North America")
1647 return "US";
1648 else
1649 return "Others";
1650 return "";
1651
1652}
std::string get_region()
Definition AppConfig.cpp:1613

References get_region().

Referenced by Slic3r::GUI::PreferencesDialog::create_debug_page(), Slic3r::GUI::PreferencesDialog::create_item_region_combobox(), and Slic3r::GUI::GuideFrame::OnScriptMessage().

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

◆ get_custom_color_from_config()

std::vector< std::string > Slic3r::AppConfig::get_custom_color_from_config ( )
1686{
1687 std::vector<std::string> colors;
1688 if (has_section("custom_color_list")) {
1689 auto data = get_section("custom_color_list");
1690 for (auto iter : data) {
1691 colors.push_back(iter.second);
1692 }
1693 }
1694 return colors;
1695}
const std::map< std::string, std::string > & get_section(const std::string &section) const
Definition AppConfig.hpp:244
bool has_section(const std::string &section) const
Definition AppConfig.hpp:242

References get_section(), and has_section().

Referenced by Slic3r::GUI::anonymous_namespace{ColorPickerDialog.cpp}::load_color_picker_favorites().

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

◆ get_filament_colors()

const std::vector< std::string > & Slic3r::AppConfig::get_filament_colors ( ) const
inline
314{ return m_filament_colors; }
std::vector< std::string > m_filament_colors
Definition AppConfig.hpp:484

References m_filament_colors.

◆ get_filament_presets()

const std::vector< std::string > & Slic3r::AppConfig::get_filament_presets ( ) const
inline
309{ return m_filament_presets; }
std::vector< std::string > m_filament_presets
Definition AppConfig.hpp:483

References m_filament_presets.

◆ get_hide_login_side_panel()

bool Slic3r::AppConfig::get_hide_login_side_panel ( )
118{
119 return get_bool("hide_login_side_panel");
120}

References get_bool().

Here is the call graph for this function:

◆ get_hms_host()

std::string Slic3r::AppConfig::get_hms_host ( )
90{
91 std::string sel = get("iot_environment");
92 std::string host = "";
93// #if !BBL_RELEASE_TO_PUBLIC
94// if (sel == ENV_DEV_HOST)
95// host = "e-dev.bambu-lab.com";
96// else if (sel == ENV_QAT_HOST)
97// host = "e-qa.bambu-lab.com";
98// else if (sel == ENV_PRE_HOST)
99// host = "e-pre.bambu-lab.com";
100// else if (sel == ENV_PRODUCT_HOST)
101// host = "e.bambulab.com";
102// return host;
103// #else
104 return "e.bambulab.com";
105// #endif
106}

References get().

Referenced by Slic3r::GUI::HMSQuery::download_hms_related(), Slic3r::GUI::get_hms_info_version(), and Slic3r::GUI::get_hms_wiki_url().

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

◆ get_language_code()

std::string Slic3r::AppConfig::get_language_code ( )
73{
74 std::string get_lang = get("language");
75 if (get_lang.empty()) return "";
76
77 if (get_lang == "zh_CN")
78 {
79 get_lang = "zh-cn";
80 }
81 else
82 {
83 if (get_lang.length() >= 2) { get_lang = get_lang.substr(0, 2); }
84 }
85
86 return get_lang;
87}

References get().

Referenced by Slic3r::GUI::HMSQuery::hms_language_code().

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

◆ get_last_backup_dir()

std::string Slic3r::AppConfig::get_last_backup_dir ( ) const
1596{
1597 const auto it = m_storage.find("app");
1598 if (it != m_storage.end()) {
1599 const auto it2 = it->second.find("last_backup_path");
1600 if (it2 != it->second.end())
1601 return it2->second;
1602 }
1603 return "";
1604}

References m_storage.

◆ get_last_dir()

std::string Slic3r::AppConfig::get_last_dir ( ) const
1465{
1466 const auto it = m_storage.find("recent");
1467 if (it != m_storage.end()) {
1468 {
1469 const auto it2 = it->second.find("last_opened_folder");
1470 if (it2 != it->second.end() && ! it2->second.empty())
1471 return it2->second;
1472 }
1473 {
1474 const auto it2 = it->second.find("settings_folder");
1475 if (it2 != it->second.end() && ! it2->second.empty())
1476 return it2->second;
1477 }
1478 }
1479 return std::string();
1480}

References m_storage.

Referenced by get_last_output_dir().

Here is the caller graph for this function:

◆ get_last_output_dir()

std::string Slic3r::AppConfig::get_last_output_dir ( const std::string & alt,
const bool removable = false ) const
1578{
1579 std::string s1 = ("last_export_path");
1580 const auto it = m_storage.find("app");
1581 if (it != m_storage.end()) {
1582 const auto it2 = it->second.find(s1);
1583 if (it2 != it->second.end() && !it2->second.empty())
1584 return it2->second;
1585 }
1586 return is_shapes_dir(alt) ? get_last_dir() : alt;
1587}
std::string get_last_dir() const
Definition AppConfig.cpp:1464
bool is_shapes_dir(const std::string &dir)
Definition utils.cpp:1295

References get_last_dir(), Slic3r::is_shapes_dir(), and m_storage.

Referenced by Slic3r::GUI::Plater::export_gcode(), and Slic3r::GUI::Plater::export_gcode_3mf().

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

◆ get_local_machines()

const std::map< std::string, BBLocalMachine > & Slic3r::AppConfig::get_local_machines ( ) const
inline
283{ return m_local_machines; }

References m_local_machines.

Referenced by anonymous_namespace{DevManager.cpp}::get_access_code_with_legacy_fallback(), and Slic3r::DeviceManager::load_local_machines_from_config().

Here is the caller graph for this function:

◆ get_mouse_device_invert_pitch()

bool Slic3r::AppConfig::get_mouse_device_invert_pitch ( const std::string & name,
bool & invert ) const
inline
404 { return get_3dmouse_device_numeric_value(name, "invert_pitch", invert); }
bool get_3dmouse_device_numeric_value(const std::string &device_name, const char *parameter_name, T &out) const
Definition AppConfig.hpp:443

References get_3dmouse_device_numeric_value().

Referenced by Slic3r::GUI::Mouse3DController::load_config().

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

◆ get_mouse_device_invert_roll()

bool Slic3r::AppConfig::get_mouse_device_invert_roll ( const std::string & name,
bool & invert ) const
inline
406 { return get_3dmouse_device_numeric_value(name, "invert_roll", invert); }

References get_3dmouse_device_numeric_value().

Referenced by Slic3r::GUI::Mouse3DController::load_config().

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

◆ get_mouse_device_invert_x()

bool Slic3r::AppConfig::get_mouse_device_invert_x ( const std::string & name,
bool & invert ) const
inline
396 { return get_3dmouse_device_numeric_value(name, "invert_x", invert); }

References get_3dmouse_device_numeric_value().

Referenced by Slic3r::GUI::Mouse3DController::load_config().

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

◆ get_mouse_device_invert_y()

bool Slic3r::AppConfig::get_mouse_device_invert_y ( const std::string & name,
bool & invert ) const
inline
398 { return get_3dmouse_device_numeric_value(name, "invert_y", invert); }

References get_3dmouse_device_numeric_value().

Referenced by Slic3r::GUI::Mouse3DController::load_config().

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

◆ get_mouse_device_invert_yaw()

bool Slic3r::AppConfig::get_mouse_device_invert_yaw ( const std::string & name,
bool & invert ) const
inline
402 { return get_3dmouse_device_numeric_value(name, "invert_yaw", invert); }

References get_3dmouse_device_numeric_value().

Referenced by Slic3r::GUI::Mouse3DController::load_config().

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

◆ get_mouse_device_invert_z()

bool Slic3r::AppConfig::get_mouse_device_invert_z ( const std::string & name,
bool & invert ) const
inline
400 { return get_3dmouse_device_numeric_value(name, "invert_z", invert); }

References get_3dmouse_device_numeric_value().

Referenced by Slic3r::GUI::Mouse3DController::load_config().

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

◆ get_mouse_device_names()

std::vector< std::string > Slic3r::AppConfig::get_mouse_device_names ( ) const
1537{
1538 static constexpr const char *prefix = "mouse_device:";
1539 static const size_t prefix_len = strlen(prefix);
1540 std::vector<std::string> out;
1541 for (const auto& key_value_pair : m_storage)
1542 if (boost::starts_with(key_value_pair.first, prefix) && key_value_pair.first.size() > prefix_len)
1543 out.emplace_back(key_value_pair.first.substr(prefix_len));
1544 return out;
1545}

References m_storage.

Referenced by Slic3r::GUI::Mouse3DController::load_config().

Here is the caller graph for this function:

◆ get_mouse_device_rotation_deadzone()

bool Slic3r::AppConfig::get_mouse_device_rotation_deadzone ( const std::string & name,
float & deadzone ) const
inline
390 { return get_3dmouse_device_numeric_value(name, "rotation_deadzone", deadzone); }

References get_3dmouse_device_numeric_value().

Referenced by Slic3r::GUI::Mouse3DController::load_config().

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

◆ get_mouse_device_rotation_speed()

bool Slic3r::AppConfig::get_mouse_device_rotation_speed ( const std::string & name,
float & speed ) const
inline
388 { return get_3dmouse_device_numeric_value(name, "rotation_speed", speed); }

References get_3dmouse_device_numeric_value().

Referenced by Slic3r::GUI::Mouse3DController::load_config().

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

◆ get_mouse_device_swap_yz()

bool Slic3r::AppConfig::get_mouse_device_swap_yz ( const std::string & name,
bool & swap ) const
inline
394 { return get_3dmouse_device_numeric_value(name, "swap_yz", swap); }

References get_3dmouse_device_numeric_value().

Referenced by Slic3r::GUI::Mouse3DController::load_config().

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

◆ get_mouse_device_translation_deadzone()

bool Slic3r::AppConfig::get_mouse_device_translation_deadzone ( const std::string & name,
double & deadzone ) const
inline
386 { return get_3dmouse_device_numeric_value(name, "translation_deadzone", deadzone); }

References get_3dmouse_device_numeric_value().

Referenced by Slic3r::GUI::Mouse3DController::load_config().

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

◆ get_mouse_device_translation_speed()

bool Slic3r::AppConfig::get_mouse_device_translation_speed ( const std::string & name,
double & speed ) const
inline
384 { return get_3dmouse_device_numeric_value(name, "translation_speed", speed); }

References get_3dmouse_device_numeric_value().

Referenced by Slic3r::GUI::Mouse3DController::load_config().

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

◆ get_mouse_device_zoom_speed()

bool Slic3r::AppConfig::get_mouse_device_zoom_speed ( const std::string & name,
double & speed ) const
inline
392 { return get_3dmouse_device_numeric_value(name, "zoom_speed", speed); }

References get_3dmouse_device_numeric_value().

Referenced by Slic3r::GUI::Mouse3DController::load_config().

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

◆ get_network_plugin_version()

std::string Slic3r::AppConfig::get_network_plugin_version ( ) const
1724{
1726}
#define SETTING_NETWORK_PLUGIN_VERSION
Definition AppConfig.hpp:28

References get(), and SETTING_NETWORK_PLUGIN_VERSION.

Here is the call graph for this function:

◆ get_nozzle_volume_types_from_config()

std::string Slic3r::AppConfig::get_nozzle_volume_types_from_config ( const std::string & printer_name)
1712{
1713 std::string nozzle_volume_types;
1714 if (has_section("nozzle_volume_types")) {
1715 auto data = get_section("nozzle_volume_types");
1716 if (data.find(printer_name) != data.end())
1717 nozzle_volume_types = data[printer_name];
1718 }
1719
1720 return nozzle_volume_types;
1721}

References get_section(), and has_section().

Referenced by Slic3r::PresetBundle::load_selections().

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

◆ get_plugin_pages_visible_count()

int Slic3r::AppConfig::get_plugin_pages_visible_count ( ) const
1734{
1735 std::string value = get(SETTING_PLUGIN_PAGES_VISIBLE_COUNT);
1736 if (value.empty())
1738
1739 int visible_count = PLUGIN_PAGES_VISIBLE_COUNT_DEFAULT;
1740 try {
1741 visible_count = std::stoi(value);
1742 }
1743 catch (...) {
1745 }
1746 return std::clamp(visible_count, PLUGIN_PAGES_VISIBLE_COUNT_MIN, PLUGIN_PAGES_VISIBLE_COUNT_MAX);
1747}
#define SETTING_PLUGIN_PAGES_VISIBLE_COUNT
Definition AppConfig.hpp:52
#define PLUGIN_PAGES_VISIBLE_COUNT_MAX
Definition AppConfig.hpp:55
#define PLUGIN_PAGES_VISIBLE_COUNT_MIN
Definition AppConfig.hpp:53
#define PLUGIN_PAGES_VISIBLE_COUNT_DEFAULT
Definition AppConfig.hpp:54

References get(), PLUGIN_PAGES_VISIBLE_COUNT_DEFAULT, PLUGIN_PAGES_VISIBLE_COUNT_MAX, PLUGIN_PAGES_VISIBLE_COUNT_MIN, and SETTING_PLUGIN_PAGES_VISIBLE_COUNT.

Referenced by set_defaults().

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

◆ get_printer_cali_infos()

const std::vector< PrinterCaliInfo > & Slic3r::AppConfig::get_printer_cali_infos ( ) const
inline
320{ return m_printer_cali_infos; }
std::vector< PrinterCaliInfo > m_printer_cali_infos
Definition AppConfig.hpp:488

References m_printer_cali_infos.

◆ get_printer_setting()

std::string Slic3r::AppConfig::get_printer_setting ( std::string printer,
std::string name )
inline
273 {
274 if (!has_printer_setting(printer, name))
275 return "";
276 return m_printer_settings[printer][name];
277 }
bool has_printer_setting(std::string printer, std::string name)
Definition AppConfig.hpp:268

References has_printer_setting(), and m_printer_settings.

Referenced by Slic3r::load_mixed_filament_settings(), Slic3r::PresetBundle::load_selections(), and Slic3r::PresetBundle::update_selections().

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

◆ get_recent_projects()

std::vector< std::string > Slic3r::AppConfig::get_recent_projects ( ) const
1483{
1484 std::vector<std::string> ret;
1485 const auto it = m_storage.find("recent_projects");
1486 if (it != m_storage.end())
1487 {
1488 for (const std::map<std::string, std::string>::value_type& item : it->second)
1489 {
1490 ret.push_back(item.second);
1491 }
1492 }
1493 return ret;
1494}

References m_storage.

◆ get_region()

std::string Slic3r::AppConfig::get_region ( )
1614{
1615// #if BBL_RELEASE_TO_PUBLIC
1616 return this->get("region");
1617// #else
1618// std::string sel = get("iot_environment");
1619// std::string region;
1620// if (sel == ENV_DEV_HOST)
1621// region = "ENV_CN_DEV";
1622// else if (sel == ENV_QAT_HOST)
1623// region = "ENV_CN_QA";
1624// else if (sel == ENV_PRE_HOST)
1625// region = "ENV_CN_PRE";
1626// if (region.empty())
1627// return this->get("region");
1628// return region;
1629// #endif
1630}

References get().

Referenced by get_country_code().

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

◆ get_section()

◆ get_skipped_network_versions()

std::vector< std::string > Slic3r::AppConfig::get_skipped_network_versions ( ) const
1766{
1767 std::vector<std::string> result;
1768 std::string skipped = get(SETTING_NETWORK_PLUGIN_SKIPPED_VERSIONS);
1769 if (skipped.empty())
1770 return result;
1771
1772 std::stringstream ss(skipped);
1773 std::string version;
1774 while (std::getline(ss, version, ';')) {
1775 if (!version.empty())
1776 result.push_back(version);
1777 }
1778 return result;
1779}

References get(), and SETTING_NETWORK_PLUGIN_SKIPPED_VERSIONS.

Referenced by add_skipped_network_version(), and is_network_version_skipped().

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

◆ get_speed_dial_recent_count()

int Slic3r::AppConfig::get_speed_dial_recent_count ( ) const
1750{
1751 std::string value = get(SETTING_SPEED_DIAL_RECENT_COUNT);
1752 if (value.empty())
1754
1755 int recent_count = SPEED_DIAL_RECENT_COUNT_DEFAULT;
1756 try {
1757 recent_count = std::stoi(value);
1758 }
1759 catch (...) {
1761 }
1762 return std::clamp(recent_count, SPEED_DIAL_RECENT_COUNT_MIN, SPEED_DIAL_RECENT_COUNT_MAX);
1763}
#define SETTING_SPEED_DIAL_RECENT_COUNT
Definition AppConfig.hpp:57
#define SPEED_DIAL_RECENT_COUNT_DEFAULT
Definition AppConfig.hpp:59
#define SPEED_DIAL_RECENT_COUNT_MIN
Definition AppConfig.hpp:58
#define SPEED_DIAL_RECENT_COUNT_MAX
Definition AppConfig.hpp:60

References get(), SETTING_SPEED_DIAL_RECENT_COUNT, SPEED_DIAL_RECENT_COUNT_DEFAULT, SPEED_DIAL_RECENT_COUNT_MAX, and SPEED_DIAL_RECENT_COUNT_MIN.

Referenced by set_defaults().

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

◆ get_stealth_mode()

bool Slic3r::AppConfig::get_stealth_mode ( )
109{
110 // always return true when user did not finish setup wizard yet
111 if (!get_bool("firstguide","finish")) {
112 return true;
113 }
114 return get_bool("stealth_mode");
115}

References get_bool().

Referenced by Slic3r::anonymous_namespace{PluginHostApp.cpp}::app_info(), and should_disable_hms().

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

◆ get_variant()

bool Slic3r::AppConfig::get_variant ( const std::string & vendor,
const std::string & model,
const std::string & variant ) const
1414{
1415 const auto it_v = m_vendors.find(vendor);
1416 if (it_v == m_vendors.end()) { return false; }
1417 const auto it_m = it_v->second.find(model);
1418 return it_m == it_v->second.end() ? false : it_m->second.find(variant) != it_m->second.end();
1419}
VendorMap m_vendors
Definition AppConfig.hpp:462

References m_vendors.

Referenced by Slic3r::GUI::PrinterPicker::PrinterPicker(), set_variant(), and Slic3r::Preset::set_visible_from_appconfig().

Here is the caller graph for this function:

◆ has() [1/2]

bool Slic3r::AppConfig::has ( const std::string & key) const
inline
231 { return this->has("app", key); }
bool has(const std::string &section, const std::string &key) const
Definition AppConfig.hpp:222

References has().

Here is the call graph for this function:

◆ has() [2/2]

bool Slic3r::AppConfig::has ( const std::string & section,
const std::string & key ) const
inline
223 {
224 auto it = m_storage.find(section);
225 if (it == m_storage.end())
226 return false;
227 auto it2 = it->second.find(key);
228 return it2 != it->second.end() && ! it2->second.empty();
229 }

References m_storage.

Referenced by has(), Slic3r::GUI::FlashforgePrintHostSendDialog::init(), Slic3r::load_mixed_filament_settings(), Slic3r::instance_id::anonymous_namespace{InstanceID.cpp}::prune_config_value(), Slic3r::GUI::Config::SnapshotDB::take_snapshot(), and Slic3r::GUI::PageMaterials::update_lists().

Here is the caller graph for this function:

◆ has_cloud_provider()

bool Slic3r::AppConfig::has_cloud_provider ( const std::string & provider) const
1864{
1865 auto providers = get_cloud_providers();
1866 return std::find(providers.begin(), providers.end(), provider) != providers.end();
1867}

References get_cloud_providers().

Here is the call graph for this function:

◆ has_printer_setting()

bool Slic3r::AppConfig::has_printer_setting ( std::string printer,
std::string name )
inline
268 {
269 if (!has_printer_settings(printer))
270 return false;
271 return m_printer_settings[printer].count(name) != 0;
272 }
bool has_printer_settings(std::string printer) const
Definition AppConfig.hpp:261

References has_printer_settings(), and m_printer_settings.

Referenced by get_printer_setting(), Slic3r::load_mixed_filament_settings(), Slic3r::PresetBundle::load_selections(), and Slic3r::PresetBundle::update_selections().

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

◆ has_printer_settings()

bool Slic3r::AppConfig::has_printer_settings ( std::string printer) const
inline
261 {
262 return m_printer_settings.find(printer) != m_printer_settings.end();
263 }

References m_printer_settings.

Referenced by has_printer_setting().

Here is the caller graph for this function:

◆ has_section()

◆ is_engineering_region()

bool Slic3r::AppConfig::is_engineering_region ( )
1654 {
1655 std::string sel = get("iot_environment");
1656 std::string region;
1657 if (sel == ENV_DEV_HOST
1658 || sel == ENV_QAT_HOST
1659 ||sel == ENV_PRE_HOST)
1660 return true;
1661 return false;
1662}
#define ENV_PRE_HOST
Definition AppConfig.hpp:19
#define ENV_DEV_HOST
Definition AppConfig.hpp:17
#define ENV_QAT_HOST
Definition AppConfig.hpp:18

References ENV_DEV_HOST, ENV_PRE_HOST, ENV_QAT_HOST, and get().

Here is the call graph for this function:

◆ is_network_update_prompt_disabled()

bool Slic3r::AppConfig::is_network_update_prompt_disabled ( ) const
1807{
1809}
#define SETTING_NETWORK_PLUGIN_UPDATE_DISABLED
Definition AppConfig.hpp:30

References get_bool(), and SETTING_NETWORK_PLUGIN_UPDATE_DISABLED.

Here is the call graph for this function:

◆ is_network_version_skipped()

bool Slic3r::AppConfig::is_network_version_skipped ( const std::string & version) const
1796{
1797 auto skipped = get_skipped_network_versions();
1798 return std::find(skipped.begin(), skipped.end(), version) != skipped.end();
1799}

References get_skipped_network_versions().

Here is the call graph for this function:

◆ legacy_datadir()

bool Slic3r::AppConfig::legacy_datadir ( ) const
inline
358{ return m_legacy_datadir; }

References m_legacy_datadir.

Referenced by Slic3r::GUI::ConfigWizard::priv::load_vendors().

Here is the caller graph for this function:

◆ load()

std::string Slic3r::AppConfig::load ( bool read_only = false)
789{
790 json j;
791
792 // Keep another instance from replacing or restoring the file mid-read.
793 InstanceLock instance_lock(read_only ? std::string() : lock_path());
794
795 // 1) Read the complete config file into a boost::property_tree.
796 namespace pt = boost::property_tree;
797 pt::ptree tree;
798 boost::nowide::ifstream ifs;
799 bool recovered = false;
800 std::string error_message;
801
802 try {
803 ifs.open(AppConfig::loading_path());
804
805#ifdef WIN32
806 std::stringstream input_stream;
807 input_stream << ifs.rdbuf();
808 std::string total_string = input_stream.str();
809 size_t last_pos = total_string.find_last_of('}');
810 std::string left_string = total_string.substr(0, last_pos+1);
811 //skip the "\n"
812 std::string right_string = total_string.substr(last_pos+2);
813
814 std::string md5_str = appconfig_md5_hash_line({left_string.data()});
815 // Verify the checksum of the config file without taking just for debugging purpose.
816 if (md5_str != right_string)
817 BOOST_LOG_TRIVIAL(info) << "The configuration file " << AppConfig::loading_path() <<
818 " has a wrong MD5 checksum or the checksum is missing. This may indicate a file corruption or a harmless user edit.";
819 j = json::parse(left_string);
820#else
821 ifs >> j;
822#endif
823 }
824 catch(nlohmann::detail::parse_error &err) {
825#ifdef WIN32
826 // The configuration file is corrupted, try replacing it with the backup configuration.
827 ifs.close();
828 std::string backup_path = (boost::format("%1%.bak") % AppConfig::loading_path()).str();
829 if (boost::filesystem::exists(backup_path)) {
830 // Compute checksum of the configuration backup file and try to load configuration from it when the checksum is correct.
831 boost::nowide::ifstream backup_ifs(backup_path);
832 std::stringstream back_input_stream;
833 back_input_stream << backup_ifs.rdbuf();
834 std::string back_total_string = back_input_stream.str();
835 size_t back_last_pos = back_total_string.find_last_of('}');
836 std::string back_left_string = back_total_string.substr(0, back_last_pos+1);
837 std::string back_right_string = back_total_string.substr(back_last_pos+2);
838
839 std::string back_md5_str = appconfig_md5_hash_line({back_left_string.data()});
840 // Verify the checksum of the config file without taking just for debugging purpose.
841 if (back_md5_str != back_right_string) {
842 BOOST_LOG_TRIVIAL(error) << format("Both \"%1%\" and \"%2%\" are corrupted. It isn't possible to restore configuration from the backup.", AppConfig::loading_path(), backup_path);
843 backup_ifs.close();
844 boost::filesystem::remove(backup_path);
845 }
846 else if (std::string error_message; copy_file(backup_path, AppConfig::loading_path(), error_message, false) != SUCCESS) {
847 BOOST_LOG_TRIVIAL(error) << format("Configuration file \"%1%\" is corrupted. Failed to restore from backup \"%2%\": %3%", AppConfig::loading_path(), backup_path, error_message);
848 backup_ifs.close();
849 boost::filesystem::remove(backup_path);
850 }
851 else {
852 BOOST_LOG_TRIVIAL(info) << format("Configuration file \"%1%\" was corrupted. It has been succesfully restored from the backup \"%2%\".", AppConfig::loading_path(), backup_path);
853 // Try parse configuration file after restore from backup.
854 j = json::parse(back_left_string);
855 recovered = true;
856 }
857 }
858 else
859#endif // WIN32
860 BOOST_LOG_TRIVIAL(info) << format("Failed to parse configuration file \"%1%\": %2%", AppConfig::loading_path(), err.what());
861
862 if (!recovered)
863 return err.what();
864 }
865
866 try {
867 for (auto it = j.begin(); it != j.end(); it++) {
868 if (it.key() == MODELS_STR) {
869 for (auto& j_model : it.value()) {
870 // This is a vendor section listing enabled model / variants
871 const auto vendor_name = j_model["vendor"].get<std::string>();
872 auto& vendor = m_vendors[vendor_name];
873 const auto model_name = j_model["model"].get<std::string>();
874 std::vector<std::string> variants;
875 if (!unescape_strings_cstyle(j_model["nozzle_diameter"], variants)) { continue; }
876 for (const auto& variant : variants) {
877 vendor[model_name].insert(variant);
878 }
879 }
880 } else if (it.key() == SECTION_FILAMENTS) {
881 json j_filaments = it.value();
882 for (auto& element : j_filaments) {
883 m_storage[it.key()][element] = "true";
884 }
885 } else if (it.key() == "presets") {
886 for (auto iter = it.value().begin(); iter != it.value().end(); iter++) {
887 if (iter.key() == "filaments") {
888 int idx = 0;
889 for(auto& element: iter.value()) {
890 if (idx == 0)
891 m_storage[it.key()]["filament"] = element;
892 else {
893 auto n = std::to_string(idx);
894 if (n.length() == 1) n = "0" + n;
895 m_storage[it.key()]["filament_" + n] = element;
896 }
897 idx++;
898 }
899 } else {
900 m_storage[it.key()][iter.key()] = iter.value().get<std::string>();
901 }
902 }
903 } else if (it.key() == "calis") {
904 for (auto &calis_j : it.value()) {
905 PrinterCaliInfo cali_info;
906 if (calis_j.contains("dev_id"))
907 cali_info.dev_id = calis_j["dev_id"].get<std::string>();
908 if (calis_j.contains("cali_finished"))
909 cali_info.cali_finished = bool(calis_j["cali_finished"].get<int>());
910 if (calis_j.contains("flow_ratio"))
911 cali_info.cache_flow_ratio = calis_j["flow_ratio"].get<float>();
912 if (calis_j.contains("cache_flow_rate_calibration_type"))
913 cali_info.cache_flow_rate_calibration_type = static_cast<FlowRatioCalibrationType>(calis_j["cache_flow_rate_calibration_type"].get<int>());
914 if (calis_j.contains("presets")) {
915 cali_info.selected_presets.clear();
916 for (auto cali_it = calis_j["presets"].begin(); cali_it != calis_j["presets"].end(); cali_it++) {
917 CaliPresetInfo preset_info;
918 preset_info.tray_id = cali_it.value()["tray_id"].get<int>();
919 preset_info.nozzle_diameter = cali_it.value()["nozzle_diameter"].get<float>();
920 preset_info.filament_id = cali_it.value()["filament_id"].get<std::string>();
921 preset_info.setting_id = cali_it.value()["setting_id"].get<std::string>();
922 preset_info.name = cali_it.value()["name"].get<std::string>();
923 if (cali_it.value().contains("extruder_id"))
924 preset_info.extruder_id = cali_it.value()["extruder_id"].get<int>();
925 if (cali_it.value().contains("nozzle_volume_type"))
926 preset_info.nozzle_volume_type = NozzleVolumeType(cali_it.value()["nozzle_volume_type"].get<int>());
927 if (cali_it.value().contains("bed_type"))
928 preset_info.bed_type = BedType(cali_it.value()["bed_type"].get<int>());
929 if (cali_it.value().contains("nozzle_pos_id"))
930 preset_info.nozzle_pos_id = cali_it.value()["nozzle_pos_id"].get<int>();
931 if (cali_it.value().contains("nozzle_sn"))
932 preset_info.nozzle_sn = cali_it.value()["nozzle_sn"].get<std::string>();
933 cali_info.selected_presets.push_back(preset_info);
934 }
935 }
936 m_printer_cali_infos.emplace_back(cali_info);
937 }
938 } else if (it.key() == "orca_presets") {
939 for (auto& j_model : it.value()) {
940 auto& settings = m_printer_settings[j_model["machine"].get<std::string>()];
941 settings.clear();
942 for (auto item = j_model.begin(); item != j_model.end(); ++item)
943 settings[item.key()] = item.value().is_string() ? item.value().get<std::string>() : item.value().dump();
944 }
945 } else if (it.key() == "local_machines") {
946 for (auto m = it.value().begin(); m != it.value().end(); ++m) {
947 const auto& p = m.value();
948 BBLocalMachine local_machine;
949 local_machine.dev_id = m.key();
950 if (p.contains("dev_name"))
951 local_machine.dev_name = p["dev_name"].get<std::string>();
952 if (p.contains("dev_ip"))
953 local_machine.dev_ip = p["dev_ip"].get<std::string>();
954 if (p.contains("printer_type"))
955 local_machine.printer_type = p["printer_type"].get<std::string>();
956 if (p.contains("printer_agent_id"))
957 local_machine.printer_agent_id = p["printer_agent_id"].get<std::string>();
958 if (p.contains("access_code"))
959 local_machine.access_code = p["access_code"].get<std::string>();
960 m_local_machines[local_machine.dev_id] = local_machine;
961 }
962 } else {
963 if (it.value().is_object()) {
964 for (auto iter = it.value().begin(); iter != it.value().end(); iter++) {
965 if (iter.value().is_boolean()) {
966 if (iter.value()) {
967 m_storage[it.key()][iter.key()] = "true";
968 } else {
969 m_storage[it.key()][iter.key()] = "false";
970 }
971 } else if (iter.key() == "filament_presets") {
972 m_filament_presets = iter.value().get<std::vector<std::string>>();
973 } else if (iter.key() == "filament_colors") {
974 m_filament_colors = iter.value().get<std::vector<std::string>>();
975 } else if(iter.key() == "filament_multi_colors") {
976 m_filament_multi_colors = iter.value().get<std::vector<std::string>>();
977 } else if(iter.key() == "filament_color_types") {
978 m_filament_color_types = iter.value().get<std::vector<std::string>>();
979 } else {
980 if (iter.value().is_string())
981 m_storage[it.key()][iter.key()] = iter.value().get<std::string>();
982 else {
983 BOOST_LOG_TRIVIAL(warning) << "load config warning...";
984 }
985 }
986 }
987 }
988 }
989 }
990 } catch(const std::exception &err) {
991 BOOST_LOG_TRIVIAL(info) << format("parse app config \"%1%\", error: %2%", AppConfig::loading_path(), err.what());
992
993 return err.what();
994 }
995
996 // Figure out if datadir has legacy presets
997 auto ini_ver = Semver::parse(get("version"));
998 m_legacy_datadir = false;
999 if (ini_ver) {
1000 m_orig_version = *ini_ver;
1001 ini_ver->set_metadata(boost::none);
1002 ini_ver->set_prerelease(boost::none);
1003 }
1004
1005 // Legacy conversion
1006 if (m_mode == EAppMode::Editor) {
1007 // Convert [extras] "physical_printer" to [presets] "physical_printer",
1008 // remove the [extras] section if it becomes empty.
1009 if (auto it_section = m_storage.find("extras"); it_section != m_storage.end()) {
1010 if (auto it_physical_printer = it_section->second.find("physical_printer"); it_physical_printer != it_section->second.end()) {
1011 m_storage["presets"]["physical_printer"] = it_physical_printer->second;
1012 it_section->second.erase(it_physical_printer);
1013 }
1014 if (it_section->second.empty())
1015 m_storage.erase(it_section);
1016 }
1017
1018 // Default for new installs
1020 // Migrate add bbl cloud if installed_networking is true
1021 bool enable_bbl_cloud = get_bool("installed_networking");
1022 if (enable_bbl_cloud) {
1023 // Legacy Bambu-only user: give them both providers
1024 set(SETTING_CLOUD_PROVIDERS, "orca;bbl");
1025 } else {
1027 }
1028 }
1029 }
1030
1031 // Override missing or keys with their defaults.
1032 this->set_defaults();
1033 m_dirty = false;
1034 return "";
1035}
std::string lock_path()
Definition AppConfig.cpp:1901
void set_defaults()
Definition AppConfig.cpp:129
std::vector< std::string > m_filament_multi_colors
Definition AppConfig.hpp:485
std::vector< std::string > m_filament_color_types
Definition AppConfig.hpp:486
static const std::string SECTION_FILAMENTS
Definition AppConfig.hpp:408
std::string loading_path()
Definition AppConfig.hpp:376
static boost::optional< Semver > parse(const std::string &str)
Definition Semver.hpp:63
T * begin(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:838
NozzleVolumeType
Definition PrintConfig.hpp:618
bool unescape_strings_cstyle(const std::string &str, std::vector< std::string > &out)
Definition Config.cpp:173
CopyFileResult copy_file(const std::string &from, const std::string &to, std::string &error_message, const bool with_check)
Definition utils.cpp:1071
@ SUCCESS
Definition Utils.hpp:260
BedType
Definition PrintConfig.hpp:507
nlohmann::json json
Definition AssembleList.cpp:42
std::string format(const char *fmt, TArgs &&... args)
Definition format.hpp:45
bool empty(const BoundingBoxBase< PointType, PointsType > &bb)
Definition BoundingBox.hpp:273
FlowRatioCalibrationType
Definition calib.hpp:68
static const std::string MODELS_STR
Definition AppConfig.cpp:66
size_t dump(const PresetBundle &bundle, const Sections &sections, std::ostream &out)
Definition profile_include_dump.cpp:96

References Slic3r::BBLocalMachine::access_code, Slic3r::CaliPresetInfo::bed_type, Slic3r::PrinterCaliInfo::cache_flow_rate_calibration_type, Slic3r::PrinterCaliInfo::cache_flow_ratio, Slic3r::PrinterCaliInfo::cali_finished, Slic3r::copy_file(), Slic3r::BBLocalMachine::dev_id, Slic3r::PrinterCaliInfo::dev_id, Slic3r::BBLocalMachine::dev_ip, Slic3r::BBLocalMachine::dev_name, Editor, Slic3r::empty(), Slic3r::CaliPresetInfo::extruder_id, Slic3r::CaliPresetInfo::filament_id, Slic3r::format(), get(), get_bool(), loading_path(), lock_path(), m_dirty, m_filament_color_types, m_filament_colors, m_filament_multi_colors, m_filament_presets, m_legacy_datadir, m_local_machines, m_mode, m_orig_version, m_printer_cali_infos, m_printer_settings, m_storage, m_vendors, Slic3r::MODELS_STR, Slic3r::CaliPresetInfo::name, Slic3r::CaliPresetInfo::nozzle_diameter, Slic3r::CaliPresetInfo::nozzle_pos_id, Slic3r::CaliPresetInfo::nozzle_sn, Slic3r::CaliPresetInfo::nozzle_volume_type, Slic3r::Semver::parse(), Slic3r::BBLocalMachine::printer_agent_id, Slic3r::BBLocalMachine::printer_type, SECTION_FILAMENTS, Slic3r::PrinterCaliInfo::selected_presets, set(), set_defaults(), SETTING_CLOUD_PROVIDERS, Slic3r::CaliPresetInfo::setting_id, Slic3r::SUCCESS, Slic3r::CaliPresetInfo::tray_id, and Slic3r::unescape_strings_cstyle().

Referenced by load_if_exists().

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

◆ load_if_exists()

std::string Slic3r::AppConfig::load_if_exists ( )
1941{
1942 return boost::filesystem::exists(loading_path()) ? load(/*read_only=*/true) : std::string();
1943}
std::string load(bool read_only=false)
Definition AppConfig.cpp:788

References load(), and loading_path().

Referenced by Slic3r::CLI::run().

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

◆ loading_path()

std::string Slic3r::AppConfig::loading_path ( )
inline
376{ return (m_loading_path.empty() ? config_path() : m_loading_path); }
std::string m_loading_path
Definition AppConfig.hpp:481

References config_path(), and m_loading_path.

Referenced by load(), and load_if_exists().

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

◆ lock_path()

std::string Slic3r::AppConfig::lock_path ( )
1902{
1903 return Slic3r::data_dir().empty() ? std::string() : config_path() + ".lock";
1904}

References config_path(), and Slic3r::data_dir().

Referenced by load(), and write_config_file().

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

◆ orig_version()

Semver Slic3r::AppConfig::orig_version ( ) const
inline
370{ return m_orig_version; }

References m_orig_version.

Referenced by Slic3r::PresetUpdater::priv::check_new_vendors().

Here is the caller graph for this function:

◆ profile_update_url()

std::string Slic3r::AppConfig::profile_update_url ( ) const
1928{
1929 std::string orca_updater_url = get(CONFIG_ORCA_UPDATER_URL);
1930 if (orca_updater_url.empty())
1931 return PROFILE_UPDATE_URL;
1932 return orca_updater_url;
1933}
constexpr const char * CONFIG_ORCA_UPDATER_URL
Definition AppConfig.cpp:64
static const std::string PROFILE_UPDATE_URL
Definition AppConfig.cpp:62

References Slic3r::CONFIG_ORCA_UPDATER_URL, get(), and Slic3r::PROFILE_UPDATE_URL.

Referenced by Slic3r::PresetUpdater::priv::check_new_vendors(), Slic3r::PresetUpdater::priv::set_download_prefs(), and Slic3r::PresetUpdater::priv::sync_vendor_config().

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

◆ remove_cloud_provider()

void Slic3r::AppConfig::remove_cloud_provider ( const std::string & provider)
1879{
1880 if (provider == "orca")
1881 return; // Cannot remove orca
1882 auto providers = get_cloud_providers();
1883 providers.erase(std::remove(providers.begin(), providers.end(), provider), providers.end());
1884 set_cloud_providers(providers);
1885}

References get_cloud_providers(), and set_cloud_providers().

Here is the call graph for this function:

◆ reset()

void Slic3r::AppConfig::reset ( )
123{
124 m_storage.clear();
125 set_defaults();
126};

References m_storage, and set_defaults().

Referenced by AppConfig(), and Slic3r::CLI::run().

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

◆ reset_selections()

void Slic3r::AppConfig::reset_selections ( )
1888{
1889 auto it = m_storage.find("presets");
1890 if (it != m_storage.end()) {
1891 it->second.erase(PRESET_PRINT_NAME);
1892 it->second.erase(PRESET_FILAMENT_NAME);
1893 it->second.erase("sla_print");
1894 it->second.erase("sla_material");
1895 it->second.erase(PRESET_PRINTER_NAME);
1896 it->second.erase("physical_printer");
1897 m_dirty = true;
1898 }
1899}
#define PRESET_PRINTER_NAME
Definition Preset.hpp:35
#define PRESET_PRINT_NAME
Definition Preset.hpp:34
#define PRESET_FILAMENT_NAME
Definition Preset.hpp:33

References m_dirty, m_storage, PRESET_FILAMENT_NAME, PRESET_PRINT_NAME, and PRESET_PRINTER_NAME.

◆ save()

void Slic3r::AppConfig::save ( )
1038{
1039 if (!is_main_thread_active()) {
1040 BOOST_LOG_TRIVIAL(fatal) << "Calling AppConfig::save() from a worker thread!";
1041 throw CriticalException("Calling AppConfig::save() from a worker thread!");
1042 }
1043
1044 // The config is first written to a file with a PID suffix and then moved
1045 // to avoid race conditions with multiple instances of Slic3r
1046 const auto path = config_path();
1047
1048 json j;
1049
1050 std::stringstream config_ss;
1051 if (m_mode == EAppMode::Editor)
1052 j["header"] = Slic3r::header_slic3r_generated();
1053 else
1055
1056 // Make sure the "no" category is written first.
1057 for (const auto& kvp : m_storage["app"]) {
1058 if (kvp.second == "true") {
1059 j["app"][kvp.first] = true;
1060 continue;
1061 }
1062 if (kvp.second == "false") {
1063 j["app"][kvp.first] = false;
1064 continue;
1065 }
1066 j["app"][kvp.first] = kvp.second;
1067 }
1068
1069 for (const auto &filament_preset : m_filament_presets) {
1070 j["app"]["filament_presets"].push_back(filament_preset);
1071 }
1072
1073 for (const auto &filament_color : m_filament_colors) {
1074 j["app"]["filament_colors"].push_back(filament_color);
1075 }
1076 for (const auto &filament_multi_color : m_filament_multi_colors) {
1077 j["app"]["filament_multi_colors"].push_back(filament_multi_color);
1078 }
1079
1080 for (const auto &filament_color_type : m_filament_color_types) {
1081 j["app"]["filament_color_types"].push_back(filament_color_type);
1082 }
1083
1084 for (const auto &cali_info : m_printer_cali_infos) {
1085 json cali_json;
1086 cali_json["dev_id"] = cali_info.dev_id;
1087 cali_json["flow_ratio"] = cali_info.cache_flow_ratio;
1088 cali_json["cali_finished"] = cali_info.cali_finished ? 1 : 0;
1089 cali_json["cache_flow_rate_calibration_type"] = static_cast<int>(cali_info.cache_flow_rate_calibration_type);
1090 for (auto filament_preset : cali_info.selected_presets) {
1091 json preset_json;
1092 preset_json["tray_id"] = filament_preset.tray_id;
1093 preset_json["extruder_id"] = filament_preset.extruder_id;
1094 preset_json["nozzle_volume_type"] = int(filament_preset.nozzle_volume_type);
1095 preset_json["bed_type"] = int(filament_preset.bed_type);
1096 preset_json["nozzle_pos_id"] = filament_preset.nozzle_pos_id;
1097 preset_json["nozzle_sn"] = filament_preset.nozzle_sn;
1098 preset_json["nozzle_diameter"] = filament_preset.nozzle_diameter;
1099 preset_json["filament_id"] = filament_preset.filament_id;
1100 preset_json["setting_id"] = filament_preset.setting_id;
1101 preset_json["name"] = filament_preset.name;
1102 cali_json["presets"].push_back(preset_json);
1103 }
1104 j["calis"].push_back(cali_json);
1105 }
1106
1107 // Write the other categories.
1108 for (const auto& category : m_storage) {
1109 if (category.first.empty())
1110 continue;
1111 if (category.first == SECTION_FILAMENTS) {
1112 json j_filaments;
1113 for (const auto& kvp: category.second) {
1114 j_filaments.push_back(kvp.first);
1115 }
1116 j[category.first] = j_filaments;
1117 continue;
1118 } else if (category.first == "presets") {
1119 json j_filament_array;
1120 for(const auto& kvp : category.second) {
1121 if (boost::starts_with(kvp.first, "filament") && kvp.first != "filament_colors" && kvp.first != "filament_multi_colors" && kvp.first != "filament_color_types") {
1122 j_filament_array.push_back(kvp.second);
1123 } else {
1124 j[category.first][kvp.first] = kvp.second;
1125 }
1126 }
1127 j["presets"]["filaments"] = j_filament_array;
1128 continue;
1129 }
1130 for (const auto& kvp : category.second) {
1131 if (kvp.second == "true") {
1132 j[category.first][kvp.first] = true;
1133 continue;
1134 }
1135 if (kvp.second == "false") {
1136 j[category.first][kvp.first] = false;
1137 continue;
1138 }
1139 j[category.first][kvp.first] = kvp.second;
1140 }
1141 }
1142
1143 // Write vendor sections
1144 for (const auto& vendor : m_vendors) {
1145 size_t size_sum = 0;
1146 for (const auto& model : vendor.second) { size_sum += model.second.size(); }
1147 if (size_sum == 0) { continue; }
1148
1149 for (const auto& model : vendor.second) {
1150 if (model.second.empty()) { continue; }
1151 const std::vector<std::string> variants(model.second.begin(), model.second.end());
1152 const auto escaped = escape_strings_cstyle(variants);
1153 //j[VENDOR_PREFIX + vendor.first][MODEL_PREFIX + model.first] = escaped;
1154 json j_model;
1155 j_model["vendor"] = vendor.first;
1156 j_model["model"] = model.first;
1157 j_model["nozzle_diameter"] = escaped;
1158 j[MODELS_STR].push_back(j_model);
1159 }
1160 }
1161
1162 // write machine settings
1163 for (const auto& preset : m_printer_settings) {
1164 j["orca_presets"].push_back(preset.second);
1165 }
1166 for (const auto& local_machine : m_local_machines) {
1167 json m_json;
1168 m_json["dev_name"] = local_machine.second.dev_name;
1169 m_json["dev_ip"] = local_machine.second.dev_ip;
1170 m_json["printer_type"] = local_machine.second.printer_type;
1171 m_json["printer_agent_id"] = local_machine.second.printer_agent_id;
1172 m_json["access_code"] = local_machine.second.access_code;
1173
1174 j["local_machines"][local_machine.first] = m_json;
1175 }
1176 const std::string config_str = j.dump(1, '\t');
1177 if (write_config_file(path, config_str + "\n", config_str))
1178 m_dirty = false;
1179}
bool write_config_file(const std::string &path, std::string body, const std::string &checksum_source)
Definition AppConfig.cpp:1366
std::string header_slic3r_generated()
Definition utils.cpp:1470
bool is_main_thread_active()
Definition Thread.cpp:218
std::string header_gcodeviewer_generated()
Definition utils.cpp:1475
std::string escape_strings_cstyle(const std::vector< std::string > &strs)
Definition Config.cpp:99

References config_path(), Editor, Slic3r::escape_strings_cstyle(), Slic3r::header_gcodeviewer_generated(), Slic3r::header_slic3r_generated(), Slic3r::is_main_thread_active(), m_dirty, m_filament_color_types, m_filament_colors, m_filament_multi_colors, m_filament_presets, m_local_machines, m_mode, m_printer_cali_infos, m_printer_settings, m_storage, m_vendors, Slic3r::MODELS_STR, SECTION_FILAMENTS, and write_config_file().

Referenced by Slic3r::GUI::anonymous_namespace{NativeCommands.cpp}::build_command_catalog(), Slic3r::GUI::anonymous_namespace{ColorPickerDialog.cpp}::save_color_picker_favorites(), and update_last_backup_dir().

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

◆ save_custom_color_to_config()

void Slic3r::AppConfig::save_custom_color_to_config ( const std::vector< std::string > & colors)
1665{
1666 auto set_colors = [](std::map<std::string, std::string> &data, const std::vector<std::string> &colors) {
1667 for (size_t i = 0; i < colors.size(); i++) {
1668 data[std::to_string(10 + i)] = colors[i]; // for map sort:10 begin
1669 }
1670 };
1671 if (colors.size() > 0) {
1672 if (!has_section("custom_color_list")) {
1673 std::map<std::string, std::string> data;
1674 set_colors(data, colors);
1675 set_section("custom_color_list", data);
1676 } else {
1677 auto data = get_section("custom_color_list");
1678 auto data_modify = const_cast<std::map<std::string, std::string> *>(&data);
1679 set_colors(*data_modify, colors);
1680 set_section("custom_color_list", *data_modify);
1681 }
1682 }
1683}
void set_section(const std::string &section, const std::map< std::string, std::string > &data)
Definition AppConfig.hpp:246

References get_section(), has_section(), and set_section().

Here is the call graph for this function:

◆ save_due()

bool Slic3r::AppConfig::save_due ( ) const
inline
141{ return std::chrono::steady_clock::now() >= m_retry_save_at; }
std::chrono::steady_clock::time_point m_retry_save_at
Definition AppConfig.hpp:475

References m_retry_save_at.

◆ save_nozzle_volume_types_to_config()

void Slic3r::AppConfig::save_nozzle_volume_types_to_config ( const std::string & printer_name,
const std::string & nozzle_volume_types )
1698{
1699 if (!has_section("nozzle_volume_types")) {
1700 std::map<std::string, std::string> data;
1701 data[printer_name] = nozzle_volume_types;
1702 set_section("nozzle_volume_types", data);
1703 } else {
1704 auto data = get_section("nozzle_volume_types");
1705 auto data_modify = const_cast<std::map<std::string, std::string>&>(data);
1706 data_modify[printer_name] = nozzle_volume_types;
1707 set_section("nozzle_volume_types", data_modify);
1708 }
1709}

References get_section(), has_section(), and set_section().

Here is the call graph for this function:

◆ save_printer_cali_infos()

void Slic3r::AppConfig::save_printer_cali_infos ( const PrinterCaliInfo & cali_info,
bool need_change_status = true )
1446{
1447 auto iter = std::find_if(m_printer_cali_infos.begin(), m_printer_cali_infos.end(), [&cali_info](const PrinterCaliInfo &cali_info_item) {
1448 return cali_info_item.dev_id == cali_info.dev_id;
1449 });
1450
1451 if (iter == m_printer_cali_infos.end()) {
1452 m_printer_cali_infos.emplace_back(cali_info);
1453 } else {
1454 if (need_change_status) {
1455 (*iter).cali_finished = cali_info.cali_finished;
1456 }
1457 (*iter).cache_flow_ratio = cali_info.cache_flow_ratio;
1458 (*iter).selected_presets = cali_info.selected_presets;
1459 (*iter).cache_flow_rate_calibration_type = cali_info.cache_flow_rate_calibration_type;
1460 }
1461 m_dirty = true;
1462}

References Slic3r::PrinterCaliInfo::cache_flow_rate_calibration_type, Slic3r::PrinterCaliInfo::cache_flow_ratio, Slic3r::PrinterCaliInfo::cali_finished, m_dirty, m_printer_cali_infos, and Slic3r::PrinterCaliInfo::selected_presets.

◆ set() [1/4]

void Slic3r::AppConfig::set ( const std::string & key,
const std::string & value )
inline
215 { this->set("app", key, value); }

References set().

Here is the call graph for this function:

◆ set() [2/4]

void Slic3r::AppConfig::set ( const std::string & section,
const std::string & key,
bool value )
inline
205 {
206 if (value){
207 set(section, key, std::string("true"));
208 } else {
209 set(section, key, std::string("false"));
210 }
211 }

References set().

Here is the call graph for this function:

◆ set() [3/4]

void Slic3r::AppConfig::set ( const std::string & section,
const std::string & key,
const char * value )
inline
202 { this->set(section, key, std::string(value)); }

References set().

Here is the call graph for this function:

◆ set() [4/4]

void Slic3r::AppConfig::set ( const std::string & section,
const std::string & key,
const std::string & value )
inline
168 {
169#ifndef NDEBUG
170 {
171 std::string key_trimmed = key;
172 boost::trim_all(key_trimmed);
173 assert(key_trimmed == key);
174 assert(! key_trimmed.empty());
175 }
176#endif // NDEBUG
177 std::string &old = m_storage[section][key];
178 if (old != value) {
179 old = value;
180 m_dirty = true;
181 }
182 }

References m_dirty, and m_storage.

Referenced by Slic3r::GUI::Sidebar::Sidebar(), add_skipped_network_version(), clear_skipped_network_versions(), Slic3r::GUI::PreferencesDialog::create_item_region_combobox(), Slic3r::GUI::ElegooPrintHostSendDialog::EndModal(), Slic3r::GUI::FlashforgePrintHostSendDialog::EndModal(), Slic3r::GUI::PrintHostSendDialog::EndModal(), Slic3r::GUI::Config::Snapshot::export_selections(), Slic3r::PresetBundle::export_selections(), Slic3r::GUI::Sidebar::priv::get_nozzle_options(), Slic3r::GUI::ColorPickerDialog::handle_web_command(), Slic3r::GUI::CrealityPrintHostSendDialog::init(), Slic3r::GUI::Config::SnapshotDB::is_on_snapshot(), load(), Slic3r::GUI::Plater::priv::load_files(), Slic3r::PresetBundle::load_installed_filaments(), Slic3r::PresetBundle::load_installed_sla_materials(), Slic3r::PresetBundle::load_selections(), main(), Slic3r::GUI::Plater::priv::on_select_bed_type(), Slic3r::GUI::ShortcutRegistry::save(), Slic3r::GUI::SelectMachineDialog::save_option_vals(), set(), set(), set(), set_bool(), set_cloud_providers(), set_defaults(), set_network_plugin_version(), anonymous_namespace{OrcaSlicer_profile_validator.cpp}::slice_all_printers(), Slic3r::GUI::Plater::priv::undo_redo_to(), update_config_dir(), update_last_backup_dir(), update_last_output_dir(), Slic3r::GUI::PageMaterials::update_lists(), update_skein_dir(), and Slic3r::instance_id::anonymous_namespace{InstanceID.cpp}::write_config_value().

Here is the caller graph for this function:

◆ set_bool()

void Slic3r::AppConfig::set_bool ( const std::string & key,
const bool & value )
inline
218 {
219 this->set("app", key, value);
220 }

References set().

Referenced by Slic3r::GUI::anonymous_namespace{NativeCommands.cpp}::build_command_catalog(), clear_remind_network_update_later(), set_defaults(), set_network_update_prompt_disabled(), and set_remind_network_update_later().

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

◆ set_cloud_providers()

void Slic3r::AppConfig::set_cloud_providers ( const std::vector< std::string > & providers)
1854{
1855 std::string joined;
1856 for (size_t i = 0; i < providers.size(); ++i) {
1857 if (i > 0) joined += ";";
1858 joined += providers[i];
1859 }
1861}

References set(), and SETTING_CLOUD_PROVIDERS.

Referenced by add_cloud_provider(), and remove_cloud_provider().

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

◆ set_defaults()

void Slic3r::AppConfig::set_defaults ( )
130{
131 if (m_mode == EAppMode::Editor) {
132#ifdef SUPPORT_AUTO_CENTER
133 // Reset the empty fields to defaults.
134 if (get("autocenter").empty())
135 set_bool("autocenter", true);
136#endif
137
138#ifdef SUPPORT_BACKGROUND_PROCESSING
139 // Disable background processing by default as it is not stable.
140 if (get("background_processing").empty())
141 set_bool("background_processing", false);
142#endif
143 if (get("auto_slice_after_change").empty())
144 set_bool("auto_slice_after_change", false);
145
146 if (get("auto_slice_change_delay_seconds").empty())
147 set("auto_slice_change_delay_seconds", "1");
148
149 if (get("drop_project_action").empty())
150 set_bool("drop_project_action", true);
151
152#ifdef _WIN32
153 if (get("associate_3mf").empty())
154 set_bool("associate_3mf", false);
155 if (get("associate_drc").empty())
156 set_bool("associate_drc", false);
157 if (get("associate_stl").empty())
158 set_bool("associate_stl", false);
159 if (get("associate_step").empty())
160 set_bool("associate_step", false);
161
162#endif // _WIN32
163
164 // remove old 'use_legacy_opengl' parameter from this config, if present
165 if (!get("use_legacy_opengl").empty())
166 erase("app", "use_legacy_opengl");
167
168 // Migrate legacy_networking boolean to network_plugin_version string
169 std::string legacy_networking = get("legacy_networking");
170 std::string network_version = get("network_plugin_version");
171
172 if (!legacy_networking.empty()) {
173 // Old legacy_networking setting exists - migrate it
174 bool was_legacy = (legacy_networking == "true" || legacy_networking == "1");
175
176 if (was_legacy && network_version.empty()) {
177 // User had legacy mode enabled - set to legacy version number
178 BOOST_LOG_TRIVIAL(info) << "Migrating legacy_networking=true to network_plugin_version=01.10.01.01";
180 }
181 // Note: If was_legacy=false, we leave the version empty and let the GUI layer set it to the latest version
182
183 // Remove the old setting
184 erase("app", "legacy_networking");
185 }
186
187#ifdef __APPLE__
188 if (get("use_retina_opengl").empty())
189 set_bool("use_retina_opengl", true);
190#endif
191
192 if (get("single_instance").empty())
193 set_bool("single_instance", false);
194
195#ifdef SUPPORT_REMEMBER_OUTPUT_PATH
196 if (get("remember_output_path").empty())
197 set_bool("remember_output_path", true);
198
199 if (get("remember_output_path_removable").empty())
200 set_bool("remember_output_path_removable", true);
201#endif
202 if (get("toolkit_size").empty())
203 set("toolkit_size", "100");
204
205#if ENABLE_ENVIRONMENT_MAP
206 if (get("use_environment_map").empty())
207 set("use_environment_map", false);
208#endif // ENABLE_ENVIRONMENT_MAP
209
210 if (get("use_inches").empty())
211 set("use_inches", "0");
212
213 if (get("default_page").empty())
214 set("default_page", "0");
215 }
216 else {
217#ifdef _WIN32
218 if (get("associate_gcode").empty())
219 set_bool("associate_gcode", false);
220#endif // _WIN32
221 }
222
223 if (get("seq_top_layer_only").empty())
224 set("seq_top_layer_only", "1");
225
226 // ORCA: darken the layers the preview layer slider is not scrubbed to
227 if (get("preview_dim_previous_layers").empty())
228 set_bool("preview_dim_previous_layers", false);
229
230 // ORCA: brightness of those dimmed layers, in percent. 0 = black, capped at 99 because
231 // 100 would render them unchanged, which is what disabling the option already does
232 if (get("preview_dim_previous_layers_brightness").empty())
233 set("preview_dim_previous_layers_brightness", "40");
234 else {
235 int brightness = 40;
236 try {
237 brightness = std::stoi(get("preview_dim_previous_layers_brightness"));
238 }
239 catch (...) {
240 brightness = 40;
241 }
242 set("preview_dim_previous_layers_brightness", std::to_string(std::max(0, std::min(brightness, 99))));
243 }
244
245 // ORCA: whether the G-code preview keeps the opacity of the filament colors
246 if (get("preview_translucent_filaments").empty())
247 set_bool("preview_translucent_filaments", true);
248
249 // ORCA: whether realistic view gives the opaque toolpaths a glossy highlight
252
253 // ORCA: view type the G-code preview opens with. "auto" keeps the automatic choice (Filament for
254 // multi material prints, Line Type for single material ones), "last" restores the view type the user
255 // picked last, any other value is a fixed view type name, see GCodeViewer::view_type_to_config_name().
256 if (get("preview_default_view_type").empty())
257 set("preview_default_view_type", "auto");
258
259 if (get("filaments_area_preferred_count").empty())
260 set("filaments_area_preferred_count", "10");
261
262 if (get("use_perspective_camera").empty())
263 set_bool("use_perspective_camera", true);
264
265 if (get("auto_perspective").empty())
266 set_bool("auto_perspective", false);
267
268 if (get("use_free_camera").empty())
269 set_bool("use_free_camera", false);
270
271 if (get("camera_navigation_style").empty())
272 set("camera_navigation_style", "0");
273
274 if (get("left_mouse_drag_action").empty())
275 set("left_mouse_drag_action", "2");
276
277 if (get("middle_mouse_drag_action").empty())
278 set("middle_mouse_drag_action", "1");
279
280 if (get("right_mouse_drag_action").empty())
281 set("right_mouse_drag_action", "1");
282
283 if (get("reverse_mouse_wheel_zoom").empty())
284 set_bool("reverse_mouse_wheel_zoom", false);
285
286 if (get("enable_append_color_by_sync_ams").empty())
287 set_bool("enable_append_color_by_sync_ams", true);
288 if (get("enable_merge_color_by_sync_ams").empty())
289 set_bool("enable_merge_color_by_sync_ams", false);
290 if (get("ams_sync_match_full_use_color_dist").empty())
291 set_bool("ams_sync_match_full_use_color_dist", false);
292 if (get("sync_ams_filament_mode").empty())
293 set("sync_ams_filament_mode", "0"); // 0: filament+color, 1: color only
294
295 if (get("camera_orbit_mult").empty())
296 set("camera_orbit_mult", "1.0");
297
300
303
306 else {
307 int fps_cap = 0;
308 try {
309 fps_cap = std::stoi(get(SETTING_OPENGL_FPS_CAP));
310 }
311 catch (...) {
312 fps_cap = 0;
313 }
314 fps_cap = std::max(0, std::min(fps_cap, 240));
315 set(SETTING_OPENGL_FPS_CAP, std::to_string(fps_cap));
316 }
317
320
323
324 // The getter already defaults, parses and clamps; write back what it resolves to.
326
328
331
334
337
340
343
346
347 // Replaces the on/off setting, whose shadows turned with the camera.
350
353
356
357 if (get("export_sources_full_pathnames").empty())
358 set_bool("export_sources_full_pathnames", false);
359
360 if (get("zoom_to_mouse").empty())
361 set_bool("zoom_to_mouse", false);
362
363#ifdef SLIC3R_CAD
364 // Experimental parametric Design tab. Off by default: the tab is not created at all
365 // until this is turned on, so nothing it builds reaches an unsuspecting user.
366 if (get("enable_cad_feature").empty())
367 set_bool("enable_cad_feature", false);
368
369 // Auto-weld sketch endpoints within kSketchJoinTol when building closed loops.
370 // Default ON: it is what the ~90% case wants; OFF makes the kernel demand an exact
371 // joint. The GUI pushes it into SketchEngine via set_sketch_auto_close().
372 if (get("auto_close_sketch_loops").empty())
373 set_bool("auto_close_sketch_loops", true);
374
375 // Design tab: draw a mate connector as a face rather than as the abstract disc + roll
376 // quadrant. Defaults ON — face orientation is hardwired perception, so the roll and the
377 // verse read without being learned, which no abstract glyph achieves. Turning it off
378 // restores the conventional CAD representation for users who expect it (x0kd).
379 if (get("design_connector_face_glyph").empty())
380 set_bool("design_connector_face_glyph", true);
381
382 // Design tab: draw the printer bed and its plate grid (the Feature tree's Bed row).
383 if (get("design_show_bed").empty())
384 set_bool("design_show_bed", true);
385#endif
386
387//#ifdef SUPPORT_SHOW_HINTS
388 if (get("show_hints").empty())
389 set_bool("show_hints", false);
390//#endif
391 if (get("enable_multi_machine").empty())
392 set_bool("enable_multi_machine", false);
393
394 if (get("drc_bits").empty())
395 set("drc_bits", DRC_BITS_DEFAULT_STR);
396
397 if (get("show_gcode_window").empty())
398 set_bool("show_gcode_window", true);
399
400 if (get("show_3d_navigator").empty())
401 set_bool("show_3d_navigator", true);
402
403 // Show the one-time "Filament Track Switch is ready" tip until it has been seen once.
404 if (get("show_fila_switch_tips").empty())
405 set_bool("show_fila_switch_tips", true);
406
407 if (get("show_plate_gridlines").empty())
408 set_bool("show_plate_gridlines", true);
409
410 if (get("focus_mode").empty())
411 set_bool("focus_mode", false);
412
413 if (get("show_outline").empty())
414 set_bool("show_outline", false);
415
416 if (get("show_axes").empty())
417 set_bool("show_axes", true);
418
419 if (get("show_labels").empty())
420 set_bool("show_labels", false);
421 if (get("show_collision_volumes").empty())
422 set_bool("show_collision_volumes", false);
423
424 if (get("show_overhang").empty())
425 set_bool("show_overhang", false);
426
427 if (get("show_center_of_mass").empty())
428 set_bool("show_center_of_mass", false);
429
430#ifdef _WIN32
431
432//#ifdef SUPPORT_3D_CONNEXION
433 if (get("use_legacy_3DConnexion").empty())
434 set_bool("use_legacy_3DConnexion", true);
435//#endif
436
437#ifdef SUPPORT_DARK_MODE
438 if (get("dark_color_mode").empty())
439 set("dark_color_mode", "0");
440#endif
441
442//#ifdef SUPPORT_SYS_MENU
443 if (get("sys_menu_enabled").empty())
444 set("sys_menu_enabled", "1");
445//#endif
446#endif // _WIN32
447
448 // BBS
449 /*if (get("3mf_include_gcode").empty())
450 set_bool("3mf_include_gcode", true);*/
451
452 if (get("developer_mode").empty())
453 set_bool("developer_mode", false);
454
455 if (get("show_unsupported_presets").empty())
456 set_bool("show_unsupported_presets", false);
457
458 if (get("enable_ssl_for_mqtt").empty())
459 set_bool("enable_ssl_for_mqtt", true);
460
461 if (get("enable_ssl_for_ftp").empty())
462 set_bool("enable_ssl_for_ftp", true);
463
464 if (get("log_severity_level").empty())
465 set("log_severity_level", "info");
466
467 if (get("internal_developer_mode").empty())
468 set_bool("internal_developer_mode", false);
469
470 // BBS
471 if (get("preset_folder").empty())
472 set("preset_folder", "");
473
474 // BBS
475 if (get("slicer_uuid").empty()) {
476 boost::uuids::uuid uuid = boost::uuids::random_generator()();
477 set("slicer_uuid", to_string(uuid));
478 }
479
480 // Orca
481 if (get("stealth_mode").empty()) {
482 set_bool("stealth_mode", false);
483 }
484 if (get("hide_login_side_panel").empty()) {
485 set_bool("hide_login_side_panel", false);
486 }
487 if (get("allow_abnormal_storage").empty()) {
488 set_bool("allow_abnormal_storage", false);
489 }
490
491 if (get("preset_bundle_auto_update").empty()) {
492 set_bool("preset_bundle_auto_update", false);
493 }
494
495#ifdef __linux__
498#else
501#endif
502
503 if(get("check_stable_update_only").empty()) {
504 set_bool("check_stable_update_only", false);
505 }
506
507 // Orca
508 if(get("show_splash_screen").empty()) {
509 set_bool("show_splash_screen", true);
510 }
511
512 if(get("auto_arrange").empty()) {
513 set_bool("auto_arrange", true);
514 }
515
516 if (get("show_model_mesh").empty()) {
517 set_bool("show_model_mesh", false);
518 }
519
520 if (get("show_model_shadow").empty()) {
521 set_bool("show_model_shadow", true);
522 }
523
524 if (get("show_build_edges").empty()) {
525 set_bool("show_build_edgets", false);
526 }
527
528 if (get("show_daily_tips").empty()) {
529 set_bool("show_daily_tips", true);
530 }
531
532 if (get("show_shared_profiles_notification").empty()) {
533 set_bool("show_shared_profiles_notification", true);
534 }
535
536 if (get("auto_calculate_flush").empty()){
537 set("auto_calculate_flush","all");
538 }
539
540 if (get("show_canvas_zoom_button").empty()) {
541 set_bool("show_canvas_zoom_button", true);
542 }
543
544 if (get("remember_printer_config").empty()) {
545 set_bool("remember_printer_config", true);
546 }
547
548 if (get("group_filament_presets").empty()) {
549 set("group_filament_presets", "1"); // All "0" / None "1" / By Type "2" / By Vendor "3"
550 }
551
552 if (get("enable_high_low_temp_mixed_printing").empty()){
553 set_bool("enable_high_low_temp_mixed_printing", false);
554 }
555
556 if (get("remember_print_action").empty()) {
557 set_bool("remember_print_action", false);
558 }
559
560 if (get("ignore_ext_filament_in_filament_map").empty()){
561 set_bool("ignore_ext_filament_in_filament_map", false);
562 }
563
564 if (get("pop_up_filament_map_dialog").empty()){
565 set_bool("pop_up_filament_map_dialog", false);
566 }
567
568 if (get("prefered_filament_map_mode").empty()){
570 }
571
572 if (get("show_home_page").empty()) {
573 set_bool("show_home_page", true);
574 }
575
576 if (get("show_printable_box").empty()) {
577 set_bool("show_printable_box", true);
578 }
579
580 if (get("units").empty()) {
581 set("units", "0");
582 }
583
584 if (get("sync_user_preset").empty()) {
585 set_bool("sync_user_preset", false);
586 }
587
588 if (get("keyboard_supported").empty()) {
589 set("keyboard_supported", std::string("none/alt/control/shift"));
590 }
591
592 if (get("mouse_supported").empty()) {
593 set("mouse_supported", "mouse left/mouse middle/mouse right");
594 }
595
596 if (get("privacy_version").empty()) {
597 set("privacy_version", "00.00.00.00");
598 }
599
600 if (get("rotate_view").empty()) {
601 set("rotate_view", "none/mouse left");
602 }
603
604 if (get("move_view").empty()) {
605 set("move_view", "none/mouse left");
606 }
607
608 if (get("zoom_view").empty()) {
609 set("zoom_view", "none/mouse left");
610 }
611
612 if (get("precise_control").empty()) {
613 set("precise_control", "none/mouse left");
614 }
615
616 if (get("download_path").empty()) {
617 set("download_path", "");
618 }
619
620 if (get("mouse_wheel").empty()) {
621 set("mouse_wheel", "0");
622 }
623
626 }
627
628 if (get("max_recent_count").empty()) {
629 set("max_recent_count", "18");
630 }
631
632 if (get("recent_models").empty()) {
633 set("recent_models", "0");
634 }
635
636 // if (get("staff_pick_switch").empty()) {
637 // set_bool("staff_pick_switch", false);
638 // }
639
640 if (get("sync_system_preset").empty()) {
641 set_bool("sync_system_preset", true);
642 }
643
644 if (get("backup_switch").empty() || get("version") < "01.06.00.00") {
645 set_bool("backup_switch", true);
646 }
647
648 if (get("backup_interval").empty()) {
649 set("backup_interval", "10");
650 }
651
652 if (get("curr_bed_type").empty()) {
653 set("curr_bed_type", "1");
654 }
655
656 if (get("sending_interval").empty()) {
657 set("sending_interval", "5");
658 }
659
660 if (get("max_send").empty()) {
661 set("max_send", "3");
662 }
663
664// #if BBL_RELEASE_TO_PUBLIC
665 if (get("iot_environment").empty()) {
666 set("iot_environment", "3");
667 }
668// #else
669// if (get("iot_environment").empty()) {
670// set("iot_environment", "1");
671// }
672// #endif
673
674 if (get("allow_ip_resolve").empty())
675 set_bool("allow_ip_resolve", true);
676
677 if (get("presets", "filament_colors").empty()) {
678 set_str("presets", "filament_colors", "#F2754E");
679 }
680
681 if (get("print", "bed_leveling").empty()) {
682 set_str("print", "bed_leveling", "1");
683 }
684 if (get("print", "flow_cali").empty()) {
685 set_str("print", "flow_cali", "1");
686 }
687 if (get("print", "timelapse").empty()) {
688 set_str("print", "timelapse", "1");
689 }
690
691 if (get("enable_step_mesh_setting").empty()) {
692 set_bool("enable_step_mesh_setting", true);
693 }
694 // Migrate legacy misspelled keys (linear_defletion/angle_defletion) to the corrected spelling.
695 if (get("linear_deflection").empty() && !get("linear_defletion").empty())
696 set("linear_deflection", get("linear_defletion"));
697 if (get("angle_deflection").empty() && !get("angle_defletion").empty())
698 set("angle_deflection", get("angle_defletion"));
699 if (get("linear_deflection").empty()) {
700 set("linear_deflection", "0.003");
701 }
702 if (get("angle_deflection").empty()) {
703 set("angle_deflection", "0.5");
704 }
705 if (get("is_split_compound").empty()) {
706 set_bool("is_split_compound", false);
707 }
708
709 if(get("installed_networking").empty()) {
710 set_bool("installed_networking", false);
711 }
712
713#ifdef __linux__
714 if (get("window_buttons_on_left").empty())
715 set_bool("window_buttons_on_left", false);
716#endif
717
718 if (get("use_printer_agents").empty())
719 {
720 // false = legacy behavior using print hosts
721 set_bool("use_printer_agents", false);
722 }
723
724 if (get("enable_ota").empty())
725 {
726 set_bool("enable_ota", false);
727 }
728
729 // Remove legacy window positions/sizes
730 erase("app", "main_frame_maximized");
731 erase("app", "main_frame_pos");
732 erase("app", "main_frame_size");
733 erase("app", "object_settings_maximized");
734 erase("app", "object_settings_pos");
735 erase("app", "object_settings_size");
736 erase("app", "severity_level");
737}
#define BAMBU_NETWORK_AGENT_VERSION_LEGACY
Definition AppConfig.hpp:65
#define SETTING_OPENGL_PHONG_SSAO
Definition AppConfig.hpp:47
#define SETTING_OPENGL_FXAA_ENABLED
Definition AppConfig.hpp:35
#define SETTING_OPENGL_PHONG_BASIC_PLATE_SHADOWS
Definition AppConfig.hpp:44
#define SETTING_OPENGL_SHOW_RENDER_TIMINGS
Definition AppConfig.hpp:40
#define SETTING_USE_ENCRYPTED_TOKEN_FILE
Definition AppConfig.hpp:32
#define SETTING_OPENGL_SCENE_CACHE
Definition AppConfig.hpp:37
#define SETTING_OPENGL_REALISTIC_SHADOWS
Definition AppConfig.hpp:46
#define SETTING_OPENGL_PHONG_SMOOTH_NORMALS
Definition AppConfig.hpp:48
#define SETTING_OPENGL_SHADING_MODEL
Definition AppConfig.hpp:43
#define SETTING_OPENGL_REALISTIC_PREVIEW
Definition AppConfig.hpp:49
#define OPTION_PROJECT_LOAD_BEHAVIOUR_ASK_WHEN_RELEVANT
Definition AppConfig.hpp:24
#define SETTING_OPENGL_AA_SAMPLES
Definition AppConfig.hpp:34
#define SETTING_OPENGL_FPS_CAP
Definition AppConfig.hpp:36
#define SETTING_PROJECT_LOAD_BEHAVIOUR
Definition AppConfig.hpp:22
#define SETTING_OPENGL_REALISTIC_MODE
Definition AppConfig.hpp:41
#define SETTING_OPENGL_SHOW_FPS_OVERLAY
Definition AppConfig.hpp:39
#define SETTING_OPENGL_REALISTIC_GLOSS
Definition AppConfig.hpp:50
#define SETTING_OPENGL_REALISTIC_PHONG
Definition AppConfig.hpp:42
#define SETTING_OPENGL_SKIP_IDENTICAL_FRAMES
Definition AppConfig.hpp:38
#define DRC_BITS_DEFAULT_STR
Definition DRC.hpp:9
void set_str(const std::string &section, const std::string &key, const std::string &value)
Definition AppConfig.hpp:184
int get_speed_dial_recent_count() const
Definition AppConfig.cpp:1749
void set_network_plugin_version(const std::string &version)
Definition AppConfig.cpp:1728
int get_plugin_pages_visible_count() const
Definition AppConfig.cpp:1733
static const t_config_enum_names & get_enum_names()
@ fmmAutoForFlush
Definition PrintConfig.hpp:633
std::string to_string(const Vec2crd &pt)
Definition Point.hpp:165

References BAMBU_NETWORK_AGENT_VERSION_LEGACY, DRC_BITS_DEFAULT_STR, Editor, Slic3r::empty(), erase(), Slic3r::fmmAutoForFlush, get(), get_bool(), Slic3r::ConfigOptionEnum< T >::get_enum_names(), get_plugin_pages_visible_count(), get_speed_dial_recent_count(), m_mode, OPTION_PROJECT_LOAD_BEHAVIOUR_ASK_WHEN_RELEVANT, set(), set_bool(), set_network_plugin_version(), set_str(), SETTING_OPENGL_AA_SAMPLES, SETTING_OPENGL_FPS_CAP, SETTING_OPENGL_FXAA_ENABLED, SETTING_OPENGL_PHONG_BASIC_PLATE_SHADOWS, SETTING_OPENGL_PHONG_SMOOTH_NORMALS, SETTING_OPENGL_PHONG_SSAO, SETTING_OPENGL_REALISTIC_GLOSS, SETTING_OPENGL_REALISTIC_MODE, SETTING_OPENGL_REALISTIC_PHONG, SETTING_OPENGL_REALISTIC_PREVIEW, SETTING_OPENGL_REALISTIC_SHADOWS, SETTING_OPENGL_SCENE_CACHE, SETTING_OPENGL_SHADING_MODEL, SETTING_OPENGL_SHOW_FPS_OVERLAY, SETTING_OPENGL_SHOW_RENDER_TIMINGS, SETTING_OPENGL_SKIP_IDENTICAL_FRAMES, SETTING_PLUGIN_PAGES_VISIBLE_COUNT, SETTING_PROJECT_LOAD_BEHAVIOUR, SETTING_SPEED_DIAL_RECENT_COUNT, SETTING_USE_ENCRYPTED_TOKEN_FILE, and Slic3r::to_string().

Referenced by load(), and reset().

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

◆ set_dirty()

void Slic3r::AppConfig::set_dirty ( )
inline
144{ m_dirty = true; }

References m_dirty.

Referenced by Slic3r::GUI::anonymous_namespace{ColorPickerDialog.cpp}::save_color_picker_favorites().

Here is the caller graph for this function:

◆ set_filament_colors()

void Slic3r::AppConfig::set_filament_colors ( const std::vector< std::string > & filament_colors)
inline
315 {
316 m_filament_colors = filament_colors;
317 m_dirty = true;
318 }

References m_dirty, and m_filament_colors.

◆ set_filament_presets()

void Slic3r::AppConfig::set_filament_presets ( const std::vector< std::string > & filament_presets)
inline
310 {
311 m_filament_presets = filament_presets;
312 m_dirty = true;
313 }

References m_dirty, and m_filament_presets.

◆ set_legacy_datadir()

void Slic3r::AppConfig::set_legacy_datadir ( bool value)
inline
359{ m_legacy_datadir = value; }

References m_legacy_datadir.

Referenced by Slic3r::GUI::ConfigWizard::run(), and Slic3r::GUI::GuideFrame::run().

Here is the caller graph for this function:

◆ set_loading_path()

void Slic3r::AppConfig::set_loading_path ( const std::string & path)
inline
375{ m_loading_path = path; }

References m_loading_path.

◆ set_mouse_device()

void Slic3r::AppConfig::set_mouse_device ( const std::string & name,
double translation_speed,
double translation_deadzone,
float rotation_speed,
float rotation_deadzone,
double zoom_speed,
bool swap_yz,
bool invert_x,
bool invert_y,
bool invert_z,
bool invert_yaw,
bool invert_pitch,
bool invert_roll )
1514{
1515 std::string key = std::string("mouse_device:") + name;
1516 auto it = m_storage.find(key);
1517 if (it == m_storage.end())
1518 it = m_storage.insert(std::map<std::string, std::map<std::string, std::string>>::value_type(key, std::map<std::string, std::string>())).first;
1519
1520 it->second.clear();
1521 it->second["translation_speed"] = float_to_string_decimal_point(translation_speed);
1522 it->second["translation_deadzone"] = float_to_string_decimal_point(translation_deadzone);
1523 it->second["rotation_speed"] = float_to_string_decimal_point(rotation_speed);
1524 it->second["rotation_deadzone"] = float_to_string_decimal_point(rotation_deadzone);
1525 it->second["zoom_speed"] = float_to_string_decimal_point(zoom_speed);
1526 it->second["swap_yz"] = swap_yz ? "1" : "0";
1527 it->second["invert_x"] = invert_x ? "1" : "0";
1528 it->second["invert_y"] = invert_y ? "1" : "0";
1529 it->second["invert_z"] = invert_z ? "1" : "0";
1530 it->second["invert_yaw"] = invert_yaw ? "1" : "0";
1531 it->second["invert_pitch"] = invert_pitch ? "1" : "0";
1532 it->second["invert_roll"] = invert_roll ? "1" : "0";
1533 m_dirty = true;
1534}
std::string float_to_string_decimal_point(double value, int precision)
Definition LocalesUtils.cpp:108

References Slic3r::float_to_string_decimal_point(), m_dirty, and m_storage.

Referenced by Slic3r::GUI::Mouse3DController::save_config().

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

◆ set_network_plugin_version()

void Slic3r::AppConfig::set_network_plugin_version ( const std::string & version)
1729{
1731}

References set(), and SETTING_NETWORK_PLUGIN_VERSION.

Referenced by set_defaults().

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

◆ set_network_update_prompt_disabled()

void Slic3r::AppConfig::set_network_update_prompt_disabled ( bool disabled)
1812{
1814}

References set_bool(), and SETTING_NETWORK_PLUGIN_UPDATE_DISABLED.

Here is the call graph for this function:

◆ set_printer_setting()

void Slic3r::AppConfig::set_printer_setting ( std::string printer,
std::string name,
std::string value )
inline
278 {
279 m_printer_settings[printer][name] = value;
280 m_dirty = true;
281 }

References m_dirty, and m_printer_settings.

Referenced by Slic3r::PresetBundle::export_selections(), and Slic3r::GUI::Plater::priv::on_select_bed_type().

Here is the caller graph for this function:

◆ set_recent_projects()

void Slic3r::AppConfig::set_recent_projects ( const std::vector< std::string > & recent_projects)
1497{
1498 auto it = m_storage.find("recent_projects");
1499 if (it == m_storage.end())
1500 it = m_storage.insert(std::map<std::string, std::map<std::string, std::string>>::value_type("recent_projects", std::map<std::string, std::string>())).first;
1501
1502 it->second.clear();
1503 for (unsigned int i = 0; i < (unsigned int)recent_projects.size(); ++i)
1504 {
1505 auto n = std::to_string(i + 1);
1506 if (n.length() == 1) n = "00" + n;
1507 else if (n.length() == 2) n = "0" + n;
1508 it->second[n] = recent_projects[i];
1509 }
1510}

References m_storage.

◆ set_remind_network_update_later()

void Slic3r::AppConfig::set_remind_network_update_later ( bool remind)
1822{
1824}

References set_bool(), and SETTING_NETWORK_PLUGIN_REMIND_LATER.

Here is the call graph for this function:

◆ set_section()

void Slic3r::AppConfig::set_section ( const std::string & section,
const std::map< std::string, std::string > & data )
inline

◆ set_str()

void Slic3r::AppConfig::set_str ( const std::string & section,
const std::string & key,
const std::string & value )
inline
185 {
186#ifndef NDEBUG
187 {
188 std::string key_trimmed = key;
189 boost::trim_all(key_trimmed);
190 assert(key_trimmed == key);
191 assert(!key_trimmed.empty());
192 }
193#endif // NDEBUG
194 std::string& old = m_storage[section][key];
195 if (old != value) {
196 old = value;
197 m_dirty = true;
198 }
199 }

References m_dirty, and m_storage.

Referenced by Slic3r::anonymous_namespace{ElegooLink.cpp}::persist_sn(), Slic3r::MachineObject::set_access_code(), set_defaults(), and Slic3r::GUI::SyncAmsInfoDialog::update_timelapse_enable_status().

Here is the caller graph for this function:

◆ set_variant()

void Slic3r::AppConfig::set_variant ( const std::string & vendor,
const std::string & model,
const std::string & variant,
bool enable )
1422{
1423 if (enable) {
1424 if (get_variant(vendor, model, variant)) { return; }
1425 m_vendors[vendor][model].insert(variant);
1426 } else {
1427 auto it_v = m_vendors.find(vendor);
1428 if (it_v == m_vendors.end()) { return; }
1429 auto it_m = it_v->second.find(model);
1430 if (it_m == it_v->second.end()) { return; }
1431 auto it_var = it_m->second.find(variant);
1432 if (it_var == it_m->second.end()) { return; }
1433 it_m->second.erase(it_var);
1434 }
1435 // If we got here, there was an update
1436 m_dirty = true;
1437}
bool get_variant(const std::string &vendor, const std::string &model, const std::string &variant) const
Definition AppConfig.cpp:1413

References get_variant(), m_dirty, and m_vendors.

Referenced by Slic3r::GUI::PagePrinters::PagePrinters(), Slic3r::GUI::GuideFrame::run(), and anonymous_namespace{OrcaSlicer_profile_validator.cpp}::slice_all_printers().

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

◆ set_vendors() [1/3]

void Slic3r::AppConfig::set_vendors ( const AppConfig & from)
1440{
1441 m_vendors = from.m_vendors;
1442 m_dirty = true;
1443}

References AppConfig(), m_dirty, and m_vendors.

Referenced by Slic3r::GUI::ConfigWizard::priv::apply_config(), Slic3r::PresetBundle::apply_vendor_config(), and Slic3r::GUI::Config::Snapshot::export_vendor_configs().

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

◆ set_vendors() [2/3]

void Slic3r::AppConfig::set_vendors ( const VendorMap & vendors)
inline
255{ m_vendors = vendors; m_dirty = true; }
const VendorMap & vendors() const
Definition AppConfig.hpp:257

References m_dirty, m_vendors, and vendors().

Here is the call graph for this function:

◆ set_vendors() [3/3]

void Slic3r::AppConfig::set_vendors ( VendorMap && vendors)
inline
256{ m_vendors = std::move(vendors); m_dirty = true; }

References m_dirty, m_vendors, and vendors().

Here is the call graph for this function:

◆ should_remind_network_update_later()

bool Slic3r::AppConfig::should_remind_network_update_later ( ) const
1817{
1819}

References get_bool(), and SETTING_NETWORK_PLUGIN_REMIND_LATER.

Here is the call graph for this function:

◆ update_config_dir()

void Slic3r::AppConfig::update_config_dir ( const std::string & dir)
1548{
1549 this->set("recent", "settings_folder", dir);
1550}

References set().

Here is the call graph for this function:

◆ update_last_backup_dir()

void Slic3r::AppConfig::update_last_backup_dir ( const std::string & dir)
1608{
1609 this->set("app", "last_backup_path", dir);
1610 this->save();
1611}
void save()
Definition AppConfig.cpp:1037

References save(), and set().

Here is the call graph for this function:

◆ update_last_output_dir()

void Slic3r::AppConfig::update_last_output_dir ( const std::string & dir,
const bool removable = false )
1590{
1591 this->set("app", ("last_export_path"), dir);
1592}

References set().

Referenced by Slic3r::GUI::Plater::export_gcode(), and Slic3r::GUI::Plater::export_gcode_3mf().

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

◆ update_local_machine()

void Slic3r::AppConfig::update_local_machine ( const BBLocalMachine & machine)
inline
293 {
294 auto it = m_local_machines.find(machine.dev_id);
295 if (it != m_local_machines.end()) {
296 const auto& current = it->second;
297 if (machine != current) {
298 m_local_machines[machine.dev_id] = machine;
299 m_dirty = true;
300 }
301 } else {
302 m_local_machines[machine.dev_id] = machine;
303 m_dirty = true;
304 }
305 }

References Slic3r::BBLocalMachine::dev_id, m_dirty, and m_local_machines.

Referenced by Slic3r::DeviceManager::update_local_machine().

Here is the caller graph for this function:

◆ update_skein_dir()

void Slic3r::AppConfig::update_skein_dir ( const std::string & dir)
1553{
1554 if (is_shapes_dir(dir))
1555 return; // do not save "shapes gallery" directory
1556 this->set("recent", "last_opened_folder", dir);
1557}

References Slic3r::is_shapes_dir(), and set().

Here is the call graph for this function:

◆ vendors()

const VendorMap & Slic3r::AppConfig::vendors ( ) const
inline

◆ version_check_url()

std::string Slic3r::AppConfig::version_check_url ( ) const
1922{
1923 auto from_settings = get("version_check_url");
1924 return from_settings.empty() ? VERSION_CHECK_URL : from_settings;
1925}
static const std::string VERSION_CHECK_URL
Definition AppConfig.cpp:61

References get(), and Slic3r::VERSION_CHECK_URL.

Referenced by Slic3r::PresetUpdater::priv::set_download_prefs().

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

◆ write_config_file()

bool Slic3r::AppConfig::write_config_file ( const std::string & path,
std::string body,
const std::string & checksum_source )
private
1367{
1368 // Everything before this is assembly; only the writes need the other instances kept out.
1369 InstanceLock instance_lock(lock_path());
1370#ifdef WIN32
1371 // WIN32 specific: the final replace is not safe in case of an application crash, there is no atomic "rename file" API
1372 // provided by Windows (sic!). Therefore we save a MD5 checksum to be able to verify file corruption. In addition,
1373 // we save the config file into a backup first before moving it to the final destination.
1374 body += appconfig_md5_hash_line(checksum_source);
1375#endif
1376 // Not flushed to the device: the idle handler saves on the GUI thread after
1377 // any change, and the rename already gives a complete old or new file.
1378 if (const std::error_code ec = write_file_atomically(path, body)) {
1379 BOOST_LOG_TRIVIAL(error) << "Failed to write the configuration " << path << ": " << ec.message() << "; trying again in 10 s";
1380 m_retry_save_at = std::chrono::steady_clock::now() + std::chrono::seconds(10);
1381 return false;
1382 }
1383 m_retry_save_at = {};
1384#ifdef WIN32
1385 // Written after the config, so the backup never holds a state that was not confirmed written.
1386 const std::string backup_path = (boost::format("%1%.bak") % path).str();
1387 if (const std::error_code ec = write_file_atomically(backup_path, body))
1388 BOOST_LOG_TRIVIAL(error) << "Failed to write the backup configuration " << backup_path << ": " << ec.message();
1389#endif
1390 return true;
1391}
std::error_code write_file_atomically(const std::string &path, std::initializer_list< std::string_view > chunks, bool binary)
Definition utils.cpp:796

References lock_path(), m_retry_save_at, and Slic3r::write_file_atomically().

Referenced by save().

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

Member Data Documentation

◆ m_dirty

◆ m_filament_color_types

std::vector<std::string> Slic3r::AppConfig::m_filament_color_types
private

Referenced by load(), and save().

◆ m_filament_colors

std::vector<std::string> Slic3r::AppConfig::m_filament_colors
private

◆ m_filament_multi_colors

std::vector<std::string> Slic3r::AppConfig::m_filament_multi_colors
private

Referenced by load(), and save().

◆ m_filament_presets

std::vector<std::string> Slic3r::AppConfig::m_filament_presets
private

◆ m_legacy_datadir

bool Slic3r::AppConfig::m_legacy_datadir
private

◆ m_loading_path

std::string Slic3r::AppConfig::m_loading_path
private

Referenced by loading_path(), and set_loading_path().

◆ m_local_machines

std::map<std::string, BBLocalMachine> Slic3r::AppConfig::m_local_machines
private

◆ m_mode

EAppMode Slic3r::AppConfig::m_mode { EAppMode::Editor }
private

◆ m_orig_version

Semver Slic3r::AppConfig::m_orig_version
private

Referenced by AppConfig(), load(), and orig_version().

◆ m_printer_cali_infos

std::vector<PrinterCaliInfo> Slic3r::AppConfig::m_printer_cali_infos
private

◆ m_printer_settings

◆ m_retry_save_at

std::chrono::steady_clock::time_point Slic3r::AppConfig::m_retry_save_at {}
private
475{};

Referenced by save_due(), and write_config_file().

◆ m_storage

◆ m_vendors

VendorMap Slic3r::AppConfig::m_vendors
private

◆ SECTION_EMBOSS_STYLE

◆ SECTION_FILAMENTS

◆ SECTION_MATERIALS


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/AppConfig.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/AppConfig.cpp