Skip to content

Commit dfc9671

Browse files
author
remi durand
committed
Merge branch 'merill-merge'
2 parents d4f5d64 + daa2c66 commit dfc9671

21 files changed

+700
-94
lines changed

resources/ui_layout/print.ui

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,40 @@ group:Autospeed (advanced)
258258

259259
page:Width & Flow:width
260260
group:Extrusion width
261-
setting:extrusion_width
262-
setting:first_layer_extrusion_width
263-
setting:perimeter_extrusion_width
264-
setting:external_perimeter_extrusion_width
265-
setting:infill_extrusion_width
266-
setting:solid_infill_extrusion_width
267-
setting:top_infill_extrusion_width
268-
setting:support_material_extrusion_width
269-
setting:skirt_extrusion_width
261+
line:default
262+
setting:sidetext_width$10:label$width:extrusion_width
263+
setting:sidetext_width$10:label_width$15:label$spacing:extrusion_spacing
264+
end_line
265+
line:first layer
266+
setting:sidetext_width$10:label$width:first_layer_extrusion_width
267+
setting:sidetext_width$10:label_width$15:label$spacing:first_layer_extrusion_spacing
268+
end_line
269+
line:perimeter
270+
setting:sidetext_width$10:label$width:perimeter_extrusion_width
271+
setting:sidetext_width$10:label_width$15:label$spacing:perimeter_extrusion_spacing
272+
end_line
273+
line:external perimeter
274+
setting:sidetext_width$10:label$width:external_perimeter_extrusion_width
275+
setting:sidetext_width$10:label_width$15:label$width&spacing combo:external_perimeter_extrusion_spacing
276+
end_line
277+
line:infill
278+
setting:sidetext_width$10:label$width:infill_extrusion_width
279+
setting:sidetext_width$10:label_width$15:label$spacing:infill_extrusion_spacing
280+
end_line
281+
line:solid infill
282+
setting:sidetext_width$10:label$width:solid_infill_extrusion_width
283+
setting:sidetext_width$10:label_width$15:label$spacing:solid_infill_extrusion_spacing
284+
end_line
285+
line:top infill
286+
setting:sidetext_width$10:label$width:top_infill_extrusion_width
287+
setting:sidetext_width$10:label_width$15:label$spacing:top_infill_extrusion_spacing
288+
end_line
289+
line:support material
290+
setting:sidetext_width$10:label$width:support_material_extrusion_width
291+
end_line
292+
line:skirt
293+
setting:sidetext_width$10:label$width:skirt_extrusion_width
294+
end_line
270295
recommended_extrusion_width_description
271296
group:Overlap
272297
line:Perimeter overlap

src/libslic3r/Config.cpp

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,9 @@ t_config_option_keys ConfigBase::diff(const ConfigBase &other) const
473473
for (const t_config_option_key &opt_key : this->keys()) {
474474
const ConfigOption *this_opt = this->option(opt_key);
475475
const ConfigOption *other_opt = other.option(opt_key);
476-
if (this_opt != nullptr && other_opt != nullptr && *this_opt != *other_opt)
476+
//dirty if both exist, they aren't both phony and value is different
477+
if (this_opt != nullptr && other_opt != nullptr && !(this_opt->phony && other_opt->phony)
478+
&& ((*this_opt != *other_opt) || (this_opt->phony != other_opt->phony)))
477479
diff.emplace_back(opt_key);
478480
}
479481
return diff;
@@ -495,6 +497,8 @@ std::string ConfigBase::opt_serialize(const t_config_option_key &opt_key) const
495497
{
496498
const ConfigOption* opt = this->option(opt_key);
497499
assert(opt != nullptr);
500+
if (opt->phony)
501+
return "";
498502
return opt->serialize();
499503
}
500504

@@ -584,7 +588,19 @@ bool ConfigBase::set_deserialize_raw(const t_config_option_key &opt_key_src, con
584588
ConfigOption *opt = this->option(opt_key, true);
585589
if (opt == nullptr)
586590
throw new UnknownOptionException(opt_key);
587-
bool ok= opt->deserialize(value, append);
591+
592+
bool ok = true;
593+
if (!optdef->can_phony || value != "")
594+
ok = opt->deserialize(value, append);
595+
//set phony status
596+
if (optdef->can_phony)
597+
if(value == "")
598+
opt->phony = true;
599+
else
600+
opt->phony = false;
601+
else
602+
opt->phony = false;
603+
588604
return ok;
589605
}
590606

