mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 08:41:11 -06:00
Tech ENABLE_GCODE_APP_CONFIG as default
This commit is contained in:
parent
a633979d85
commit
f04d9c1806
11 changed files with 76 additions and 116 deletions
|
@ -37,9 +37,9 @@ void AppConfig::reset()
|
|||
// Override missing or keys with their defaults.
|
||||
void AppConfig::set_defaults()
|
||||
{
|
||||
#if ENABLE_GCODE_APP_CONFIG
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
if (m_mode == EAppMode::Editor) {
|
||||
#endif // ENABLE_GCODE_APP_CONFIG
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
// Reset the empty fields to defaults.
|
||||
if (get("autocenter").empty())
|
||||
set("autocenter", "0");
|
||||
|
@ -91,13 +91,13 @@ void AppConfig::set_defaults()
|
|||
if (get("auto_toolbar_size").empty())
|
||||
set("auto_toolbar_size", "100");
|
||||
|
||||
#if !ENABLE_GCODE_APP_CONFIG
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
if (get("use_perspective_camera").empty())
|
||||
set("use_perspective_camera", "1");
|
||||
|
||||
if (get("use_free_camera").empty())
|
||||
set("use_free_camera", "0");
|
||||
#endif // !ENABLE_GCODE_APP_CONFIG
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
|
||||
#if ENABLE_ENVIRONMENT_MAP
|
||||
if (get("use_environment_map").empty())
|
||||
|
@ -106,7 +106,7 @@ void AppConfig::set_defaults()
|
|||
|
||||
if (get("use_inches").empty())
|
||||
set("use_inches", "0");
|
||||
#if ENABLE_GCODE_APP_CONFIG
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
}
|
||||
|
||||
if (get("use_perspective_camera").empty())
|
||||
|
@ -114,7 +114,7 @@ void AppConfig::set_defaults()
|
|||
|
||||
if (get("use_free_camera").empty())
|
||||
set("use_free_camera", "0");
|
||||
#endif // ENABLE_GCODE_APP_CONFIG
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
if (get("show_splash_screen").empty())
|
||||
set("show_splash_screen", "1");
|
||||
|
@ -197,13 +197,6 @@ std::string AppConfig::load()
|
|||
|
||||
void AppConfig::save()
|
||||
{
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#if !ENABLE_GCODE_APP_CONFIG
|
||||
if (!m_save_enabled)
|
||||
return;
|
||||
#endif // !ENABLE_GCODE_APP_CONFIG
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
// 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();
|
||||
|
@ -211,14 +204,14 @@ void AppConfig::save()
|
|||
|
||||
boost::nowide::ofstream c;
|
||||
c.open(path_pid, std::ios::out | std::ios::trunc);
|
||||
#if ENABLE_GCODE_APP_CONFIG
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
if (m_mode == EAppMode::Editor)
|
||||
c << "# " << Slic3r::header_slic3r_generated() << std::endl;
|
||||
else
|
||||
c << "# " << Slic3r::header_gcodeviewer_generated() << std::endl;
|
||||
#else
|
||||
c << "# " << Slic3r::header_slic3r_generated() << std::endl;
|
||||
#endif // ENABLE_GCODE_APP_CONFIG
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
// 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;
|
||||
|
@ -418,7 +411,7 @@ void AppConfig::reset_selections()
|
|||
|
||||
std::string AppConfig::config_path()
|
||||
{
|
||||
#if ENABLE_GCODE_APP_CONFIG
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
std::string path = (m_mode == EAppMode::Editor) ?
|
||||
(boost::filesystem::path(Slic3r::data_dir()) / (SLIC3R_APP_KEY ".ini")).make_preferred().string() :
|
||||
(boost::filesystem::path(Slic3r::data_dir()) / (GCODEVIEWER_APP_KEY ".ini")).make_preferred().string();
|
||||
|
@ -426,7 +419,7 @@ std::string AppConfig::config_path()
|
|||
return path;
|
||||
#else
|
||||
return (boost::filesystem::path(Slic3r::data_dir()) / (SLIC3R_APP_KEY ".ini")).make_preferred().string();
|
||||
#endif // ENABLE_GCODE_APP_CONFIG
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
}
|
||||
|
||||
std::string AppConfig::version_check_url() const
|
||||
|
@ -437,11 +430,11 @@ std::string AppConfig::version_check_url() const
|
|||
|
||||
bool AppConfig::exists()
|
||||
{
|
||||
#if ENABLE_GCODE_APP_CONFIG
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
return boost::filesystem::exists(config_path());
|
||||
#else
|
||||
return boost::filesystem::exists(AppConfig::config_path());
|
||||
#endif // ENABLE_GCODE_APP_CONFIG
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
}
|
||||
|
||||
}; // namespace Slic3r
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Slic3r {
|
|||
class AppConfig
|
||||
{
|
||||
public:
|
||||
#if ENABLE_GCODE_APP_CONFIG
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
enum class EAppMode : unsigned char
|
||||
{
|
||||
Editor,
|
||||
|
@ -25,15 +25,11 @@ public:
|
|||
explicit AppConfig(EAppMode mode) :
|
||||
#else
|
||||
AppConfig() :
|
||||
#endif // ENABLE_GCODE_APP_CONFIG
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
m_dirty(false),
|
||||
m_orig_version(Semver::invalid()),
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#if ENABLE_GCODE_APP_CONFIG
|
||||
m_mode(mode),
|
||||
#else
|
||||
m_save_enabled(true),
|
||||
#endif // !ENABLE_GCODE_APP_CONFIG
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
m_legacy_datadir(false)
|
||||
{
|
||||
|
@ -139,11 +135,11 @@ public:
|
|||
void reset_selections();
|
||||
|
||||
// Get the default config path from Slic3r::data_dir().
|
||||
#if ENABLE_GCODE_APP_CONFIG
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
std::string config_path();
|
||||
#else
|
||||
static std::string config_path();
|
||||
#endif // ENABLE_GCODE_APP_CONFIG
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
// 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; }
|
||||
|
@ -158,11 +154,11 @@ public:
|
|||
Semver orig_version() const { return m_orig_version; }
|
||||
|
||||
// Does the config file exist?
|
||||
#if ENABLE_GCODE_APP_CONFIG
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
bool exists();
|
||||
#else
|
||||
static bool exists();
|
||||
#endif // ENABLE_GCODE_APP_CONFIG
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
std::vector<std::string> get_recent_projects() const;
|
||||
void set_recent_projects(const std::vector<std::string>& recent_projects);
|
||||
|
@ -182,12 +178,6 @@ public:
|
|||
bool get_mouse_device_swap_yz(const std::string& name, bool& swap) const
|
||||
{ return get_3dmouse_device_numeric_value(name, "swap_yz", swap); }
|
||||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#if !ENABLE_GCODE_APP_CONFIG
|
||||
void enable_save(bool enable) { m_save_enabled = enable; }
|
||||
#endif // !ENABLE_GCODE_APP_CONFIG
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
static const std::string SECTION_FILAMENTS;
|
||||
static const std::string SECTION_MATERIALS;
|
||||
|
||||
|
@ -206,9 +196,9 @@ private:
|
|||
return true;
|
||||
}
|
||||
|
||||
#if ENABLE_GCODE_APP_CONFIG
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
EAppMode m_mode { EAppMode::Editor };
|
||||
#endif // ENABLE_GCODE_APP_CONFIG
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
// Map of section, name -> value
|
||||
std::map<std::string, std::map<std::string, std::string>> m_storage;
|
||||
|
@ -218,12 +208,6 @@ private:
|
|||
bool m_dirty;
|
||||
// Original version found in the ini file before it was overwritten
|
||||
Semver m_orig_version;
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#if !ENABLE_GCODE_APP_CONFIG
|
||||
// Whether or not calls to save() should take effect
|
||||
bool m_save_enabled;
|
||||
#endif // !ENABLE_GCODE_APP_CONFIG
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
// Whether the existing version is before system profiles & configuration updating
|
||||
bool m_legacy_datadir;
|
||||
};
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
#define ENABLE_GCODE_VIEWER (1 && ENABLE_2_3_0_ALPHA1)
|
||||
#define ENABLE_GCODE_VIEWER_STATISTICS (0 && ENABLE_GCODE_VIEWER)
|
||||
#define ENABLE_GCODE_VIEWER_DATA_CHECKING (0 && ENABLE_GCODE_VIEWER)
|
||||
#define ENABLE_GCODE_APP_CONFIG (1 && ENABLE_GCODE_VIEWER)
|
||||
#define ENABLE_GCODE_DRAG_AND_DROP_GCODE_FILES (1 && ENABLE_GCODE_VIEWER)
|
||||
|
||||
#endif // _prusaslicer_technologies_h_
|
||||
|
|
|
@ -107,11 +107,11 @@ std::string string_printf(const char *format, ...);
|
|||
// to be placed at the top of Slic3r generated files.
|
||||
std::string header_slic3r_generated();
|
||||
|
||||
#if ENABLE_GCODE_APP_CONFIG
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
// Standard "generated by PrusaGCodeViewer version xxx timestamp xxx" header string,
|
||||
// to be placed at the top of Slic3r generated files.
|
||||
std::string header_gcodeviewer_generated();
|
||||
#endif // ENABLE_GCODE_APP_CONFIG
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
// getpid platform wrapper
|
||||
extern unsigned get_current_pid();
|
||||
|
|
|
@ -607,12 +607,12 @@ std::string header_slic3r_generated()
|
|||
return std::string("generated by " SLIC3R_APP_NAME " " SLIC3R_VERSION " on " ) + Utils::utc_timestamp();
|
||||
}
|
||||
|
||||
#if ENABLE_GCODE_APP_CONFIG
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
std::string header_gcodeviewer_generated()
|
||||
{
|
||||
return std::string("generated by " GCODEVIEWER_APP_NAME " " SLIC3R_VERSION " on ") + Utils::utc_timestamp();
|
||||
}
|
||||
#endif // ENABLE_GCODE_APP_CONFIG
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
unsigned get_current_pid()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue