Removed old sliders from 3DPreview

This commit is contained in:
YuSanka 2018-08-30 15:30:31 +02:00
parent 99aaedffc1
commit 1358c8efd2
5 changed files with 221 additions and 173 deletions

View File

@ -5,7 +5,7 @@ use utf8;
use Slic3r::Print::State ':steps'; use Slic3r::Print::State ':steps';
use Wx qw(:misc :sizer :slider :statictext :keycode wxWHITE wxCB_READONLY); use Wx qw(:misc :sizer :slider :statictext :keycode wxWHITE wxCB_READONLY);
use Wx::Event qw(EVT_SLIDER EVT_KEY_DOWN EVT_CHECKBOX EVT_CHOICE EVT_CHECKLISTBOX); use Wx::Event qw(EVT_SLIDER EVT_KEY_DOWN EVT_CHECKBOX EVT_CHOICE EVT_CHECKLISTBOX EVT_SIZE);
use base qw(Wx::Panel Class::Accessor); use base qw(Wx::Panel Class::Accessor);
use Wx::Locale gettext => 'L'; use Wx::Locale gettext => 'L';
@ -27,47 +27,47 @@ sub new {
Slic3r::GUI::_3DScene::enable_shader($canvas, 1); Slic3r::GUI::_3DScene::enable_shader($canvas, 1);
Slic3r::GUI::_3DScene::set_config($canvas, $config); Slic3r::GUI::_3DScene::set_config($canvas, $config);
$self->canvas($canvas); $self->canvas($canvas);
my $slider_low = Wx::Slider->new( # my $slider_low = Wx::Slider->new(
$self, -1, # $self, -1,
0, # default # 0, # default
0, # min # 0, # min
# we set max to a bogus non-zero value because the MSW implementation of wxSlider # we set max to a bogus non-zero value because the MSW implementation of wxSlider
# will skip drawing the slider if max <= min: # will skip drawing the slider if max <= min:
1, # max # 1, # max
wxDefaultPosition, # wxDefaultPosition,
wxDefaultSize, # wxDefaultSize,
wxVERTICAL | wxSL_INVERSE, # wxVERTICAL | wxSL_INVERSE,
); # );
$self->slider_low($slider_low); # $self->slider_low($slider_low);
my $slider_high = Wx::Slider->new( # my $slider_high = Wx::Slider->new(
$self, -1, # $self, -1,
0, # default # 0, # default
0, # min # 0, # min
# we set max to a bogus non-zero value because the MSW implementation of wxSlider # we set max to a bogus non-zero value because the MSW implementation of wxSlider
# will skip drawing the slider if max <= min: # will skip drawing the slider if max <= min:
1, # max # 1, # max
wxDefaultPosition, # wxDefaultPosition,
wxDefaultSize, # wxDefaultSize,
wxVERTICAL | wxSL_INVERSE, # wxVERTICAL | wxSL_INVERSE,
); # );
$self->slider_high($slider_high); # $self->slider_high($slider_high);
my $z_label_low = $self->{z_label_low} = Wx::StaticText->new($self, -1, "", wxDefaultPosition, # my $z_label_low = $self->{z_label_low} = Wx::StaticText->new($self, -1, "", wxDefaultPosition,
[40,-1], wxALIGN_CENTRE_HORIZONTAL); # [40,-1], wxALIGN_CENTRE_HORIZONTAL);
$z_label_low->SetFont($Slic3r::GUI::small_font); # $z_label_low->SetFont($Slic3r::GUI::small_font);
my $z_label_high = $self->{z_label_high} = Wx::StaticText->new($self, -1, "", wxDefaultPosition, # my $z_label_high = $self->{z_label_high} = Wx::StaticText->new($self, -1, "", wxDefaultPosition,
[40,-1], wxALIGN_CENTRE_HORIZONTAL); # [40,-1], wxALIGN_CENTRE_HORIZONTAL);
$z_label_high->SetFont($Slic3r::GUI::small_font); # $z_label_high->SetFont($Slic3r::GUI::small_font);
my $z_label_low_idx = $self->{z_label_low_idx} = Wx::StaticText->new($self, -1, "", wxDefaultPosition, # my $z_label_low_idx = $self->{z_label_low_idx} = Wx::StaticText->new($self, -1, "", wxDefaultPosition,
[40,-1], wxALIGN_CENTRE_HORIZONTAL); # [40,-1], wxALIGN_CENTRE_HORIZONTAL);
$z_label_low_idx->SetFont($Slic3r::GUI::small_font); # $z_label_low_idx->SetFont($Slic3r::GUI::small_font);
my $z_label_high_idx = $self->{z_label_high_idx} = Wx::StaticText->new($self, -1, "", wxDefaultPosition, # my $z_label_high_idx = $self->{z_label_high_idx} = Wx::StaticText->new($self, -1, "", wxDefaultPosition,
[40,-1], wxALIGN_CENTRE_HORIZONTAL); # [40,-1], wxALIGN_CENTRE_HORIZONTAL);
$z_label_high_idx->SetFont($Slic3r::GUI::small_font); # $z_label_high_idx->SetFont($Slic3r::GUI::small_font);
$self->single_layer(0); # $self->single_layer(0);
my $checkbox_singlelayer = $self->{checkbox_singlelayer} = Wx::CheckBox->new($self, -1, L("1 Layer")); # my $checkbox_singlelayer = $self->{checkbox_singlelayer} = Wx::CheckBox->new($self, -1, L("1 Layer"));
my $label_view_type = $self->{label_view_type} = Wx::StaticText->new($self, -1, L("View")); my $label_view_type = $self->{label_view_type} = Wx::StaticText->new($self, -1, L("View"));
@ -103,34 +103,30 @@ sub new {
.L("Custom"); .L("Custom");
Slic3r::GUI::create_combochecklist($combochecklist_features, $feature_text, $feature_items, 1); Slic3r::GUI::create_combochecklist($combochecklist_features, $feature_text, $feature_items, 1);
# **************** EXP ******************
my $double_slider_sizer = Wx::BoxSizer->new(wxHORIZONTAL); my $double_slider_sizer = Wx::BoxSizer->new(wxHORIZONTAL);
Slic3r::GUI::create_double_slider($self, $double_slider_sizer, $self->canvas); Slic3r::GUI::create_double_slider($self, $double_slider_sizer, $self->canvas);
$self->double_slider_sizer($double_slider_sizer); $self->double_slider_sizer($double_slider_sizer);
# **************** EXP ******************
my $checkbox_travel = $self->{checkbox_travel} = Wx::CheckBox->new($self, -1, L("Travel")); my $checkbox_travel = $self->{checkbox_travel} = Wx::CheckBox->new($self, -1, L("Travel"));
my $checkbox_retractions = $self->{checkbox_retractions} = Wx::CheckBox->new($self, -1, L("Retractions")); my $checkbox_retractions = $self->{checkbox_retractions} = Wx::CheckBox->new($self, -1, L("Retractions"));
my $checkbox_unretractions = $self->{checkbox_unretractions} = Wx::CheckBox->new($self, -1, L("Unretractions")); my $checkbox_unretractions = $self->{checkbox_unretractions} = Wx::CheckBox->new($self, -1, L("Unretractions"));
my $checkbox_shells = $self->{checkbox_shells} = Wx::CheckBox->new($self, -1, L("Shells")); my $checkbox_shells = $self->{checkbox_shells} = Wx::CheckBox->new($self, -1, L("Shells"));
my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL); # my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL);
my $vsizer = Wx::BoxSizer->new(wxVERTICAL); # my $vsizer = Wx::BoxSizer->new(wxVERTICAL);
my $vsizer_outer = Wx::BoxSizer->new(wxVERTICAL); # my $vsizer_outer = Wx::BoxSizer->new(wxVERTICAL);
$vsizer->Add($slider_low, 3, wxALIGN_CENTER_HORIZONTAL, 0); # $vsizer->Add($slider_low, 3, wxALIGN_CENTER_HORIZONTAL, 0);
$vsizer->Add($z_label_low_idx, 0, wxALIGN_CENTER_HORIZONTAL, 0); # $vsizer->Add($z_label_low_idx, 0, wxALIGN_CENTER_HORIZONTAL, 0);
$vsizer->Add($z_label_low, 0, wxALIGN_CENTER_HORIZONTAL, 0); # $vsizer->Add($z_label_low, 0, wxALIGN_CENTER_HORIZONTAL, 0);
$hsizer->Add($vsizer, 0, wxEXPAND, 0); # $hsizer->Add($vsizer, 0, wxEXPAND, 0);
$vsizer = Wx::BoxSizer->new(wxVERTICAL); # $vsizer = Wx::BoxSizer->new(wxVERTICAL);
$vsizer->Add($slider_high, 3, wxALIGN_CENTER_HORIZONTAL, 0); # $vsizer->Add($slider_high, 3, wxALIGN_CENTER_HORIZONTAL, 0);
$vsizer->Add($z_label_high_idx, 0, wxALIGN_CENTER_HORIZONTAL, 0); # $vsizer->Add($z_label_high_idx, 0, wxALIGN_CENTER_HORIZONTAL, 0);
$vsizer->Add($z_label_high, 0, 0, 0); # $vsizer->Add($z_label_high, 0, 0, 0);
$hsizer->Add($vsizer, 0, wxEXPAND, 0); # $hsizer->Add($vsizer, 0, wxEXPAND, 0);
# **************** EXP ****************** # $vsizer_outer->Add($hsizer, 3, wxALIGN_CENTER_HORIZONTAL, 0);
$hsizer->Add($double_slider_sizer, 0, wxEXPAND, 0); # $vsizer_outer->Add($double_slider_sizer, 3, wxEXPAND, 0);
# **************** EXP ****************** # $vsizer_outer->Add($checkbox_singlelayer, 0, wxTOP | wxALIGN_CENTER_HORIZONTAL, 5);
$vsizer_outer->Add($hsizer, 3, wxALIGN_CENTER_HORIZONTAL, 0);
$vsizer_outer->Add($checkbox_singlelayer, 0, wxTOP | wxALIGN_CENTER_HORIZONTAL, 5);
my $bottom_sizer = Wx::BoxSizer->new(wxHORIZONTAL); my $bottom_sizer = Wx::BoxSizer->new(wxHORIZONTAL);
$bottom_sizer->Add($label_view_type, 0, wxALIGN_CENTER_VERTICAL, 5); $bottom_sizer->Add($label_view_type, 0, wxALIGN_CENTER_VERTICAL, 5);
@ -149,81 +145,83 @@ sub new {
my $sizer = Wx::BoxSizer->new(wxHORIZONTAL); my $sizer = Wx::BoxSizer->new(wxHORIZONTAL);
$sizer->Add($canvas, 1, wxALL | wxEXPAND, 0); $sizer->Add($canvas, 1, wxALL | wxEXPAND, 0);
$sizer->Add($vsizer_outer, 0, wxTOP | wxBOTTOM | wxEXPAND, 5); # $sizer->Add($vsizer_outer, 0, wxTOP | wxBOTTOM | wxEXPAND, 5);
$sizer->Add($double_slider_sizer, 0, wxEXPAND, 0);#wxTOP | wxBOTTOM | wxEXPAND, 5);
my $main_sizer = Wx::BoxSizer->new(wxVERTICAL); my $main_sizer = Wx::BoxSizer->new(wxVERTICAL);
$main_sizer->Add($sizer, 1, wxALL | wxEXPAND, 0); $main_sizer->Add($sizer, 1, wxALL | wxEXPAND, 0);
$main_sizer->Add($bottom_sizer, 0, wxALL | wxEXPAND, 0); $main_sizer->Add($bottom_sizer, 0, wxALL | wxEXPAND, 0);
EVT_SLIDER($self, $slider_low, sub { # EVT_SLIDER($self, $slider_low, sub {
$slider_high->SetValue($slider_low->GetValue) if $self->single_layer; # $slider_high->SetValue($slider_low->GetValue) if $self->single_layer;
$self->set_z_idx_low ($slider_low ->GetValue) # $self->set_z_idx_low ($slider_low ->GetValue)
}); # });
EVT_SLIDER($self, $slider_high, sub { # EVT_SLIDER($self, $slider_high, sub {
$slider_low->SetValue($slider_high->GetValue) if $self->single_layer; # $slider_low->SetValue($slider_high->GetValue) if $self->single_layer;
$self->set_z_idx_high($slider_high->GetValue) # $self->set_z_idx_high($slider_high->GetValue)
}); # });
EVT_KEY_DOWN($canvas, sub { # EVT_KEY_DOWN($canvas, sub {
my ($s, $event) = @_; # my ($s, $event) = @_;
my $key = $event->GetKeyCode; # Slic3r::GUI::update_double_slider_from_canvas($event);
if ($event->HasModifiers) { # my $key = $event->GetKeyCode;
$event->Skip; # if ($event->HasModifiers) {
} else { # $event->Skip;
if ($key == ord('U')) { # } else {
$slider_high->SetValue($slider_high->GetValue + 1); # if ($key == ord('U')) {
$slider_low->SetValue($slider_high->GetValue) if ($event->ShiftDown()); # $slider_high->SetValue($slider_high->GetValue + 1);
$self->set_z_idx_high($slider_high->GetValue); # $slider_low->SetValue($slider_high->GetValue) if ($event->ShiftDown());
} elsif ($key == ord('D')) { # $self->set_z_idx_high($slider_high->GetValue);
$slider_high->SetValue($slider_high->GetValue - 1); # } elsif ($key == ord('D')) {
$slider_low->SetValue($slider_high->GetValue) if ($event->ShiftDown()); # $slider_high->SetValue($slider_high->GetValue - 1);
$self->set_z_idx_high($slider_high->GetValue); # $slider_low->SetValue($slider_high->GetValue) if ($event->ShiftDown());
} elsif ($key == ord('S')) { # $self->set_z_idx_high($slider_high->GetValue);
$checkbox_singlelayer->SetValue(! $checkbox_singlelayer->GetValue()); # } elsif ($key == ord('S')) {
$self->single_layer($checkbox_singlelayer->GetValue()); # $checkbox_singlelayer->SetValue(! $checkbox_singlelayer->GetValue());
if ($self->single_layer) { # $self->single_layer($checkbox_singlelayer->GetValue());
$slider_low->SetValue($slider_high->GetValue); # if ($self->single_layer) {
$self->set_z_idx_high($slider_high->GetValue); # $slider_low->SetValue($slider_high->GetValue);
} # $self->set_z_idx_high($slider_high->GetValue);
} else { # }
$event->Skip; # } else {
} # $event->Skip;
} # }
}); # }
EVT_KEY_DOWN($slider_low, sub { # });
my ($s, $event) = @_; # EVT_KEY_DOWN($slider_low, sub {
my $key = $event->GetKeyCode; # my ($s, $event) = @_;
if ($event->HasModifiers) { # my $key = $event->GetKeyCode;
$event->Skip; # if ($event->HasModifiers) {
} else { # $event->Skip;
if ($key == WXK_LEFT) { # } else {
} elsif ($key == WXK_RIGHT) { # if ($key == WXK_LEFT) {
$slider_high->SetFocus; # } elsif ($key == WXK_RIGHT) {
} else { # $slider_high->SetFocus;
$event->Skip; # } else {
} # $event->Skip;
} # }
}); # }
EVT_KEY_DOWN($slider_high, sub { # });
my ($s, $event) = @_; # EVT_KEY_DOWN($slider_high, sub {
my $key = $event->GetKeyCode; # my ($s, $event) = @_;
if ($event->HasModifiers) { # my $key = $event->GetKeyCode;
$event->Skip; # if ($event->HasModifiers) {
} else { # $event->Skip;
if ($key == WXK_LEFT) { # } else {
$slider_low->SetFocus; # if ($key == WXK_LEFT) {
} elsif ($key == WXK_RIGHT) { # $slider_low->SetFocus;
} else { # } elsif ($key == WXK_RIGHT) {
$event->Skip; # } else {
} # $event->Skip;
} # }
}); # }
EVT_CHECKBOX($self, $checkbox_singlelayer, sub { # });
$self->single_layer($checkbox_singlelayer->GetValue()); # EVT_CHECKBOX($self, $checkbox_singlelayer, sub {
if ($self->single_layer) { # $self->single_layer($checkbox_singlelayer->GetValue());
$slider_low->SetValue($slider_high->GetValue); # if ($self->single_layer) {
$self->set_z_idx_high($slider_high->GetValue); # $slider_low->SetValue($slider_high->GetValue);
} # $self->set_z_idx_high($slider_high->GetValue);
}); # }
# });
EVT_CHOICE($self, $choice_view_type, sub { EVT_CHOICE($self, $choice_view_type, sub {
my $selection = $choice_view_type->GetCurrentSelection(); my $selection = $choice_view_type->GetCurrentSelection();
$self->{preferred_color_mode} = ($selection == $self->{tool_idx}) ? 'tool' : 'feature'; $self->{preferred_color_mode} = ($selection == $self->{tool_idx}) ? 'tool' : 'feature';
@ -253,6 +251,12 @@ sub new {
$self->refresh_print; $self->refresh_print;
}); });
EVT_SIZE($self, sub {
my ($s, $event) = @_;
$event->Skip;
$self->Refresh;
});
$self->SetSizer($main_sizer); $self->SetSizer($main_sizer);
$self->SetMinSize($self->GetSize); $self->SetMinSize($self->GetSize);
$sizer->SetSizeHints($self); $sizer->SetSizeHints($self);
@ -394,7 +398,6 @@ sub load_print {
} }
$self->update_sliders($n_layers) if ($n_layers > 0); $self->update_sliders($n_layers) if ($n_layers > 0);
Slic3r::GUI::update_double_slider($self->{force_sliders_full_range}) if ($n_layers > 0);
$self->_loaded(1); $self->_loaded(1);
} }
} }
@ -402,13 +405,13 @@ sub load_print {
sub reset_sliders { sub reset_sliders {
my ($self) = @_; my ($self) = @_;
$self->enabled(0); $self->enabled(0);
$self->set_z_range(0,0); # $self->set_z_range(0,0);
$self->slider_low->Hide; # $self->slider_low->Hide;
$self->slider_high->Hide; # $self->slider_high->Hide;
$self->{z_label_low}->SetLabel(""); # $self->{z_label_low}->SetLabel("");
$self->{z_label_high}->SetLabel(""); # $self->{z_label_high}->SetLabel("");
$self->{z_label_low_idx}->SetLabel(""); # $self->{z_label_low_idx}->SetLabel("");
$self->{z_label_high_idx}->SetLabel(""); # $self->{z_label_high_idx}->SetLabel("");
Slic3r::GUI::reset_double_slider(); Slic3r::GUI::reset_double_slider();
$self->double_slider_sizer->Hide(0); $self->double_slider_sizer->Hide(0);
@ -418,50 +421,51 @@ sub update_sliders
{ {
my ($self, $n_layers) = @_; my ($self, $n_layers) = @_;
my $z_idx_low = $self->slider_low->GetValue; # my $z_idx_low = $self->slider_low->GetValue;
my $z_idx_high = $self->slider_high->GetValue; # my $z_idx_high = $self->slider_high->GetValue;
$self->enabled(1); $self->enabled(1);
$self->slider_low->SetRange(0, $n_layers - 1); # $self->slider_low->SetRange(0, $n_layers - 1);
$self->slider_high->SetRange(0, $n_layers - 1); # $self->slider_high->SetRange(0, $n_layers - 1);
if ($self->{force_sliders_full_range}) { # if ($self->{force_sliders_full_range}) {
$z_idx_low = 0; # $z_idx_low = 0;
$z_idx_high = $n_layers - 1; # $z_idx_high = $n_layers - 1;
} elsif ($z_idx_high < $n_layers && ($self->single_layer || $z_idx_high != 0)) { # } elsif ($z_idx_high < $n_layers && ($self->single_layer || $z_idx_high != 0)) {
# search new indices for nearest z (size of $self->{layers_z} may change in dependence of what is shown) # # search new indices for nearest z (size of $self->{layers_z} may change in dependence of what is shown)
if (defined($self->{z_low})) { # if (defined($self->{z_low})) {
for (my $i = scalar(@{$self->{layers_z}}) - 1; $i >= 0; $i -= 1) { # for (my $i = scalar(@{$self->{layers_z}}) - 1; $i >= 0; $i -= 1) {
if ($self->{layers_z}[$i] <= $self->{z_low}) { # if ($self->{layers_z}[$i] <= $self->{z_low}) {
$z_idx_low = $i; # $z_idx_low = $i;
last; # last;
} # }
} # }
} # }
if (defined($self->{z_high})) { # if (defined($self->{z_high})) {
for (my $i = scalar(@{$self->{layers_z}}) - 1; $i >= 0; $i -= 1) { # for (my $i = scalar(@{$self->{layers_z}}) - 1; $i >= 0; $i -= 1) {
if ($self->{layers_z}[$i] <= $self->{z_high}) { # if ($self->{layers_z}[$i] <= $self->{z_high}) {
$z_idx_high = $i; # $z_idx_high = $i;
last; # last;
} # }
} # }
} # }
} elsif ($z_idx_high >= $n_layers) { # } elsif ($z_idx_high >= $n_layers) {
# Out of range. Disable 'single layer' view. # # Out of range. Disable 'single layer' view.
$self->single_layer(0); # $self->single_layer(0);
$self->{checkbox_singlelayer}->SetValue(0); # $self->{checkbox_singlelayer}->SetValue(0);
$z_idx_low = 0; # $z_idx_low = 0;
$z_idx_high = $n_layers - 1; # $z_idx_high = $n_layers - 1;
} else { # } else {
$z_idx_low = 0; # $z_idx_low = 0;
$z_idx_high = $n_layers - 1; # $z_idx_high = $n_layers - 1;
} # }
$self->slider_low->SetValue($z_idx_low); # $self->slider_low->SetValue($z_idx_low);
$self->slider_high->SetValue($z_idx_high); # $self->slider_high->SetValue($z_idx_high);
$self->slider_low->Show; # $self->slider_low->Show;
$self->slider_high->Show; # $self->slider_high->Show;
$self->set_z_range($self->{layers_z}[$z_idx_low], $self->{layers_z}[$z_idx_high]); # $self->set_z_range($self->{layers_z}[$z_idx_low], $self->{layers_z}[$z_idx_high]);
Slic3r::GUI::update_double_slider($self->{force_sliders_full_range});
$self->double_slider_sizer->Show(0); $self->double_slider_sizer->Show(0);
$self->Layout; $self->Layout;

View File

@ -1679,6 +1679,7 @@ void create_double_slider(wxWindow* parent, wxBoxSizer* sizer, wxGLCanvas* canva
sizer->Add(m_slider, 0, wxEXPAND, 0); sizer->Add(m_slider, 0, wxEXPAND, 0);
m_preview_canvas = canvas; m_preview_canvas = canvas;
m_preview_canvas->Bind(wxEVT_KEY_DOWN, update_double_slider_from_canvas);
m_slider->Bind(wxEVT_SCROLL_CHANGED, [parent](wxEvent& event) { m_slider->Bind(wxEVT_SCROLL_CHANGED, [parent](wxEvent& event) {
_3DScene::set_toolpaths_range(m_preview_canvas, m_slider->GetLowerValueD() - 1e-6, m_slider->GetHigherValueD() + 1e-6); _3DScene::set_toolpaths_range(m_preview_canvas, m_slider->GetLowerValueD() - 1e-6, m_slider->GetHigherValueD() + 1e-6);
@ -1710,7 +1711,9 @@ void set_double_slider_thumbs( const bool force_sliders_full_range,
const std::vector<double> &layers_z, const std::vector<double> &layers_z,
const double z_low, const double z_high) const double z_low, const double z_high)
{ {
if (force_sliders_full_range) { // Force slider full range only when slider is created.
// Support selected diapason on the all next steps
if (/*force_sliders_full_range*/z_high == 0.0) {
m_slider->SetLowerValue(0); m_slider->SetLowerValue(0);
m_slider->SetHigherValue(layers_z.size() - 1); m_slider->SetHigherValue(layers_z.size() - 1);
return; return;
@ -1748,5 +1751,25 @@ void reset_double_slider()
m_slider->SetLowerValue(0); m_slider->SetLowerValue(0);
} }
void update_double_slider_from_canvas(wxKeyEvent& event)
{
if (event.HasModifiers()) {
event.Skip();
return;
}
const auto key = event.GetKeyCode();
if (key == 'U' || key == 'D') {
const int new_pos = key == 'U' ? m_slider->GetHigherValue() + 1 : m_slider->GetHigherValue() - 1;
m_slider->SetHigherValue(new_pos);
if (event.ShiftDown()) m_slider->SetLowerValue(m_slider->GetHigherValue());
}
else if (key == 'S')
m_slider->ChangeOneLayerLock();
else
event.Skip();
}
} //namespace GUI } //namespace GUI
} //namespace Slic3r } //namespace Slic3r

View File

@ -126,6 +126,8 @@ void update_objects_list_extruder_column(int extruders_count);
void create_double_slider(wxWindow* parent, wxBoxSizer* sizer, wxGLCanvas* canvas); void create_double_slider(wxWindow* parent, wxBoxSizer* sizer, wxGLCanvas* canvas);
void update_double_slider(bool force_sliders_full_range); void update_double_slider(bool force_sliders_full_range);
void reset_double_slider(); void reset_double_slider();
// update DoubleSlider after keyDown in canvas
void update_double_slider_from_canvas(wxKeyEvent& event);
} //namespace GUI } //namespace GUI
} //namespace Slic3r } //namespace Slic3r

View File

@ -829,7 +829,9 @@ wxSize PrusaDoubleSlider::DoGetBestSize() const
void PrusaDoubleSlider::SetLowerValue(const int lower_val) void PrusaDoubleSlider::SetLowerValue(const int lower_val)
{ {
m_selection = ssLower;
m_lower_value = lower_val; m_lower_value = lower_val;
correct_lower_value();
Refresh(); Refresh();
Update(); Update();
@ -840,7 +842,9 @@ void PrusaDoubleSlider::SetLowerValue(const int lower_val)
void PrusaDoubleSlider::SetHigherValue(const int higher_val) void PrusaDoubleSlider::SetHigherValue(const int higher_val)
{ {
m_selection = ssHigher;
m_higher_value = higher_val; m_higher_value = higher_val;
correct_higher_value();
Refresh(); Refresh();
Update(); Update();
@ -1193,6 +1197,20 @@ bool PrusaDoubleSlider::is_point_in_rect(const wxPoint& pt, const wxRect& rect)
return false; return false;
} }
void PrusaDoubleSlider::ChangeOneLayerLock()
{
m_is_one_layer = !m_is_one_layer;
m_selection == ssLower ? correct_lower_value() : correct_higher_value();
if (!m_selection) m_selection = ssHigher;
Refresh();
Update();
wxCommandEvent e(wxEVT_SCROLL_CHANGED);
e.SetEventObject(this);
ProcessWindowEvent(e);
}
void PrusaDoubleSlider::OnLeftDown(wxMouseEvent& event) void PrusaDoubleSlider::OnLeftDown(wxMouseEvent& event)
{ {
this->CaptureMouse(); this->CaptureMouse();

View File

@ -540,6 +540,7 @@ public:
void SetSliderValues(const std::vector<std::pair<int, double>>& values) { void SetSliderValues(const std::vector<std::pair<int, double>>& values) {
m_values = values; m_values = values;
} }
void ChangeOneLayerLock();
void OnPaint(wxPaintEvent& ){ render();} void OnPaint(wxPaintEvent& ){ render();}
void OnLeftDown(wxMouseEvent& event); void OnLeftDown(wxMouseEvent& event);