ENH: add check logic of filament_map when Print::Apply
Change-Id: Ibab353c4b16183611d63d75bcdf5f370cb578f21
This commit is contained in:
parent
e9081ba8d4
commit
bbc4d701bf
|
@ -2279,6 +2279,7 @@ DynamicPrintConfig PresetBundle::full_fff_config(bool apply_extruder, std::vecto
|
|||
//BBS: add logic for settings check between different system presets
|
||||
add_if_some_non_empty(std::move(different_settings), "different_settings_to_system");
|
||||
add_if_some_non_empty(std::move(print_compatible_printers), "print_compatible_printers");
|
||||
out.option<ConfigOptionInts>("extruder_filament_count", true)->values = this->extruder_filament_counts;
|
||||
|
||||
out.option<ConfigOptionEnumGeneric>("printer_technology", true)->value = ptFFF;
|
||||
return out;
|
||||
|
@ -2496,6 +2497,11 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
|
|||
}
|
||||
}
|
||||
}
|
||||
//no need to parse extruder_filament_count
|
||||
std::vector<int> extruder_filament_count = std::move(config.option<ConfigOptionInts>("extruder_filament_count", true)->values);
|
||||
config.erase("extruder_filament_count");
|
||||
if (this->extruder_filament_counts.empty())
|
||||
this->extruder_filament_counts = extruder_filament_count;
|
||||
|
||||
// 1) Create a name from the file name.
|
||||
// Keep the suffix (.ini, .gcode, .amf, .3mf etc) to differentiate it from the normal profiles.
|
||||
|
|
|
@ -127,7 +127,7 @@ public:
|
|||
std::vector<std::vector<std::string>> ams_multi_color_filment;
|
||||
|
||||
// todo multi_extruders: delete mutable
|
||||
mutable std::vector<int> filament_maps;
|
||||
mutable std::vector<int> extruder_filament_counts;
|
||||
// Calibrate
|
||||
Preset const * calibrate_printer = nullptr;
|
||||
std::set<Preset const *> calibrate_filaments;
|
||||
|
|
|
@ -244,6 +244,9 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|
|||
|| opt_key == "first_layer_print_sequence"
|
||||
|| opt_key == "other_layers_print_sequence"
|
||||
|| opt_key == "other_layers_print_sequence_nums"
|
||||
|| opt_key == "extruder_filament_count"
|
||||
|| opt_key == "filament_map_mode"
|
||||
|| opt_key == "filament_map"
|
||||
//|| opt_key == "wipe_tower_bridging"
|
||||
|| opt_key == "wipe_tower_no_sparse_layers"
|
||||
|| opt_key == "flush_volumes_matrix"
|
||||
|
@ -2306,6 +2309,19 @@ void Print::finalize_first_layer_convex_hull()
|
|||
m_first_layer_convex_hull = Geometry::convex_hull(m_first_layer_convex_hull.points);
|
||||
}
|
||||
|
||||
void Print::update_filament_maps_to_config(std::vector<int> f_maps)
|
||||
{
|
||||
std::vector<int>& filament_maps = m_full_print_config.option<ConfigOptionInts>("filament_map", true)->values;
|
||||
|
||||
filament_maps = f_maps;
|
||||
m_config.filament_map.values = f_maps;
|
||||
}
|
||||
|
||||
std::vector<int> Print::get_filament_maps() const
|
||||
{
|
||||
return m_config.filament_map.values;
|
||||
}
|
||||
|
||||
// Wipe tower support.
|
||||
bool Print::has_wipe_tower() const
|
||||
{
|
||||
|
@ -2476,35 +2492,35 @@ void Print::_make_wipe_tower()
|
|||
}
|
||||
else {
|
||||
std::vector<float> flush_matrix(cast<float>(get_flush_volumes_matrix(m_config.flush_volumes_matrix.values, 0, nozzle_nums)));
|
||||
|
||||
|
||||
// Extract purging volumes for each extruder pair:
|
||||
std::vector<std::vector<float>> wipe_volumes;
|
||||
for (unsigned int i = 0; i < number_of_extruders; ++i)
|
||||
wipe_volumes.push_back(std::vector<float>(flush_matrix.begin() + i * number_of_extruders, flush_matrix.begin() + (i + 1) * number_of_extruders));
|
||||
|
||||
|
||||
|
||||
|
||||
// BBS: priming logic is removed, so get the initial extruder by first_extruder()
|
||||
unsigned int current_extruder_id = m_wipe_tower_data.tool_ordering.first_extruder();
|
||||
for (auto &layer_tools : m_wipe_tower_data.tool_ordering.layer_tools()) { // for all layers
|
||||
if (!layer_tools.has_wipe_tower) continue;
|
||||
bool first_layer = &layer_tools == &m_wipe_tower_data.tool_ordering.front();
|
||||
wipe_tower.plan_toolchange((float)layer_tools.print_z, (float)layer_tools.wipe_tower_layer_height, current_extruder_id, current_extruder_id);
|
||||
|
||||
|
||||
for (const auto extruder_id : layer_tools.extruders) {
|
||||
// BBS: priming logic is removed, so no need to do toolchange for first extruder
|
||||
if (/*(first_layer && extruder_id == m_wipe_tower_data.tool_ordering.all_extruders().back()) || */extruder_id != current_extruder_id) {
|
||||
float volume_to_purge = wipe_volumes[current_extruder_id][extruder_id];
|
||||
volume_to_purge *= m_config.flush_multiplier.get_at(0);
|
||||
|
||||
|
||||
// Not all of that can be used for infill purging:
|
||||
//volume_to_purge -= (float)m_config.filament_minimal_purge_on_wipe_tower.get_at(extruder_id);
|
||||
|
||||
|
||||
// try to assign some infills/objects for the wiping:
|
||||
volume_to_purge = layer_tools.wiping_extrusions().mark_wiping_extrusions(*this, current_extruder_id, extruder_id, volume_to_purge);
|
||||
|
||||
|
||||
// add back the minimal amount toforce on the wipe tower:
|
||||
//volume_to_purge += (float)m_config.filament_minimal_purge_on_wipe_tower.get_at(extruder_id);
|
||||
|
||||
|
||||
// request a toolchange at the wipe tower with at least volume_to_wipe purging amount
|
||||
wipe_tower.plan_toolchange((float)layer_tools.print_z, (float)layer_tools.wipe_tower_layer_height,
|
||||
current_extruder_id, extruder_id, m_config.prime_volume, volume_to_purge);
|
||||
|
@ -2512,14 +2528,14 @@ void Print::_make_wipe_tower()
|
|||
}
|
||||
}
|
||||
layer_tools.wiping_extrusions().ensure_perimeters_infills_order(*this);
|
||||
|
||||
|
||||
// if enable timelapse, slice all layer
|
||||
if (enable_timelapse_print()) {
|
||||
if (layer_tools.wipe_tower_partitions == 0)
|
||||
wipe_tower.set_last_layer_extruder_fill(false);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (&layer_tools == &m_wipe_tower_data.tool_ordering.back() || (&layer_tools + 1)->wipe_tower_partitions == 0)
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -805,6 +805,9 @@ public:
|
|||
const WipeTowerData& wipe_tower_data(size_t filaments_cnt = 0) const;
|
||||
const ToolOrdering& tool_ordering() const { return m_tool_ordering; }
|
||||
|
||||
void update_filament_maps_to_config(std::vector<int> f_maps);
|
||||
std::vector<int> get_filament_maps() const;
|
||||
|
||||
bool enable_timelapse_print() const;
|
||||
|
||||
std::string output_filename(const std::string &filename_base = std::string()) const override;
|
||||
|
|
|
@ -1028,12 +1028,14 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
|||
new_full_config.option("print_settings_id", true);
|
||||
new_full_config.option("filament_settings_id", true);
|
||||
new_full_config.option("printer_settings_id", true);
|
||||
|
||||
// BBS
|
||||
int used_filaments = this->extruders(true).size();
|
||||
std::vector <unsigned int> used_filaments = this->extruders(true);
|
||||
std::unordered_set <unsigned int> used_filament_set(used_filaments.begin(), used_filaments.end());
|
||||
|
||||
//new_full_config.normalize_fdm(used_filaments);
|
||||
new_full_config.normalize_fdm_1();
|
||||
t_config_option_keys changed_keys = new_full_config.normalize_fdm_2(objects().size(), used_filaments);
|
||||
t_config_option_keys changed_keys = new_full_config.normalize_fdm_2(objects().size(), used_filaments.size());
|
||||
if (changed_keys.size() > 0) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got changed_keys, size=%1%")%changed_keys.size();
|
||||
for (int i = 0; i < changed_keys.size(); i++)
|
||||
|
@ -1114,6 +1116,40 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
|||
t_config_option_keys object_diff = m_default_object_config.diff(new_full_config);
|
||||
t_config_option_keys region_diff = m_default_region_config.diff(new_full_config);
|
||||
|
||||
//BBS: process the filament_map related logic
|
||||
std::unordered_set<std::string> print_diff_set(print_diff.begin(), print_diff.end());
|
||||
if (print_diff_set.find("filament_map_mode") == print_diff_set.end())
|
||||
{
|
||||
FilamentMapMode map_mode = new_full_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode", true)->value;
|
||||
if (map_mode == fmmAuto) {
|
||||
print_diff_set.erase("filament_map");
|
||||
}
|
||||
else {
|
||||
print_diff_set.erase("extruder_filament_count");
|
||||
std::vector<int> old_filament_map = m_config.filament_map.values;
|
||||
std::vector<int> new_filament_map = new_full_config.option<ConfigOptionInts>("filament_map", true)->values;
|
||||
|
||||
if (old_filament_map.size() == new_filament_map.size())
|
||||
{
|
||||
bool same_map = true;
|
||||
for (size_t index = 0; index < old_filament_map.size(); index++)
|
||||
{
|
||||
if ((old_filament_map[index] == new_filament_map[index])
|
||||
|| (used_filament_set.find(index + 1) == used_filament_set.end()))
|
||||
continue;
|
||||
else {
|
||||
same_map = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (same_map)
|
||||
print_diff_set.erase("filament_map");
|
||||
}
|
||||
}
|
||||
if (print_diff_set.size() != print_diff.size())
|
||||
print_diff.assign(print_diff_set.begin(), print_diff_set.end());
|
||||
}
|
||||
|
||||
// Do not use the ApplyStatus as we will use the max function when updating apply_status.
|
||||
unsigned int apply_status = APPLY_STATUS_UNCHANGED;
|
||||
auto update_apply_status = [&apply_status](bool invalidated)
|
||||
|
|
|
@ -3019,6 +3019,12 @@ void PrintConfigDef::init_fff_params()
|
|||
def->set_default_value(new ConfigOptionStrings { "Direct Drive Normal" });
|
||||
def->cli = ConfigOptionDef::nocli;
|
||||
|
||||
def = this->add("extruder_filament_count", coInts);
|
||||
def->label = "Extruder filament count";
|
||||
def->tooltip = "Filament counts per extruder";
|
||||
def->set_default_value(new ConfigOptionInts { 1 });
|
||||
def->cli = ConfigOptionDef::nocli;
|
||||
|
||||
def = this->add("printer_extruder_id", coInts);
|
||||
def->label = "Printer extruder id";
|
||||
def->tooltip = "Printer extruder id";
|
||||
|
|
|
@ -969,6 +969,7 @@ PRINT_CONFIG_CLASS_DEFINE(
|
|||
((ConfigOptionInts, temperature_vitrification)) //BBS
|
||||
((ConfigOptionFloats, filament_max_volumetric_speed))
|
||||
((ConfigOptionInts, required_nozzle_HRC))
|
||||
((ConfigOptionEnum<FilamentMapMode>, filament_map_mode))
|
||||
((ConfigOptionInts, filament_map))
|
||||
//((ConfigOptionInts, filament_extruder_id))
|
||||
((ConfigOptionStrings, filament_extruder_variant))
|
||||
|
@ -1024,6 +1025,7 @@ PRINT_CONFIG_CLASS_DEFINE(
|
|||
((ConfigOptionPercent, accel_to_decel_factor))
|
||||
((ConfigOptionEnumsGeneric, extruder_type))
|
||||
((ConfigOptionEnumsGeneric, nozzle_volume_type))
|
||||
((ConfigOptionInts, extruder_filament_count))
|
||||
((ConfigOptionInts, printer_extruder_id))
|
||||
((ConfigOptionStrings, printer_extruder_variant))
|
||||
//Orca
|
||||
|
|
Loading…
Reference in New Issue