refine the plate's sliced_result logic
1. when the plate is locked, the sliced result is kept after auto-arrange; 2. when only arrange a plate, other plates' results are not affected Change-Id: I7566e11e9eec0c2b196a2e78d9dc306ea325e9ff
This commit is contained in:
parent
8386b48554
commit
516a960f71
3 changed files with 32 additions and 17 deletions
|
@ -412,7 +412,7 @@ void ArrangeJob::prepare()
|
|||
|
||||
//add the virtual object into unselect list if has
|
||||
m_plater->get_partplate_list().preprocess_exclude_areas(m_unselected, MAX_NUM_PLATES);
|
||||
|
||||
|
||||
#if SAVE_ARRANGE_POLY
|
||||
if (1)
|
||||
{ // subtract excluded region and get a polygon bed
|
||||
|
@ -625,8 +625,11 @@ void ArrangeJob::finalize() {
|
|||
//BBS: partplate
|
||||
PartPlateList& plate_list = m_plater->get_partplate_list();
|
||||
//clear all the relations before apply the arrangement results
|
||||
plate_list.clear();
|
||||
|
||||
if (only_on_partplate) {
|
||||
plate_list.clear(false, false, true, current_plate_index);
|
||||
}
|
||||
else
|
||||
plate_list.clear(false, false, true, -1);
|
||||
//BBS: adjust the bed_index, create new plates, get the max bed_index
|
||||
for (ArrangePolygon& ap : m_selected) {
|
||||
//if (ap.bed_idx < 0) continue; // bed_idx<0 means unarrangable
|
||||
|
@ -709,7 +712,12 @@ void ArrangeJob::finalize() {
|
|||
m_plater->get_notification_manager()->close_notification_of_type(NotificationType::ArrangeOngoing);
|
||||
|
||||
//BBS: reload all objects due to arrange
|
||||
plate_list.rebuild_plates_after_arrangement(!only_on_partplate);
|
||||
if (only_on_partplate) {
|
||||
plate_list.rebuild_plates_after_arrangement(!only_on_partplate, true, current_plate_index);
|
||||
}
|
||||
else {
|
||||
plate_list.rebuild_plates_after_arrangement(!only_on_partplate, true);
|
||||
}
|
||||
|
||||
// BBS: update slice context and gcode result.
|
||||
m_plater->update_slicing_context_to_current_partplate();
|
||||
|
|
|
@ -1162,12 +1162,14 @@ void PartPlate::set_index(int index)
|
|||
m_print->set_plate_index(index);
|
||||
}
|
||||
|
||||
void PartPlate::clear()
|
||||
void PartPlate::clear(bool clear_sliced_result)
|
||||
{
|
||||
obj_to_instance_set.clear();
|
||||
instance_outside_set.clear();
|
||||
m_ready_for_slice = true;
|
||||
update_slice_result_valid_state(false);
|
||||
if (clear_sliced_result) {
|
||||
m_ready_for_slice = true;
|
||||
update_slice_result_valid_state(false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -2415,14 +2417,19 @@ void PartPlateList::reset_size(int width, int depth, int height)
|
|||
}
|
||||
|
||||
//clear all the instances in the plate, but keep the plates
|
||||
void PartPlateList::clear(bool delete_plates, bool release_print_list)
|
||||
void PartPlateList::clear(bool delete_plates, bool release_print_list, bool except_locked, int plate_index)
|
||||
{
|
||||
for (unsigned int i = 0; i < (unsigned int)m_plate_list.size(); ++i)
|
||||
{
|
||||
PartPlate* plate = m_plate_list[i];
|
||||
assert(plate != NULL);
|
||||
|
||||
plate->clear();
|
||||
if (except_locked && plate->is_locked())
|
||||
plate->clear(false);
|
||||
else if ((plate_index != -1) && (plate_index != i))
|
||||
plate->clear(false);
|
||||
else
|
||||
plate->clear();
|
||||
if (delete_plates)
|
||||
delete plate;
|
||||
}
|
||||
|
@ -3202,12 +3209,12 @@ int PartPlateList::add_to_plate(int obj_id, int instance_id, int plate_id)
|
|||
}
|
||||
|
||||
//reload all objects
|
||||
int PartPlateList::reload_all_objects()
|
||||
int PartPlateList::reload_all_objects(bool except_locked, int plate_index)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned int i, j, k;
|
||||
|
||||
clear();
|
||||
clear(false, false, except_locked, plate_index);
|
||||
|
||||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(": m_model->objects.size() is %1%") % m_model->objects.size();
|
||||
//try to find a new plate
|
||||
|
@ -3945,7 +3952,7 @@ int PartPlateList::rebuild_plates_after_deserialize(std::vector<bool>& previous_
|
|||
}
|
||||
|
||||
//retruct plates structures after auto-arrangement
|
||||
int PartPlateList::rebuild_plates_after_arrangement(bool recycle_plates)
|
||||
int PartPlateList::rebuild_plates_after_arrangement(bool recycle_plates, bool except_locked, int plate_index)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
|
@ -3956,7 +3963,7 @@ int PartPlateList::rebuild_plates_after_arrangement(bool recycle_plates)
|
|||
//for (auto object : m_model->objects)
|
||||
// std::sort(object->instances.begin(), object->instances.end(), [](auto a, auto b) {return a->arrange_order < b->arrange_order; });
|
||||
|
||||
ret = reload_all_objects();
|
||||
ret = reload_all_objects(except_locked, plate_index);
|
||||
|
||||
if (recycle_plates)
|
||||
{
|
||||
|
|
|
@ -198,7 +198,7 @@ public:
|
|||
bool operator<(PartPlate&) const;
|
||||
|
||||
//clear alll the instances in plate
|
||||
void clear();
|
||||
void clear(bool clear_sliced_result = true);
|
||||
|
||||
//static const int plate_x_offset = 20; //mm
|
||||
//static const double plate_x_gap = 0.2;
|
||||
|
@ -468,7 +468,7 @@ public:
|
|||
//this may be happened after machine changed
|
||||
void reset_size(int width, int depth, int height);
|
||||
//clear all the instances in the plate, but keep the plates
|
||||
void clear(bool delete_plates = false, bool release_print_list = false);
|
||||
void clear(bool delete_plates = false, bool release_print_list = false, bool except_locked = false, int plate_index = -1);
|
||||
//clear all the instances in the plate, and delete the plates, only keep the first default plate
|
||||
void reset(bool do_init);
|
||||
|
||||
|
@ -563,7 +563,7 @@ public:
|
|||
int add_to_plate(int obj_id, int instance_id, int plate_id);
|
||||
|
||||
//reload all objects
|
||||
int reload_all_objects();
|
||||
int reload_all_objects(bool except_locked = false, int plate_index = -1);
|
||||
|
||||
//reload objects for newly created plate
|
||||
int construct_objects_list_for_new_plate(int plate_index);
|
||||
|
@ -624,7 +624,7 @@ public:
|
|||
int rebuild_plates_after_deserialize(std::vector<bool>& previous_sliced_result, std::vector<std::string>& previous_gcode_paths);
|
||||
|
||||
//retruct plates structures after auto-arrangement
|
||||
int rebuild_plates_after_arrangement(bool recycle_plates = true);
|
||||
int rebuild_plates_after_arrangement(bool recycle_plates = true, bool except_locked = false, int plate_index = -1);
|
||||
|
||||
/* load/store releted functions, with_gcode = true and plate_idx = -1, export all gcode
|
||||
* if with_gcode = true and specify plate_idx, export plate_idx gcode only
|
||||
|
|
Loading…
Reference in a new issue