Skip to content

Commit

Permalink
fix crash (seam), support bot. int. angle. occtwrapper on linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Jul 3, 2024
2 parents 15631a3 + a40b7ba commit 7c0a696
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 136 deletions.
6 changes: 6 additions & 0 deletions BuildLinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,18 @@ then
cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DSLIC3R_STATIC=1 ${BUILD_ARGS}
echo "done"

#make avrdude-slic3r
make avrdude-slic3r

# make Slic3r
echo "[8/9] Building Slic3r..."
make -j$NCORES Slic3r

# make .mo
make gettext_po_to_mo

# make OCCTWrapper.so
make OCCTWrapper

popd
echo "done"
Expand Down
12 changes: 9 additions & 3 deletions src/libslic3r/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,13 @@ class ConfigOption {
virtual ConfigOption* clone() const = 0;
// Set a value from a ConfigOption. The two options should be compatible.
virtual void set(const ConfigOption *option) = 0;
// Getters, idx is ignored if it's a scalar value.
virtual int32_t get_int(size_t idx = 0) const { throw BadOptionTypeException("Calling ConfigOption::get_int on a non-int ConfigOption"); }
virtual double get_float(size_t idx = 0) const { throw BadOptionTypeException("Calling ConfigOption::get_float on a non-float ConfigOption"); }
virtual bool is_percent(size_t idx = 0) const { return false; }
virtual bool get_bool(size_t idx = 0) const { throw BadOptionTypeException("Calling ConfigOption::get_bool on a non-boolean ConfigOption"); }
virtual void set_enum_int(int32_t /* val */) { throw BadOptionTypeException("Calling ConfigOption::set_enum_int on a non-enum ConfigOption"); }
// If scalar, idx is ignore, else: if idx < 0 return the vector; if idx >=0 then return the value at theis index; if idx >= size(), then return the first value or a default one.
virtual boost::any get_any(int32_t idx = -1) const { throw BadOptionTypeException("Calling ConfigOption::get_any on a raw ConfigOption"); }
virtual void set_any(boost::any, int32_t idx = -1) { throw BadOptionTypeException("Calling ConfigOption::set_any on a raw ConfigOption"); }
virtual bool is_enabled(size_t idx = -1) const { return (flags & FCO_ENABLED) != 0; }
Expand All @@ -528,6 +530,8 @@ class ConfigOption {
virtual size_t hash() const throw() = 0;
bool is_scalar() const { return (int(this->type()) & int(coVectorType)) == 0; }
bool is_vector() const { return ! this->is_scalar(); }
// Size of the vector it contains, or 1 if it's a scalar value.
virtual size_t size() const = 0;
// If this option is nullable, then it may have its value or values set to nil.
virtual bool nullable() const { return false; }
// A scalar is nil, or all values of a vector are nil if idx < 0.
Expand Down Expand Up @@ -564,6 +568,7 @@ class ConfigOptionSingle : public ConfigOption {
operator T() const { return this->value; }
boost::any get_any(int32_t idx = -1) const override { return boost::any(value); }
void set_any(boost::any anyval, int32_t idx = -1) override { value = boost::any_cast<T>(anyval); }
size_t size() const override { return 1; }

void set(const ConfigOption *rhs) override
{
Expand Down Expand Up @@ -626,8 +631,6 @@ class ConfigOptionVectorBase : public ConfigOption {
// currently, it's used to try to have a meaningful value for a Field if the default value is Nil (and to avoid cloning the option, clear it, asking for an item)
virtual boost::any get_default_value() const = 0;

// Get size of this vector.
virtual size_t size() const = 0;
// Is this vector empty?
virtual bool empty() const = 0;
// Get if the size of this vector is/should be the same as nozzle_diameter
Expand Down Expand Up @@ -942,6 +945,7 @@ class ConfigOptionVector : public ConfigOptionVectorBase
return true;
return false;
}

// Apply an override option, possibly a nullable one.
bool apply_override(const ConfigOption *rhs) override {
if (this->nullable())
Expand Down Expand Up @@ -3147,9 +3151,11 @@ class DynamicConfig : public virtual ConfigBase
// Thus the virtual method get_int() is used to retrieve the enum value.
template<typename ENUM>
ENUM opt_enum(const t_config_option_key &opt_key) const { return static_cast<ENUM>(this->option(opt_key)->get_int()); }

bool opt_bool(const t_config_option_key &opt_key) const { return this->option<ConfigOptionBool>(opt_key)->value != 0; }
bool opt_bool(const t_config_option_key &opt_key, unsigned int idx) const { return this->option<ConfigOptionBools>(opt_key)->get_at(idx) != 0; }
bool& opt_bool(const t_config_option_key &opt_key) { return this->option<ConfigOptionBool>(opt_key)->value; }
unsigned char& opt_bool(const t_config_option_key &opt_key, unsigned int idx) { return this->option<ConfigOptionBools>(opt_key)->get_at(idx); }

// Command line processing
bool read_cli(int argc, const char* const argv[], t_config_option_keys* extra, t_config_option_keys* keys = nullptr);
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/GCode/SeamPlacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ PolylineWithEnds extract_perimeter_polylines(const Layer *layer, const SeamPosit
// if Custom Seam modifiers are present, oversamples the polyline if necessary to better fit user intentions
void process_perimeter_polylines(const PolylineWithEnd &orig_polyline, float z_coord, const LayerRegion *region,
const GlobalModelInfo &global_model_info, PrintObjectSeamData::LayerSeams &result) {
if (orig_polyline.size() == 0) {
if (orig_polyline.size() <= 1) {
return;
}
PolylineWithEnd polyline = orig_polyline;
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3749,7 +3749,7 @@ void PrintConfigDef::init_fff_params()
def->sidetext = L("mm or %");
def->ratio_over = "nozzle_diameter";
def->min = 0;
def->max_literal = { 10, false };
def->max_literal = { 1, true };
def->mode = comSimpleAE | comPrusa;
def->is_vector_extruder = true;
def->set_default_value(new ConfigOptionFloatsOrPercents{ FloatOrPercent{ 75, true} });
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/SupportMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4142,7 +4142,7 @@ void PrintObjectSupportMaterial::generate_toolpaths(
float raft_angle_1st_layer = 0.f;
float raft_angle_base = 0.f;
float raft_angle_interface = 0.f;
size_t raft_top_interface_idx = m_slicing_params->interface_raft_layers == 0 ? 0 : (m_slicing_params->base_raft_layers + m_slicing_params->interface_raft_layers - 1);
size_t raft_top_interface_idx = m_slicing_params->interface_raft_layers == 0 ? size_t(-1) : (m_slicing_params->base_raft_layers + m_slicing_params->interface_raft_layers - 1);
if (m_slicing_params->base_raft_layers > 1) {
// There are all raft layer types (1st layer, base, interface & contact layers) available.
raft_angle_1st_layer = m_support_params.interface_angle;
Expand Down
139 changes: 139 additions & 0 deletions src/slic3r/GUI/ConfigManipulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,145 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config)
toggle_field("max_print_speed", config->opt_float("max_volumetric_speed") != 0);
}


void ConfigManipulation::update_printer_fff_config(DynamicPrintConfig *config,
const bool is_global_config)
{
const std::vector<double> &nozzle_sizes = config->option<ConfigOptionFloats>("nozzle_diameter")->get_values();
//for each extruder
for (size_t extruder_idx = 0; extruder_idx < nozzle_sizes.size(); ++extruder_idx) {
double min_lh = config->get_computed_value("min_layer_height", extruder_idx);
double max_lh = config->get_computed_value("max_layer_height", extruder_idx);
if (max_lh > nozzle_sizes[extruder_idx]) {
const wxString msg_text = _(
L("Maximum layer height is not valid, it can't be higher than the nozzle diameter.\n\nThe maximum layer height will be set to 100% of the nozzle diameter."));
MessageDialog dialog(m_msg_dlg_parent, msg_text, _(L("Maximum layer height")), wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
new_conf.option<ConfigOptionFloatsOrPercents>("max_layer_height")->set_at(FloatOrPercent{100., true}, extruder_idx);
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
if (min_lh >= max_lh) {
const wxString msg_text = _(
L("Minimum layer height is not valid, it can't be higher or equal to the maximum layer height.\n\nThe minimum layer height will be set to 0."));
MessageDialog dialog(m_msg_dlg_parent, msg_text, _(L("Minimum layer height")), wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
new_conf.option<ConfigOptionFloatsOrPercents>("min_layer_height")->set_at(FloatOrPercent{0.0, false}, extruder_idx);
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}

bool have_retract_length = config->opt_float("retract_length", extruder_idx) > 0;
bool use_firmware_retraction = config->opt_bool("use_firmware_retraction");
bool wipe = config->opt_bool("wipe", extruder_idx) && have_retract_length;
if (use_firmware_retraction && wipe) {
DynamicPrintConfig new_conf = *config;
//wxMessageDialog dialog(parent(),
MessageDialog dialog(m_msg_dlg_parent,
_(L("The Wipe option is not available when using the Firmware Retraction mode.\n"
"\nShall I disable it in order to enable Firmware Retraction?")),
_(L("Firmware Retraction")), wxICON_WARNING | wxYES | wxNO);

if (dialog.ShowModal() == wxID_YES) {
new_conf.opt_bool("wipe", extruder_idx) = false;
} else {
new_conf.opt_bool("use_firmware_retraction") = false;
}
apply(config, &new_conf);
}
}
}
void ConfigManipulation::toggle_printer_fff_options(DynamicPrintConfig *config, DynamicPrintConfig &full_config)
{
Field* field;

size_t extruder_count = config->option("nozzle_diameter")->size();
toggle_field("toolchange_gcode", extruder_count > 1);
toggle_field("single_extruder_multi_material", extruder_count > 1);

//thumbnails
bool custom_color = config->opt_bool("thumbnails_custom_color");
toggle_field("thumbnails_color", custom_color);
const ConfigOptionEnum<GCodeThumbnailsFormat>* thumbnails_format = config->option<ConfigOptionEnum<GCodeThumbnailsFormat>>("thumbnails_format");

if (thumbnails_format) {
toggle_field("thumbnails_end_file", thumbnails_format->value != (GCodeThumbnailsFormat::BIQU));
toggle_field("thumbnails_tag_format", thumbnails_format->value != (GCodeThumbnailsFormat::BIQU));
}

//firmware
bool have_remaining_times = config->opt_bool("remaining_times");
toggle_field("remaining_times_type", have_remaining_times);

bool have_arc_fitting = config->opt_bool("arc_fitting");
toggle_field("arc_fitting_tolerance", have_arc_fitting);

auto flavor = config->option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor")->value;
bool is_marlin_flavor = flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware;
// Disable silent mode for non-marlin firmwares.
toggle_field("silent_mode", is_marlin_flavor);

for (size_t i = 0; i < extruder_count; ++i) {

bool have_retract_length = config->opt_float("retract_length", i) > 0;

// when using firmware retraction, firmware decides retraction length
bool use_firmware_retraction = config->opt_bool("use_firmware_retraction");
toggle_field("retract_length", !use_firmware_retraction, i);

// retraction only if have retraction length or we're using firmware retraction
bool retraction = (have_retract_length || use_firmware_retraction);

// user can customize other retraction options if retraction is enabled
std::vector<std::string> vec = { "retract_lift", "retract_layer_change", "retract_before_travel" };
for (auto el : vec) {
toggle_field(el, retraction, i);
}

bool has_lift = retraction && config->opt_float("retract_lift", i) > 0;
// retract lift above / below only applies if using retract lift
vec.resize(0);
vec = { "retract_lift_above", "retract_lift_below", "retract_lift_top", "retract_lift_first_layer", "retract_lift_before_travel"};
for (auto el : vec) {
toggle_field(el, has_lift, i);
}

// some options only apply when not using firmware retraction
vec.resize(0);
vec = { "retract_speed", "deretract_speed", "retract_before_wipe", "retract_restart_extra", "wipe", "wipe_speed" , "wipe_only_crossing"};
for (auto el : vec) {
toggle_field(el, retraction && !use_firmware_retraction, i);
}

bool wipe = config->opt_bool("wipe", i) && have_retract_length;
vec.resize(0);
vec = { "retract_before_wipe", "wipe_only_crossing", "wipe_speed" };
for (auto el : vec) {
toggle_field(el, wipe, i);
}

// wipe_only_crossing can only work if avoid_crossing_perimeters
if (!full_config.option("avoid_crossing_perimeters")->get_bool()) {
toggle_field("wipe_only_crossing", false, i);
}

toggle_field("retract_length_toolchange", extruder_count > 1, i);

bool toolchange_retraction = config->opt_float("retract_length_toolchange", i) > 0;
toggle_field("retract_restart_extra_toolchange", extruder_count > 1 && toolchange_retraction, i);
}
if (config->opt_bool("single_extruder_multi_material") && extruder_count > 1) {
bool have_advanced_wipe_volume = config->opt_bool("wipe_advanced");
for (auto el : { "wipe_advanced_nozzle_melted_volume", "wipe_advanced_multiplier", "wipe_advanced_algo" }) {
toggle_field(el, have_advanced_wipe_volume);
}
}
}

void ConfigManipulation::update_print_sla_config(DynamicPrintConfig* config, const bool is_global_config/* = false*/)
{
double head_penetration = config->opt_float("support_head_penetration");
Expand Down
4 changes: 4 additions & 0 deletions src/slic3r/GUI/ConfigManipulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class ConfigManipulation
void update_print_fff_config(DynamicPrintConfig* config, const bool is_global_config = false);
void toggle_print_fff_options(DynamicPrintConfig* config);

// FFF printer
void update_printer_fff_config(DynamicPrintConfig* config, const bool is_global_config = false);
void toggle_printer_fff_options(DynamicPrintConfig* config, DynamicPrintConfig &full_config);

// SLA print
void update_print_sla_config(DynamicPrintConfig* config, const bool is_global_config = false);
void toggle_print_sla_options(DynamicPrintConfig* config);
Expand Down
Loading

0 comments on commit 7c0a696

Please sign in to comment.