mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 06:15:58 +08:00
Cut WIP: Lock icon is added for objects after a cut performing
* ObjectDataViewModel: Some code refactoring to update bitmap in respect to the warning mane and lock appearance
This commit is contained in:
parent
c29b7b1eef
commit
87e1df2fb2
@ -1383,6 +1383,15 @@ bool ObjectList::is_instance_or_object_selected()
|
||||
return selection.is_single_full_instance() || selection.is_single_full_object();
|
||||
}
|
||||
|
||||
bool ObjectList::is_selected_object_cut()
|
||||
{
|
||||
const Selection& selection = scene_selection();
|
||||
int obj_idx = selection.get_object_idx();
|
||||
if (obj_idx < 0)
|
||||
return false;
|
||||
return object(obj_idx)->is_cut();
|
||||
}
|
||||
|
||||
void ObjectList::load_subobject(ModelVolumeType type, bool from_galery/* = false*/)
|
||||
{
|
||||
if (type == ModelVolumeType::INVALID && from_galery) {
|
||||
@ -1779,22 +1788,22 @@ void ObjectList::load_mesh_object(const TriangleMesh &mesh, const wxString &name
|
||||
#endif /* _DEBUG */
|
||||
}
|
||||
|
||||
void ObjectList::del_object(const int obj_idx)
|
||||
bool ObjectList::del_object(const int obj_idx)
|
||||
{
|
||||
wxGetApp().plater()->delete_object_from_model(obj_idx);
|
||||
return wxGetApp().plater()->delete_object_from_model(obj_idx);
|
||||
}
|
||||
|
||||
// Delete subobject
|
||||
void ObjectList::del_subobject_item(wxDataViewItem& item)
|
||||
bool ObjectList::del_subobject_item(wxDataViewItem& item)
|
||||
{
|
||||
if (!item) return;
|
||||
if (!item) return false;
|
||||
|
||||
int obj_idx, idx;
|
||||
ItemType type;
|
||||
|
||||
m_objects_model->GetItemInfo(item, type, obj_idx, idx);
|
||||
if (type == itUndef)
|
||||
return;
|
||||
return false;
|
||||
|
||||
wxDataViewItem parent = m_objects_model->GetParent(item);
|
||||
|
||||
@ -1808,10 +1817,8 @@ void ObjectList::del_subobject_item(wxDataViewItem& item)
|
||||
del_layer_from_object(obj_idx, m_objects_model->GetLayerRangeByItem(item));
|
||||
else if (type & itInfo && obj_idx != -1)
|
||||
del_info_item(obj_idx, m_objects_model->GetInfoItemType(item));
|
||||
else if (idx == -1)
|
||||
return;
|
||||
else if (!del_subobject_from_object(obj_idx, idx, type))
|
||||
return;
|
||||
else if (idx == -1 || !del_subobject_from_object(obj_idx, idx, type))
|
||||
return false;
|
||||
|
||||
// If last volume item with warning was deleted, unmark object item
|
||||
if (type & itVolume) {
|
||||
@ -1821,6 +1828,8 @@ void ObjectList::del_subobject_item(wxDataViewItem& item)
|
||||
|
||||
m_objects_model->Delete(item);
|
||||
update_info_items(obj_idx);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ObjectList::del_info_item(const int obj_idx, InfoItemType type)
|
||||
@ -1965,6 +1974,16 @@ bool ObjectList::del_subobject_from_object(const int obj_idx, const int idx, con
|
||||
Slic3r::GUI::show_error(nullptr, _L("From Object List You can't delete the last solid part from object."));
|
||||
return false;
|
||||
}
|
||||
if (object->is_cut()) {
|
||||
if (volume->is_model_part()) {
|
||||
Slic3r::GUI::show_error(nullptr, _L("Solid part cannot be deleted from cut object."));
|
||||
return false;
|
||||
}
|
||||
if (volume->is_negative_volume()) {
|
||||
Slic3r::GUI::show_error(nullptr, _L("Negative volume cannot be deleted from cut object."));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
take_snapshot(_L("Delete Subobject"));
|
||||
|
||||
@ -1992,6 +2011,10 @@ bool ObjectList::del_subobject_from_object(const int obj_idx, const int idx, con
|
||||
Slic3r::GUI::show_error(nullptr, _L("Last instance of an object cannot be deleted."));
|
||||
return false;
|
||||
}
|
||||
if (object->is_cut()) {
|
||||
Slic3r::GUI::show_error(nullptr, _L("Instance cannot be deleted from cut object."));
|
||||
return false;
|
||||
}
|
||||
|
||||
take_snapshot(_L("Delete Instance"));
|
||||
object->delete_instance(idx);
|
||||
@ -2735,7 +2758,8 @@ void ObjectList::add_object_to_list(size_t obj_idx, bool call_selection_changed)
|
||||
const wxString& item_name = from_u8(model_object->name);
|
||||
const auto item = m_objects_model->Add(item_name,
|
||||
model_object->config.has("extruder") ? model_object->config.extruder() : 0,
|
||||
get_warning_icon_name(model_object->mesh().stats()));
|
||||
get_warning_icon_name(model_object->mesh().stats()),
|
||||
model_object->is_cut());
|
||||
|
||||
update_info_items(obj_idx, nullptr, call_selection_changed);
|
||||
|
||||
@ -2805,29 +2829,40 @@ void ObjectList::delete_instance_from_list(const size_t obj_idx, const size_t in
|
||||
select_item([this, obj_idx, inst_idx]() { return m_objects_model->Delete(m_objects_model->GetItemByInstanceId(obj_idx, inst_idx)); });
|
||||
}
|
||||
|
||||
void ObjectList::delete_from_model_and_list(const ItemType type, const int obj_idx, const int sub_obj_idx)
|
||||
void ObjectList::update_lock_icons_for_model()
|
||||
{
|
||||
if ( !(type&(itObject|itVolume|itInstance)) )
|
||||
return;
|
||||
|
||||
take_snapshot(_(L("Delete Selected Item")));
|
||||
|
||||
if (type&itObject) {
|
||||
del_object(obj_idx);
|
||||
delete_object_from_list(obj_idx);
|
||||
}
|
||||
else {
|
||||
del_subobject_from_object(obj_idx, sub_obj_idx, type);
|
||||
|
||||
type == itVolume ? delete_volume_from_list(obj_idx, sub_obj_idx) :
|
||||
delete_instance_from_list(obj_idx, sub_obj_idx);
|
||||
}
|
||||
for (int obj_idx = 0; obj_idx < (*m_objects).size(); ++obj_idx)
|
||||
if (!(*m_objects)[obj_idx]->is_cut())
|
||||
m_objects_model->UpdateLockIcon(m_objects_model->GetItemById(obj_idx), false);
|
||||
}
|
||||
|
||||
void ObjectList::delete_from_model_and_list(const std::vector<ItemForDelete>& items_for_delete)
|
||||
bool ObjectList::delete_from_model_and_list(const ItemType type, const int obj_idx, const int sub_obj_idx)
|
||||
{
|
||||
// take_snapshot(_(L("Delete Selected Item"))); // #ysFIXME - delete this redundant snapshot after test
|
||||
|
||||
if (type & (itObject | itVolume | itInstance)) {
|
||||
if (type & itObject) {
|
||||
bool was_cut = object(obj_idx)->is_cut();
|
||||
if (del_object(obj_idx)) {
|
||||
delete_object_from_list(obj_idx);
|
||||
if (was_cut)
|
||||
update_lock_icons_for_model();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (del_subobject_from_object(obj_idx, sub_obj_idx, type)) {
|
||||
type == itVolume ? delete_volume_from_list(obj_idx, sub_obj_idx) :
|
||||
delete_instance_from_list(obj_idx, sub_obj_idx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ObjectList::delete_from_model_and_list(const std::vector<ItemForDelete>& items_for_delete)
|
||||
{
|
||||
if (items_for_delete.empty())
|
||||
return;
|
||||
return false;
|
||||
|
||||
m_prevent_list_events = true;
|
||||
|
||||
@ -2836,8 +2871,12 @@ void ObjectList::delete_from_model_and_list(const std::vector<ItemForDelete>& it
|
||||
if (!(item->type&(itObject | itVolume | itInstance)))
|
||||
continue;
|
||||
if (item->type&itObject) {
|
||||
del_object(item->obj_idx);
|
||||
bool was_cut = object(item->obj_idx)->is_cut();
|
||||
if (!del_object(item->obj_idx))
|
||||
continue;
|
||||
m_objects_model->Delete(m_objects_model->GetItemById(item->obj_idx));
|
||||
if (was_cut)
|
||||
update_lock_icons_for_model();
|
||||
}
|
||||
else {
|
||||
if (!del_subobject_from_object(item->obj_idx, item->sub_obj_idx, item->type))
|
||||
@ -2867,8 +2906,12 @@ void ObjectList::delete_from_model_and_list(const std::vector<ItemForDelete>& it
|
||||
update_info_items(id);
|
||||
}
|
||||
|
||||
m_prevent_list_events = true;
|
||||
m_prevent_list_events = false;
|
||||
if (modified_objects_ids.empty())
|
||||
return false;
|
||||
part_selection_changed();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ObjectList::delete_all_objects_from_list()
|
||||
@ -2973,8 +3016,10 @@ void ObjectList::remove()
|
||||
{
|
||||
wxDataViewItem parent = m_objects_model->GetParent(item);
|
||||
ItemType type = m_objects_model->GetItemType(item);
|
||||
if (type & itObject)
|
||||
delete_from_model_and_list(itObject, m_objects_model->GetIdByItem(item), -1);
|
||||
if (type & itObject) {
|
||||
if (!delete_from_model_and_list(itObject, m_objects_model->GetIdByItem(item), -1))
|
||||
return item;
|
||||
}
|
||||
else {
|
||||
if (type & (itLayer | itInstance)) {
|
||||
// In case there is just one layer or two instances and we delete it, del_subobject_item will
|
||||
@ -2984,7 +3029,8 @@ void ObjectList::remove()
|
||||
parent = m_objects_model->GetTopParent(item);
|
||||
}
|
||||
|
||||
del_subobject_item(item);
|
||||
if (!del_subobject_item(item))
|
||||
return item;
|
||||
}
|
||||
|
||||
return parent;
|
||||
|
@ -247,7 +247,7 @@ public:
|
||||
void add_category_to_settings_from_frequent(const std::vector<std::string>& category_options, wxDataViewItem item);
|
||||
void show_settings(const wxDataViewItem settings_item);
|
||||
bool is_instance_or_object_selected();
|
||||
|
||||
bool is_selected_object_cut();
|
||||
void load_subobject(ModelVolumeType type, bool from_galery = false);
|
||||
// ! ysFIXME - delete commented code after testing and rename "load_modifier" to something common
|
||||
//void load_part(ModelObject& model_object, std::vector<ModelVolume*>& added_volumes, ModelVolumeType type, bool from_galery = false);
|
||||
@ -257,8 +257,8 @@ public:
|
||||
void load_shape_object_from_gallery();
|
||||
void load_shape_object_from_gallery(const wxArrayString& input_files);
|
||||
void load_mesh_object(const TriangleMesh &mesh, const wxString &name, bool center = true);
|
||||
void del_object(const int obj_idx);
|
||||
void del_subobject_item(wxDataViewItem& item);
|
||||
bool del_object(const int obj_idx);
|
||||
bool del_subobject_item(wxDataViewItem& item);
|
||||
void del_settings_from_config(const wxDataViewItem& parent_item);
|
||||
void del_instances_from_object(const int obj_idx);
|
||||
void del_layer_from_object(const int obj_idx, const t_layer_height_range& layer_range);
|
||||
@ -295,8 +295,9 @@ public:
|
||||
void delete_object_from_list(const size_t obj_idx);
|
||||
void delete_volume_from_list(const size_t obj_idx, const size_t vol_idx);
|
||||
void delete_instance_from_list(const size_t obj_idx, const size_t inst_idx);
|
||||
void delete_from_model_and_list(const ItemType type, const int obj_idx, const int sub_obj_idx);
|
||||
void delete_from_model_and_list(const std::vector<ItemForDelete>& items_for_delete);
|
||||
void update_lock_icons_for_model();
|
||||
bool delete_from_model_and_list(const ItemType type, const int obj_idx, const int sub_obj_idx);
|
||||
bool delete_from_model_and_list(const std::vector<ItemForDelete>& items_for_delete);
|
||||
// Delete all objects from the list
|
||||
void delete_all_objects_from_list();
|
||||
// Increase instances count
|
||||
|
@ -38,6 +38,7 @@ static constexpr char LayerRootIcon[] = "edit_layers_all";
|
||||
static constexpr char LayerIcon[] = "edit_layers_some";
|
||||
static constexpr char WarningIcon[] = "exclamation";
|
||||
static constexpr char WarningManifoldIcon[] = "exclamation_manifold";
|
||||
static constexpr char LockIcon[] = "lock_closed_white";
|
||||
|
||||
struct InfoItemAtributes {
|
||||
std::string name;
|
||||
@ -57,19 +58,15 @@ const std::map<InfoItemType, InfoItemAtributes> INFO_ITEMS{
|
||||
ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent,
|
||||
const wxString& sub_obj_name,
|
||||
Slic3r::ModelVolumeType type,
|
||||
const wxBitmap& bmp,
|
||||
const wxString& extruder,
|
||||
const int idx/* = -1*/,
|
||||
const std::string& warning_icon_name /*= std::string*/) :
|
||||
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_warning_icon_name(warning_icon_name)
|
||||
m_extruder(type == Slic3r::ModelVolumeType::MODEL_PART || type == Slic3r::ModelVolumeType::PARAMETER_MODIFIER ? extruder : "")
|
||||
{
|
||||
m_bmp = bmp;
|
||||
set_action_and_extruder_icons();
|
||||
init_container();
|
||||
}
|
||||
@ -174,13 +171,6 @@ void ObjectDataViewModelNode::set_printable_icon(PrintIndicator printable)
|
||||
create_scaled_bitmap(m_printable == piPrintable ? "eye_open.png" : "eye_closed.png");
|
||||
}
|
||||
|
||||
void ObjectDataViewModelNode::set_warning_icon(const std::string& warning_icon_name)
|
||||
{
|
||||
m_warning_icon_name = warning_icon_name;
|
||||
if (warning_icon_name.empty())
|
||||
m_bmp = m_empty_bmp;
|
||||
}
|
||||
|
||||
void ObjectDataViewModelNode::update_settings_digest_bitmaps()
|
||||
{
|
||||
m_bmp = m_empty_bmp;
|
||||
@ -328,6 +318,7 @@ ObjectDataViewModel::ObjectDataViewModel()
|
||||
m_volume_bmps = MenuFactory::get_volume_bitmaps();
|
||||
m_warning_bmp = create_scaled_bitmap(WarningIcon);
|
||||
m_warning_manifold_bmp = create_scaled_bitmap(WarningManifoldIcon);
|
||||
m_lock_bmp = create_scaled_bitmap(LockIcon);
|
||||
|
||||
for (auto item : INFO_ITEMS)
|
||||
m_info_bmps[item.first] = create_scaled_bitmap(item.second.bmp_name);
|
||||
@ -341,19 +332,56 @@ ObjectDataViewModel::~ObjectDataViewModel()
|
||||
m_bitmap_cache = nullptr;
|
||||
}
|
||||
|
||||
wxBitmap& ObjectDataViewModel::GetWarningBitmap(const std::string& warning_icon_name)
|
||||
void ObjectDataViewModel::UpdateBitmapForNode(ObjectDataViewModelNode* node)
|
||||
{
|
||||
return warning_icon_name.empty() ? m_empty_bmp : warning_icon_name == WarningIcon ? m_warning_bmp : m_warning_manifold_bmp;
|
||||
int vol_type = static_cast<int>(node->GetVolumeType());
|
||||
bool is_volume_node = vol_type >= 0;
|
||||
|
||||
if (!node->has_warning_icon() && !node->has_lock()) {
|
||||
node->SetBitmap(is_volume_node ? m_volume_bmps[vol_type] : m_empty_bmp);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string scaled_bitmap_name = std::string();
|
||||
if (node->has_warning_icon())
|
||||
scaled_bitmap_name += node->warning_icon_name();
|
||||
if (node->has_lock())
|
||||
scaled_bitmap_name += LockIcon;
|
||||
if (is_volume_node)
|
||||
scaled_bitmap_name += std::to_string(vol_type);
|
||||
scaled_bitmap_name += "-em" + std::to_string(wxGetApp().em_unit()) + (wxGetApp().dark_mode() ? "-dm" : "-lm");
|
||||
|
||||
wxBitmap* bmp = m_bitmap_cache->find(scaled_bitmap_name);
|
||||
if (!bmp) {
|
||||
std::vector<wxBitmap> bmps;
|
||||
if (node->has_warning_icon())
|
||||
bmps.emplace_back(node->warning_icon_name() == WarningIcon ? m_warning_bmp : m_warning_manifold_bmp);
|
||||
if (node->has_lock())
|
||||
bmps.emplace_back(m_lock_bmp);
|
||||
if (is_volume_node)
|
||||
bmps.emplace_back(m_volume_bmps[vol_type]);
|
||||
bmp = m_bitmap_cache->insert(scaled_bitmap_name, bmps);
|
||||
}
|
||||
|
||||
node->SetBitmap(*bmp);
|
||||
}
|
||||
|
||||
void ObjectDataViewModel::UpdateBitmapForNode(ObjectDataViewModelNode* node, const std::string& warning_icon_name, bool has_lock)
|
||||
{
|
||||
node->SetWarningIconName(warning_icon_name);
|
||||
node->SetLock(has_lock);
|
||||
UpdateBitmapForNode(node);
|
||||
}
|
||||
|
||||
wxDataViewItem ObjectDataViewModel::Add(const wxString &name,
|
||||
const int extruder,
|
||||
const std::string& warning_icon_name/* = std::string()*/ )
|
||||
const std::string& warning_icon_name,
|
||||
const bool has_lock)
|
||||
{
|
||||
const wxString extruder_str = extruder == 0 ? _L("default") : wxString::Format("%d", extruder);
|
||||
auto root = new ObjectDataViewModelNode(name, extruder_str);
|
||||
// Add warning icon if detected auto-repaire
|
||||
root->SetWarningBitmap(GetWarningBitmap(warning_icon_name), warning_icon_name);
|
||||
UpdateBitmapForNode(root, warning_icon_name, has_lock);
|
||||
|
||||
m_objects.push_back(root);
|
||||
// notify control
|
||||
@ -384,7 +412,8 @@ 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, type, GetVolumeIcon(type, root->m_warning_icon_name), extruder_str, 0, root->m_warning_icon_name);
|
||||
const auto node = new ObjectDataViewModelNode(root, root->m_name, type, extruder_str, 0);
|
||||
UpdateBitmapForNode(node, root->warning_icon_name(), root->has_lock());
|
||||
|
||||
insert_position < 0 ? root->Append(node) : root->Insert(node, insert_position);
|
||||
// notify control
|
||||
@ -395,13 +424,16 @@ wxDataViewItem ObjectDataViewModel::AddVolumeChild( const wxDataViewItem &parent
|
||||
if (insert_position >= 0) insert_position++;
|
||||
}
|
||||
|
||||
const auto node = new ObjectDataViewModelNode(root, name, volume_type, GetVolumeIcon(volume_type, warning_icon_name), extruder_str, root->m_volumes_cnt, warning_icon_name);
|
||||
const auto node = new ObjectDataViewModelNode(root, name, volume_type, extruder_str, root->m_volumes_cnt);
|
||||
UpdateBitmapForNode(node, warning_icon_name, root->has_lock() && volume_type < ModelVolumeType::PARAMETER_MODIFIER);
|
||||
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
|
||||
if (!warning_icon_name.empty() && warning_icon_name != root->m_warning_icon_name &&
|
||||
(root->m_warning_icon_name.empty() || root->m_warning_icon_name == WarningManifoldIcon) )
|
||||
root->SetWarningBitmap(GetWarningBitmap(warning_icon_name), warning_icon_name);
|
||||
if (!warning_icon_name.empty() && warning_icon_name != root->warning_icon_name() &&
|
||||
(!root->has_warning_icon() || root->warning_icon_name() == WarningManifoldIcon)) {
|
||||
root->SetWarningIconName(warning_icon_name);
|
||||
UpdateBitmapForNode(root);
|
||||
}
|
||||
|
||||
// notify control
|
||||
const wxDataViewItem child((void*)node);
|
||||
@ -1682,6 +1714,7 @@ void ObjectDataViewModel::Rescale()
|
||||
m_volume_bmps = MenuFactory::get_volume_bitmaps();
|
||||
m_warning_bmp = create_scaled_bitmap(WarningIcon);
|
||||
m_warning_manifold_bmp = create_scaled_bitmap(WarningManifoldIcon);
|
||||
m_lock_bmp = create_scaled_bitmap(LockIcon);
|
||||
|
||||
for (auto item : INFO_ITEMS)
|
||||
m_info_bmps[item.first] = create_scaled_bitmap(item.second.bmp_name);
|
||||
@ -1700,10 +1733,8 @@ void ObjectDataViewModel::Rescale()
|
||||
switch (node->m_type)
|
||||
{
|
||||
case itObject:
|
||||
if (node->m_bmp.IsOk()) node->m_bmp = GetWarningBitmap(node->m_warning_icon_name);
|
||||
break;
|
||||
case itVolume:
|
||||
node->m_bmp = GetVolumeIcon(node->m_volume_type, node->m_warning_icon_name);
|
||||
UpdateBitmapForNode(node);
|
||||
break;
|
||||
case itLayerRoot:
|
||||
node->m_bmp = create_scaled_bitmap(LayerRootIcon);
|
||||
@ -1719,27 +1750,6 @@ void ObjectDataViewModel::Rescale()
|
||||
}
|
||||
}
|
||||
|
||||
wxBitmap ObjectDataViewModel::GetVolumeIcon(const Slic3r::ModelVolumeType vol_type, const std::string& warning_icon_name/* = std::string()*/)
|
||||
{
|
||||
if (warning_icon_name.empty())
|
||||
return m_volume_bmps[static_cast<int>(vol_type)];
|
||||
|
||||
std::string scaled_bitmap_name = warning_icon_name + std::to_string(static_cast<int>(vol_type));
|
||||
scaled_bitmap_name += "-em" + std::to_string(wxGetApp().em_unit()) + (wxGetApp().dark_mode() ? "-dm" : "-lm");
|
||||
|
||||
wxBitmap *bmp = m_bitmap_cache->find(scaled_bitmap_name);
|
||||
if (bmp == nullptr) {
|
||||
std::vector<wxBitmap> bmps;
|
||||
|
||||
bmps.emplace_back(GetWarningBitmap(warning_icon_name));
|
||||
bmps.emplace_back(m_volume_bmps[static_cast<int>(vol_type)]);
|
||||
|
||||
bmp = m_bitmap_cache->insert(scaled_bitmap_name, bmps);
|
||||
}
|
||||
|
||||
return *bmp;
|
||||
}
|
||||
|
||||
void ObjectDataViewModel::AddWarningIcon(const wxDataViewItem& item, const std::string& warning_icon_name)
|
||||
{
|
||||
if (!item.IsOk())
|
||||
@ -1747,13 +1757,14 @@ void ObjectDataViewModel::AddWarningIcon(const wxDataViewItem& item, const std::
|
||||
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
||||
|
||||
if (node->GetType() & itObject) {
|
||||
node->SetWarningBitmap(GetWarningBitmap(warning_icon_name), warning_icon_name);
|
||||
UpdateBitmapForNode(node, warning_icon_name, node->has_lock());
|
||||
return;
|
||||
}
|
||||
|
||||
if (node->GetType() & itVolume) {
|
||||
node->SetWarningBitmap(GetVolumeIcon(node->GetVolumeType(), warning_icon_name), warning_icon_name);
|
||||
node->GetParent()->SetWarningBitmap(GetWarningBitmap(warning_icon_name), warning_icon_name);
|
||||
UpdateBitmapForNode(node, warning_icon_name, node->has_lock());
|
||||
if (ObjectDataViewModelNode* parent = node->GetParent())
|
||||
UpdateBitmapForNode(parent, warning_icon_name, parent->has_lock());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1768,12 +1779,9 @@ void ObjectDataViewModel::DeleteWarningIcon(const wxDataViewItem& item, const bo
|
||||
if (!node->GetBitmap().IsOk() || !(node->GetType() & (itVolume | itObject)))
|
||||
return;
|
||||
|
||||
if (node->GetType() & itVolume) {
|
||||
node->SetWarningBitmap(m_volume_bmps[static_cast<int>(node->volume_type())], "");
|
||||
return;
|
||||
}
|
||||
node->SetWarningIconName(std::string());
|
||||
UpdateBitmapForNode(node);
|
||||
|
||||
node->SetWarningBitmap(wxNullBitmap, "");
|
||||
if (unmark_object)
|
||||
{
|
||||
wxDataViewItemArray children;
|
||||
@ -1800,6 +1808,25 @@ void ObjectDataViewModel::UpdateWarningIcon(const wxDataViewItem& item, const st
|
||||
AddWarningIcon(item, warning_icon_name);
|
||||
}
|
||||
|
||||
void ObjectDataViewModel::UpdateLockIcon(const wxDataViewItem& item, bool has_lock)
|
||||
{
|
||||
if (!item.IsOk())
|
||||
return;
|
||||
ObjectDataViewModelNode* node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
||||
if (node->has_lock() == has_lock)
|
||||
return;
|
||||
|
||||
node->SetLock(has_lock);
|
||||
UpdateBitmapForNode(node);
|
||||
|
||||
if (node->GetType() & itObject) {
|
||||
wxDataViewItemArray children;
|
||||
GetChildren(item, children);
|
||||
for (const wxDataViewItem& child : children)
|
||||
UpdateLockIcon(child, has_lock);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
|
@ -80,6 +80,7 @@ class ObjectDataViewModelNode
|
||||
PrintIndicator m_printable {piUndef};
|
||||
wxBitmap m_printable_icon;
|
||||
std::string m_warning_icon_name{ "" };
|
||||
bool m_has_lock{false};
|
||||
|
||||
std::string m_action_icon_name = "";
|
||||
ModelVolumeType m_volume_type;
|
||||
@ -100,10 +101,8 @@ public:
|
||||
ObjectDataViewModelNode(ObjectDataViewModelNode* parent,
|
||||
const wxString& sub_obj_name,
|
||||
Slic3r::ModelVolumeType type,
|
||||
const wxBitmap& bmp,
|
||||
const wxString& extruder,
|
||||
const int idx = -1,
|
||||
const std::string& warning_icon_name = std::string());
|
||||
const int idx = -1 );
|
||||
|
||||
ObjectDataViewModelNode(ObjectDataViewModelNode* parent,
|
||||
const t_layer_height_range& layer_range,
|
||||
@ -179,10 +178,11 @@ public:
|
||||
}
|
||||
|
||||
bool SetValue(const wxVariant &variant, unsigned int col);
|
||||
void SetVolumeType(ModelVolumeType type) { m_volume_type = type; }
|
||||
void SetBitmap(const wxBitmap &icon) { m_bmp = icon; }
|
||||
void SetExtruder(const wxString &extruder) { m_extruder = extruder; }
|
||||
void SetWarningBitmap(const wxBitmap& icon, const std::string& warning_icon_name) { m_bmp = icon; m_warning_icon_name = warning_icon_name; }
|
||||
void SetVolumeType(ModelVolumeType type) { m_volume_type = type; }
|
||||
void SetBitmap(const wxBitmap &icon) { m_bmp = icon; }
|
||||
void SetExtruder(const wxString &extruder) { m_extruder = extruder; }
|
||||
void SetWarningIconName(const std::string& warning_icon_name) { m_warning_icon_name = warning_icon_name; }
|
||||
void SetLock(bool has_lock) { m_has_lock = has_lock; }
|
||||
const wxBitmap& GetBitmap() const { return m_bmp; }
|
||||
const wxString& GetName() const { return m_name; }
|
||||
ItemType GetType() const { return m_type; }
|
||||
@ -229,8 +229,6 @@ public:
|
||||
void set_extruder_icon();
|
||||
// Set printable icon for node
|
||||
void set_printable_icon(PrintIndicator printable);
|
||||
// Set warning icon for node
|
||||
void set_warning_icon(const std::string& warning_icon);
|
||||
|
||||
void update_settings_digest_bitmaps();
|
||||
bool update_settings_digest(const std::vector<std::string>& categories);
|
||||
@ -241,7 +239,9 @@ public:
|
||||
bool valid();
|
||||
#endif /* NDEBUG */
|
||||
bool invalid() const { return m_idx < -1; }
|
||||
bool has_warning_icon() const { return !m_warning_icon_name.empty(); }
|
||||
bool has_warning_icon() const { return !m_warning_icon_name.empty(); }
|
||||
bool has_lock() const { return m_has_lock; }
|
||||
const std::string& warning_icon_name() const { return m_warning_icon_name; }
|
||||
|
||||
private:
|
||||
friend class ObjectDataViewModel;
|
||||
@ -263,6 +263,7 @@ class ObjectDataViewModel :public wxDataViewModel
|
||||
wxBitmap m_empty_bmp;
|
||||
wxBitmap m_warning_bmp;
|
||||
wxBitmap m_warning_manifold_bmp;
|
||||
wxBitmap m_lock_bmp;
|
||||
|
||||
wxDataViewCtrl* m_ctrl { nullptr };
|
||||
|
||||
@ -272,7 +273,8 @@ public:
|
||||
|
||||
wxDataViewItem Add( const wxString &name,
|
||||
const int extruder,
|
||||
const std::string& warning_icon_name = std::string());
|
||||
const std::string& warning_icon_name,
|
||||
const bool has_lock);
|
||||
wxDataViewItem AddVolumeChild( const wxDataViewItem &parent_item,
|
||||
const wxString &name,
|
||||
const Slic3r::ModelVolumeType volume_type,
|
||||
@ -386,11 +388,10 @@ public:
|
||||
// Rescale bitmaps for existing Items
|
||||
void Rescale();
|
||||
|
||||
wxBitmap GetVolumeIcon(const Slic3r::ModelVolumeType vol_type,
|
||||
const std::string& warning_icon_name = std::string());
|
||||
void AddWarningIcon(const wxDataViewItem& item, const std::string& warning_name);
|
||||
void DeleteWarningIcon(const wxDataViewItem& item, const bool unmark_object = false);
|
||||
void UpdateWarningIcon(const wxDataViewItem& item, const std::string& warning_name);
|
||||
void UpdateLockIcon(const wxDataViewItem& item, bool has_lock);
|
||||
bool HasWarningIcon(const wxDataViewItem& item) const;
|
||||
t_layer_height_range GetLayerRangeByItem(const wxDataViewItem& item) const;
|
||||
|
||||
@ -404,7 +405,8 @@ private:
|
||||
wxDataViewItem AddInstanceRoot(const wxDataViewItem& parent_item);
|
||||
void AddAllChildren(const wxDataViewItem& parent);
|
||||
|
||||
wxBitmap& GetWarningBitmap(const std::string& warning_icon_name);
|
||||
void UpdateBitmapForNode(ObjectDataViewModelNode* node);
|
||||
void UpdateBitmapForNode(ObjectDataViewModelNode* node, const std::string& warning_icon_name, bool has_lock);
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user