Merge branch 'master' into fs_svg_SPE-1517

This commit is contained in:
Filip Sykala - NTB T15p 2023-10-18 15:20:55 +02:00
commit 4088a4bcd6
15 changed files with 64 additions and 104 deletions

View File

@ -11,9 +11,24 @@
#include "objparser.hpp"
#include "libslic3r/LocalesUtils.hpp"
#include "fast_float/fast_float.h"
namespace ObjParser {
// To fix issues with obj loading on macOS Sonoma, we use the following function instead of strtod that
// was used before. Apparently the locales are not handled as they should. We already saw this before in
// https://github.com/prusa3d/PrusaSlicer/issues/10380.
static double strtod_clocale(const char* str, char const** str_end)
{
double val = 0.;
auto [pend, ec] = fast_float::from_chars(str, *str_end, val);
if (pend != str && ec != std::errc::result_out_of_range)
*str_end = pend; // success
else
*str_end = str;
return val;
}
static bool obj_parseline(const char *line, ObjData &data)
{
#define EATWS() while (*line == ' ' || *line == '\t') ++ line
@ -45,15 +60,15 @@ static bool obj_parseline(const char *line, ObjData &data)
if (c2 != ' ' && c2 != '\t')
return false;
EATWS();
char *endptr = 0;
double u = strtod(line, &endptr);
const char *endptr = 0;
double u = strtod_clocale(line, &endptr);
if (endptr == 0 || (*endptr != ' ' && *endptr != '\t'))
return false;
line = endptr;
EATWS();
double v = 0;
if (*line != 0) {
v = strtod(line, &endptr);
v = strtod_clocale(line, &endptr);
if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0))
return false;
line = endptr;
@ -61,7 +76,7 @@ static bool obj_parseline(const char *line, ObjData &data)
}
double w = 0;
if (*line != 0) {
w = strtod(line, &endptr);
w = strtod_clocale(line, &endptr);
if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0))
return false;
line = endptr;
@ -82,18 +97,18 @@ static bool obj_parseline(const char *line, ObjData &data)
if (c2 != ' ' && c2 != '\t')
return false;
EATWS();
char *endptr = 0;
double x = strtod(line, &endptr);
const char *endptr = 0;
double x = strtod_clocale(line, &endptr);
if (endptr == 0 || (*endptr != ' ' && *endptr != '\t'))
return false;
line = endptr;
EATWS();
double y = strtod(line, &endptr);
double y = strtod_clocale(line, &endptr);
if (endptr == 0 || (*endptr != ' ' && *endptr != '\t'))
return false;
line = endptr;
EATWS();
double z = strtod(line, &endptr);
double z = strtod_clocale(line, &endptr);
if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0))
return false;
line = endptr;
@ -112,20 +127,20 @@ static bool obj_parseline(const char *line, ObjData &data)
if (c2 != ' ' && c2 != '\t')
return false;
EATWS();
char *endptr = 0;
double u = strtod(line, &endptr);
const char *endptr = 0;
double u = strtod_clocale(line, &endptr);
if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0))
return false;
line = endptr;
EATWS();
double v = strtod(line, &endptr);
double v = strtod_clocale(line, &endptr);
if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0))
return false;
line = endptr;
EATWS();
double w = 0;
if (*line != 0) {
w = strtod(line, &endptr);
w = strtod_clocale(line, &endptr);
if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0))
return false;
line = endptr;
@ -144,25 +159,25 @@ static bool obj_parseline(const char *line, ObjData &data)
if (c2 != ' ' && c2 != '\t')
return false;
EATWS();
char *endptr = 0;
double x = strtod(line, &endptr);
const char *endptr = 0;
double x = strtod_clocale(line, &endptr);
if (endptr == 0 || (*endptr != ' ' && *endptr != '\t'))
return false;
line = endptr;
EATWS();
double y = strtod(line, &endptr);
double y = strtod_clocale(line, &endptr);
if (endptr == 0 || (*endptr != ' ' && *endptr != '\t'))
return false;
line = endptr;
EATWS();
double z = strtod(line, &endptr);
double z = strtod_clocale(line, &endptr);
if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0))
return false;
line = endptr;
EATWS();
double w = 1.0;
if (*line != 0) {
w = strtod(line, &endptr);
w = strtod_clocale(line, &endptr);
if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0))
return false;
line = endptr;

View File

