NEW:Enhanced disk name function

Right click to modify the disk name, which is also displayed in the left UI bar
# Conflicts:
#	src/slic3r/GUI/GUI_Factories.cpp
#	src/slic3r/GUI/GUI_Factories.hpp

Change-Id: Ib688bef58d75fba1e5df4f201bfdcef7a3872308
(cherry picked from commit 019681ce69e115e8e4602a93dcb3dc61f20ecba5)
This commit is contained in:
zhou.xu 2023-05-06 14:22:28 +08:00 committed by Lane.Wei
parent edba4d18a6
commit fdd7d11b14
10 changed files with 112 additions and 13 deletions

View file

@ -1085,8 +1085,15 @@ void GLCanvas3D::load_arrange_settings()
m_arrange_settings_fff_seq_print.is_seq_print = true; m_arrange_settings_fff_seq_print.is_seq_print = true;
} }
PrinterTechnology GLCanvas3D::current_printer_technology() const int GLCanvas3D::GetHoverId()
{ {
if (m_hover_plate_idxs.size() == 0) {
return -1; }
return m_hover_plate_idxs.front();
}
PrinterTechnology GLCanvas3D::current_printer_technology() const {
return m_process->current_printer_technology(); return m_process->current_printer_technology();
} }

View file

@ -495,6 +495,8 @@ public:
CanvasAssembleView = 2, CanvasAssembleView = 2,
}; };
int GetHoverId();
private: private:
bool m_is_dark = false; bool m_is_dark = false;
wxGLCanvas* m_canvas; wxGLCanvas* m_canvas;

View file

@ -1381,6 +1381,7 @@ wxMenu* MenuFactory::assemble_multi_selection_menu()
wxMenu* MenuFactory::plate_menu() wxMenu* MenuFactory::plate_menu()
{ {
append_menu_item_locked(&m_plate_menu); append_menu_item_locked(&m_plate_menu);
append_menu_item_plate_name(&m_plate_menu);
return &m_plate_menu; return &m_plate_menu;
} }
@ -1627,6 +1628,40 @@ void MenuFactory::append_menu_item_fill_bed(wxMenu *menu)
menu, wxID_ANY, _L("Fill bed with copies") + dots, _L("Fill the remaining area of bed with copies of the selected object"), menu, wxID_ANY, _L("Fill bed with copies") + dots, _L("Fill the remaining area of bed with copies of the selected object"),
[](wxCommandEvent &) { plater()->fill_bed_with_instances(); }, "", nullptr, []() { return plater()->can_increase_instances(); }, m_parent); [](wxCommandEvent &) { plater()->fill_bed_with_instances(); }, "", nullptr, []() { return plater()->can_increase_instances(); }, m_parent);
} }
void MenuFactory::append_menu_item_plate_name(wxMenu *menu)
{
wxString name= _L("Edit plate setitngs");
// Delete old menu item
const int item_id = menu->FindItem(name);
if (item_id != wxNOT_FOUND) menu->Destroy(item_id);
PartPlate *plate = plater()->get_partplate_list().get_selected_plate();
assert(plate);
auto item = append_menu_item(
menu, wxID_ANY, name, "",
[plate](wxCommandEvent &e) {
int hover_idx =plater()->canvas3D()->GetHoverId();
if (hover_idx == -1) {
int plate_idx=plater()->GetPlateIndexByRightMenuInLeftUI();
plater()->select_plate_by_hover_id(plate_idx * PartPlate::GRABBER_COUNT, false, true);
}
else
{
plater()->select_plate_by_hover_id(hover_idx, false, true);
}
},
"", nullptr, []() { return true; }, m_parent);
m_parent->Bind(
wxEVT_UPDATE_UI,
[](wxUpdateUIEvent &evt) {
PartPlate *plate = plater()->get_partplate_list().get_selected_plate();
assert(plate);
plater()->set_current_canvas_as_dirty();
},
item->GetId());
}
void MenuFactory::update_object_menu() void MenuFactory::update_object_menu()
{ {

View file

@ -151,6 +151,7 @@ private:
void append_menu_item_set_printable(wxMenu* menu); void append_menu_item_set_printable(wxMenu* menu);
void append_menu_item_locked(wxMenu* menu); void append_menu_item_locked(wxMenu* menu);
void append_menu_item_fill_bed(wxMenu *menu); void append_menu_item_fill_bed(wxMenu *menu);
void append_menu_item_plate_name(wxMenu *menu);
}; };
}} }}