@@ -798,13 +814,21 @@ size_t ConfigBase::load_from_gcode_string(const char* str)
798814
return num_key_value_pairs;
799815
}
800816

801-
void ConfigBase::save(const std::string &file) const
817+
void ConfigBase::save(const std::string &file, bool to_prusa) const
802818
{
803819
boost::nowide::ofstream c;
804820
c.open(file, std::ios::out | std::ios::trunc);
805821
c << "# " << Slic3r::header_slic3r_generated() << std::endl;
806-
for (const std::string &opt_key : this->keys())
807-
c << opt_key << " = " << this->opt_serialize(opt_key) << std::endl;
822+
if (to_prusa)
823+
for (std::string opt_key : this->keys()) {
824+
std::string value = this->opt_serialize(opt_key);
825+
this->to_prusa(opt_key, value);
826+
if(!opt_key.empty())
827+
c << opt_key << " = " << value << std::endl;
828+
}
829+
else
830+
for (const std::string &opt_key : this->keys())
831+
c << opt_key << " = " << this->opt_serialize(opt_key) << std::endl;
808832
c.close();
809833
}
810834

src/libslic3r/Config.hpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ inline OutputFormat operator&=(OutputFormat& a, OutputFormat b) {
214214
// A generic value of a configuration option.
215215
class ConfigOption {
216216
public:
217+
// if true, this option doesn't need to be saved, it's a computed value from an other configOption.
218+
bool phony;
219+
220+
ConfigOption() : phony(false) {}
221+
ConfigOption(bool phony) : phony(phony) {}
222+
217223
virtual ~ConfigOption() {}
218224

219225
virtual ConfigOptionType type() const = 0;
@@ -258,6 +264,7 @@ class ConfigOptionSingle : public ConfigOption {
258264
public:
259265
T value;
260266
explicit ConfigOptionSingle(T value) : value(value) {}
267+
explicit ConfigOptionSingle(T value, bool phony) : ConfigOption(phony), value(value) {}
261268
operator T() const { return this->value; }
262269

263270
void set(const ConfigOption *rhs) override
@@ -266,6 +273,7 @@ class ConfigOptionSingle : public ConfigOption {
266273
throw Slic3r::RuntimeError("ConfigOptionSingle: Assigning an incompatible type");
267274
assert(dynamic_cast<const ConfigOptionSingle<T>*>(rhs));
268275
this->value = static_cast<const ConfigOptionSingle<T>*>(rhs)->value;
276+
this->phony = rhs->phony;
269277
}
270278

271279
bool operator==(const ConfigOption &rhs) const override
@@ -340,6 +348,7 @@ class ConfigOptionVector : public ConfigOptionVectorBase
340348
throw Slic3r::RuntimeError("ConfigOptionVector: Assigning an incompatible type");
341349
assert(dynamic_cast<const ConfigOptionVector<T>*>(rhs));
342350
this->values = static_cast<const ConfigOptionVector<T>*>(rhs)->values;
351+
this->phony = rhs->phony;
343352
}
344353

345354
// Set from a vector of ConfigOptions.
@@ -504,6 +513,7 @@ class ConfigOptionFloat : public ConfigOptionSingle<double>
504513
public:
505514
ConfigOptionFloat() : ConfigOptionSingle<double>(0) {}
506515
explicit ConfigOptionFloat(double _value) : ConfigOptionSingle<double>(_value) {}
516+
explicit ConfigOptionFloat(double _value, bool _phony) : ConfigOptionSingle<double>(_value, _phony) {}
507517

508518
static ConfigOptionType static_type() { return coFloat; }
509519
ConfigOptionType type() const override { return static_type(); }
@@ -850,6 +860,7 @@ class ConfigOptionPercent : public ConfigOptionFloat
850860
public:
851861
ConfigOptionPercent() : ConfigOptionFloat(0) {}
852862
explicit ConfigOptionPercent(double _value) : ConfigOptionFloat(_value) {}
863+
explicit ConfigOptionPercent(double _value, bool _phony) : ConfigOptionFloat(_value, _phony) {}
853864

854865
static ConfigOptionType static_type() { return coPercent; }
855866
ConfigOptionType type() const override { return static_type(); }
@@ -943,6 +954,7 @@ class ConfigOptionFloatOrPercent : public ConfigOptionPercent
943954
bool percent;
944955
ConfigOptionFloatOrPercent() : ConfigOptionPercent(0), percent(false) {}
945956
explicit ConfigOptionFloatOrPercent(double _value, bool _percent) : ConfigOptionPercent(_value), percent(_percent) {}
957+
explicit ConfigOptionFloatOrPercent(double _value, bool _percent, bool _phony) : ConfigOptionPercent(_value, _phony), percent(_percent) {}
946958

947959
static ConfigOptionType static_type() { return coFloatOrPercent; }
948960
ConfigOptionType type() const override { return static_type(); }
@@ -1427,6 +1439,7 @@ class ConfigOptionEnum : public ConfigOptionSingle<T>
14271439
throw Slic3r::RuntimeError("ConfigOptionEnum<T>: Assigning an incompatible type");
14281440
// rhs could be of the following type: ConfigOptionEnumGeneric or ConfigOptionEnum<T>
14291441
this->value = (T)rhs->getInt();
1442+
this->phony = rhs->phony;
14301443
}
14311444

14321445
std::string serialize() const override
@@ -1511,6 +1524,7 @@ class ConfigOptionEnumGeneric : public ConfigOptionInt
15111524
throw Slic3r::RuntimeError("ConfigOptionEnumGeneric: Assigning an incompatible type");
15121525
// rhs could be of the following type: ConfigOptionEnumGeneric or ConfigOptionEnum<T>
15131526
this->value = rhs->getInt();
1527+
this->phony = rhs->phony;
15141528
}
15151529

