Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuSanka <yusanka@gmail.com>2020-08-11 17:12:00 +0300
committerYuSanka <yusanka@gmail.com>2020-08-11 17:12:00 +0300
commita71ef4dd613ca6bc430e424c26df8fc7a65db9f5 (patch)
treecf967daf35ead9a28f7e6c5f096a38f4bcc62ce9 /src/slic3r
parentcb407e46e5d833d5e286d4e7e2f092fb3f19e6ec (diff)
parenta6a5025a7600be41c305567ed16acfdf703194e4 (diff)
Merge remote-tracking branch 'origin/master' into ys_unsaved_changes
Diffstat (limited to 'src/slic3r')
-rw-r--r--src/slic3r/CMakeLists.txt2
-rw-r--r--src/slic3r/Config/Snapshot.cpp1
-rw-r--r--src/slic3r/GUI/3DScene.cpp2
-rw-r--r--src/slic3r/GUI/AppConfig.cpp397
-rw-r--r--src/slic3r/GUI/AppConfig.hpp191
-rw-r--r--src/slic3r/GUI/Camera.cpp2
-rw-r--r--src/slic3r/GUI/ConfigWizard_private.hpp1
-rw-r--r--src/slic3r/GUI/GUI_App.cpp9
-rw-r--r--src/slic3r/GUI/Jobs/SLAImportJob.cpp1
-rw-r--r--src/slic3r/GUI/MainFrame.cpp1
-rw-r--r--src/slic3r/GUI/Mouse3DController.cpp1
-rw-r--r--src/slic3r/GUI/Preferences.cpp2
-rw-r--r--src/slic3r/GUI/PresetComboBoxes.cpp7
-rw-r--r--src/slic3r/GUI/PrintHostDialogs.cpp2
14 files changed, 15 insertions, 604 deletions
diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt
index 28a191419..bc122d6e1 100644
--- a/src/slic3r/CMakeLists.txt
+++ b/src/slic3r/CMakeLists.txt
@@ -12,8 +12,6 @@ set(SLIC3R_GUI_SOURCES
GUI/SysInfoDialog.hpp
GUI/KBShortcutsDialog.cpp
GUI/KBShortcutsDialog.hpp
- GUI/AppConfig.cpp
- GUI/AppConfig.hpp
GUI/BackgroundSlicingProcess.cpp
GUI/BackgroundSlicingProcess.hpp
GUI/BitmapCache.cpp
diff --git a/src/slic3r/Config/Snapshot.cpp b/src/slic3r/Config/Snapshot.cpp
index f7d313418..30596b614 100644
--- a/src/slic3r/Config/Snapshot.cpp
+++ b/src/slic3r/Config/Snapshot.cpp
@@ -1,5 +1,4 @@
#include "Snapshot.hpp"
-#include "../GUI/AppConfig.hpp"
#include <time.h>
diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp
index 5dc0d430f..d683fd90c 100644
--- a/src/slic3r/GUI/3DScene.cpp
+++ b/src/slic3r/GUI/3DScene.cpp
@@ -10,7 +10,6 @@
#if ENABLE_ENVIRONMENT_MAP
#include "GUI_App.hpp"
#include "Plater.hpp"
-#include "AppConfig.hpp"
#endif // ENABLE_ENVIRONMENT_MAP
#include "libslic3r/ExtrusionEntity.hpp"
@@ -24,6 +23,7 @@
#include "slic3r/GUI/BitmapCache.hpp"
#include "libslic3r/Format/STL.hpp"
#include "libslic3r/Utils.hpp"
+#include "libslic3r/AppConfig.hpp"
#include <stdio.h>
#include <stdlib.h>
diff --git a/src/slic3r/GUI/AppConfig.cpp b/src/slic3r/GUI/AppConfig.cpp
deleted file mode 100644
index 93589e536..000000000
--- a/src/slic3r/GUI/AppConfig.cpp
+++ /dev/null
@@ -1,397 +0,0 @@
-#include "libslic3r/libslic3r.h"
-#include "libslic3r/Utils.hpp"
-#include "AppConfig.hpp"
-
-#include <utility>
-#include <vector>
-#include <stdexcept>
-
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/nowide/cenv.hpp>
-#include <boost/nowide/fstream.hpp>
-#include <boost/property_tree/ini_parser.hpp>
-#include <boost/property_tree/ptree_fwd.hpp>
-#include <boost/algorithm/string/predicate.hpp>
-#include <boost/format/format_fwd.hpp>
-
-#include <wx/string.h>
-#include "I18N.hpp"
-
-namespace Slic3r {
-
-static const std::string VENDOR_PREFIX = "vendor:";
-static const std::string MODEL_PREFIX = "model:";
-static const std::string VERSION_CHECK_URL = "https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/PrusaSlicer.version";
-
-const std::string AppConfig::SECTION_FILAMENTS = "filaments";
-const std::string AppConfig::SECTION_MATERIALS = "sla_materials";
-
-void AppConfig::reset()
-{
- m_storage.clear();
- set_defaults();
-};
-
-// Override missing or keys with their defaults.
-void AppConfig::set_defaults()
-{
- // Reset the empty fields to defaults.
- if (get("autocenter").empty())
- set("autocenter", "0");
- // Disable background processing by default as it is not stable.
- if (get("background_processing").empty())
- set("background_processing", "0");
- // If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.
- // By default, Prusa has the controller hidden.
- if (get("no_controller").empty())
- set("no_controller", "1");
- // If set, the "- default -" selections of print/filament/printer are suppressed, if there is a valid preset available.
- if (get("no_defaults").empty())
- set("no_defaults", "1");
- if (get("show_incompatible_presets").empty())
- set("show_incompatible_presets", "0");
-
- if (get("version_check").empty())
- set("version_check", "1");
- if (get("preset_update").empty())
- set("preset_update", "1");
-
- if (get("export_sources_full_pathnames").empty())
- set("export_sources_full_pathnames", "0");
-
- // remove old 'use_legacy_opengl' parameter from this config, if present
- if (!get("use_legacy_opengl").empty())
- erase("", "use_legacy_opengl");
-
-#ifdef __APPLE__
- if (get("use_retina_opengl").empty())
- set("use_retina_opengl", "1");
-#endif
-
- if (get("single_instance").empty())
- set("single_instance", "0");
-
- if (get("remember_output_path").empty())
- set("remember_output_path", "1");
-
- if (get("remember_output_path_removable").empty())
- set("remember_output_path_removable", "1");
-
- if (get("use_custom_toolbar_size").empty())
- set("use_custom_toolbar_size", "0");
-
- if (get("custom_toolbar_size").empty())
- set("custom_toolbar_size", "100");
-
- if (get("auto_toolbar_size").empty())
- set("auto_toolbar_size", "100");
-
- if (get("use_perspective_camera").empty())
- set("use_perspective_camera", "1");
-
- if (get("use_free_camera").empty())
- set("use_free_camera", "0");
-
-#if ENABLE_ENVIRONMENT_MAP
- if (get("use_environment_map").empty())
- set("use_environment_map", "0");
-#endif // ENABLE_ENVIRONMENT_MAP
-
- if (get("use_inches").empty())
- set("use_inches", "0");
-
- // Remove legacy window positions/sizes
- erase("", "main_frame_maximized");
- erase("", "main_frame_pos");
- erase("", "main_frame_size");
- erase("", "object_settings_maximized");
- erase("", "object_settings_pos");
- erase("", "object_settings_size");
-}
-
-void AppConfig::load()
-{
- // 1) Read the complete config file into a boost::property_tree.
- namespace pt = boost::property_tree;
- pt::ptree tree;
- boost::nowide::ifstream ifs(AppConfig::config_path());
- try {
- pt::read_ini(ifs, tree);
- } catch (pt::ptree_error& ex) {
- // Error while parsing config file. We'll customize the error message and rethrow to be displayed.
- throw std::runtime_error(
- _utf8(L("Error parsing PrusaSlicer config file, it is probably corrupted. "
- "Try to manually delete the file to recover from the error. Your user profiles will not be affected.")) +
- "\n\n" + AppConfig::config_path() + "\n\n" + ex.what());
- }
-
- // 2) Parse the property_tree, extract the sections and key / value pairs.
- for (const auto &section : tree) {
- if (section.second.empty()) {
- // This may be a top level (no section) entry, or an empty section.
- std::string data = section.second.data();
- if (! data.empty())
- // If there is a non-empty data, then it must be a top-level (without a section) config entry.
- m_storage[""][section.first] = data;
- } else if (boost::starts_with(section.first, VENDOR_PREFIX)) {
- // This is a vendor section listing enabled model / variants
- const auto vendor_name = section.first.substr(VENDOR_PREFIX.size());
- auto &vendor = m_vendors[vendor_name];
- for (const auto &kvp : section.second) {
- if (! boost::starts_with(kvp.first, MODEL_PREFIX)) { continue; }
- const auto model_name = kvp.first.substr(MODEL_PREFIX.size());
- std::vector<std::string> variants;
- if (! unescape_strings_cstyle(kvp.second.data(), variants)) { continue; }
- for (const auto &variant : variants) {
- vendor[model_name].insert(variant);
- }
- }
- } else {
- // This must be a section name. Read the entries of a section.
- std::map<std::string, std::string> &storage = m_storage[section.first];
- for (auto &kvp : section.second)
- storage[kvp.first] = kvp.second.data();
- }
- }
-
- // Figure out if datadir has legacy presets
- auto ini_ver = Semver::parse(get("version"));
- m_legacy_datadir = false;
- if (ini_ver) {
- m_orig_version = *ini_ver;
- // Make 1.40.0 alphas compare well
- ini_ver->set_metadata(boost::none);
- ini_ver->set_prerelease(boost::none);
- m_legacy_datadir = ini_ver < Semver(1, 40, 0);
- }
-
- // Override missing or keys with their defaults.
- this->set_defaults();
- m_dirty = false;
-}
-
-void AppConfig::save()
-{
- // The config is first written to a file with a PID suffix and then moved
- // to avoid race conditions with multiple instances of Slic3r
- const auto path = config_path();
- std::string path_pid = (boost::format("%1%.%2%") % path % get_current_pid()).str();
-
- boost::nowide::ofstream c;
- c.open(path_pid, std::ios::out | std::ios::trunc);
- c << "# " << Slic3r::header_slic3r_generated() << std::endl;
- // Make sure the "no" category is written first.
- for (const std::pair<std::string, std::string> &kvp : m_storage[""])
- c << kvp.first << " = " << kvp.second << std::endl;
- // Write the other categories.
- for (const auto category : m_storage) {
- if (category.first.empty())
- continue;
- c << std::endl << "[" << category.first << "]" << std::endl;
- for (const std::pair<std::string, std::string> &kvp : category.second)
- c << kvp.first << " = " << kvp.second << std::endl;
- }
- // Write vendor sections
- for (const auto &vendor : m_vendors) {
- size_t size_sum = 0;
- for (const auto &model : vendor.second) { size_sum += model.second.size(); }
- if (size_sum == 0) { continue; }
-
- c << std::endl << "[" << VENDOR_PREFIX << vendor.first << "]" << std::endl;
-
- for (const auto &model : vendor.second) {
- if (model.second.size() == 0) { continue; }
- const std::vector<std::string> variants(model.second.begin(), model.second.end());
- const auto escaped = escape_strings_cstyle(variants);
- c << MODEL_PREFIX << model.first << " = " << escaped << std::endl;
- }
- }
- c.close();
-
- rename_file(path_pid, path);
- m_dirty = false;
-}
-
-bool AppConfig::get_variant(const std::string &vendor, const std::string &model, const std::string &variant) const
-{
- const auto it_v = m_vendors.find(vendor);
- if (it_v == m_vendors.end()) { return false; }
- const auto it_m = it_v->second.find(model);
- return it_m == it_v->second.end() ? false : it_m->second.find(variant) != it_m->second.end();
-}
-
-void AppConfig::set_variant(const std::string &vendor, const std::string &model, const std::string &variant, bool enable)
-{
- if (enable) {
- if (get_variant(vendor, model, variant)) { return; }
- m_vendors[vendor][model].insert(variant);
- } else {
- auto it_v = m_vendors.find(vendor);
- if (it_v == m_vendors.end()) { return; }
- auto it_m = it_v->second.find(model);
- if (it_m == it_v->second.end()) { return; }
- auto it_var = it_m->second.find(variant);
- if (it_var == it_m->second.end()) { return; }
- it_m->second.erase(it_var);
- }
- // If we got here, there was an update
- m_dirty = true;
-}
-
-void AppConfig::set_vendors(const AppConfig &from)
-{
- m_vendors = from.m_vendors;
- m_dirty = true;
-}
-
-std::string AppConfig::get_last_dir() const
-{
- const auto it = m_storage.find("recent");
- if (it != m_storage.end()) {
- {
- const auto it2 = it->second.find("skein_directory");
- if (it2 != it->second.end() && ! it2->second.empty())
- return it2->second;
- }
- {
- const auto it2 = it->second.find("config_directory");
- if (it2 != it->second.end() && ! it2->second.empty())
- return it2->second;
- }
- }
- return std::string();
-}
-
-std::vector<std::string> AppConfig::get_recent_projects() const
-{
- std::vector<std::string> ret;
- const auto it = m_storage.find("recent_projects");
- if (it != m_storage.end())
- {
- for (const std::map<std::string, std::string>::value_type& item : it->second)
- {
- ret.push_back(item.second);
- }
- }
- return ret;
-}
-
-void AppConfig::set_recent_projects(const std::vector<std::string>& recent_projects)
-{
- auto it = m_storage.find("recent_projects");
- if (it == m_storage.end())
- 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;
-
- it->second.clear();
- for (unsigned int i = 0; i < (unsigned int)recent_projects.size(); ++i)
- {
- it->second[std::to_string(i + 1)] = recent_projects[i];
- }
-}
-
-void 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)
-{
- std::string key = std::string("mouse_device:") + name;
- auto it = m_storage.find(key);
- if (it == m_storage.end())
- it = m_storage.insert(std::map<std::string, std::map<std::string, std::string>>::value_type(key, std::map<std::string, std::string>())).first;
-
- it->second.clear();
- it->second["translation_speed"] = std::to_string(translation_speed);
- it->second["translation_deadzone"] = std::to_string(translation_deadzone);
- it->second["rotation_speed"] = std::to_string(rotation_speed);
- it->second["rotation_deadzone"] = std::to_string(rotation_deadzone);
- it->second["zoom_speed"] = std::to_string(zoom_speed);
- it->second["swap_yz"] = swap_yz ? "1" : "0";
-}
-
-std::vector<std::string> AppConfig::get_mouse_device_names() const
-{
- static constexpr const char *prefix = "mouse_device:";
- static const size_t prefix_len = strlen(prefix);
- std::vector<std::string> out;
- for (const std::pair<std::string, std::map<std::string, std::string>>& key_value_pair : m_storage)
- if (boost::starts_with(key_value_pair.first, prefix) && key_value_pair.first.size() > prefix_len)
- out.emplace_back(key_value_pair.first.substr(prefix_len));
- return out;
-}
-
-void AppConfig::update_config_dir(const std::string &dir)
-{
- this->set("recent", "config_directory", dir);
-}
-
-void AppConfig::update_skein_dir(const std::string &dir)
-{
- this->set("recent", "skein_directory", dir);
-}
-/*
-std::string AppConfig::get_last_output_dir(const std::string &alt) const
-{
-
- const auto it = m_storage.find("");
- if (it != m_storage.end()) {
- const auto it2 = it->second.find("last_output_path");
- const auto it3 = it->second.find("remember_output_path");
- if (it2 != it->second.end() && it3 != it->second.end() && ! it2->second.empty() && it3->second == "1")
- return it2->second;
- }
- return alt;
-}
-
-void AppConfig::update_last_output_dir(const std::string &dir)
-{
- this->set("", "last_output_path", dir);
-}
-*/
-std::string AppConfig::get_last_output_dir(const std::string& alt, const bool removable) const
-{
- std::string s1 = (removable ? "last_output_path_removable" : "last_output_path");
- std::string s2 = (removable ? "remember_output_path_removable" : "remember_output_path");
- const auto it = m_storage.find("");
- if (it != m_storage.end()) {
- const auto it2 = it->second.find(s1);
- const auto it3 = it->second.find(s2);
- if (it2 != it->second.end() && it3 != it->second.end() && !it2->second.empty() && it3->second == "1")
- return it2->second;
- }
- return alt;
-}
-
-void AppConfig::update_last_output_dir(const std::string& dir, const bool removable)
-{
- this->set("", (removable ? "last_output_path_removable" : "last_output_path"), dir);
-}
-
-
-void AppConfig::reset_selections()
-{
- auto it = m_storage.find("presets");
- if (it != m_storage.end()) {
- it->second.erase("print");
- it->second.erase("filament");
- it->second.erase("sla_print");
- it->second.erase("sla_material");
- it->second.erase("printer");
- m_dirty = true;
- }
-}
-
-std::string AppConfig::config_path()
-{
- return (boost::filesystem::path(Slic3r::data_dir()) / (SLIC3R_APP_KEY ".ini")).make_preferred().string();
-}
-
-std::string AppConfig::version_check_url() const
-{
- auto from_settings = get("version_check_url");
- return from_settings.empty() ? VERSION_CHECK_URL : from_settings;
-}
-
-bool AppConfig::exists()
-{
- return boost::filesystem::exists(AppConfig::config_path());
-}
-
-}; // namespace Slic3r
diff --git a/src/slic3r/GUI/AppConfig.hpp b/src/slic3r/GUI/AppConfig.hpp
deleted file mode 100644
index 1e90d32e0..000000000
--- a/src/slic3r/GUI/AppConfig.hpp
+++ /dev/null
@@ -1,191 +0,0 @@
-#ifndef slic3r_AppConfig_hpp_
-#define slic3r_AppConfig_hpp_
-
-#include <set>
-#include <map>
-#include <string>
-
-#include <boost/algorithm/string/trim_all.hpp>
-
-#include "libslic3r/Config.hpp"
-#include "libslic3r/Semver.hpp"
-
-namespace Slic3r {
-
-class AppConfig
-{
-public:
- AppConfig() :
- m_dirty(false),
- m_orig_version(Semver::invalid()),
- m_legacy_datadir(false)
- {
- this->reset();
- }
-
- // Clear and reset to defaults.
- void reset();
- // Override missing or keys with their defaults.
- void set_defaults();
-
- // Load the slic3r.ini from a user profile directory (or a datadir, if configured).
- void load();
- // Store the slic3r.ini into a user profile directory (or a datadir, if configured).
- void save();
-
- // Does this config need to be saved?
- bool dirty() const { return m_dirty; }
-
- // Const accessor, it will return false if a section or a key does not exist.
- bool get(const std::string &section, const std::string &key, std::string &value) const
- {
- value.clear();
- auto it = m_storage.find(section);
- if (it == m_storage.end())
- return false;
- auto it2 = it->second.find(key);
- if (it2 == it->second.end())
- return false;
- value = it2->second;
- return true;
- }
- std::string get(const std::string &section, const std::string &key) const
- { std::string value; this->get(section, key, value); return value; }
- std::string get(const std::string &key) const
- { std::string value; this->get("", key, value); return value; }
- void set(const std::string &section, const std::string &key, const std::string &value)
- {
-#ifndef _NDEBUG
- std::string key_trimmed = key;
- boost::trim_all(key_trimmed);
- assert(key_trimmed == key);
- assert(! key_trimmed.empty());
-#endif // _NDEBUG
- std::string &old = m_storage[section][key];
- if (old != value) {
- old = value;
- m_dirty = true;
- }
- }
- void set(const std::string &key, const std::string &value)
- { this->set("", key, value); }
- bool has(const std::string &section, const std::string &key) const
- {
- auto it = m_storage.find(section);
- if (it == m_storage.end())
- return false;
- auto it2 = it->second.find(key);
- return it2 != it->second.end() && ! it2->second.empty();
- }
- bool has(const std::string &key) const
- { return this->has("", key); }
-
- void erase(const std::string &section, const std::string &key)
- {
- auto it = m_storage.find(section);
- if (it != m_storage.end()) {
- it->second.erase(key);
- }
- }
-
- bool has_section(const std::string &section) const
- { return m_storage.find(section) != m_storage.end(); }
- const std::map<std::string, std::string>& get_section(const std::string &section) const
- { return m_storage.find(section)->second; }
- void set_section(const std::string &section, const std::map<std::string, std::string>& data)
- { m_storage[section] = data; }
- void clear_section(const std::string &section)
- { m_storage[section].clear(); }
-
- typedef std::map<std::string, std::map<std::string, std::set<std::string>>> VendorMap;
- 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) { m_vendors = vendors; m_dirty = true; }
- void set_vendors(VendorMap &&vendors) { m_vendors = std::move(vendors); m_dirty = true; }
- const VendorMap& vendors() const { return m_vendors; }
-
- // return recent/skein_directory or recent/config_directory or empty string.
- 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;
- //void update_last_output_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);
-
- // reset the current print / filament / printer selections, so that
- // the PresetBundle::load_selections(const AppConfig &config) call will select
- // the first non-default preset when called.
- void reset_selections();
-
- // Get the default config path from Slic3r::data_dir().
- static std::string config_path();
-
- // Returns true if the user's data directory comes from before Slic3r 1.40.0 (no updating)
- bool legacy_datadir() const { return m_legacy_datadir; }
- void set_legacy_datadir(bool value) { m_legacy_datadir = value; }
-
- // Get the Slic3r version check url.
- // This returns a hardcoded string unless it is overriden by "version_check_url" in the ini file.
- std::string version_check_url() const;
-
- // Returns the original Slic3r version found in the ini file before it was overwritten
- // by the current version
- Semver orig_version() const { return m_orig_version; }
-
- // Does the config file exist?
- static bool exists();
-
- 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);
- std::vector<std::string> get_mouse_device_names() const;
- bool get_mouse_device_translation_speed(const std::string& name, double& speed) const
- { return get_3dmouse_device_numeric_value(name, "translation_speed", speed); }
- bool get_mouse_device_translation_deadzone(const std::string& name, double& deadzone) const
- { return get_3dmouse_device_numeric_value(name, "translation_deadzone", deadzone); }
- bool get_mouse_device_rotation_speed(const std::string& name, float& speed) const
- { return get_3dmouse_device_numeric_value(name, "rotation_speed", speed); }
- bool get_mouse_device_rotation_deadzone(const std::string& name, float& deadzone) const
- { return get_3dmouse_device_numeric_value(name, "rotation_deadzone", deadzone); }
- bool get_mouse_device_zoom_speed(const std::string& name, double& speed) const
- { return get_3dmouse_device_numeric_value(name, "zoom_speed", speed); }
- bool get_mouse_device_swap_yz(const std::string& name, bool& swap) const
- { return get_3dmouse_device_numeric_value(name, "swap_yz", swap); }
-
- static const std::string SECTION_FILAMENTS;
- static const std::string SECTION_MATERIALS;
-
-private:
- template<typename T>
- bool get_3dmouse_device_numeric_value(const std::string &device_name, const char *parameter_name, T &out) const
- {
- std::string key = std::string("mouse_device:") + device_name;
- auto it = m_storage.find(key);
- if (it == m_storage.end())
- return false;
- auto it_val = it->second.find(parameter_name);
- if (it_val == it->second.end())
- return false;
- out = T(::atof(it_val->second.c_str()));
- return true;
- }
-
- // Map of section, name -> value
- std::map<std::string, std::map<std::string, std::string>> m_storage;
- // Map of enabled vendors / models / variants
- VendorMap m_vendors;
- // Has any value been modified since the config.ini has been last saved or loaded?
- bool m_dirty;
- // Original version found in the ini file before it was overwritten
- Semver m_orig_version;
- // Whether the existing version is before system profiles & configuration updating
- bool m_legacy_datadir;
-};
-
-}; // namespace Slic3r
-
-#endif /* slic3r_AppConfig_hpp_ */
diff --git a/src/slic3r/GUI/Camera.cpp b/src/slic3r/GUI/Camera.cpp
index ac32767c4..c1bf8e825 100644
--- a/src/slic3r/GUI/Camera.cpp
+++ b/src/slic3r/GUI/Camera.cpp
@@ -1,8 +1,8 @@
#include "libslic3r/libslic3r.h"
+#include "libslic3r/AppConfig.hpp"
#include "Camera.hpp"
#include "GUI_App.hpp"
-#include "AppConfig.hpp"
#if ENABLE_CAMERA_STATISTICS
#include "Mouse3DController.hpp"
#endif // ENABLE_CAMERA_STATISTICS
diff --git a/src/slic3r/GUI/ConfigWizard_private.hpp b/src/slic3r/GUI/ConfigWizard_private.hpp
index be2919861..9921552a7 100644
--- a/src/slic3r/GUI/ConfigWizard_private.hpp
+++ b/src/slic3r/GUI/ConfigWizard_private.hpp
@@ -22,7 +22,6 @@
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/PresetBundle.hpp"
#include "slic3r/Utils/PresetUpdater.hpp"
-#include "AppConfig.hpp"
#include "BedShapeDialog.hpp"
#include "GUI.hpp"
#include "wxExtensions.hpp"
diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp
index 38bda5f5e..82c2861bc 100644
--- a/src/slic3r/GUI/GUI_App.cpp
+++ b/src/slic3r/GUI/GUI_App.cpp
@@ -38,7 +38,6 @@
#include "GUI.hpp"
#include "GUI_Utils.hpp"
-#include "AppConfig.hpp"
#include "3DScene.hpp"
#include "MainFrame.hpp"
#include "Plater.hpp"
@@ -326,7 +325,13 @@ void GUI_App::init_app_config()
// load settings
app_conf_exists = app_config->exists();
if (app_conf_exists) {
- app_config->load();
+ std::string error = app_config->load();
+ if (!error.empty())
+ // Error while parsing config file. We'll customize the error message and rethrow to be displayed.
+ throw std::runtime_error(
+ _u8L("Error parsing PrusaSlicer config file, it is probably corrupted. "
+ "Try to manually delete the file to recover from the error. Your user profiles will not be affected.") +
+ "\n\n" + AppConfig::config_path() + "\n\n" + error);
}
}
diff --git a/src/slic3r/GUI/Jobs/SLAImportJob.cpp b/src/slic3r/GUI/Jobs/SLAImportJob.cpp
index cc779df2a..2d5d5b072 100644
--- a/src/slic3r/GUI/Jobs/SLAImportJob.cpp
+++ b/src/slic3r/GUI/Jobs/SLAImportJob.cpp
@@ -2,7 +2,6 @@
#include "slic3r/GUI/GUI.hpp"
#include "slic3r/GUI/GUI_App.hpp"
-#include "slic3r/GUI/AppConfig.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/GUI_ObjectList.hpp"
#include "slic3r/Utils/SLAImport.hpp"
diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp
index 084280300..bbc1da534 100644
--- a/src/slic3r/GUI/MainFrame.cpp
+++ b/src/slic3r/GUI/MainFrame.cpp
@@ -20,7 +20,6 @@
#include "Tab.hpp"
#include "ProgressStatusBar.hpp"
#include "3DScene.hpp"
-#include "AppConfig.hpp"
#include "PrintHostDialogs.hpp"
#include "wxExtensions.hpp"
#include "GUI_ObjectList.hpp"
diff --git a/src/slic3r/GUI/Mouse3DController.cpp b/src/slic3r/GUI/Mouse3DController.cpp
index 9bbbf92a0..4c5ee2076 100644
--- a/src/slic3r/GUI/Mouse3DController.cpp
+++ b/src/slic3r/GUI/Mouse3DController.cpp
@@ -4,7 +4,6 @@
#include "Camera.hpp"
#include "GUI_App.hpp"
-#include "AppConfig.hpp"
#include "GLCanvas3D.hpp"
#include "Plater.hpp"
#include "NotificationManager.hpp"
diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp
index 4b5808e16..242c3d851 100644
--- a/src/slic3r/GUI/Preferences.cpp
+++ b/src/slic3r/GUI/Preferences.cpp
@@ -1,8 +1,8 @@
#include "Preferences.hpp"
-#include "AppConfig.hpp"
#include "OptionsGroup.hpp"
#include "GUI_App.hpp"
#include "I18N.hpp"
+#include "libslic3r/AppConfig.hpp"
namespace Slic3r {
namespace GUI {
diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp
index 33ae4f54e..7539f3616 100644
--- a/src/slic3r/GUI/PresetComboBoxes.cpp
+++ b/src/slic3r/GUI/PresetComboBoxes.cpp
@@ -517,7 +517,7 @@ PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset
const Preset* selected_preset = m_collection->find_preset(m_preset_bundle->filament_presets[m_extruder_idx]);
// Wide icons are shown if the currently selected preset is not compatible with the current printer,
// and red flag is drown in front of the selected preset.
- bool wide_icons = selected_preset != nullptr && !selected_preset->is_compatible;
+ bool wide_icons = selected_preset && !selected_preset->is_compatible;
float scale = m_em_unit*0.1f;
int shifl_Left = wide_icons ? int(scale * 16 + 0.5) : 0;
@@ -707,10 +707,11 @@ void PlaterPresetComboBox::update()
assert(selected_filament_preset);
}
- const Preset& selected_preset = m_type == Preset::TYPE_FILAMENT ? *selected_filament_preset : m_collection->get_selected_preset();
+ bool has_selection = m_collection->get_selected_idx() != size_t(-1);
+ const Preset* selected_preset = m_type == Preset::TYPE_FILAMENT ? selected_filament_preset : has_selection ? &m_collection->get_selected_preset() : nullptr;
// Show wide icons if the currently selected preset is not compatible with the current printer,
// and draw a red flag in front of the selected preset.
- bool wide_icons = !selected_preset.is_compatible;
+ bool wide_icons = selected_preset && !selected_preset->is_compatible;
std::map<wxString, wxBitmap*> nonsys_presets;
diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp
index bae60e47f..216af5df4 100644
--- a/src/slic3r/GUI/PrintHostDialogs.cpp
+++ b/src/slic3r/GUI/PrintHostDialogs.cpp
@@ -15,11 +15,11 @@
#include "GUI.hpp"
#include "GUI_App.hpp"
-#include "AppConfig.hpp"
#include "MsgDialog.hpp"
#include "I18N.hpp"
#include "../Utils/PrintHost.hpp"
#include "wxExtensions.hpp"
+#include "libslic3r/AppConfig.hpp"
namespace fs = boost::filesystem;