mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	class 3D callbacks moved to c++
This commit is contained in:
		
							parent
							
								
									ff86407840
								
							
						
					
					
						commit
						a8500d6bae
					
				
					 11 changed files with 250 additions and 92 deletions
				
			
		|  | @ -126,7 +126,8 @@ sub new { | |||
|         Slic3r::GUI::_3DScene::register_on_scale_object_uniformly_callback($self->{canvas3D}, sub { $self->changescale(undef) }); | ||||
|         Slic3r::GUI::_3DScene::register_on_increase_objects_callback($self->{canvas3D}, sub { $self->increase() }); | ||||
|         Slic3r::GUI::_3DScene::register_on_decrease_objects_callback($self->{canvas3D}, sub { $self->decrease() }); | ||||
|         Slic3r::GUI::_3DScene::register_on_remove_object_callback($self->{canvas3D}, sub { $self->remove() });         | ||||
|         Slic3r::GUI::_3DScene::register_on_remove_object_callback($self->{canvas3D}, sub { $self->remove() }); | ||||
|         Slic3r::GUI::_3DScene::register_on_instance_moved_callback($self->{canvas3D}, $on_instances_moved); | ||||
| #        $self->{canvas3D}->set_on_double_click($on_double_click); | ||||
| #        $self->{canvas3D}->set_on_right_click(sub { $on_right_click->($self->{canvas3D}, @_); }); | ||||
| #        $self->{canvas3D}->set_on_arrange(sub { $self->arrange }); | ||||
|  | @ -136,21 +137,29 @@ sub new { | |||
| #        $self->{canvas3D}->set_on_increase_objects(sub { $self->increase() }); | ||||
| #        $self->{canvas3D}->set_on_decrease_objects(sub { $self->decrease() }); | ||||
| #        $self->{canvas3D}->set_on_remove_object(sub { $self->remove() }); | ||||
| #        $self->{canvas3D}->set_on_instances_moved($on_instances_moved); | ||||
| #============================================================================================================================== | ||||
|         $self->{canvas3D}->set_on_instances_moved($on_instances_moved); | ||||
|         $self->{canvas3D}->set_on_enable_action_buttons($enable_action_buttons); | ||||
| #===================================================================================================================================         | ||||
|         Slic3r::GUI::_3DScene::enable_shader($self->{canvas3D}, 1); | ||||
|         Slic3r::GUI::_3DScene::enable_force_zoom_to_bed($self->{canvas3D}, 1); | ||||
| #        $self->{canvas3D}->use_plain_shader(1); | ||||
| #===================================================================================================================================         | ||||
|         $self->{canvas3D}->set_on_wipe_tower_moved(sub { | ||||
|             my ($new_pos_3f) = @_; | ||||
|         Slic3r::GUI::_3DScene::register_on_wipe_tower_moved_callback($self->{canvas3D}, sub { | ||||
|             my ($x, $y) = @_; | ||||
|             my $cfg = Slic3r::Config->new; | ||||
|             $cfg->set('wipe_tower_x', $new_pos_3f->x); | ||||
|             $cfg->set('wipe_tower_y', $new_pos_3f->y); | ||||
|             $cfg->set('wipe_tower_x', $x); | ||||
|             $cfg->set('wipe_tower_y', $y); | ||||
|             $self->GetFrame->{options_tabs}{print}->load_config($cfg); | ||||
|         }); | ||||
| 
 | ||||
| #        $self->{canvas3D}->set_on_wipe_tower_moved(sub { | ||||
| #            my ($new_pos_3f) = @_; | ||||
| #            my $cfg = Slic3r::Config->new; | ||||
| #            $cfg->set('wipe_tower_x', $new_pos_3f->x); | ||||
| #            $cfg->set('wipe_tower_y', $new_pos_3f->y); | ||||
| #            $self->GetFrame->{options_tabs}{print}->load_config($cfg); | ||||
| #        }); | ||||
| #============================================================================================================================== | ||||
|         Slic3r::GUI::_3DScene::register_on_model_update_callback($self->{canvas3D}, sub { | ||||
|             if (wxTheApp->{app_config}->get("background_processing")) { | ||||
|  |  | |||
|  | @ -13,9 +13,7 @@ use base qw(Slic3r::GUI::3DScene Class::Accessor); | |||
| use Wx::Locale gettext => 'L'; | ||||
| 
 | ||||
| #============================================================================================================================== | ||||
| __PACKAGE__->mk_accessors(qw( | ||||
|     on_rotate_object_left on_rotate_object_right on_scale_object_uniformly | ||||
|     on_remove_object on_increase_objects on_decrease_objects on_enable_action_buttons)); | ||||
| __PACKAGE__->mk_accessors(qw(on_enable_action_buttons)); | ||||
| #__PACKAGE__->mk_accessors(qw( | ||||
| #    on_arrange on_rotate_object_left on_rotate_object_right on_scale_object_uniformly | ||||
| #    on_remove_object on_increase_objects on_decrease_objects on_enable_action_buttons)); | ||||
|  | @ -44,12 +42,15 @@ sub new { | |||
| #============================================================================================================================== | ||||
|     $self->{config}             = $config; | ||||
| #============================================================================================================================== | ||||
|     Slic3r::GUI::_3DScene::set_model($self, $model); | ||||
|     Slic3r::GUI::_3DScene::set_print($self, $print); | ||||
|     Slic3r::GUI::_3DScene::set_config($self, $config); | ||||
| #============================================================================================================================== | ||||
|     $self->{on_select_object}   = sub {}; | ||||
|     $self->{on_instances_moved} = sub {}; | ||||
|     $self->{on_wipe_tower_moved} = sub {}; | ||||
| #============================================================================================================================== | ||||
| #    $self->{on_instances_moved} = sub {}; | ||||
| #    $self->{on_wipe_tower_moved} = sub {}; | ||||
| #============================================================================================================================== | ||||
| 
 | ||||
|     $self->{objects_volumes_idxs} = []; | ||||
|          | ||||
|  | @ -64,44 +65,39 @@ sub new { | |||
| #        $self->{on_select_object}->(($volume_idx == -1) ? undef : $self->volumes->[$volume_idx]->object_idx) | ||||
| #            if ($self->{on_select_object}); | ||||
| #    }); | ||||
| #============================================================================================================================== | ||||
| 
 | ||||
| #============================================================================================================================== | ||||
|     Slic3r::GUI::_3DScene::register_on_move_callback($self, sub { | ||||
| # | ||||
| #    $self->on_move(sub { | ||||
| #============================================================================================================================== | ||||
|         my @volume_idxs = @_; | ||||
|         my %done = ();  # prevent moving instances twice | ||||
|         my $object_moved; | ||||
|         my $wipe_tower_moved; | ||||
|         foreach my $volume_idx (@volume_idxs) { | ||||
|             my $volume = $self->volumes->[$volume_idx]; | ||||
|             my $obj_idx = $volume->object_idx; | ||||
|             my $instance_idx = $volume->instance_idx; | ||||
|             next if $done{"${obj_idx}_${instance_idx}"}; | ||||
|             $done{"${obj_idx}_${instance_idx}"} = 1; | ||||
|             if ($obj_idx < 1000) { | ||||
|                 # Move a regular object. | ||||
|                 my $model_object = $self->{model}->get_object($obj_idx); | ||||
|                 $model_object | ||||
|                     ->instances->[$instance_idx] | ||||
|                     ->offset | ||||
|                     ->translate($volume->origin->x, $volume->origin->y); #)) | ||||
|                 $model_object->invalidate_bounding_box; | ||||
|                 $object_moved = 1; | ||||
|             } elsif ($obj_idx == 1000) { | ||||
|                 # Move a wipe tower proxy. | ||||
|                 $wipe_tower_moved = $volume->origin; | ||||
|             } | ||||
|         } | ||||
|          | ||||
|         $self->{on_instances_moved}->() | ||||
|             if $object_moved && $self->{on_instances_moved}; | ||||
|         $self->{on_wipe_tower_moved}->($wipe_tower_moved) | ||||
|             if $wipe_tower_moved && $self->{on_wipe_tower_moved}; | ||||
|     }); | ||||
| 
 | ||||
| #============================================================================================================================== | ||||
| #        my @volume_idxs = @_; | ||||
| #        my %done = ();  # prevent moving instances twice | ||||
| #        my $object_moved; | ||||
| #        my $wipe_tower_moved; | ||||
| #        foreach my $volume_idx (@volume_idxs) { | ||||
| #            my $volume = $self->volumes->[$volume_idx]; | ||||
| #            my $obj_idx = $volume->object_idx; | ||||
| #            my $instance_idx = $volume->instance_idx; | ||||
| #            next if $done{"${obj_idx}_${instance_idx}"}; | ||||
| #            $done{"${obj_idx}_${instance_idx}"} = 1; | ||||
| #            if ($obj_idx < 1000) { | ||||
| #                # Move a regular object. | ||||
| #                my $model_object = $self->{model}->get_object($obj_idx); | ||||
| #                $model_object | ||||
| #                    ->instances->[$instance_idx] | ||||
| #                    ->offset | ||||
| #                    ->translate($volume->origin->x, $volume->origin->y); #)) | ||||
| #                $model_object->invalidate_bounding_box; | ||||
| #                $object_moved = 1; | ||||
| #            } elsif ($obj_idx == 1000) { | ||||
| #                # Move a wipe tower proxy. | ||||
| #                $wipe_tower_moved = $volume->origin; | ||||
| #            } | ||||
| #        } | ||||
| #         | ||||
| #        $self->{on_instances_moved}->() | ||||
| #            if $object_moved && $self->{on_instances_moved}; | ||||
| #        $self->{on_wipe_tower_moved}->($wipe_tower_moved) | ||||
| #            if $wipe_tower_moved && $self->{on_wipe_tower_moved}; | ||||
| #    }); | ||||
| # | ||||
| #    EVT_KEY_DOWN($self, sub { | ||||
| #        my ($s, $event) = @_; | ||||
| #        if ($event->HasModifiers) { | ||||
|  | @ -194,19 +190,17 @@ sub set_on_select_object { | |||
| #    my ($self, $cb) = @_; | ||||
| #    $self->on_remove_object($cb); | ||||
| #} | ||||
| #============================================================================================================================== | ||||
| 
 | ||||
| sub set_on_instances_moved { | ||||
|     my ($self, $cb) = @_; | ||||
|     $self->{on_instances_moved} = $cb; | ||||
| } | ||||
| 
 | ||||
| sub set_on_wipe_tower_moved { | ||||
|     my ($self, $cb) = @_; | ||||
|     $self->{on_wipe_tower_moved} = $cb; | ||||
| } | ||||
| 
 | ||||
| #============================================================================================================================== | ||||
| # | ||||
| #sub set_on_instances_moved { | ||||
| #    my ($self, $cb) = @_; | ||||
| #    $self->{on_instances_moved} = $cb; | ||||
| #} | ||||
| # | ||||
| #sub set_on_wipe_tower_moved { | ||||
| #    my ($self, $cb) = @_; | ||||
| #    $self->{on_wipe_tower_moved} = $cb; | ||||
| #} | ||||
| # | ||||
| #sub set_on_model_update { | ||||
| #    my ($self, $cb) = @_; | ||||
| #    $self->on_model_update($cb); | ||||
|  | @ -216,6 +210,9 @@ sub set_on_wipe_tower_moved { | |||
| sub set_on_enable_action_buttons { | ||||
|     my ($self, $cb) = @_; | ||||
|     $self->on_enable_action_buttons($cb); | ||||
| #============================================================================================================================== | ||||
|     Slic3r::GUI::_3DScene::register_on_enable_action_buttons_callback($self, $cb); | ||||
| #============================================================================================================================== | ||||
| } | ||||
| 
 | ||||
| sub update_volumes_selection { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Enrico Turri
						Enrico Turri