Prepared callback from c++ to Perl to inform about a change of object settings
This commit is contained in:
parent
6b56f99df7
commit
f5ef672815
@ -27,6 +27,8 @@ our $VALUE_CHANGE_EVENT = Wx::NewEventType;
|
||||
our $PRESETS_CHANGED_EVENT = Wx::NewEventType;
|
||||
# 3) To inform about a change of object selection
|
||||
our $OBJECT_SELECTION_CHANGED_EVENT = Wx::NewEventType;
|
||||
# 4) To inform about a change of object settings
|
||||
our $OBJECT_SETTINGS_CHANGED_EVENT = Wx::NewEventType;
|
||||
|
||||
sub new {
|
||||
my ($class, %params) = @_;
|
||||
@ -117,6 +119,7 @@ sub _init_tabpanel {
|
||||
if (!$self->{no_plater}) {
|
||||
$panel->AddPage($self->{plater} = Slic3r::GUI::Plater->new($panel,
|
||||
event_object_selection_changed => $OBJECT_SELECTION_CHANGED_EVENT,
|
||||
event_object_settings_changed => $OBJECT_SETTINGS_CHANGED_EVENT,
|
||||
), L("Plater"));
|
||||
if (!$self->{no_controller}) {
|
||||
$panel->AddPage($self->{controller} = Slic3r::GUI::Controller->new($panel), L("Controller"));
|
||||
@ -173,7 +176,7 @@ sub _init_tabpanel {
|
||||
}
|
||||
});
|
||||
|
||||
# The following event is emited by the C++ Tab implementation on config value change.
|
||||
# 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;
|
||||
@ -182,6 +185,17 @@ sub _init_tabpanel {
|
||||
$self->{plater}->item_changed_selection($obj_idx);
|
||||
});
|
||||
|
||||
# The following event is emited by the C++ Tab implementation on object settings change.
|
||||
EVT_COMMAND($self, -1, $OBJECT_SETTINGS_CHANGED_EVENT, sub {
|
||||
my ($self, $event) = @_;
|
||||
my $obj_idx = $event->GetInt;
|
||||
|
||||
#my $line = $event->GetString;
|
||||
#my ($parts_changed, $part_settings_changed) = split('',$line);
|
||||
|
||||
#$self->{plater}->changed_object_settings($obj_idx, $parts_changed, $part_settings_changed);
|
||||
});
|
||||
|
||||
|
||||
Slic3r::GUI::create_preset_tabs($self->{no_controller}, $VALUE_CHANGE_EVENT, $PRESETS_CHANGED_EVENT);
|
||||
$self->{options_tabs} = {};
|
||||
|
@ -56,6 +56,7 @@ sub new {
|
||||
|
||||
# store input params
|
||||
$self->{event_object_selection_changed} = $params{event_object_selection_changed};
|
||||
$self->{event_object_settings_changed} = $params{event_object_settings_changed};
|
||||
|
||||
# C++ Slic3r::Model with Perl extensions in Slic3r/Model.pm
|
||||
$self->{model} = Slic3r::Model->new;
|
||||
@ -398,13 +399,15 @@ sub new {
|
||||
Slic3r::GUI::add_frequently_changed_parameters($self->{right_panel}, $frequently_changed_parameters_sizer, $presets);
|
||||
|
||||
my $expert_mode_part_sizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||
Slic3r::GUI::add_expert_mode_part($self->{right_panel}, $expert_mode_part_sizer, $self->{event_object_selection_changed});
|
||||
if ($expert_mode_part_sizer->IsShown(2)==1)
|
||||
{
|
||||
$expert_mode_part_sizer->Layout;
|
||||
$expert_mode_part_sizer->Show(2, 0); # ? Why doesn't work
|
||||
$self->{right_panel}->Layout;
|
||||
}
|
||||
Slic3r::GUI::add_expert_mode_part( $self->{right_panel}, $expert_mode_part_sizer,
|
||||
$self->{event_object_selection_changed},
|
||||
$self->{event_object_settings_changed});
|
||||
# if ($expert_mode_part_sizer->IsShown(2)==1)
|
||||
# {
|
||||
# $expert_mode_part_sizer->Layout;
|
||||
# $expert_mode_part_sizer->Show(2, 0); # ? Why doesn't work
|
||||
# $self->{right_panel}->Layout;
|
||||
# }
|
||||
|
||||
my $object_info_sizer;
|
||||
{
|
||||
@ -1960,6 +1963,29 @@ sub object_settings_dialog {
|
||||
}
|
||||
}
|
||||
|
||||
sub changed_object_settings {
|
||||
my ($self, $obj_idx, $parts_changed, $part_settings_changed) = @_;
|
||||
|
||||
# update thumbnail since parts may have changed
|
||||
if ($parts_changed) {
|
||||
# recenter and re-align to Z = 0
|
||||
my $model_object = $self->{model}->objects->[$obj_idx];
|
||||
$model_object->center_around_origin;
|
||||
$self->reset_thumbnail($obj_idx);
|
||||
}
|
||||
|
||||
# update print
|
||||
if ($parts_changed || $part_settings_changed) {
|
||||
$self->stop_background_process;
|
||||
$self->{print}->reload_object($obj_idx);
|
||||
$self->schedule_background_process;
|
||||
$self->{canvas}->reload_scene if $self->{canvas};
|
||||
$self->{canvas3D}->reload_scene if $self->{canvas3D};
|
||||
} else {
|
||||
$self->resume_background_process;
|
||||
}
|
||||
}
|
||||
|
||||
# Called to update various buttons depending on whether there are any objects or
|
||||
# whether background processing (export of a G-code, sending to Octoprint, forced background re-slicing) is active.
|
||||
sub object_list_changed {
|
||||
|
@ -143,6 +143,7 @@ wxDataViewCtrl *m_objects_ctrl = nullptr;
|
||||
MyObjectTreeModel *m_objects_model = nullptr;
|
||||
wxCollapsiblePane *m_collpane_settings = nullptr;
|
||||
int m_event_object_selection_changed = 0;
|
||||
int m_event_object_settings_changed = 0;
|
||||
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
|
||||
@ -1163,9 +1164,12 @@ void select_current_object(int idx)
|
||||
}
|
||||
}
|
||||
|
||||
void add_expert_mode_part(wxWindow* parent, wxBoxSizer* sizer, int event_object_selection_changed)
|
||||
void add_expert_mode_part( wxWindow* parent, wxBoxSizer* sizer,
|
||||
int event_object_selection_changed,
|
||||
int event_object_settings_changed)
|
||||
{
|
||||
m_event_object_selection_changed = event_object_selection_changed;
|
||||
m_event_object_settings_changed = event_object_settings_changed;
|
||||
wxWindowUpdateLocker noUpdates(parent);
|
||||
|
||||
// *** Objects List ***
|
||||
|
@ -202,7 +202,9 @@ void unselect_objects();
|
||||
// Select current object in the list on c++ side
|
||||
void select_current_object(int idx);
|
||||
|
||||
void add_expert_mode_part(wxWindow* parent, wxBoxSizer* sizer, int event_object_selection_changed);
|
||||
void add_expert_mode_part( wxWindow* parent, wxBoxSizer* sizer,
|
||||
int event_object_selection_changed,
|
||||
int event_object_settings_changed);
|
||||
void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer);
|
||||
// Update view mode according to selected menu
|
||||
void update_mode();
|
||||
|
@ -83,9 +83,13 @@ void add_frequently_changed_parameters(SV *ui_parent, SV *ui_sizer, SV *ui_p_siz
|
||||
(wxBoxSizer*)wxPli_sv_2_object(aTHX_ ui_sizer, "Wx::BoxSizer"),
|
||||
(wxFlexGridSizer*)wxPli_sv_2_object(aTHX_ ui_p_sizer, "Wx::FlexGridSizer")); %};
|
||||
|
||||
void add_expert_mode_part(SV *ui_parent, SV *ui_sizer, int event)
|
||||
void add_expert_mode_part( SV *ui_parent, SV *ui_sizer,
|
||||
int event_object_selection_changed,
|
||||
int event_object_settings_changed)
|
||||
%code%{ Slic3r::GUI::add_expert_mode_part( (wxWindow*)wxPli_sv_2_object(aTHX_ ui_parent, "Wx::Window"),
|
||||
(wxBoxSizer*)wxPli_sv_2_object(aTHX_ ui_sizer, "Wx::BoxSizer"), event); %};
|
||||
(wxBoxSizer*)wxPli_sv_2_object(aTHX_ ui_sizer, "Wx::BoxSizer"),
|
||||
event_object_selection_changed,
|
||||
event_object_settings_changed); %};
|
||||
|
||||
void set_objects_from_perl( SV *ui_parent,
|
||||
SV *frequently_changed_parameters_sizer,
|
||||
|
Loading…
Reference in New Issue
Block a user