mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-13 22:05:54 +08:00
add klipper to export gcode target
This commit is contained in:
parent
e0f085bb03
commit
a16a6415dd
@ -2688,11 +2688,13 @@ void PrintConfigDef::init_fff_params()
|
||||
def->enum_values.push_back("flashair");
|
||||
def->enum_values.push_back("astrobox");
|
||||
def->enum_values.push_back("repetier");
|
||||
def->enum_values.push_back("klipper");
|
||||
def->enum_labels.push_back("OctoPrint");
|
||||
def->enum_labels.push_back("Duet");
|
||||
def->enum_labels.push_back("FlashAir");
|
||||
def->enum_labels.push_back("AstroBox");
|
||||
def->enum_labels.push_back("Repetier");
|
||||
def->enum_labels.push_back("Klipper");
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionEnum<PrintHostType>(htOctoPrint));
|
||||
|
||||
|
@ -72,7 +72,12 @@ enum class MachineLimitsUsage : uint8_t {
|
||||
};
|
||||
|
||||
enum PrintHostType {
|
||||
htOctoPrint, htDuet, htFlashAir, htAstroBox, htRepetier
|
||||
htOctoPrint,
|
||||
htDuet,
|
||||
htFlashAir,
|
||||
htAstroBox,
|
||||
htRepetier,
|
||||
htKlipper,
|
||||
};
|
||||
|
||||
enum AuthorizationType {
|
||||
@ -222,6 +227,7 @@ template<> inline const t_config_enum_values& ConfigOptionEnum<PrintHostType>::g
|
||||
{"flashair", htFlashAir},
|
||||
{"astrobox", htAstroBox},
|
||||
{"repetier", htRepetier},
|
||||
{"klipper", htKlipper},
|
||||
};
|
||||
return keys_map;
|
||||
}
|
||||
|
@ -215,6 +215,8 @@ set(SLIC3R_GUI_SOURCES
|
||||
Utils/FixModelByWin10.hpp
|
||||
Utils/OctoPrint.cpp
|
||||
Utils/OctoPrint.hpp
|
||||
Utils/Klipper.cpp
|
||||
Utils/Klipper.hpp
|
||||
Utils/Duet.cpp
|
||||
Utils/Duet.hpp
|
||||
Utils/FlashAir.cpp
|
||||
|
@ -499,7 +499,12 @@ void PhysicalPrinterDialog::update()
|
||||
m_optgroup->hide_field(opt_key);
|
||||
const auto opt = m_config->option<ConfigOptionEnum<PrintHostType>>("host_type");
|
||||
supports_multiple_printers = opt && opt->value == htRepetier;
|
||||
}
|
||||
|
||||
// hide api key for klipper
|
||||
if (opt && opt->value == htKlipper) {
|
||||
m_optgroup->hide_field("printhost_apikey");
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_optgroup->set_value("host_type", int(PrintHostType::htOctoPrint), false);
|
||||
m_optgroup->hide_field("host_type");
|
||||
|
30
src/slic3r/Utils/Klipper.cpp
Normal file
30
src/slic3r/Utils/Klipper.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include "Klipper.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <exception>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
|
||||
#include <wx/progdlg.h>
|
||||
#include <wx/string.h>
|
||||
|
||||
#include "slic3r/GUI/I18N.hpp"
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "Http.hpp"
|
||||
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
namespace pt = boost::property_tree;
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
Klipper::Klipper(DynamicPrintConfig *config) : OctoPrint(config) {}
|
||||
|
||||
const char* Klipper::get_name() const { return "Klipper"; }
|
||||
|
||||
}
|
30
src/slic3r/Utils/Klipper.hpp
Normal file
30
src/slic3r/Utils/Klipper.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef slic3r_Klipper_hpp_
|
||||
#define slic3r_Klipper_hpp_
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <wx/string.h>
|
||||
#include <wx/arrstr.h>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include "OctoPrint.hpp"
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class DynamicPrintConfig;
|
||||
|
||||
class Klipper : public OctoPrint
|
||||
{
|
||||
public:
|
||||
Klipper(DynamicPrintConfig *config);
|
||||
~Klipper() override = default;
|
||||
|
||||
const char* get_name() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -80,15 +80,12 @@ bool OctoPrint::test(wxString &msg) const
|
||||
|
||||
wxString OctoPrint::get_test_ok_msg () const
|
||||
{
|
||||
return _(L("Connection to OctoPrint works correctly."));
|
||||
return wxString::Format(_(L("Connection to %s works correctly.")), get_name());
|
||||
}
|
||||
|
||||
wxString OctoPrint::get_test_failed_msg (wxString &msg) const
|
||||
{
|
||||
return GUI::from_u8((boost::format("%s: %s\n\n%s")
|
||||
% _utf8(L("Could not connect to OctoPrint"))
|
||||
% std::string(msg.ToUTF8())
|
||||
% _utf8(L("Note: OctoPrint version at least 1.1.0 is required."))).str());
|
||||
return wxString::Format("%s: %s\n\n%s", wxString::Format(_(L("Could not connect to %s")), get_name()), msg, _(L("Note: OctoPrint version at least 1.1.0 is required.")));
|
||||
}
|
||||
|
||||
bool OctoPrint::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const
|
||||
@ -133,7 +130,7 @@ bool OctoPrint::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Erro
|
||||
prorgess_fn(std::move(progress), cancel);
|
||||
if (cancel) {
|
||||
// Upload was canceled
|
||||
BOOST_LOG_TRIVIAL(info) << "Octoprint: Upload canceled";
|
||||
BOOST_LOG_TRIVIAL(info) << get_name() << ": Upload canceled";
|
||||
res = false;
|
||||
}
|
||||
})
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "FlashAir.hpp"
|
||||
#include "AstroBox.hpp"
|
||||
#include "Repetier.hpp"
|
||||
#include "Klipper.hpp"
|
||||
#include "../GUI/PrintHostDialogs.hpp"
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
@ -50,6 +51,7 @@ PrintHost* PrintHost::get_print_host(DynamicPrintConfig *config)
|
||||
case htFlashAir: return new FlashAir(config);
|
||||
case htAstroBox: return new AstroBox(config);
|
||||
case htRepetier: return new Repetier(config);
|
||||
case htKlipper: return new Klipper(config);
|
||||
default: return nullptr;
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user