Code refactoring: Deleted unused variables and _cleaned_ overbusy functions

This commit is contained in:
YuSanka 2019-04-22 01:51:10 +02:00
parent ff3f1c9ee0
commit 1f02eb704a
5 changed files with 39 additions and 72 deletions

View file

@ -463,8 +463,7 @@ void ObjectList::paste_volumes_into_list(int obj_idx, const ModelVolumePtrs& vol
items.Add(vol_item); items.Add(vol_item);
} }
m_parts_changed = true; changed_object(obj_idx);
parts_changed(obj_idx);
if (items.size() > 1) if (items.size() > 1)
{ {
@ -490,9 +489,7 @@ void ObjectList::paste_objects_into_list(const std::vector<size_t>& object_idxs)
items.Add(m_objects_model->GetItemById(object)); items.Add(m_objects_model->GetItemById(object));
} }
m_parts_changed = true;
wxGetApp().plater()->changed_objects(object_idxs); wxGetApp().plater()->changed_objects(object_idxs);
m_parts_changed = false;
select_items(items); select_items(items);
#ifndef __WXOSX__ //#ifdef __WXMSW__ // #ys_FIXME #ifndef __WXOSX__ //#ifdef __WXMSW__ // #ys_FIXME
@ -703,8 +700,7 @@ void ObjectList::OnDrop(wxDataViewEvent &event)
select_item(m_objects_model->ReorganizeChildren(from_volume_id, to_volume_id, select_item(m_objects_model->ReorganizeChildren(from_volume_id, to_volume_id,
m_objects_model->GetParent(item))); m_objects_model->GetParent(item)));
m_parts_changed = true; changed_object(m_dragged_data.obj_idx());
parts_changed(m_dragged_data.obj_idx());
m_dragged_data.clear(); m_dragged_data.clear();
} }
@ -1290,7 +1286,7 @@ void ObjectList::load_subobject(ModelVolumeType type)
wxArrayString part_names; wxArrayString part_names;
load_part((*m_objects)[obj_idx], part_names, type); load_part((*m_objects)[obj_idx], part_names, type);
parts_changed(obj_idx); changed_object(obj_idx);
for (int i = 0; i < part_names.size(); ++i) { for (int i = 0; i < part_names.size(); ++i) {
const wxDataViewItem sel_item = m_objects_model->AddVolumeChild(item, part_names.Item(i), type); const wxDataViewItem sel_item = m_objects_model->AddVolumeChild(item, part_names.Item(i), type);
@ -1306,7 +1302,6 @@ void ObjectList::load_part( ModelObject* model_object,
{ {
wxWindow* parent = wxGetApp().tab_panel()->GetPage(0); wxWindow* parent = wxGetApp().tab_panel()->GetPage(0);
m_parts_changed = false;
wxArrayString input_files; wxArrayString input_files;
wxGetApp().import_model(parent, input_files); wxGetApp().import_model(parent, input_files);
for (int i = 0; i < input_files.size(); ++i) { for (int i = 0; i < input_files.size(); ++i) {
@ -1342,8 +1337,6 @@ void ObjectList::load_part( ModelObject* model_object,
// set a default extruder value, since user can't add it manually // set a default extruder value, since user can't add it manually
new_volume->config.set_key_value("extruder", new ConfigOptionInt(0)); new_volume->config.set_key_value("extruder", new ConfigOptionInt(0));
m_parts_changed = true;
} }
} }
} }
@ -1493,8 +1486,7 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
// set a default extruder value, since user can't add it manually // set a default extruder value, since user can't add it manually
new_volume->config.set_key_value("extruder", new ConfigOptionInt(0)); new_volume->config.set_key_value("extruder", new ConfigOptionInt(0));
m_parts_changed = true; changed_object(obj_idx);
parts_changed(obj_idx);
const auto object_item = m_objects_model->GetTopParent(GetSelection()); const auto object_item = m_objects_model->GetTopParent(GetSelection());
select_item(m_objects_model->AddVolumeChild(object_item, name, type)); select_item(m_objects_model->AddVolumeChild(object_item, name, type));
@ -1558,8 +1550,7 @@ void ObjectList::del_instances_from_object(const int obj_idx)
(*m_objects)[obj_idx]->invalidate_bounding_box(); // ? #ys_FIXME (*m_objects)[obj_idx]->invalidate_bounding_box(); // ? #ys_FIXME
m_parts_changed = true; changed_object(obj_idx);
parts_changed(obj_idx);
} }
bool ObjectList::del_subobject_from_object(const int obj_idx, const int idx, const int type) bool ObjectList::del_subobject_from_object(const int obj_idx, const int idx, const int type)
@ -1604,8 +1595,7 @@ bool ObjectList::del_subobject_from_object(const int obj_idx, const int idx, con
else else
return false; return false;
m_parts_changed = true; changed_object(obj_idx);
parts_changed(obj_idx);
return true; return true;
} }
@ -1655,8 +1645,7 @@ void ObjectList::split()
if (parent == item) if (parent == item)
Expand(parent); Expand(parent);
m_parts_changed = true; changed_object(obj_idx);
parts_changed(obj_idx);
} }
bool ObjectList::get_volume_by_item(const wxDataViewItem& item, ModelVolume*& volume) bool ObjectList::get_volume_by_item(const wxDataViewItem& item, ModelVolume*& volume)
@ -1713,17 +1702,10 @@ bool ObjectList::can_split_instances()
return selection.is_multiple_full_instance() || selection.is_single_full_instance(); return selection.is_multiple_full_instance() || selection.is_single_full_instance();
} }
void ObjectList::part_settings_changed() // NO_PARAMETERS function call means that changed object index will be determine from Selection()
void ObjectList::changed_object(const int obj_idx/* = -1*/) const
{ {
m_part_settings_changed = true; wxGetApp().plater()->changed_object(obj_idx < 0 ? get_selected_obj_idx() : obj_idx);
wxGetApp().plater()->changed_object(get_selected_obj_idx());
m_part_settings_changed = false;
}
void ObjectList::parts_changed(int obj_idx)
{
wxGetApp().plater()->changed_object(obj_idx);
m_parts_changed = false;
} }
void ObjectList::part_selection_changed() void ObjectList::part_selection_changed()
@ -2446,8 +2428,7 @@ void ObjectList::change_part_type()
volume->set_type(new_type); volume->set_type(new_type);
m_objects_model->SetVolumeType(item, new_type); m_objects_model->SetVolumeType(item, new_type);
m_parts_changed = true; changed_object(get_selected_obj_idx());
parts_changed(get_selected_obj_idx());
// Update settings showing, if we have it // Update settings showing, if we have it
//(we show additional settings for Part and Modifier and hide it for Support Blocker/Enforcer) //(we show additional settings for Part and Modifier and hide it for Support Blocker/Enforcer)

