From 5e4c6c8e2d44f9ebd223cb4c887fb4d3f45a16b9 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 10 Dec 2018 14:13:01 +0100 Subject: [PATCH] Fixed build under OSX --- src/slic3r/GUI/GUI_ObjectList.cpp | 53 ++++++++++++++----------------- src/slic3r/GUI/GUI_ObjectList.hpp | 2 +- 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 4996bbd5d..2b74b28d6 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -222,12 +222,28 @@ void ObjectList::set_extruder_column_hidden(bool hide) GetColumn(1)->SetHidden(hide); } -void ObjectList::update_extruder_in_config(const wxString& selection) +void ObjectList::update_extruder_in_config(const wxDataViewItem& item/*wxString& selection*/) { + if (m_objects_model->GetParent(item) == wxDataViewItem(0)) { + const int obj_idx = m_objects_model->GetIdByItem(item); + m_config = &(*m_objects)[obj_idx]->config; + } + else { + const int obj_idx = m_objects_model->GetIdByItem(m_objects_model->GetParent(item)); + const int volume_id = m_objects_model->GetVolumeIdByItem(item); + if (obj_idx < 0 || volume_id < 0) + return; + m_config = &(*m_objects)[obj_idx]->volumes[volume_id]->config; + } + + wxVariant variant; + m_objects_model->GetValue(variant, item, 1); + const wxString selection = variant.GetString(); + if (!m_config || selection.empty()) return; - int extruder = selection.size() > 1 ? 0 : atoi(selection.c_str()); + const int extruder = selection.size() > 1 ? 0 : atoi(selection.c_str()); m_config->set_key_value("extruder", new ConfigOptionInt(extruder)); // update scene @@ -366,11 +382,11 @@ void ObjectList::item_value_change(wxDataViewEvent& event) { wxVariant variant; m_objects_model->GetValue(variant, event.GetItem(), 1); -#ifdef __WXOSX__ - m_selected_extruder = variant.GetString(); -#else // --> for Linux - update_extruder_in_config(variant.GetString()); -#endif //__WXOSX__ +// #ifdef __WXOSX__ +// m_selected_extruder = variant.GetString(); +// #else // --> for Linux +// update_extruder_in_config(variant.GetString()); +// #endif //__WXOSX__ } } @@ -1632,28 +1648,7 @@ void ObjectList::update_settings_items() void ObjectList::ItemValueChanged(wxDataViewEvent &event) { - const wxDataViewItem item = event.GetItem(); - if (m_objects_model->GetParent(item) == wxDataViewItem(0)) { - const int obj_idx = m_objects_model->GetIdByItem(item); - m_config = &(*m_objects)[obj_idx]->config; - } - else { - const int obj_idx = m_objects_model->GetIdByItem(m_objects_model->GetParent(item)); - const int volume_id = m_objects_model->GetVolumeIdByItem(item); - m_config = &(*m_objects)[obj_idx]->volumes[volume_id]->config; - } - - wxVariant variant; - m_objects_model->GetValue(variant, event.GetItem(), 1); - const wxString sel_extr = variant.GetString(); - if (!m_config || sel_extr.empty()) - return; - - int extruder = sel_extr.size() > 1 ? 0 : atoi(sel_extr.c_str()); - m_config->set_key_value("extruder", new ConfigOptionInt(extruder)); - - // update scene - wxGetApp().plater()->update(); + update_extruder_in_config(event.GetItem()); } } //namespace GUI diff --git a/src/slic3r/GUI/GUI_ObjectList.hpp b/src/slic3r/GUI/GUI_ObjectList.hpp index 2e946a28d..9d959c5b7 100644 --- a/src/slic3r/GUI/GUI_ObjectList.hpp +++ b/src/slic3r/GUI/GUI_ObjectList.hpp @@ -105,7 +105,7 @@ public: // show/hide "Extruder" column for Objects List void set_extruder_column_hidden(bool hide); // update extruder in current config - void update_extruder_in_config(const wxString& selection); + void update_extruder_in_config(const wxDataViewItem& item/*wxString& selection*/); void init_icons();