From fb9ba1a55c2bca2650f10bb8afd1df21853e3233 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Sat, 16 Jun 2018 03:04:59 +0200 Subject: [PATCH] Set correct man/max value for movers --- lib/Slic3r/GUI/MainFrame.pm | 5 ++-- lib/Slic3r/GUI/Plater.pm | 7 +++--- xs/src/slic3r/GUI/Field.cpp | 1 - xs/src/slic3r/GUI/Field.hpp | 3 ++- xs/src/slic3r/GUI/GUI_ObjectParts.cpp | 36 ++++++++++++++++++++------- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index fd2844783..7f14c4068 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -179,9 +179,10 @@ sub _init_tabpanel { # The following event is emited by the C++ Tab implementation on object selection change. EVT_COMMAND($self, -1, $OBJECT_SELECTION_CHANGED_EVENT, sub { my ($self, $event) = @_; - my $obj_idx = $event->GetInt; + my $obj_idx = $event->GetId; + my $child = $event->GetInt == 1 ? 1 : undef; - $self->{plater}->select_object($obj_idx < 0 ? undef: $obj_idx); + $self->{plater}->select_object($obj_idx < 0 ? undef: $obj_idx, $child); $self->{plater}->item_changed_selection($obj_idx); }); diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 1d2168fe8..3905228bc 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -2081,7 +2081,7 @@ sub selection_changed { } sub select_object { - my ($self, $obj_idx) = @_; + my ($self, $obj_idx, $child) = @_; # remove current selection foreach my $o (0..$#{$self->{objects}}) { @@ -2090,8 +2090,9 @@ sub select_object { if (defined $obj_idx) { $self->{objects}->[$obj_idx]->selected(1); - # Select current object in the list on c++ side - Slic3r::GUI::select_current_object($obj_idx); + # Select current object in the list on c++ side, if item isn't child + if (!defined $child){ + Slic3r::GUI::select_current_object($obj_idx);} } else { # Unselect all objects in the list on c++ side Slic3r::GUI::unselect_objects(); diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index dcb251be6..1b4aef033 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -710,7 +710,6 @@ void SliderCtrl::BUILD() } }), m_textctrl->GetId()); - // // recast as a wxWindow to fit the calling convention m_sizer = dynamic_cast(temp); } diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index 40f56c0d3..04ee8c87b 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -213,7 +213,7 @@ protected: inline bool is_bad_field(const t_field& obj) { return obj->getSizer() == nullptr && obj->getWindow() == nullptr; } /// Covenience function to determine whether this field is a valid window field. -inline bool is_window_field(const t_field& obj) { return !is_bad_field(obj) && obj->getWindow() != nullptr; } +inline bool is_window_field(const t_field& obj) { return !is_bad_field(obj) && obj->getWindow() != nullptr && obj->getSizer() == nullptr; } /// Covenience function to determine whether this field is a valid sizer field. inline bool is_sizer_field(const t_field& obj) { return !is_bad_field(obj) && obj->getSizer() != nullptr; } @@ -414,6 +414,7 @@ public: m_textctrl->SetEditable(false); } wxSizer* getSizer() override { return m_sizer; } + wxWindow* getWindow() override { return dynamic_cast(m_slider); } }; } // GUI diff --git a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp index f1c5df1e7..77cacadff 100644 --- a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp +++ b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp @@ -23,6 +23,10 @@ wxDataViewCtrl *m_objects_ctrl = nullptr; PrusaObjectDataViewModel *m_objects_model = nullptr; wxCollapsiblePane *m_collpane_settings = nullptr; +wxSlider* mover_x = nullptr; +wxSlider* mover_y = nullptr; +wxSlider* mover_z = nullptr; + bool g_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 // calls this method again and again and again @@ -95,7 +99,8 @@ wxBoxSizer* content_objects_list(wxWindow *win) if (m_event_object_selection_changed > 0) { wxCommandEvent event(m_event_object_selection_changed); - event.SetInt(obj_idx); + event.SetInt(int(m_objects_model->GetParent(item) != wxDataViewItem(0))); + event.SetId(obj_idx); get_main_frame()->ProcessWindowEvent(event); } @@ -107,6 +112,22 @@ wxBoxSizer* content_objects_list(wxWindow *win) m_sizer_object_buttons->Show(show_obj_sizer); m_sizer_part_buttons->Show(!show_obj_sizer); m_sizer_object_movers->Show(!show_obj_sizer); + + if (!show_obj_sizer) + { + auto bb_size = m_objects[obj_idx]->bounding_box().size(); + int scale = 10; //?? + + mover_x->SetMin(-bb_size.x * 4*scale); + mover_x->SetMax( bb_size.x * 4*scale); + + mover_y->SetMin(-bb_size.y * 4*scale); + mover_y->SetMax( bb_size.y * 4*scale); + + mover_z->SetMin(-bb_size.z * 4 * scale); + mover_z->SetMax( bb_size.z * 4 * scale); + } + m_collpane_settings->SetLabelText((show_obj_sizer ? _(L("Object Settings")) : _(L("Part Settings"))) + ":"); m_collpane_settings->Show(true); }); @@ -200,8 +221,8 @@ wxBoxSizer* content_edit_object_buttons(wxWindow* win) wxSizer* object_movers(wxWindow *win) { - DynamicPrintConfig* config = &get_preset_bundle()->/*full_config();//*/printers.get_edited_preset().config; // TODO get config from Model_volume - std::shared_ptr optgroup = std::make_shared(win, "Move", config); +// DynamicPrintConfig* config = &get_preset_bundle()->/*full_config();//*/printers.get_edited_preset().config; // TODO get config from Model_volume + std::shared_ptr optgroup = std::make_shared(win, "Move"/*, config*/); optgroup->label_width = 20; ConfigOptionDef def; @@ -209,24 +230,21 @@ wxSizer* object_movers(wxWindow *win) def.type = coInt; def.gui_type = "slider"; def.default_value = new ConfigOptionInt(0); - // def.min = -(model_object->bounding_box->size->x) * 4; - // def.max = model_object->bounding_box->size->x * 4; Option option = Option(def, "x"); option.opt.full_width = true; optgroup->append_single_option_line(option); + mover_x = dynamic_cast(optgroup->get_field("x")->getWindow()); def.label = L("Y"); - // def.min = -(model_object->bounding_box->size->y) * 4; - // def.max = model_object->bounding_box->size->y * 4; option = Option(def, "y"); optgroup->append_single_option_line(option); + mover_y = dynamic_cast(optgroup->get_field("y")->getWindow()); def.label = L("Z"); - // def.min = -(model_object->bounding_box->size->z) * 4; - // def.max = model_object->bounding_box->size->z * 4; option = Option(def, "z"); optgroup->append_single_option_line(option); + mover_z = dynamic_cast(optgroup->get_field("z")->getWindow()); get_optgroups().push_back(optgroup); // ogObjectMovers m_sizer_object_movers = optgroup->sizer;