Automatically disable retract_layer_change when using spiral_vase

This commit is contained in:
Alessandro Ranellucci 2014-05-26 23:51:58 +02:00
parent 2ac40f9547
commit 98b8936ee2
5 changed files with 27 additions and 7 deletions

View file

@ -320,6 +320,15 @@ DynamicConfig::option(const t_config_option_key opt_key, bool create) {
return this->options[opt_key];
}
template<class T>
T*
DynamicConfig::opt(const t_config_option_key opt_key, bool create) {
return dynamic_cast<T*>(this->option(opt_key, create));
}
template ConfigOptionInt* DynamicConfig::opt<ConfigOptionInt>(const t_config_option_key opt_key, bool create);
template ConfigOptionBool* DynamicConfig::opt<ConfigOptionBool>(const t_config_option_key opt_key, bool create);
template ConfigOptionBools* DynamicConfig::opt<ConfigOptionBools>(const t_config_option_key opt_key, bool create);
const ConfigOption*
DynamicConfig::option(const t_config_option_key opt_key) const {
return const_cast<DynamicConfig*>(this)->option(opt_key, false);

View file

@ -491,6 +491,7 @@ class DynamicConfig : public ConfigBase
DynamicConfig& operator= (DynamicConfig other);
void swap(DynamicConfig &other);
~DynamicConfig();
template<class T> T* opt(const t_config_option_key opt_key, bool create = false);
ConfigOption* option(const t_config_option_key opt_key, bool create = false);
const ConfigOption* option(const t_config_option_key opt_key) const;
void keys(t_config_option_keys *keys) const;

View file

@ -985,6 +985,13 @@ class DynamicPrintConfig : public DynamicConfig
if (!this->has("support_material_interface_extruder"))
this->option("support_material_interface_extruder", true)->setInt(extruder);
}
if (this->has("spiral_vase") && this->opt<ConfigOptionBool>("spiral_vase", true)->value) {
{
// this should be actually done only on the spiral layers instead of all
ConfigOptionBools* opt = this->opt<ConfigOptionBools>("retract_layer_change", true);
opt->values.assign(opt->values.size(), false); // set all values to false
}
}
};
};

View file

@ -4,7 +4,7 @@ use strict;
use warnings;
use Slic3r::XS;
use Test::More tests => 114;
use Test::More tests => 115;
foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
$config->set('layer_height', 0.3);
@ -176,4 +176,12 @@ foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
is $config->get('perimeter_extruder'), 3, 'defined extruder is not overwritten by default extruder';
}
{
my $config = Slic3r::Config->new;
$config->set('spiral_vase', 1);
$config->set('retract_layer_change', [1,0]);
$config->normalize;
is_deeply $config->get('retract_layer_change'), [0,0], 'retract_layer_change is disabled with spiral_vase';
}
__END__