Suppressed import/adding of the 3mf which contains multi-part objects

+ Try to fix the wrong extruder selection under OSX
This commit is contained in:
YuSanka 2018-12-10 13:39:56 +01:00
parent 1f0c12dd9f
commit 293d6ba8ad
3 changed files with 58 additions and 20 deletions

View File

@ -68,24 +68,26 @@ ObjectList::ObjectList(wxWindow* parent) :
#ifdef __WXMSW__
// Extruder value changed
Bind(wxEVT_CHOICE, [this](wxCommandEvent& event) { update_extruder_in_config(event.GetString()); });
// Bind(wxEVT_CHOICE, [this](wxCommandEvent& event) { update_extruder_in_config(event.GetString()); });
GetMainWindow()->Bind(wxEVT_MOTION, [this](wxMouseEvent& event) {
set_tooltip_for_item(/*event.GetPosition()*/get_mouse_position_in_control());
event.Skip();
});
#else
// #else
// equivalent to wxEVT_CHOICE on __WXMSW__
Bind(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, [this](wxDataViewEvent& e) { item_value_change(e); });
// Bind(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, [this](wxDataViewEvent& e) { item_value_change(e); });
#endif //__WXMSW__
Bind(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, [this](wxDataViewEvent& e) {on_begin_drag(e); });
Bind(wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, [this](wxDataViewEvent& e) {on_drop_possible(e); });
Bind(wxEVT_DATAVIEW_ITEM_DROP, [this](wxDataViewEvent& e) {on_drop(e); });
Bind(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, [this](wxDataViewEvent& e) { on_begin_drag(e); });
Bind(wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, [this](wxDataViewEvent& e) { on_drop_possible(e); });
Bind(wxEVT_DATAVIEW_ITEM_DROP, [this](wxDataViewEvent& e) { on_drop(e); });
Bind(wxCUSTOMEVT_LAST_VOLUME_IS_DELETED, [this](wxCommandEvent& e) {last_volume_is_deleted(e.GetInt()); });
Bind(wxCUSTOMEVT_LAST_VOLUME_IS_DELETED, [this](wxCommandEvent& e) { last_volume_is_deleted(e.GetInt()); });
Bind(wxEVT_DATAVIEW_ITEM_START_EDITING, &ObjectList::OnStartEditing, this);
// Bind(wxEVT_DATAVIEW_ITEM_START_EDITING, &ObjectList::OnStartEditing, this);
// Bind(wxEVT_DATAVIEW_ITEM_EDITING_DONE, &ObjectList::OnEditingDone, this);
Bind(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, &ObjectList::ItemValueChanged, this);
}
ObjectList::~ObjectList()
@ -276,9 +278,9 @@ void ObjectList::selection_changed()
part_selection_changed();
#ifdef __WXOSX__
update_extruder_in_config(m_selected_extruder);
#endif //__WXOSX__
// #ifdef __WXOSX__
// update_extruder_in_config(m_selected_extruder);
// #endif //__WXOSX__
}
void ObjectList::context_menu()
@ -1623,11 +1625,35 @@ void ObjectList::update_settings_items()
UnselectAll();
}
void ObjectList::OnStartEditing(wxDataViewEvent &event)
// void ObjectList::OnEditingDone(wxDataViewEvent &event)
// {
// m_selected_extruder = event.GetValue().GetString();
// }
void ObjectList::ItemValueChanged(wxDataViewEvent &event)
{
const auto item_type = m_objects_model->GetItemType(event.GetItem());
if ( !(item_type&(itObject|itVolume)) )
event.Veto();
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();
}
} //namespace GUI

View File

@ -80,9 +80,9 @@ class ObjectList : public wxDataViewCtrl
bool m_prevent_list_events = false; // We use this flag to avoid circular event handling Select()
// happens to fire a wxEVT_LIST_ITEM_SELECTED on OSX, whose event handler
// calls this method again and again and again
#ifdef __WXOSX__
wxString m_selected_extruder = "";
#endif //__WXOSX__
// #ifdef __WXOSX__
// wxString m_selected_extruder = "";
// #endif //__WXOSX__
bool m_parts_changed = false;
bool m_part_settings_changed = false;
@ -202,8 +202,8 @@ public:
void update_settings_items();
private:
void OnStartEditing(wxDataViewEvent &event);
// void OnEditingDone(wxDataViewEvent &event);
void ItemValueChanged(wxDataViewEvent &event);
};

View File

@ -1453,6 +1453,18 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
}
}
// check multi-part object adding for the SLA-printing
if (printer_technology == ptSLA)
{
for (auto obj : model.objects)
if ( obj->volumes.size()>1 ) {
Slic3r::GUI::show_error(nullptr,
wxString::Format(_(L("You can't to add the object(s) from %s because of one or some of them is(are) multi-part")),
filename.string()));
return std::vector<size_t>();
}
}
if (one_by_one) {
auto loaded_idxs = load_model_objects(model.objects);
obj_idxs.insert(obj_idxs.end(), loaded_idxs.begin(), loaded_idxs.end());