Refactoring: moved Slic3r::GCode::Base to Slic3r::GCode::Writer

This commit is contained in:
Alessandro Ranellucci 2014-10-25 10:42:07 +02:00
parent c2e710d092
commit 7f57f007cd
12 changed files with 154 additions and 212 deletions

View file

@ -123,12 +123,12 @@ ConfigBase::get(t_config_option_key opt_key) {
av_store(av, it - optv->values.begin(), newSVpvn_utf8(it->c_str(), it->length(), true));
return newRV_noinc((SV*)av);
} else if (ConfigOptionPoint* optv = dynamic_cast<ConfigOptionPoint*>(opt)) {
return optv->point.to_SV_pureperl();
return perl_to_SV_clone_ref(optv->point);
} else if (ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt)) {
AV* av = newAV();
av_fill(av, optv->values.size()-1);
for (Pointfs::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
av_store(av, it - optv->values.begin(), it->to_SV_pureperl());
av_store(av, it - optv->values.begin(), perl_to_SV_clone_ref(*it));
return newRV_noinc((SV*)av);
} else if (ConfigOptionBool* optv = dynamic_cast<ConfigOptionBool*>(opt)) {
return newSViv(optv->value ? 1 : 0);
@ -158,7 +158,7 @@ ConfigBase::get_at(t_config_option_key opt_key, size_t i) {
std::string val = optv->get_at(i);
return newSVpvn_utf8(val.c_str(), val.length(), true);
} else if (ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt)) {
return optv->get_at(i).to_SV_pureperl();
return perl_to_SV_clone_ref(optv->get_at(i));
} else if (ConfigOptionBools* optv = dynamic_cast<ConfigOptionBools*>(opt)) {
return newSViv(optv->get_at(i) ? 1 : 0);
} else {

View file

@ -2,7 +2,7 @@
namespace Slic3r {
Extruder::Extruder(int id, PrintConfig *config)
Extruder::Extruder(int id, GCodeConfig *config)
: id(id),
config(config)
{
@ -91,18 +91,6 @@ Extruder::used_filament() const
return this->absolute_E + this->retracted;
}
Pointf
Extruder::extruder_offset() const
{
return this->config->extruder_offset.get_at(this->id);
}
double
Extruder::nozzle_diameter() const
{
return this->config->nozzle_diameter.get_at(this->id);
}
double
Extruder::filament_diameter() const
{
@ -115,18 +103,6 @@ Extruder::extrusion_multiplier() const
return this->config->extrusion_multiplier.get_at(this->id);
}
int
Extruder::temperature() const
{
return this->config->temperature.get_at(this->id);
}
int
Extruder::first_layer_temperature() const
{
return this->config->first_layer_temperature.get_at(this->id);
}
double
Extruder::retract_length() const
{
@ -151,18 +127,6 @@ Extruder::retract_restart_extra() const
return this->config->retract_restart_extra.get_at(this->id);
}
double
Extruder::retract_before_travel() const
{
return this->config->retract_before_travel.get_at(this->id);
}
bool
Extruder::retract_layer_change() const
{
return this->config->retract_layer_change.get_at(this->id);
}
double
Extruder::retract_length_toolchange() const
{
@ -175,12 +139,6 @@ Extruder::retract_restart_extra_toolchange() const
return this->config->retract_restart_extra_toolchange.get_at(this->id);
}
bool
Extruder::wipe() const
{
return this->config->wipe.get_at(this->id);
}
#ifdef SLIC3RXS
REGISTER_CLASS(Extruder, "Extruder");

View file

@ -10,7 +10,15 @@ namespace Slic3r {
class Extruder
{
public:
Extruder(int id, PrintConfig *config);
int id;
double E;
double absolute_E;
double retracted;
double restart_extra;
double e_per_mm3;
double retract_speed_mm_min;
Extruder(int id, GCodeConfig *config);
virtual ~Extruder() {}
void reset();
double extrude(double dE);
@ -20,32 +28,17 @@ class Extruder
double extruded_volume() const;
double used_filament() const;
Pointf extruder_offset() const;
double nozzle_diameter() const;
double filament_diameter() const;
double extrusion_multiplier() const;
int temperature() const;
int first_layer_temperature() const;
double retract_length() const;
double retract_lift() const;
int retract_speed() const;
double retract_restart_extra() const;
double retract_before_travel() const;
bool retract_layer_change() const;
double retract_length_toolchange() const;
double retract_restart_extra_toolchange() const;
bool wipe() const;
int id;
double E;
double absolute_E;
double retracted;
double restart_extra;
double e_per_mm3;
double retract_speed_mm_min;
private:
PrintConfig *config;
GCodeConfig *config;
};
}

View file

@ -310,6 +310,8 @@ class GCodeConfig : public virtual StaticPrintConfig
{
public:
ConfigOptionString extrusion_axis;
ConfigOptionFloats extrusion_multiplier;
ConfigOptionFloats filament_diameter;
ConfigOptionBool gcode_comments;
ConfigOptionEnum<GCodeFlavor> gcode_flavor;
ConfigOptionFloats retract_length;
@ -324,6 +326,10 @@ class GCodeConfig : public virtual StaticPrintConfig
GCodeConfig() : StaticPrintConfig() {
this->extrusion_axis.value = "E";
this->extrusion_multiplier.values.resize(1);
this->extrusion_multiplier.values[0] = 1;
this->filament_diameter.values.resize(1);
this->filament_diameter.values[0] = 3;
this->gcode_comments.value = false;
this->gcode_flavor.value = gcfRepRap;
this->retract_length.values.resize(1);
@ -345,6 +351,8 @@ class GCodeConfig : public virtual StaticPrintConfig
ConfigOption* option(const t_config_option_key opt_key, bool create = false) {
if (opt_key == "extrusion_axis") return &this->extrusion_axis;
if (opt_key == "extrusion_multiplier") return &this->extrusion_multiplier;
if (opt_key == "filament_diameter") return &this->filament_diameter;
if (opt_key == "gcode_comments") return &this->gcode_comments;
if (opt_key == "gcode_flavor") return &this->gcode_flavor;
if (opt_key == "retract_length") return &this->retract_length;
@ -379,10 +387,8 @@ class PrintConfig : public GCodeConfig
ConfigOptionFloat extruder_clearance_height;
ConfigOptionFloat extruder_clearance_radius;
ConfigOptionPoints extruder_offset;
ConfigOptionFloats extrusion_multiplier;
ConfigOptionBool fan_always_on;
ConfigOptionInt fan_below_layer_time;
ConfigOptionFloats filament_diameter;
ConfigOptionFloat first_layer_acceleration;
ConfigOptionInt first_layer_bed_temperature;
ConfigOptionFloatOrPercent first_layer_extrusion_width;
@ -440,12 +446,8 @@ class PrintConfig : public GCodeConfig
this->extruder_clearance_radius.value = 20;
this->extruder_offset.values.resize(1);
this->extruder_offset.values[0] = Pointf(0,0);
this->extrusion_multiplier.values.resize(1);
this->extrusion_multiplier.values[0] = 1;
this->fan_always_on.value = false;
this->fan_below_layer_time.value = 60;
this->filament_diameter.values.resize(1);
this->filament_diameter.values[0] = 3;
this->first_layer_acceleration.value = 0;
this->first_layer_bed_temperature.value = 0;
this->first_layer_extrusion_width.value = 200;
@ -507,10 +509,8 @@ class PrintConfig : public GCodeConfig
if (opt_key == "extruder_clearance_height") return &this->extruder_clearance_height;
if (opt_key == "extruder_clearance_radius") return &this->extruder_clearance_radius;
if (opt_key == "extruder_offset") return &this->extruder_offset;
if (opt_key == "extrusion_multiplier") return &this->extrusion_multiplier;
if (opt_key == "fan_always_on") return &this->fan_always_on;
if (opt_key == "fan_below_layer_time") return &this->fan_below_layer_time;
if (opt_key == "filament_diameter") return &this->filament_diameter;
if (opt_key == "first_layer_acceleration") return &this->first_layer_acceleration;
if (opt_key == "first_layer_bed_temperature") return &this->first_layer_bed_temperature;
if (opt_key == "first_layer_extrusion_width") return &this->first_layer_extrusion_width;