ObjectList::paste_objects_into_list() refactored to call front end / back end synchronization and scene refresh only once

This commit is contained in:
Enrico Turri 2019-04-15 15:40:40 +02:00
parent d8f28bc31a
commit 8235ad2b02
3 changed files with 35 additions and 3 deletions

View File

@ -487,12 +487,13 @@ void ObjectList::paste_objects_into_list(const std::vector<size_t>& object_idxs)
for (const size_t object : object_idxs)
{
add_object_to_list(object);
m_parts_changed = true;
parts_changed(object);
items.Add(m_objects_model->GetItemById(object));
}
m_parts_changed = true;
wxGetApp().plater()->changed_objects(object_idxs);
m_parts_changed = false;
select_items(items);
#ifndef __WXOSX__ //#ifdef __WXMSW__ // #ys_FIXME
selection_changed();

View File

@ -3714,6 +3714,36 @@ void Plater::changed_object(int obj_idx)
this->p->schedule_background_process();
}
void Plater::changed_objects(const std::vector<size_t>& object_idxs)
{
if (object_idxs.empty())
return;
auto list = wxGetApp().obj_list();
wxASSERT(list != nullptr);
if (list == nullptr)
return;
if (list->is_parts_changed()) {
for (int obj_idx : object_idxs)
{
if (obj_idx < p->model.objects.size())
// recenter and re - align to Z = 0
p->model.objects[obj_idx]->ensure_on_bed();
}
if (this->p->printer_technology == ptSLA) {
// Update the SLAPrint from the current Model, so that the reload_scene()
// pulls the correct data, update the 3D scene.
this->p->update_restart_background_process(true, false);
}
else
p->view3D->reload_scene(false);
}
// update print
this->p->schedule_background_process();
}
void Plater::schedule_background_process()
{
this->p->schedule_background_process();

View File

@ -162,6 +162,7 @@ public:
void reslice();
void reslice_SLA_supports(const ModelObject &object);
void changed_object(int obj_idx);
void changed_objects(const std::vector<size_t>& object_idxs);
void schedule_background_process();
void fix_through_netfabb(const int obj_idx, const int vol_idx = -1);
void send_gcode();