Merge branch 'fs_emboss' of https://github.com/prusa3d/PrusaSlicer into fs_emboss

This commit is contained in:
Filip Sykala 2021-10-21 19:42:22 +02:00
commit 1ef444ba63
5 changed files with 32 additions and 21 deletions

View file

@ -1014,10 +1014,6 @@ void MenuFactory::append_immutable_part_menu_items(wxMenu* menu)
{
append_menu_items_mirror(menu);
append_menu_item(menu, wxID_ANY, _L("Split"), _L("Split the selected object into individual parts"),
[](wxCommandEvent&) { plater()->split_volume(); }, "split_parts_SMALL", nullptr,
[]() { return plater()->can_split(false); }, m_parent);
menu->AppendSeparator();
append_menu_item_change_type(menu);
}
@ -1041,19 +1037,19 @@ void MenuFactory::create_part_menu()
append_menu_item_fix_through_netfabb(menu);
append_menu_item_simplify(menu);
append_menu_item(menu, wxID_ANY, _L("Split"), _L("Split the selected object into individual parts"),
[](wxCommandEvent&) { plater()->split_volume(); }, "split_parts_SMALL", nullptr,
[]() { return plater()->can_split(false); }, m_parent);
append_immutable_part_menu_items(menu);
}
void MenuFactory::create_text_part_menu()
{
wxMenu* menu = &m_text_part_menu;
#ifdef __WXOSX__
append_menu_items_osx(menu);
#endif // __WXOSX__
append_menu_item_edit_text(menu);
menu->AppendSeparator();
append_menu_item_delete(menu);
// menu->AppendSeparator();
append_menu_item_edit_text(menu);
append_immutable_part_menu_items(menu);
}

View file

@ -1,5 +1,6 @@
#include "libslic3r/libslic3r.h"
#include "libslic3r/PresetBundle.hpp"
#include "libslic3r/TextConfiguration.hpp"
#include "GUI_ObjectList.hpp"
#include "GUI_Factories.hpp"
#include "GUI_ObjectManipulation.hpp"
@ -631,14 +632,22 @@ void ObjectList::update_name_in_model(const wxDataViewItem& item) const
ModelObject* obj = object(obj_idx);
if (m_objects_model->GetItemType(item) & itObject) {
obj->name = m_objects_model->GetName(item).ToUTF8().data();
obj->name = into_u8(m_objects_model->GetName(item));
// if object has just one volume, rename this volume too
if (obj->volumes.size() == 1)
if (obj->volumes.size() == 1 && !obj->volumes[0]->text_configuration.has_value())
obj->volumes[0]->name = obj->name;
return;
}
if (volume_id < 0) return;
if (volume_id < 0)
return;
// Renaming of the text volume is suppressed
// So, revert the name in object list
if (obj->volumes[volume_id]->text_configuration.has_value()) {
m_objects_model->SetName(from_u8(obj->volumes[volume_id]->name), item);
return;
}
obj->volumes[volume_id]->name = m_objects_model->GetName(item).ToUTF8().data();
}
@ -1741,7 +1750,7 @@ void ObjectList::load_shape_object_from_gallery(const wxArrayString& input_files
wxGetApp().mainframe->update_title();
}
void ObjectList::load_mesh_object(const TriangleMesh &mesh, const wxString &name, bool center)
void ObjectList::load_mesh_object(const TriangleMesh &mesh, const wxString &name, bool center, TextConfiguration* text_config/* = nullptr*/)
{
// Add mesh to model as a new object
Model& model = wxGetApp().plater()->model();
@ -1759,6 +1768,8 @@ void ObjectList::load_mesh_object(const TriangleMesh &mesh, const wxString &name
ModelVolume* new_volume = new_object->add_volume(mesh);
new_object->sort_volumes(wxGetApp().app_config->get("order_volumes") == "1");
new_volume->name = into_u8(name);
if (text_config)
new_volume->text_configuration = *text_config;
// set a default extruder value, since user can't add it manually
new_volume->config.set_key_value("extruder", new ConfigOptionInt(0));
new_object->invalidate_bounding_box();
@ -2680,7 +2691,8 @@ void ObjectList::add_object_to_list(size_t obj_idx, bool call_selection_changed)
update_info_items(obj_idx, nullptr, call_selection_changed);
// add volumes to the object
if (model_object->volumes.size() > 1) {
if (model_object->volumes.size() > 1 ||
model_object->volumes[0]->text_configuration.has_value()) {
for (const ModelVolume* volume : model_object->volumes) {
const wxDataViewItem& vol_item = m_objects_model->AddVolumeChild(item,
from_u8(volume->name),

View file

@ -27,6 +27,7 @@ class ModelConfig;
class ModelObject;
class ModelVolume;
class TriangleMesh;
struct TextConfiguration;
enum class ModelVolumeType : int;
// FIXME: broken build on mac os because of this is missing:
@ -256,7 +257,7 @@ public:
void load_shape_object(const std::string &type_name);
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 load_mesh_object(const TriangleMesh &mesh, const wxString &name, bool center = true, TextConfiguration* text_config = nullptr);
void del_object(const int obj_idx);
void del_subobject_item(wxDataViewItem& item);
void del_settings_from_config(const wxDataViewItem& parent_item);

View file

@ -409,12 +409,10 @@ bool GLGizmoEmboss::add_volume(const std::string &name, indexed_triangle_set &it
// decide to add as volume or new object
const Selection &selection = m_parent.get_selection();
if (selection.is_empty() || selection.get_object_idx() < 0) {
TextConfiguration text_configuration = create_configuration();
// create new object
app.obj_list()->load_mesh_object(tm, name);
app.obj_list()->load_mesh_object(tm, name, true, &text_configuration);
app.mainframe->update_title();
// get new created volume
m_volume = app.obj_list()->objects()->back()->volumes.front();
m_volume->text_configuration = create_configuration();
// load mesh cause close gizmo, soo I open it again
m_parent.get_gizmos_manager().open_gizmo(GLGizmosManager::EType::Emboss);

View file

@ -751,8 +751,12 @@ wxDataViewItem ObjectDataViewModel::Delete(const wxDataViewItem &item)
// get index of the last VolumeItem in CildrenList
size_t vol_idx = GetItemIndexForFirstVolume(node_parent);
// delete this last volume
ObjectDataViewModelNode *last_child_node = node_parent->GetNthChild(vol_idx);
// if last volume is text then don't delete it
if (last_child_node->is_text_volume())
return parent;
// delete this last volume
DeleteSettings(wxDataViewItem(last_child_node));
node_parent->GetChildren().Remove(last_child_node);
node_parent->m_volumes_cnt = 0;