mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 12:11:15 -06:00 
			
		
		
		
	Added one more failing test to address bad option priority hierarchy
This commit is contained in:
		
							parent
							
								
									4540350b66
								
							
						
					
					
						commit
						10bf334a58
					
				
					 3 changed files with 36 additions and 5 deletions
				
			
		|  | @ -1196,8 +1196,7 @@ sub object_settings_dialog { | |||
| 	 | ||||
| 	# update print | ||||
| 	if ($dlg->PartsChanged || $dlg->PartSettingsChanged) { | ||||
|         $self->{print}->delete_object($obj_idx); | ||||
|         $self->{print}->add_model_object($model_object, $obj_idx); | ||||
|         $self->{print}->reload_object($obj_idx); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -80,10 +80,10 @@ sub apply_config { | |||
|                 next if !defined $volume->material_id; | ||||
|                 my $material = $object->model_object->model->materials->{$volume->material_id}; | ||||
|                 $new->apply_dynamic($material->config); | ||||
|             } | ||||
|         } | ||||
|                 push @new_region_configs, $new; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     # then find the first pair of identical configs | ||||
|     my $have_identical_configs = 0; | ||||
|  | @ -101,7 +101,7 @@ sub apply_config { | |||
|     if ($have_identical_configs) { | ||||
|         # okay, the current subdivision of regions does not make sense anymore. | ||||
|         # we need to remove all objects and re-add them | ||||
|         my @model_objects = map $_->model_object, @{$self->object}; | ||||
|         my @model_objects = map $_->model_object, @{$self->objects}; | ||||
|         $self->delete_all_objects; | ||||
|         $self->add_model_object($_) for @model_objects; | ||||
|     } elsif (@$region_diff > 0) { | ||||
|  | @ -141,6 +141,7 @@ sub add_model_object { | |||
|          | ||||
|         # override the defaults with per-object config and then with per-material config | ||||
|         $config->apply_dynamic($object->config); | ||||
|          | ||||
|         if (defined $volume->material_id) { | ||||
|             my $material_config = $object->model->materials->{ $volume->material_id }->config; | ||||
|             $config->apply_dynamic($material_config); | ||||
|  | @ -214,6 +215,20 @@ sub delete_all_objects { | |||
|     $self->_state->invalidate(STEP_BRIM); | ||||
| } | ||||
| 
 | ||||
| sub reload_object { | ||||
|     my ($self, $obj_idx) = @_; | ||||
|      | ||||
|     # TODO: this method should check whether the per-object config and per-material configs | ||||
|     # have changed in such a way that regions need to be rearranged or we can just apply | ||||
|     # the diff and invalidate something.  Same logic as apply_config() | ||||
|     # For now we just re-add all objects since we haven't implemented this incremental logic yet. | ||||
|     # This should also check whether object volumes (parts) have changed. | ||||
|      | ||||
|     my @model_objects = map $_->model_object, @{$self->objects}; | ||||
|     $self->delete_all_objects; | ||||
|     $self->add_model_object($_) for @model_objects; | ||||
| } | ||||
| 
 | ||||
| sub validate { | ||||
|     my $self = shift; | ||||
|      | ||||
|  |  | |||
							
								
								
									
										19
									
								
								t/print.t
									
										
									
									
									
								
							
							
						
						
									
										19
									
								
								t/print.t
									
										
									
									
									
								
							|  | @ -1,4 +1,4 @@ | |||
| use Test::More tests => 2; | ||||
| use Test::More tests => 3; | ||||
| use strict; | ||||
| use warnings; | ||||
| 
 | ||||
|  | @ -30,4 +30,21 @@ use Slic3r::Test; | |||
|     ok abs(unscale($center->[Y]) - $config->print_center->[Y]) < epsilon, 'print is centered around print_center (Y)'; | ||||
| } | ||||
| 
 | ||||
| { | ||||
|     # this represents the aggregate config from presets | ||||
|     my $config = Slic3r::Config->new_from_defaults; | ||||
|      | ||||
|     # user adds one object to the plater | ||||
|     my $print = Slic3r::Test::init_print('20mm_cube', config => $config); | ||||
|      | ||||
|     # user sets a per-object option | ||||
|     $print->objects->[0]->config->set('fill_density', 100); | ||||
|     $print->reload_object(0); | ||||
|      | ||||
|     # user exports G-code, thus the default config is reapplied | ||||
|     $print->apply_config($config); | ||||
|      | ||||
|     is $print->objects->[0]->config->fill_density, 100, 'apply_config() does not override per-object settings'; | ||||
| } | ||||
| 
 | ||||
| __END__ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci