mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 02:55:55 +08:00
Fixes and improvements to the view selection menu
This commit is contained in:
parent
5242b3e03a
commit
a7693c4719
@ -55,7 +55,7 @@ use constant HAS_VBO => 1;
|
||||
|
||||
|
||||
# phi / theta angles to orient the camera.
|
||||
use constant VIEW_DEFAULT => [45.0,45.0];
|
||||
use constant VIEW_ISO => [45.0,45.0];
|
||||
use constant VIEW_LEFT => [90.0,90.0];
|
||||
use constant VIEW_RIGHT => [-90.0,90.0];
|
||||
use constant VIEW_TOP => [0.0,0.0];
|
||||
@ -63,7 +63,7 @@ use constant VIEW_BOTTOM => [0.0,180.0];
|
||||
use constant VIEW_FRONT => [0.0,90.0];
|
||||
use constant VIEW_REAR => [180.0,90.0];
|
||||
|
||||
use constant GIMBALL_LOCK_THETA_MAX => 170;
|
||||
use constant GIMBAL_LOCK_THETA_MAX => 170;
|
||||
|
||||
# make OpenGL::Array thread-safe
|
||||
{
|
||||
@ -254,7 +254,7 @@ sub mouse_event {
|
||||
if (TURNTABLE_MODE) {
|
||||
$self->_sphi($self->_sphi + ($pos->x - $orig->x) * TRACKBALLSIZE);
|
||||
$self->_stheta($self->_stheta - ($pos->y - $orig->y) * TRACKBALLSIZE); #-
|
||||
$self->_stheta(GIMBALL_LOCK_THETA_MAX) if $self->_stheta > GIMBALL_LOCK_THETA_MAX;
|
||||
$self->_stheta(GIMBAL_LOCK_THETA_MAX) if $self->_stheta > GIMBAL_LOCK_THETA_MAX;
|
||||
$self->_stheta(0) if $self->_stheta < 0;
|
||||
} else {
|
||||
my $size = $self->GetClientSize;
|
||||
@ -336,8 +336,8 @@ sub select_view {
|
||||
if (ref($direction)) {
|
||||
$dirvec = $direction;
|
||||
} else {
|
||||
if ($direction eq 'default') {
|
||||
$dirvec = VIEW_DEFAULT;
|
||||
if ($direction eq 'iso') {
|
||||
$dirvec = VIEW_ISO;
|
||||
} elsif ($direction eq 'left') {
|
||||
$dirvec = VIEW_LEFT;
|
||||
} elsif ($direction eq 'right') {
|
||||
@ -354,12 +354,18 @@ sub select_view {
|
||||
}
|
||||
$self->_sphi($dirvec->[0]);
|
||||
$self->_stheta($dirvec->[1]);
|
||||
# Avoid gimball lock.
|
||||
$self->_stheta(GIMBALL_LOCK_THETA_MAX) if $self->_stheta > GIMBALL_LOCK_THETA_MAX;
|
||||
|
||||
# Avoid gimbal lock.
|
||||
$self->_stheta(GIMBAL_LOCK_THETA_MAX) if $self->_stheta > GIMBAL_LOCK_THETA_MAX;
|
||||
$self->_stheta(0) if $self->_stheta < 0;
|
||||
|
||||
# View everything.
|
||||
$self->zoom_to_volumes;
|
||||
$self->volumes_bounding_box->defined
|
||||
? $self->zoom_to_volumes
|
||||
: $self->zoom_to_bed;
|
||||
|
||||
$self->on_viewport_changed->() if $self->on_viewport_changed;
|
||||
$self->_dirty(1);
|
||||
$self->Refresh;
|
||||
}
|
||||
|
||||
@ -368,7 +374,7 @@ sub zoom_to_bounding_box {
|
||||
|
||||
# calculate the zoom factor needed to adjust viewport to
|
||||
# bounding box
|
||||
my $max_size = max(@{$bb->size}) * 2;
|
||||
my $max_size = max(@{$bb->size}) * 1.05;
|
||||
my $min_viewport_size = min($self->GetSizeWH);
|
||||
$self->_zoom($min_viewport_size / $max_size);
|
||||
|
||||
|
@ -290,7 +290,7 @@ sub _init_menubar {
|
||||
# View menu
|
||||
if (!$self->{no_plater}) {
|
||||
$self->{viewMenu} = Wx::Menu->new;
|
||||
$self->_append_menu_item($self->{viewMenu}, "Default", 'Default View', sub { $self->select_view('default'); });
|
||||
$self->_append_menu_item($self->{viewMenu}, "Iso" , 'Iso View' , sub { $self->select_view('iso' ); });
|
||||
$self->_append_menu_item($self->{viewMenu}, "Top" , 'Top View' , sub { $self->select_view('top' ); });
|
||||
$self->_append_menu_item($self->{viewMenu}, "Bottom" , 'Bottom View' , sub { $self->select_view('bottom' ); });
|
||||
$self->_append_menu_item($self->{viewMenu}, "Front" , 'Front View' , sub { $self->select_view('front' ); });
|
||||
|
@ -26,6 +26,7 @@
|
||||
long x_max() %code{% RETVAL = THIS->max.x; %};
|
||||
long y_min() %code{% RETVAL = THIS->min.y; %};
|
||||
long y_max() %code{% RETVAL = THIS->max.y; %};
|
||||
bool defined() %code{% RETVAL = THIS->defined; %};
|
||||
|
||||
%{
|
||||
|
||||
@ -63,6 +64,7 @@ new_from_points(CLASS, points)
|
||||
void set_x_max(double val) %code{% THIS->max.x = val; %};
|
||||
void set_y_min(double val) %code{% THIS->min.y = val; %};
|
||||
void set_y_max(double val) %code{% THIS->max.y = val; %};
|
||||
bool defined() %code{% RETVAL = THIS->defined; %};
|
||||
|
||||
%{
|
||||
|
||||
@ -97,4 +99,5 @@ new_from_points(CLASS, points)
|
||||
double y_max() %code{% RETVAL = THIS->max.y; %};
|
||||
double z_min() %code{% RETVAL = THIS->min.z; %};
|
||||
double z_max() %code{% RETVAL = THIS->max.z; %};
|
||||
bool defined() %code{% RETVAL = THIS->defined; %};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user