mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 10:17:55 -06:00
FIX: fix the print config status not correct issue
the print object updating is behind the .normalize_fdm which will cause some issue in corner cases Change-Id: I57e9e7aa2acff81b89aedd95ffc7a7effb76cc6b
This commit is contained in:
parent
5fa771c6cb
commit
dbcdc876ac
3 changed files with 166 additions and 19 deletions
|
@ -97,7 +97,7 @@ static inline void layer_height_ranges_copy_configs(t_layer_config_ranges &lr_ds
|
|||
}
|
||||
}
|
||||
|
||||
static inline bool transform3d_lower(const Transform3d &lhs, const Transform3d &rhs)
|
||||
static inline bool transform3d_lower(const Transform3d &lhs, const Transform3d &rhs)
|
||||
{
|
||||
typedef Transform3d::Scalar T;
|
||||
const T *lv = lhs.data();
|
||||
|
@ -111,7 +111,7 @@ static inline bool transform3d_lower(const Transform3d &lhs, const Transform3d &
|
|||
return false;
|
||||
}
|
||||
|
||||
static inline bool transform3d_equal(const Transform3d &lhs, const Transform3d &rhs)
|
||||
static inline bool transform3d_equal(const Transform3d &lhs, const Transform3d &rhs)
|
||||
{
|
||||
typedef Transform3d::Scalar T;
|
||||
const T *lv = lhs.data();
|
||||
|
@ -434,7 +434,7 @@ struct PrintObjectStatus {
|
|||
New
|
||||
};
|
||||
|
||||
PrintObjectStatus(PrintObject *print_object, Status status = Unknown) :
|
||||
PrintObjectStatus(PrintObject *print_object, Status status = Unknown) :
|
||||
id(print_object->model_object()->id()),
|
||||
print_object(print_object),
|
||||
trafo(print_object->trafo()),
|
||||
|
@ -445,7 +445,7 @@ struct PrintObjectStatus {
|
|||
ObjectID id;
|
||||
// Pointer to the old PrintObject
|
||||
PrintObject *print_object;
|
||||
// Trafo generated with model_object->world_matrix(true)
|
||||
// Trafo generated with model_object->world_matrix(true)
|
||||
Transform3d trafo;
|
||||
Status status;
|
||||
|
||||
|
@ -464,7 +464,7 @@ public:
|
|||
}
|
||||
|
||||
struct iterator_range : std::pair<const_iterator, const_iterator>
|
||||
{
|
||||
{
|
||||
using std::pair<const_iterator, const_iterator>::pair;
|
||||
iterator_range(const std::pair<const_iterator, const_iterator> in) : std::pair<const_iterator, const_iterator>(in) {}
|
||||
|
||||
|
@ -549,7 +549,7 @@ static PrintObjectRegions::BoundingBox transformed_its_bbox2d(const indexed_tria
|
|||
}
|
||||
|
||||
static void transformed_its_bboxes_in_z_ranges(
|
||||
const indexed_triangle_set &its,
|
||||
const indexed_triangle_set &its,
|
||||
const Transform3f &m,
|
||||
const std::vector<t_layer_height_range> &z_ranges,
|
||||
std::vector<std::pair<PrintObjectRegions::BoundingBox, bool>> &bboxes,
|
||||
|
@ -732,7 +732,7 @@ bool verify_update_print_object_regions(
|
|||
assert(next_region_id == int(layer_range.volume_regions.size()) ||
|
||||
layer_range.volume_regions[next_region_id].model_volume != region.model_volume ||
|
||||
layer_range.volume_regions[next_region_id].parent <= parent_region_id);
|
||||
if (next_region_id < int(layer_range.volume_regions.size()) &&
|
||||
if (next_region_id < int(layer_range.volume_regions.size()) &&
|
||||
layer_range.volume_regions[next_region_id].model_volume == region.model_volume &&
|
||||
layer_range.volume_regions[next_region_id].parent == parent_region_id) {
|
||||
// A parent region is already overridden.
|
||||
|
@ -767,7 +767,7 @@ bool verify_update_print_object_regions(
|
|||
}
|
||||
}
|
||||
|
||||
// Verify and / or update PrintRegions produced by color painting.
|
||||
// Verify and / or update PrintRegions produced by color painting.
|
||||
for (const PrintObjectRegions::LayerRangeRegions &layer_range : print_object_regions.layer_ranges)
|
||||
for (const PrintObjectRegions::PaintedRegion ®ion : layer_range.painted_regions) {
|
||||
const PrintObjectRegions::VolumeRegion &parent_region = layer_range.volume_regions[region.parent];
|
||||
|
@ -819,7 +819,7 @@ void update_volume_bboxes(
|
|||
std::vector<PrintObjectRegions::LayerRangeRegions> &layer_ranges,
|
||||
std::vector<ObjectID> &cached_volume_ids,
|
||||
ModelVolumePtrs model_volumes,
|
||||
const Transform3d &object_trafo,
|
||||
const Transform3d &object_trafo,
|
||||
const float offset)
|
||||
{
|
||||
// output will be sorted by the order of model_volumes sorted by their ObjectIDs.
|
||||
|
@ -968,7 +968,7 @@ static PrintObjectRegions* generate_print_object_regions(
|
|||
if (parent_volume.is_model_part() || parent_volume.is_modifier())
|
||||
if (PrintObjectRegions::BoundingBox parent_bbox = find_modifier_volume_extents(layer_range, parent_region_id); parent_bbox.intersects(*bbox)) {
|
||||
// Only create new region for a modifier, which actually modifies config of it's parent.
|
||||
if (PrintRegionConfig config = region_config_from_model_volume(parent_region.region->config(), nullptr, volume, num_extruders);
|
||||
if (PrintRegionConfig config = region_config_from_model_volume(parent_region.region->config(), nullptr, volume, num_extruders);
|
||||
config != parent_region.region->config()) {
|
||||
added = true;
|
||||
layer_range.volume_regions.push_back({ &volume, parent_region_id, get_create_region(std::move(config)), bbox });
|
||||
|
@ -1021,7 +1021,16 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
|||
new_full_config.option("printer_settings_id", true);
|
||||
// BBS
|
||||
int used_filaments = this->extruders().size();
|
||||
new_full_config.normalize_fdm(used_filaments);
|
||||
//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(used_filaments);
|
||||
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++)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", i=%1%, key=%2%")%i %changed_keys[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Find modified keys of the various configs. Resolve overrides extruder retract values by filament profiles.
|
||||
DynamicPrintConfig filament_overrides;
|
||||
|
@ -1075,13 +1084,14 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
|||
m_default_object_config.apply_only(new_full_config, object_diff, true);
|
||||
// Handle changes to regions config defaults
|
||||
m_default_region_config.apply_only(new_full_config, region_diff, true);
|
||||
m_full_print_config = std::move(new_full_config);
|
||||
//m_full_print_config = std::move(new_full_config);
|
||||
m_full_print_config = new_full_config;
|
||||
if (num_extruders != m_config.filament_diameter.size()) {
|
||||
num_extruders = m_config.filament_diameter.size();
|
||||
num_extruders_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ModelObjectStatusDB model_object_status_db;
|
||||
|
||||
// 1) Synchronize model objects.
|
||||
|
@ -1219,7 +1229,7 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
|||
if (solid_or_modifier_differ || model_origin_translation_differ || layer_height_ranges_differ ||
|
||||
! model_object.layer_height_profile.timestamp_matches(model_object_new.layer_height_profile)) {
|
||||
// The very first step (the slicing step) is invalidated. One may freely remove all associated PrintObjects.
|
||||
model_object_status.print_object_regions_status =
|
||||
model_object_status.print_object_regions_status =
|
||||
model_object_status.print_object_regions == nullptr || model_origin_translation_differ || layer_height_ranges_differ ?
|
||||
// Drop print_objects_regions.
|
||||
ModelObjectStatus::PrintObjectRegionsStatus::Invalid :
|
||||
|
@ -1279,7 +1289,7 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
|||
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() ||
|
||||
if (model_object.instances.size() != model_object_new.instances.size() ||
|
||||
! std::equal(model_object.instances.begin(), model_object.instances.end(), model_object_new.instances.begin(), [](auto l, auto r){ return l->id() == r->id(); })) {
|
||||
// G-code generator accesses model_object.instances to generate sequential print ordering matching the Plater object list.
|
||||
update_apply_status(this->invalidate_step(psGCodeExport));
|
||||
|
@ -1289,8 +1299,8 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
|||
model_object.instances.emplace_back(new ModelInstance(*model_instance));
|
||||
model_object.instances.back()->set_model_object(&model_object);
|
||||
}
|
||||
} else if (! std::equal(model_object.instances.begin(), model_object.instances.end(), model_object_new.instances.begin(),
|
||||
[](auto l, auto r){ return l->print_volume_state == r->print_volume_state && l->printable == r->printable &&
|
||||
} else if (! std::equal(model_object.instances.begin(), model_object.instances.end(), model_object_new.instances.begin(),
|
||||
[](auto l, auto r){ return l->print_volume_state == r->print_volume_state && l->printable == r->printable &&
|
||||
l->get_transformation().get_matrix().isApprox(r->get_transformation().get_matrix()); })) {
|
||||
// If some of the instances changed, the bounding box of the updated ModelObject is likely no more valid.
|
||||
// This is safe as the ModelObject's bounding box is only accessed from this function, which is called from the main thread only.
|
||||
|
@ -1397,6 +1407,44 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
|||
}
|
||||
}
|
||||
|
||||
//BBS: check the config again
|
||||
int new_used_filaments = this->extruders().size();
|
||||
t_config_option_keys new_changed_keys = new_full_config.normalize_fdm_2(new_used_filaments);
|
||||
if (new_changed_keys.size() > 0) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got new_changed_keys, size=%1%")%new_changed_keys.size();
|
||||
for (int i = 0; i < new_changed_keys.size(); i++)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", i=%1%, key=%2%")%i %new_changed_keys[i];
|
||||
}
|
||||
|
||||
update_apply_status(false);
|
||||
|
||||
// The following call may stop the background processing.
|
||||
update_apply_status(this->invalidate_state_by_config_options(new_full_config, new_changed_keys));
|
||||
|
||||
update_apply_status(this->invalidate_step(psGCodeExport));
|
||||
|
||||
if (full_config_diff.empty()) {
|
||||
//BBS: previous empty
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" %1%: full_config_diff previous empty, need to apply now.")%__LINE__;
|
||||
|
||||
m_placeholder_parser.clear_config();
|
||||
// Set the profile aliases for the PrintBase::output_filename()
|
||||
m_placeholder_parser.set("print_preset", new_full_config.option("print_settings_id")->clone());
|
||||
m_placeholder_parser.set("filament_preset", new_full_config.option("filament_settings_id")->clone());
|
||||
m_placeholder_parser.set("printer_preset", new_full_config.option("printer_settings_id")->clone());
|
||||
|
||||
//m_placeholder_parser.apply_config(filament_overrides);
|
||||
}
|
||||
// It is also safe to change m_config now after this->invalidate_state_by_config_options() call.
|
||||
m_config.apply_only(new_full_config, new_changed_keys, true);
|
||||
// Handle changes to object config defaults
|
||||
m_default_object_config.apply_only(new_full_config, new_changed_keys, true);
|
||||
// Handle changes to regions config defaults
|
||||
m_default_region_config.apply_only(new_full_config, new_changed_keys, true);
|
||||
m_full_print_config = std::move(new_full_config);
|
||||
}
|
||||
|
||||
// All regions now have distinct settings.
|
||||
// Check whether applying the new region config defaults we would get different regions,
|
||||
// update regions or create regions from scratch.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue