Files
OrcaSlicer/src/slic3r/Utils/Flashforge.hpp
T
HanifKoh 4895bc03b4 Remove Unused Project Includes and Forward-Declare Where a Type Is Only Referenced (#16099)
* Remove Unused Project Includes and Forward-Declare Where a Type Is Only Referenced

Generated with include-what-you-use and applied conservatively. Only OrcaSlicer's own headers, the ones under src/ and tests/, are removed or forward-declared; standard-library and third-party includes are left alone. An include is removed only when both the Release and the Debug configuration leave it unused, never from inside a conditional block, and never from a file with platform-specific blocks, which only gain includes. Files whose only use of a header sits behind a feature or debug macro (libvgcode's OpenGL ES and marker code, the ARACHNE/TESTS_EXPORT_SVGS debug output) keep their includes.

clonable_ptr.hpp gains #pragma once; it had no include guard and was only safe while Config.hpp was its sole includer.

* Remove Unused Project Includes From Files With Platform-Specific Code

A Linux include-what-you-use run cannot see the code inside _WIN32, __APPLE__ or __linux__ blocks, so its verdict is only taken where nothing the removed header declares, directly or through what it includes, is named inside those blocks. Removals also have to hold in both the Release and Debug configuration and never touch a line inside a conditional block.

* Restore the libslic3r Precompiled Header and Direct Includes Lost in the Platform Pass

The platform-file pass treated pchheader.hpp as an ordinary header and
emptied it, and left GUI_Preview.hpp and 14 other files relying on
headers they no longer reached directly.

* Restore MainFrame.hpp in ParamsDialog.cpp for the Windows-Only Reparent Call

* Include Headers That Files Reached Through Ones the Cleanup Removed

* Drop Includes Duplicated by the Cleanup or by Main's Own Additions

* Leave PreciseSeam.cpp as Main Has It After the Precise Seam Rework
2026-10-05 16:47:17 +08:00

81 lines
3.6 KiB
C++

#ifndef slic3r_FlashForge_hpp_
#define slic3r_FlashForge_hpp_
#include <vector>
#include <string>
#include <wx/string.h>
#include "PrintHost.hpp"
#include "SerialMessage.hpp"
#include "SerialMessageType.hpp"
namespace Slic3r { enum GCodeFlavor : unsigned char; }
namespace Slic3r {
class DynamicPrintConfig;
class Http;
struct FlashforgeMaterialSlot
{
int slot_id {0}; // API is 1-based.
bool has_filament {false};
std::string material_name;
std::string material_color;
};
struct FlashforgeDiscoveredPrinter
{
std::string name;
std::string serial_number;
std::string ip_address;
};
class Flashforge : public PrintHost
{
public:
explicit Flashforge(DynamicPrintConfig *config);
~Flashforge() override = default;
const char *get_name() const override;
bool test(wxString &curl_msg) const override;
wxString get_test_ok_msg() const override;
wxString get_test_failed_msg(wxString &msg) const override;
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const override;
bool has_auto_discovery() const override { return true; }
bool can_test() const override { return true; }
PrintHostPostUploadActions get_post_upload_actions() const override { return PrintHostPostUploadAction::StartPrint; }
std::string get_host() const override { return m_host; }
bool fetch_material_slots(std::vector<FlashforgeMaterialSlot>& slots, bool* supports_material_station, wxString& msg) const;
// Parses a local API "detail" reply. Returns false when the body is not valid JSON.
static bool parse_material_slots(const std::string& body, std::vector<FlashforgeMaterialSlot>& slots, bool* supports_material_station);
static bool discover_printers(std::vector<FlashforgeDiscoveredPrinter>& printers, wxString& msg, int timeout_ms = 10000, int idle_timeout_ms = 1500, int max_retries = 3);
private:
std::string m_host;
std::string m_serial_number;
std::string m_check_code;
std::string m_console_port;
const int m_bufferSize;
GCodeFlavor m_gcFlavor;
Slic3r::Utils::SerialMessage controlCommand = {"~M601 S1\r\n",Slic3r::Utils::Command};
Slic3r::Utils::SerialMessage connectKlipperCommand = {"~M640\r\n",Slic3r::Utils::Command};
Slic3r::Utils::SerialMessage connectLegacyCommand = {"~M650\r\n",Slic3r::Utils::Command};
Slic3r::Utils::SerialMessage nozzlePosCommand = {"~M114\r\n", Slic3r::Utils::Command};
Slic3r::Utils::SerialMessage deviceInfoCommand = {"~M115\r\n", Slic3r::Utils::Command};
Slic3r::Utils::SerialMessage statusCommand = {"~M119\r\n",Slic3r::Utils::Command};
Slic3r::Utils::SerialMessage tempStatusCommand = {"~M105\r\n", Slic3r::Utils::Command};
Slic3r::Utils::SerialMessage printStatusCommand = {"~M27\r\n", Slic3r::Utils::Command};
Slic3r::Utils::SerialMessage saveFileCommand = {"~M29\r\n",Slic3r::Utils::Command};
bool upload_local_api(PrintHostUpload upload_data, ProgressFn progress_fn, ErrorFn error_fn) const;
bool test_local_api(wxString& msg) const;
bool request_local_api_json(const std::string& path, const std::string& body, std::string& response_body, wxString& error_msg) const;
std::string make_http_url(const std::string& path) const;
std::string extract_host_name() const;
bool connect(wxString& msg) const;
bool start_print(wxString& msg, const std::string& filename) const;
};
} // namespace Slic3r
#endif