mirror of
https://github.com/QIDITECH/QIDISlicer.git
synced 2026-01-31 07:58:43 +03:00
Prusa 2.7.2
This commit is contained in:
@@ -74,8 +74,8 @@ static inline void model_volume_list_copy_configs(ModelObject &model_object_dst,
|
||||
mv_dst.supported_facets.assign(mv_src.supported_facets);
|
||||
assert(mv_dst.seam_facets.id() == mv_src.seam_facets.id());
|
||||
mv_dst.seam_facets.assign(mv_src.seam_facets);
|
||||
assert(mv_dst.mmu_segmentation_facets.id() == mv_src.mmu_segmentation_facets.id());
|
||||
mv_dst.mmu_segmentation_facets.assign(mv_src.mmu_segmentation_facets);
|
||||
assert(mv_dst.mm_segmentation_facets.id() == mv_src.mm_segmentation_facets.id());
|
||||
mv_dst.mm_segmentation_facets.assign(mv_src.mm_segmentation_facets);
|
||||
//FIXME what to do with the materials?
|
||||
// mv_dst.m_material_id = mv_src.m_material_id;
|
||||
++ i_src;
|
||||
@@ -165,34 +165,37 @@ static bool layer_height_ranges_equal(const t_layer_config_ranges &lr1, const t_
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns true if va == vb when all CustomGCode items that are not ToolChangeCode are ignored.
|
||||
static bool custom_per_printz_gcodes_tool_changes_differ(const std::vector<CustomGCode::Item> &va, const std::vector<CustomGCode::Item> &vb)
|
||||
{
|
||||
// Returns true if va == vb when all CustomGCode items that are not the specified type (not_ignore_type) are ignored.
|
||||
static bool custom_per_printz_gcodes_tool_changes_differ(
|
||||
const std::vector<CustomGCode::Item> &va,
|
||||
const std::vector<CustomGCode::Item> &vb,
|
||||
CustomGCode::Type not_ignore_type
|
||||
) {
|
||||
auto it_a = va.begin();
|
||||
auto it_b = vb.begin();
|
||||
while (it_a != va.end() || it_b != vb.end()) {
|
||||
if (it_a != va.end() && it_a->type != CustomGCode::ToolChange) {
|
||||
// Skip any CustomGCode items, which are not tool changes.
|
||||
if (it_a != va.end() && it_a->type != not_ignore_type) {
|
||||
// Skip any CustomGCode items, which are not equal to not_ignore_type.
|
||||
++ it_a;
|
||||
continue;
|
||||
}
|
||||
if (it_b != vb.end() && it_b->type != CustomGCode::ToolChange) {
|
||||
// Skip any CustomGCode items, which are not tool changes.
|
||||
if (it_b != vb.end() && it_b->type != not_ignore_type) {
|
||||
// Skip any CustomGCode items, which are not equal to not_ignore_type.
|
||||
++ it_b;
|
||||
continue;
|
||||
}
|
||||
if (it_a == va.end() || it_b == vb.end())
|
||||
// va or vb contains more Tool Changes than the other.
|
||||
// va or vb contains more items of not_ignore_type than the other.
|
||||
return true;
|
||||
assert(it_a->type == CustomGCode::ToolChange);
|
||||
assert(it_b->type == CustomGCode::ToolChange);
|
||||
assert(it_a->type == not_ignore_type);
|
||||
assert(it_b->type == not_ignore_type);
|
||||
if (*it_a != *it_b)
|
||||
// The two Tool Changes differ.
|
||||
// The two items of not_ignore_type differ.
|
||||
return true;
|
||||
++ it_a;
|
||||
++ it_b;
|
||||
}
|
||||
// There is no change in custom Tool Changes.
|
||||
// There is no change in specified not_ignore_type items.
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1057,11 +1060,20 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
||||
model_object_status_db.add(*model_object, ModelObjectStatus::New);
|
||||
} else {
|
||||
if (m_model.custom_gcode_per_print_z != model.custom_gcode_per_print_z) {
|
||||
update_apply_status(num_extruders_changed ||
|
||||
const CustomGCode::Mode current_mode = m_model.custom_gcode_per_print_z.mode;
|
||||
const CustomGCode::Mode next_mode = model.custom_gcode_per_print_z.mode;
|
||||
|
||||
const bool multi_extruder_differ = (current_mode == next_mode) && (current_mode == CustomGCode::MultiExtruder || next_mode == CustomGCode::MultiExtruder);
|
||||
// Tool change G-codes are applied as color changes for a single extruder printer, no need to invalidate tool ordering.
|
||||
//FIXME The tool ordering may be invalidated unnecessarily if the custom_gcode_per_print_z.mode is not applicable
|
||||
// to the active print / model state, and then it is reset, so it is being applicable, but empty, thus the effect is the same.
|
||||
(num_extruders > 1 && custom_per_printz_gcodes_tool_changes_differ(m_model.custom_gcode_per_print_z.gcodes, model.custom_gcode_per_print_z.gcodes)) ?
|
||||
const bool tool_change_differ = num_extruders > 1 && custom_per_printz_gcodes_tool_changes_differ(m_model.custom_gcode_per_print_z.gcodes, model.custom_gcode_per_print_z.gcodes, CustomGCode::ToolChange);
|
||||
// For multi-extruder printers, we perform a tool change before a color change.
|
||||
// So, in that case, we must invalidate tool ordering and wipe tower even if custom color change g-codes differ.
|
||||
const bool color_change_differ = num_extruders > 1 && (next_mode == CustomGCode::MultiExtruder) && custom_per_printz_gcodes_tool_changes_differ(m_model.custom_gcode_per_print_z.gcodes, model.custom_gcode_per_print_z.gcodes, CustomGCode::ColorChange);
|
||||
|
||||
update_apply_status(
|
||||
(num_extruders_changed || tool_change_differ || multi_extruder_differ || color_change_differ) ?
|
||||
// The Tool Ordering and the Wipe Tower are no more valid.
|
||||
this->invalidate_steps({ psWipeTower, psGCodeExport }) :
|
||||
// There is no change in Tool Changes stored in custom_gcode_per_print_z, therefore there is no need to update Tool Ordering.
|
||||
@@ -1225,7 +1237,10 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
||||
model_volume_list_copy_configs(model_object /* dst */, model_object_new /* src */, ModelVolumeType::PARAMETER_MODIFIER);
|
||||
layer_height_ranges_copy_configs(model_object.layer_config_ranges /* dst */, model_object_new.layer_config_ranges /* src */);
|
||||
// Copy the ModelObject name, input_file and instances. The instances will be compared against PrintObject instances in the next step.
|
||||
if (model_object.name != model_object_new.name) {
|
||||
update_apply_status(this->invalidate_step(psGCodeExport));
|
||||
model_object.name = model_object_new.name;
|
||||
}
|
||||
model_object.input_file = model_object_new.input_file;
|
||||
// Only refresh ModelInstances if there is any change.
|
||||
if (model_object.instances.size() != model_object_new.instances.size() ||
|
||||
@@ -1357,7 +1372,7 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
||||
std::vector<unsigned int> painting_extruders;
|
||||
if (const auto &volumes = print_object.model_object()->volumes;
|
||||
num_extruders > 1 &&
|
||||
std::find_if(volumes.begin(), volumes.end(), [](const ModelVolume *v) { return ! v->mmu_segmentation_facets.empty(); }) != volumes.end()) {
|
||||
std::find_if(volumes.begin(), volumes.end(), [](const ModelVolume *v) { return ! v->mm_segmentation_facets.empty(); }) != volumes.end()) {
|
||||
//FIXME be more specific! Don't enumerate extruders that are not used for painting!
|
||||
painting_extruders.assign(num_extruders, 0);
|
||||
std::iota(painting_extruders.begin(), painting_extruders.end(), 1);
|
||||
|
||||
Reference in New Issue
Block a user