Implemented adding of support enforcer/blocker to the object list
This commit is contained in:
parent
864bc6ad48
commit
a9e7b5c645
BIN
resources/icons/support_blocker_.png
Normal file
BIN
resources/icons/support_blocker_.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
resources/icons/support_enforcer_.png
Normal file
BIN
resources/icons/support_enforcer_.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
@ -213,17 +213,26 @@ void ObjectList::update_extruder_in_config(const wxString& selection)
|
||||
|
||||
void ObjectList::init_icons()
|
||||
{
|
||||
m_bmp_modifiermesh = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("lambda.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("plugin.png")), wxBITMAP_TYPE_PNG);
|
||||
m_bmp_solidmesh = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("object.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("package.png")), wxBITMAP_TYPE_PNG);
|
||||
m_bmp_modifiermesh = wxBitmap(from_u8(var("lambda.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("plugin.png")), wxBITMAP_TYPE_PNG);
|
||||
m_bmp_solidmesh = wxBitmap(from_u8(var("object.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("package.png")), wxBITMAP_TYPE_PNG);
|
||||
|
||||
m_bmp_support_enforcer = wxBitmap(from_u8(var("support_enforcer_.png")), wxBITMAP_TYPE_PNG);
|
||||
m_bmp_support_blocker = wxBitmap(from_u8(var("support_blocker_.png")), wxBITMAP_TYPE_PNG);
|
||||
|
||||
m_bmp_vector.reserve(4); // bitmaps for different types of parts
|
||||
m_bmp_vector.push_back(&m_bmp_solidmesh); // Add part
|
||||
m_bmp_vector.push_back(&m_bmp_modifiermesh); // Add modifier
|
||||
m_bmp_vector.push_back(&m_bmp_support_enforcer); // Add support enforcer
|
||||
m_bmp_vector.push_back(&m_bmp_support_blocker); // Add support blocker
|
||||
|
||||
// init icon for manifold warning
|
||||
m_bmp_manifold_warning = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("exclamation_mark_.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("error.png")), wxBITMAP_TYPE_PNG);
|
||||
m_bmp_manifold_warning = wxBitmap(from_u8(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);
|
||||
m_bmp_split = wxBitmap(from_u8(var("split.png")), wxBITMAP_TYPE_PNG);
|
||||
|
||||
// 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(from_u8(var("cog.png")), wxBITMAP_TYPE_PNG);
|
||||
}
|
||||
|
||||
|
||||
@ -552,47 +561,60 @@ wxMenuItem* ObjectList::menu_item_settings(wxMenu* menu, int id, const bool is_p
|
||||
wxMenu* ObjectList::create_add_part_popupmenu()
|
||||
{
|
||||
wxMenu *menu = new wxMenu;
|
||||
std::vector<std::string> menu_items = { L("Add part"), L("Add modifier"), L("Add generic") };
|
||||
std::vector<std::string> menu_object_types_items = {L("Add part"),
|
||||
L("Add modifier"),
|
||||
L("Add support enforcer"),
|
||||
L("Add support bloker"),
|
||||
L("Add generic") };
|
||||
const int obj_types_count = menu_object_types_items.size();
|
||||
const int generics_count = 4;
|
||||
|
||||
wxWindowID config_id_base = wxWindow::NewControlId(menu_items.size() + 4 + 2);
|
||||
wxWindowID config_id_base = wxWindow::NewControlId(menu_object_types_items.size() + 4 + 2);
|
||||
|
||||
// Add first 4 menu items
|
||||
int i = 0;
|
||||
for (auto& item : menu_items) {
|
||||
for (i = 0; i < obj_types_count - 1; i++) {
|
||||
auto& item = menu_object_types_items[i];
|
||||
auto menu_item = new wxMenuItem(menu, config_id_base + i, _(item));
|
||||
menu_item->SetBitmap(i == 0 ? m_bmp_solidmesh : m_bmp_modifiermesh);
|
||||
if (item == "Add generic")
|
||||
menu_item_add_generic(menu_item, config_id_base + i);
|
||||
menu_item->SetBitmap(*m_bmp_vector[i]);
|
||||
menu->Append(menu_item);
|
||||
i++;
|
||||
}
|
||||
// Add generic modifier
|
||||
auto& item = menu_object_types_items[i];
|
||||
auto menu_item = new wxMenuItem(menu, config_id_base + i, _(item));
|
||||
menu_item->SetBitmap(*m_bmp_vector[1]); // set modifier's icon
|
||||
menu_item_add_generic(menu_item, config_id_base + i);
|
||||
menu->Append(menu_item);
|
||||
|
||||
// Split object to parts
|
||||
menu->AppendSeparator();
|
||||
auto menu_item = menu_item_split(menu, config_id_base + i + 4);
|
||||
menu_item = menu_item_split(menu, config_id_base + obj_types_count + generics_count);
|
||||
menu->Append(menu_item);
|
||||
menu_item->Enable(is_splittable_object(false));
|
||||
|
||||
// Settings
|
||||
menu->AppendSeparator();
|
||||
// Append settings popupmenu
|
||||
menu->Append(menu_item_settings(menu, config_id_base + i + 5, false));
|
||||
menu->Append(menu_item_settings(menu, config_id_base + obj_types_count + generics_count+1, false));
|
||||
|
||||
menu->Bind(wxEVT_MENU, [config_id_base, menu, this](wxEvent &event) {
|
||||
switch (event.GetId() - config_id_base) {
|
||||
case 0:
|
||||
load_subobject();
|
||||
case 0: // ~ModelVolume::MODEL_PART
|
||||
case 1: // ~ModelVolume::PARAMETER_MODIFIER
|
||||
case 2: // ~ModelVolume::SUPPORT_ENFORCER
|
||||
case 3: // ~ModelVolume::SUPPORT_BLOCKER
|
||||
load_subobject(event.GetId() - config_id_base);
|
||||
break;
|
||||
case 1:
|
||||
load_subobject(true);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
#ifdef __WXMSW__
|
||||
load_lambda(menu->GetLabel(event.GetId()).ToStdString());
|
||||
#endif // __WXMSW__
|
||||
break;
|
||||
case 7: //3:
|
||||
case 9:
|
||||
split(false);
|
||||
break;
|
||||
default:
|
||||
@ -655,31 +677,21 @@ wxMenu* ObjectList::create_add_settings_popupmenu(bool is_part)
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
||||
// Load SubObjects (parts and modifiers)
|
||||
void ObjectList::load_subobject(bool is_modifier /*= false*/, bool is_lambda/* = false*/)
|
||||
void ObjectList::load_subobject(int type)
|
||||
{
|
||||
auto item = GetSelection();
|
||||
if (!item)
|
||||
return;
|
||||
int obj_idx = -1;
|
||||
if (m_objects_model->GetParent(item) == wxDataViewItem(0))
|
||||
obj_idx = m_objects_model->GetIdByItem(item);
|
||||
else
|
||||
if (!item || m_objects_model->GetParent(item) != wxDataViewItem(0))
|
||||
return;
|
||||
int obj_idx = m_objects_model->GetIdByItem(item);
|
||||
|
||||
if (obj_idx < 0) return;
|
||||
wxArrayString part_names;
|
||||
if (is_lambda)
|
||||
load_lambda((*m_objects)[obj_idx], part_names, is_modifier);
|
||||
else
|
||||
load_part((*m_objects)[obj_idx], part_names, is_modifier);
|
||||
load_part((*m_objects)[obj_idx], part_names, type);
|
||||
|
||||
parts_changed(obj_idx);
|
||||
|
||||
for (int i = 0; i < part_names.size(); ++i) {
|
||||
const wxDataViewItem sel_item = m_objects_model->AddVolumeChild(item, part_names.Item(i),
|
||||
is_modifier ? m_bmp_modifiermesh : m_bmp_solidmesh);
|
||||
const wxDataViewItem sel_item = m_objects_model->AddVolumeChild(item, part_names.Item(i), *m_bmp_vector[type]);
|
||||
|
||||
if (i == part_names.size() - 1)
|
||||
select_item(sel_item);
|
||||
@ -688,11 +700,12 @@ void ObjectList::load_subobject(bool is_modifier /*= false*/, bool is_lambda/* =
|
||||
#ifndef __WXOSX__ //#ifdef __WXMSW__ // #ys_FIXME
|
||||
// selection_changed();
|
||||
#endif //no __WXOSX__//__WXMSW__
|
||||
|
||||
}
|
||||
|
||||
void ObjectList::load_part( ModelObject* model_object,
|
||||
wxArrayString& part_names,
|
||||
const bool is_modifier)
|
||||
int type)
|
||||
{
|
||||
wxWindow* parent = wxGetApp().tab_panel()->GetPage(0);
|
||||
|
||||
@ -722,7 +735,7 @@ void ObjectList::load_part( ModelObject* model_object,
|
||||
}
|
||||
for (auto volume : object->volumes) {
|
||||
auto new_volume = model_object->add_volume(*volume);
|
||||
new_volume->set_type(is_modifier ? ModelVolume::PARAMETER_MODIFIER : ModelVolume::MODEL_PART);
|
||||
new_volume->set_type(static_cast<ModelVolume::Type>(type));
|
||||
boost::filesystem::path(input_file).filename().string();
|
||||
new_volume->name = boost::filesystem::path(input_file).filename().string();
|
||||
|
||||
@ -738,58 +751,7 @@ void ObjectList::load_part( ModelObject* model_object,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectList::load_lambda( ModelObject* model_object,
|
||||
wxArrayString& part_names,
|
||||
const bool is_modifier)
|
||||
{
|
||||
auto dlg = new LambdaObjectDialog(GetMainWindow());
|
||||
if (dlg->ShowModal() == wxID_CANCEL) {
|
||||
m_parts_changed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
std::string name = "lambda-";
|
||||
TriangleMesh mesh;
|
||||
|
||||
auto params = dlg->ObjectParameters();
|
||||
switch (params.type)
|
||||
{
|
||||
case LambdaTypeBox:{
|
||||
mesh = make_cube(params.dim[0], params.dim[1], params.dim[2]);
|
||||
name += "Box";
|
||||
break; }
|
||||
case LambdaTypeCylinder:{
|
||||
mesh = make_cylinder(params.cyl_r, params.cyl_h);
|
||||
name += "Cylinder";
|
||||
break; }
|
||||
case LambdaTypeSphere:{
|
||||
mesh = make_sphere(params.sph_rho);
|
||||
name += "Sphere";
|
||||
break; }
|
||||
case LambdaTypeSlab:{
|
||||
const auto& size = model_object->bounding_box().size();
|
||||
mesh = make_cube(size(0)*1.5, size(1)*1.5, params.slab_h);
|
||||
// box sets the base coordinate at 0, 0, move to center of plate and move it up to initial_z
|
||||
mesh.translate(-size(0)*1.5 / 2.0, -size(1)*1.5 / 2.0, params.slab_z);
|
||||
name += "Slab";
|
||||
break; }
|
||||
default:
|
||||
break;
|
||||
}
|
||||
mesh.repair();
|
||||
|
||||
auto new_volume = model_object->add_volume(mesh);
|
||||
new_volume->set_type(is_modifier ? ModelVolume::PARAMETER_MODIFIER : ModelVolume::MODEL_PART);
|
||||
|
||||
new_volume->name = name;
|
||||
// set a default extruder value, since user can't add it manually
|
||||
new_volume->config.set_key_value("extruder", new ConfigOptionInt(0));
|
||||
|
||||
part_names.Add(name);
|
||||
|
||||
m_parts_changed = true;
|
||||
}
|
||||
|
||||
void ObjectList::load_lambda(const std::string& type_name)
|
||||
|
@ -28,10 +28,14 @@ class ObjectList : public wxDataViewCtrl
|
||||
|
||||
wxBitmap m_bmp_modifiermesh;
|
||||
wxBitmap m_bmp_solidmesh;
|
||||
wxBitmap m_bmp_support_enforcer;
|
||||
wxBitmap m_bmp_support_blocker;
|
||||
wxBitmap m_bmp_manifold_warning;
|
||||
wxBitmap m_bmp_cog;
|
||||
wxBitmap m_bmp_split;
|
||||
|
||||
std::vector<wxBitmap*> m_bmp_vector;
|
||||
|
||||
int m_selected_object_id = -1;
|
||||
bool m_prevent_list_events = false; // We use this flag to avoid circular event handling Select()
|
||||
// happens to fire a wxEVT_LIST_ITEM_SELECTED on OSX, whose event handler
|
||||
@ -85,9 +89,8 @@ public:
|
||||
wxMenu* create_part_settings_popupmenu();
|
||||
wxMenu* create_add_settings_popupmenu(bool is_part);
|
||||
|
||||
void load_subobject(bool is_modifier = false, bool is_lambda = false);
|
||||
void load_part(ModelObject* model_object, wxArrayString& part_names, const bool is_modifier);
|
||||
void load_lambda(ModelObject* model_object, wxArrayString& part_names, const bool is_modifier);
|
||||
void load_subobject(int type);
|
||||
void load_part(ModelObject* model_object, wxArrayString& part_names, int type);
|
||||
void load_lambda(const std::string& type_name);
|
||||
void del_subobject_item(wxDataViewItem& item);
|
||||
void del_settings_from_config();
|
||||
|
Loading…
Reference in New Issue
Block a user