View file

@ -139,8 +139,8 @@ class ObjectList : public wxDataViewCtrl
// update_settings_items - updating canvas selection is undesirable, // update_settings_items - updating canvas selection is undesirable,
// because it would turn off the gizmos (mainly a problem for the SLA gizmo) // because it would turn off the gizmos (mainly a problem for the SLA gizmo)
bool m_parts_changed = false; // bool m_parts_changed = false;
bool m_part_settings_changed = false; // bool m_part_settings_changed = false;
int m_selected_row = 0; int m_selected_row = 0;
wxDataViewItem m_last_selected_item {nullptr}; wxDataViewItem m_last_selected_item {nullptr};
@ -225,11 +225,8 @@ public:
wxBoxSizer* get_sizer() {return m_sizer;} wxBoxSizer* get_sizer() {return m_sizer;}
int get_selected_obj_idx() const; int get_selected_obj_idx() const;
DynamicPrintConfig& get_item_config(const wxDataViewItem& item) const; DynamicPrintConfig& get_item_config(const wxDataViewItem& item) const;
bool is_parts_changed() const { return m_parts_changed; }
bool is_part_settings_changed() const { return m_part_settings_changed; }
void part_settings_changed();
void parts_changed(int obj_idx); void changed_object(const int obj_idx = -1) const;
void part_selection_changed(); void part_selection_changed();
// Add object to the list // Add object to the list

View file

@ -84,7 +84,7 @@ void ObjectSettings::update_settings_list()
#endif // __WXMSW__ #endif // __WXMSW__
btn->Bind(wxEVT_BUTTON, [opt_key, config, this](wxEvent &event) { btn->Bind(wxEVT_BUTTON, [opt_key, config, this](wxEvent &event) {
config->erase(opt_key); config->erase(opt_key);
wxGetApp().obj_list()->part_settings_changed(); wxGetApp().obj_list()->changed_object();
wxTheApp->CallAfter([this]() { wxTheApp->CallAfter([this]() {
wxWindowUpdateLocker noUpdates(m_parent); wxWindowUpdateLocker noUpdates(m_parent);
update_settings_list(); update_settings_list();
@ -127,7 +127,7 @@ void ObjectSettings::update_settings_list()
optgroup->sidetext_width = 5.5 * wxGetApp().em_unit(); optgroup->sidetext_width = 5.5 * wxGetApp().em_unit();
optgroup->m_on_change = [](const t_config_option_key& opt_id, const boost::any& value) { optgroup->m_on_change = [](const t_config_option_key& opt_id, const boost::any& value) {
wxGetApp().obj_list()->part_settings_changed(); }; wxGetApp().obj_list()->changed_object(); };
for (auto& opt : cat.second) for (auto& opt : cat.second)
{ {

View file

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

View file

@ -1755,6 +1755,8 @@ void TabPrinter::build_fff()
auto *nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(m_config->option("nozzle_diameter")); auto *nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(m_config->option("nozzle_diameter"));
m_initial_extruders_count = m_extruders_count = nozzle_diameter->values.size(); m_initial_extruders_count = m_extruders_count = nozzle_diameter->values.size();
wxGetApp().sidebar().update_objects_list_extruder_column(m_initial_extruders_count);
const Preset* parent_preset = m_presets->get_selected_preset_parent(); const Preset* parent_preset = m_presets->get_selected_preset_parent();
m_sys_extruders_count = parent_preset == nullptr ? 0 : m_sys_extruders_count = parent_preset == nullptr ? 0 :
static_cast<const ConfigOptionFloats*>(parent_preset->config.option("nozzle_diameter"))->values.size(); static_cast<const ConfigOptionFloats*>(parent_preset->config.option("nozzle_diameter"))->values.size();