Skip to content

Commit

Permalink
test mac build
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Dec 29, 2023
2 parents c5c8cd3 + 9e51196 commit 3079669
Show file tree
Hide file tree
Showing 33 changed files with 220 additions and 203 deletions.
1 change: 1 addition & 0 deletions resources/ui_layout/default/printer_fff.ui
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ group:Thumbnails
line:Thumbnail options
setting:thumbnails_format
setting:thumbnails_with_bed
setting:thumbnails_tag_format
setting:thumbnails_end_file
end_line
group:Advanced
Expand Down
1 change: 1 addition & 0 deletions resources/ui_layout/default/printer_sla.ui
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ group:Thumbnails
line:Options
setting:thumbnails_with_bed
setting:thumbnails_with_support
setting:thumbnails_tag_format
end_line
group:Print Host upload
build_printhost
Expand Down
1 change: 1 addition & 0 deletions resources/ui_layout/example/printer_fff.ui
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ group:Thumbnails
line:Thumbnail options
setting:thumbnails_format
setting:thumbnails_with_bed
setting:thumbnails_tag_format
setting:thumbnails_end_file
end_line
group:Advanced
Expand Down
1 change: 1 addition & 0 deletions resources/ui_layout/example/printer_sla.ui
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ group:Thumbnails
line:Options
setting:thumbnails_with_bed
setting:thumbnails_with_support
setting:thumbnails_tag_format
end_line
group:Print Host upload
build_printhost
Expand Down
4 changes: 2 additions & 2 deletions src/PrusaSlicer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ int CLI::run(int argc, char **argv)

// The default bed shape should reflect the default display parameters
// and not the fff defaults.
double w = sla_print_config.display_width.get_float();
double h = sla_print_config.display_height.get_float();
double w = sla_print_config.display_width.get_float();
double h = sla_print_config.display_height.get_float();
sla_print_config.bed_shape.values = { Vec2d(0, 0), Vec2d(w, 0), Vec2d(w, h), Vec2d(0, h) };

