mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-14 19:31:14 +00:00
* Stop Leaking json Through Headers and Drop Includes Kept Only for the Name AppConfig.hpp, DeviceManager.hpp and UserManager.hpp carried a global "using namespace nlohmann;", json_diff.hpp a global "using json = nlohmann::json;" and PrinterFileSystem.h a global "using nlohmann::json;". Every file that included one of them, directly or not, could write a bare json, and 63 did without declaring it. The last two also made the include checker treat json_diff.hpp and PrinterFileSystem.h as the headers that provide json, so they were included from files that use nothing else from them: 57 of the 59 includers of json_diff.hpp never name json_diff. The five statements are removed. Headers that use the type now spell nlohmann::json, source files declare their own "using json = nlohmann::json;", and the includes that only supplied the name are dropped or replaced by <nlohmann/json.hpp>. Eight files reached json_diff.hpp only through an include that is now gone and with it lost that header's "using namespace std;". The std names they used unqualified are qualified. * Declare json in OrcaSlicer.cpp on Every Platform OrcaSlicer.cpp had its "using namespace nlohmann;" and the json include inside the Linux-only include block, so on Windows and macOS it took json from AppConfig.hpp's global directive, which is gone. The include and a "using json = nlohmann::json;" now sit outside the block.
69 lines
2.7 KiB
C++
69 lines
2.7 KiB
C++
#include <nlohmann/json.hpp>
|
|
|
|
#include "DevConfig.h"
|
|
#include "DevUtil.h"
|
|
|
|
using namespace nlohmann;
|
|
|
|
namespace Slic3r
|
|
{
|
|
|
|
bool DevConfig::SupportChamberTempDisplay() const
|
|
{
|
|
if (!m_support_chamber_temp_display.has_value()) {
|
|
return m_has_chamber;
|
|
}
|
|
|
|
return m_support_chamber_temp_display.value();
|
|
}
|
|
|
|
void DevConfig::ParseConfig(const json& print_json)
|
|
{
|
|
ParseChamberConfig(print_json);
|
|
ParsePrintOptionsConfig(print_json);
|
|
ParseCalibrationConfig(print_json);
|
|
}
|
|
|
|
void DevConfig::ParseChamberConfig(const json& print_json)
|
|
{
|
|
DevJsonValParser::ParseVal(print_json, "support_chamber", m_has_chamber);
|
|
|
|
if (print_json.contains("support_chamber_temp_display")) {
|
|
m_support_chamber_temp_display = DevJsonValParser::GetVal<bool>(print_json, "support_chamber_temp_display");
|
|
}
|
|
|
|
DevJsonValParser::ParseVal(print_json, "support_chamber_temp_edit", m_support_chamber_edit);
|
|
if (m_support_chamber_edit)
|
|
{
|
|
if (print_json.contains("support_chamber_temp_edit_range"))
|
|
{
|
|
const auto &support_champer_range = print_json["support_chamber_temp_edit_range"];
|
|
if (support_champer_range.is_array() && support_champer_range.size() > 1) {
|
|
m_chamber_temp_edit_min = support_champer_range[0];
|
|
m_chamber_temp_edit_max = support_champer_range[1];
|
|
}
|
|
}
|
|
|
|
DevJsonValParser::ParseVal(print_json, "support_chamber_temp_switch_heating", m_chamber_temp_switch_heat);
|
|
}
|
|
}
|
|
|
|
void DevConfig::ParsePrintOptionsConfig(const json& print_json)
|
|
{
|
|
DevJsonValParser::ParseVal(print_json, "support_first_layer_inspect", m_support_first_layer_inspect);
|
|
DevJsonValParser::ParseVal(print_json, "support_save_remote_print_file_to_storage", m_support_save_remote_print_file_to_storage);
|
|
DevJsonValParser::ParseVal(print_json, "support_ai_monitoring", m_support_ai_monitor);
|
|
DevJsonValParser::ParseVal(print_json, "support_print_without_sd", m_support_print_without_sd);
|
|
DevJsonValParser::ParseVal(print_json, "support_print_all", m_support_print_all);
|
|
}
|
|
|
|
void DevConfig::ParseCalibrationConfig(const json& print_json)
|
|
{
|
|
DevJsonValParser::ParseVal(print_json, "support_lidar_calibration", m_support_calibration_lidar);
|
|
DevJsonValParser::ParseVal(print_json, "support_nozzle_offset_calibration", m_support_calibration_nozzle_offset);
|
|
DevJsonValParser::ParseVal(print_json, "support_high_tempbed_calibration", m_support_calibration_high_temp_bed);
|
|
DevJsonValParser::ParseVal(print_json, "support_auto_flow_calibration", m_support_calibration_pa_flow_auto);
|
|
DevJsonValParser::ParseVal(print_json, "support_clump_position_calibration", m_support_calibration_clump_pos);
|
|
}
|
|
|
|
} |