Fixes and improvements to the view selection menu, cherry picked from @alexrj a7693c4719c0e0e0129aea7461706d2ed53a52cc
This commit is contained in:
parent
d628764da6
commit
9e8dae817d
@ -74,7 +74,7 @@ use constant SELECTED_COLOR => [0,1,0,1];
|
|||||||
use constant HOVER_COLOR => [0.4,0.9,0,1];
|
use constant HOVER_COLOR => [0.4,0.9,0,1];
|
||||||
|
|
||||||
# phi / theta angles to orient the camera.
|
# 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_LEFT => [90.0,90.0];
|
||||||
use constant VIEW_RIGHT => [-90.0,90.0];
|
use constant VIEW_RIGHT => [-90.0,90.0];
|
||||||
use constant VIEW_TOP => [0.0,0.0];
|
use constant VIEW_TOP => [0.0,0.0];
|
||||||
@ -82,8 +82,7 @@ use constant VIEW_BOTTOM => [0.0,180.0];
|
|||||||
use constant VIEW_FRONT => [0.0,90.0];
|
use constant VIEW_FRONT => [0.0,90.0];
|
||||||
use constant VIEW_REAR => [180.0,90.0];
|
use constant VIEW_REAR => [180.0,90.0];
|
||||||
|
|
||||||
#use constant GIMBALL_LOCK_THETA_MAX => 150;
|
use constant GIMBAL_LOCK_THETA_MAX => 170;
|
||||||
use constant GIMBALL_LOCK_THETA_MAX => 170;
|
|
||||||
|
|
||||||
# make OpenGL::Array thread-safe
|
# make OpenGL::Array thread-safe
|
||||||
{
|
{
|
||||||
@ -257,7 +256,7 @@ sub mouse_event {
|
|||||||
if (TURNTABLE_MODE) {
|
if (TURNTABLE_MODE) {
|
||||||
$self->_sphi($self->_sphi + ($pos->x - $orig->x) * TRACKBALLSIZE);
|
$self->_sphi($self->_sphi + ($pos->x - $orig->x) * TRACKBALLSIZE);
|
||||||
$self->_stheta($self->_stheta - ($pos->y - $orig->y) * 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;
|
$self->_stheta(0) if $self->_stheta < 0;
|
||||||
} else {
|
} else {
|
||||||
my $size = $self->GetClientSize;
|
my $size = $self->GetClientSize;
|
||||||
@ -341,8 +340,8 @@ sub select_view {
|
|||||||
if (ref($direction)) {
|
if (ref($direction)) {
|
||||||
$dirvec = $direction;
|
$dirvec = $direction;
|
||||||
} else {
|
} else {
|
||||||
if ($direction eq 'default') {
|
if ($direction eq 'iso') {
|
||||||
$dirvec = VIEW_DEFAULT;
|
$dirvec = VIEW_ISO;
|
||||||
} elsif ($direction eq 'left') {
|
} elsif ($direction eq 'left') {
|
||||||
$dirvec = VIEW_LEFT;
|
$dirvec = VIEW_LEFT;
|
||||||
} elsif ($direction eq 'right') {
|
} elsif ($direction eq 'right') {
|
||||||
@ -357,18 +356,22 @@ sub select_view {
|
|||||||
$dirvec = VIEW_REAR;
|
$dirvec = VIEW_REAR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my $bb = $self->volumes_bounding_box;
|
|
||||||
if (! $bb->empty) {
|
$self->_sphi($dirvec->[0]);
|
||||||
$self->_sphi($dirvec->[0]);
|
$self->_stheta($dirvec->[1]);
|
||||||
$self->_stheta($dirvec->[1]);
|
|
||||||
# Avoid gimball lock.
|
# Avoid gimbal lock.
|
||||||
$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;
|
$self->_stheta(0) if $self->_stheta < 0;
|
||||||
# View everything.
|
|
||||||
$self->zoom_to_bounding_box($bb);
|
# View everything.
|
||||||
$self->on_viewport_changed->() if $self->on_viewport_changed;
|
$self->volumes_bounding_box->defined
|
||||||
$self->Refresh;
|
? $self->zoom_to_volumes
|
||||||
}
|
: $self->zoom_to_bed;
|
||||||
|
|
||||||
|
$self->on_viewport_changed->() if $self->on_viewport_changed;
|
||||||
|
$self->_dirty(1);
|
||||||
|
$self->Refresh;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub zoom_to_bounding_box {
|
sub zoom_to_bounding_box {
|
||||||
@ -377,7 +380,7 @@ sub zoom_to_bounding_box {
|
|||||||
|
|
||||||
# calculate the zoom factor needed to adjust viewport to
|
# calculate the zoom factor needed to adjust viewport to
|
||||||
# bounding box
|
# bounding box
|
||||||
my $max_size = max(@{$bb->size}) * 2;
|
my $max_size = max(@{$bb->size}) * 1.05;
|
||||||
my $min_viewport_size = min($self->GetSizeWH);
|
my $min_viewport_size = min($self->GetSizeWH);
|
||||||
$self->_zoom($min_viewport_size / $max_size);
|
$self->_zoom($min_viewport_size / $max_size);
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ sub _init_menubar {
|
|||||||
# View menu
|
# View menu
|
||||||
if (!$self->{no_plater}) {
|
if (!$self->{no_plater}) {
|
||||||
$self->{viewMenu} = Wx::Menu->new;
|
$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}, "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}, "Bottom" , 'Bottom View' , sub { $self->select_view('bottom' ); });
|
||||||
$self->_append_menu_item($self->{viewMenu}, "Front" , 'Front View' , sub { $self->select_view('front' ); });
|
$self->_append_menu_item($self->{viewMenu}, "Front" , 'Front View' , sub { $self->select_view('front' ); });
|
||||||
|
@ -30,7 +30,8 @@
|
|||||||
long y_min() %code{% RETVAL = THIS->min.y; %};
|
long y_min() %code{% RETVAL = THIS->min.y; %};
|
||||||
long y_max() %code{% RETVAL = THIS->max.y; %};
|
long y_max() %code{% RETVAL = THIS->max.y; %};
|
||||||
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld;%ld,%ld", THIS->min.x, THIS->min.y, THIS->max.x, THIS->max.y); RETVAL = buf; %};
|
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld;%ld,%ld", THIS->min.x, THIS->min.y, THIS->max.x, THIS->max.y); RETVAL = buf; %};
|
||||||
|
bool defined() %code{% RETVAL = THIS->defined; %};
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
|
||||||
BoundingBox*
|
BoundingBox*
|
||||||
@ -69,7 +70,8 @@ new_from_points(CLASS, points)
|
|||||||
void set_y_min(double val) %code{% THIS->min.y = val; %};
|
void set_y_min(double val) %code{% THIS->min.y = val; %};
|
||||||
void set_y_max(double val) %code{% THIS->max.y = val; %};
|
void set_y_max(double val) %code{% THIS->max.y = val; %};
|
||||||
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf;%lf,%lf", THIS->min.x, THIS->min.y, THIS->max.x, THIS->max.y); RETVAL = buf; %};
|
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf;%lf,%lf", THIS->min.x, THIS->min.y, THIS->max.x, THIS->max.y); RETVAL = buf; %};
|
||||||
|
bool defined() %code{% RETVAL = THIS->defined; %};
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
|
||||||
BoundingBoxf*
|
BoundingBoxf*
|
||||||
@ -106,4 +108,5 @@ new_from_points(CLASS, points)
|
|||||||
double z_min() %code{% RETVAL = THIS->min.z; %};
|
double z_min() %code{% RETVAL = THIS->min.z; %};
|
||||||
double z_max() %code{% RETVAL = THIS->max.z; %};
|
double z_max() %code{% RETVAL = THIS->max.z; %};
|
||||||
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf,%lf;%lf,%lf,%lf", THIS->min.x, THIS->min.y, THIS->min.z, THIS->max.x, THIS->max.y, THIS->max.z); RETVAL = buf; %};
|
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf,%lf;%lf,%lf,%lf", THIS->min.x, THIS->min.y, THIS->min.z, THIS->max.x, THIS->max.y, THIS->max.z); RETVAL = buf; %};
|
||||||
|
bool defined() %code{% RETVAL = THIS->defined; %};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user