View file

@ -1266,6 +1266,14 @@ void ObjectList::show_context_menu(const bool evt_context_menu)
type & itInstance ? plater->instance_menu() : type & itInstance ? plater->instance_menu() :
type & itVolume ? plater->part_menu() : type & itVolume ? plater->part_menu() :
printer_technology() == ptFFF ? plater->object_menu() : plater->sla_object_menu(); printer_technology() == ptFFF ? plater->object_menu() : plater->sla_object_menu();
plater->SetPlateIndexByRightMenuInLeftUI(-1);
if (type & itPlate) {
int plate_idx = -1;
const ItemType type0 = m_objects_model->GetItemType(item, plate_idx);
if (plate_idx >= 0) {
plater->SetPlateIndexByRightMenuInLeftUI(plate_idx);
}
}
} }
else if (evt_context_menu) else if (evt_context_menu)
menu = plater->default_menu(); menu = plater->default_menu();

View file

@ -328,6 +328,13 @@ bool ObjectDataViewModelNode::SetValue(const wxVariant& variant, unsigned col)
return false; return false;
} }
void ObjectDataViewModelNode::SetName(const wxString &tempName)
{
if (m_name != tempName) {
m_name = tempName;
}
}
void ObjectDataViewModelNode::SetIdx(const int &idx) void ObjectDataViewModelNode::SetIdx(const int &idx)
{ {
m_idx = idx; m_idx = idx;
@ -451,8 +458,13 @@ wxDataViewItem ObjectDataViewModel::AddPlate(PartPlate* part_plate, wxString nam
wxString plate_name = name; wxString plate_name = name;
if (plate_name == "") { if (plate_name == "") {
plate_name = _L("Plate"); plate_name = _L("Plate");
std::string plate_CustomName = part_plate ? part_plate->get_plate_name() : "";
if (plate_CustomName.length() > 0) {
plate_name << " " << plate_idx + 1 << " (" << plate_CustomName << ")";
} else {
plate_name << " " << plate_idx + 1; plate_name << " " << plate_idx + 1;
} }
}
auto plate_node = new ObjectDataViewModelNode(part_plate, plate_name); auto plate_node = new ObjectDataViewModelNode(part_plate, plate_name);
bool is_added = false; bool is_added = false;
@ -1241,6 +1253,20 @@ wxDataViewItem ObjectDataViewModel::GetItemByPlateId(int plate_idx)
return wxDataViewItem(nullptr); return wxDataViewItem(nullptr);
} }
void ObjectDataViewModel::SetCurSelectedPlateFullNmae(int plate_idx, const std::string & custom_name) {
for (auto plate : m_plates) {
if (plate->m_plate_idx == plate_idx) {
wxString plate_full_name=_L("Plate");
if (custom_name.length() > 0) {
plate_full_name << " " << plate_idx + 1 << " (" << custom_name << ")";
} else {
plate_full_name << " " << plate_idx + 1;
}
plate->SetName(plate_full_name);
}
}
}
wxDataViewItem ObjectDataViewModel::GetItemByVolumeId(int obj_idx, int volume_idx) wxDataViewItem ObjectDataViewModel::GetItemByVolumeId(int obj_idx, int volume_idx)
{ {
if (size_t(obj_idx) >= m_objects.size()) { if (size_t(obj_idx) >= m_objects.size()) {
@ -1957,6 +1983,15 @@ ItemType ObjectDataViewModel::GetItemType(const wxDataViewItem &item) const
return node->m_type < 0 ? itUndef : node->m_type; return node->m_type < 0 ? itUndef : node->m_type;
} }
ItemType ObjectDataViewModel::GetItemType(const wxDataViewItem &item, int &plate_idx) const
{
if (!item.IsOk())
return itUndef;
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
plate_idx=node->m_plate_idx;
return node->m_type < 0 ? itUndef : node->m_type;
}
InfoItemType ObjectDataViewModel::GetInfoItemType(const wxDataViewItem &item) const InfoItemType ObjectDataViewModel::GetInfoItemType(const wxDataViewItem &item) const
{ {
if (!item.IsOk()) if (!item.IsOk())

View file

@ -220,7 +220,7 @@ public:
{ {
return m_children.GetCount(); return m_children.GetCount();
} }
void SetName(const wxString &);
bool SetValue(const wxVariant &variant, unsigned int col); bool SetValue(const wxVariant &variant, unsigned int col);
void SetVolumeType(ModelVolumeType type) { m_volume_type = type; } void SetVolumeType(ModelVolumeType type) { m_volume_type = type; }
void SetBitmap(const wxBitmap &icon) { m_bmp = icon; } void SetBitmap(const wxBitmap &icon) { m_bmp = icon; }
@ -361,6 +361,7 @@ public:
void DeleteVolumeChildren(wxDataViewItem& parent); void DeleteVolumeChildren(wxDataViewItem& parent);
void DeleteSettings(const wxDataViewItem& parent); void DeleteSettings(const wxDataViewItem& parent);
wxDataViewItem GetItemByPlateId(int plate_idx); wxDataViewItem GetItemByPlateId(int plate_idx);
void SetCurSelectedPlateFullNmae(int plate_idx,const std::string &);
wxDataViewItem GetItemById(int obj_idx); wxDataViewItem GetItemById(int obj_idx);
wxDataViewItem GetItemById(const int obj_idx, const int sub_obj_idx, const ItemType parent_type); wxDataViewItem GetItemById(const int obj_idx, const int sub_obj_idx, const ItemType parent_type);
wxDataViewItem GetItemByVolumeId(int obj_idx, int volume_idx); wxDataViewItem GetItemByVolumeId(int obj_idx, int volume_idx);
@ -428,6 +429,7 @@ public:
bool HasInfoItem(InfoItemType type) const; bool HasInfoItem(InfoItemType type) const;
ItemType GetItemType(const wxDataViewItem &item) const; ItemType GetItemType(const wxDataViewItem &item) const;
ItemType GetItemType(const wxDataViewItem &item,int& plate_idx) const;
InfoItemType GetInfoItemType(const wxDataViewItem &item) const; InfoItemType GetInfoItemType(const wxDataViewItem &item) const;
wxDataViewItem GetItemByType( const wxDataViewItem &parent_item, wxDataViewItem GetItemByType( const wxDataViewItem &parent_item,
ItemType type) const; ItemType type) const;

View file

@ -1556,6 +1556,12 @@ void PartPlate::set_plate_name(const std::string &name)
// compare if name equal to m_name, case sensitive // compare if name equal to m_name, case sensitive
if (boost::equals(m_name, name)) return; if (boost::equals(m_name, name)) return;
if (m_plater) {
ObjectList *obj_list = wxGetApp().obj_list();
if (obj_list) {
obj_list->GetModel()->SetCurSelectedPlateFullNmae(m_plate_index, name);
}
}
m_name = name; m_name = name;
m_name_change = true; m_name_change = true;
if (m_print != nullptr) if (m_print != nullptr)

View file

@ -1701,6 +1701,7 @@ struct Plater::priv
bool m_slice_all{false}; bool m_slice_all{false};
bool m_is_slicing {false}; bool m_is_slicing {false};
bool m_is_publishing {false}; bool m_is_publishing {false};
int m_is_RightClickInLeftUI{-1};
int m_cur_slice_plate; int m_cur_slice_plate;
//BBS: m_slice_all in .gcode.3mf file case, set true when slice all //BBS: m_slice_all in .gcode.3mf file case, set true when slice all
bool m_slice_all_only_has_gcode{ false }; bool m_slice_all_only_has_gcode{ false };
@ -11114,13 +11115,13 @@ void Plater::validate_current_plate(bool& model_fits, bool& validate_error)
//BBS: select Plate by hover_id //BBS: select Plate by hover_id
int Plater::select_plate_by_hover_id(int hover_id, bool right_click) int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModidyPlateName)
{ {
int ret; int ret;
int action, plate_index; int action, plate_index;
plate_index = hover_id / PartPlate::GRABBER_COUNT; plate_index = hover_id / PartPlate::GRABBER_COUNT;
action = hover_id % PartPlate::GRABBER_COUNT; action = isModidyPlateName?5:hover_id % PartPlate::GRABBER_COUNT;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": enter, hover_id %1%, plate_index %2%, action %3%")%hover_id % plate_index %action; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": enter, hover_id %1%, plate_index %2%, action %3%")%hover_id % plate_index %action;
if (action == 0) if (action == 0)
@ -11746,7 +11747,8 @@ wxMenu* Plater::default_menu() { return p->menus.default_menu();
wxMenu* Plater::instance_menu() { return p->menus.instance_menu(); } wxMenu* Plater::instance_menu() { return p->menus.instance_menu(); }
wxMenu* Plater::layer_menu() { return p->menus.layer_menu(); } wxMenu* Plater::layer_menu() { return p->menus.layer_menu(); }
wxMenu* Plater::multi_selection_menu() { return p->menus.multi_selection_menu(); } wxMenu* Plater::multi_selection_menu() { return p->menus.multi_selection_menu(); }
int Plater::GetPlateIndexByRightMenuInLeftUI() { return p->m_is_RightClickInLeftUI; }
void Plater::SetPlateIndexByRightMenuInLeftUI(int index) { p->m_is_RightClickInLeftUI = index; }
SuppressBackgroundProcessingUpdate::SuppressBackgroundProcessingUpdate() : SuppressBackgroundProcessingUpdate::SuppressBackgroundProcessingUpdate() :
m_was_scheduled(wxGetApp().plater()->is_background_process_update_scheduled()) m_was_scheduled(wxGetApp().plater()->is_background_process_update_scheduled())
{ {

View file

@ -508,7 +508,7 @@ public:
//BBS: update progress result //BBS: update progress result
void apply_background_progress(); void apply_background_progress();
//BBS: select the plate by hover_id //BBS: select the plate by hover_id
int select_plate_by_hover_id(int hover_id, bool right_click = false); int select_plate_by_hover_id(int hover_id, bool right_click = false, bool isModidyPlateName = false);
//BBS: delete the plate, index= -1 means the current plate //BBS: delete the plate, index= -1 means the current plate
int delete_plate(int plate_index = -1); int delete_plate(int plate_index = -1);
//BBS: select the sliced plate by index //BBS: select the sliced plate by index
@ -673,7 +673,8 @@ public:
wxMenu* instance_menu(); wxMenu* instance_menu();
wxMenu* layer_menu(); wxMenu* layer_menu();
wxMenu* multi_selection_menu(); wxMenu* multi_selection_menu();
int GetPlateIndexByRightMenuInLeftUI();
void SetPlateIndexByRightMenuInLeftUI(int);
static bool has_illegal_filename_characters(const wxString& name); static bool has_illegal_filename_characters(const wxString& name);
static bool has_illegal_filename_characters(const std::string& name); static bool has_illegal_filename_characters(const std::string& name);
static void show_illegal_characters_warning(wxWindow* parent); static void show_illegal_characters_warning(wxWindow* parent);