|
@@ -17,16 +17,6 @@ namespace GUI {
|
|
|
|
|
|
wxDEFINE_EVENT(wxCUSTOMEVT_LAST_VOLUME_IS_DELETED, wxCommandEvent);
|
|
|
|
|
|
-static wxBitmap get_extruder_color_icon(size_t extruder_idx, bool thin_icon = false)
|
|
|
-{
|
|
|
- // Create the bitmap with color bars.
|
|
|
- std::vector<wxBitmap*> bmps = get_extruder_color_icons(thin_icon);
|
|
|
- if (bmps.empty())
|
|
|
- return wxNullBitmap;
|
|
|
-
|
|
|
- return *bmps[extruder_idx >= bmps.size() ? 0 : extruder_idx];
|
|
|
-}
|
|
|
-
|
|
|
BitmapCache* m_bitmap_cache = nullptr;
|
|
|
|
|
|
// *****************************************************************************
|
|
@@ -49,6 +39,24 @@ static constexpr char LayerIcon[] = "edit_layers_some";
|
|
|
static constexpr char WarningIcon[] = "exclamation";
|
|
|
static constexpr char InfoIcon[] = "info";
|
|
|
|
|
|
+ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent,
|
|
|
+ const wxString& sub_obj_name,
|
|
|
+ Slic3r::ModelVolumeType type,
|
|
|
+ const wxBitmap& bmp,
|
|
|
+ const wxString& extruder,
|
|
|
+ const int idx/* = -1*/) :
|
|
|
+ m_parent(parent),
|
|
|
+ m_name(sub_obj_name),
|
|
|
+ m_type(itVolume),
|
|
|
+ m_volume_type(type),
|
|
|
+ m_idx(idx),
|
|
|
+ m_extruder(type == Slic3r::ModelVolumeType::MODEL_PART || type == Slic3r::ModelVolumeType::PARAMETER_MODIFIER ? extruder : "")
|
|
|
+{
|
|
|
+ m_bmp = bmp;
|
|
|
+ set_action_and_extruder_icons();
|
|
|
+ init_container();
|
|
|
+}
|
|
|
+
|
|
|
ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent, const InfoItemType info_type) :
|
|
|
m_parent(parent),
|
|
|
m_type(itInfo),
|
|
@@ -137,12 +145,11 @@ void ObjectDataViewModelNode::set_action_and_extruder_icons()
|
|
|
|
|
|
void ObjectDataViewModelNode::set_extruder_icon()
|
|
|
{
|
|
|
- if (m_type & (itInstance | itInstanceRoot | itLayerRoot))
|
|
|
+ if (m_type & (itInstance | itInstanceRoot | itLayerRoot) ||
|
|
|
+ ((m_type & itVolume) && m_volume_type != Slic3r::ModelVolumeType::MODEL_PART && m_volume_type != Slic3r::ModelVolumeType::PARAMETER_MODIFIER))
|
|
|
return; // don't set colored bitmap for Instance
|
|
|
|
|
|
- int extruder_idx = atoi(m_extruder.c_str());
|
|
|
- if (extruder_idx > 0) --extruder_idx;
|
|
|
- m_extruder_bmp = get_extruder_color_icon(extruder_idx);
|
|
|
+ UpdateExtruderAndColorIcon();
|
|
|
}
|
|
|
|
|
|
void ObjectDataViewModelNode::set_printable_icon(PrintIndicator printable)
|
|
@@ -238,6 +245,39 @@ void ObjectDataViewModelNode::SetIdx(const int& idx)
|
|
|
m_name = wxString::Format(_(L("Instance %d")), m_idx + 1);
|
|
|
}
|
|
|
|
|
|
+void ObjectDataViewModelNode::UpdateExtruderAndColorIcon(wxString extruder /*= ""*/)
|
|
|
+{
|
|
|
+ if (m_type == itVolume && m_volume_type != ModelVolumeType::MODEL_PART && m_volume_type != ModelVolumeType::PARAMETER_MODIFIER)
|
|
|
+ return;
|
|
|
+ if (extruder.empty())
|
|
|
+ extruder = m_extruder;
|
|
|
+ else
|
|
|
+ m_extruder = extruder; // update extruder
|
|
|
+
|
|
|
+ // update color icon
|
|
|
+ size_t extruder_idx = atoi(extruder.c_str());
|
|
|
+ if (extruder_idx == 0) {
|
|
|
+ if (m_type & itObject);
|
|
|
+ else if (m_type & itVolume && m_volume_type == ModelVolumeType::MODEL_PART) {
|
|
|
+ extruder_idx = atoi(m_parent->GetExtruder().c_str());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ m_extruder_bmp = wxNullBitmap;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (extruder_idx > 0) --extruder_idx;
|
|
|
+ // Create the bitmap with color bars.
|
|
|
+ std::vector<wxBitmap*> bmps = get_extruder_color_icons(false);// use wide icons
|
|
|
+ if (bmps.empty()) {
|
|
|
+ m_extruder_bmp = wxNullBitmap;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ m_extruder_bmp = *bmps[extruder_idx >= bmps.size() ? 0 : extruder_idx];
|
|
|
+}
|
|
|
+
|
|
|
// *****************************************************************************
|
|
|
// ----------------------------------------------------------------------------
|
|
|
// ObjectDataViewModel
|
|
@@ -317,8 +357,7 @@ wxDataViewItem ObjectDataViewModel::AddVolumeChild( const wxDataViewItem &parent
|
|
|
if (create_frst_child && root->m_volumes_cnt == 0)
|
|
|
{
|
|
|
const Slic3r::ModelVolumeType type = Slic3r::ModelVolumeType::MODEL_PART;
|
|
|
- const auto node = new ObjectDataViewModelNode(root, root->m_name, GetVolumeIcon(type, obj_errors), extruder_str, 0);
|
|
|
- node->m_volume_type = type;
|
|
|
+ const auto node = new ObjectDataViewModelNode(root, root->m_name, type, GetVolumeIcon(type, obj_errors), extruder_str, 0);
|
|
|
|
|
|
insert_position < 0 ? root->Append(node) : root->Insert(node, insert_position);
|
|
|
// notify control
|
|
@@ -347,7 +386,7 @@ wxDataViewItem ObjectDataViewModel::AddVolumeChild( const wxDataViewItem &parent
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- const auto node = new ObjectDataViewModelNode(root, name, 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, new_volume_id);
|
|
|
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
|
|
@@ -359,8 +398,6 @@ wxDataViewItem ObjectDataViewModel::AddVolumeChild( const wxDataViewItem &parent
|
|
|
ItemAdded(parent_item, child);
|
|
|
root->m_volumes_cnt++;
|
|
|
|
|
|
- node->m_volume_type = volume_type;
|
|
|
-
|
|
|
return child;
|
|
|
}
|
|
|
|
|
@@ -1068,20 +1105,36 @@ bool ObjectDataViewModel::UpdateColumValues(unsigned col)
|
|
|
|
|
|
void ObjectDataViewModel::UpdateExtruderBitmap(wxDataViewItem item)
|
|
|
{
|
|
|
- wxString extruder = GetExtruder(item);
|
|
|
- if (extruder.IsEmpty())
|
|
|
+ if (!item.IsOk())
|
|
|
return;
|
|
|
+ ObjectDataViewModelNode* node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
|
|
+ node->UpdateExtruderAndColorIcon();
|
|
|
+}
|
|
|
|
|
|
- // set extruder bitmap
|
|
|
- int extruder_idx = atoi(extruder.c_str());
|
|
|
- if (extruder_idx > 0) --extruder_idx;
|
|
|
-
|
|
|
- const DataViewBitmapText extruder_val(extruder, get_extruder_color_icon(extruder_idx));
|
|
|
+void ObjectDataViewModel::UpdateVolumesExtruderBitmap(wxDataViewItem obj_item)
|
|
|
+{
|
|
|
+ if (!obj_item.IsOk() || GetItemType(obj_item) != itObject)
|
|
|
+ return;
|
|
|
+ ObjectDataViewModelNode* obj_node = static_cast<ObjectDataViewModelNode*>(obj_item.GetID());
|
|
|
+ for (auto child : obj_node->GetChildren())
|
|
|
+ if (child->GetVolumeType() == ModelVolumeType::MODEL_PART)
|
|
|
+ child->UpdateExtruderAndColorIcon();
|
|
|
+}
|
|
|
|
|
|
- wxVariant value;
|
|
|
- value << extruder_val;
|
|
|
+int ObjectDataViewModel::GetDefaultExtruderIdx(wxDataViewItem item)
|
|
|
+{
|
|
|
+ ItemType type = GetItemType(item);
|
|
|
+ if (type == itObject)
|
|
|
+ return 0;
|
|
|
|
|
|
- SetValue(value, item, colExtruder);
|
|
|
+ if (type == itVolume && GetVolumeType(item) == ModelVolumeType::MODEL_PART) {
|
|
|
+ wxDataViewItem obj_item = GetParent(item);
|
|
|
+ int extruder_id = GetExtruderNumber(obj_item);
|
|
|
+ if (extruder_id > 0) extruder_id--;
|
|
|
+ return extruder_id;
|
|
|
+ }
|
|
|
+
|
|
|
+ return -1;
|
|
|
}
|
|
|
|
|
|
void ObjectDataViewModel::GetItemInfo(const wxDataViewItem& item, ItemType& type, int& obj_idx, int& idx)
|
|
@@ -1249,18 +1302,12 @@ bool ObjectDataViewModel::SetValue(const wxVariant &variant, const int item_idx,
|
|
|
|
|
|
void ObjectDataViewModel::SetExtruder(const wxString& extruder, wxDataViewItem item)
|
|
|
{
|
|
|
- DataViewBitmapText extruder_val;
|
|
|
- extruder_val.SetText(extruder);
|
|
|
-
|
|
|
- // set extruder bitmap
|
|
|
- int extruder_idx = atoi(extruder.c_str());
|
|
|
- if (extruder_idx > 0) --extruder_idx;
|
|
|
- extruder_val.SetBitmap(get_extruder_color_icon(extruder_idx));
|
|
|
-
|
|
|
- wxVariant value;
|
|
|
- value << extruder_val;
|
|
|
-
|
|
|
- SetValue(value, item, colExtruder);
|
|
|
+ if (!item.IsOk())
|
|
|
+ return;
|
|
|
+ ObjectDataViewModelNode* node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
|
|
+ node->UpdateExtruderAndColorIcon(extruder);
|
|
|
+ if (node->GetType() == itObject)
|
|
|
+ UpdateVolumesExtruderBitmap(item);
|
|
|
}
|
|
|
|
|
|
void ObjectDataViewModel::AddAllChildren(const wxDataViewItem& parent)
|
|
@@ -1520,14 +1567,19 @@ void ObjectDataViewModel::UpdateSettingsDigest(const wxDataViewItem &item,
|
|
|
ItemChanged(item);
|
|
|
}
|
|
|
|
|
|
-void ObjectDataViewModel::SetVolumeType(const wxDataViewItem &item, const Slic3r::ModelVolumeType type)
|
|
|
+void ObjectDataViewModel::SetVolumeType(const wxDataViewItem &item, const Slic3r::ModelVolumeType volume_type)
|
|
|
{
|
|
|
if (!item.IsOk() || GetItemType(item) != itVolume)
|
|
|
return;
|
|
|
|
|
|
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
|
|
- node->SetVolumeType(type);
|
|
|
- node->SetBitmap(m_volume_bmps[int(type)]);
|
|
|
+ node->SetVolumeType(volume_type);
|
|
|
+ node->SetBitmap(m_volume_bmps[int(volume_type)]);
|
|
|
+ if (volume_type != Slic3r::ModelVolumeType::MODEL_PART && volume_type != Slic3r::ModelVolumeType::PARAMETER_MODIFIER)
|
|
|
+ node->SetExtruder(""); // hide extruder
|
|
|
+ else if (node->GetExtruder().IsEmpty())
|
|
|
+ node->SetExtruder("default"); // show extruder ans set it to default
|
|
|
+ node->UpdateExtruderAndColorIcon();
|
|
|
ItemChanged(item);
|
|
|
}
|
|
|
|