mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-28 16:31:59 +08:00
Moved group selection for PrintHostDialog
This commit is contained in:
parent
d7f0cc71e6
commit
5e236a70cb
@ -2745,7 +2745,6 @@ void GCode::append_full_config(const Print &print, std::string &str)
|
|||||||
"print_host",
|
"print_host",
|
||||||
"printhost_apikey",
|
"printhost_apikey",
|
||||||
"printhost_cafile",
|
"printhost_cafile",
|
||||||
"repetier_group",
|
|
||||||
"repetier_slug"
|
"repetier_slug"
|
||||||
};
|
};
|
||||||
assert(std::is_sorted(banned_keys.begin(), banned_keys.end()));
|
assert(std::is_sorted(banned_keys.begin(), banned_keys.end()));
|
||||||
|
@ -155,13 +155,6 @@ void PrintConfigDef::init_common_params()
|
|||||||
def->mode = comAdvanced;
|
def->mode = comAdvanced;
|
||||||
def->set_default_value(new ConfigOptionString(""));
|
def->set_default_value(new ConfigOptionString(""));
|
||||||
|
|
||||||
def = this->add("repetier_group", coString);
|
|
||||||
def->label = L("Repetier Group");
|
|
||||||
def->tooltip = L("Name of the Repetier group that the G-code file will be sent to.");
|
|
||||||
def->mode = comAdvanced;
|
|
||||||
def->set_default_value(new ConfigOptionString(""));
|
|
||||||
|
|
||||||
|
|
||||||
def = this->add("printhost_cafile", coString);
|
def = this->add("printhost_cafile", coString);
|
||||||
def->label = L("HTTPS CA File");
|
def->label = L("HTTPS CA File");
|
||||||
def->category = OptionCategory::general;
|
def->category = OptionCategory::general;
|
||||||
|
@ -1278,7 +1278,6 @@ public:
|
|||||||
ConfigOptionString printhost_apikey;
|
ConfigOptionString printhost_apikey;
|
||||||
ConfigOptionString printhost_cafile;
|
ConfigOptionString printhost_cafile;
|
||||||
ConfigOptionString repetier_slug;
|
ConfigOptionString repetier_slug;
|
||||||
ConfigOptionString repetier_group;
|
|
||||||
ConfigOptionString serial_port;
|
ConfigOptionString serial_port;
|
||||||
ConfigOptionInt serial_speed;
|
ConfigOptionInt serial_speed;
|
||||||
|
|
||||||
@ -1290,7 +1289,6 @@ protected:
|
|||||||
OPT_PTR(printhost_apikey);
|
OPT_PTR(printhost_apikey);
|
||||||
OPT_PTR(printhost_cafile);
|
OPT_PTR(printhost_cafile);
|
||||||
OPT_PTR(repetier_slug);
|
OPT_PTR(repetier_slug);
|
||||||
OPT_PTR(repetier_group);
|
|
||||||
OPT_PTR(serial_port);
|
OPT_PTR(serial_port);
|
||||||
OPT_PTR(serial_speed);
|
OPT_PTR(serial_speed);
|
||||||
}
|
}
|
||||||
|
@ -2066,7 +2066,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||||||
"complete_objects_one_skirt",
|
"complete_objects_one_skirt",
|
||||||
"duplicate_distance", "extruder_clearance_radius", "skirts", "skirt_distance", "skirt_height",
|
"duplicate_distance", "extruder_clearance_radius", "skirts", "skirt_distance", "skirt_height",
|
||||||
"brim_width", "variable_layer_height", "serial_port", "serial_speed", "host_type", "print_host",
|
"brim_width", "variable_layer_height", "serial_port", "serial_speed", "host_type", "print_host",
|
||||||
"printhost_apikey", "printhost_cafile", "repetier_slug", "repetier_group", "nozzle_diameter", "single_extruder_multi_material",
|
"printhost_apikey", "printhost_cafile", "repetier_slug", "nozzle_diameter", "single_extruder_multi_material",
|
||||||
"wipe_tower", "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_brim",
|
"wipe_tower", "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_brim",
|
||||||
"extruder_colour", "filament_colour", "max_print_height", "printer_model", "printer_technology",
|
"extruder_colour", "filament_colour", "max_print_height", "printer_model", "printer_technology",
|
||||||
// These values are necessary to construct SlicingParameters by the Canvas3D variable layer height editor.
|
// These values are necessary to construct SlicingParameters by the Canvas3D variable layer height editor.
|
||||||
@ -5295,10 +5295,14 @@ void Plater::send_gcode()
|
|||||||
}
|
}
|
||||||
default_output_file = fs::path(Slic3r::fold_utf8_to_ascii(default_output_file.string()));
|
default_output_file = fs::path(Slic3r::fold_utf8_to_ascii(default_output_file.string()));
|
||||||
|
|
||||||
PrintHostSendDialog dlg(default_output_file, upload_job.printhost->can_start_print());
|
wxArrayString groups;
|
||||||
|
upload_job.printhost->get_groups(groups);
|
||||||
|
|
||||||
|
PrintHostSendDialog dlg(default_output_file, upload_job.printhost->can_start_print(), groups);
|
||||||
if (dlg.ShowModal() == wxID_OK) {
|
if (dlg.ShowModal() == wxID_OK) {
|
||||||
upload_job.upload_data.upload_path = dlg.filename();
|
upload_job.upload_data.upload_path = dlg.filename();
|
||||||
upload_job.upload_data.start_print = dlg.start_print();
|
upload_job.upload_data.start_print = dlg.start_print();
|
||||||
|
upload_job.upload_data.group = dlg.group();
|
||||||
|
|
||||||
p->export_gcode(fs::path(), false, std::move(upload_job));
|
p->export_gcode(fs::path(), false, std::move(upload_job));
|
||||||
}
|
}
|
||||||
|
@ -613,7 +613,7 @@ const std::vector<std::string>& Preset::printer_options()
|
|||||||
"bed_shape", "bed_custom_texture", "bed_custom_model", "z_offset", "gcode_flavor", "use_relative_e_distances", "serial_port", "serial_speed",
|
"bed_shape", "bed_custom_texture", "bed_custom_model", "z_offset", "gcode_flavor", "use_relative_e_distances", "serial_port", "serial_speed",
|
||||||
"use_firmware_retraction", "use_volumetric_e", "variable_layer_height",
|
"use_firmware_retraction", "use_volumetric_e", "variable_layer_height",
|
||||||
"min_length",
|
"min_length",
|
||||||
"host_type", "print_host", "printhost_apikey", "printhost_cafile", "repetier_slug", "repetier_group",
|
"host_type", "print_host", "printhost_apikey", "printhost_cafile", "repetier_slug",
|
||||||
"single_extruder_multi_material", "start_gcode", "end_gcode", "before_layer_gcode", "layer_gcode", "toolchange_gcode",
|
"single_extruder_multi_material", "start_gcode", "end_gcode", "before_layer_gcode", "layer_gcode", "toolchange_gcode",
|
||||||
"feature_gcode",
|
"feature_gcode",
|
||||||
"between_objects_gcode", "printer_vendor", "printer_model", "printer_variant", "printer_notes", "cooling_tube_retraction",
|
"between_objects_gcode", "printer_vendor", "printer_model", "printer_variant", "printer_notes", "cooling_tube_retraction",
|
||||||
@ -751,7 +751,7 @@ const std::vector<std::string>& Preset::sla_printer_options()
|
|||||||
"gamma_correction",
|
"gamma_correction",
|
||||||
"min_exposure_time", "max_exposure_time",
|
"min_exposure_time", "max_exposure_time",
|
||||||
"min_initial_exposure_time", "max_initial_exposure_time",
|
"min_initial_exposure_time", "max_initial_exposure_time",
|
||||||
"print_host", "printhost_apikey", "printhost_cafile", "repetier_slug", "repetier_group",
|
"print_host", "printhost_apikey", "printhost_cafile", "repetier_slug",
|
||||||
"printer_notes",
|
"printer_notes",
|
||||||
"inherits",
|
"inherits",
|
||||||
"thumbnails",
|
"thumbnails",
|
||||||
@ -892,20 +892,17 @@ static ProfileHostParams profile_host_params_same_or_anonymized(const DynamicPri
|
|||||||
auto opt_printhost_apikey_old = cfg_old.option<ConfigOptionString>("printhost_apikey");
|
auto opt_printhost_apikey_old = cfg_old.option<ConfigOptionString>("printhost_apikey");
|
||||||
auto opt_printhost_cafile_old = cfg_old.option<ConfigOptionString>("printhost_cafile");
|
auto opt_printhost_cafile_old = cfg_old.option<ConfigOptionString>("printhost_cafile");
|
||||||
auto opt_repetier_slug_old = cfg_old.option<ConfigOptionString>("repetier_slug");
|
auto opt_repetier_slug_old = cfg_old.option<ConfigOptionString>("repetier_slug");
|
||||||
auto opt_repetier_group_old = cfg_old.option<ConfigOptionString>("repetier_group");
|
|
||||||
|
|
||||||
auto opt_print_host_new = cfg_new.option<ConfigOptionString>("print_host");
|
auto opt_print_host_new = cfg_new.option<ConfigOptionString>("print_host");
|
||||||
auto opt_printhost_apikey_new = cfg_new.option<ConfigOptionString>("printhost_apikey");
|
auto opt_printhost_apikey_new = cfg_new.option<ConfigOptionString>("printhost_apikey");
|
||||||
auto opt_printhost_cafile_new = cfg_new.option<ConfigOptionString>("printhost_cafile");
|
auto opt_printhost_cafile_new = cfg_new.option<ConfigOptionString>("printhost_cafile");
|
||||||
auto opt_repetier_slug_new = cfg_new.option<ConfigOptionString>("repetier_slug");
|
auto opt_repetier_slug_new = cfg_new.option<ConfigOptionString>("repetier_slug");
|
||||||
auto opt_repetier_group_new = cfg_new.option<ConfigOptionString>("repetier_group");
|
|
||||||
|
|
||||||
// If the new print host data is undefined, use the old data.
|
// If the new print host data is undefined, use the old data.
|
||||||
bool new_print_host_undefined = (opt_print_host_new == nullptr || opt_print_host_new ->empty()) &&
|
bool new_print_host_undefined = (opt_print_host_new == nullptr || opt_print_host_new ->empty()) &&
|
||||||
(opt_printhost_apikey_new == nullptr || opt_printhost_apikey_new ->empty()) &&
|
(opt_printhost_apikey_new == nullptr || opt_printhost_apikey_new ->empty()) &&
|
||||||
(opt_printhost_cafile_new == nullptr || opt_printhost_cafile_new ->empty()) &&
|
(opt_printhost_cafile_new == nullptr || opt_printhost_cafile_new ->empty()) &&
|
||||||
(opt_repetier_slug_new == nullptr || opt_repetier_slug_new ->empty()) &&
|
(opt_repetier_slug_new == nullptr || opt_repetier_slug_new ->empty());
|
||||||
(opt_repetier_group_new == nullptr || opt_repetier_group_new ->empty());
|
|
||||||
if (new_print_host_undefined)
|
if (new_print_host_undefined)
|
||||||
return ProfileHostParams::Anonymized;
|
return ProfileHostParams::Anonymized;
|
||||||
|
|
||||||
@ -914,8 +911,8 @@ static ProfileHostParams profile_host_params_same_or_anonymized(const DynamicPri
|
|||||||
(l != nullptr && r != nullptr && l->value == r->value);
|
(l != nullptr && r != nullptr && l->value == r->value);
|
||||||
};
|
};
|
||||||
return (opt_same(opt_print_host_old, opt_print_host_new) && opt_same(opt_printhost_apikey_old, opt_printhost_apikey_new) &&
|
return (opt_same(opt_print_host_old, opt_print_host_new) && opt_same(opt_printhost_apikey_old, opt_printhost_apikey_new) &&
|
||||||
opt_same(opt_printhost_cafile_old, opt_printhost_cafile_new) && opt_same(opt_repetier_slug_old, opt_repetier_slug_new) &&
|
opt_same(opt_printhost_cafile_old, opt_printhost_cafile_new) && opt_same(opt_repetier_slug_old, opt_repetier_slug_new))
|
||||||
opt_same(opt_repetier_group_old, opt_repetier_group_new)) ? ProfileHostParams::Same : ProfileHostParams::Different;
|
? ProfileHostParams::Same : ProfileHostParams::Different;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool profile_print_params_same(const DynamicPrintConfig &cfg_old, const DynamicPrintConfig &cfg_new)
|
static bool profile_print_params_same(const DynamicPrintConfig &cfg_old, const DynamicPrintConfig &cfg_new)
|
||||||
@ -927,7 +924,7 @@ static bool profile_print_params_same(const DynamicPrintConfig &cfg_old, const D
|
|||||||
"compatible_printers", "compatible_printers_condition", "inherits",
|
"compatible_printers", "compatible_printers_condition", "inherits",
|
||||||
"print_settings_id", "filament_settings_id", "sla_print_settings_id", "sla_material_settings_id", "printer_settings_id",
|
"print_settings_id", "filament_settings_id", "sla_print_settings_id", "sla_material_settings_id", "printer_settings_id",
|
||||||
"printer_model", "printer_variant", "default_print_profile", "default_filament_profile", "default_sla_print_profile", "default_sla_material_profile",
|
"printer_model", "printer_variant", "default_print_profile", "default_filament_profile", "default_sla_print_profile", "default_sla_material_profile",
|
||||||
"print_host", "printhost_apikey", "repetier_slug", "repetier_group", "printhost_cafile" })
|
"print_host", "printhost_apikey", "repetier_slug", "printhost_cafile" })
|
||||||
diff.erase(std::remove(diff.begin(), diff.end(), key), diff.end());
|
diff.erase(std::remove(diff.begin(), diff.end(), key), diff.end());
|
||||||
// Preset with the same name as stored inside the config exists.
|
// Preset with the same name as stored inside the config exists.
|
||||||
return diff.empty() && profile_host_params_same_or_anonymized(cfg_old, cfg_new) != ProfileHostParams::Different;
|
return diff.empty() && profile_host_params_same_or_anonymized(cfg_old, cfg_new) != ProfileHostParams::Different;
|
||||||
@ -978,7 +975,6 @@ Preset& PresetCollection::load_external_preset(
|
|||||||
opt_update("printhost_apikey");
|
opt_update("printhost_apikey");
|
||||||
opt_update("printhost_cafile");
|
opt_update("printhost_cafile");
|
||||||
opt_update("repetier_slug");
|
opt_update("repetier_slug");
|
||||||
opt_update("repetier_group");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Update the "inherits" field.
|
// Update the "inherits" field.
|
||||||
|
@ -527,7 +527,6 @@ DynamicPrintConfig PresetBundle::full_config_secure() const
|
|||||||
config.erase("print_host");
|
config.erase("print_host");
|
||||||
config.erase("printhost_apikey");
|
config.erase("printhost_apikey");
|
||||||
config.erase("repetier_slug");
|
config.erase("repetier_slug");
|
||||||
config.erase("repetier_group");
|
|
||||||
config.erase("printhost_cafile");
|
config.erase("printhost_cafile");
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,13 @@ namespace GUI {
|
|||||||
|
|
||||||
static const char *CONFIG_KEY_PATH = "printhost_path";
|
static const char *CONFIG_KEY_PATH = "printhost_path";
|
||||||
static const char *CONFIG_KEY_PRINT = "printhost_print";
|
static const char *CONFIG_KEY_PRINT = "printhost_print";
|
||||||
|
static const char *CONFIG_KEY_GROUP = "repetier_group";
|
||||||
|
|
||||||
PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, bool can_start_print)
|
PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, bool can_start_print, wxArrayString& groups)
|
||||||
: MsgDialog(nullptr, _(L("Send G-Code to printer host")), _(L("Upload to Printer Host with the following filename:")), wxID_NONE)
|
: MsgDialog(nullptr, _(L("Send G-Code to printer host")), _(L("Upload to Printer Host with the following filename:")), wxID_NONE)
|
||||||
, txt_filename(new wxTextCtrl(this, wxID_ANY))
|
, txt_filename(new wxTextCtrl(this, wxID_ANY))
|
||||||
, box_print(can_start_print ? new wxCheckBox(this, wxID_ANY, _(L("Start printing after upload"))) : nullptr)
|
, box_print(can_start_print ? new wxCheckBox(this, wxID_ANY, _(L("Start printing after upload"))) : nullptr)
|
||||||
|
, combo_groups(!groups.IsEmpty() ? new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, groups, wxCB_READONLY) : nullptr)
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
txt_filename->OSXDisableAllSmartSubstitutions();
|
txt_filename->OSXDisableAllSmartSubstitutions();
|
||||||
@ -50,6 +52,18 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, bool can_start_pr
|
|||||||
box_print->SetValue(app_config->get("recent", CONFIG_KEY_PRINT) == "1");
|
box_print->SetValue(app_config->get("recent", CONFIG_KEY_PRINT) == "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (combo_groups != nullptr) {
|
||||||
|
auto *label_group = new wxStaticText(this, wxID_ANY, _(L("Group")));
|
||||||
|
content_sizer->Add(label_group);
|
||||||
|
|
||||||
|
content_sizer->Add(combo_groups, 0, wxBOTTOM, 2*VERT_SPACING);
|
||||||
|
|
||||||
|
wxString recent_group = from_u8(app_config->get("recent", CONFIG_KEY_GROUP));
|
||||||
|
if (recent_group.Length() > 0) {
|
||||||
|
combo_groups->SetValue(recent_group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
btn_sizer->Add(CreateStdDialogButtonSizer(wxOK | wxCANCEL));
|
btn_sizer->Add(CreateStdDialogButtonSizer(wxOK | wxCANCEL));
|
||||||
|
|
||||||
|
|
||||||
@ -86,6 +100,16 @@ bool PrintHostSendDialog::start_print() const
|
|||||||
return box_print != nullptr ? box_print->GetValue() : false;
|
return box_print != nullptr ? box_print->GetValue() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string PrintHostSendDialog::group() const
|
||||||
|
{
|
||||||
|
if (combo_groups == nullptr) {
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
wxString group = combo_groups->GetValue();
|
||||||
|
return into_u8(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PrintHostSendDialog::EndModal(int ret)
|
void PrintHostSendDialog::EndModal(int ret)
|
||||||
{
|
{
|
||||||
if (ret == wxID_OK) {
|
if (ret == wxID_OK) {
|
||||||
@ -96,9 +120,15 @@ void PrintHostSendDialog::EndModal(int ret)
|
|||||||
path.clear();
|
path.clear();
|
||||||
else
|
else
|
||||||
path = path.SubString(0, last_slash);
|
path = path.SubString(0, last_slash);
|
||||||
|
|
||||||
AppConfig *app_config = wxGetApp().app_config;
|
AppConfig *app_config = wxGetApp().app_config;
|
||||||
app_config->set("recent", CONFIG_KEY_PATH, into_u8(path));
|
app_config->set("recent", CONFIG_KEY_PATH, into_u8(path));
|
||||||
app_config->set("recent", CONFIG_KEY_PRINT, start_print() ? "1" : "0");
|
app_config->set("recent", CONFIG_KEY_PRINT, start_print() ? "1" : "0");
|
||||||
|
|
||||||
|
if (combo_groups != nullptr) {
|
||||||
|
wxString group = combo_groups->GetValue();
|
||||||
|
app_config->set("recent", CONFIG_KEY_GROUP, into_u8(group));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MsgDialog::EndModal(ret);
|
MsgDialog::EndModal(ret);
|
||||||
|
@ -29,14 +29,16 @@ namespace GUI {
|
|||||||
class PrintHostSendDialog : public GUI::MsgDialog
|
class PrintHostSendDialog : public GUI::MsgDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PrintHostSendDialog(const boost::filesystem::path &path, bool can_start_print);
|
PrintHostSendDialog(const boost::filesystem::path &path, bool can_start_print, wxArrayString& groups);
|
||||||
boost::filesystem::path filename() const;
|
boost::filesystem::path filename() const;
|
||||||
bool start_print() const;
|
bool start_print() const;
|
||||||
|
std::string group() const;
|
||||||
|
|
||||||
virtual void EndModal(int ret) override;
|
virtual void EndModal(int ret) override;
|
||||||
private:
|
private:
|
||||||
wxTextCtrl *txt_filename;
|
wxTextCtrl *txt_filename;
|
||||||
wxCheckBox *box_print;
|
wxCheckBox *box_print;
|
||||||
|
wxComboBox *combo_groups;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1992,6 +1992,26 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
|
|||||||
return sizer;
|
return sizer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto repetier_slug_browse = [=](wxWindow* parent) {
|
||||||
|
add_scaled_button(parent, &m_repetier_slug_browse_btn, "printers", _(L("Printers")) + " "+ dots, wxBU_LEFT | wxBU_EXACTFIT);
|
||||||
|
ScalableButton* btn = m_repetier_slug_browse_btn;
|
||||||
|
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||||
|
|
||||||
|
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
sizer->Add(btn);
|
||||||
|
|
||||||
|
btn->Bind(wxEVT_BUTTON, [=](wxCommandEvent &e) {
|
||||||
|
BonjourDialog dialog(parent, tech);
|
||||||
|
if (dialog.show_and_lookup()) {
|
||||||
|
optgroup->set_value("repetier_slug", std::move(dialog.get_selected()), true);
|
||||||
|
optgroup->get_field("repetier_slug")->field_changed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return sizer;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Set a wider width for a better alignment
|
// Set a wider width for a better alignment
|
||||||
Option option = optgroup->get_option("print_host");
|
Option option = optgroup->get_option("print_host");
|
||||||
option.opt.width = Field::def_width_wider();
|
option.opt.width = Field::def_width_wider();
|
||||||
@ -2002,12 +2022,10 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
|
|||||||
option = optgroup->get_option("printhost_apikey");
|
option = optgroup->get_option("printhost_apikey");
|
||||||
option.opt.width = Field::def_width_wider();
|
option.opt.width = Field::def_width_wider();
|
||||||
optgroup->append_single_option_line(option);
|
optgroup->append_single_option_line(option);
|
||||||
|
|
||||||
option = optgroup->get_option("repetier_slug");
|
option = optgroup->get_option("repetier_slug");
|
||||||
option.opt.width = Field::def_width_wider();
|
option.opt.width = Field::def_width_wider();
|
||||||
optgroup->append_single_option_line(option);
|
optgroup->append_single_option_line(option);
|
||||||
option = optgroup->get_option("repetier_group");
|
|
||||||
option.opt.width = Field::def_width_wider();
|
|
||||||
optgroup->append_single_option_line(option);
|
|
||||||
|
|
||||||
const auto ca_file_hint = _utf8(L("HTTPS CA file is optional. It is only needed if you use HTTPS with a self-signed certificate."));
|
const auto ca_file_hint = _utf8(L("HTTPS CA file is optional. It is only needed if you use HTTPS with a self-signed certificate."));
|
||||||
|
|
||||||
@ -2614,13 +2632,10 @@ void TabPrinter::update_fff()
|
|||||||
bool is_repetier = m_config->option<ConfigOptionEnum<PrintHostType>>("host_type")->value == htRepetier;
|
bool is_repetier = m_config->option<ConfigOptionEnum<PrintHostType>>("host_type")->value == htRepetier;
|
||||||
{
|
{
|
||||||
Field *rs = get_field("repetier_slug");
|
Field *rs = get_field("repetier_slug");
|
||||||
Field *rg = get_field("repetier_group");
|
|
||||||
if (is_repetier) {
|
if (is_repetier) {
|
||||||
rs->enable();
|
rs->enable();
|
||||||
rg->enable();
|
|
||||||
} else {
|
} else {
|
||||||
rs->disable();
|
rs->disable();
|
||||||
rg->disable();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,6 +392,7 @@ public:
|
|||||||
wxButton* m_serial_test_btn = nullptr;
|
wxButton* m_serial_test_btn = nullptr;
|
||||||
ScalableButton* m_print_host_test_btn = nullptr;
|
ScalableButton* m_print_host_test_btn = nullptr;
|
||||||
ScalableButton* m_printhost_browse_btn = nullptr;
|
ScalableButton* m_printhost_browse_btn = nullptr;
|
||||||
|
ScalableButton* m_repetier_slug_browse_btn = nullptr;
|
||||||
ScalableButton* m_reset_to_filament_color = nullptr;
|
ScalableButton* m_reset_to_filament_color = nullptr;
|
||||||
|
|
||||||
size_t m_extruders_count;
|
size_t m_extruders_count;
|
||||||
|
@ -28,6 +28,7 @@ public:
|
|||||||
bool can_test() const override { return true; }
|
bool can_test() const override { return true; }
|
||||||
bool can_start_print() const override { return true; }
|
bool can_start_print() const override { return true; }
|
||||||
std::string get_host() const override { return host; }
|
std::string get_host() const override { return host; }
|
||||||
|
bool get_groups(wxArrayString& groups) const override { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate_version_text(const boost::optional<std::string> &version_text) const;
|
bool validate_version_text(const boost::optional<std::string> &version_text) const;
|
||||||
|
@ -27,6 +27,7 @@ public:
|
|||||||
bool can_test() const override { return true; }
|
bool can_test() const override { return true; }
|
||||||
bool can_start_print() const override { return true; }
|
bool can_start_print() const override { return true; }
|
||||||
std::string get_host() const override { return host; }
|
std::string get_host() const override { return host; }
|
||||||
|
bool get_groups(wxArrayString& groups) const override { return false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string host;
|
std::string host;
|
||||||
|
@ -28,6 +28,7 @@ public:
|
|||||||
bool can_test() const override { return true; }
|
bool can_test() const override { return true; }
|
||||||
bool can_start_print() const override { return false; }
|
bool can_start_print() const override { return false; }
|
||||||
std::string get_host() const override { return host; }
|
std::string get_host() const override { return host; }
|
||||||
|
bool get_groups(wxArrayString& groups) const override { return false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string host;
|
std::string host;
|
||||||
|
@ -29,6 +29,7 @@ public:
|
|||||||
bool can_test() const override { return true; }
|
bool can_test() const override { return true; }
|
||||||
bool can_start_print() const override { return true; }
|
bool can_start_print() const override { return true; }
|
||||||
std::string get_host() const override { return host; }
|
std::string get_host() const override { return host; }
|
||||||
|
bool get_groups(wxArrayString& groups) const override { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool validate_version_text(const boost::optional<std::string> &version_text) const;
|
virtual bool validate_version_text(const boost::optional<std::string> &version_text) const;
|
||||||
|
@ -20,6 +20,9 @@ struct PrintHostUpload
|
|||||||
{
|
{
|
||||||
boost::filesystem::path source_path;
|
boost::filesystem::path source_path;
|
||||||
boost::filesystem::path upload_path;
|
boost::filesystem::path upload_path;
|
||||||
|
|
||||||
|
std::string group;
|
||||||
|
|
||||||
bool start_print = false;
|
bool start_print = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -42,6 +45,7 @@ public:
|
|||||||
virtual bool can_test() const = 0;
|
virtual bool can_test() const = 0;
|
||||||
virtual bool can_start_print() const = 0;
|
virtual bool can_start_print() const = 0;
|
||||||
virtual std::string get_host() const = 0;
|
virtual std::string get_host() const = 0;
|
||||||
|
virtual bool get_groups(wxArrayString& groups) const = 0;
|
||||||
|
|
||||||
static PrintHost* get_print_host(DynamicPrintConfig *config);
|
static PrintHost* get_print_host(DynamicPrintConfig *config);
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
#include <boost/property_tree/ptree.hpp>
|
#include <boost/property_tree/ptree.hpp>
|
||||||
@ -27,8 +28,7 @@ Repetier::Repetier(DynamicPrintConfig *config) :
|
|||||||
host(config->opt_string("print_host")),
|
host(config->opt_string("print_host")),
|
||||||
apikey(config->opt_string("printhost_apikey")),
|
apikey(config->opt_string("printhost_apikey")),
|
||||||
cafile(config->opt_string("printhost_cafile")),
|
cafile(config->opt_string("printhost_cafile")),
|
||||||
slug(config->opt_string("repetier_slug")),
|
slug(config->opt_string("repetier_slug"))
|
||||||
group(config->opt_string("repetier_group"))
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
const char* Repetier::get_name() const { return "Repetier"; }
|
const char* Repetier::get_name() const { return "Repetier"; }
|
||||||
@ -106,19 +106,20 @@ bool Repetier::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error
|
|||||||
|
|
||||||
auto url = make_url((boost::format("printer/model/%1%") % slug).str());
|
auto url = make_url((boost::format("printer/model/%1%") % slug).str());
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Uploading file %2% at %3%, filename: %4%, path: %5%, print: %6%")
|
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Uploading file %2% at %3%, filename: %4%, path: %5%, print: %6%, group: %7%")
|
||||||
% name
|
% name
|
||||||
% upload_data.source_path
|
% upload_data.source_path
|
||||||
% url
|
% url
|
||||||
% upload_filename.string()
|
% upload_filename.string()
|
||||||
% upload_parent_path.string()
|
% upload_parent_path.string()
|
||||||
% upload_data.start_print;
|
% upload_data.start_print
|
||||||
|
% upload_data.group;
|
||||||
|
|
||||||
auto http = Http::post(std::move(url));
|
auto http = Http::post(std::move(url));
|
||||||
set_auth(http);
|
set_auth(http);
|
||||||
|
|
||||||
if (! group.empty()) {
|
if (! upload_data.group.empty() && upload_data.group != _utf8(L("Default"))) {
|
||||||
http.form_add("group", group);
|
http.form_add("group", upload_data.group);
|
||||||
}
|
}
|
||||||
|
|
||||||
http.form_add("a", "upload")
|
http.form_add("a", "upload")
|
||||||
@ -171,4 +172,45 @@ std::string Repetier::make_url(const std::string &path) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Repetier::get_groups(wxArrayString& groups) const
|
||||||
|
{
|
||||||
|
bool res = true;
|
||||||
|
|
||||||
|
const char *name = get_name();
|
||||||
|
auto url = make_url((boost::format("printer/api/%1%") % slug).str());
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Get groups at: %2%") % name % url;
|
||||||
|
|
||||||
|
auto http = Http::get(std::move(url));
|
||||||
|
set_auth(http);
|
||||||
|
http.form_add("a", "listModelGroups");
|
||||||
|
http.on_error([&](std::string body, std::string error, unsigned status) {
|
||||||
|
BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting version: %2%, HTTP %3%, body: `%4%`") % name % error % status % body;
|
||||||
|
})
|
||||||
|
.on_complete([&, this](std::string body, unsigned) {
|
||||||
|
BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: Got groups: %2%") % name % body;
|
||||||
|
|
||||||
|
try {
|
||||||
|
std::stringstream ss(body);
|
||||||
|
pt::ptree ptree;
|
||||||
|
pt::read_json(ss, ptree);
|
||||||
|
|
||||||
|
BOOST_FOREACH(boost::property_tree::ptree::value_type &v, ptree.get_child("groupNames.")) {
|
||||||
|
if (v.second.data() == "#") {
|
||||||
|
groups.push_back(_utf8(L("Default")));
|
||||||
|
} else {
|
||||||
|
groups.push_back(v.second.data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception &) {
|
||||||
|
//msg = "Could not parse server response";
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.perform_sync();
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ public:
|
|||||||
bool can_test() const override { return true; }
|
bool can_test() const override { return true; }
|
||||||
bool can_start_print() const override { return false; }
|
bool can_start_print() const override { return false; }
|
||||||
std::string get_host() const override { return host; }
|
std::string get_host() const override { return host; }
|
||||||
|
bool get_groups(wxArrayString& groups) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool validate_version_text(const boost::optional<std::string> &version_text) const;
|
virtual bool validate_version_text(const boost::optional<std::string> &version_text) const;
|
||||||
@ -38,7 +39,6 @@ private:
|
|||||||
std::string apikey;
|
std::string apikey;
|
||||||
std::string cafile;
|
std::string cafile;
|
||||||
std::string slug;
|
std::string slug;
|
||||||
std::string group;
|
|
||||||
|
|
||||||
void set_auth(Http &http) const;
|
void set_auth(Http &http) const;
|
||||||
std::string make_url(const std::string &path) const;
|
std::string make_url(const std::string &path) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user