Implemented set printable state for ObjectList
This commit is contained in:
parent
885da35544
commit
f712e5fcf4
@ -2273,6 +2273,8 @@ void ObjectList::add_object_to_list(size_t obj_idx, bool call_selection_changed)
|
|||||||
|
|
||||||
select_item(m_objects_model->AddInstanceChild(m_objects_model->GetItemById(obj_idx), print_idicator));
|
select_item(m_objects_model->AddInstanceChild(m_objects_model->GetItemById(obj_idx), print_idicator));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
m_objects_model->SetPrintableState(obj_idx, model_object->instances[0]->is_printable() ? piPrintable : piUnprintable);
|
||||||
|
|
||||||
// add settings to the object, if it has those
|
// add settings to the object, if it has those
|
||||||
add_settings_item(item, &model_object->config);
|
add_settings_item(item, &model_object->config);
|
||||||
@ -3632,6 +3634,25 @@ void ObjectList::update_after_undo_redo()
|
|||||||
m_prevent_canvas_selection_update = false;
|
m_prevent_canvas_selection_update = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObjectList::update_printable_state(int obj_idx, int instance_idx)
|
||||||
|
{
|
||||||
|
ModelObject* object = (*m_objects)[obj_idx];
|
||||||
|
PrintIndicator printable = piUndef;
|
||||||
|
|
||||||
|
if (object->instances.size() == 1)
|
||||||
|
{
|
||||||
|
printable = object->instances[0]->printable ? piPrintable : piUnprintable;
|
||||||
|
instance_idx = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_objects_model->SetPrintableState(obj_idx, piUndef);
|
||||||
|
printable = object->instances[instance_idx]->printable ? piPrintable : piUnprintable;
|
||||||
|
}
|
||||||
|
|
||||||
|
select_item(m_objects_model->SetPrintableState(obj_idx, printable, instance_idx));
|
||||||
|
}
|
||||||
|
|
||||||
ModelObject* ObjectList::object(const int obj_idx) const
|
ModelObject* ObjectList::object(const int obj_idx) const
|
||||||
{
|
{
|
||||||
if (obj_idx < 0)
|
if (obj_idx < 0)
|
||||||
|
@ -349,6 +349,7 @@ public:
|
|||||||
void msw_rescale();
|
void msw_rescale();
|
||||||
|
|
||||||
void update_after_undo_redo();
|
void update_after_undo_redo();
|
||||||
|
void update_printable_state(int obj_idx, int instance_idx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef __WXOSX__
|
#ifdef __WXOSX__
|
||||||
|
@ -1479,6 +1479,8 @@ void Selection::toggle_instance_printable_state()
|
|||||||
if ((volume->object_idx() == obj_idx) && (volume->instance_idx() == instance_idx))
|
if ((volume->object_idx() == obj_idx) && (volume->instance_idx() == instance_idx))
|
||||||
volume->printable = instance->printable;
|
volume->printable = instance->printable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxGetApp().obj_list()->update_printable_state(obj_idx, instance_idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -799,11 +799,27 @@ wxDataViewItem ObjectDataViewModel::AddInstanceChild(const wxDataViewItem& paren
|
|||||||
|
|
||||||
ObjectDataViewModelNode* inst_root_node = (ObjectDataViewModelNode*)inst_root_item.GetID();
|
ObjectDataViewModelNode* inst_root_node = (ObjectDataViewModelNode*)inst_root_item.GetID();
|
||||||
|
|
||||||
|
const bool just_created = inst_root_node->GetChildren().Count() == 0;
|
||||||
|
|
||||||
// Add instance nodes
|
// Add instance nodes
|
||||||
ObjectDataViewModelNode *instance_node = nullptr;
|
ObjectDataViewModelNode *instance_node = nullptr;
|
||||||
size_t counter = 0;
|
size_t counter = 0;
|
||||||
while (counter < print_indicator.size()) {
|
while (counter < print_indicator.size()) {
|
||||||
instance_node = new ObjectDataViewModelNode(inst_root_node, itInstance);
|
instance_node = new ObjectDataViewModelNode(inst_root_node, itInstance);
|
||||||
|
|
||||||
|
// if InstanceRoot item is just created and start to adding Instances
|
||||||
|
if (just_created && counter == 0)
|
||||||
|
{
|
||||||
|
ObjectDataViewModelNode* obj_node = (ObjectDataViewModelNode*)parent_item.GetID();
|
||||||
|
|
||||||
|
// use object's printable state to first instance
|
||||||
|
instance_node->set_printable_icon(obj_node->IsPrintable());
|
||||||
|
|
||||||
|
// and set printable state for object_node to piUndef
|
||||||
|
obj_node->set_printable_icon(piUndef);
|
||||||
|
ItemChanged(parent_item);
|
||||||
|
}
|
||||||
|
else
|
||||||
instance_node->set_printable_icon(print_indicator[counter] ? piPrintable : piUnprintable);
|
instance_node->set_printable_icon(print_indicator[counter] ? piPrintable : piUnprintable);
|
||||||
inst_root_node->Append(instance_node);
|
inst_root_node->Append(instance_node);
|
||||||
// notify control
|
// notify control
|
||||||
@ -915,11 +931,13 @@ wxDataViewItem ObjectDataViewModel::Delete(const wxDataViewItem &item)
|
|||||||
ItemDeleted(parent, item);
|
ItemDeleted(parent, item);
|
||||||
|
|
||||||
ObjectDataViewModelNode *last_instance_node = node_parent->GetNthChild(0);
|
ObjectDataViewModelNode *last_instance_node = node_parent->GetNthChild(0);
|
||||||
|
PrintIndicator last_instance_printable = last_instance_node->IsPrintable();
|
||||||
node_parent->GetChildren().Remove(last_instance_node);
|
node_parent->GetChildren().Remove(last_instance_node);
|
||||||
delete last_instance_node;
|
delete last_instance_node;
|
||||||
ItemDeleted(parent, wxDataViewItem(last_instance_node));
|
ItemDeleted(parent, wxDataViewItem(last_instance_node));
|
||||||
|
|
||||||
ObjectDataViewModelNode *obj_node = node_parent->GetParent();
|
ObjectDataViewModelNode *obj_node = node_parent->GetParent();
|
||||||
|
obj_node->set_printable_icon(last_instance_printable);
|
||||||
obj_node->GetChildren().Remove(node_parent);
|
obj_node->GetChildren().Remove(node_parent);
|
||||||
delete node_parent;
|
delete node_parent;
|
||||||
ret_item = wxDataViewItem(obj_node);
|
ret_item = wxDataViewItem(obj_node);
|
||||||
@ -1041,9 +1059,12 @@ wxDataViewItem ObjectDataViewModel::DeleteLastInstance(const wxDataViewItem &par
|
|||||||
const int inst_cnt = inst_root_node->GetChildCount();
|
const int inst_cnt = inst_root_node->GetChildCount();
|
||||||
const bool delete_inst_root_item = inst_cnt - num < 2 ? true : false;
|
const bool delete_inst_root_item = inst_cnt - num < 2 ? true : false;
|
||||||
|
|
||||||
|
PrintIndicator last_inst_printable = piUndef;
|
||||||
|
|
||||||
int stop = delete_inst_root_item ? 0 : inst_cnt - num;
|
int stop = delete_inst_root_item ? 0 : inst_cnt - num;
|
||||||
for (int i = inst_cnt - 1; i >= stop;--i) {
|
for (int i = inst_cnt - 1; i >= stop;--i) {
|
||||||
ObjectDataViewModelNode *last_instance_node = inst_root_node->GetNthChild(i);
|
ObjectDataViewModelNode *last_instance_node = inst_root_node->GetNthChild(i);
|
||||||
|
if (i==0) last_inst_printable = last_instance_node->IsPrintable();
|
||||||
inst_root_node->GetChildren().Remove(last_instance_node);
|
inst_root_node->GetChildren().Remove(last_instance_node);
|
||||||
delete last_instance_node;
|
delete last_instance_node;
|
||||||
ItemDeleted(inst_root_item, wxDataViewItem(last_instance_node));
|
ItemDeleted(inst_root_item, wxDataViewItem(last_instance_node));
|
||||||
@ -1052,7 +1073,9 @@ wxDataViewItem ObjectDataViewModel::DeleteLastInstance(const wxDataViewItem &par
|
|||||||
if (delete_inst_root_item) {
|
if (delete_inst_root_item) {
|
||||||
ret_item = parent_item;
|
ret_item = parent_item;
|
||||||
parent_node->GetChildren().Remove(inst_root_node);
|
parent_node->GetChildren().Remove(inst_root_node);
|
||||||
|
parent_node->set_printable_icon(last_inst_printable);
|
||||||
ItemDeleted(parent_item, inst_root_item);
|
ItemDeleted(parent_item, inst_root_item);
|
||||||
|
ItemChanged(parent_item);
|
||||||
#ifndef __WXGTK__
|
#ifndef __WXGTK__
|
||||||
if (parent_node->GetChildCount() == 0)
|
if (parent_node->GetChildCount() == 0)
|
||||||
parent_node->m_container = false;
|
parent_node->m_container = false;
|
||||||
@ -1621,6 +1644,27 @@ void ObjectDataViewModel::SetVolumeType(const wxDataViewItem &item, const Slic3r
|
|||||||
ItemChanged(item);
|
ItemChanged(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxDataViewItem ObjectDataViewModel::SetPrintableState(
|
||||||
|
int obj_idx,
|
||||||
|
PrintIndicator printable/* = piUndef*/,
|
||||||
|
int subobj_idx /* = -1*/,
|
||||||
|
ItemType subobj_type/* = itInstance*/)
|
||||||
|
{
|
||||||
|
wxDataViewItem item = wxDataViewItem(0);
|
||||||
|
if (subobj_idx < 0)
|
||||||
|
item = GetItemById(obj_idx);
|
||||||
|
else
|
||||||
|
item = subobj_type&itInstance ? GetItemByInstanceId(obj_idx, subobj_idx) :
|
||||||
|
GetItemByVolumeId(obj_idx, subobj_idx);
|
||||||
|
|
||||||
|
ObjectDataViewModelNode* node = (ObjectDataViewModelNode*)item.GetID();
|
||||||
|
if (!node)
|
||||||
|
return wxDataViewItem(0);
|
||||||
|
node->set_printable_icon(printable);
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
void ObjectDataViewModel::Rescale()
|
void ObjectDataViewModel::Rescale()
|
||||||
{
|
{
|
||||||
wxDataViewItemArray all_items;
|
wxDataViewItemArray all_items;
|
||||||
|
@ -324,6 +324,7 @@ public:
|
|||||||
void SetIdx(const int& idx);
|
void SetIdx(const int& idx);
|
||||||
int GetIdx() const { return m_idx; }
|
int GetIdx() const { return m_idx; }
|
||||||
t_layer_height_range GetLayerRange() const { return m_layer_range; }
|
t_layer_height_range GetLayerRange() const { return m_layer_range; }
|
||||||
|
PrintIndicator IsPrintable() const { return m_printable; }
|
||||||
|
|
||||||
// use this function only for childrens
|
// use this function only for childrens
|
||||||
void AssignAllVal(ObjectDataViewModelNode& from_node)
|
void AssignAllVal(ObjectDataViewModelNode& from_node)
|
||||||
@ -482,6 +483,10 @@ public:
|
|||||||
void SetVolumeBitmaps(const std::vector<wxBitmap*>& volume_bmps) { m_volume_bmps = volume_bmps; }
|
void SetVolumeBitmaps(const std::vector<wxBitmap*>& volume_bmps) { m_volume_bmps = volume_bmps; }
|
||||||
void SetWarningBitmap(wxBitmap* bitmap) { m_warning_bmp = bitmap; }
|
void SetWarningBitmap(wxBitmap* bitmap) { m_warning_bmp = bitmap; }
|
||||||
void SetVolumeType(const wxDataViewItem &item, const Slic3r::ModelVolumeType type);
|
void SetVolumeType(const wxDataViewItem &item, const Slic3r::ModelVolumeType type);
|
||||||
|
wxDataViewItem SetPrintableState( int obj_idx,
|
||||||
|
PrintIndicator printable = piUndef,
|
||||||
|
int subobj_idx = -1,
|
||||||
|
ItemType subobj_type = itInstance);
|
||||||
|
|
||||||
void SetAssociatedControl(wxDataViewCtrl* ctrl) { m_ctrl = ctrl; }
|
void SetAssociatedControl(wxDataViewCtrl* ctrl) { m_ctrl = ctrl; }
|
||||||
// Rescale bitmaps for existing Items
|
// Rescale bitmaps for existing Items
|
||||||
|
Loading…
Reference in New Issue
Block a user