@ -3071,7 +3071,6 @@ std::string GCodeGenerator::_extrude(
Vec2d prev = GCodeFormatter::quantize(prev_exact);
auto it = path.begin();
auto end = path.end();
const bool emit_radius = m_config.arc_fitting == ArcFittingType::EmitRadius;
for (++ it; it != end; ++ it) {
Vec2d p_exact = this->point_to_gcode(it->point);
Vec2d p = GCodeFormatter::quantize(p_exact);
@ -3082,14 +3081,9 @@ std::string GCodeGenerator::_extrude(
Vec2d ij;
if (it->radius != 0) {
// Extrude an arc.
assert(m_config.arc_fitting == ArcFittingType::EmitCenter ||
m_config.arc_fitting == ArcFittingType::EmitRadius);
assert(m_config.arc_fitting == ArcFittingType::EmitCenter);
radius = unscaled<double>(it->radius);
if (emit_radius) {
// Only quantize radius if emitting it directly into G-code. Otherwise use the exact radius for calculating the IJ values.
//FIXME rather re-fit the arc to improve accuracy!
radius = GCodeFormatter::quantize_xyzf(radius);
} else {
{
// Calculate quantized IJ circle center offset.
ij = GCodeFormatter::quantize(Vec2d(
Geometry::ArcWelder::arc_center(prev_exact.cast<double>(), p_exact.cast<double>(), double(radius), it->ccw())
@ -3112,9 +3106,7 @@ std::string GCodeGenerator::_extrude(
path_length += line_length;
const double dE = e_per_mm * line_length;
assert(dE > 0);
gcode += emit_radius ?
m_writer.extrude_to_xy_G2G3R(p, radius, it->ccw(), dE, comment) :
m_writer.extrude_to_xy_G2G3IJ(p, ij, it->ccw(), dE, comment);
gcode += m_writer.extrude_to_xy_G2G3IJ(p, ij, it->ccw(), dE, comment);
}
prev = p;
prev_exact = p_exact;

View File

@ -302,22 +302,6 @@ std::string GCodeWriter::travel_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &ij
return w.string();
}
std::string GCodeWriter::travel_to_xy_G2G3R(const Vec2d &point, const double radius, const bool ccw, const std::string_view comment)
{
assert(std::abs(point.x()) < 1200.);
assert(std::abs(point.y()) < 1200.);
assert(std::abs(radius) >= 0.001);
assert(std::abs(radius) < 1800.);
m_pos.head<2>() = point.head<2>();
GCodeG2G3Formatter w(ccw);
w.emit_xy(point);
w.emit_radius(radius);
w.emit_comment(this->config.gcode_comments, comment);
return w.string();
}
std::string GCodeWriter::travel_to_xyz(const Vec3d &point, const std::string_view comment)
{
// FIXME: This function was not being used when travel_speed_z was separated (bd6badf).
@ -431,25 +415,6 @@ std::string GCodeWriter::extrude_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &i
return w.string();
}
std::string GCodeWriter::extrude_to_xy_G2G3R(const Vec2d &point, const double radius, const bool ccw, double dE, const std::string_view comment)
{
assert(dE != 0);
assert(std::abs(dE) < 1000.0);
assert(std::abs(point.x()) < 1200.);
assert(std::abs(point.y()) < 1200.);
assert(std::abs(radius) >= 0.001);
assert(std::abs(radius) < 1800.);
m_pos.head<2>() = point.head<2>();
GCodeG2G3Formatter w(ccw);
w.emit_xy(point);
w.emit_radius(radius);
w.emit_e(m_extrusion_axis, m_extruder->extrude(dE).second);
w.emit_comment(this->config.gcode_comments, comment);
return w.string();
}
#if 0
std::string GCodeWriter::extrude_to_xyz(const Vec3d &point, double dE, const std::string_view comment)
{

View File

@ -69,13 +69,11 @@ public:
std::string set_speed(double F, const std::string_view comment = {}, const std::string_view cooling_marker = {}) const;
std::string travel_to_xy(const Vec2d &point, const std::string_view comment = {});
std::string travel_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &ij, const bool ccw, const std::string_view comment = {});
std::string travel_to_xy_G2G3R(const Vec2d &point, const double radius, const bool ccw, const std::string_view comment = {});
std::string travel_to_xyz(const Vec3d &point, const std::string_view comment = {});
std::string travel_to_z(double z, const std::string_view comment = {});
bool will_move_z(double z) const;
std::string extrude_to_xy(const Vec2d &point, double dE, const std::string_view comment = {});
std::string extrude_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &ij, const bool ccw, double dE, const std::string_view comment);
std::string extrude_to_xy_G2G3R(const Vec2d &point, const double radius, const bool ccw, double dE, const std::string_view comment);
// std::string extrude_to_xyz(const Vec3d &point, double dE, const std::string_view comment = {});
std::string retract(bool before_wipe = false);
std::string retract_for_toolchange(bool before_wipe = false);
@ -195,12 +193,6 @@ public:
this->emit_axis('J', point.y(), XYZF_EXPORT_DIGITS);
}
// Positive radius means a smaller arc,
// negative radius means a larger arc.
void emit_radius(const double radius) {
this->emit_axis('R', radius, XYZF_EXPORT_DIGITS);
}
void emit_e(const std::string_view axis, double v) {
if (! axis.empty()) {
// not gcfNoExtrusion

View File

@ -116,16 +116,15 @@ std::string Wipe::wipe(GCodeGenerator &gcodegen, bool toolchange)
retract_length -= dE;
return done;
};
const bool emit_radius = gcodegen.config().arc_fitting == ArcFittingType::EmitRadius;
auto wipe_arc = [&gcode, &gcodegen, &retract_length, xy_to_e, emit_radius, &wipe_linear](
auto wipe_arc = [&gcode, &gcodegen, &retract_length, xy_to_e, &wipe_linear](
const Vec2d &prev_quantized, Vec2d &p, double radius_in, const bool ccw) {
Vec2d p_quantized = GCodeFormatter::quantize(p);
if (p_quantized == prev_quantized) {
p = p_quantized;
return false;
}
// Only quantize radius if emitting it directly into G-code. Otherwise use the exact radius for calculating the IJ values.
double radius = emit_radius ? GCodeFormatter::quantize_xyzf(radius_in) : radius_in;
// Use the exact radius for calculating the IJ values, no quantization.
double radius = radius_in;
if (radius == 0)
// Degenerated arc after quantization. Process it as if it was a line segment.
return wipe_linear(prev_quantized, p);
@ -151,9 +150,7 @@ std::string Wipe::wipe(GCodeGenerator &gcodegen, bool toolchange)
} else
p = p_quantized;
assert(dE > 0);
if (emit_radius) {
gcode += gcodegen.writer().extrude_to_xy_G2G3R(p, radius, ccw, -dE, wipe_retract_comment);
} else {
{
// Calculate quantized IJ circle center offset.
Vec2d ij = GCodeFormatter::quantize(Vec2d(center - prev_quantized));
if (ij == Vec2d::Zero())

View File

@ -375,6 +375,7 @@ double arc_fit_max_deviation(const Point &start_point, const Point &end_point, c
const Points::const_iterator begin, const Points::const_iterator end);
// 1.2m diameter, maximum given by coord_t
static_assert(sizeof(coord_t) == 4);
static constexpr const double default_scaled_max_radius = scaled<double>(600.);
// 0.05mm
static constexpr const double default_scaled_resolution = scaled<double>(0.05);

View File

@ -465,7 +465,7 @@ static std::vector<std::string> s_Preset_print_options {
"ooze_prevention", "standby_temperature_delta", "interface_shells", "extrusion_width", "first_layer_extrusion_width",
"perimeter_extrusion_width", "external_perimeter_extrusion_width", "infill_extrusion_width", "solid_infill_extrusion_width",
"top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "infill_anchor", "infill_anchor_max", "bridge_flow_ratio",
"elefant_foot_compensation", "xy_size_compensation", "resolution", "gcode_resolution", "arc_fitting", "arc_fitting_tolerance",
"elefant_foot_compensation", "xy_size_compensation", "resolution", "gcode_resolution", "arc_fitting",
"wipe_tower", "wipe_tower_x", "wipe_tower_y",
"wipe_tower_width", "wipe_tower_cone_angle", "wipe_tower_rotation_angle", "wipe_tower_brim_width", "wipe_tower_bridging", "single_extruder_multi_material_priming", "mmu_segmented_region_max_width",
"mmu_segmented_region_interlocking_depth", "wipe_tower_extruder", "wipe_tower_no_sparse_layers", "wipe_tower_extra_spacing", "compatible_printers", "compatible_printers_condition", "inherits",

View File

@ -59,8 +59,7 @@ static t_config_enum_names enum_names_from_keys_map(const t_config_enum_values &
static const t_config_enum_values s_keys_map_ArcFittingType {
{ "disabled", int(ArcFittingType::Disabled) },
{ "emit_center", int(ArcFittingType::EmitCenter) },
{ "emit_radius", int(ArcFittingType::EmitRadius) }
{ "emit_center", int(ArcFittingType::EmitCenter) }
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(ArcFittingType)
@ -441,21 +440,11 @@ void PrintConfigDef::init_fff_params()
"G-code resolution will be used as the fitting tolerance.");
def->set_enum<ArcFittingType>({
{ "disabled", "Disabled" },
{ "emit_center", "Enabled: G2/3 I J" },
{ "emit_radius", "Enabled: G2/3 R" }
{ "emit_center", "Enabled: G2/3 I J" }
});
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionEnum<ArcFittingType>(ArcFittingType::Disabled));
def = this->add("arc_fitting_tolerance", coFloatOrPercent);
def->label = L("Arc fitting tolerance");
def->sidetext = L("mm or %");
def->tooltip = L("When using the arc_fitting option, allow the curve to deviate certain % from the collection of straight paths.\n"
"Can be either a mm value or a percentage of the current extrusion width.");
def->mode = comAdvanced;
def->min = 0;
def->set_default_value(new ConfigOptionFloatOrPercent(5, true));
// Maximum extruder temperature, bumped to 1500 to support printing of glass.
const int max_temp = 1500;
def = this->add("avoid_crossing_curled_overhangs", coBool);

View File

@ -49,8 +49,7 @@ namespace Slic3r {
enum class ArcFittingType {
Disabled,
EmitCenter,
EmitRadius,
EmitCenter
};
enum GCodeFlavor : unsigned char {
@ -701,7 +700,6 @@ PRINT_CONFIG_CLASS_DEFINE(
GCodeConfig,
((ConfigOptionEnum<ArcFittingType>, arc_fitting))
((ConfigOptionFloatOrPercent, arc_fitting_tolerance))
((ConfigOptionBool, autoemit_temperature_commands))
((ConfigOptionString, before_layer_gcode))
((ConfigOptionString, between_objects_gcode))

View File

@ -715,8 +715,7 @@ bool PrintObject::invalidate_state_by_config_options(
|| opt_key == "perimeter_extrusion_width"
|| opt_key == "infill_overlap"
|| opt_key == "external_perimeters_first"
|| opt_key == "arc_fitting"
|| opt_key == "arc_fitting_tolerance") {
|| opt_key == "arc_fitting") {
steps.emplace_back(posPerimeters);
} else if (
opt_key == "gap_fill_enabled"

View File

@ -345,9 +345,6 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config)
toggle_field("min_feature_size", have_arachne);
toggle_field("min_bead_width", have_arachne);
toggle_field("thin_walls", !have_arachne);
bool has_arc_fitting = config->opt_enum<ArcFittingType>("arc_fitting") != ArcFittingType::Disabled;
toggle_field("arc_fitting_tolerance", has_arc_fitting);
}
void ConfigManipulation::update_print_sla_config(DynamicPrintConfig* config, const bool is_global_config/* = false*/)

View File

@ -2448,7 +2448,7 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
// TODO: for when we're able to flash dictionaries
// local_menu->Append(config_id_base + FirmwareMenuDict, _L("Flash Language File"), _L("Upload a language dictionary file into a Prusa printer"));
}
local_menu->Append(config_id_base + ConfigMenuWifiConfigFile, _L("Wi-Fi Configuration File"), _L("Generate a file to be loaded by a Prusa printer to configure a Wi-Fi connection."));
local_menu->Append(config_id_base + ConfigMenuWifiConfigFile, _L("Wi-Fi Configuration File"), _L("Generate a file to be loaded by a Prusa printer to configure its Wi-Fi connection."));
local_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent &event) {
switch (event.GetId() - config_id_base) {

View File

@ -1677,7 +1677,6 @@ void TabPrint::build()
optgroup->append_single_option_line("resolution");
optgroup->append_single_option_line("gcode_resolution");
optgroup->append_single_option_line("arc_fitting");
optgroup->append_single_option_line("arc_fitting_tolerance");
optgroup->append_single_option_line("xy_size_compensation");
optgroup->append_single_option_line("elefant_foot_compensation", "elephant-foot-compensation_114487");

View File

@ -17,7 +17,7 @@ namespace Slic3r {
namespace GUI {
WifiConfigDialog::WifiConfigDialog(wxWindow* parent, std::string& file_path, RemovableDriveManager* removable_manager)
: DPIDialog(parent, wxID_ANY, _L("Physical Printer Instalation"), wxDefaultPosition, wxDefaultSize/*wxSize(25 * wxGetApp().em_unit(), 20 * wxGetApp().em_unit())*/, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
: DPIDialog(parent, wxID_ANY, _L("Wi-Fi Configuration File Generator"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
, m_wifi_scanner(new WifiScanner())
, out_file_path(file_path)
, m_removable_manager(removable_manager)
@ -28,6 +28,15 @@ WifiConfigDialog::WifiConfigDialog(wxWindow* parent, std::string& file_path, Rem
wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);
panel->SetSizer(vsizer);
// TRN Wifi config dialog explanation line 1.
wxStaticText* explain_label1 = new wxStaticText(panel, wxID_ANY, _L("Generate a file to be loaded by a Prusa printer to configure its Wi-Fi connection."));
// TRN Wifi config dialog explanation line 2.
wxStaticText* explain_label2 = new wxStaticText(panel, wxID_ANY, _L("Write this file on a USB flash drive. Its name will be prusa_printer_settings.ini."));
// TRN Wifi config dialog explanation line 3.
wxStaticText* explain_label3 = new wxStaticText(panel, wxID_ANY, _L("Your Prusa Printer should load this file automatically."));
// TRN Wifi config dialog explanation line 4.
wxStaticText* explain_label4 = new wxStaticText(panel, wxID_ANY, _L("Note: This file will contains SSID and password in plain text."));
auto* ssid_sizer = new wxBoxSizer(wxHORIZONTAL);
// TRN SSID of WiFi network.
wxStaticText* ssid_label = new wxStaticText(panel, wxID_ANY, GUI::format_wxstr("%1%:", _L("SSID")));
@ -36,6 +45,7 @@ WifiConfigDialog::WifiConfigDialog(wxWindow* parent, std::string& file_path, Rem
m_ssid_combo->SetToolTip(_L("On some versions of MacOS, this only loads SSID of connencted network."));
#endif // __APPLE__
rescan_networks(false);
// TRN Text of button to rescan visible networks in Wifi Config dialog.
wxButton* ssid_button = new wxButton(panel, wxID_ANY, _(L("Rescan")));
ssid_sizer->Add(m_ssid_combo, 1, wxALIGN_CENTER_VERTICAL, 10);
ssid_sizer->Add(ssid_button, 0);
@ -46,6 +56,7 @@ WifiConfigDialog::WifiConfigDialog(wxWindow* parent, std::string& file_path, Rem
m_pass_textctrl = new wxTextCtrl(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize);
pass_sizer->Add(m_pass_textctrl, 1, wxALIGN_CENTER_VERTICAL, 10);
#if __APPLE__
// TRN Text of button to retrieve password from keychain in Wifi Config dialog. Only on Mac.
wxButton* pass_button = new wxButton(panel, wxID_ANY, _(L("Retrieve")));
pass_sizer->Add(pass_button, 0);
pass_button->Bind(wxEVT_BUTTON, &WifiConfigDialog::on_retrieve_password, this);
@ -58,10 +69,12 @@ WifiConfigDialog::WifiConfigDialog(wxWindow* parent, std::string& file_path, Rem
wxStaticText* drive_label = new wxStaticText(panel, wxID_ANY, GUI::format_wxstr("%1%:", _L("Drive")));
m_drive_combo = new wxComboBox(panel, wxID_ANY);
rescan_drives();
// TRN Text of button to rescan connect usb drives in Wifi Config dialog.
wxButton* drive_button = new wxButton(panel, wxID_ANY, _(L("Rescan")));
drive_sizer->Add(m_drive_combo, 1, wxALIGN_CENTER_VERTICAL, 10);
drive_sizer->Add(drive_button, 0);
// TRN Text of button to write config file in Wifi Config dialog.
wxButton* ok_button = new wxButton(panel, wxID_OK, _L("Write"));
wxButton* cancel_button = new wxButton(panel, wxID_CANCEL);
@ -77,6 +90,10 @@ WifiConfigDialog::WifiConfigDialog(wxWindow* parent, std::string& file_path, Rem
grid->Add(drive_label, 0, wxALIGN_CENTER_VERTICAL);
grid->Add(drive_sizer, 0, wxEXPAND);
vsizer->Add(explain_label1, 0, wxALIGN_CENTER_VERTICAL);
vsizer->Add(explain_label2, 0, wxALIGN_CENTER_VERTICAL);
vsizer->Add(explain_label3, 0, wxALIGN_CENTER_VERTICAL);
vsizer->Add(explain_label4, 0, wxALIGN_CENTER_VERTICAL);
vsizer->Add(grid, 0, wxEXPAND | wxTOP | wxBOTTOM, 15);
wxBoxSizer* buttons_sizer = new wxBoxSizer(wxHORIZONTAL);

View File

@ -144,7 +144,6 @@ void fill_wifi_map(Slic3r::WifiSsidPskMap& wifi_map, std::string& connected_ssid
wxString xml(xmlstr);
boost::property_tree::ptree pt;
std::stringstream ss(boost::nowide::narrow(xml));
BOOST_LOG_TRIVIAL(error) << ss.str();
boost::property_tree::read_xml(ss, pt);
std::string password;
std::string psk_protected;