Set correct man/max value for movers
This commit is contained in:
parent
54975a4e36
commit
fb9ba1a55c
5 changed files with 36 additions and 16 deletions
|
@ -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);
|
||||
});
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -710,7 +710,6 @@ void SliderCtrl::BUILD()
|
|||
}
|
||||
}), m_textctrl->GetId());
|
||||
|
||||
// // recast as a wxWindow to fit the calling convention
|
||||
m_sizer = dynamic_cast<wxSizer*>(temp);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<wxWindow*>(m_slider); }
|
||||
};
|
||||
|
||||
} // GUI
|
||||
|
|
|
@ -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<ConfigOptionsGroup> optgroup = std::make_shared<ConfigOptionsGroup>(win, "Move", config);
|
||||
// DynamicPrintConfig* config = &get_preset_bundle()->/*full_config();//*/printers.get_edited_preset().config; // TODO get config from Model_volume
|
||||
std::shared_ptr<ConfigOptionsGroup> optgroup = std::make_shared<ConfigOptionsGroup>(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<wxSlider*>(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<wxSlider*>(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<wxSlider*>(optgroup->get_field("z")->getWindow());
|
||||
|
||||
get_optgroups().push_back(optgroup); // ogObjectMovers
|
||||
m_sizer_object_movers = optgroup->sizer;
|
||||
|
|
Loading…
Reference in a new issue