Skip to content

Commit

Permalink
Merge branch 'merill-merge'
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Sep 6, 2021
2 parents c582f36 + 2795295 commit 70d9ca8
Show file tree
Hide file tree
Showing 70 changed files with 1,944 additions and 980 deletions.
Binary file added resources/icons/Slic3r-gcodeviewer.ico
Binary file not shown.
Binary file added resources/icons/Slic3r-gcodeviewer_128px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icons/Slic3r-gcodeviewer_192px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icons/Slic3r-gcodeviewer_32px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions resources/ui_layout/extruder.ui
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ group:Retraction
setting:idx:retract_restart_extra
setting:idx:retract_before_travel
setting:idx:retract_layer_change
group:Retraction wipe
setting:idx:wipe
setting:idx:wipe_speed
setting:idx:retract_before_wipe
setting:idx:wipe_extra_perimeter
group:Retraction when tool is disabled (advanced settings for multi-extruder setups)
Expand Down
5 changes: 4 additions & 1 deletion resources/ui_layout/filament.ui
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ page:Cooling:time
group:Fan speed - default
setting:label$Run the fan at default speed when possible:fan_always_on
setting:min_fan_speed
setting:bridge_fan_speed
line:Bridges fan speed
setting:label$:bridge_fan_speed
setting:label$Infill bridges:bridge_internal_fan_speed
end_line
setting:top_fan_speed
setting:external_perimeter_fan_speed
line:Disable fan for the first
Expand Down
2 changes: 2 additions & 0 deletions resources/ui_layout/print.ui
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ group:Modifying slices
line:Convert round vertical holes to polyholes
setting:label$_:hole_to_polyhole
setting:hole_to_polyhole_threshold
setting:hole_to_polyhole_twisted
end_line
group:Other
setting:clip_multipart_objects
Expand Down Expand Up @@ -257,6 +258,7 @@ group:Speed for non-print moves
end_line
group:sidetext_width$7:Modifiers
line:First layer speed
setting:label_width$8:width$4:first_layer_min_speed
setting:label_width$8:width$4:first_layer_speed
setting:label_width$8:width$4:first_layer_infill_speed
end_line
Expand Down
6 changes: 5 additions & 1 deletion resources/ui_layout/printer_fff.ui
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ group:silent_mode_event:Firmware
setting:gcode_precision_xyz
setting:gcode_precision_e
end_line
line:Processing limit
setting:max_gcode_per_second
setting:min_length
end_line
setting:gcode_filename_illegal_char
group:Cooling fan
line:Speedup
setting:label$Speedup time:fan_speedup_time
Expand All @@ -40,7 +45,6 @@ group:Advanced
setting:use_relative_e_distances
setting:use_firmware_retraction
setting:use_volumetric_e
setting:min_length
setting:variable_layer_height

page:Custom G-code:cog
Expand Down
4 changes: 2 additions & 2 deletions src/PrusaSlicer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,8 @@ int CLI::run(int argc, char **argv)
sla_print.set_status_callback(
[](const PrintBase::SlicingStatus& s)
{
if(s.percent >= 0) // FIXME: is this sufficient?
printf("%3d%s %s\n", s.percent, "% =>", s.text.c_str());
if(s.percent >= 0 && s.args.empty()) // FIXME: is this sufficient?
printf("%3d%s %s\n", s.percent, "% =>", s.main_text.c_str());
});

PrintBase *print = (printer_technology == ptFFF) ? static_cast<PrintBase*>(&fff_print) : static_cast<PrintBase*>(&sla_print);
Expand Down
3 changes: 3 additions & 0 deletions src/libslic3r/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ void AppConfig::set_defaults()
if (get("freecad_path").empty())
set("freecad_path", ".");

if (get("show_overwrite_dialog").empty())
set("show_overwrite_dialog", "1");

if (get("tab_icon_size").empty())
set("tab_icon_size", "32");

Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/AppConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class AppConfig
std::string get_last_output_dir(const std::string& alt, const bool removable = false) const;
void update_last_output_dir(const std::string &dir, const bool removable = false);

bool get_show_overwrite_dialog() const { return get("show_overwrite_dialog") != "0"; }

