Add kill switch parameter for "exact last layer height"

This commit is contained in:
supermerill 2018-09-25 16:13:59 +02:00
parent 3ee37f40f4
commit 86323a6b73
7 changed files with 34 additions and 9 deletions

View File

@ -1046,6 +1046,13 @@ PrintConfigDef::PrintConfigDef()
def->min = 0;
def->default_value = new ConfigOptionFloat(0.3);
def = this->add("exact_last_layer_height", coBool);
def->label = L("Exact last layer height");
def->category = L("Layers and Perimeters");
def->tooltip = L("This setting controls the height of last object layers to put the last layer at the exact highest height possible. Experimental.");
def->cli = "exact_last-layer-height=f";
def->default_value = new ConfigOptionBool(false);
def = this->add("remaining_times", coBool);
def->label = L("Supports remaining times");
def->tooltip = L("Emit M73 P[percent printed] R[remaining time in minutes] at 1 minute"
@ -2364,9 +2371,13 @@ void DynamicPrintConfig::normalize()
opt->values.assign(opt->values.size(), false); // set all values to false
}
{
this->opt<ConfigOptionInt>("perimeters", true)->value = 1;
this->opt<ConfigOptionInt>("perimeters", true)->value = 1;
this->opt<ConfigOptionInt>("top_solid_layers", true)->value = 0;
this->opt<ConfigOptionPercent>("fill_density", true)->value = 0;
this->opt<ConfigOptionPercent>("fill_density", true)->value = 0;
this->opt<ConfigOptionBool>("support_material", true)->value = false;
this->opt<ConfigOptionInt>("support_material_enforce_layers")->value = 0;
this->opt<ConfigOptionBool>("exact_last_layer_height", true)->value = false;
this->opt<ConfigOptionBool>("ensure_vertical_shell_thickness", true)->value = false;
}
}
}

View File

@ -330,6 +330,7 @@ public:
ConfigOptionBool infill_only_where_needed;
ConfigOptionBool interface_shells;
ConfigOptionFloat layer_height;
ConfigOptionBool exact_last_layer_height;
ConfigOptionInt raft_layers;
ConfigOptionEnum<SeamPosition> seam_position;
// ConfigOptionFloat seam_preferred_direction;
@ -368,6 +369,7 @@ protected:
OPT_PTR(infill_only_where_needed);
OPT_PTR(interface_shells);
OPT_PTR(layer_height);
OPT_PTR(exact_last_layer_height);
OPT_PTR(raft_layers);
OPT_PTR(seam_position);
// OPT_PTR(seam_preferred_direction);

View File

@ -163,6 +163,7 @@ bool PrintObject::invalidate_state_by_config_options(const std::vector<t_config_
} else if (
opt_key == "layer_height"
|| opt_key == "first_layer_height"
|| opt_key == "exact_last_layer_height"
|| opt_key == "raft_layers") {
steps.emplace_back(posSlice);
this->reset_layer_height_profile();

View File

@ -71,6 +71,7 @@ SlicingParameters SlicingParameters::create_from_config(
// Miniumum/maximum of the minimum layer height over all extruders.
params.min_layer_height = MIN_LAYER_HEIGHT;
params.max_layer_height = std::numeric_limits<double>::max();
params.exact_last_layer_height = object_config.exact_last_layer_height.value;
if (object_config.support_material.value || params.base_raft_layers > 0) {
// Has some form of support. Add the support layers to the minimum / maximum layer height limits.
params.min_layer_height = std::max(
@ -553,7 +554,7 @@ std::vector<coordf_t> generate_object_layers(
}
// Adjust the last layer to align with the top object layer exactly
if (out.size() > 0 && slicing_params.object_print_z_height() != out[out.size()-1]){
if (out.size() > 0 && slicing_params.object_print_z_height() != out[out.size() - 1] && slicing_params.exact_last_layer_height) {
float neededPrintZ = slicing_params.object_print_z_height();
int idx_layer = out.size() / 2 - 1;
float diffZ = neededPrintZ - out[idx_layer * 2 + 1];

View File

@ -57,6 +57,7 @@ struct SlicingParameters
coordf_t min_layer_height;
coordf_t max_layer_height;
coordf_t max_suport_layer_height;
bool exact_last_layer_height;
// First layer height of the print, this may be used for the first layer of the raft
// or for the first layer of the print.

View File

@ -306,7 +306,7 @@ const std::vector<std::string>& Preset::print_options()
"elefant_foot_compensation", "xy_size_compensation", "hole_size_compensation", "threads", "resolution",
"wipe_tower", "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_bridging",
"only_one_perimeter_top", "single_extruder_multi_material_priming", "compatible_printers", "compatible_printers_condition", "inherits",
"infill_dense", "no_perimeter_unsupported", "min_perimeter_unsupported", "noperi_bridge_only"
"infill_dense", "no_perimeter_unsupported", "min_perimeter_unsupported", "noperi_bridge_only", "exact_last_layer_height"
};
return s_opts;
}

View File

@ -786,7 +786,8 @@ void TabPrint::build()
auto page = add_options_page(_(L("Layers and perimeters")), "layers.png");
auto optgroup = page->new_optgroup(_(L("Layer height")));
optgroup->append_single_option_line("layer_height");
optgroup->append_single_option_line("first_layer_height");
optgroup->append_single_option_line("first_layer_height");
optgroup->append_single_option_line("exact_last_layer_height");
optgroup = page->new_optgroup(_(L("Vertical shells")));
optgroup->append_single_option_line("perimeters");
@ -1042,15 +1043,22 @@ void TabPrint::update()
double fill_density = m_config->option<ConfigOptionPercent>("fill_density")->value;
if (m_config->opt_bool("spiral_vase") &&
!(m_config->opt_int("perimeters") == 1 && m_config->opt_int("top_solid_layers") == 0 &&
fill_density == 0)) {
if (m_config->opt_bool("spiral_vase") && !(
m_config->opt_int("perimeters") == 1
&& m_config->opt_int("top_solid_layers") == 0
&& fill_density == 0
&& m_config->opt_bool("support_material") == false
&& m_config->opt_int("support_material_enforce_layers") == 0
&& m_config->opt_bool("exact_last_layer_height") == false
&& m_config->opt_bool("ensure_vertical_shell_thickness") == false
)) {
wxString msg_text = _(L("The Spiral Vase mode requires:\n"
"- one perimeter\n"
"- no top solid layers\n"
"- 0% fill density\n"
"- no support material\n"
"- no ensure_vertical_shell_thickness\n"
"- unchecked 'exact last layer height'\n"
"\nShall I adjust those settings in order to enable Spiral Vase?"));
auto dialog = new wxMessageDialog(parent(), msg_text, _(L("Spiral Vase")), wxICON_WARNING | wxYES | wxNO);
DynamicPrintConfig new_conf = *m_config;
@ -1059,7 +1067,8 @@ void TabPrint::update()
new_conf.set_key_value("top_solid_layers", new ConfigOptionInt(0));
new_conf.set_key_value("fill_density", new ConfigOptionPercent(0));
new_conf.set_key_value("support_material", new ConfigOptionBool(false));
new_conf.set_key_value("support_material_enforce_layers", new ConfigOptionInt(0));
new_conf.set_key_value("support_material_enforce_layers", new ConfigOptionInt(0));
new_conf.set_key_value("exact_last_layer_height", new ConfigOptionBool(false));
new_conf.set_key_value("ensure_vertical_shell_thickness", new ConfigOptionBool(false));
fill_density = 0;
}