sla_print_config.apply(m_print_config, true);
Expand Down
4 changes: 2 additions & 2 deletions src/libslic3r/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,8 @@ double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int ex
if (extruder_id < 0) {
const ConfigOption* opt_extruder_id = nullptr;
if ((opt_extruder_id = this->option("extruder")) == nullptr)
if ((opt_extruder_id = this->option("current_extruder")) == nullptr ||
opt_extruder_id->get_int() < 0 || opt_extruder_id->get_int() >= vector_opt->size()) {
if ((opt_extruder_id = this->option("current_extruder")) == nullptr
|| opt_extruder_id->get_int() < 0 || opt_extruder_id->get_int() >= vector_opt->size()) {
std::stringstream ss; ss << "ConfigBase::get_abs_value(): " << opt_key << " need to has the extuder id to get the right value, but it's not available";
throw ConfigurationError(ss.str());
}
Expand Down
173 changes: 76 additions & 97 deletions src/libslic3r/Config.hpp

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1377,13 +1377,15 @@ void GCode::_do_export(Print& print_mod, GCodeOutputStream &file, ThumbnailsGene
const ConfigOptionBool* thumbnails_end_file = print.full_print_config().option<ConfigOptionBool>("thumbnails_end_file");
if(!thumbnails_end_file || !thumbnails_end_file->value) {
const ConfigOptionBool* thumbnails_with_bed = print.full_print_config().option<ConfigOptionBool>("thumbnails_with_bed");
const ConfigOptionBool* thumbnails_tag_with_format = print.full_print_config().option<ConfigOptionBool>("thumbnails_tag_format");
const ConfigOptionEnum<GCodeThumbnailsFormat>* thumbnails_format = print.full_print_config().option<ConfigOptionEnum<GCodeThumbnailsFormat>>("thumbnails_format");
// Unit tests or command line slicing may not define "thumbnails" or "thumbnails_format".
// If "thumbnails_format" is not defined, export to PNG.
GCodeThumbnails::export_thumbnails_to_file(thumbnail_cb,
print.full_print_config().option<ConfigOptionPoints>("thumbnails")->values,
thumbnails_with_bed == nullptr ? false : thumbnails_with_bed->value,
thumbnails_with_bed ? thumbnails_with_bed->value : false,
thumbnails_format ? thumbnails_format->value : GCodeThumbnailsFormat::PNG,
thumbnails_tag_with_format ? thumbnails_tag_with_format->value : false,
[&file](const char* sz) { file.write(sz); },
[&print]() { print.throw_if_canceled(); });
}
Expand Down Expand Up @@ -2085,13 +2087,15 @@ void GCode::_do_export(Print& print_mod, GCodeOutputStream &file, ThumbnailsGene
//print thumbnails at the end instead of the start if requested
if (thumbnails_end_file && thumbnails_end_file->value) {
const ConfigOptionBool* thumbnails_with_bed = print.full_print_config().option<ConfigOptionBool>("thumbnails_with_bed");
const ConfigOptionBool* thumbnails_tag_with_format = print.full_print_config().option<ConfigOptionBool>("thumbnails_tag_format");
const ConfigOptionEnum<GCodeThumbnailsFormat>* thumbnails_format = print.full_print_config().option<ConfigOptionEnum<GCodeThumbnailsFormat>>("thumbnails_format");
// Unit tests or command line slicing may not define "thumbnails" or "thumbnails_format".
// If "thumbnails_format" is not defined, export to PNG.
GCodeThumbnails::export_thumbnails_to_file(thumbnail_cb,
print.full_print_config().option<ConfigOptionPoints>("thumbnails")->values,
thumbnails_with_bed==nullptr? false:thumbnails_with_bed->value,
thumbnails_with_bed ? thumbnails_with_bed->value : false,
thumbnails_format ? thumbnails_format->value : GCodeThumbnailsFormat::PNG,
thumbnails_tag_with_format ? thumbnails_tag_with_format->value: false,
[&file](const char* sz) { file.write(sz); },
[&print]() { print.throw_if_canceled(); });
}
Expand Down Expand Up @@ -5436,7 +5440,7 @@ double_t GCode::_compute_speed_mm_per_sec(const ExtrusionPath& path, double spee


void GCode::cooldown_marker_init() {
if (!_cooldown_marker_speed[ExtrusionRole::erExternalPerimeter].empty()) {
if (_cooldown_marker_speed[ExtrusionRole::erExternalPerimeter].empty()) {
std::string allow_speed_change = ";CM_extrude_speed;_EXTRUDE_SET_SPEED";
//only change speed on external perimeter (and similar) speed if really necessary.
std::string maybe_allow_speed_change = ";CM_extrude_speed_external;_EXTRUDE_SET_SPEED_MAYBE";
Expand Down
17 changes: 15 additions & 2 deletions src/libslic3r/GCode/CoolingBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void CoolingBuffer::reset(const Vec3d &position)
struct CoolingLine
{
enum Type : uint32_t {
TYPE_NONE = 0,
//first 5 bits are for the extrusiontype (not a flag)

TYPE_SET_TOOL = 1 << 7,
Expand Down Expand Up @@ -401,6 +402,8 @@ std::vector<PerExtruderAdjustments> CoolingBuffer::parse_layer_gcode(const std::
// Index of an existing CoolingLine of the current adjustment, which holds the feedrate setting command
// for a sequence of extrusion moves.
size_t active_speed_modifier = size_t(-1);
// type to add to each next G1 (just for adjustable for now)
size_t current_stamp = CoolingLine::TYPE_NONE;

for (; *line_start != 0; line_start = line_end)
{
Expand Down Expand Up @@ -460,10 +463,13 @@ std::vector<PerExtruderAdjustments> CoolingBuffer::parse_layer_gcode(const std::
if (wipe)
line.type |= CoolingLine::TYPE_WIPE;
if (boost::contains(sline, ";_EXTRUDE_SET_SPEED") && ! wipe) {
line.type |= CoolingLine::TYPE_ADJUSTABLE;
active_speed_modifier = adjustment->lines.size();
if (boost::contains(sline, ";_EXTRUDE_SET_SPEED_MAYBE"))
line.type |= CoolingLine::TYPE_ADJUSTABLE;
current_stamp |= CoolingLine::TYPE_ADJUSTABLE;
if (boost::contains(sline, ";_EXTRUDE_SET_SPEED_MAYBE")) {
line.type |= CoolingLine::TYPE_ADJUSTABLE_MAYBE;
current_stamp |= CoolingLine::TYPE_ADJUSTABLE_MAYBE;
}
}
if ((line.type & CoolingLine::TYPE_G92) == 0) {
// G0 or G1. Calculate the duration.
Expand Down Expand Up @@ -494,6 +500,12 @@ std::vector<PerExtruderAdjustments> CoolingBuffer::parse_layer_gcode(const std::
line.length = std::abs(dif[3]);
}
line.feedrate = new_pos[4];
if (line.feedrate > 0.f && line.length > 0.f) {
assert((line.type & CoolingLine::TYPE_ADJUSTABLE) == 0);
// there can be no active_speed_modifier in custom gcode.
assert(active_speed_modifier != size_t(-1) || current_stamp == CoolingLine::TYPE_NONE);
line.type |= current_stamp;
}
assert((line.type & CoolingLine::TYPE_ADJUSTABLE) == 0 || line.feedrate > 0.f);
if (line.length > 0) {
assert(line.feedrate > 0);
Expand Down Expand Up @@ -546,6 +558,7 @@ std::vector<PerExtruderAdjustments> CoolingBuffer::parse_layer_gcode(const std::
}
}
active_speed_modifier = size_t(-1);
current_stamp = CoolingLine::TYPE_NONE;
} else if (boost::starts_with(sline, ";_TOOLCHANGE")) {
//not using m_toolchange_prefix anymore because there is no use case for it, there is always a _TOOLCHANGE for when a fan change is needed.
int prefix = 13;
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/GCode/Thumbnails.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using namespace std::literals;
struct CompressedPNG : CompressedImageBuffer
{
~CompressedPNG() override { if (data) mz_free(data); }
std::string_view tag() const override { return "thumbnail"sv; }
std::string_view tag() const override { return "thumbnail_PNG"sv; }
};

struct CompressedJPG : CompressedImageBuffer
Expand Down
20 changes: 16 additions & 4 deletions src/libslic3r/GCode/Thumbnails.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace Slic3r::GCodeThumbnails {

constexpr std::string_view EMPTY_TAG = "thumbnail";

struct CompressedImageBuffer
{
void *data { nullptr };
Expand All @@ -24,7 +26,13 @@ struct CompressedImageBuffer
std::unique_ptr<CompressedImageBuffer> compress_thumbnail(const ThumbnailData &data, GCodeThumbnailsFormat format);

template<typename WriteToOutput, typename ThrowIfCanceledCallback>
inline void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb, const std::vector<Vec2d> &sizes, bool with_bed, GCodeThumbnailsFormat format, WriteToOutput output, ThrowIfCanceledCallback throw_if_canceled)
inline void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb,
const std::vector<Vec2d> & sizes,
bool with_bed,
GCodeThumbnailsFormat format,
bool with_tag_format,
WriteToOutput output,
ThrowIfCanceledCallback throw_if_canceled)
{
// Write thumbnails using base64 encoding
if (thumbnail_cb != nullptr) {
Expand All @@ -43,7 +51,9 @@ inline void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb,
auto compressed = compress_thumbnail(data, format);
if (compressed->data && compressed->size) {
if (format == GCodeThumbnailsFormat::BIQU) {
output((boost::format("\n;\n; %s begin %dx%d %d\n") % compressed->tag() % data.width % data.height % (compressed->size - 1)).str().c_str());
output((boost::format("\n;\n; %s begin %dx%d %d\n")
% (with_tag_format ? compressed->tag() : EMPTY_TAG)
% data.width % data.height % (compressed->size - 1)).str().c_str());
//print size in hex
std::stringstream ss;
ss << std::setfill('0') << std::hex;
Expand All @@ -60,7 +70,9 @@ inline void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb,
encoded.resize(boost::beast::detail::base64::encoded_size(compressed->size));
encoded.resize(boost::beast::detail::base64::encode((void*)encoded.data(), (const void*)compressed->data, compressed->size));

output((boost::format("\n;\n; %s begin %dx%d %d\n") % compressed->tag() % data.width % data.height % encoded.size()).str().c_str());
output((boost::format("\n;\n; %s begin %dx%d %d\n")
% (with_tag_format ? compressed->tag() : EMPTY_TAG)
% data.width % data.height % encoded.size()).str().c_str());
while (encoded.size() > max_row_length) {
output((boost::format("; %s\n") % encoded.substr(0, max_row_length)).str().c_str());
encoded = encoded.substr(max_row_length);
Expand All @@ -69,7 +81,7 @@ inline void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb,
if (encoded.size() > 0)
output((boost::format("; %s\n") % encoded).str().c_str());
}
output((boost::format("; %s end\n;\n") % compressed->tag()).str().c_str());
output((boost::format("; %s end\n;\n") % (with_tag_format ? compressed->tag() : EMPTY_TAG)).str().c_str());
}
throw_if_canceled();
}
Expand Down
8 changes: 4 additions & 4 deletions src/libslic3r/PlaceholderParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ namespace client
case coFloat: output.set_d(opt.opt->get_float()); break;
case coInt: output.set_i(opt.opt->get_int()); break;
case coString: output.set_s(static_cast<const ConfigOptionString*>(opt.opt)->value); break;
case coPercent: output.set_d(opt.opt->get_float()); break;
case coPercent: output.set_d(opt.opt->get_float()); break;
case coPoint: output.set_s(opt.opt->serialize()); break;
case coBool: output.set_b(opt.opt->get_bool()); break;
case coFloatOrPercent:
Expand Down Expand Up @@ -969,7 +969,7 @@ namespace client
v *= val;
break;
// if (opt_parent->type() == coFloat || opt_parent->type() == coFloatOrPercent) {
// v *= opt_parent->getFloat();
// v *= opt_parent->get_float();
// if (opt_parent->type() == coFloat || ! static_cast<const ConfigOptionFloatOrPercent*>(opt_parent)->percent)
// break;
// v *= 0.01; // percent to ratio
Expand All @@ -985,15 +985,15 @@ namespace client
case coInts:
opt_def = print_config_def.get(opt_key);
if (opt_def->is_vector_extruder) {
output.set_i(int(((ConfigOptionVectorBase *) opt.opt)->get_float(int(ctx->current_extruder_id))));
output.set_i(int(((ConfigOptionVectorBase*)opt.opt)->get_float(int(ctx->current_extruder_id))));
break;
} else
ctx->throw_exception("Unknown scalar variable type", opt.it_range);
case coFloats:
case coPercents:
vector_opt = static_cast<const ConfigOptionVectorBase*>(opt.opt);
if (vector_opt->is_extruder_size()) {
output.set_d(((ConfigOptionVectorBase *) opt.opt)->get_float(int(ctx->current_extruder_id)));
output.set_d(((ConfigOptionVectorBase*)opt.opt)->get_float(int(ctx->current_extruder_id)));
break;
} else
ctx->throw_exception("Unknown scalar variable type", opt.it_range);
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/Preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ static std::vector<std::string> s_Preset_printer_options {
"thumbnails_custom_color",
"thumbnails_end_file",
"thumbnails_format",
"thumbnails_tag_format",
"thumbnails_with_bed",
"wipe_advanced",
"wipe_advanced_nozzle_melted_volume",
Expand Down Expand Up @@ -960,6 +961,7 @@ static std::vector<std::string> s_Preset_sla_printer_options {
"thumbnails_color",
"thumbnails_custom_color",
"thumbnails_with_bed",
"thumbnails_tag_format",
"thumbnails_with_support",
};

Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver& /* ne
"thumbnails_custom_color",
"thumbnails_end_file",
"thumbnails_format",
"thumbnails_tag_format",
"thumbnails_with_bed",
"time_estimation_compensation",
"time_cost",
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/PrintApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static inline void layer_height_ranges_copy_configs(t_layer_config_ranges &lr_ds
assert(std::abs(kvp_dst.first.first - kvp_src.first.first ) <= EPSILON);
assert(std::abs(kvp_dst.first.second - kvp_src.first.second) <= EPSILON);
// Layer heights are allowed do differ in case the layer height table is being overriden by the smooth profile.
// assert(std::abs(kvp_dst.second.option("layer_height")->getFloat() - kvp_src.second.option("layer_height")->getFloat()) <= EPSILON);
// assert(std::abs(kvp_dst.second.option("layer_height")->get_float() - kvp_src.second.option("layer_height")->get_float()) <= EPSILON);
kvp_dst.second = kvp_src.second;
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/libslic3r/PrintBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ std::string PrintBase::output_filename(const std::string &format, const std::str
cfg.set_key_value("input_filename_base", new ConfigOptionString(filename_base));
}
try {
uint16_t extruder_initial = config_override->option("initial_extruder") != nullptr &&
config_override->option("initial_extruder")->type() == coInt ? config_override->option("initial_extruder")->get_int() : 0;
uint16_t extruder_initial = config_override->option("initial_extruder") != nullptr && config_override->option("initial_extruder")->type() == coInt ? config_override->option("initial_extruder")->get_int() : 0;
boost::filesystem::path filepath = format.empty() ?
cfg.opt_string("input_filename_base") + default_ext :
this->placeholder_parser().process(format, extruder_initial, &cfg);
Expand Down
Loading

0 comments on commit 3079669

Please sign in to comment.