mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-07 15:51:08 +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.
128 lines
5.1 KiB
C++
128 lines
5.1 KiB
C++
#pragma once
|
|
#include <nlohmann/json.hpp>
|
|
#include <optional>
|
|
#include <vector>
|
|
|
|
|
|
#include "DevDefs.h"
|
|
#include "libslic3r/calib.hpp" // Orca: lowercase filename (Linux case-sensitive)
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
class MachineObject;
|
|
|
|
|
|
enum class CalibStatus{
|
|
IDLE = 0,
|
|
REQUEST,
|
|
WAITING,
|
|
FINISHED,
|
|
};
|
|
|
|
enum class ManualPaCaliMethod {
|
|
PA_LINE = 0,
|
|
PA_PATTERN,
|
|
};
|
|
|
|
class DevCalib
|
|
{
|
|
protected:
|
|
bool m_support_new_auto_cali{false};
|
|
int m_calib_version {-1};
|
|
std::optional<int> m_last_calib_version;
|
|
|
|
public:
|
|
DevCalib(MachineObject *obj) : m_owner(obj){};
|
|
MachineObject* GetOwner() const {return m_owner; };
|
|
|
|
void RequestPAResult();
|
|
CalibStatus GetPAResultStatus() const {return m_pa_results_status;}
|
|
bool IsPAResultReady() const { return m_pa_results_status == CalibStatus::FINISHED;}
|
|
void ResetPAResult();
|
|
|
|
/* calib history */
|
|
int RequestPAHistory(const PACalibExtruderInfo &calib_info);
|
|
CalibStatus GetPAHistoryStatus() const {return m_pa_table_status;}
|
|
bool IsPAHistoryReady() const { return m_pa_table_status == CalibStatus::FINISHED;}
|
|
void ResetPAHistory();
|
|
|
|
void RequestFlowRateResult();
|
|
CalibStatus GetFlowRateResultStatus() const {return m_flow_results_status;}
|
|
bool IsFlowRateReady() const { return m_flow_results_status == CalibStatus::FINISHED;}
|
|
void ResetFlowRateResult();
|
|
|
|
int GetCalibVersion() const {return m_calib_version;}
|
|
void SyncCalibVersion() { if (IsVersionInited()) { m_last_calib_version = m_calib_version; } }
|
|
void ResetCalibVersion() {m_last_calib_version.reset();}
|
|
bool IsVersionExpired() const;
|
|
bool IsVersionInited() const { return m_calib_version > -1;}
|
|
|
|
bool IsSupportNewAutoCali() const {return m_support_new_auto_cali;}
|
|
|
|
public:
|
|
void SetStashCalibFinished(bool finished) {m_calib_finished = finished;}
|
|
bool GetStashCalibFinished() { return m_calib_finished;}
|
|
|
|
void SetStashFlowRatio(float ratio) { m_flow_ratio = ratio;}
|
|
float GetStashFlowRatio() const {return m_flow_ratio;}
|
|
|
|
FlowRatioCalibrationType GetFlowRatioCalibType() {return m_flow_ratio_calibration_type;}
|
|
void SetFlowRatioCalibType(const FlowRatioCalibrationType &type) { m_flow_ratio_calibration_type = type; }
|
|
|
|
ManualPaCaliMethod GetManualPaCalibMethod() {return m_manual_pa_cali_method;}
|
|
void SetManualPaCalibMethod(const ManualPaCaliMethod& method) { m_manual_pa_cali_method = method;}
|
|
|
|
NozzleDiameterType GetSelectedNozzleDiameter() {return m_selected_nozzle_diameter;}
|
|
void SetSelectedNozzleDiameter(const NozzleDiameterType& diameter) { m_selected_nozzle_diameter = diameter;}
|
|
|
|
std::vector<CaliPresetInfo> GetSelectedCalibPreset() {return m_selected_calib_preset;}
|
|
void ResetSelectedCalibPreset() { m_selected_calib_preset.clear();}
|
|
void SetSelectedCalibPreset(const std::vector<CaliPresetInfo>& preset) { m_selected_calib_preset = preset;}
|
|
|
|
std::vector<PACalibResult> GetPAHistory() const {return m_pa_calib_tab; }
|
|
std::vector<PACalibResult> GetPAResult() const {return m_pa_calib_results; }
|
|
std::vector<FlowRatioCalibResult> GetFlowRatioResult() const {return m_flow_ratio_results; }
|
|
|
|
protected:
|
|
void ExtrusionCalibSetParse(const nlohmann::json &jj);
|
|
void ExtrusionCalibSelectParse(const nlohmann::json &jj);
|
|
void ExtrusionCalibGetTableParse(const nlohmann::json &jj);
|
|
void ExtrusionCalibGetResultParse(const nlohmann::json &jj);
|
|
void FlowrateGetResultParse(const nlohmann::json &jj);
|
|
|
|
private:
|
|
MachineObject* m_owner{nullptr};
|
|
|
|
std::vector<PACalibResult> m_pa_calib_tab;
|
|
std::vector<PACalibResult> m_pa_calib_results;
|
|
std::vector<FlowRatioCalibResult> m_flow_ratio_results;
|
|
|
|
CalibStatus m_pa_results_status{CalibStatus::IDLE};
|
|
CalibStatus m_pa_table_status{CalibStatus::IDLE};
|
|
CalibStatus m_flow_results_status{CalibStatus::IDLE};
|
|
|
|
FlowRatioCalibrationType m_flow_ratio_calibration_type{FlowRatioCalibrationType::COMPLETE_CALIBRATION};
|
|
ManualPaCaliMethod m_manual_pa_cali_method{ManualPaCaliMethod::PA_LINE};
|
|
|
|
// calibration page selected info
|
|
// 1: record when start calibration in preset page
|
|
// 2: reset when start calibration in start page
|
|
// 3: save tray_id, filament_id, setting_id, and name, nozzle_dia
|
|
// std::vector<CaliPresetInfo> selected_cali_preset;
|
|
NozzleDiameterType m_selected_nozzle_diameter{NozzleDiameterType::NONE_DIAMETER_TYPE};
|
|
std::vector<CaliPresetInfo> m_selected_calib_preset;
|
|
|
|
// stash calibrating info
|
|
float m_flow_ratio { 0.0 };
|
|
bool m_calib_finished{false};
|
|
|
|
public:
|
|
static void ParseCalibVersion(const nlohmann::json& j, DevCalib* system);
|
|
|
|
static void ParseSupportNewAutoCalib(int flag, DevCalib* system);
|
|
|
|
static void ParseV1_0(const nlohmann::json& print_json, DevCalib* system, bool key_field_only);
|
|
};
|
|
|
|
} // namespace Slic3r
|