Changed object list behavior when we have only one part(volume) inside main object

This commit is contained in:
YuSanka 2018-11-12 13:47:24 +01:00
parent 564fa9e4dc
commit c227dad8cc
4 changed files with 108 additions and 6 deletions

View file

@ -71,6 +71,8 @@ ObjectList::ObjectList(wxWindow* parent) :
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()); });
}
ObjectList::~ObjectList()
@ -88,6 +90,7 @@ void ObjectList::create_objects_ctrl()
m_objects_model = new PrusaObjectDataViewModel;
AssociateModel(m_objects_model);
m_objects_model->SetAssociatedControl(this);
#if wxUSE_DRAG_AND_DROP && wxUSE_UNICODE
EnableDragSource(wxDF_UNICODETEXT);
EnableDropTarget(wxDF_UNICODETEXT);
@ -96,7 +99,7 @@ void ObjectList::create_objects_ctrl()
// column 0(Icon+Text) of the view control:
// And Icon can be consisting of several bitmaps
AppendColumn(new wxDataViewColumn(_(L("Name")), new PrusaBitmapTextRenderer(),
0, 250, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE));
0, 200, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE));
// column 1 of the view control:
AppendColumn(create_objects_list_extruder_column(4));
@ -1434,5 +1437,19 @@ void ObjectList::change_part_type()
}
}
void ObjectList::last_volume_is_deleted(const int obj_idx)
{
if (obj_idx < 0 || (*m_objects).empty() || (*m_objects)[obj_idx]->volumes.empty())
return;
auto volume = (*m_objects)[obj_idx]->volumes[0];
// clear volume's config values
volume->config.clear();
// set a default extruder value, since user can't add it manually
volume->config.set_key_value("extruder", new ConfigOptionInt(0));
}
} //namespace GUI
} //namespace Slic3r