Files
OrcaSlicer/src/slic3r/GUI/ConfigManipulation.cpp
T
HanifKoh 2cb2f0d2e7 Validate Only the Edited Variant's Adaptive PA Model and Accept Spaces in It (#16978)
* Validate Only the Edited Variant's Adaptive PA Model and Accept Spaces in It

Since pressure advance became a per-variant filament setting, the Filament
tab validated every variant column of the adaptive pressure advance model
whenever one was edited. The columns the user never touched still hold the
default placeholder, which the validator rejects, so every edit of a
multi-variant filament ended in a "Line 1: flow value must be greater than PA
value" dialog about a column the user could not see. The check now covers the
variant being edited only, as the nozzle temperature checks on the same tab do.

The validator also rejected whitespace between the values, which the model
parser accepts, so a model typed as "0.027, 8.1416, 2000.0" sliced correctly
but warned on every slice. Whitespace is now ignored before the values are
checked.

Enabling adaptive pressure advance before entering a model warned that the
model "may contain invalid values", which only meant that the placeholder is
all zeros. That case now gets its own warning saying that no measurements
have been entered.

* Keep the Empty Adaptive PA Model a Single Filament Column in Its Test

Deserializing an empty string into the model option leaves it with no
entries, and get_at on an empty vector aborts on a libstdc++ built with
assertions, as the Flatpak unit-test lanes are. Presets always hold one
column per filament, so set the value directly.
2026-10-29 12:08:50 +08:00

1485 lines
96 KiB
C++

