Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Turri <enricoturri@seznam.cz>2018-06-19 10:46:26 +0300
committerEnrico Turri <enricoturri@seznam.cz>2018-06-19 10:46:26 +0300
commitb9ce19b07c005e6ffc1ed4c2136c34008ef3e797 (patch)
tree7f525505539a913a6b1e50c88c61c3101e147c06 /lib/Slic3r/GUI
parenta3949b9f01f60ad3f0543de270f4dc662f6c9249 (diff)
Object updated by rotate gizmo
Diffstat (limited to 'lib/Slic3r/GUI')
-rw-r--r--lib/Slic3r/GUI/Plater.pm20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm
index d1ccf07d5..0185749a3 100644
--- a/lib/Slic3r/GUI/Plater.pm
+++ b/lib/Slic3r/GUI/Plater.pm
@@ -14,6 +14,7 @@ use Wx qw(:button :colour :cursor :dialog :filedialog :keycode :icon :font :id :
use Wx::Event qw(EVT_BUTTON EVT_TOGGLEBUTTON EVT_COMMAND EVT_KEY_DOWN EVT_LIST_ITEM_ACTIVATED
EVT_LIST_ITEM_DESELECTED EVT_LIST_ITEM_SELECTED EVT_LEFT_DOWN EVT_MOUSE_EVENTS EVT_PAINT EVT_TOOL
EVT_CHOICE EVT_COMBOBOX EVT_TIMER EVT_NOTEBOOK_PAGE_CHANGED);
+use Slic3r::Geometry qw(PI);
use base 'Wx::Panel';
use constant TB_ADD => &Wx::NewId;
@@ -134,6 +135,12 @@ sub new {
$self->schedule_background_process;
};
+ # callback to react to gizmo rotate
+ my $on_gizmo_rotate = sub {
+ my ($angle_z) = @_;
+ $self->rotate(rad2deg($angle_z), Z, 'absolute');
+ };
+
# Initialize 3D plater
if ($Slic3r::GUI::have_OpenGL) {
$self->{canvas3D} = Slic3r::GUI::Plater::3D->new($self->{preview_notebook}, $self->{objects}, $self->{model}, $self->{print}, $self->{config});
@@ -151,6 +158,7 @@ sub new {
Slic3r::GUI::_3DScene::register_on_instance_moved_callback($self->{canvas3D}, $on_instances_moved);
Slic3r::GUI::_3DScene::register_on_enable_action_buttons_callback($self->{canvas3D}, $enable_action_buttons);
Slic3r::GUI::_3DScene::register_on_gizmo_scale_uniformly_callback($self->{canvas3D}, $on_gizmo_scale_uniformly);
+ Slic3r::GUI::_3DScene::register_on_gizmo_rotate_callback($self->{canvas3D}, $on_gizmo_rotate);
Slic3r::GUI::_3DScene::enable_gizmos($self->{canvas3D}, 1);
Slic3r::GUI::_3DScene::enable_shader($self->{canvas3D}, 1);
Slic3r::GUI::_3DScene::enable_force_zoom_to_bed($self->{canvas3D}, 1);
@@ -1060,7 +1068,17 @@ sub rotate {
if ($axis == Z) {
my $new_angle = deg2rad($angle);
- $_->set_rotation(($relative ? $_->rotation : 0.) + $new_angle) for @{ $model_object->instances };
+ foreach my $inst (@{ $model_object->instances }) {
+ my $rotation = ($relative ? $inst->rotation : 0.) + $new_angle;
+ while ($rotation > 2.0 * PI) {
+ $rotation -= 2.0 * PI;
+ }
+ while ($rotation < 0.0) {
+ $rotation += 2.0 * PI;
+ }
+ $inst->set_rotation($rotation);
+ Slic3r::GUI::_3DScene::update_gizmos_data($self->{canvas3D}) if ($self->{canvas3D});
+ }
$object->transform_thumbnail($self->{model}, $obj_idx);
} else {
# rotation around X and Y needs to be performed on mesh