Files
OrcaSlicer/src/slic3r/GUI/ExportPresetBundleDialog.hpp
T
HanifKoh 73d32d4791 Stop Leaking json Through Headers and Drop Includes Kept Only for the Name (#16221)
* 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.
2026-10-07 14:22:16 +08:00

87 lines
3.0 KiB
C++

#ifndef slic3r_ExportPresetBundleDialog_hpp_
#define slic3r_ExportPresetBundleDialog_hpp_
#include "GUI.hpp"
#include "GUI_Utils.hpp"
#include "Widgets/WebViewHostDialog.hpp"
#include "libslic3r/AppConfig.hpp"
#include "libslic3r/Preset.hpp"
#include <slic3r/GUI/GUI.hpp>
#include <wx/chartype.h>
#include <unordered_map>
#include <string>
#include <vector>
#include <utility>
#include <wx/dataview.h>
#include <wx/event.h>
#include <wx/gdicmn.h>
#include <wx/language.h>
#include <wx/string.h>
#include <wx/fswatcher.h>
#include <wx/toplevel.h>
namespace Slic3r { namespace GUI {
#define DESIGN_GRAY900_COLOR wxColour("#363636") // Label color
#define DESIGN_GRAY600_COLOR wxColour("#ACACAC") // Dimmed text color
#define DESIGN_WINDOW_SIZE wxSize(FromDIP(640), FromDIP(640))
#define DESIGN_TITLE_SIZE wxSize(FromDIP(280), -1)
#define DESIGN_COMBOBOX_SIZE wxSize(FromDIP(120), -1)
#define DESIGN_LARGE_COMBOBOX_SIZE wxSize(FromDIP(120), -1)
#define DESIGN_INPUT_SIZE wxSize(FromDIP(120), -1)
#define DESIGN_LEFT_MARGIN 25
#define VERTICAL_GAP_SIZE FromDIP(4)
enum ExportCase {
INITIALIZE_FAIL = 0,
ADD_FILE_FAIL,
ADD_BUNDLE_STRUCTURE_FAIL,
FINALIZE_FAIL,
OPEN_ZIP_WRITTEN_FILE,
EXPORT_CANCEL,
EXPORT_SUCCESS,
CASE_COUNT,
};
class ExportPresetBundleDialog : public Slic3r::GUI::WebViewHostDialog
{
public:
ExportPresetBundleDialog(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxString& title = wxT(""),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxMAXIMIZE_BOX);
~ExportPresetBundleDialog();
// Utilities
bool seq_top_layer_only_changed() const { return m_seq_top_layer_only_changed; }
bool recreate_GUI() const { return m_recreate_GUI; }
void show_export_result(const ExportCase& e);
void Init();
void InitExportData();
void on_script_message(const nlohmann::json& payload) override;
void OnRequestPresets();
void OnExportData(const wxString& path, const wxString& name, nlohmann::json data);
protected:
bool m_seq_top_layer_only_changed{false};
bool m_recreate_GUI{false};
// Export Preset
std::unordered_map<std::string, Preset*> m_printer_presets; // first: printer name, second: printer presets have same printer name
std::unordered_map<std::string, std::vector<const Preset*>>
m_filament_presets; // first: printer name, second: filament presets have same printer name
std::unordered_map<std::string, std::vector<const Preset*>>
m_process_presets; // first: printer name, second: filament presets have same printer name
std::unordered_map<std::string, std::vector<std::pair<std::string, Preset*>>>
m_filament_name_to_presets; // first: filament name, second presets have same filament name and printer name in vector
};
}} // namespace Slic3r::GUI
#endif