Skip to content

Commit

Permalink
#852 decimals for xyz & e are now configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
remi durand committed Feb 23, 2021
1 parent 55e6ead commit 201c612
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 4 deletions.
4 changes: 3 additions & 1 deletion resources/ui_layout/extruder.ui
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ group:Retraction when tool is disabled (advanced settings for multi-extruder set
setting:idx:retract_length_toolchange
setting:idx:retract_restart_extra_toolchange
group:Preview
reset_to_filament_color
reset_to_filament_color
group:Gcode
setting:gcode_precision_e
1 change: 1 addition & 0 deletions resources/ui_layout/printer_fff.ui
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ group:silent_mode_event:Firmware
setting:gcode_flavor
setting:silent_mode
setting:remaining_times
setting:gcode_precision_xyz
group:Cooling fan
line:Speedup
setting:label$Speedup time:fan_speedup_time
Expand Down
4 changes: 2 additions & 2 deletions src/libslic3r/GCodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#define FLAVOR_IS_NOT(val) this->config.gcode_flavor != val
#define COMMENT(comment) if (this->config.gcode_comments && !comment.empty()) gcode << " ; " << comment;
#define PRECISION(val, precision) std::fixed << std::setprecision(precision) << (val)
#define XYZF_NUM(val) PRECISION(val, 3)
#define E_NUM(val) PRECISION(val, 5)
#define XYZF_NUM(val) PRECISION(val, this->config.gcode_precision_xyz.value)
#define E_NUM(val) PRECISION(val, this->config.gcode_precision_e.get_at(m_tool->id()))

namespace Slic3r {

Expand Down
4 changes: 3 additions & 1 deletion src/libslic3r/Preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,9 @@ const std::vector<std::string>& Preset::printer_options()
"fan_kickstart",
"fan_speedup_overhangs",
"fan_speedup_time",
"gcode_flavor", "use_relative_e_distances",
"gcode_flavor",
"gcode_precision_xyz",
"use_relative_e_distances",
"use_firmware_retraction", "use_volumetric_e", "variable_layer_height",
"min_length",
//FIXME the print host keys are left here just for conversion from the Printer preset to Physical Printer preset.
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ bool Print::invalidate_state_by_config_options(const std::vector<t_config_option
"gap_fill_speed",
"gcode_comments",
"gcode_label_objects",
"gcode_precision_xyz",
"gcode_precision_e",
"infill_acceleration",
"layer_gcode",
"min_fan_speed",
Expand Down
15 changes: 15 additions & 0 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1876,6 +1876,20 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(1));

def = this->add("gcode_precision_xyz", coInt);
def->label = L("xyz decimals");
def->category = OptionCategory::output;
def->tooltip = L("Choose how many digit after the dot for xyz coordinates.");
def->mode = comExpert;
def->set_default_value(new ConfigOptionInt(3));

def = this->add("gcode_precision_e", coInts);
def->label = L("Extruder decimals");
def->category = OptionCategory::output;
def->tooltip = L("Choose how many digit after the dot for extruder moves.");
def->mode = comExpert;
def->set_default_value(new ConfigOptionInts{ 5 });

def = this->add("high_current_on_filament_swap", coBool);
def->label = L("High extruder current on filament swap");
def->category = OptionCategory::general;
Expand Down Expand Up @@ -4182,6 +4196,7 @@ void PrintConfigDef::init_extruder_option_keys()
"extruder_offset",
"extruder_fan_offset",
"extruder_temperature_offset",
"gcode_precision_e",
"tool_name",
"retract_length",
"retract_lift",
Expand Down
4 changes: 4 additions & 0 deletions src/libslic3r/PrintConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,8 @@ class GCodeConfig : public StaticPrintConfig
ConfigOptionBool gcode_comments;
ConfigOptionEnum<GCodeFlavor> gcode_flavor;
ConfigOptionBool gcode_label_objects;
ConfigOptionInt gcode_precision_xyz;
ConfigOptionInts gcode_precision_e;
ConfigOptionString layer_gcode;
ConfigOptionString feature_gcode;
ConfigOptionFloat max_print_speed;
Expand Down Expand Up @@ -1154,6 +1156,8 @@ class GCodeConfig : public StaticPrintConfig
OPT_PTR(gcode_comments);
OPT_PTR(gcode_flavor);
OPT_PTR(gcode_label_objects);
OPT_PTR(gcode_precision_xyz);
OPT_PTR(gcode_precision_e);
OPT_PTR(layer_gcode);
OPT_PTR(feature_gcode);
OPT_PTR(max_print_speed);
Expand Down

0 comments on commit 201c612

Please sign in to comment.