#include "ConfigManipulation.hpp"
#include "I18N.hpp"
#include "GUI_App.hpp"
#include "DeviceCore/DevConfigUtil.h"
#include "format.hpp"
#include "libslic3r/Config.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/PresetBundle.hpp"
#include "libslic3r/MaterialType.hpp"
#include "MsgDialog.hpp"
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/GCode/AdaptivePAProcessor.hpp"
#include "Plater.hpp"
#include <algorithm>
#include "slic3r/GUI/GUI.hpp"
#include "libslic3r/libslic3r.h"
#include "slic3r/GUI/Field.hpp"
#include "libslic3r/BeltBrim.hpp"
#include <cstdlib>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#include <wx/msgdlg.h>
#include <wx/string.h>
namespace Slic3r {
namespace GUI {
namespace {
std::string trim_copy(const std::string& text)
{
const auto first = text.find_first_not_of(" \t\r\n");
if (first == std::string::npos)
return {};
const auto last = text.find_last_not_of(" \t\r\n");
return text.substr(first, last - first + 1);
}
} // namespace
void ConfigManipulation::apply(DynamicPrintConfig* config, DynamicPrintConfig* new_config)
{
bool modified = false;
m_applying_keys = config->diff(*new_config);
for (auto opt_key : m_applying_keys) {
config->set_key_value(opt_key, new_config->option(opt_key)->clone());
modified = true;
}
if (modified && load_config != nullptr)
load_config();
m_applying_keys.clear();
}
bool ConfigManipulation::is_applying() const { return is_msg_dlg_already_exist; }
t_config_option_keys const &ConfigManipulation::applying_keys() const
{
return m_applying_keys;
}
void ConfigManipulation::toggle_field(const std::string &opt_key, const bool toggle, int opt_index, const wxString& reason)
{
if (local_config) {
if (local_config->option(opt_key) == nullptr) return;
}
cb_toggle_field(opt_key, toggle, opt_index, reason);
}
void ConfigManipulation::toggle_line(const std::string& opt_key, const bool toggle, int opt_index, const wxString& reason)
{
if (local_config) {
if (local_config->option(opt_key) == nullptr)
return;
}
if (cb_toggle_line)
cb_toggle_line(opt_key, toggle, opt_index, reason);
}
void ConfigManipulation::set_option_label(const std::string& opt_key, const wxString& label, int opt_index)
{
if (cb_set_option_label)
cb_set_option_label(opt_key, label, opt_index);
}
void ConfigManipulation::check_nozzle_recommended_temperature_range(DynamicPrintConfig *config, unsigned int variant_index) {
if (is_msg_dlg_already_exist)
return;
int temperature_range_low, temperature_range_high;
if (!get_temperature_range(config, temperature_range_low, temperature_range_high, variant_index)) return;
// Get the selected filament type
std::string filament_type = "";
if (config->has("filament_type") && config->option<ConfigOptionStrings>("filament_type")->values.size() > 0) {
filament_type = config->option<ConfigOptionStrings>("filament_type")->values[0];
}
int min_recommended_temp = 190;
int max_recommended_temp = 300;
if (!MaterialType::get_temperature_range(filament_type, min_recommended_temp, max_recommended_temp)){
filament_type = "Unknown";
}
wxString msg_text;
bool need_check = false;
if (temperature_range_low < min_recommended_temp) {
msg_text += wxString::Format(_L("A minimum temperature above %d\u2103 is recommended for %s.\n"),
min_recommended_temp, filament_type);
need_check = true;
}
if (temperature_range_high > max_recommended_temp) {
msg_text += wxString::Format(_L("A maximum temperature below %d\u2103 is recommended for %s.\n"),
max_recommended_temp, filament_type);
need_check = true;
}
if (temperature_range_low > temperature_range_high) {
msg_text += _L("The recommended minimum temperature cannot be higher than the recommended maximum temperature.\n");
need_check = true;
}
if (need_check) {
msg_text += _L("Please check.\n");
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
is_msg_dlg_already_exist = true;
dialog.ShowModal();
is_msg_dlg_already_exist = false;
}
}
void ConfigManipulation::check_nozzle_temperature_range(DynamicPrintConfig *config, unsigned int variant_index)
{
if (is_msg_dlg_already_exist)
return;
int temperature_range_low, temperature_range_high;
if (!get_temperature_range(config, temperature_range_low, temperature_range_high, variant_index)) return;
if (config->has("nozzle_temperature")) {
if (config->opt_int("nozzle_temperature", variant_index) < temperature_range_low || config->opt_int("nozzle_temperature", variant_index) > temperature_range_high) {
wxString msg_text = _(L("The nozzle may become clogged when the temperature is out of the recommended range.\nPlease make sure whether to use this temperature to print.\n\n"));
msg_text += wxString::Format(_L("The recommended nozzle temperature for this filament type is [%d, %d] degrees Celsius."), temperature_range_low, temperature_range_high);
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
is_msg_dlg_already_exist = true;
dialog.ShowModal();
is_msg_dlg_already_exist = false;
}
}
}
void ConfigManipulation::check_nozzle_temperature_initial_layer_range(DynamicPrintConfig* config, unsigned int variant_index)
{
if (is_msg_dlg_already_exist)
return;
int temperature_range_low, temperature_range_high;
if (!get_temperature_range(config, temperature_range_low, temperature_range_high, variant_index)) return;
if (config->has("nozzle_temperature_initial_layer")) {
if (config->opt_int("nozzle_temperature_initial_layer", variant_index) < temperature_range_low ||
config->opt_int("nozzle_temperature_initial_layer", variant_index) > temperature_range_high)
{
wxString msg_text = _(L("The nozzle may become clogged when the temperature is out of the recommended range.\nPlease make sure whether to use this temperature to print.\n\n"));
msg_text += wxString::Format(_L("The recommended nozzle temperature for this filament type is [%d, %d] degrees Celsius."), temperature_range_low, temperature_range_high);
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
is_msg_dlg_already_exist = true;
dialog.ShowModal();
is_msg_dlg_already_exist = false;
}
}
}
void ConfigManipulation::check_adaptive_pressure_advance_model(DynamicPrintConfig* config, unsigned int variant_index)
{
if (is_msg_dlg_already_exist || !config->has("adaptive_pressure_advance_model"))
return;
const auto* model = config->option<ConfigOptionStrings>("adaptive_pressure_advance_model");
if (model == nullptr || model->values.empty())
return;
// Each extruder variant holds its own model; only the one being edited is checked, the
// others may still hold the default placeholder.
const std::string error = AdaptivePAProcessor::validate_adaptive_pa_model(model->get_at(variant_index));
if (!error.empty()) {
wxString msg_text = _L("Adaptive Pressure Advance model validation failed:\n");
msg_text += from_u8(error);
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
is_msg_dlg_already_exist = true;
dialog.ShowModal();
is_msg_dlg_already_exist = false;
}
}
void ConfigManipulation::check_filament_max_volumetric_speed(DynamicPrintConfig *config)
{
//if (is_msg_dlg_already_exist) return;
//float max_volumetric_speed = config->opt_float("filament_max_volumetric_speed");
float max_volumetric_speed = config->has("filament_max_volumetric_speed") ? config->opt_float("filament_max_volumetric_speed", (float) 0.5) : 0.5;
// BBS: limite the min max_volumetric_speed
if (max_volumetric_speed < 0.5) {
const wxString msg_text = _(L("Too small max volumetric speed.\nValue was reset to 0.5"));
MessageDialog dialog(nullptr, msg_text, "", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
new_conf.set_key_value("filament_max_volumetric_speed", new ConfigOptionFloats({0.5}));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
}
void ConfigManipulation::check_filament_ironing_spacing(DynamicPrintConfig *config)
{
const auto *opt = config->option<ConfigOptionFloatsNullable>("filament_ironing_spacing");
if (opt == nullptr)
return;
std::vector<double> values = opt->values;
bool reset = false;
for (size_t i = 0; i < values.size(); ++i)
if (!opt->is_nil(i) && values[i] < IRONING_SPACING_MIN) {
values[i] = 0.1;
reset = true;
}
if (!reset)
return;
const wxString msg_text = _(L("Ironing spacing too small\nIt has been reset to 0.1"));
MessageDialog dialog(nullptr, msg_text, "", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
new_conf.set_key_value("filament_ironing_spacing", new ConfigOptionFloatsNullable(values));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
void ConfigManipulation::check_chamber_temperature(DynamicPrintConfig* config)
{
bool support_chamber_temp_control=GUI::wxGetApp().preset_bundle->printers.get_selected_preset().config.opt_bool("support_chamber_temp_control");
if (support_chamber_temp_control&&config->has("chamber_temperature")) {
std::string filament_type = config->option<ConfigOptionStrings>("filament_type")->get_at(0);
int chamber_min_temp, chamber_max_temp;
if (MaterialType::get_chamber_temperature_range(filament_type, chamber_min_temp, chamber_max_temp)) {
if (chamber_max_temp < config->option<ConfigOptionInts>("chamber_temperature")->get_at(0)) {
wxString msg_text = wxString::Format(_L("Current chamber temperature is higher than the material\'s safe temperature; this may result in material softening and nozzle clogs. The maximum safe temperature for the material is %d"), chamber_max_temp);
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
is_msg_dlg_already_exist = true;
dialog.ShowModal();
is_msg_dlg_already_exist = false;
}
}
}
}
void ConfigManipulation::check_chamber_minimal_temperature(DynamicPrintConfig* config)
{
// Orca: the minimal chamber temperature is a "start printing" threshold that is passed to the
// print start macro. It must not exceed the target chamber temperature, otherwise the macro
// could wait forever for a temperature the heater is never asked to reach.
if (config->has("chamber_minimal_temperature") && config->has("chamber_temperature")) {
const int chamber_min_temp = config->option<ConfigOptionInts>("chamber_minimal_temperature")->get_at(0);
const int chamber_target_temp = config->option<ConfigOptionInts>("chamber_temperature")->get_at(0);
if (chamber_min_temp > chamber_target_temp) {
wxString msg_text = wxString::Format(_L("The minimal chamber temperature (%d℃) is higher than the target chamber temperature (%d℃). "
"The minimal value is the threshold at which printing starts while the chamber keeps heating toward the target, "
"so it should not exceed it. It will be clamped to the target."),
chamber_min_temp, chamber_target_temp);
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
new_conf.set_key_value("chamber_minimal_temperature", new ConfigOptionInts({chamber_target_temp}));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
}
}
void ConfigManipulation::layer_height_limits(double& min_layer_height, double& max_layer_height) const
{
const DynamicPrintConfig& printer_config = GUI::wxGetApp().preset_bundle->printers.get_edited_preset().config;
const std::vector<double>& min_limits = printer_config.option<ConfigOptionFloats>("min_layer_height")->values;
const std::vector<double>& max_limits = printer_config.option<ConfigOptionFloats>("max_layer_height")->values;
min_layer_height = *std::min_element(min_limits.begin(), min_limits.end());
max_layer_height = *std::max_element(max_limits.begin(), max_limits.end());
}
bool ConfigManipulation::check_layer_height(DynamicPrintConfig* config)
{
double min_layer_height = 0., max_layer_height = 0.;
layer_height_limits(min_layer_height, max_layer_height);
const double layer_height = config->opt_float("layer_height");
if (min_layer_height > EPSILON && layer_height < EPSILON) {
const wxString msg_text = wxString::Format(_L("Layer height is too small. It will be set to the minimum (%g mm)."), min_layer_height);
MessageDialog dialog(wxGetApp().plater(), msg_text, "", wxICON_WARNING | wxOK);
dialog.SetButtonLabel(wxID_OK, _L("OK"));
is_msg_dlg_already_exist = true;
dialog.ShowModal();
is_msg_dlg_already_exist = false;
DynamicPrintConfig new_conf = *config;
new_conf.set_key_value("layer_height", new ConfigOptionFloat(min_layer_height));
apply(config, &new_conf);
return true;
}
if (max_layer_height > EPSILON && layer_height > max_layer_height + EPSILON)
return layer_height_out_of_range_dialog(config, max_layer_height);
if (min_layer_height > EPSILON && layer_height < min_layer_height - EPSILON)
return layer_height_out_of_range_dialog(config, min_layer_height);
return false;
}
bool ConfigManipulation::layer_height_out_of_range_dialog(DynamicPrintConfig* config, double clamp_to)
{
wxString msg_text = _(L("Layer height is outside the limits set in Printer Settings -> Extruder -> Layer height limits, "
"this may cause printing quality issues."));
msg_text += "\n\n" + wxString::Format(_L("Adjust it to the limit (%g mm) automatically?"), clamp_to);
MessageDialog dialog(wxGetApp().plater(), msg_text, "", wxICON_WARNING | wxYES | wxNO);
dialog.SetButtonLabel(wxID_YES, _L("Adjust"));
dialog.SetButtonLabel(wxID_NO, _L("Ignore"));
is_msg_dlg_already_exist = true;
const bool adjust = dialog.ShowModal() == wxID_YES;
if (adjust) {
DynamicPrintConfig new_conf = *config;
new_conf.set_key_value("layer_height", new ConfigOptionFloat(clamp_to));
apply(config, &new_conf);
}
is_msg_dlg_already_exist = false;
return adjust;
}
void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, const bool is_global_config, const bool is_plate_config)
{
// #ys_FIXME_to_delete
//! Temporary workaround for the correct updates of the TextCtrl (like "layer_height"):
// KillFocus() for the wxSpinCtrl use CallAfter function. So,
// to except the duplicate call of the update() after dialog->ShowModal(),
// let check if this process is already started.
if (is_msg_dlg_already_exist)
return;
bool is_object_config = (!is_global_config && !is_plate_config);
// Belt printer: a raft and a draft shield are refused by Print::validate(), and
// the fields that would clear them are greyed out in belt mode, so a preset that
// carries either could not be sliced at all. Reset them instead of only disabling
// the fields.
if (GUI::wxGetApp().preset_bundle != nullptr) {
const auto *belt_opt = GUI::wxGetApp().preset_bundle->printers.get_edited_preset().config.option<ConfigOptionBool>("belt_printer");
const auto *raft_opt = config->option<ConfigOptionInt>("raft_layers");
const auto *shield_opt = config->option<ConfigOptionEnum<DraftShield>>("draft_shield");
const bool has_raft = raft_opt != nullptr && raft_opt->value > 0;
const bool has_shield = shield_opt != nullptr && shield_opt->value != dsDisabled;
if (belt_opt != nullptr && belt_opt->value && (has_raft || has_shield)) {
const wxString msg_text = _(L("Raft and draft shield are not available on belt printers.\nThey have been disabled."));
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
if (has_raft)
new_conf.set_key_value("raft_layers", new ConfigOptionInt(0));
if (has_shield)
new_conf.set_key_value("draft_shield", new ConfigOptionEnum<DraftShield>(dsDisabled));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
}
// layer_height shouldn't be equal to zero
auto layer_height = config->opt_float("layer_height");
if (layer_height < EPSILON)
{
const wxString msg_text = _(L("Layer height too small\nIt has been reset to 0.2"));
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
new_conf.set_key_value("layer_height", new ConfigOptionFloat(0.2));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
//BBS: ironing_spacing shouldn't be too small or equal to zero
if (config->opt_float("ironing_spacing") < IRONING_SPACING_MIN)
{
const wxString msg_text = _(L("Ironing spacing too small\nIt has been reset to 0.1"));
MessageDialog dialog(nullptr, msg_text, "", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
new_conf.set_key_value("ironing_spacing", new ConfigOptionFloat(0.1));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
if (config->opt_float("support_ironing_spacing") < IRONING_SPACING_MIN)
{
const wxString msg_text = _(L("Ironing spacing too small\nIt has been reset to 0.1"));
MessageDialog dialog(nullptr, msg_text, "", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
new_conf.set_key_value("support_ironing_spacing", new ConfigOptionFloat(0.1));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
if (config->option<ConfigOptionFloat>("initial_layer_print_height")->value < EPSILON)
{
const wxString msg_text = _(L("Zero initial layer height is invalid.\n\nThe first layer height will be reset to 0.2."));
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
new_conf.set_key_value("initial_layer_print_height", new ConfigOptionFloat(0.2));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
if (abs(config->option<ConfigOptionFloat>("xy_hole_compensation")->value) > 2)
{
const wxString msg_text = _(L("This setting is only used for tuning model size by small amounts.\nFor example, when the model size has small errors or when tolerances are incorrect. For large adjustments, please use the model scale function.\n\nThe value will be reset to 0."));
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
new_conf.set_key_value("xy_hole_compensation", new ConfigOptionFloat(0));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
if (abs(config->option<ConfigOptionFloat>("xy_contour_compensation")->value) > 2)
{
const wxString msg_text = _(L("This setting is only used for tuning model size by small amounts.\nFor example, when the model size has small errors or when tolerances are incorrect. For large adjustments, please use the model scale function.\n\nThe value will be reset to 0."));
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
new_conf.set_key_value("xy_contour_compensation", new ConfigOptionFloat(0));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
if (config->option<ConfigOptionFloat>("elefant_foot_compensation")->value > 1)
{
const wxString msg_text = _(L("The elephant foot compensation value is too large.\nIf there are significant elephant foot issues, please check other settings.\nThe bed temperature may be too high, for example.\n\nThe value will be reset to 0."));
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
new_conf.set_key_value("elefant_foot_compensation", new ConfigOptionFloat(0));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
if (config->option<ConfigOptionBool>("enable_wrapping_detection")->value) {
std::string printer_type = wxGetApp().preset_bundle->printers.get_edited_preset().get_printer_type(wxGetApp().preset_bundle);
if (!DevPrinterConfigUtil::support_wrapping_detection(printer_type)) {
DynamicPrintConfig new_conf = *config;
new_conf.set_key_value("enable_wrapping_detection", new ConfigOptionBool(false));
apply(config, &new_conf);
}
}
double sparse_infill_density = config->option<ConfigOptionPercent>("sparse_infill_density")->value;
int fill_multiline = config->option<ConfigOptionInt>("fill_multiline")->value;
auto timelapse_type = config->opt_enum<TimelapseType>("timelapse_type");
if (!is_plate_config &&
config->opt_bool("spiral_mode") &&
! (config->opt_int("wall_loops") == 1 &&
config->opt_int("top_shell_layers") == 0 &&
sparse_infill_density == 0 &&
! config->opt_bool("enable_support") &&
config->opt_int("enforce_support_layers") == 0 &&
! config->opt_bool("detect_thin_wall") &&
! config->opt_bool("overhang_reverse") &&
config->opt_enum<TimelapseType>("timelapse_type") == TimelapseType::tlTraditional &&
!config->opt_bool("enable_wrapping_detection")))
{
DynamicPrintConfig new_conf = *config;
auto answer = show_spiral_mode_settings_dialog(is_object_config);
bool support = true;
if (answer == wxID_YES) {
new_conf.set_key_value("wall_loops", new ConfigOptionInt(1));
new_conf.set_key_value("top_shell_layers", new ConfigOptionInt(0));
new_conf.set_key_value("sparse_infill_density", new ConfigOptionPercent(0));
new_conf.set_key_value("enable_support", new ConfigOptionBool(false));
new_conf.set_key_value("enforce_support_layers", new ConfigOptionInt(0));
new_conf.set_key_value("detect_thin_wall", new ConfigOptionBool(false));
new_conf.set_key_value("overhang_reverse", new ConfigOptionBool(false));
new_conf.set_key_value("timelapse_type", new ConfigOptionEnum<TimelapseType>(tlTraditional));
new_conf.set_key_value("enable_wrapping_detection", new ConfigOptionBool(false));
sparse_infill_density = 0;
timelapse_type = TimelapseType::tlTraditional;
support = false;
}
else {
new_conf.set_key_value("spiral_mode", new ConfigOptionBool(false));
}
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
if (config->opt_bool("alternate_extra_wall") &&
(config->opt_enum<EnsureVerticalShellThickness>("ensure_vertical_shell_thickness") == evstAll)) {
wxString msg_text = _(L("Alternate extra wall doesn't work well when ensure vertical shell thickness is set to All."));
if (is_global_config)
msg_text += "\n\n" + _(L("Change these settings automatically?\n"
"Yes - Change ensure vertical shell thickness to Moderate and enable alternate extra wall\n"
"No - Don't use alternate extra wall"));
MessageDialog dialog(m_msg_dlg_parent, msg_text, "",
wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK));
DynamicPrintConfig new_conf = *config;
auto answer = dialog.ShowModal();
if (!is_global_config || answer == wxID_YES) {
new_conf.set_key_value("ensure_vertical_shell_thickness", new ConfigOptionEnum<EnsureVerticalShellThickness>(evstModerate));
new_conf.set_key_value("alternate_extra_wall", new ConfigOptionBool(true));
}
else {
new_conf.set_key_value("ensure_vertical_shell_thickness", new ConfigOptionEnum<EnsureVerticalShellThickness>(evstAll));
new_conf.set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
}
apply(config, &new_conf);
}
// BBS
int filament_cnt = wxGetApp().preset_bundle->filament_presets.size();
#if 0
bool has_wipe_tower = filament_cnt > 1 && config->opt_bool("enable_prime_tower");
if (has_wipe_tower && (config->opt_bool("adaptive_layer_height") || config->opt_bool("independent_support_layer_height"))) {
wxString msg_text;
if (config->opt_bool("adaptive_layer_height") && config->opt_bool("independent_support_layer_height")) {
msg_text = _(L("Prime tower does not work when Adaptive Layer Height or Independent Support Layer Height is on.\n"
"Which do you want to keep?\n"
"YES - Keep Prime Tower\n"
"NO - Keep Adaptive Layer Height and Independent Support Layer Height"));
}
else if (config->opt_bool("adaptive_layer_height")) {
msg_text = _(L("Prime tower does not work when Adaptive Layer Height is on.\n"
"Which do you want to keep?\n"
"YES - Keep Prime Tower\n"
"NO - Keep Adaptive Layer Height"));
}
else {
msg_text = _(L("Prime tower does not work when Independent Support Layer Height is on.\n"
"Which do you want to keep?\n"
"YES - Keep Prime Tower\n"
"NO - Keep Independent Support Layer Height"));
}
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxYES | wxNO);
is_msg_dlg_already_exist = true;
auto answer = dialog.ShowModal();
DynamicPrintConfig new_conf = *config;
if (answer == wxID_YES) {
if (config->opt_bool("adaptive_layer_height"))
new_conf.set_key_value("adaptive_layer_height", new ConfigOptionBool(false));
if (config->opt_bool("independent_support_layer_height"))
new_conf.set_key_value("independent_support_layer_height", new ConfigOptionBool(false));
}
else
new_conf.set_key_value("enable_prime_tower", new ConfigOptionBool(false));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
// BBS
if (has_wipe_tower && config->opt_bool("enable_support") && !config->opt_bool("independent_support_layer_height")) {
double top_gap_raw = config->opt_float("support_top_z_distance");
//double bottom_gap_raw = config->opt_float("support_bottom_z_distance");
double top_gap = std::round(top_gap_raw / layer_height) * layer_height;
//double bottom_gap = std::round(bottom_gap_raw / layer_height) * layer_height;
if (top_gap != top_gap_raw /* || bottom_gap != bottom_gap_raw*/) {
DynamicPrintConfig new_conf = *config;
new_conf.set_key_value("support_top_z_distance", new ConfigOptionFloat(top_gap));
//new_conf.set_key_value("support_bottom_z_distance", new ConfigOptionFloat(bottom_gap));
apply(config, &new_conf);
//wxMessageBox(_L("Support top/bottom Z distance is automatically changed to multiple of layer height."));
}
}
#endif
// BBL printers do not support cone wipe tower
if (config->opt_bool("enable_prime_tower") && is_BBL_Printer) {
auto wipe_tower_wall_type = config->opt_enum<WipeTowerWallType>("wipe_tower_wall_type");
if (wipe_tower_wall_type == WipeTowerWallType::wtwCone) {
DynamicPrintConfig new_conf = *config;
new_conf.set_key_value("wipe_tower_wall_type", new ConfigOptionEnum<WipeTowerWallType>(WipeTowerWallType::wtwRectangle));
apply(config, &new_conf);
}
}
// Check "enable_support" and "overhangs" relations only on global settings level
if (is_global_config && config->opt_bool("enable_support")) {
// Ask only once.
if (!m_support_material_overhangs_queried) {
m_support_material_overhangs_queried = true;
if (!config->opt_bool("detect_overhang_wall")/* != 1*/) {
//BBS: detect_overhang_wall is setting in develop mode. Enable it directly.
DynamicPrintConfig new_conf = *config;
new_conf.set_key_value("detect_overhang_wall", new ConfigOptionBool(true));
apply(config, &new_conf);
}
}
}
else {
m_support_material_overhangs_queried = false;
}
if (config->opt_bool("enable_support")) {
auto support_type = config->opt_enum<SupportType>("support_type");
auto support_style = config->opt_enum<SupportMaterialStyle>("support_style");
std::set<int> enum_set_normal = { smsDefault, smsGrid, smsSnug };
std::set<int> enum_set_tree = { smsDefault, smsTreeSlim, smsTreeStrong, smsTreeHybrid, smsTreeOrganic };
auto & set = is_tree(support_type) ? enum_set_tree : enum_set_normal;
if (set.find(support_style) == set.end()) {
DynamicPrintConfig new_conf = *config;
new_conf.set_key_value("support_style", new ConfigOptionEnum<SupportMaterialStyle>(smsDefault));
apply(config, &new_conf);
}
}
// BBS
// Reset filament overrides pointing at a slot that no longer exists. Support and the wipe
// tower additionally reject mixed slots: the engine consumes those keys directly, so a virtual
// slot would reach the G-code unresolved, while the per-feature keys are resolved per layer.
static const char* physical_only_keys[] = { "support_filament", "support_interface_filament", "wipe_tower_filament" };
static const char* feature_keys[] = { "outer_wall_filament_id", "inner_wall_filament_id",
"sparse_infill_filament_id", "internal_solid_filament_id",
"top_surface_filament_id", "bottom_surface_filament_id" };
auto reset_invalid_filament = [this, config, filament_cnt](const char* key, bool allow_mixed) {
auto* opt = dynamic_cast<ConfigOptionInt*>(config->option(key, false));
if (opt == nullptr)
return;
const int val = opt->getInt();
const bool out_of_range = val > filament_cnt;
const bool is_mixed = !allow_mixed && val > 0 && val <= filament_cnt &&
wxGetApp().preset_bundle->is_mixed_filament(val - 1);
if (!out_of_range && !is_mixed)
return;
DynamicPrintConfig new_conf = *config;
int new_value = 0;
if (out_of_range) {
const DynamicPrintConfig *conf_temp = wxGetApp().plater()->config();
if (conf_temp != nullptr && conf_temp->has(key))
new_value = conf_temp->opt_int(key);
}
new_conf.set_key_value(key, new ConfigOptionInt(new_value));
apply(config, &new_conf);
};
for (const char* key : physical_only_keys)
reset_invalid_filament(key, false);
for (const char* key : feature_keys)
reset_invalid_filament(key, true);
// Sub-layer splitting divides each layer by the mix ratio; an adaptive layer profile makes
// those sub-layer heights vary per layer, which degrades the blend. Warn once per enable.
{
static bool s_mixed_sublayer_warned = false;
bool sublayer_on = config->opt_bool("enable_mixed_color_sublayer");
if (sublayer_on && !s_mixed_sublayer_warned &&
wxGetApp().app_config->get("no_warn_mixed_sublayer_variable_layer") != "1") {
bool has_variable_layer = false;
for (const auto* obj : wxGetApp().model().objects) {
if (obj->layer_height_profile.get().size() > 4) {
has_variable_layer = true;
break;
}
}
if (has_variable_layer) {
MessageDialog dialog(m_msg_dlg_parent,
_L("Using variable layer height together with mixed color sublayer may result in poor color mixing quality."),
"", wxICON_WARNING | wxOK);
dialog.show_dsa_button();
is_msg_dlg_already_exist = true;
dialog.ShowModal();
is_msg_dlg_already_exist = false;
if (dialog.get_checkbox_state())
wxGetApp().app_config->set("no_warn_mixed_sublayer_variable_layer", "1");
s_mixed_sublayer_warned = true;
}
}
if (!sublayer_on)
s_mixed_sublayer_warned = false;
}
if (config->opt_enum<SeamScarfType>("seam_slope_type") != SeamScarfType::None &&
config->get_abs_value("seam_slope_start_height") >= layer_height) {
const wxString msg_text = _(L("seam_slope_start_height needs to be smaller than layer_height.\nReset to 0."));
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
new_conf.set_key_value("seam_slope_start_height", new ConfigOptionFloatOrPercent(0, false));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
// layer_height shouldn't be equal to zero
float skin_depth = config->opt_float("skin_infill_depth");
if (config->opt_float("infill_lock_depth") > skin_depth) {
// xgettext:no-c-format, no-boost-format
const wxString msg_text = _(L("Lock depth should be smaller than skin depth.\nReset to 50% of skin depth."));
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
new_conf.set_key_value("infill_lock_depth", new ConfigOptionFloat(skin_depth / 2));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
bool have_arachne = config->opt_enum<PerimeterGeneratorType>("wall_generator") == PerimeterGeneratorType::Arachne;
if (config->opt_enum<FuzzySkinMode>("fuzzy_skin_mode") != FuzzySkinMode::Displacement && !have_arachne) {
wxString msg_text = _(L("Both [Extrusion] and [Combined] modes of Fuzzy Skin require the Arachne Wall Generator to be enabled."));
msg_text += "\n\n" + _(L("Change these settings automatically?\n"
"Yes - Enable Arachne Wall Generator\n"
"No - Disable Arachne Wall Generator and set [Displacement] mode of the Fuzzy Skin"));
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxYES | wxNO);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
auto answer = dialog.ShowModal();
if (answer == wxID_YES)
new_conf.set_key_value("wall_generator", new ConfigOptionEnum<PerimeterGeneratorType>(PerimeterGeneratorType::Arachne));
else
new_conf.set_key_value("fuzzy_skin_mode", new ConfigOptionEnum<FuzzySkinMode>(FuzzySkinMode::Displacement));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
}
void ConfigManipulation::apply_null_fff_config(DynamicPrintConfig *config, std::vector<std::string> const &keys, std::map<ObjectBase *, ModelConfig *> const &configs)
{
for (auto &k : keys) {
if (k == "independent_support_layer_height" || k == "enable_support" || k == "detect_thin_wall")
config->set_key_value(k, new ConfigOptionBool(true));
else if (k == "wall_loops")
config->set_key_value(k, new ConfigOptionInt(0));
else if (k == "top_shell_layers" || k == "enforce_support_layers")
config->set_key_value(k, new ConfigOptionInt(1));
else if (k == "sparse_infill_density") {
double v = config->option<ConfigOptionPercent>(k)->value;
for (auto &c : configs) {
auto o = c.second->get().option<ConfigOptionPercent>(k);
if (o && o->value > v) v = o->value;
}
config->set_key_value(k, new ConfigOptionPercent(v)); // sparse_infill_pattern
}
else if (k == "detect_overhang_wall")
config->set_key_value(k, new ConfigOptionBool(false));
else if (k == "sparse_infill_pattern")
config->set_key_value(k, new ConfigOptionEnum<InfillPattern>(ipGrid));
}
}
void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, int variant_index, const bool is_global_config)
{
PresetBundle *preset_bundle = wxGetApp().preset_bundle;
const GCodeFlavor gcflavor = preset_bundle->printers.get_edited_preset().config.option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor")->value;
// Orca: use booleans to avoid repeated comparisons with enum values
const bool gcf_is_marlin_firmware = gcflavor == GCodeFlavor::gcfMarlinFirmware;
const bool gcf_is_klipper = gcflavor == GCodeFlavor::gcfKlipper;
// Belt printer: detect early since it affects multiple toggle decisions below.
// `is_belt_tilted` is the stricter test that mirrors PrintObject::has_belt_brim():
// only a tilted belt gets the belt-plane brim, while a belt printer with no
// rotation is geometrically a flat bed and keeps the ordinary plate brim.
bool is_belt_printer = false;
bool is_belt_tilted = false;
{
const auto &printer_cfg = preset_bundle->printers.get_edited_preset().config;
const auto *belt_opt = printer_cfg.option<ConfigOptionBool>("belt_printer");
if (belt_opt)
is_belt_printer = belt_opt->value;
const auto *axis = printer_cfg.option<ConfigOptionEnum<BeltRotationAxis>>("belt_slice_rotation");
const auto *angle = printer_cfg.option<ConfigOptionFloat>("belt_slice_rotation_angle");
if (is_belt_printer && axis != nullptr && angle != nullptr) {
// Same window as Print::has_tilted_belt(); shared constants so the GUI and
// the backend cannot drift apart.
const double tilt = std::abs(angle->value);
is_belt_tilted = (axis->value == BeltRotationAxis::X || axis->value == BeltRotationAxis::Y)
&& tilt >= BELT_BRIM_MIN_TILT_DEG && tilt <= BELT_BRIM_MAX_TILT_DEG;
}
}
bool have_volumetric_extrusion_rate_slope = config->option<ConfigOptionFloat>("max_volumetric_extrusion_rate_slope")->value > 0;
float have_volumetric_extrusion_rate_slope_segment_length = config->option<ConfigOptionFloat>("max_volumetric_extrusion_rate_slope_segment_length")->value;
const wxString extrusion_smoothing_reason = _L("Set the maximum volumetric extrusion rate slope above zero to use extrusion rate smoothing.");
toggle_field("enable_arc_fitting", !have_volumetric_extrusion_rate_slope && !is_belt_printer, -1, _L("Arc fitting is unavailable for belt printers and when extrusion rate smoothing is enabled."));
toggle_line("max_volumetric_extrusion_rate_slope_segment_length", have_volumetric_extrusion_rate_slope, -1, extrusion_smoothing_reason);
toggle_line("extrusion_rate_smoothing_external_perimeter_only", have_volumetric_extrusion_rate_slope, -1, extrusion_smoothing_reason);
if(have_volumetric_extrusion_rate_slope) config->set_key_value("enable_arc_fitting", new ConfigOptionEnum<ArcFittingMode>(ArcFittingMode::Disabled));
if(have_volumetric_extrusion_rate_slope_segment_length < 0.5) {
DynamicPrintConfig new_conf = *config;
new_conf.set_key_value("max_volumetric_extrusion_rate_slope_segment_length", new ConfigOptionFloat(1));
apply(config, &new_conf);
}
bool have_perimeters = config->opt_int("wall_loops") > 0;
const wxString wall_loops_reason = _L("Set wall loops above zero to use this setting.");
for (auto el : { "extra_perimeters_on_overhangs", "ensure_vertical_shell_thickness", "detect_thin_wall", "detect_overhang_wall",
"seam_position", "staggered_inner_seams", "wall_sequence", "outer_wall_line_width" })
toggle_field(el, have_perimeters, -1, wall_loops_reason);
for (auto el : { "inner_wall_speed", "outer_wall_speed", "small_perimeter_speed", "small_perimeter_threshold" })
toggle_field(el, have_perimeters, variant_index, wall_loops_reason);
bool have_infill = config->option<ConfigOptionPercent>("sparse_infill_density")->value > 0;
// sparse_infill_filament_id uses the same logic as in Print::extruders()
for (auto el : { "sparse_infill_pattern", "infill_combination", "fill_multiline","infill_direction",
"infill_complete_top",
"minimum_sparse_infill_area", "sparse_infill_filament_id","infill_shift_step","sparse_infill_rotate_template","symmetric_infill_y_axis"})
toggle_line(el, have_infill, -1, _L("This setting is hidden because sparse infill density is zero."));
InfillPattern pattern = config->opt_enum<InfillPattern>("sparse_infill_pattern");
// Orca: the concentric patterns follow the surface outline instead of crossing it, so there is
// nothing for an infill anchor to attach to. Hide the anchor settings for them.
bool have_infill_anchor = have_infill && pattern != ipConcentric && pattern != ipSpiralInset;
const wxString infill_anchor_reason = _L("Infill anchors require nonzero sparse infill density and a pattern other than Concentric or Spiral Inset.");
toggle_line("infill_anchor", have_infill_anchor, -1, infill_anchor_reason);
toggle_line("infill_anchor_max", have_infill_anchor, -1, infill_anchor_reason);
bool have_combined_infill = config->opt_bool("infill_combination") && have_infill;
toggle_line("infill_combination_max_layer_height", have_combined_infill, -1, _L("Enable infill combination and use nonzero sparse infill density to show this setting."));
// Infill patterns that support multiline infill.
bool have_multiline_infill_pattern = pattern == ipGyroid || pattern == ipGrid || pattern == ipRectilinear || pattern == ipTpmsD || pattern == ipTpmsFK || pattern == ipCrossHatch || pattern == ipHoneycomb || pattern == ipLateralLattice || pattern == ipLateralHoneycomb || pattern == ipConcentric ||
pattern == ipCubic || pattern == ipStars || pattern == ipAlignedRectilinear || pattern == ipLightning || pattern == ip3DHoneycomb || pattern == ipAdaptiveCubic || pattern == ipSupportCubic|| pattern == ipTriangles || pattern == ipQuarterCubic|| pattern == ipArchimedeanChords || pattern == ipHilbertCurve || pattern == ipOctagramSpiral;
// The sparse infill density is the surface density of the adaptive infill; at 100% the infill is solid.
bool have_adaptive_infill_pattern = have_infill && config->option<ConfigOptionPercent>("sparse_infill_density")->value < 100 &&
is_adaptive_infill_pattern(pattern);
toggle_line("adaptive_infill_mode", have_adaptive_infill_pattern, -1, _L("Select Gyroid, TPMS-D or TPMS-FK infill with sparse infill density greater than zero and less than 100%."));
bool have_adaptive_infill = have_adaptive_infill_pattern && config->opt_enum<AdaptiveInfillMode>("adaptive_infill_mode") != AdaptiveInfillMode::Disabled;
const wxString adaptive_density_reason = _L("Enable adaptive density for Gyroid, TPMS-D or TPMS-FK infill with sparse infill density greater than zero and less than 100%.");
toggle_line("adaptive_infill_interior_density", have_adaptive_infill, -1, adaptive_density_reason);
toggle_line("adaptive_infill_gradient", have_adaptive_infill, -1, adaptive_density_reason);
// gyroid_optimized only applies when the sparse infill pattern is gyroid without adaptive density;
// hide the whole line otherwise.
toggle_line("gyroid_optimized", have_infill && pattern == ipGyroid && !have_adaptive_infill, -1, _L("Select Gyroid infill with nonzero sparse infill density and disable adaptive density to use this setting."));
// If there is infill, enable/disable fill_multiline according to whether the pattern supports multiline infill.
if (have_infill) {
toggle_field("fill_multiline", have_multiline_infill_pattern, -1, _L("The selected sparse infill pattern does not support multiline infill."));
// If the infill pattern does not support multiline fill_multiline is changed to 1.
// Necessary when the pattern contains params.multiline (for example, triangles because they belong to the rectilinear class)
if (!have_multiline_infill_pattern) {
DynamicPrintConfig new_conf = *config;
new_conf.set_key_value("fill_multiline", new ConfigOptionInt(1));
apply(config, &new_conf);
}
// Hide infill anchor max if sparse_infill_pattern is not line or if sparse_infill_pattern is line but infill_anchor_max is 0.
bool infill_anchor = config->opt_enum<InfillPattern>("sparse_infill_pattern") != ipLine;
toggle_field("infill_anchor_max", infill_anchor, -1, _L("The Line infill pattern does not support infill anchors."));
// Only allow configuration of open anchors if the anchoring is enabled.
bool has_infill_anchors = infill_anchor && config->option<ConfigOptionFloatOrPercent>("infill_anchor_max")->value > 0;
toggle_field("infill_anchor", has_infill_anchors, -1, _L("Select an infill pattern other than Line and set the maximum infill anchor length above zero."));
}
//cross zag
bool is_cross_zag = config->option<ConfigOptionEnum<InfillPattern>>("sparse_infill_pattern")->value == InfillPattern::ipCrossZag;
bool is_locked_zig = config->option<ConfigOptionEnum<InfillPattern>>("sparse_infill_pattern")->value == InfillPattern::ipLockedZag;
toggle_line("infill_shift_step", is_cross_zag || is_locked_zig, -1, _L("Select the Cross Zag or Locked Zag sparse infill pattern to use this setting."));
for (auto el : { "skeleton_infill_density", "skin_infill_density", "infill_lock_depth", "skin_infill_depth","skin_infill_line_width", "skeleton_infill_line_width" })
toggle_line(el, is_locked_zig, -1, _L("Select the Locked Zag sparse infill pattern to use this setting."));
bool is_zig_zag = config->option<ConfigOptionEnum<InfillPattern>>("sparse_infill_pattern")->value == InfillPattern::ipZigZag;
toggle_line("symmetric_infill_y_axis", is_zig_zag || is_cross_zag || is_locked_zig, -1, _L("Select the Zig Zag, Cross Zag or Locked Zag sparse infill pattern to use this setting."));
bool is_3Dhoneycomb = config->option<ConfigOptionEnum<InfillPattern>>("sparse_infill_pattern")->value == InfillPattern::ip3DHoneycomb;
toggle_line("infill_complete_top", have_infill && is_3Dhoneycomb, -1, _L("Select 3D Honeycomb infill with nonzero sparse infill density to use this setting."));
bool has_spiral_vase = config->opt_bool("spiral_mode");
const wxString spiral_mode_reason = _L("Enable spiral vase mode to use this setting.");
toggle_line("spiral_mode_smooth", has_spiral_vase, -1, spiral_mode_reason);
toggle_line("spiral_mode_max_xy_smoothing", has_spiral_vase && config->opt_bool("spiral_mode_smooth"), -1, _L("Enable spiral vase mode and spiral smoothing to use this setting."));
toggle_line("spiral_starting_flow_ratio", has_spiral_vase, -1, spiral_mode_reason);
toggle_line("spiral_finishing_flow_ratio", has_spiral_vase, -1, spiral_mode_reason);
bool has_top_shell_layers = config->opt_int("top_shell_layers") > 0 || (has_spiral_vase && config->opt_int("bottom_shell_layers") > 1);
const wxString top_shell_layers_reason = _L("This setting requires top shell layers, or more than one bottom shell layer in spiral vase mode.");
bool has_top_shell = has_top_shell_layers && config->option<ConfigOptionPercent>("top_surface_density")->value > 0;
const wxString top_shell_reason = _L("This setting requires a top shell with nonzero top surface density.");
bool has_bottom_shell = config->opt_int("bottom_shell_layers") > 0;
const wxString bottom_shell_reason = _L("Set bottom shell layers above zero to use this setting.");
bool has_solid_infill = has_top_shell_layers || has_bottom_shell;
toggle_line("sparse_infill_smooth_factor", have_infill && is_smoothable_infill_pattern(pattern, config->opt_int("fill_multiline")), -1, _L("Use nonzero sparse infill density and an infill pattern and multiline setting that support infill smoothing."));
toggle_field("top_surface_pattern", has_top_shell, -1, top_shell_reason);
toggle_field("bottom_surface_pattern", has_bottom_shell, -1, bottom_shell_reason);
toggle_field("top_surface_density", has_top_shell_layers, -1, top_shell_layers_reason);
toggle_field("bottom_surface_density", has_bottom_shell, -1, bottom_shell_reason);
toggle_field("top_layer_direction", has_top_shell, -1, top_shell_reason);
toggle_field("bottom_layer_direction", has_bottom_shell, -1, bottom_shell_reason);
toggle_line("top_surface_expansion", has_top_shell, -1, top_shell_reason);
toggle_line("top_surface_expansion_margin", has_top_shell, -1, top_shell_reason);
bool has_top_surface_expansion = config->opt_float("top_surface_expansion") > 0;
const wxString top_surface_expansion_reason = _L("Set top surface expansion above zero to use this setting.");
toggle_field("top_surface_expansion_margin", has_top_surface_expansion, -1, top_surface_expansion_reason);
toggle_line("top_surface_expansion_direction", has_top_shell, -1, top_shell_reason);
toggle_field("top_surface_expansion_direction", has_top_surface_expansion, -1, top_surface_expansion_reason);
// Orca: Archimedean Chords and Octagram Spiral are the centered surface patterns that the
// pattern-centering feature acts on.
auto is_centered_pattern = [](InfillPattern p) {
return p == InfillPattern::ipArchimedeanChords || p == InfillPattern::ipOctagramSpiral;
};
bool is_top_centered = is_centered_pattern(config->option<ConfigOptionEnum<InfillPattern>>("top_surface_pattern")->value);
bool is_bottom_centered = is_centered_pattern(config->option<ConfigOptionEnum<InfillPattern>>("bottom_surface_pattern")->value);
bool has_centered_surface = (has_top_shell && is_top_centered) || (has_bottom_shell && is_bottom_centered);
// Orca: center of surface pattern
toggle_line("center_of_surface_pattern", has_centered_surface, -1, _L("Use a top or bottom shell with the Archimedean Chords or Octagram Spiral surface pattern."));
// Orca: separate infills
toggle_line("separated_infills", is_separable_infill_pattern(pattern), -1, _L("The selected sparse infill pattern does not support separated infills."));
// Fill order is only meaningful for the center-based surface fill patterns; hide it otherwise.
auto is_centered_fill = [](InfillPattern p) { return p == ipConcentric || p == ipSpiralInset || p == ipArchimedeanChords || p == ipOctagramSpiral; };
toggle_line("top_surface_fill_order", has_top_shell && is_centered_fill(config->opt_enum<InfillPattern>("top_surface_pattern")), -1, _L("Use a top shell with nonzero surface density and the Concentric, Spiral Inset, Archimedean Chords or Octagram Spiral surface pattern."));
toggle_line("bottom_surface_fill_order", has_bottom_shell && is_centered_fill(config->opt_enum<InfillPattern>("bottom_surface_pattern")), -1, _L("Use bottom shell layers and the Concentric, Spiral Inset, Archimedean Chords or Octagram Spiral surface pattern."));
const wxString infill_or_shell_reason = _L("Use nonzero sparse infill density or top or bottom shell layers to edit this setting.");
for (auto el : { "infill_direction", "sparse_infill_line_width", "gap_fill_target","filter_out_gap_fill","infill_wall_overlap",
"bridge_angle", "internal_bridge_angle", "relative_bridge_angle",
"solid_infill_direction", "solid_infill_rotate_template", "internal_solid_infill_pattern", "internal_solid_filament_id", "top_surface_filament_id", "bottom_surface_filament_id",
})
toggle_field(el, have_infill || has_solid_infill, -1, infill_or_shell_reason);
for (auto el : { "sparse_infill_speed", "bridge_speed", "internal_bridge_speed"})
toggle_field(el, have_infill || has_solid_infill, variant_index, infill_or_shell_reason);
toggle_field("top_shell_thickness", ! has_spiral_vase && has_top_shell_layers, -1, _L("Disable spiral vase mode and set top shell layers above zero to edit top shell thickness."));
toggle_field("bottom_shell_thickness", ! has_spiral_vase && has_bottom_shell, -1, _L("Disable spiral vase mode and set bottom shell layers above zero to edit bottom shell thickness."));
// Gap fill is newly allowed in between perimeter lines even for empty infill (see GH #1476).
toggle_field("gap_infill_speed", have_perimeters, variant_index, wall_loops_reason);
toggle_field("top_surface_line_width", has_top_shell, -1, top_shell_reason);
toggle_field("top_surface_speed", has_top_shell, variant_index, top_shell_reason);
bool have_default_acceleration = config->opt_float_nullable("default_acceleration", variant_index) > 0;
for (auto el : {"outer_wall_acceleration", "inner_wall_acceleration", "initial_layer_acceleration", "initial_layer_travel_acceleration",
"top_surface_acceleration", "travel_acceleration", "bridge_acceleration", "sparse_infill_acceleration", "internal_solid_infill_acceleration"})
toggle_field(el, have_default_acceleration, variant_index, _L("Set default acceleration above zero to edit acceleration for individual extrusion roles."));
bool machine_supports_junction_deviation = false;
if (gcf_is_marlin_firmware) {
if (const auto *machine_jd = preset_bundle->printers.get_edited_preset().config.option<ConfigOptionFloats>("machine_max_junction_deviation")) {
machine_supports_junction_deviation = !machine_jd->values.empty() && machine_jd->values.front() > 0.0;
}
}
toggle_line("default_junction_deviation", gcf_is_marlin_firmware, variant_index, _L("This setting requires the Marlin firmware G-code flavor."));
if (machine_supports_junction_deviation) {
toggle_field("default_junction_deviation", true, variant_index);
const wxString junction_deviation_jerk_reason = _L("Jerk settings are unavailable while the printer uses junction deviation.");
toggle_field("default_jerk", false, variant_index, junction_deviation_jerk_reason);
for (auto el : { "outer_wall_jerk", "inner_wall_jerk", "initial_layer_jerk", "initial_layer_travel_jerk", "top_surface_jerk", "travel_jerk", "infill_jerk"})
toggle_line(el, false, variant_index, junction_deviation_jerk_reason);
} else {
toggle_field("default_junction_deviation", false, variant_index, _L("Set the printer junction deviation limit above zero with the Marlin firmware G-code flavor to edit this setting."));
toggle_field("default_jerk", true, variant_index);
bool have_default_jerk = config->has("default_jerk") && config->opt_float_nullable("default_jerk", variant_index) > 0;
for (auto el : { "outer_wall_jerk", "inner_wall_jerk", "initial_layer_jerk", "initial_layer_travel_jerk", "top_surface_jerk", "travel_jerk", "infill_jerk"}) {
toggle_line(el, true, variant_index);
toggle_field(el, have_default_jerk, variant_index, _L("Set default jerk above zero to edit jerk for individual extrusion roles."));
}
}
// Belt printer: disable skirt, brim, raft, and draft shield controls.
bool have_skirt = config->opt_int("skirt_loops") > 0 && !is_belt_printer;
const wxString skirt_reason = _L("Use a non-belt printer with skirt loops above zero to use this setting.");
toggle_field("skirt_height", have_skirt && config->opt_enum<DraftShield>("draft_shield") != dsEnabled, -1, _L("Use a non-belt printer with skirt loops above zero and disable the full-height draft shield to edit skirt height."));
toggle_line("single_loop_draft_shield", have_skirt, -1, skirt_reason); // ORCA: Display one wall if skirt enabled
for (auto el : {"skirt_type", "min_skirt_length", "skirt_distance", "skirt_start_angle", "skirt_speed", "draft_shield"})
toggle_field(el, have_skirt, -1, skirt_reason);
if (is_belt_printer) {
const wxString belt_skirt_reason = _L("Skirts are unavailable for belt printers.");
toggle_field("skirt_loops", false, -1, belt_skirt_reason);
toggle_field("skirt_height", false, -1, belt_skirt_reason);
}
// Belt printers now get a brim too, laid onto the tilted belt by BeltBrim.cpp,
// so brim type / width / object gap all apply. A belt printer with no tilt is
// geometrically a flat bed and uses the ordinary plate brim, hence the separate
// is_belt_tilted test.
bool have_brim = config->opt_enum<BrimType>("brim_type") != btNoBrim;
const wxString brim_reason = _L("Select a brim type other than No brim to use this setting.");
toggle_field("brim_object_gap", have_brim, -1, brim_reason);
// Both are first-layer-only concepts that the belt path cannot honour.
const wxString flat_bed_brim_reason = _L("Enable a brim on a printer without a tilted belt to use this setting.");
toggle_field("brim_use_efc_outline", have_brim && !is_belt_tilted, -1, flat_bed_brim_reason);
toggle_field("combine_brims", have_brim && !is_belt_tilted, -1, flat_bed_brim_reason);
bool have_brim_width = have_brim && config->opt_enum<BrimType>("brim_type") != btAutoBrim &&
config->opt_enum<BrimType>("brim_type") != btPainted;
// On a tilted belt Auto / Mouse ear / Painted all collapse to outer-only at the
// configured width, so the width field has to stay live for them too.
toggle_field("brim_width", have_brim_width || (have_brim && is_belt_tilted), -1, _L("Select a brim type with an editable width, or enable a brim on a tilted belt printer."));
toggle_field("brim_flow_ratio", have_brim, -1, brim_reason);
// Paired toggle_line + toggle_field: cb_toggle_line is null in the per-object
// override panel, so the row cannot be hidden there and greying out is the
// fallback. Both extras are belt-only: one extends the brim ahead along the belt,
// the other widens it across the belt.
for (auto el : { "leading_brim_length", "extra_brim_width" }) {
toggle_line(el, is_belt_tilted, -1, _L("This setting requires a belt printer with a tilted slicing plane."));
toggle_field(el, is_belt_tilted && have_brim, -1, _L("Enable a brim on a belt printer with a tilted slicing plane to use this setting."));
}
// Wall filament selectors use the same logic as in Print::extruders().
const wxString wall_filament_reason = _L("Enable walls or a brim to select the wall filament.");
toggle_field("outer_wall_filament_id", have_perimeters || have_brim, -1, wall_filament_reason);
toggle_field("inner_wall_filament_id", have_perimeters || have_brim, -1, wall_filament_reason);
const BrimType brim_type = config->opt_enum<BrimType>("brim_type");
const bool have_auto_brim_ear = brim_type == btEar && !is_belt_tilted;
const bool have_painted_brim_ear = brim_type == btPainted && !is_belt_tilted;
set_option_label("brim_width", have_auto_brim_ear ? L("Brim ear radius") : L("Brim width"));
const auto brim_width = config->opt_float("brim_width");
// Automatic brim ear settings require a non-zero brim width.
const wxString brim_width_reason = _L("Set brim width above zero to edit brim ear detection.");
toggle_field("brim_ears_max_angle", brim_width > 0.0f, -1, brim_width_reason);
toggle_field("brim_ears_detection_length", brim_width > 0.0f, -1, brim_width_reason);
// Painted ears carry their own radius and do not depend on brim_width.
toggle_field("brim_ears_outer_only", have_painted_brim_ear || brim_width > 0.0f, -1, _L("Use painted brim ears or set brim width above zero to edit this setting."));
const wxString automatic_brim_ear_reason = _L("Select automatic brim ears on a printer without a tilted belt to use this setting.");
toggle_line("brim_ears_max_angle", have_auto_brim_ear, -1, automatic_brim_ear_reason);
toggle_line("brim_ears_detection_length", have_auto_brim_ear, -1, automatic_brim_ear_reason);
toggle_line("brim_ears_outer_only", have_auto_brim_ear || have_painted_brim_ear, -1, _L("Select automatic or painted brim ears on a printer without a tilted belt to use this setting."));
// Hide Elephant foot compensation layers if elefant_foot_compensation is not enabled
toggle_line("elefant_foot_compensation_layers", config->opt_float("elefant_foot_compensation") > 0 || config->option<ConfigOptionPercent>("elefant_foot_layers_density")->get_abs_value(1.0f) < 1.0f, -1, _L("Enable elephant foot compensation or set elephant foot layer density below 100% to use this setting."));
bool have_raft = config->opt_int("raft_layers") > 0 && !is_belt_printer;
if (is_belt_printer)
toggle_field("raft_layers", false, -1, _L("Rafts are unavailable for belt printers."));
bool have_support_material = config->opt_bool("enable_support") || have_raft;
const wxString enable_support_reason = _L("Enable support to edit this setting.");
const wxString support_reason = is_belt_printer ? enable_support_reason :
_L("Enable support or add raft layers to edit this setting.");
SupportType support_type = config->opt_enum<SupportType>("support_type");
bool have_support_interface = config->opt_int("support_interface_top_layers") > 0 || config->opt_int("support_interface_bottom_layers") > 0;
bool have_support_soluble = have_support_material && config->opt_float("support_top_z_distance") == 0;
auto support_style = config->opt_enum<SupportMaterialStyle>("support_style");
for (auto el : { "support_style", "support_base_pattern",
"support_base_pattern_spacing", "support_expansion", "support_angle",
"support_interface_pattern", "support_interface_top_layers", "support_interface_bottom_layers",
"bridge_no_support", "max_bridge_length", "support_top_z_distance", "support_bottom_z_distance",
"support_type", "support_on_build_plate_only", "support_critical_regions_only", "support_interface_not_for_body",
"support_object_xy_distance", "support_object_first_layer_gap", "independent_support_layer_height"})
toggle_field(el, have_support_material, -1, support_reason);
toggle_field("support_threshold_angle", have_support_material && is_auto(support_type), -1,
!have_support_material ? support_reason : _L("Select an automatic support type to edit the threshold angle."));
toggle_field("support_threshold_overlap", config->opt_int("support_threshold_angle") == 0 && have_support_material && is_auto(support_type), -1,
!have_support_material ? support_reason : _L("Select an automatic support type and set the threshold angle to zero to edit threshold overlap."));
//toggle_field("support_closing_radius", have_support_material && support_style == smsSnug);
bool support_is_tree = config->opt_bool("enable_support") && is_tree(support_type);
bool support_is_organic = support_is_tree && (support_style == smsTreeOrganic || support_style == smsDefault);
bool support_is_normal_tree = support_is_tree && !support_is_organic;
// hide settings that are not used by tree supports
toggle_line("support_threshold_overlap", !support_is_tree, -1, _L("Threshold overlap is unavailable for tree supports.")); // ORCA: tree supports do not use Threshold Overlap
// settings specific to normal trees
for (auto el : {"tree_support_branch_angle", "tree_support_branch_distance", "tree_support_branch_diameter", "tree_support_auto_brim", "tree_support_brim_width"})
toggle_line(el, support_is_normal_tree, -1, _L("Enable tree supports and select a style other than Organic or Default to show this setting."));
// settings specific to organic trees
for (auto el : {"tree_support_branch_angle_organic", "tree_support_branch_distance_organic", "tree_support_branch_diameter_organic", "tree_support_angle_slow", "tree_support_tip_diameter", "tree_support_top_rate", "tree_support_branch_diameter_angle"})
toggle_line(el, support_is_organic, -1, _L("Enable tree supports with the Organic or Default style to show this setting."));
// ORCA: Independent support layer height is not compatible with organic tree supports,
// as they rely on the support layers being the same as the object layers to determine where to place branches.
toggle_line("independent_support_layer_height", have_support_material && !support_is_organic, -1,
!have_support_material ? support_reason : _L("Independent support layer height is unavailable for organic tree supports."));
toggle_field("tree_support_brim_width", support_is_tree && !config->opt_bool("tree_support_auto_brim"), -1,
_L("Enable tree supports and turn off automatic brim width to edit the tree support brim width."));
// tree support use max_bridge_length instead of bridge_no_support
toggle_line("max_bridge_length", support_is_tree, -1, _L("Enable tree supports to show the maximum bridge length."));
toggle_line("bridge_no_support", !support_is_tree, -1, _L("Tree supports use maximum bridge length instead of the bridge support setting."));
toggle_line("support_critical_regions_only", is_auto(support_type) && support_is_tree, -1, _L("Enable automatic tree supports to show this setting."));
for (auto el : { "support_interface_filament",
"support_interface_loop_pattern", "support_bottom_interface_spacing" })
toggle_field(el, have_support_material && have_support_interface, -1,
!have_support_material ? support_reason : _L("Set top or bottom support interface layers above zero to edit this setting."));
bool can_ironing_support = have_raft || (have_support_material && config->opt_int("support_interface_top_layers") > 0);
toggle_field("support_ironing", can_ironing_support, -1, _L("Enable a raft, or enable supports with top interface layers, to use support ironing."));
bool has_support_ironing = can_ironing_support && config->opt_bool("support_ironing");
for (auto el : {"support_ironing_pattern", "support_ironing_flow", "support_ironing_spacing" })
toggle_line(el, has_support_ironing, -1, _L("Enable support ironing with a raft or top support interface layers to show this setting."));
// Orca: Force solid support interface when using support ironing
toggle_field("support_interface_spacing", have_support_material && have_support_interface && !has_support_ironing, -1,
!have_support_material ? support_reason :
!have_support_interface ? _L("Set top or bottom support interface layers above zero to edit interface spacing.") :
_L("Support ironing requires a solid interface, so interface spacing cannot be edited."));
// see issue #10915
// bool have_skirt_height = have_skirt &&
// (config->opt_int("skirt_height") > 1 || config->opt_enum<DraftShield>("draft_shield") != dsEnabled);
// toggle_line("support_speed", have_support_material || have_skirt_height);
// toggle_line("support_interface_speed", have_support_material && have_support_interface);
// Orca:
for (auto el : {"small_support_perimeter_speed", "small_support_perimeter_threshold"})
toggle_field(el, config->opt_bool("enable_support"), -1, enable_support_reason);
// BBS
//toggle_field("support_material_synchronize_layers", have_support_soluble);
toggle_field("inner_wall_line_width", have_perimeters || have_skirt || have_brim, -1, _L("Enable walls, a skirt or a brim to edit inner wall line width."));
toggle_field("support_filament", have_support_material || have_skirt, -1, _L("Enable support, a raft, or a skirt to select the support filament."));
toggle_line("raft_contact_distance", have_raft && !have_support_soluble, -1,
!have_raft ? _L("Add raft layers to show raft contact distance.") : _L("Raft contact distance is unavailable when the top support Z distance is zero."));
// Orca:Hide raft expansion when raft is not enabled
toggle_line("raft_expansion", have_raft, -1, _L("Add raft layers to show raft expansion."));
// Orca: Slim, Strong and Hybrid tree supports size their raft by first layer expansion only.
toggle_field("raft_expansion", !(is_tree(support_type) && (support_style == smsTreeSlim || support_style == smsTreeStrong || support_style == smsTreeHybrid)), -1,
_L("Slim, Strong and Hybrid tree supports use first layer expansion instead of raft expansion."));
// Orca: First-layer density is available for supports broadly.
toggle_field("raft_first_layer_density", have_support_material, -1, support_reason);
// Orca: For regular tree (Slim/Strong) without raft, hide first-layer expansion.
// Keep it enabled for non-tree supports, organic tree, hybrid tree, and any raft case.
toggle_field("raft_first_layer_expansion",
have_support_material && ((!support_is_normal_tree || support_style == smsTreeHybrid) || have_raft), -1,
!have_support_material ? support_reason : _L("Add a raft or choose a tree support style other than Slim or Strong to edit first layer expansion."));
bool has_ironing = (config->opt_enum<IroningType>("ironing_type") != IroningType::NoIroning);
for (auto el : { "ironing_pattern", "ironing_flow", "ironing_spacing", "ironing_angle", "ironing_inset", "ironing_angle_fixed" })
toggle_line(el, has_ironing, -1, _L("Enable ironing to use this setting."));
bool has_rectilinear_ironing = (config->opt_enum<InfillPattern>("ironing_pattern") == InfillPattern::ipRectilinear);
for (auto el : {"ironing_angle", "ironing_angle_fixed"})
toggle_field(el, has_ironing && has_rectilinear_ironing, -1, _L("Enable ironing with the Rectilinear pattern to edit ironing angles."));
toggle_line("ironing_speed", has_ironing || has_support_ironing, -1, _L("Enable ironing or support ironing to edit ironing speed."));
bool has_zaa = config->opt_bool("zaa_enabled");
for (auto el : {"zaa_minimize_perimeter_height", "zaa_min_z", "zaa_dont_alternate_fill_direction", "ironing_expansion"})
toggle_line(el, has_zaa, -1, _L("Enable Z contouring to use this setting."));
bool have_sequential_printing = (config->opt_enum<PrintSequence>("print_sequence") == PrintSequence::ByObject);
// for (auto el : { "extruder_clearance_radius", "extruder_clearance_height_to_rod", "extruder_clearance_height_to_lid" })
// toggle_field(el, have_sequential_printing);
toggle_field("print_order", !have_sequential_printing, -1, _L("Print order cannot be edited when the print sequence is By object."));
toggle_field("single_extruder_multi_material", !is_BBL_Printer, -1, _L("This setting is unavailable for Bambu Lab printers."));
auto bSEMM = preset_bundle->printers.get_edited_preset().config.opt_bool("single_extruder_multi_material");
const bool supports_wipe_tower_2 = !is_BBL_Printer && preset_bundle->printers.get_edited_preset().config.opt_enum<WipeTowerType>("wipe_tower_type") == WipeTowerType::Type2;
toggle_field("ooze_prevention", !bSEMM, -1, _L("This setting is unavailable in single extruder multimaterial mode."));
bool have_ooze_prevention = config->opt_bool("ooze_prevention");
const wxString ooze_prevention_reason = _L("Enable ooze prevention to use this setting.");
toggle_line("standby_temperature_delta", have_ooze_prevention, -1, ooze_prevention_reason);
toggle_line("preheat_time", have_ooze_prevention, -1, ooze_prevention_reason);
int preheat_steps = config->opt_int("preheat_steps");
toggle_line("preheat_steps", have_ooze_prevention && (preheat_steps > 0), -1, _L("Enable ooze prevention and use a positive number of preheat steps to show this setting."));
bool have_prime_tower = config->opt_bool("enable_prime_tower");
// ORCA-Belt: belt printers replace the classic wipe tower with the
// auto-generated belt purge prism, enabled by the belt-only printer option
// enable_belt_purge_tower. Its width (a process option) is only relevant
// then. (is_belt_printer is computed at the top of this function.)
const bool have_belt_purge_tower = is_belt_printer
&& preset_bundle->printers.get_edited_preset().config.has("enable_belt_purge_tower")
&& preset_bundle->printers.get_edited_preset().config.opt_bool("enable_belt_purge_tower");
toggle_line("belt_purge_tower_width", have_belt_purge_tower, -1, _L("Enable the belt purge tower in the belt printer settings to use this setting."));
const wxString prime_tower_reason = _L("Enable the prime tower on a non-belt printer to use this setting.");
for (auto el : {"prime_tower_width", "prime_tower_brim_width", "prime_tower_skip_points", "wipe_tower_wall_type", "prime_tower_infill_gap","prime_tower_enable_framework", "enable_tower_interface_features"})
toggle_line(el, have_prime_tower && !is_belt_printer, -1, prime_tower_reason);
toggle_line("enable_tower_interface_cooldown_during_tower",
have_prime_tower && !is_belt_printer && config->opt_bool("enable_tower_interface_features"), -1, _L("Enable the prime tower and tower interface features on a non-belt printer to use this setting."));
bool purge_in_primetower = preset_bundle->printers.get_edited_preset().config.opt_bool("purge_in_prime_tower");
for (auto el : {"wipe_tower_rotation_angle", "wipe_tower_cone_angle",
"wipe_tower_extra_spacing", "wipe_tower_max_purge_speed",
"wipe_tower_bridging", "wipe_tower_extra_flow"})
toggle_line(el, have_prime_tower && supports_wipe_tower_2 && !is_belt_printer, -1, _L("Enable the prime tower and select wipe tower Type 2 on a non-Bambu, non-belt printer."));
// Orca: both tower generators skip sparse layers, so this is not a wipe tower 2 exclusive.
toggle_line("wipe_tower_no_sparse_layers", have_prime_tower && !is_belt_printer, -1, prime_tower_reason);
// Dropping the sparse layers outright leaves nothing to combine, so the two are exclusive.
toggle_line("wipe_tower_sparse_layers_combination", have_prime_tower && !is_belt_printer && !config->opt_bool("wipe_tower_no_sparse_layers"), -1, _L("Enable the prime tower on a non-belt printer and turn off skipping sparse tower layers to use layer combination."));
WipeTowerWallType wipe_tower_wall_type = config->opt_enum<WipeTowerWallType>("wipe_tower_wall_type");
bool have_rib_wall = (wipe_tower_wall_type == WipeTowerWallType::wtwRib)&&have_prime_tower&&!is_belt_printer;
const wxString rib_wall_reason = _L("Enable the prime tower with Rib walls on a non-belt printer to use this setting.");
toggle_line("wipe_tower_cone_angle", have_prime_tower && supports_wipe_tower_2 && !is_belt_printer && wipe_tower_wall_type == WipeTowerWallType::wtwCone, -1, _L("Enable a Type 2 prime tower with Cone walls on a non-Bambu, non-belt printer."));
toggle_line("wipe_tower_extra_rib_length", have_rib_wall, -1, rib_wall_reason);
toggle_line("wipe_tower_rib_width", have_rib_wall, -1, rib_wall_reason);
toggle_line("wipe_tower_fillet_wall", have_rib_wall, -1, rib_wall_reason);
toggle_field("prime_tower_width", have_prime_tower && !have_rib_wall && !is_belt_printer, -1, _L("Enable the prime tower on a non-belt printer and choose a wall type other than Rib to edit tower width."));
toggle_line("single_extruder_multi_material_priming", !bSEMM && have_prime_tower && supports_wipe_tower_2 && !is_belt_printer, -1, _L("Enable a Type 2 prime tower on a non-Bambu, non-belt printer and disable single extruder multimaterial mode."));
bool use_cyclic_ordering = config->opt_enum<ToolChangeOrderingType>("toolchange_ordering") == ToolChangeOrderingType::Cyclic;
const wxString cyclic_order_reason = _L("Select Cyclic tool change ordering to use this setting.");
toggle_line("toolchange_cyclic_order", use_cyclic_ordering, -1, cyclic_order_reason);
toggle_line("toolchange_cyclic_first_layer", use_cyclic_ordering, -1, cyclic_order_reason);
toggle_line("prime_volume",have_prime_tower && (!purge_in_primetower || !bSEMM), -1, _L("Enable the prime tower and either disable purging in the prime tower or disable single extruder multimaterial mode."));
for (auto el : {"flush_into_infill", "flush_into_support", "flush_into_objects"})
toggle_field(el, have_prime_tower, -1, _L("Enable the prime tower to use this setting."));
bool have_avoid_crossing_perimeters = config->opt_bool("reduce_crossing_wall");
toggle_line("max_travel_detour_distance", have_avoid_crossing_perimeters, -1, _L("Enable avoiding crossing walls to edit the maximum travel detour distance."));
bool has_set_other_flow_ratios = config->opt_bool("set_other_flow_ratios");
for (auto el : {"first_layer_flow_ratio", "outer_wall_flow_ratio", "inner_wall_flow_ratio", "overhang_flow_ratio", "sparse_infill_flow_ratio", "internal_solid_infill_flow_ratio", "gap_fill_flow_ratio", "support_flow_ratio", "support_interface_flow_ratio"})
toggle_line(el, has_set_other_flow_ratios, -1, _L("Enable setting other flow ratios to use this setting."));
bool has_overhang_speed = config->opt_bool_nullable("enable_overhang_speed", variant_index);
const wxString overhang_speed_reason = _L("Enable slowing down for overhangs to use this setting.");
for (auto el : {"overhang_1_4_speed", "overhang_2_4_speed", "overhang_3_4_speed", "overhang_4_4_speed"})
toggle_line(el, has_overhang_speed, variant_index, overhang_speed_reason);
toggle_line("slowdown_for_curled_perimeters", has_overhang_speed, variant_index, overhang_speed_reason);
toggle_line("flush_into_objects", !is_global_config, -1, _L("This setting is available in object settings rather than global print settings."));
toggle_line("support_interface_not_for_body",config->opt_int("support_interface_filament")&&!config->opt_int("support_filament"), -1,
_L("Select a specific support interface filament and use the default support filament to show this setting."));
// Get the current fuzzy skin state
bool has_fuzzy_skin = config->opt_enum<FuzzySkinType>("fuzzy_skin") != FuzzySkinType::Disabled_fuzzy;
// Show fuzzy skin options when fuzzy skin is not disabled
for (auto el : {"fuzzy_skin_mode", "fuzzy_skin_noise_type", "fuzzy_skin_point_distance", "fuzzy_skin_thickness", "fuzzy_skin_first_layer"})
toggle_line(el, has_fuzzy_skin, -1, _L("Enable fuzzy skin to use this setting."));
// Show noise type specific options with the same logic
NoiseType fuzzy_skin_noise_type = config->opt_enum<NoiseType>("fuzzy_skin_noise_type");
const bool is_ripple = fuzzy_skin_noise_type == NoiseType::Ripple;
const wxString ripple_noise_reason = _L("Enable fuzzy skin with Ripple noise to use this setting.");
toggle_line("fuzzy_skin_scale", fuzzy_skin_noise_type != NoiseType::Classic && has_fuzzy_skin && !is_ripple, -1, _L("Enable fuzzy skin and select a noise type other than Classic or Ripple to edit noise scale."));
toggle_line("fuzzy_skin_octaves", fuzzy_skin_noise_type != NoiseType::Classic && fuzzy_skin_noise_type != NoiseType::Voronoi && has_fuzzy_skin && !is_ripple, -1, _L("Enable fuzzy skin and select a noise type other than Classic, Voronoi or Ripple to edit noise octaves."));
toggle_line("fuzzy_skin_persistence", (fuzzy_skin_noise_type == NoiseType::Perlin || fuzzy_skin_noise_type == NoiseType::Billow) && has_fuzzy_skin && !is_ripple, -1, _L("Enable fuzzy skin with Perlin or Billow noise to edit persistence."));
toggle_line("fuzzy_skin_ripples_per_layer", is_ripple && has_fuzzy_skin, -1, ripple_noise_reason);
toggle_line("fuzzy_skin_ripple_offset", is_ripple && has_fuzzy_skin, -1, ripple_noise_reason);
toggle_line("fuzzy_skin_layers_between_ripple_offset", is_ripple && has_fuzzy_skin, -1, ripple_noise_reason);
bool have_arachne = config->opt_enum<PerimeterGeneratorType>("wall_generator") == PerimeterGeneratorType::Arachne;
for (auto el : {"wall_transition_length", "wall_transition_filter_deviation", "wall_transition_angle", "min_feature_size", "min_length_factor",
"min_bead_width", "wall_distribution_count", "initial_layer_min_bead_width", "wall_maximum_resolution", "wall_maximum_deviation"})
toggle_line(el, have_arachne, -1, _L("Select the Arachne wall generator to use this setting."));
toggle_field("detect_thin_wall", !have_arachne, -1, _L("Thin wall detection is unavailable with the Arachne wall generator."));
// Orca
auto is_role_based_wipe_speed = config->opt_bool("role_based_wipe_speed");
toggle_field("wipe_speed",!is_role_based_wipe_speed, -1, _L("Disable role-based wipe speed to edit wipe speed manually."));
const bool have_wipe_inward = config->opt_bool("wipe_inward");
toggle_line("wipe_inward_distance", have_wipe_inward, -1, _L("Enable inward wiping to edit inward wipe distance."));
for (auto el : {"accel_to_decel_enable", "accel_to_decel_factor"})
toggle_line(el, gcf_is_klipper, -1, _L("This setting requires the Klipper G-code flavor."));
if(gcf_is_klipper)
toggle_field("accel_to_decel_factor", config->opt_bool("accel_to_decel_enable"), -1, _L("Enable acceleration to deceleration to edit its factor."));
toggle_line("exclude_object_tolerance", gcf_is_klipper && config->opt_bool("exclude_object"), -1,
_L("Enable excluding objects with the Klipper G-code flavor to edit the outline tolerance."));
bool have_make_overhang_printable = config->opt_bool("make_overhang_printable");
const wxString printable_overhang_reason = _L("Enable making overhangs printable to use this setting.");
toggle_line("make_overhang_printable_angle", have_make_overhang_printable, -1, printable_overhang_reason);
toggle_line("make_overhang_printable_hole_size", have_make_overhang_printable, -1, printable_overhang_reason);
// Orca: the one-wall options act on top/bottom surfaces, which exist only with a shell. An unfilled surface
// (0% surface density) is still a surface, so these are gated on the layer counts alone.
toggle_line("only_one_wall_first_layer", has_bottom_shell, -1, bottom_shell_reason);
toggle_line("only_one_wall_top", has_top_shell_layers, -1, top_shell_layers_reason);
toggle_line("min_width_top_surface", (has_top_shell_layers && config->opt_bool("only_one_wall_top")) || ((config->opt_float("min_length_factor") > 0.5f) && have_arachne), -1, _L("Enable only one wall on top surfaces with top shell layers, or use Arachne with a minimum wall length factor above 0.5.")); // 0.5 is default value
for (auto el : { "hole_to_polyhole_threshold", "hole_to_polyhole_twisted", "hole_to_polyhole_max_edges" })
toggle_line(el, config->opt_bool("hole_to_polyhole"), -1, _L("Enable converting holes to polyholes to use this setting."));
bool has_detect_overhang_wall = config->opt_bool("detect_overhang_wall");
bool has_overhang_reverse = config->opt_bool("overhang_reverse");
bool allow_overhang_reverse = !has_spiral_vase;
toggle_line("unsupported_wall_last", has_detect_overhang_wall, -1, _L("Enable overhang wall detection to use this setting."));
toggle_line("overhang_reverse", allow_overhang_reverse, -1, _L("Reverse overhang direction is unavailable in spiral vase mode."));
toggle_line("overhang_reverse_internal_only", allow_overhang_reverse && has_overhang_reverse, -1, _L("Disable spiral vase mode and enable reverse overhang direction to use this setting."));
bool has_overhang_reverse_internal_only = config->opt_bool("overhang_reverse_internal_only");
if (has_overhang_reverse_internal_only){
DynamicPrintConfig new_conf = *config;
new_conf.set_key_value("overhang_reverse_threshold", new ConfigOptionFloatOrPercent(0,true));
apply(config, &new_conf);
}
toggle_line("overhang_reverse_threshold", has_detect_overhang_wall && allow_overhang_reverse && has_overhang_reverse && !has_overhang_reverse_internal_only, -1, _L("Enable overhang wall detection and reverse overhang direction, disable spiral vase mode, and turn off reversing internal perimeters only."));
toggle_line("timelapse_type", is_BBL_Printer, -1, _L("This setting requires a Bambu Lab printer."));
bool have_small_area_infill_flow_compensation = config->opt_bool("small_area_infill_flow_compensation");
toggle_line("small_area_infill_flow_compensation_model", have_small_area_infill_flow_compensation, -1, _L("Enable small area infill flow compensation to edit its model."));
// Belt printers: the scarf would start one layer back along the belt, inside the
// previous layer (GCode::extrude_loop skips it there too).
toggle_field("seam_slope_type", !has_spiral_vase && !is_belt_printer, -1, _L("Scarf seams are unavailable in spiral vase mode and for belt printers."));
bool has_seam_slope = !has_spiral_vase && !is_belt_printer && config->opt_enum<SeamScarfType>("seam_slope_type") != SeamScarfType::None;
const wxString scarf_seam_reason = _L("Enable scarf seams on a non-belt printer with spiral vase mode disabled to use this setting.");
toggle_line("seam_slope_conditional", has_seam_slope, -1, scarf_seam_reason);
toggle_line("seam_slope_start_height", has_seam_slope, -1, scarf_seam_reason);
toggle_line("seam_slope_entire_loop", has_seam_slope, -1, scarf_seam_reason);
toggle_line("seam_slope_min_length", has_seam_slope, -1, scarf_seam_reason);
toggle_line("seam_slope_steps", has_seam_slope, -1, scarf_seam_reason);
toggle_line("seam_slope_inner_walls", has_seam_slope, -1, scarf_seam_reason);
toggle_line("scarf_joint_speed", has_seam_slope, -1, scarf_seam_reason);
toggle_line("scarf_joint_flow_ratio", has_seam_slope, -1, scarf_seam_reason);
toggle_field("seam_slope_min_length", !config->opt_bool("seam_slope_entire_loop"), -1, _L("Disable scarfing the entire loop to edit the minimum scarf length."));
const wxString conditional_scarf_reason = _L("Enable conditional scarf seams on a non-belt printer with spiral vase mode disabled to use this setting.");
toggle_line("scarf_angle_threshold", has_seam_slope && config->opt_bool("seam_slope_conditional"), -1, conditional_scarf_reason);
toggle_line("scarf_overhang_threshold", has_seam_slope && config->opt_bool("seam_slope_conditional"), -1, conditional_scarf_reason);
bool use_beam_interlocking = config->opt_bool("interlocking_beam");
const wxString beam_interlocking_reason = _L("Enable beam interlocking to use this setting.");
toggle_line("mmu_segmented_region_interlocking_depth", !use_beam_interlocking, -1, _L("Disable beam interlocking to edit segmented region interlocking depth."));
toggle_line("interlocking_beam_width", use_beam_interlocking, -1, beam_interlocking_reason);
toggle_line("interlocking_orientation", use_beam_interlocking, -1, beam_interlocking_reason);
toggle_line("interlocking_beam_layer_count", use_beam_interlocking, -1, beam_interlocking_reason);
toggle_line("interlocking_depth", use_beam_interlocking, -1, beam_interlocking_reason);
toggle_line("interlocking_boundary_avoidance", use_beam_interlocking, -1, beam_interlocking_reason);
bool lattice_options = config->opt_enum<InfillPattern>("sparse_infill_pattern") == InfillPattern::ipLateralLattice;
for (auto el : { "lateral_lattice_angle_1", "lateral_lattice_angle_2"})
toggle_line(el, lattice_options, -1, _L("Select the Lateral Lattice sparse infill pattern to use this setting."));
bool lightning_options = config->opt_enum<InfillPattern>("sparse_infill_pattern") == InfillPattern::ipLightning;
for (auto el : { "lightning_overhang_angle", "lightning_prune_angle", "lightning_straightening_angle" })
toggle_line(el, lightning_options, -1, _L("Select the Lightning sparse infill pattern to use this setting."));
// Adaptative Cubic and support cubic infill patterns do not support infill rotation.
bool FillAdaptive = (pattern == InfillPattern::ipAdaptiveCubic || pattern == InfillPattern::ipSupportCubic);
//Orca: disable infill_direction/solid_infill_direction if sparse_infill_rotate_template/solid_infill_rotate_template is not empty value and adaptive cubic/support cubic infill pattern is not selected
toggle_field("sparse_infill_rotate_template", !FillAdaptive, -1, _L("Infill rotation templates are unavailable for Adaptive Cubic and Support Cubic infill."));
toggle_field("infill_direction", config->opt_string("sparse_infill_rotate_template") == "" && !FillAdaptive, -1, _L("Clear the sparse infill rotation template and choose a pattern other than Adaptive Cubic or Support Cubic to edit infill direction."));
toggle_field("solid_infill_direction", config->opt_string("solid_infill_rotate_template") == "", -1, _L("Clear the solid infill rotation template to edit solid infill direction."));
toggle_line("infill_overhang_angle", config->opt_enum<InfillPattern>("sparse_infill_pattern") == InfillPattern::ipLateralHoneycomb, -1, _L("Select the Lateral Honeycomb sparse infill pattern to use this setting."));
std::string printer_type = wxGetApp().preset_bundle->printers.get_edited_preset().get_printer_type(wxGetApp().preset_bundle);
toggle_line("enable_wrapping_detection", DevPrinterConfigUtil::support_wrapping_detection(printer_type), -1, _L("The selected printer does not support wrapping detection."));
}
void ConfigManipulation::update_print_sla_config(DynamicPrintConfig* config, const bool is_global_config/* = false*/)
{
double head_penetration = config->opt_float("support_head_penetration");
double head_width = config->opt_float("support_head_width");
if (head_penetration > head_width) {
//wxString msg_text = _(L("Head penetration should not be greater than the head width."));
wxString msg_text = "Head penetration should not be greater than the head width.";
//MessageDialog dialog(m_msg_dlg_parent, msg_text, _(L("Invalid Head penetration")), wxICON_WARNING | wxOK);
MessageDialog dialog(m_msg_dlg_parent, msg_text, "Invalid Head penetration", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
if (dialog.ShowModal() == wxID_OK) {
new_conf.set_key_value("support_head_penetration", new ConfigOptionFloat(head_width));
apply(config, &new_conf);
}
}
double pinhead_d = config->opt_float("support_head_front_diameter");
double pillar_d = config->opt_float("support_pillar_diameter");
if (pinhead_d > pillar_d) {
//wxString msg_text = _(L("Pinhead diameter should be smaller than the pillar diameter."));
wxString msg_text = "Pinhead diameter should be smaller than the pillar diameter.";
//MessageDialog dialog(m_msg_dlg_parent, msg_text, _(L("Invalid pinhead diameter")), wxICON_WARNING | wxOK);
MessageDialog dialog(m_msg_dlg_parent, msg_text, "Invalid pinhead diameter", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
if (dialog.ShowModal() == wxID_OK) {
new_conf.set_key_value("support_head_front_diameter", new ConfigOptionFloat(pillar_d / 2.0));
apply(config, &new_conf);
}
}
}
void ConfigManipulation::toggle_print_sla_options(DynamicPrintConfig* config)
{
bool supports_en = config->opt_bool("supports_enable");
const wxString support_reason = _L("Enable support to edit this setting.");
toggle_field("support_head_front_diameter", supports_en, -1, support_reason);
toggle_field("support_head_penetration", supports_en, -1, support_reason);
toggle_field("support_head_width", supports_en, -1, support_reason);
toggle_field("support_pillar_diameter", supports_en, -1, support_reason);
toggle_field("support_small_pillar_diameter_percent", supports_en, -1, support_reason);
toggle_field("support_max_bridges_on_pillar", supports_en, -1, support_reason);
toggle_field("support_pillar_connection_mode", supports_en, -1, support_reason);
toggle_field("support_buildplate_only", supports_en, -1, support_reason);
toggle_field("support_base_diameter", supports_en, -1, support_reason);
toggle_field("support_base_height", supports_en, -1, support_reason);
toggle_field("support_base_safety_distance", supports_en, -1, support_reason);
toggle_field("support_critical_angle", supports_en, -1, support_reason);
toggle_field("support_max_bridge_length", supports_en, -1, support_reason);
toggle_field("support_max_pillar_link_distance", supports_en, -1, support_reason);
toggle_field("support_points_density_relative", supports_en, -1, support_reason);
toggle_field("support_points_minimal_distance", supports_en, -1, support_reason);
bool pad_en = config->opt_bool("pad_enable");
const wxString pad_reason = _L("Enable the pad to edit this setting.");
toggle_field("pad_wall_thickness", pad_en, -1, pad_reason);
toggle_field("pad_wall_height", pad_en, -1, pad_reason);
toggle_field("pad_brim_size", pad_en, -1, pad_reason);
toggle_field("pad_max_merge_distance", pad_en, -1, pad_reason);
// toggle_field("pad_edge_radius", supports_en);
toggle_field("pad_wall_slope", pad_en, -1, pad_reason);
toggle_field("pad_around_object", pad_en, -1, pad_reason);
toggle_field("pad_around_object_everywhere", pad_en, -1, pad_reason);
bool zero_elev = config->opt_bool("pad_around_object") && pad_en;
const wxString pad_around_object_reason = _L("Enable the pad around the object to edit this setting.");
toggle_field("support_object_elevation", supports_en && !zero_elev, -1, _L("Enable support and disable the pad around the object to edit object elevation."));
toggle_field("pad_object_gap", zero_elev, -1, pad_around_object_reason);
toggle_field("pad_around_object_everywhere", zero_elev, -1, pad_around_object_reason);
toggle_field("pad_object_connector_stride", zero_elev, -1, pad_around_object_reason);
toggle_field("pad_object_connector_width", zero_elev, -1, pad_around_object_reason);
toggle_field("pad_object_connector_penetration", zero_elev, -1, pad_around_object_reason);
}
int ConfigManipulation::show_spiral_mode_settings_dialog(bool is_object_config)
{
wxString msg_text = _(L("Spiral mode only works when wall loops is 1, support is disabled, clumping detection by probing is disabled, top shell layers is 0, sparse infill density is 0 and timelapse type is traditional."));
auto printer_structure_opt = wxGetApp().preset_bundle->printers.get_edited_preset().config.option<ConfigOptionEnum<PrinterStructure>>("printer_structure");
if (printer_structure_opt && printer_structure_opt->value == PrinterStructure::psI3) {
msg_text += _(L(" But machines with I3 structure will not generate timelapse videos."));
}
if (!is_object_config)
msg_text += "\n\n" + _(L("Change these settings automatically\?\nYes - Change these settings and enable spiral/vase mode automatically\nNo - Cancel enabling spiral mode"));
MessageDialog dialog(wxGetApp().plater(), msg_text, "",
wxICON_WARNING | (!is_object_config ? wxYES | wxNO : wxOK));
is_msg_dlg_already_exist = true;
auto answer = dialog.ShowModal();
is_msg_dlg_already_exist = false;
if (is_object_config)
answer = wxID_YES;
return answer;
}
bool ConfigManipulation::get_temperature_range(DynamicPrintConfig *config, int &range_low, int &range_high, unsigned int variant_index)
{
bool range_low_exist = false, range_high_exist = false;
if (config->has("nozzle_temperature_range_low")) {
range_low = config->opt_int("nozzle_temperature_range_low", variant_index);
range_low_exist = true;
}
if (config->has("nozzle_temperature_range_high")) {
range_high = config->opt_int("nozzle_temperature_range_high", variant_index);
range_high_exist = true;
}
return range_low_exist && range_high_exist;
}
} // GUI
} // Slic3r