Added split-function for the object in list.

Updated adding of amf-objects.
This commit is contained in:
YuSanka 2018-07-30 17:03:14 +02:00
parent 2142070331
commit 814d255c77
3 changed files with 35 additions and 15 deletions

View file

@ -28,6 +28,7 @@ wxIcon m_icon_modifiermesh;
wxIcon m_icon_solidmesh; wxIcon m_icon_solidmesh;
wxIcon m_icon_manifold_warning; wxIcon m_icon_manifold_warning;
wxBitmap m_bmp_cog; wxBitmap m_bmp_cog;
wxBitmap m_bmp_split;
wxSlider* m_mover_x = nullptr; wxSlider* m_mover_x = nullptr;
wxSlider* m_mover_y = nullptr; wxSlider* m_mover_y = nullptr;
@ -140,6 +141,9 @@ void init_mesh_icons(){
// init icon for manifold warning // init icon for manifold warning
m_icon_manifold_warning = wxIcon(Slic3r::GUI::from_u8(Slic3r::var("exclamation_mark_.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("error.png")), wxBITMAP_TYPE_PNG); m_icon_manifold_warning = wxIcon(Slic3r::GUI::from_u8(Slic3r::var("exclamation_mark_.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("error.png")), wxBITMAP_TYPE_PNG);
// init bitmap for "Split to sub-objects" context menu
m_bmp_split = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("split.png")), wxBITMAP_TYPE_PNG);
// init bitmap for "Add Settings" context menu // init bitmap for "Add Settings" context menu
m_bmp_cog = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("cog.png")), wxBITMAP_TYPE_PNG); m_bmp_cog = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("cog.png")), wxBITMAP_TYPE_PNG);
} }
@ -600,6 +604,10 @@ void add_object_to_list(const std::string &name, ModelObject* model_object)
m_objects_model->SetValue(variant, item, 0); m_objects_model->SetValue(variant, item, 0);
} }
if (model_object->volumes.size() > 1)
for (auto id = 0; id < model_object->volumes.size(); id++)
m_objects_model->AddChild(item, model_object->volumes[id]->name, m_icon_solidmesh, false);
ModelObjectPtrs* objects = m_objects; ModelObjectPtrs* objects = m_objects;
// part_selection_changed(); // part_selection_changed();
#ifdef __WXMSW__ #ifdef __WXMSW__
@ -836,16 +844,22 @@ void get_settings_choice(wxMenu *menu, int id, bool is_part)
wxMenu *create_add_part_popupmenu() wxMenu *create_add_part_popupmenu()
{ {
wxMenu *menu = new wxMenu; wxMenu *menu = new wxMenu;
wxWindowID config_id_base = wxWindow::NewControlId(4);
std::vector<std::string> menu_items = { L("Add part"), L("Add modifier"), L("Add generic") }; std::vector<std::string> menu_items = { L("Add part"), L("Add modifier"), L("Add generic") };
wxWindowID config_id_base = wxWindow::NewControlId(menu_items.size()+2);
int i = 0; int i = 0;
for (auto& item : menu_items) { for (auto& item : menu_items) {
auto menu_item = new wxMenuItem(menu, config_id_base + i, _(item)); auto menu_item = new wxMenuItem(menu, config_id_base + i, _(item));
menu_item->SetBitmap(i == 0 ? m_icon_solidmesh : m_icon_modifiermesh); menu_item->SetBitmap(i == 0 ? m_icon_solidmesh : m_icon_modifiermesh);
menu->Append(menu_item); menu->Append(menu_item);
i++; i++;
} }
menu->AppendSeparator();
auto menu_item = new wxMenuItem(menu, config_id_base + 3, _(L("Split to sub-objects")));
menu_item->SetBitmap(m_bmp_split);
menu->Append(menu_item);
wxWindow* win = get_tab_panel()->GetPage(0); wxWindow* win = get_tab_panel()->GetPage(0);
@ -860,6 +874,9 @@ wxMenu *create_add_part_popupmenu()
case 2: case 2:
on_btn_load(win, true, true); on_btn_load(win, true, true);
break; break;
case 3:
on_btn_split();
break;
default:{ default:{
get_settings_choice(menu, event.GetId(), false); get_settings_choice(menu, event.GetId(), false);
break;} break;}
@ -868,7 +885,7 @@ wxMenu *create_add_part_popupmenu()
menu->AppendSeparator(); menu->AppendSeparator();
// Append settings popupmenu // Append settings popupmenu
auto menu_item = new wxMenuItem(menu, config_id_base + 3, _(L("Add settings"))); menu_item = new wxMenuItem(menu, config_id_base + 4, _(L("Add settings")));
menu_item->SetBitmap(m_bmp_cog); menu_item->SetBitmap(m_bmp_cog);
auto sub_menu = create_add_settings_popupmenu(false); auto sub_menu = create_add_settings_popupmenu(false);
@ -1087,16 +1104,17 @@ void on_btn_split()
if (!item) if (!item)
return; return;
auto volume_id = m_objects_model->GetVolumeIdByItem(item); auto volume_id = m_objects_model->GetVolumeIdByItem(item);
ModelVolume* volume;
if (volume_id < 0) if (volume_id < 0)
return; volume = (*m_objects)[m_selected_object_id]->volumes[0];//return;
else
auto volume = (*m_objects)[m_selected_object_id]->volumes[volume_id]; volume = (*m_objects)[m_selected_object_id]->volumes[volume_id];
DynamicPrintConfig& config = get_preset_bundle()->prints.get_edited_preset().config; DynamicPrintConfig& config = get_preset_bundle()->printers.get_edited_preset().config;
auto nozzle_dmrs_cnt = config.option<ConfigOptionFloats>("nozzle_diameter")->values.size(); auto nozzle_dmrs_cnt = config.option<ConfigOptionFloats>("nozzle_diameter")->values.size();
if (volume->split(nozzle_dmrs_cnt) > 1) { if (volume->split(nozzle_dmrs_cnt) > 1) {
// TODO update model auto model_object = (*m_objects)[m_selected_object_id];
m_parts_changed = true; for (auto id = 0; id < model_object->volumes.size(); id++)
parts_changed(m_selected_object_id); m_objects_model->AddChild(item, model_object->volumes[id]->name, m_icon_solidmesh, false);
} }
} }

