Replace multitude of Extruder fields with querying a PrintConfig object by id.

This commit is contained in:
Y. Sapir 2014-04-27 00:28:32 +03:00
parent b319dc9361
commit 2565d80679
7 changed files with 38 additions and 140 deletions

View file

@ -25,19 +25,19 @@ use constant EXTRUDER_ROLE_INFILL => 2;
use constant EXTRUDER_ROLE_SUPPORT_MATERIAL => 3;
use constant EXTRUDER_ROLE_SUPPORT_MATERIAL_INTERFACE => 4;
sub new_from_config {
my ($class, $config, $extruder_id) = @_;
my %conf = (
id => $extruder_id,
use_relative_e_distances => $config->use_relative_e_distances,
);
foreach my $opt_key (@{&OPTIONS}) {
$conf{$opt_key} = $config->get_at($opt_key, $extruder_id);
# generate accessors
{
no strict 'refs';
for my $opt_key (@{&Slic3r::Extruder::OPTIONS}) {
*{$opt_key} = sub {
my $self = shift;
$self->config->get_at($opt_key, $self->id);
};
}
return $class->new(%conf);
}
sub e_per_mm3 {
my $self = shift;
return $self->extrusion_multiplier * (4 / (($self->filament_diameter ** 2) * PI));