Some minor changes to the newly-ported Extruder class

This commit is contained in:
Alessandro Ranellucci 2014-04-28 22:02:34 +02:00
parent 4c330b6c59
commit 24571612c7
6 changed files with 33 additions and 64 deletions

View file

@ -24,7 +24,7 @@ Extruder::reset()
double
Extruder::extrude(double dE)
{
if (this->use_relative_e_distances()) {
if (this->config->use_relative_e_distances) {
this->E = 0;
}
@ -33,116 +33,94 @@ Extruder::extrude(double dE)
return this->E;
}
template <typename Val, class OptType> Val
Extruder::get_config(const char *name) const
{
// TODO: figure out way to avoid static_cast to access hidden const method
const ConfigOption *opt = static_cast<const ConfigBase*>(this->config)
->option(name);
return dynamic_cast<const OptType *>(opt)->get_at(this->id);
}
bool
Extruder::use_relative_e_distances() const
{
// not using get_config because use_relative_e_distances is global
// for all extruders
// TODO: figure out way to avoid static_cast to access hidden const method
const ConfigOption *opt = static_cast<const ConfigBase*>(this->config)
->option("use_relative_e_distances");
return *static_cast<const ConfigOptionBool*>(opt);
}
Pointf
Extruder::extruder_offset() const
{
return get_config<Pointf, ConfigOptionPoints>("extruder_offset");
return this->config->extruder_offset.get_at(this->id);
}
double
Extruder::nozzle_diameter() const
{
return get_config<double, ConfigOptionFloats>("nozzle_diameter");
return this->config->nozzle_diameter.get_at(this->id);
}
double
Extruder::filament_diameter() const
{
return get_config<double, ConfigOptionFloats>("filament_diameter");
return this->config->filament_diameter.get_at(this->id);
}
double
Extruder::extrusion_multiplier() const
{
return get_config<double, ConfigOptionFloats>("extrusion_multiplier");
return this->config->extrusion_multiplier.get_at(this->id);
}
int
Extruder::temperature() const
{
return get_config<int, ConfigOptionInts>("temperature");
return this->config->temperature.get_at(this->id);
}
int
Extruder::first_layer_temperature() const
{
return get_config<int, ConfigOptionInts>("first_layer_temperature");
return this->config->first_layer_temperature.get_at(this->id);
}
double
Extruder::retract_length() const
{
return get_config<double, ConfigOptionFloats>("retract_length");
return this->config->retract_length.get_at(this->id);
}
double
Extruder::retract_lift() const
{
return get_config<double, ConfigOptionFloats>("retract_lift");
return this->config->retract_lift.get_at(this->id);
}
int
Extruder::retract_speed() const
{
return get_config<int, ConfigOptionInts>("retract_speed");
return this->config->retract_speed.get_at(this->id);
}
double
Extruder::retract_restart_extra() const
{
return get_config<double, ConfigOptionFloats>("retract_restart_extra");
return this->config->retract_restart_extra.get_at(this->id);
}
double
Extruder::retract_before_travel() const
{
return get_config<double, ConfigOptionFloats>("retract_before_travel");
return this->config->retract_before_travel.get_at(this->id);
}
bool
Extruder::retract_layer_change() const
{
return get_config<bool, ConfigOptionBools>("retract_layer_change");
return this->config->retract_layer_change.get_at(this->id);
}
double
Extruder::retract_length_toolchange() const
{
return get_config<double, ConfigOptionFloats>("retract_length_toolchange");
return this->config->retract_length_toolchange.get_at(this->id);
}
double
Extruder::retract_restart_extra_toolchange() const
{
return get_config<double, ConfigOptionFloats>(
"retract_restart_extra_toolchange");
return this->config->retract_restart_extra_toolchange.get_at(this->id);
}
bool
Extruder::wipe() const
{
return get_config<bool, ConfigOptionBools>("wipe");
return this->config->wipe.get_at(this->id);
}