// reset the current print / filament / printer selections, so that
// the PresetBundle::load_selections(const AppConfig &config) call will select
// the first non-default preset when called.
Expand Down
6 changes: 3 additions & 3 deletions src/libslic3r/Arrange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,10 @@ inline coord_t width(const BoundingBox& box) { return box.max.x() - box.min.x();
inline coord_t height(const BoundingBox& box) { return box.max.y() - box.min.y(); }
inline double area(const BoundingBox& box) { return double(width(box)) * height(box); }
inline double poly_area(const Points &pts) { return std::abs(Polygon::area(pts)); }
inline double distance_to(const Point& p1, const Point& p2)
inline coordf_t distance_to(const Point& p1, const Point& p2)
{
double dx = p2.x() - p1.x();
double dy = p2.y() - p1.y();
coordf_t dx = coordf_t(p2.x() - p1.x());
coordf_t dy = coordf_t(p2.y() - p1.y());
return std::sqrt(dx*dx + dy*dy);
}

Expand Down
6 changes: 3 additions & 3 deletions src/libslic3r/BoundingBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ BoundingBox3Base<PointClass>::size() const
template Vec3f BoundingBox3Base<Vec3f>::size() const;
template Vec3d BoundingBox3Base<Vec3d>::size() const;

template <class PointClass> double BoundingBoxBase<PointClass>::radius() const
template <class PointClass> coordf_t BoundingBoxBase<PointClass>::radius() const
{
assert(this->defined);
double x = this->max(0) - this->min(0);
double y = this->max(1) - this->min(1);
coordf_t x = coordf_t(this->max(0) - this->min(0));
coordf_t y = coordf_t(this->max(1) - this->min(1));
return 0.5 * sqrt(x*x+y*y);
}
template double BoundingBoxBase<Point>::radius() const;
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/BoundingBox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BoundingBoxBase
void merge(const BoundingBoxBase<PointClass> &bb);
void scale(double factor);
PointClass size() const;
double radius() const;
coordf_t radius() const;
void translate(coordf_t x, coordf_t y) { assert(this->defined); PointClass v(x, y); this->min += v; this->max += v; }
void translate(const Vec2d &v) { this->min += v; this->max += v; }
void offset(coordf_t delta);
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/ClipperUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ ExPolygons variable_offset_inner_ex(const ExPolygon &expoly, const std::vector<s
append(holes, fix_after_outer_offset(mittered_offset_path_scaled(hole.points, deltas[1 + &hole - expoly.holes.data()], miter_limit), ClipperLib::pftNegative, false));
//tiny holes can be reduced to giberish, get rid of them.
for (auto it = holes.begin(); it != holes.end();)
if (ClipperLib::Area(*it) < CLIPPER_OFFSET_SCALE*CLIPPER_OFFSET_SCALE) {
if (ClipperLib::Area(*it) < double(CLIPPER_OFFSET_SCALE) * double(CLIPPER_OFFSET_SCALE)) {
it = holes.erase(it);
}
else ++it;
Expand Down
133 changes: 88 additions & 45 deletions src/libslic3r/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,65 +657,108 @@ bool ConfigBase::set_deserialize_raw(const t_config_option_key &opt_key_src, con
opt->set_phony(false);
else
opt->set_phony(false);

if (optdef->is_vector_extruder)
static_cast<ConfigOptionVectorBase*>(opt)->set_is_extruder_size(true);
return success;
}

// Return an absolute value of a possibly relative config variable.
// For example, return absolute infill extrusion width, either from an absolute value, or relative to the layer height.
double ConfigBase::get_abs_value(const t_config_option_key &opt_key) const
double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int extruder_id) const
{
// Get stored option value.
const ConfigOption *raw_opt = this->option(opt_key);
if (raw_opt == nullptr) {
std::stringstream ss; ss << "You can't define an option that need " << opt_key << " without defining it!";
throw std::runtime_error(ss.str());
}
if (raw_opt->type() == coFloat)
return static_cast<const ConfigOptionFloat*>(raw_opt)->value;
if (raw_opt->type() == coInt)
return static_cast<const ConfigOptionInt*>(raw_opt)->value;
if (raw_opt->type() == coBool)
return static_cast<const ConfigOptionBool*>(raw_opt)->value?1:0;
const ConfigOptionDef* opt_def = nullptr;
const ConfigOptionPercent* cast_opt = nullptr;
if (raw_opt->type() == coFloatOrPercent) {
if(!static_cast<const ConfigOptionFloatOrPercent*>(raw_opt)->percent)
return static_cast<const ConfigOptionFloatOrPercent*>(raw_opt)->value;
// Get option definition.
const ConfigDef *def = this->def();
if (def == nullptr)
throw NoDefinitionException(opt_key);
opt_def = def->get(opt_key);
cast_opt = static_cast<const ConfigOptionFloatOrPercent*>(raw_opt);
assert(opt_def != nullptr);
}
if (raw_opt->type() == coPercent) {
// Get option definition.
const ConfigDef* def = this->def();
if (def == nullptr)
throw NoDefinitionException(opt_key);
opt_def = def->get(opt_key);
assert(opt_def != nullptr);
cast_opt = static_cast<const ConfigOptionPercent*>(raw_opt);
}
if (opt_def != nullptr) {
//if over no other key, it's most probably a simple %
if (opt_def->ratio_over == "")
return cast_opt->get_abs_value(1);
if (opt_def->ratio_over == "nozzle_diameter") {
//use the first... i guess.
//TODO: find a better way, like a "current_extruder_idx" config option.
if (this->option(opt_def->ratio_over) == nullptr) {
std::stringstream ss; ss << "ConfigBase::get_abs_value(): " << opt_key << " need nozzle_diameter but can't acess it. Please use get_abs_value(nozzle_diam).";
throw std::runtime_error(ss.str());

if (!raw_opt->is_vector()) {
if (raw_opt->type() == coFloat)
return static_cast<const ConfigOptionFloat*>(raw_opt)->value;
if (raw_opt->type() == coInt)
return static_cast<const ConfigOptionInt*>(raw_opt)->value;
if (raw_opt->type() == coBool)
return static_cast<const ConfigOptionBool*>(raw_opt)->value ? 1 : 0;
const ConfigOptionDef* opt_def = nullptr;
const ConfigOptionPercent* cast_opt = nullptr;
if (raw_opt->type() == coFloatOrPercent) {
if (!static_cast<const ConfigOptionFloatOrPercent*>(raw_opt)->percent)
return static_cast<const ConfigOptionFloatOrPercent*>(raw_opt)->value;
// Get option definition.
const ConfigDef* def = this->def();
if (def == nullptr)
throw NoDefinitionException(opt_key);
opt_def = def->get(opt_key);
cast_opt = static_cast<const ConfigOptionFloatOrPercent*>(raw_opt);
assert(opt_def != nullptr);
}
if (raw_opt->type() == coPercent) {
// Get option definition.
const ConfigDef* def = this->def();
if (def == nullptr)
throw NoDefinitionException(opt_key);
opt_def = def->get(opt_key);
assert(opt_def != nullptr);
cast_opt = static_cast<const ConfigOptionPercent*>(raw_opt);
}
if (opt_def != nullptr) {
//if over no other key, it's most probably a simple %
if (opt_def->ratio_over == "")
return cast_opt->get_abs_value(1);
// Compute absolute value over the absolute value of the base option.
//FIXME there are some ratio_over chains, which end with empty ratio_with.
// For example, XXX_extrusion_width parameters are not handled by get_abs_value correctly.
if (!opt_def->ratio_over.empty() && opt_def->ratio_over != "depends")
return cast_opt->get_abs_value(this->get_computed_value(opt_def->ratio_over));

std::stringstream ss; ss << "ConfigBase::get_abs_value(): " << opt_key << " has no valid ratio_over to compute of";
throw ConfigurationError(ss.str());
}
} else {
// check if it's an extruder_id array
const ConfigOptionVectorBase* vector_opt = static_cast<const ConfigOptionVectorBase*>(raw_opt);
if (vector_opt->is_extruder_size()) {
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->getInt() < 0 || opt_extruder_id->getInt() >= 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());
}
extruder_id = opt_extruder_id->getInt();
}

if (raw_opt->type() == coFloats || raw_opt->type() == coInts || raw_opt->type() == coBools)
return vector_opt->getFloat(extruder_id);
if (raw_opt->type() == coFloatsOrPercents) {
const ConfigOptionFloatsOrPercents* opt_fl_per = static_cast<const ConfigOptionFloatsOrPercents*>(raw_opt);
if (!opt_fl_per->values[extruder_id].percent)
return opt_fl_per->values[extruder_id].value;

const ConfigDef* def = this->def();
if (def == nullptr)
throw NoDefinitionException(opt_key);
const ConfigOptionDef* opt_def = def->get(opt_key);
if (!opt_def->ratio_over.empty() && opt_def->ratio_over != "depends")
return opt_fl_per->get_abs_value(extruder_id, this->get_computed_value(opt_def->ratio_over, extruder_id));
std::stringstream ss; ss << "ConfigBase::get_abs_value(): " << opt_key << " has no valid ratio_over to compute of";
throw ConfigurationError(ss.str());
}
if (raw_opt->type() == coPercents) {
const ConfigOptionPercents* opt_per = static_cast<const ConfigOptionPercents*>(raw_opt);
const ConfigDef* def = this->def();
if (def == nullptr)
throw NoDefinitionException(opt_key);
const ConfigOptionDef* opt_def = def->get(opt_key);
if (!opt_def->ratio_over.empty() && opt_def->ratio_over != "depends")
return opt_per->get_abs_value(extruder_id, this->get_computed_value(opt_def->ratio_over, extruder_id));
std::stringstream ss; ss << "ConfigBase::get_abs_value(): " << opt_key << " has no valid ratio_over to compute of";
throw ConfigurationError(ss.str());
}
return cast_opt->get_abs_value(static_cast<const ConfigOptionFloats*>(this->option(opt_def->ratio_over))->values[0]);
}
// Compute absolute value over the absolute value of the base option.
//FIXME there are some ratio_over chains, which end with empty ratio_with.
// For example, XXX_extrusion_width parameters are not handled by get_abs_value correctly.
return opt_def->ratio_over.empty() ? 0. :
cast_opt->get_abs_value(this->get_abs_value(opt_def->ratio_over));
}
std::stringstream ss; ss << "ConfigBase::get_abs_value(): "<< opt_key<<" has not a valid option type for get_abs_value()";
throw ConfigurationError(ss.str());
Expand Down
Loading

0 comments on commit 70d9ca8

Please sign in to comment.