Files
OrcaSlicer/src/slic3r/GUI/ConfigManipulation.hpp
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

130 lines
5.7 KiB
C++

#ifndef slic3r_ConfigManipulation_hpp_
#define slic3r_ConfigManipulation_hpp_
/* Class for validation config options
* and update (enable/disable) IU components
*
* Used for config validation for global config (Print Settings Tab)
* and local config (overrides options on sidebar)
* */
#include <functional>
#include <string>
#include <wx/string.h>
#include <boost/any.hpp>
#include "libslic3r/Config.hpp"
#include <vector>
#include <map>
class wxWindow;
namespace Slic3r { class DynamicPrintConfig; }
namespace boost { class any; }
namespace Slic3r {
class ModelConfig;
class ObjectBase;
namespace GUI {
class ConfigManipulation
{
public:
using ToggleCallback = std::function<void(const std::string&, bool, int, const wxString&)>;
private:
bool is_msg_dlg_already_exist{ false };
bool m_is_initialized_support_material_overhangs_queried{ false };
bool m_support_material_overhangs_queried{ false };
bool is_BBL_Printer{false};
// function to loading of changed configuration
std::function<void()> load_config = nullptr;
ToggleCallback cb_toggle_field = nullptr;
ToggleCallback cb_toggle_line = nullptr;
std::function<void(const std::string &, const wxString &, int opt_index)> cb_set_option_label = nullptr;
// callback to propagation of changed value, if needed
std::function<void(const std::string&, const boost::any&)> cb_value_change = nullptr;
//BBS: change local config to const DynamicPrintConfig
const DynamicPrintConfig* local_config = nullptr;
//ModelConfig* local_config = nullptr;
wxWindow* m_msg_dlg_parent {nullptr};
t_config_option_keys m_applying_keys;
public:
ConfigManipulation(std::function<void()> load_config,
ToggleCallback cb_toggle_field,
ToggleCallback cb_toggle_line,
std::function<void(const std::string&, const boost::any&)> cb_value_change,
//BBS: change local config to DynamicPrintConfig
const DynamicPrintConfig* local_config = nullptr,
wxWindow* msg_dlg_parent = nullptr,
std::function<void(const std::string &, const wxString &, int opt_index)> cb_set_option_label = nullptr) :
load_config(load_config),
cb_toggle_field(cb_toggle_field),
cb_toggle_line(cb_toggle_line),
cb_set_option_label(cb_set_option_label),
cb_value_change(cb_value_change),
m_msg_dlg_parent(msg_dlg_parent),
local_config(local_config) {}
ConfigManipulation() {}
~ConfigManipulation() {
load_config = nullptr;
cb_toggle_field = nullptr;
cb_toggle_line = nullptr;
cb_set_option_label = nullptr;
cb_value_change = nullptr;
}
bool is_applying() const;
void apply(DynamicPrintConfig* config, DynamicPrintConfig* new_config);
t_config_option_keys const &applying_keys() const;
void toggle_field(const std::string& field_key, const bool toggle, int opt_index = -1, const wxString& reason = {});
void toggle_line(const std::string& field_key, const bool toggle, int opt_index = -1, const wxString& reason = {});
// Renames an option's row. `label` is the untranslated English msgid (an L("...") string); the
// row translates it for display.
void set_option_label(const std::string& field_key, const wxString& label, int opt_index = -1);
// FFF print
void update_print_fff_config(DynamicPrintConfig* config, const bool is_global_config = false, const bool is_plate_config = false);
void toggle_print_fff_options(DynamicPrintConfig* config, int variant_index, const bool is_global_config = false);
void apply_null_fff_config(DynamicPrintConfig *config, std::vector<std::string> const &keys, std::map<ObjectBase*, ModelConfig*> const & configs);
//BBS: FFF filament nozzle temperature range
void check_nozzle_recommended_temperature_range(DynamicPrintConfig *config, unsigned int variant_index);
void check_nozzle_temperature_range(DynamicPrintConfig* config, unsigned int variant_index);
void check_nozzle_temperature_initial_layer_range(DynamicPrintConfig* config, unsigned int variant_index);
void check_adaptive_pressure_advance_model(DynamicPrintConfig* config, unsigned int variant_index);
void check_filament_max_volumetric_speed(DynamicPrintConfig *config);
void check_filament_ironing_spacing(DynamicPrintConfig *config);
void check_chamber_temperature(DynamicPrintConfig* config);
void check_chamber_minimal_temperature(DynamicPrintConfig* config);
bool check_layer_height(DynamicPrintConfig* config);
bool layer_height_out_of_range_dialog(DynamicPrintConfig* config, double clamp_to);
void layer_height_limits(double& min_layer_height, double& max_layer_height) const;
void set_is_BBL_Printer(bool is_bbl_printer) { is_BBL_Printer = is_bbl_printer; };
bool get_is_BBL_Printer() { return is_BBL_Printer; };
// SLA print
void update_print_sla_config(DynamicPrintConfig* config, const bool is_global_config = false);
void toggle_print_sla_options(DynamicPrintConfig* config);
bool is_initialized_support_material_overhangs_queried() { return m_is_initialized_support_material_overhangs_queried; }
void initialize_support_material_overhangs_queried(bool queried)
{
m_is_initialized_support_material_overhangs_queried = true;
m_support_material_overhangs_queried = queried;
}
int show_spiral_mode_settings_dialog(bool is_object_config = false);
private:
bool get_temperature_range(DynamicPrintConfig *config, int &range_low, int &range_high, unsigned int variant_index);
};
} // GUI
} // Slic3r
#endif /* slic3r_ConfigManipulation_hpp_ */