Fixed DnD for "Model part" volumes inside the object

Fixed volumes order inside the object
This commit is contained in:
YuSanka 2021-06-02 12:52:47 +02:00
parent 2d9953069a
commit 7eebd56b5f
7 changed files with 101 additions and 96 deletions

View file

@ -368,25 +368,7 @@ wxDataViewItem ObjectDataViewModel::AddVolumeChild( const wxDataViewItem &parent
if (insert_position >= 0) insert_position++;
}
size_t new_volume_id = root->m_volumes_cnt;
// find insert_position in respect to the volume type
for (int pos = (insert_position < 0 ? (int)root->GetChildCount() : insert_position) - 1; pos >= 0; pos--) {
ObjectDataViewModelNode* node = root->GetNthChild(pos);
if (volume_type >= node->m_volume_type) {
insert_position = pos + 1;
new_volume_id = (size_t)(node->GetIdx()) + 1;
for (int new_pos = pos + 1; new_pos < (int)root->GetChildCount(); new_pos++) {
ObjectDataViewModelNode* new_node = root->GetNthChild(new_pos);
if (new_node->GetType() != itVolume)
break;
new_node->SetIdx(new_node->GetIdx() + 1);
}
break;
}
}
const auto node = new ObjectDataViewModelNode(root, name, volume_type, GetVolumeIcon(volume_type, has_errors), extruder_str, new_volume_id);
const auto node = new ObjectDataViewModelNode(root, name, volume_type, GetVolumeIcon(volume_type, has_errors), extruder_str, root->m_volumes_cnt);
insert_position < 0 ? root->Append(node) : root->Insert(node, insert_position);
// if part with errors is added, but object wasn't marked, then mark it