Code refactoring: AppConfig.cpp(hpp) are removed from the GUI to libslic3r
This commit is contained in:
parent
afcc14861f
commit
f9e47b2702
@ -44,6 +44,7 @@
|
|||||||
#include "libslic3r/Format/OBJ.hpp"
|
#include "libslic3r/Format/OBJ.hpp"
|
||||||
#include "libslic3r/Format/SL1.hpp"
|
#include "libslic3r/Format/SL1.hpp"
|
||||||
#include "libslic3r/Utils.hpp"
|
#include "libslic3r/Utils.hpp"
|
||||||
|
#include "libslic3r/AppConfig.hpp"
|
||||||
|
|
||||||
#include "PrusaSlicer.hpp"
|
#include "PrusaSlicer.hpp"
|
||||||
|
|
||||||
@ -52,7 +53,6 @@
|
|||||||
#include "slic3r/GUI/GUI_App.hpp"
|
#include "slic3r/GUI/GUI_App.hpp"
|
||||||
#include "slic3r/GUI/3DScene.hpp"
|
#include "slic3r/GUI/3DScene.hpp"
|
||||||
#include "slic3r/GUI/InstanceCheck.hpp"
|
#include "slic3r/GUI/InstanceCheck.hpp"
|
||||||
#include "slic3r/GUI/AppConfig.hpp"
|
|
||||||
#include "slic3r/GUI/MainFrame.hpp"
|
#include "slic3r/GUI/MainFrame.hpp"
|
||||||
#include "slic3r/GUI/Plater.hpp"
|
#include "slic3r/GUI/Plater.hpp"
|
||||||
#endif /* SLIC3R_GUI */
|
#endif /* SLIC3R_GUI */
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
#include <boost/format/format_fwd.hpp>
|
#include <boost/format/format_fwd.hpp>
|
||||||
|
|
||||||
#include <wx/string.h>
|
//#include <wx/string.h>
|
||||||
#include "I18N.hpp"
|
//#include "I18N.hpp"
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ void AppConfig::set_defaults()
|
|||||||
erase("", "object_settings_size");
|
erase("", "object_settings_size");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppConfig::load()
|
std::string AppConfig::load()
|
||||||
{
|
{
|
||||||
// 1) Read the complete config file into a boost::property_tree.
|
// 1) Read the complete config file into a boost::property_tree.
|
||||||
namespace pt = boost::property_tree;
|
namespace pt = boost::property_tree;
|
||||||
@ -120,10 +120,15 @@ void AppConfig::load()
|
|||||||
pt::read_ini(ifs, tree);
|
pt::read_ini(ifs, tree);
|
||||||
} catch (pt::ptree_error& ex) {
|
} catch (pt::ptree_error& ex) {
|
||||||
// Error while parsing config file. We'll customize the error message and rethrow to be displayed.
|
// Error while parsing config file. We'll customize the error message and rethrow to be displayed.
|
||||||
|
// ! But to avoid the use of _utf8 (related to use of wxWidgets)
|
||||||
|
// we will rethrow this exception from the place of load() call, if returned value wouldn't be empty
|
||||||
|
/*
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
_utf8(L("Error parsing PrusaSlicer config file, it is probably corrupted. "
|
_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.")) +
|
"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());
|
"\n\n" + AppConfig::config_path() + "\n\n" + ex.what());
|
||||||
|
*/
|
||||||
|
return ex.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2) Parse the property_tree, extract the sections and key / value pairs.
|
// 2) Parse the property_tree, extract the sections and key / value pairs.
|
||||||
@ -169,6 +174,7 @@ void AppConfig::load()
|
|||||||
// Override missing or keys with their defaults.
|
// Override missing or keys with their defaults.
|
||||||
this->set_defaults();
|
this->set_defaults();
|
||||||
m_dirty = false;
|
m_dirty = false;
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppConfig::save()
|
void AppConfig::save()
|
@ -29,7 +29,8 @@ public:
|
|||||||
void set_defaults();
|
void set_defaults();
|
||||||
|
|
||||||
// Load the slic3r.ini from a user profile directory (or a datadir, if configured).
|
// Load the slic3r.ini from a user profile directory (or a datadir, if configured).
|
||||||
void load();
|
// return error string or empty strinf
|
||||||
|
std::string load();
|
||||||
// Store the slic3r.ini into a user profile directory (or a datadir, if configured).
|
// Store the slic3r.ini into a user profile directory (or a datadir, if configured).
|
||||||
void save();
|
void save();
|
||||||
|
|
@ -151,6 +151,8 @@ add_library(libslic3r STATIC
|
|||||||
Preset.hpp
|
Preset.hpp
|
||||||
PresetBundle.cpp
|
PresetBundle.cpp
|
||||||
PresetBundle.hpp
|
PresetBundle.hpp
|
||||||
|
AppConfig.cpp
|
||||||
|
AppConfig.hpp
|
||||||
Print.cpp
|
Print.cpp
|
||||||
Print.hpp
|
Print.hpp
|
||||||
PrintBase.cpp
|
PrintBase.cpp
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "Preset.hpp"
|
#include "Preset.hpp"
|
||||||
#include "slic3r/GUI/AppConfig.hpp"
|
#include "AppConfig.hpp"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
@ -2,13 +2,12 @@
|
|||||||
#define slic3r_PresetBundle_hpp_
|
#define slic3r_PresetBundle_hpp_
|
||||||
|
|
||||||
#include "Preset.hpp"
|
#include "Preset.hpp"
|
||||||
|
#include "AppConfig.hpp"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
#include "slic3r/GUI/AppConfig.hpp"
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
// Bundle of Print + Filament + Printer presets.
|
// Bundle of Print + Filament + Printer presets.
|
||||||
|
@ -12,8 +12,6 @@ set(SLIC3R_GUI_SOURCES
|
|||||||
GUI/SysInfoDialog.hpp
|
GUI/SysInfoDialog.hpp
|
||||||
GUI/KBShortcutsDialog.cpp
|
GUI/KBShortcutsDialog.cpp
|
||||||
GUI/KBShortcutsDialog.hpp
|
GUI/KBShortcutsDialog.hpp
|
||||||
GUI/AppConfig.cpp
|
|
||||||
GUI/AppConfig.hpp
|
|
||||||
GUI/BackgroundSlicingProcess.cpp
|
GUI/BackgroundSlicingProcess.cpp
|
||||||
GUI/BackgroundSlicingProcess.hpp
|
GUI/BackgroundSlicingProcess.hpp
|
||||||
GUI/BitmapCache.cpp
|
GUI/BitmapCache.cpp
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "Snapshot.hpp"
|
#include "Snapshot.hpp"
|
||||||
#include "../GUI/AppConfig.hpp"
|
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#if ENABLE_ENVIRONMENT_MAP
|
#if ENABLE_ENVIRONMENT_MAP
|
||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
#include "Plater.hpp"
|
#include "Plater.hpp"
|
||||||
#include "AppConfig.hpp"
|
|
||||||
#endif // ENABLE_ENVIRONMENT_MAP
|
#endif // ENABLE_ENVIRONMENT_MAP
|
||||||
|
|
||||||
#include "libslic3r/ExtrusionEntity.hpp"
|
#include "libslic3r/ExtrusionEntity.hpp"
|
||||||
@ -24,6 +23,7 @@
|
|||||||
#include "slic3r/GUI/BitmapCache.hpp"
|
#include "slic3r/GUI/BitmapCache.hpp"
|
||||||
#include "libslic3r/Format/STL.hpp"
|
#include "libslic3r/Format/STL.hpp"
|
||||||
#include "libslic3r/Utils.hpp"
|
#include "libslic3r/Utils.hpp"
|
||||||
|
#include "libslic3r/AppConfig.hpp"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "libslic3r/libslic3r.h"
|
#include "libslic3r/libslic3r.h"
|
||||||
|
#include "libslic3r/AppConfig.hpp"
|
||||||
|
|
||||||
#include "Camera.hpp"
|
#include "Camera.hpp"
|
||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
#include "AppConfig.hpp"
|
|
||||||
#if ENABLE_CAMERA_STATISTICS
|
#if ENABLE_CAMERA_STATISTICS
|
||||||
#include "Mouse3DController.hpp"
|
#include "Mouse3DController.hpp"
|
||||||
#endif // ENABLE_CAMERA_STATISTICS
|
#endif // ENABLE_CAMERA_STATISTICS
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include "libslic3r/PrintConfig.hpp"
|
#include "libslic3r/PrintConfig.hpp"
|
||||||
#include "libslic3r/PresetBundle.hpp"
|
#include "libslic3r/PresetBundle.hpp"
|
||||||
#include "slic3r/Utils/PresetUpdater.hpp"
|
#include "slic3r/Utils/PresetUpdater.hpp"
|
||||||
#include "AppConfig.hpp"
|
|
||||||
#include "BedShapeDialog.hpp"
|
#include "BedShapeDialog.hpp"
|
||||||
#include "GUI.hpp"
|
#include "GUI.hpp"
|
||||||
#include "wxExtensions.hpp"
|
#include "wxExtensions.hpp"
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
|
|
||||||
#include "GUI.hpp"
|
#include "GUI.hpp"
|
||||||
#include "GUI_Utils.hpp"
|
#include "GUI_Utils.hpp"
|
||||||
#include "AppConfig.hpp"
|
|
||||||
#include "3DScene.hpp"
|
#include "3DScene.hpp"
|
||||||
#include "MainFrame.hpp"
|
#include "MainFrame.hpp"
|
||||||
#include "Plater.hpp"
|
#include "Plater.hpp"
|
||||||
@ -326,7 +325,13 @@ void GUI_App::init_app_config()
|
|||||||
// load settings
|
// load settings
|
||||||
app_conf_exists = app_config->exists();
|
app_conf_exists = app_config->exists();
|
||||||
if (app_conf_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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "slic3r/GUI/GUI.hpp"
|
#include "slic3r/GUI/GUI.hpp"
|
||||||
#include "slic3r/GUI/GUI_App.hpp"
|
#include "slic3r/GUI/GUI_App.hpp"
|
||||||
#include "slic3r/GUI/AppConfig.hpp"
|
|
||||||
#include "slic3r/GUI/Plater.hpp"
|
#include "slic3r/GUI/Plater.hpp"
|
||||||
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
||||||
#include "slic3r/Utils/SLAImport.hpp"
|
#include "slic3r/Utils/SLAImport.hpp"
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "Tab.hpp"
|
#include "Tab.hpp"
|
||||||
#include "ProgressStatusBar.hpp"
|
#include "ProgressStatusBar.hpp"
|
||||||
#include "3DScene.hpp"
|
#include "3DScene.hpp"
|
||||||
#include "AppConfig.hpp"
|
|
||||||
#include "PrintHostDialogs.hpp"
|
#include "PrintHostDialogs.hpp"
|
||||||
#include "wxExtensions.hpp"
|
#include "wxExtensions.hpp"
|
||||||
#include "GUI_ObjectList.hpp"
|
#include "GUI_ObjectList.hpp"
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include "Camera.hpp"
|
#include "Camera.hpp"
|
||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
#include "AppConfig.hpp"
|
|
||||||
#include "GLCanvas3D.hpp"
|
#include "GLCanvas3D.hpp"
|
||||||
#include "Plater.hpp"
|
#include "Plater.hpp"
|
||||||
#include "NotificationManager.hpp"
|
#include "NotificationManager.hpp"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "Preferences.hpp"
|
#include "Preferences.hpp"
|
||||||
#include "AppConfig.hpp"
|
|
||||||
#include "OptionsGroup.hpp"
|
#include "OptionsGroup.hpp"
|
||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
#include "I18N.hpp"
|
#include "I18N.hpp"
|
||||||
|
#include "libslic3r/AppConfig.hpp"
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
|
|
||||||
#include "GUI.hpp"
|
#include "GUI.hpp"
|
||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
#include "AppConfig.hpp"
|
|
||||||
#include "MsgDialog.hpp"
|
#include "MsgDialog.hpp"
|
||||||
#include "I18N.hpp"
|
#include "I18N.hpp"
|
||||||
#include "../Utils/PrintHost.hpp"
|
#include "../Utils/PrintHost.hpp"
|
||||||
#include "wxExtensions.hpp"
|
#include "wxExtensions.hpp"
|
||||||
|
#include "libslic3r/AppConfig.hpp"
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user