Copy and paste -> Fixed copy of multiple instances and volumes insertion into objects list

This commit is contained in:
Enrico Turri 2019-04-11 11:09:32 +02:00
parent 4987e5a7d5
commit 99993170eb
4 changed files with 11 additions and 7 deletions

View File

@ -1630,7 +1630,8 @@ void ObjectList::split()
model_object->volumes[id]->is_modifier() ?
ModelVolumeType::PARAMETER_MODIFIER : ModelVolumeType::MODEL_PART,
model_object->volumes[id]->config.has("extruder") ?
model_object->volumes[id]->config.option<ConfigOptionInt>("extruder")->value : 0);
model_object->volumes[id]->config.option<ConfigOptionInt>("extruder")->value : 0,
false);
// add settings to the part, if it has those
auto opt_keys = model_object->volumes[id]->config.keys();
if ( !(opt_keys.size() == 1 && opt_keys[0] == "extruder") ) {
@ -1824,7 +1825,8 @@ void ObjectList::add_object_to_list(size_t obj_idx)
from_u8(model_object->volumes[id]->name),
model_object->volumes[id]->type(),
!model_object->volumes[id]->config.has("extruder") ? 0 :
model_object->volumes[id]->config.option<ConfigOptionInt>("extruder")->value);
model_object->volumes[id]->config.option<ConfigOptionInt>("extruder")->value,
false);
auto opt_keys = model_object->volumes[id]->config.keys();
if (!opt_keys.empty() && !(opt_keys.size() == 1 && opt_keys[0] == "extruder")) {
select_item(m_objects_model->AddSettingsChild(vol_item));

View File

@ -1045,12 +1045,12 @@ void Selection::copy_to_clipboard()
for (unsigned int i : m_list)
{
const GLVolume* volume = (*m_volumes)[i];
if (volume->object_idx() == object.first)
if ((volume->object_idx() == object.first) && (volume->instance_idx() == *object.second.begin()))
{
int volume_idx = volume->volume_idx();
if ((0 <= volume_idx) && (volume_idx < (int)src_object->volumes.size()))
{
ModelVolume* src_volume = src_object->volumes[volume->volume_idx()];
ModelVolume* src_volume = src_object->volumes[volume_idx];
ModelVolume* dst_volume = dst_object->add_volume(*src_volume);
dst_volume->set_new_unique_id();
dst_volume->config = src_volume->config;

View File

@ -531,7 +531,8 @@ wxDataViewItem PrusaObjectDataViewModel::Add(const wxString &name, const int ext
wxDataViewItem PrusaObjectDataViewModel::AddVolumeChild(const wxDataViewItem &parent_item,
const wxString &name,
const Slic3r::ModelVolumeType volume_type,
const int extruder/* = 0*/)
const int extruder/* = 0*/,
const bool create_frst_child/* = true*/)
{
PrusaObjectDataViewModelNode *root = (PrusaObjectDataViewModelNode*)parent_item.GetID();
if (!root) return wxDataViewItem(0);
@ -543,7 +544,7 @@ wxDataViewItem PrusaObjectDataViewModel::AddVolumeChild(const wxDataViewItem &pa
if (insert_position < 0 || root->GetNthChild(insert_position)->m_type != itInstanceRoot)
insert_position = -1;
if (root->m_volumes_cnt == 0)
if (create_frst_child && root->m_volumes_cnt == 0)
{
const auto node = new PrusaObjectDataViewModelNode(root, root->m_name, *m_volume_bmps[0], extruder_str, 0);
insert_position < 0 ? root->Append(node) : root->Insert(node, insert_position);

View File

@ -457,7 +457,8 @@ public:
wxDataViewItem AddVolumeChild(const wxDataViewItem &parent_item,
const wxString &name,
const Slic3r::ModelVolumeType volume_type,
const int extruder = 0);
const int extruder = 0,
const bool create_frst_child = true);
wxDataViewItem AddSettingsChild(const wxDataViewItem &parent_item);
wxDataViewItem AddInstanceChild(const wxDataViewItem &parent_item, size_t num);
wxDataViewItem Delete(const wxDataViewItem &item);