From ad99b2a0fdb42ece84785d055b48e7606856b36f Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Thu, 15 May 2014 16:37:18 +0200 Subject: [PATCH] Fixed one more regression introduced with Model refactoring. Includes regression test --- lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm | 2 +- xs/MANIFEST | 1 + xs/t/19_model.t | 18 ++++++++++++++++++ xs/xsp/Model.xsp | 8 ++++---- 4 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 xs/t/19_model.t diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index 5713acaba..e61ccfcce 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -197,7 +197,7 @@ sub on_btn_load { foreach my $object (@{$model->objects}) { foreach my $volume (@{$object->volumes}) { my $new_volume = $self->{model_object}->add_volume($volume); - $new_volume->modifier($is_modifier); + $new_volume->set_modifier($is_modifier); if (!defined $new_volume->material_id) { # it looks like this block is never entered because all input volumes seem to have an assigned material # TODO: check we can assume that for any input format diff --git a/xs/MANIFEST b/xs/MANIFEST index d8334bcd8..7cfc00572 100644 --- a/xs/MANIFEST +++ b/xs/MANIFEST @@ -1732,6 +1732,7 @@ t/14_geometry.t t/15_config.t t/16_flow.t t/17_boundingbox.t +t/19_model.t xsp/BoundingBox.xsp xsp/Clipper.xsp xsp/Config.xsp diff --git a/xs/t/19_model.t b/xs/t/19_model.t new file mode 100644 index 000000000..ad0962de9 --- /dev/null +++ b/xs/t/19_model.t @@ -0,0 +1,18 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Slic3r::XS; +use Test::More tests => 3; + +{ + my $model = Slic3r::Model->new; + my $object = $model->_add_object; + isa_ok $object, 'Slic3r::Model::Object::Ref'; + isa_ok $object->origin_translation, 'Slic3r::Pointf::Ref'; + $object->origin_translation->translate(10,0); + is_deeply \@{$object->origin_translation}, [10,0], 'origin_translation is modified by ref'; +} + +__END__ diff --git a/xs/xsp/Model.xsp b/xs/xsp/Model.xsp index 5903994ca..798169cc5 100644 --- a/xs/xsp/Model.xsp +++ b/xs/xsp/Model.xsp @@ -151,8 +151,8 @@ ModelMaterial::attributes() void set_layer_height_ranges(t_layer_height_ranges ranges) %code%{ THIS->layer_height_ranges = ranges; %}; - Clone origin_translation() - %code%{ RETVAL = THIS->origin_translation; %}; + Ref origin_translation() + %code%{ RETVAL = &THIS->origin_translation; %}; void set_origin_translation(Pointf* point) %code%{ THIS->origin_translation = *point; %}; }; @@ -185,8 +185,8 @@ ModelMaterial::attributes() %code%{ RETVAL = THIS->rotation; %}; double scaling_factor() %code%{ RETVAL = THIS->scaling_factor; %}; - Clone offset() - %code%{ RETVAL = THIS->offset; %}; + Ref offset() + %code%{ RETVAL = &THIS->offset; %}; void set_rotation(double val) %code%{ THIS->rotation = val; %};