mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-21 17:34:29 +08:00
Some code cleanup.
- Renamed repetier_slug to printhost_slug - Replaced test method with original code
This commit is contained in:
parent
62c6637976
commit
db99b091d9
@ -2745,7 +2745,7 @@ void GCode::append_full_config(const Print &print, std::string &str)
|
|||||||
"print_host",
|
"print_host",
|
||||||
"printhost_apikey",
|
"printhost_apikey",
|
||||||
"printhost_cafile",
|
"printhost_cafile",
|
||||||
"repetier_slug"
|
"printhost_slug"
|
||||||
};
|
};
|
||||||
assert(std::is_sorted(banned_keys.begin(), banned_keys.end()));
|
assert(std::is_sorted(banned_keys.begin(), banned_keys.end()));
|
||||||
auto is_banned = [banned_keys](const std::string &key) {
|
auto is_banned = [banned_keys](const std::string &key) {
|
||||||
|
@ -149,9 +149,9 @@ 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_slug", coString);
|
def = this->add("printhost_slug", coString);
|
||||||
def->label = L("Repetier Printer");
|
def->label = L("Printer");
|
||||||
def->tooltip = L("Name of the Repetier printer");
|
def->tooltip = L("Name of the printer");
|
||||||
def->gui_type = "select_open";
|
def->gui_type = "select_open";
|
||||||
def->mode = comAdvanced;
|
def->mode = comAdvanced;
|
||||||
def->set_default_value(new ConfigOptionString(""));
|
def->set_default_value(new ConfigOptionString(""));
|
||||||
|
@ -1277,7 +1277,7 @@ public:
|
|||||||
ConfigOptionString print_host;
|
ConfigOptionString print_host;
|
||||||
ConfigOptionString printhost_apikey;
|
ConfigOptionString printhost_apikey;
|
||||||
ConfigOptionString printhost_cafile;
|
ConfigOptionString printhost_cafile;
|
||||||
ConfigOptionString repetier_slug;
|
ConfigOptionString printhost_slug;
|
||||||
ConfigOptionString serial_port;
|
ConfigOptionString serial_port;
|
||||||
ConfigOptionInt serial_speed;
|
ConfigOptionInt serial_speed;
|
||||||
|
|
||||||
@ -1288,7 +1288,7 @@ protected:
|
|||||||
OPT_PTR(print_host);
|
OPT_PTR(print_host);
|
||||||
OPT_PTR(printhost_apikey);
|
OPT_PTR(printhost_apikey);
|
||||||
OPT_PTR(printhost_cafile);
|
OPT_PTR(printhost_cafile);
|
||||||
OPT_PTR(repetier_slug);
|
OPT_PTR(printhost_slug);
|
||||||
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", "nozzle_diameter", "single_extruder_multi_material",
|
"printhost_apikey", "printhost_cafile", "printhost_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.
|
||||||
|
@ -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",
|
"host_type", "print_host", "printhost_apikey", "printhost_cafile", "printhost_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",
|
"print_host", "printhost_apikey", "printhost_cafile", "printhost_slug",
|
||||||
"printer_notes",
|
"printer_notes",
|
||||||
"inherits",
|
"inherits",
|
||||||
"thumbnails",
|
"thumbnails",
|
||||||
@ -891,18 +891,18 @@ static ProfileHostParams profile_host_params_same_or_anonymized(const DynamicPri
|
|||||||
auto opt_print_host_old = cfg_old.option<ConfigOptionString>("print_host");
|
auto opt_print_host_old = cfg_old.option<ConfigOptionString>("print_host");
|
||||||
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_printhost_slug_old = cfg_old.option<ConfigOptionString>("printhost_slug");
|
||||||
|
|
||||||
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_printhost_slug_new = cfg_new.option<ConfigOptionString>("printhost_slug");
|
||||||
|
|
||||||
// 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_printhost_slug_new == nullptr || opt_printhost_slug_new ->empty());
|
||||||
if (new_print_host_undefined)
|
if (new_print_host_undefined)
|
||||||
return ProfileHostParams::Anonymized;
|
return ProfileHostParams::Anonymized;
|
||||||
|
|
||||||
@ -911,7 +911,7 @@ 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_printhost_slug_old, opt_printhost_slug_new))
|
||||||
? ProfileHostParams::Same : ProfileHostParams::Different;
|
? ProfileHostParams::Same : ProfileHostParams::Different;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -924,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", "printhost_cafile" })
|
"print_host", "printhost_apikey", "printhost_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;
|
||||||
@ -974,7 +974,7 @@ Preset& PresetCollection::load_external_preset(
|
|||||||
opt_update("print_host");
|
opt_update("print_host");
|
||||||
opt_update("printhost_apikey");
|
opt_update("printhost_apikey");
|
||||||
opt_update("printhost_cafile");
|
opt_update("printhost_cafile");
|
||||||
opt_update("repetier_slug");
|
opt_update("printhost_slug");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Update the "inherits" field.
|
// Update the "inherits" field.
|
||||||
|
@ -526,7 +526,7 @@ DynamicPrintConfig PresetBundle::full_config_secure() const
|
|||||||
DynamicPrintConfig config = this->full_config();
|
DynamicPrintConfig config = this->full_config();
|
||||||
config.erase("print_host");
|
config.erase("print_host");
|
||||||
config.erase("printhost_apikey");
|
config.erase("printhost_apikey");
|
||||||
config.erase("repetier_slug");
|
config.erase("printhost_slug");
|
||||||
config.erase("printhost_cafile");
|
config.erase("printhost_cafile");
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
@ -1993,8 +1993,8 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto print_host_printers = [this](wxWindow* parent) {
|
auto print_host_printers = [this](wxWindow* parent) {
|
||||||
add_scaled_button(parent, &m_repetier_slug_browse_btn, "browse", _(L("Refresh Printers")), wxBU_LEFT | wxBU_EXACTFIT);
|
add_scaled_button(parent, &m_printhost_slug_browse_btn, "browse", _(L("Refresh Printers")), wxBU_LEFT | wxBU_EXACTFIT);
|
||||||
ScalableButton* btn = m_repetier_slug_browse_btn;
|
ScalableButton* btn = m_printhost_slug_browse_btn;
|
||||||
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||||
|
|
||||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
@ -2015,7 +2015,7 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
|
|||||||
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("printhost_slug");
|
||||||
option.opt.width = Field::def_width_wider();
|
option.opt.width = Field::def_width_wider();
|
||||||
Line slug_line = optgroup->create_single_option_line(option);
|
Line slug_line = optgroup->create_single_option_line(option);
|
||||||
slug_line.append_widget(print_host_printers);
|
slug_line.append_widget(print_host_printers);
|
||||||
@ -2138,7 +2138,7 @@ void TabPrinter::update_printers()
|
|||||||
std::unique_ptr<PrintHost> host(PrintHost::get_print_host(m_config));
|
std::unique_ptr<PrintHost> host(PrintHost::get_print_host(m_config));
|
||||||
|
|
||||||
wxArrayString printers;
|
wxArrayString printers;
|
||||||
Field *rs = get_field("repetier_slug");
|
Field *rs = get_field("printhost_slug");
|
||||||
if (!host->get_printers(printers)) {
|
if (!host->get_printers(printers)) {
|
||||||
std::vector<std::string> slugs;
|
std::vector<std::string> slugs;
|
||||||
|
|
||||||
@ -2521,9 +2521,9 @@ void TabPrinter::update_fff()
|
|||||||
m_print_host_test_btn->Enable(!m_config->opt_string("print_host").empty() && host->can_test());
|
m_print_host_test_btn->Enable(!m_config->opt_string("print_host").empty() && host->can_test());
|
||||||
if(m_printhost_browse_btn)
|
if(m_printhost_browse_btn)
|
||||||
m_printhost_browse_btn->Enable(host->has_auto_discovery());
|
m_printhost_browse_btn->Enable(host->has_auto_discovery());
|
||||||
m_repetier_slug_browse_btn->Enable(host->can_support_multiple_printers());
|
m_printhost_slug_browse_btn->Enable(host->can_support_multiple_printers());
|
||||||
|
|
||||||
Field *rs = get_field("repetier_slug");
|
Field *rs = get_field("printhost_slug");
|
||||||
if (host->can_support_multiple_printers()) {
|
if (host->can_support_multiple_printers()) {
|
||||||
update_printers();
|
update_printers();
|
||||||
rs->enable();
|
rs->enable();
|
||||||
|
@ -393,7 +393,7 @@ public:
|
|||||||
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_printhost_browse_printer_btn = nullptr;
|
ScalableButton* m_printhost_browse_printer_btn = nullptr;
|
||||||
ScalableButton* m_repetier_slug_browse_btn = nullptr;
|
ScalableButton* m_printhost_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,7 +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("printhost_slug"))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
const char* Repetier::get_name() const { return "Repetier"; }
|
const char* Repetier::get_name() const { return "Repetier"; }
|
||||||
@ -41,7 +41,7 @@ bool Repetier::test(wxString &msg) const
|
|||||||
const char *name = get_name();
|
const char *name = get_name();
|
||||||
|
|
||||||
bool res = true;
|
bool res = true;
|
||||||
auto url = make_url("printer/version");
|
auto url = make_url("printer/info");
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: List version at: %2%") % name % url;
|
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: List version at: %2%") % name % url;
|
||||||
|
|
||||||
@ -61,20 +61,11 @@ bool Repetier::test(wxString &msg) const
|
|||||||
pt::ptree ptree;
|
pt::ptree ptree;
|
||||||
pt::read_json(ss, ptree);
|
pt::read_json(ss, ptree);
|
||||||
|
|
||||||
/*
|
const auto text = ptree.get_optional<std::string>("name");
|
||||||
const auto error = ptree.get_optional<std::string>("error");
|
res = validate_version_text(text);
|
||||||
if (error) {
|
if (! res) {
|
||||||
msg = GUI::from_u8((boost::format(_utf8(L("%s"))) % error).str());
|
msg = GUI::from_u8((boost::format(_utf8(L("Mismatched type of print host: %s"))) % (text ? *text : "Repetier")).str());
|
||||||
res = false;
|
|
||||||
} else {
|
|
||||||
BOOST_FOREACH(boost::property_tree::ptree::value_type &v, ptree.get_child("data.")) {
|
|
||||||
const auto slug = v.second.get<std::string>("slug");
|
|
||||||
slugs.push_back(slug);
|
|
||||||
}
|
|
||||||
|
|
||||||
//res = !printers.empty();
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
catch (const std::exception &) {
|
catch (const std::exception &) {
|
||||||
res = false;
|
res = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user