From 6c1b52afa2c0e4d5c6ff3063bcd67dd42cbcbedc Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 29 Aug 2018 13:11:30 +0200 Subject: [PATCH] Deleted "scale" column from object list --- lib/Slic3r/GUI/Plater.pm | 4 +-- xs/src/slic3r/GUI/GUI_ObjectParts.cpp | 39 +++++++++++---------------- xs/src/slic3r/GUI/GUI_ObjectParts.hpp | 5 ++-- xs/src/slic3r/GUI/wxExtensions.cpp | 24 +++++------------ xs/src/slic3r/GUI/wxExtensions.hpp | 19 +++++-------- xs/xsp/GUI.xsp | 7 ++--- 6 files changed, 37 insertions(+), 61 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index eb95bc4d4..1a769a87e 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -136,7 +136,7 @@ sub new { $_->set_scaling_factor($scale) for @{ $model_object->instances }; # Set object scale on c++ side - Slic3r::GUI::set_object_scale($obj_idx, $model_object->instances->[0]->scaling_factor * 100); +# Slic3r::GUI::set_object_scale($obj_idx, $model_object->instances->[0]->scaling_factor * 100); # $object->transform_thumbnail($self->{model}, $obj_idx); @@ -1278,7 +1278,7 @@ sub changescale { } # Set object scale on c++ side - Slic3r::GUI::set_object_scale($obj_idx, $scale); +# Slic3r::GUI::set_object_scale($obj_idx, $scale); $scale /= 100; # turn percent into factor my $variation = $scale / $model_instance->scaling_factor; diff --git a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp index 7f3b049cd..94555f50e 100644 --- a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp +++ b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp @@ -226,7 +226,7 @@ wxDataViewColumn* object_ctrl_create_extruder_column(int extruders_count) choices.Add(wxString::Format("%d", i)); wxDataViewChoiceRenderer *c = new wxDataViewChoiceRenderer(choices, wxDATAVIEW_CELL_EDITABLE, wxALIGN_CENTER_HORIZONTAL); - wxDataViewColumn* column = new wxDataViewColumn(_(L("Extruder")), c, 3, 60, wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE); + wxDataViewColumn* column = new wxDataViewColumn(_(L("Extruder")), c, 2, 60, wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE); return column; } @@ -246,7 +246,7 @@ void create_objects_ctrl(wxWindow* win, wxBoxSizer*& objects_sz) #endif // wxUSE_DRAG_AND_DROP && wxUSE_UNICODE // column 0(Icon+Text) of the view control: - m_objects_ctrl->AppendIconTextColumn(_(L("Name")), 0, wxDATAVIEW_CELL_INERT, 120, + m_objects_ctrl->AppendIconTextColumn(_(L("Name")), 0, wxDATAVIEW_CELL_INERT, 200, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE); // column 1 of the view control: @@ -254,14 +254,10 @@ void create_objects_ctrl(wxWindow* win, wxBoxSizer*& objects_sz) wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE); // column 2 of the view control: - m_objects_ctrl->AppendTextColumn(_(L("Scale")), 2, wxDATAVIEW_CELL_INERT, 55, - wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE); - - // column 3 of the view control: m_objects_ctrl->AppendColumn(object_ctrl_create_extruder_column(4)); - // column 4 of the view control: - m_objects_ctrl->AppendBitmapColumn(" ", 4, wxDATAVIEW_CELL_INERT, 25, + // column 3 of the view control: + m_objects_ctrl->AppendBitmapColumn(" ", 3, wxDATAVIEW_CELL_INERT, 25, wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE); } @@ -659,8 +655,7 @@ void show_collpane_settings(bool expert_mode) void add_object_to_list(const std::string &name, ModelObject* model_object) { wxString item_name = name; - int scale = model_object->instances[0]->scaling_factor * 100; - auto item = m_objects_model->Add(item_name, model_object->instances.size(), scale); + auto item = m_objects_model->Add(item_name, model_object->instances.size()); m_objects_ctrl->Select(item); // Add error icon if detected auto-repaire @@ -697,6 +692,8 @@ void delete_object_from_list() // m_objects_ctrl->Select(m_objects_model->Delete(item)); m_objects_model->Delete(item); + part_selection_changed(); + // if (m_objects_model->IsEmpty()) // m_collpane_settings->Show(false); } @@ -704,6 +701,8 @@ void delete_object_from_list() void delete_all_objects_from_list() { m_objects_model->DeleteAll(); + + part_selection_changed(); // m_collpane_settings->Show(false); } @@ -713,12 +712,6 @@ void set_object_count(int idx, int count) m_objects_ctrl->Refresh(); } -void set_object_scale(int idx, int scale) -{ - m_objects_model->SetValue(wxString::Format("%d%%", scale), idx, 2); - m_objects_ctrl->Refresh(); -} - void unselect_objects() { if (!m_objects_ctrl->GetSelection()) @@ -834,10 +827,10 @@ void object_ctrl_key_event(wxKeyEvent& event) void object_ctrl_item_value_change(wxDataViewEvent& event) { - if (event.GetColumn() == 3) + if (event.GetColumn() == 2) { wxVariant variant; - m_objects_model->GetValue(variant, event.GetItem(), 3); + m_objects_model->GetValue(variant, event.GetItem(), 2); #ifdef __WXOSX__ g_selected_extruder = variant.GetString(); #else // --> for Linux @@ -930,8 +923,8 @@ void update_settings_list() no_updates.reset(nullptr); #endif - get_right_panel()->Layout(); - get_right_panel()->GetParent()->Layout(); + /*get_right_panel()*/parent->Layout(); + get_right_panel()->GetParent()->GetParent()->Layout(); } void get_settings_choice(wxMenu *menu, int id, bool is_part) @@ -1523,7 +1516,7 @@ void part_selection_changed() void set_extruder_column_hidden(bool hide) { - m_objects_ctrl->GetColumn(3)->SetHidden(hide); + m_objects_ctrl->GetColumn(2)->SetHidden(hide); } void update_extruder_in_config(const wxString& selection) @@ -1668,9 +1661,9 @@ void update_objects_list_extruder_column(int extruders_count) extruders_count = 1; // delete old 3rd column - m_objects_ctrl->DeleteColumn(m_objects_ctrl->GetColumn(3)); + m_objects_ctrl->DeleteColumn(m_objects_ctrl->GetColumn(2)); // insert new created 3rd column - m_objects_ctrl->InsertColumn(3, object_ctrl_create_extruder_column(extruders_count)); + m_objects_ctrl->InsertColumn(2, object_ctrl_create_extruder_column(extruders_count)); // set show/hide for this column set_extruder_column_hidden(extruders_count <= 1); } diff --git a/xs/src/slic3r/GUI/GUI_ObjectParts.hpp b/xs/src/slic3r/GUI/GUI_ObjectParts.hpp index f8b08d3a6..82bfe4a6c 100644 --- a/xs/src/slic3r/GUI/GUI_ObjectParts.hpp +++ b/xs/src/slic3r/GUI/GUI_ObjectParts.hpp @@ -9,6 +9,7 @@ class wxArrayString; class wxMenu; class wxDataViewEvent; class wxKeyEvent; +class wxControl; namespace Slic3r { class ModelObject; @@ -61,8 +62,6 @@ void delete_object_from_list(); void delete_all_objects_from_list(); // Set count of object on c++ side void set_object_count(int idx, int count); -// Set object scale on c++ side -void set_object_scale(int idx, int scale); // Unselect all objects in the list on c++ side void unselect_objects(); // Select current object in the list on c++ side @@ -70,6 +69,8 @@ void select_current_object(int idx); // Remove objects/sub-object from the list void remove(); +//void create_double_slider(wxWindow* parent, wxControl* slider); + void object_ctrl_selection_changed(); void object_ctrl_context_menu(); void object_ctrl_key_event(wxKeyEvent& event); diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp index a8ed45e07..e646ed0ec 100644 --- a/xs/src/slic3r/GUI/wxExtensions.cpp +++ b/xs/src/slic3r/GUI/wxExtensions.cpp @@ -362,7 +362,7 @@ void PrusaObjectDataViewModelNode::set_part_action_icon() { // PrusaObjectDataViewModel // ---------------------------------------------------------------------------- -wxDataViewItem PrusaObjectDataViewModel::Add(wxString &name) +wxDataViewItem PrusaObjectDataViewModel::Add(const wxString &name) { auto root = new PrusaObjectDataViewModelNode(name); m_objects.push_back(root); @@ -373,9 +373,9 @@ wxDataViewItem PrusaObjectDataViewModel::Add(wxString &name) return child; } -wxDataViewItem PrusaObjectDataViewModel::Add(wxString &name, int instances_count, int scale) +wxDataViewItem PrusaObjectDataViewModel::Add(const wxString &name, const int instances_count/*, int scale*/) { - auto root = new PrusaObjectDataViewModelNode(name, instances_count, scale); + auto root = new PrusaObjectDataViewModelNode(name, instances_count); m_objects.push_back(root); // notify control wxDataViewItem child((void*)root); @@ -562,15 +562,6 @@ wxString PrusaObjectDataViewModel::GetCopy(const wxDataViewItem &item) const return node->m_copy; } -wxString PrusaObjectDataViewModel::GetScale(const wxDataViewItem &item) const -{ - PrusaObjectDataViewModelNode *node = (PrusaObjectDataViewModelNode*)item.GetID(); - if (!node) // happens if item.IsOk()==false - return wxEmptyString; - - return node->m_scale; -} - wxIcon& PrusaObjectDataViewModel::GetIcon(const wxDataViewItem &item) const { PrusaObjectDataViewModelNode *node = (PrusaObjectDataViewModelNode*)item.GetID(); @@ -592,12 +583,9 @@ void PrusaObjectDataViewModel::GetValue(wxVariant &variant, const wxDataViewItem variant = node->m_copy; break; case 2: - variant = node->m_scale; - break; - case 3: variant = node->m_extruder; break; - case 4: + case 3: variant << node->m_action_icon; break; default: @@ -1016,8 +1004,8 @@ wxString PrusaDoubleSlider::get_label(const SelectedSlider& selection) const const wxString str = m_values.empty() ? wxNumberFormatter::ToString(m_label_koef*value, 2, wxNumberFormatter::Style_None) : - wxNumberFormatter::ToString(m_values[value], 2, wxNumberFormatter::Style_None); - return wxString::Format("%s\n(%d)", str, value); + wxNumberFormatter::ToString(m_values[value].second, 2, wxNumberFormatter::Style_None); + return wxString::Format("%s\n(%d)", str, m_values.empty() ? value : m_values[value].first); } void PrusaDoubleSlider::draw_thumb_text(wxDC& dc, const wxPoint& pos, const SelectedSlider& selection) const diff --git a/xs/src/slic3r/GUI/wxExtensions.hpp b/xs/src/slic3r/GUI/wxExtensions.hpp index 62e4f4f15..76e59f2eb 100644 --- a/xs/src/slic3r/GUI/wxExtensions.hpp +++ b/xs/src/slic3r/GUI/wxExtensions.hpp @@ -157,11 +157,10 @@ class PrusaObjectDataViewModelNode MyObjectTreeModelNodePtrArray m_children; wxIcon m_empty_icon; public: - PrusaObjectDataViewModelNode(const wxString &name, int instances_count=1, int scale=100) { + PrusaObjectDataViewModelNode(const wxString &name, const int instances_count=1) { m_parent = NULL; m_name = name; m_copy = wxString::Format("%d", instances_count); - m_scale = wxString::Format("%d%%", scale); m_type = "object"; m_volume_id = -1; #ifdef __WXGTK__ @@ -181,7 +180,6 @@ public: m_parent = parent; m_name = sub_obj_name; m_copy = wxEmptyString; - m_scale = wxEmptyString; m_icon = icon; m_type = "volume"; m_volume_id = volume_id; @@ -203,7 +201,6 @@ public: wxString m_name; wxIcon& m_icon = m_empty_icon; wxString m_copy; - wxString m_scale; std::string m_type; int m_volume_id; bool m_container = false; @@ -270,12 +267,9 @@ public: m_copy = variant.GetString(); return true; case 2: - m_scale = variant.GetString(); - return true; - case 3: m_extruder = variant.GetString(); return true; - case 4: + case 3: m_action_icon << variant; return true; default: @@ -349,8 +343,8 @@ public: delete object; } - wxDataViewItem Add(wxString &name); - wxDataViewItem Add(wxString &name, int instances_count, int scale); + wxDataViewItem Add(const wxString &name); + wxDataViewItem Add(const wxString &name, const int instances_count); wxDataViewItem AddChild(const wxDataViewItem &parent_item, const wxString &name, const wxIcon& icon, @@ -368,7 +362,6 @@ public: wxString GetName(const wxDataViewItem &item) const; wxString GetCopy(const wxDataViewItem &item) const; - wxString GetScale(const wxDataViewItem &item) const; wxIcon& GetIcon(const wxDataViewItem &item) const; // helper methods to change the model @@ -542,7 +535,7 @@ public: void SetKoefForLabels(const double koef) { m_label_koef = koef; } - void SetSliderValues(const std::vector& values) { + void SetSliderValues(const std::vector>& values) { m_values = values; } @@ -638,7 +631,7 @@ private: std::vector line_pens; std::vector segm_pens; std::set m_ticks; - std::vector m_values; + std::vector> m_values; }; diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index b9183af1d..c18fce44d 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -146,9 +146,6 @@ void delete_all_objects_from_list() void set_object_count(int idx, int count) %code%{ Slic3r::GUI::set_object_count(idx, count); %}; -void set_object_scale(int idx, int scale) - %code%{ Slic3r::GUI::set_object_scale(idx, scale); %}; - void unselect_objects() %code%{ Slic3r::GUI::unselect_objects(); %}; @@ -185,3 +182,7 @@ void register_on_request_update_callback(SV* callback) void deregister_on_request_update_callback() %code%{ Slic3r::GUI::g_on_request_update_callback.deregister_callback(); %}; +//void create_double_slider(SV *ui_parent, SV *ui_ds) +// %code%{ Slic3r::GUI::create_double_slider( (wxWindow*)wxPli_sv_2_object(aTHX_ ui_parent, "Wx::Window"), +// (wxControl*)wxPli_sv_2_object(aTHX_ ui_ds, "Wx::Control")); %}; +