ENH: support default filament for modifier

1. set modifier's initial filament index to "default" (0)
2. allow to change modifier's filament index to "default"

Change-Id: I66e546e20fa5492532dd8733df5b0d38a92fd4d7
Signed-off-by: yifan.wu <yifan.wu@bambulab.com>
This commit is contained in:
yifan.wu 2022-11-19 22:08:27 +08:00 committed by Lane.Wei
parent 6d46ac98ba
commit 05a00edb79
7 changed files with 94 additions and 17 deletions

View file

@ -349,6 +349,11 @@ void ObjectDataViewModelNode::UpdateExtruderAndColorIcon(wxString extruder /*= "
else if (m_type & itVolume && m_volume_type == ModelVolumeType::MODEL_PART) {
extruder_idx = atoi(m_parent->GetExtruder().c_str());
}
// BBS
else if (m_type & itVolume && m_volume_type == ModelVolumeType::PARAMETER_MODIFIER) {
m_extruder_bmp = *get_default_extruder_color_icon();
return;
}
else {
m_extruder_bmp = wxNullBitmap;
return;
@ -546,10 +551,20 @@ wxDataViewItem ObjectDataViewModel::AddVolumeChild( const wxDataViewItem &parent
if (insert_position >= 0) insert_position++;
}
wxString extruder_str = extruder == 0 ? _(L("default")) : wxString::Format("%d", extruder);
// BBS
wxString extruder_str;
if (extruder == 0) {
if (volume_type == ModelVolumeType::PARAMETER_MODIFIER)
extruder_str = _L("default");
else
extruder_str = root->m_extruder;
}
else {
extruder_str = wxString::Format("%d", extruder);
}
const auto node = new ObjectDataViewModelNode(root, name, volume_type, GetVolumeIcon(volume_type, warning_icon_name),
extruder == 0 ? root->m_extruder : extruder_str, root->m_volumes_cnt, warning_icon_name);
extruder_str, root->m_volumes_cnt, warning_icon_name);
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
@ -1378,7 +1393,7 @@ void ObjectDataViewModel::UpdateVolumesExtruderBitmap(wxDataViewItem obj_item, b
return;
ObjectDataViewModelNode* obj_node = static_cast<ObjectDataViewModelNode*>(obj_item.GetID());
for (auto child : obj_node->GetChildren())
if (child->GetVolumeType() == ModelVolumeType::MODEL_PART || child->GetVolumeType() == ModelVolumeType::PARAMETER_MODIFIER)
if (child->GetVolumeType() == ModelVolumeType::MODEL_PART)
child->UpdateExtruderAndColorIcon(use_obj_extruder ? obj_node->GetExtruder() : "");
}