Files
OrcaSlicer/src/slic3r/Utils/SimplyPrint.hpp
T
HanifKoh 84657ff11e Add Missing Includes Across the Remaining Sources and Tests (#16071)
* Ignore Clipper, libpng, mcut and Boost.Polygon Internals in clang-tidy

Each only works through a wrapper or umbrella header: libslic3r/clipper.hpp or clipper_z.hpp configure Clipper before including it, png.h pulls in libpng's config headers, and Boost.Polygon's headers only compile through polygon.hpp or voronoi.hpp.

* Ignore minilzo's Config Headers in clang-tidy

lzoconf.h and lzodefs.h are internal to minilzo.h, which is what the code includes.

* Add Missing Includes Across the Remaining Sources and Tests

Covers src/slic3r/Utils, src/slic3r/plugin, src/slic3r/Config, src/libvgcode, src/dev-utils, src/OrcaSlicer.cpp and tests/, the directories left after src/slic3r/GUI and src/libslic3r. Generated with clang-tidy misc-include-cleaner. libvgcode's own headers are included by relative path as in the rest of that library, and Catch2 and pybind11 with angle brackets as elsewhere in the repo.

* Make the GUI and Test Headers Compile on Their Own

Each now includes, or forward-declares, what it uses instead of relying on what its includers happened to include first. Headers that only compile on one platform, or that nothing built includes, are left alone.

* Keep Windows and nanosvg Setup Ahead of the Added Includes

OrcaSlicer.cpp and several tests set _WIN32_WINNT, WIN32_LEAN_AND_MEAN or NOMINMAX before including Windows.h, and the profile validator defines NANOSVG_IMPLEMENTATION before any libslic3r header. The added includes had landed above those blocks, which broke the Windows build.

* Add the GUI Includes the First Pass Missed

Covers headers that only became editable once they compiled on their own, and wx symbols whose suggested header changed as the clang-tidy ignore list grew after the src/slic3r/GUI pass.

* Keep the Added Test Includes Below the NOMINMAX Guard

test_marchingsquares.cpp and test_texture_displacement.cpp had includes inside #ifndef NOMINMAX, which the tests inherit as defined on Windows from libslic3r, so those were skipped there. .clang-tidy also ignores the MSVC STL and UCRT internals, Boost.Multiprecision's fwd.hpp and CPython's Windows include directory, as in #16068.
2026-10-03 13:45:21 +08:00

78 lines
3.3 KiB
C++

#ifndef slic3r_SimplyPrint_hpp_
#define slic3r_SimplyPrint_hpp_
#include "PrintHost.hpp"
#include "slic3r/GUI/Jobs/OAuthJob.hpp"
#include <string>
#include <map>
#include <functional>
#include <boost/filesystem/path.hpp>
#include <wx/string.h>
namespace Slic3r {
class DynamicPrintConfig;
class Http;
class SimplyPrint : public PrintHost
{
std::string cred_file;
std::map<std::string, std::string> cred;
void load_oauth_credential();
/**
* \brief Call the given SimplyPrint API, and if the token expired do a token refresh then retry
* \param build_request the http request builder
* \param on_complete
* \param on_error
* \return whether the API call succeeded
*/
bool do_api_call(std::function<Http(bool /*is_retry*/)> build_request,
std::function<bool(std::string /* body */, unsigned /* http_status */)> on_complete,
std::function<bool(std::string /* body */, std::string /* error */, unsigned /* http_status */)> on_error) const;
/**
* \brief Upload a temp file and open SimplyPrint panel for file importing
* \param file_path for file smaller than 100MB, this is the file path, otherwise must left empty
* \param chunk_id for file greater than 100MB, this is the chunk id returned by the ChunkReceive API, otherwise must left empty
* \param filename the target file name
* \param prorgess_fn
* \param error_fn
* \return whether upload succeeded
*/
bool do_temp_upload(const boost::filesystem::path& file_path,
const std::string& chunk_id,
const std::string& filename,
ProgressFn prorgess_fn,
ErrorFn error_fn) const;
bool do_chunk_upload(const boost::filesystem::path& file_path,
const std::string& filename,
ProgressFn prorgess_fn,
ErrorFn error_fn) const;
public:
SimplyPrint(DynamicPrintConfig* config);
~SimplyPrint() override = default;
const char* get_name() const override { return "SimplyPrint"; }
bool can_test() const override { return true; }
bool has_auto_discovery() const override { return false; }
bool is_cloud() const override { return true; }
std::string get_host() const override { return "https://simplyprint.io"; }
GUI::OAuthParams get_oauth_params() const;
void save_oauth_credential(const GUI::OAuthResult& cred) const;
wxString get_test_ok_msg() const override;
wxString get_test_failed_msg(wxString& msg) const override;
bool test(wxString& curl_msg) const override;
PrintHostPostUploadActions get_post_upload_actions() const override { return PrintHostPostUploadAction::QueuePrint; }
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const override;
bool is_logged_in() const override { return !cred.empty(); }
void log_out() const override;
};
} // namespace Slic3r
#endif