View file

@ -384,12 +384,13 @@ wxDataViewItem PrusaObjectDataViewModel::Add(wxString &name, int instances_count
wxDataViewItem PrusaObjectDataViewModel::AddChild( const wxDataViewItem &parent_item, wxDataViewItem PrusaObjectDataViewModel::AddChild( const wxDataViewItem &parent_item,
const wxString &name, const wxString &name,
const wxIcon& icon) const wxIcon& icon,
bool create_frst_child/* = true*/)
{ {
PrusaObjectDataViewModelNode *root = (PrusaObjectDataViewModelNode*)parent_item.GetID(); PrusaObjectDataViewModelNode *root = (PrusaObjectDataViewModelNode*)parent_item.GetID();
if (!root) return wxDataViewItem(0); if (!root) return wxDataViewItem(0);
if (root->GetChildren().Count() == 0) if (root->GetChildren().Count() == 0 && create_frst_child)
{ {
auto icon_solid_mesh = wxIcon(Slic3r::GUI::from_u8(Slic3r::var("object.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("package.png")), wxBITMAP_TYPE_PNG); auto icon_solid_mesh = wxIcon(Slic3r::GUI::from_u8(Slic3r::var("object.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("package.png")), wxBITMAP_TYPE_PNG);
auto node = new PrusaObjectDataViewModelNode(root, root->m_name, icon_solid_mesh, 0); auto node = new PrusaObjectDataViewModelNode(root, root->m_name, icon_solid_mesh, 0);

View file

@ -350,7 +350,8 @@ public:
wxDataViewItem Add(wxString &name, int instances_count, int scale); wxDataViewItem Add(wxString &name, int instances_count, int scale);
wxDataViewItem AddChild(const wxDataViewItem &parent_item, wxDataViewItem AddChild(const wxDataViewItem &parent_item,
const wxString &name, const wxString &name,
const wxIcon& icon); const wxIcon& icon,
bool create_frst_child = true);
wxDataViewItem Delete(const wxDataViewItem &item); wxDataViewItem Delete(const wxDataViewItem &item);
void DeleteAll(); void DeleteAll();
wxDataViewItem GetItemById(int obj_idx); wxDataViewItem GetItemById(int obj_idx);