15161530
std::string serialize() const override
@@ -1658,7 +1672,9 @@ class ConfigOptionDef
16581672
// For text input: If true, the GUI formats text as code (fixed-width)
16591673
bool is_code = false;
16601674
// Not editable. Currently only used for the display of the number of threads.
1661-
bool readonly = false;
1675+
bool readonly = false;
1676+
// Can be phony. if not present at laoding, mark it as phony. Also adapt the gui to look for phony status.
1677+
bool can_phony = false;
16621678
// Height of a multiline GUI text box.
16631679
int height = -1;
16641680
// Optional width of an input field.
@@ -1907,7 +1923,7 @@ class ConfigBase : public ConfigOptionResolver
19071923
// Returns number of key/value pairs extracted.
19081924
size_t load_from_gcode_string(const char* str);
19091925
void load(const boost::property_tree::ptree &tree);
1910-
void save(const std::string &file) const;
1926+
void save(const std::string &file, bool to_prusa = false) const;
19111927

19121928
// Set all the nullable values to nils.
19131929
void null_nullables();

src/libslic3r/Fill/FillAdaptive.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ std::pair<double, double> adaptive_fill_line_spacing(const PrintObject &print_ob
299299
for (const PrintRegion *region : print_object.print()->regions()) {
300300
const PrintRegionConfig &config = region->config();
301301
bool nonempty = config.fill_density > 0;
302-
bool has_adaptive_infill = nonempty && config.fill_pattern == ipAdaptiveCubic;
303-
bool has_support_infill = nonempty && config.fill_pattern == ipSupportCubic;
302+
bool has_adaptive_infill = nonempty && config.fill_pattern.value == ipAdaptiveCubic;
303+
bool has_support_infill = nonempty && config.fill_pattern.value == ipSupportCubic;
304304
double infill_extrusion_width = config.infill_extrusion_width.get_abs_value(max_nozzle_diameter);
305305
region_fill_data.push_back(RegionFillData({
306306
has_adaptive_infill ? Tristate::Maybe : Tristate::No,

src/libslic3r/GCode.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessor::Result* re
743743
namespace DoExport {
744744
static void init_gcode_processor(const PrintConfig& config, GCodeProcessor& processor, bool& silent_time_estimator_enabled)
745745
{
746-
silent_time_estimator_enabled = (config.gcode_flavor == gcfMarlin) && config.silent_mode;
746+
silent_time_estimator_enabled = (config.gcode_flavor.value == gcfMarlin) && config.silent_mode;
747747
processor.reset();
748748
processor.apply_config(config);
749749
processor.enable_stealth_time_estimator(silent_time_estimator_enabled);
@@ -1490,7 +1490,7 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu
14901490
bbox_prime.offset(0.5f);
14911491
bool overlap = bbox_prime.overlap(bbox_print);
14921492

1493-
if (print.config().gcode_flavor == gcfMarlin) {
1493+
if (print.config().gcode_flavor.value == gcfMarlin) {
14941494
_write(file, this->retract());
14951495
_write(file, "M300 S800 P500\n"); // Beep for 500ms, tone 800Hz.
14961496
if (overlap) {
@@ -1727,14 +1727,14 @@ void GCode::print_machine_envelope(FILE *file, Print &print)
17271727
int(print.config().machine_max_acceleration_travel.values.front() + 0.5),
17281728
int(print.config().machine_max_acceleration_travel.values.front() + 0.5));
17291729
if (std::set<uint8_t>{gcfMarlin, gcfLerdge, gcfRepetier, gcfSmoothie, gcfSprinter}.count(print.config().gcode_flavor.value) > 0)
1730-
fprintf(file, (print.config().gcode_flavor == gcfMarlin || print.config().gcode_flavor == gcfSmoothie)
1730+
fprintf(file, (print.config().gcode_flavor.value == gcfMarlin || print.config().gcode_flavor.value == gcfSmoothie)
17311731
? "M203 X%d Y%d Z%d E%d ; sets maximum feedrates, mm/sec\n"
17321732
: "M203 X%d Y%d Z%d E%d ; sets maximum feedrates, mm/min\n",
17331733
int(print.config().machine_max_feedrate_x.values.front() + 0.5),
17341734
int(print.config().machine_max_feedrate_y.values.front() + 0.5),
17351735
int(print.config().machine_max_feedrate_z.values.front() + 0.5),
17361736
int(print.config().machine_max_feedrate_e.values.front() + 0.5));
1737-
if (print.config().gcode_flavor == gcfRepRap) {
1737+
if (print.config().gcode_flavor.value == gcfRepRap) {
17381738
fprintf(file, "M203 X%d Y%d Z%d E%d I%d; sets maximum feedrates, mm/min\n",
17391739
int(print.config().machine_max_feedrate_x.values.front() + 0.5),
17401740
int(print.config().machine_max_feedrate_y.values.front() + 0.5),
@@ -1806,7 +1806,7 @@ void GCode::_print_first_layer_extruder_temperatures(FILE *file, Print &print, c
18061806
{
18071807
// Is the bed temperature set by the provided custom G-code?
18081808
int temp_by_gcode = -1;
1809-
bool include_g10 = print.config().gcode_flavor == gcfRepRap;
1809+
bool include_g10 = print.config().gcode_flavor.value == gcfRepRap;
18101810
if (custom_gcode_sets_temperature(gcode, 104, 109, include_g10, temp_by_gcode)) {
18111811
// Set the extruder temperature at m_writer, but throw away the generated G-code as it will be written with the custom G-code.
18121812
int temp = print.config().first_layer_temperature.get_at(first_printing_extruder_id);
@@ -1819,14 +1819,14 @@ void GCode::_print_first_layer_extruder_temperatures(FILE *file, Print &print, c
18191819
// Custom G-code does not set the extruder temperature. Do it now.
18201820
if (!print.config().single_extruder_multi_material.value) {
18211821
// Set temperatures of all the printing extruders.
1822-
for (unsigned int tool_id : print.extruders()) {
1823-
int temp = print.config().first_layer_temperature.get_at(tool_id);
1822+
for (const Extruder& tool : m_writer.extruders()) {
1823+
int temp = print.config().first_layer_temperature.get_at(tool.id());
18241824
if (temp == 0)
1825-
temp = print.config().temperature.get_at(tool_id);
1825+
temp = print.config().temperature.get_at(tool.id());
18261826
if (print.config().ooze_prevention.value)
18271827
temp += print.config().standby_temperature_delta.value;
18281828
if (temp > 0)
1829-
_write(file, m_writer.set_temperature(temp, false, tool_id));
1829+
_write(file, m_writer.set_temperature(temp, false, tool.id()));
18301830
}
18311831
}
18321832
if (wait || print.config().single_extruder_multi_material.value) {

src/libslic3r/GCodeWriter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#include <map>
77
#include <assert.h>
88

9-
#define FLAVOR_IS(val) this->config.gcode_flavor == val
10-
#define FLAVOR_IS_NOT(val) this->config.gcode_flavor != val
11-
#define COMMENT(comment) if (this->config.gcode_comments && !comment.empty()) gcode << " ; " << comment;
9+
#define FLAVOR_IS(val) this->config.gcode_flavor.value == val
10+
#define FLAVOR_IS_NOT(val) this->config.gcode_flavor.value != val
11+
#define COMMENT(comment) if (this->config.gcode_comments.value && !comment.empty()) gcode << " ; " << comment;
1212
#define PRECISION(val, precision) std::fixed << std::setprecision(precision) << (val)
1313
#define XYZF_NUM(val) PRECISION(val, this->config.gcode_precision_xyz.value)
1414
#define E_NUM(val) PRECISION(val, this->config.gcode_precision_e.get_at(m_tool->id()))

src/libslic3r/PerimeterGenerator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void PerimeterGenerator::process()
156156
ExPolygons bridgeable = union_ex(detector.coverage(-1, true));
157157
if (!bridgeable.empty()) {
158158
//check if we get everything or just the bridgeable area
159-
if (this->config->no_perimeter_unsupported_algo == npuaNoPeri || this->config->no_perimeter_unsupported_algo == npuaFilled) {
159+
if (this->config->no_perimeter_unsupported_algo.value == npuaNoPeri || this->config->no_perimeter_unsupported_algo.value == npuaFilled) {
160160
//we bridge everything, even the not-bridgeable bits
161161
for (size_t i = 0; i < unsupported_filtered.size();) {
162162
ExPolygon &poly_unsupp = *(unsupported_filtered.begin() + i);
@@ -177,7 +177,7 @@ void PerimeterGenerator::process()
177177
}
178178
unsupported_filtered = intersection_ex(last,
179179
offset2_ex(unsupported_filtered, double(-perimeter_spacing / 2), double(perimeter_spacing * 3 / 2)));
180-
if (this->config->no_perimeter_unsupported_algo == npuaFilled) {
180+
if (this->config->no_perimeter_unsupported_algo.value == npuaFilled) {
181181
for (ExPolygon &expol : unsupported_filtered) {
182182
//check if the holes won't be covered by the upper layer
183183
//TODO: if we want to do that, we must modify the geometry before making perimeters.
@@ -227,7 +227,7 @@ void PerimeterGenerator::process()
227227

228228
}
229229
//TODO: add other polys as holes inside this one (-margin)
230-
} else if (this->config->no_perimeter_unsupported_algo == npuaBridgesOverhangs || this->config->no_perimeter_unsupported_algo == npuaBridges){
230+
} else if (this->config->no_perimeter_unsupported_algo.value == npuaBridgesOverhangs || this->config->no_perimeter_unsupported_algo.value == npuaBridges){
231231
//simplify to avoid most of artefacts from printing lines.
232232
ExPolygons bridgeable_simplified;
233233
for (ExPolygon &poly : bridgeable) {
@@ -246,7 +246,7 @@ void PerimeterGenerator::process()
246246
//unbridgeable = offset2_ex(unbridgeable, -ext_perimeter_width, ext_perimeter_width);
247247

248248

249-
if (this->config->no_perimeter_unsupported_algo == npuaBridges) {
249+
if (this->config->no_perimeter_unsupported_algo.value == npuaBridges) {
250250
ExPolygons unbridgeable = unsupported_filtered;
251251
for (ExPolygon &expol : unbridgeable)
252252
expol.holes.clear();

0 commit comments

Comments
 (0)