mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-07 06:39:05 +08:00
Fixed z layers indices under 3D preview sliders
This commit is contained in:
parent
5224acad59
commit
0584990b65
@ -2192,10 +2192,8 @@ sub reset_legend_texture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub get_current_print_zs {
|
sub get_current_print_zs {
|
||||||
my ($self) = @_;
|
my ($self, $active_only) = @_;
|
||||||
|
return $self->volumes->get_current_print_zs($active_only);
|
||||||
my $count = $self->volumes->get_current_print_zs();
|
|
||||||
return $count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -380,7 +380,7 @@ sub load_print {
|
|||||||
$self->show_hide_ui_elements('full');
|
$self->show_hide_ui_elements('full');
|
||||||
|
|
||||||
# recalculates zs and update sliders accordingly
|
# recalculates zs and update sliders accordingly
|
||||||
$self->{layers_z} = $self->canvas->get_current_print_zs();
|
$self->{layers_z} = $self->canvas->get_current_print_zs(1);
|
||||||
$n_layers = scalar(@{$self->{layers_z}});
|
$n_layers = scalar(@{$self->{layers_z}});
|
||||||
if ($n_layers == 0) {
|
if ($n_layers == 0) {
|
||||||
# all layers filtered out
|
# all layers filtered out
|
||||||
@ -465,10 +465,21 @@ sub set_z_range
|
|||||||
$self->{z_high} = $z_high;
|
$self->{z_high} = $z_high;
|
||||||
$self->{z_label_low}->SetLabel(sprintf '%.2f', $z_low);
|
$self->{z_label_low}->SetLabel(sprintf '%.2f', $z_low);
|
||||||
$self->{z_label_high}->SetLabel(sprintf '%.2f', $z_high);
|
$self->{z_label_high}->SetLabel(sprintf '%.2f', $z_high);
|
||||||
my $z_idx_low = 1 + $self->slider_low->GetValue;
|
|
||||||
my $z_idx_high = 1 + $self->slider_high->GetValue;
|
my $layers_z = $self->canvas->get_current_print_zs(0);
|
||||||
$self->{z_label_low_idx}->SetLabel(sprintf '%d', $z_idx_low);
|
for (my $i = 0; $i < scalar(@{$layers_z}); $i += 1) {
|
||||||
$self->{z_label_high_idx}->SetLabel(sprintf '%d', $z_idx_high);
|
if (($z_low - 1e-6 < @{$layers_z}[$i]) && (@{$layers_z}[$i] < $z_low + 1e-6)) {
|
||||||
|
$self->{z_label_low_idx}->SetLabel(sprintf '%d', $i + 1);
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (my $i = 0; $i < scalar(@{$layers_z}); $i += 1) {
|
||||||
|
if (($z_high - 1e-6 < @{$layers_z}[$i]) && (@{$layers_z}[$i] < $z_high + 1e-6)) {
|
||||||
|
$self->{z_label_high_idx}->SetLabel(sprintf '%d', $i + 1);
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$self->canvas->set_toolpaths_range($z_low - 1e-6, $z_high + 1e-6);
|
$self->canvas->set_toolpaths_range($z_low - 1e-6, $z_high + 1e-6);
|
||||||
$self->canvas->Refresh if $self->IsShown;
|
$self->canvas->Refresh if $self->IsShown;
|
||||||
}
|
}
|
||||||
|
@ -760,13 +760,13 @@ void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<double> GLVolumeCollection::get_current_print_zs() const
|
std::vector<double> GLVolumeCollection::get_current_print_zs(bool active_only) const
|
||||||
{
|
{
|
||||||
// Collect layer top positions of all volumes.
|
// Collect layer top positions of all volumes.
|
||||||
std::vector<double> print_zs;
|
std::vector<double> print_zs;
|
||||||
for (GLVolume *vol : this->volumes)
|
for (GLVolume *vol : this->volumes)
|
||||||
{
|
{
|
||||||
if (vol->is_active)
|
if (!active_only || vol->is_active)
|
||||||
append(print_zs, vol->print_zs);
|
append(print_zs, vol->print_zs);
|
||||||
}
|
}
|
||||||
std::sort(print_zs.begin(), print_zs.end());
|
std::sort(print_zs.begin(), print_zs.end());
|
||||||
|
@ -428,7 +428,7 @@ public:
|
|||||||
void update_colors_by_extruder(const DynamicPrintConfig* config);
|
void update_colors_by_extruder(const DynamicPrintConfig* config);
|
||||||
|
|
||||||
// Returns a vector containing the sorted list of all the print_zs of the volumes contained in this collection
|
// Returns a vector containing the sorted list of all the print_zs of the volumes contained in this collection
|
||||||
std::vector<double> get_current_print_zs() const;
|
std::vector<double> get_current_print_zs(bool active_only) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLVolumeCollection(const GLVolumeCollection &other);
|
GLVolumeCollection(const GLVolumeCollection &other);
|
||||||
|
@ -92,9 +92,8 @@
|
|||||||
int count()
|
int count()
|
||||||
%code{% RETVAL = THIS->volumes.size(); %};
|
%code{% RETVAL = THIS->volumes.size(); %};
|
||||||
|
|
||||||
std::vector<double> get_current_print_zs()
|
std::vector<double> get_current_print_zs(bool active_only)
|
||||||
%code{% RETVAL = THIS->get_current_print_zs(); %};
|
%code{% RETVAL = THIS->get_current_print_zs(active_only); %};
|
||||||
|
|
||||||
|
|
||||||
void set_range(double low, double high);
|
void set_range(double low, double high);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user