mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	New Slic3r::Print::State class
This commit is contained in:
		
							parent
							
								
									685e8e4dfa
								
							
						
					
					
						commit
						d2295cdf70
					
				
					 3 changed files with 115 additions and 52 deletions
				
			
		| 
						 | 
				
			
			@ -5,6 +5,7 @@ use List::Util qw(min max sum first);
 | 
			
		|||
use Slic3r::Geometry qw(X Y Z PI scale unscale deg2rad rad2deg scaled_epsilon chained_path);
 | 
			
		||||
use Slic3r::Geometry::Clipper qw(diff diff_ex intersection intersection_ex union union_ex 
 | 
			
		||||
    offset offset_ex offset2 offset2_ex CLIPPER_OFFSET_SCALE JT_MITER);
 | 
			
		||||
use Slic3r::Print::State ':steps';
 | 
			
		||||
use Slic3r::Surface ':types';
 | 
			
		||||
 | 
			
		||||
has 'print'             => (is => 'ro', weak_ref => 1, required => 1);
 | 
			
		||||
| 
						 | 
				
			
			@ -21,6 +22,7 @@ has '_shifted_copies'   => (is => 'rw');  # Slic3r::Point objects in scaled G-co
 | 
			
		|||
has 'layers'            => (is => 'rw', default => sub { [] });
 | 
			
		||||
has 'support_layers'    => (is => 'rw', default => sub { [] });
 | 
			
		||||
has 'fill_maker'        => (is => 'lazy');
 | 
			
		||||
has '_state'            => (is => 'ro', default => sub { Slic3r::Print::State->new });
 | 
			
		||||
 | 
			
		||||
sub BUILD {
 | 
			
		||||
    my $self = shift;
 | 
			
		||||
| 
						 | 
				
			
			@ -70,6 +72,9 @@ sub _trigger_copies {
 | 
			
		|||
            $c;
 | 
			
		||||
        } @{$self->copies}[@{chained_path($self->copies)}]
 | 
			
		||||
    ]);
 | 
			
		||||
    
 | 
			
		||||
    $self->print->_state->invalidate(STEP_SKIRT);
 | 
			
		||||
    $self->print->_state->invalidate(STEP_BRIM);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# in unscaled coordinates
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										68
									
								
								lib/Slic3r/Print/State.pm
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								lib/Slic3r/Print/State.pm
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,68 @@
 | 
			
		|||
package Slic3r::Print::State;
 | 
			
		||||
use Moo;
 | 
			
		||||
 | 
			
		||||
require Exporter;
 | 
			
		||||
our @ISA = qw(Exporter);
 | 
			
		||||
our @EXPORT_OK   = qw(STEP_INIT_EXTRUDERS STEP_SLICE STEP_PERIMETERS STEP_PREPARE_INFILL 
 | 
			
		||||
                    STEP_INFILL STEP_SUPPORTMATERIAL STEP_SKIRT STEP_BRIM);
 | 
			
		||||
our %EXPORT_TAGS = (steps => \@EXPORT_OK);
 | 
			
		||||
 | 
			
		||||
has '_started'  => (is => 'ro', default => sub {{}});  # { step => 1, ... }
 | 
			
		||||
has '_done'     => (is => 'ro', default => sub {{}});  # { step => 1, ... }
 | 
			
		||||
 | 
			
		||||
use constant STEP_INIT_EXTRUDERS    => 0;
 | 
			
		||||
use constant STEP_SLICE             => 1;
 | 
			
		||||
use constant STEP_PERIMETERS        => 2;
 | 
			
		||||
use constant STEP_PREPARE_INFILL    => 3;
 | 
			
		||||
use constant STEP_INFILL            => 4;
 | 
			
		||||
use constant STEP_SUPPORTMATERIAL   => 5;
 | 
			
		||||
use constant STEP_SKIRT             => 6;
 | 
			
		||||
use constant STEP_BRIM              => 7;
 | 
			
		||||
 | 
			
		||||
our %print_steps = map { $_ => 1 } (
 | 
			
		||||
    STEP_INIT_EXTRUDERS,
 | 
			
		||||
    STEP_SKIRT,
 | 
			
		||||
    STEP_BRIM,
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
our %prereqs = (
 | 
			
		||||
    STEP_INIT_EXTRUDERS     => [],
 | 
			
		||||
    STEP_SLICE              => [],
 | 
			
		||||
    STEP_PERIMETERS         => [STEP_SLICE, STEP_INIT_EXTRUDERS],
 | 
			
		||||
    STEP_PREPARE_INFILL     => [STEP_PERIMETERS],
 | 
			
		||||
    STEP_INFILL             => [STEP_INFILL],
 | 
			
		||||
    STEP_SUPPORTMATERIAL    => [STEP_SLICE, STEP_INIT_EXTRUDERS],
 | 
			
		||||
    STEP_SKIRT              => [STEP_PERIMETERS, STEP_INFILL],
 | 
			
		||||
    STEP_BRIM               => [STEP_PERIMETERS, STEP_INFILL, STEP_SKIRT],
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
sub started {
 | 
			
		||||
    my ($self, $step) = @_;
 | 
			
		||||
    return $self->_started->{$step};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub done {
 | 
			
		||||
    my ($self, $step) = @_;
 | 
			
		||||
    return $self->_done->{$step};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub set_started {
 | 
			
		||||
    my ($self, $step) = @_;
 | 
			
		||||
    
 | 
			
		||||
    $self->_started->{$step} = 1;
 | 
			
		||||
    delete $self->_done->{$step};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub set_done {
 | 
			
		||||
    my ($self, $step) = @_;
 | 
			
		||||
    $self->_done->{$step} = 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub invalidate {
 | 
			
		||||
    my ($self, $step) = @_;
 | 
			
		||||
    
 | 
			
		||||
    delete $self->_started->{$step};
 | 
			
		||||
    delete $self->_done->{$step};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
1;
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue