Simplify optional arguments structs

This commit is contained in:
thewildmage
2023-06-01 20:05:31 -06:00
parent 704d5b7cc4
commit e0555605f9
2 changed files with 39 additions and 30 deletions

View File

@@ -302,7 +302,7 @@ std::string CalibPressureAdvancePattern::generate_test(double start_pa, double e
delta_modify_start(start_x, start_y, num_patterns);
}
CalibPressureAdvancePattern::PatternConfig pattern_config(
CalibPressureAdvancePattern::PatternCalc pattern_calc(
start_pa,
step_pa,
num_patterns,
@@ -318,7 +318,40 @@ std::string CalibPressureAdvancePattern::generate_test(double start_pa, double e
glyph_end_x(num_patterns, center_x)
);
return print_pa_pattern(pattern_config);
return print_pa_pattern(pattern_calc);
}
CalibPressureAdvancePattern::PatternSettings() {
const CalibPressureAdvancePattern cpap;
anchor_line_width = cpap.line_width_anchor();
anchor_perimeters = cpap.m_anchor_perimeters;
extrusion_multiplier = cpap.m_extrusion_multiplier;
first_layer_height = cpap.m_height_first_layer;
first_layer_speed = cpap.speed_adjust(cpap.m_speed_first_layer);
layer_height = cpap.m_height_layer;
line_width = cpap.line_width();
perim_speed = cpap.speed_adjust(cpap.m_speed_perimeter;
}
CalibPressureAdvancePattern::DrawLineOptArgs() {
PatternSettings ps;
extrusion_multiplier = ps.extrusion_multiplier;
height = ps.layer_height;
line_width = ps.line_width;
speed = ps.perim_speed;
comment = "Print line";
}
CalibPressureAdvancePattern::DrawBoxOptArgs() {
PatternSettings ps;
is_filled = false;
num_perimeters = ps.anchor_perimeters;
height = ps.first_layer_height;
line_width = ps.anchor_line_width;
speed = ps.first_layer_spee;
}
double CalibPressureAdvancePattern::get_distance(double cur_x, double cur_y, double to_x, double to_y)

View File

@@ -179,17 +179,7 @@ private:
};
struct PatternSettings {
PatternSettings(const CalibPressureAdvancePattern* cpap) :
anchor_line_width(cpap->line_width_anchor()),
anchor_perimeters(cpap->m_anchor_perimeters),
extrusion_multiplier(cpap->m_extrusion_multiplier),
first_layer_height(cpap->m_height_first_layer),
first_layer_speed(cpap->speed_adjust(cpap->m_speed_first_layer)),
layer_height(cpap->m_height_layer),
line_width(cpap->line_width()),
perim_speed(cpap->speed_adjust(cpap->m_speed_perimeter))
{ }
;
PatternSettings();
double anchor_line_width;
int anchor_perimeters;
@@ -202,14 +192,7 @@ private:
};
struct DrawLineOptArgs {
DrawLineOptArgs(PatternSettings* ps) :
extrusion_multiplier(ps->extrusion_multiplier),
height(ps->layer_height),
line_width(ps->line_width),
speed(ps->perim_speed),
comment("Print line")
{ }
;
DrawLineOptArgs();
double extrusion_multiplier;
double height;
@@ -219,14 +202,7 @@ private:
};
struct DrawBoxOptArgs {
DrawBoxOptArgs(const PatternSettings* ps) :
is_filled(false),
num_perimeters(ps->anchor_perimeters),
height(ps->first_layer_height),
line_width(ps->anchor_line_width),
speed(ps->first_layer_speed)
{ }
;
DrawBoxOptArgs();
bool is_filled;
int num_perimeters;
@@ -267,7 +243,7 @@ private:
std::string draw_line(double to_x, double to_y, std::string comment = std::string());
std::string draw_box(double min_x, double min_y, double size_x, double size_y);
std::string print_pa_pattern(double start_x, double start_y, double start_pa, double step_pa, int num_patterns);
std::string print_pa_pattern(PatternCalc& calc);
double m_line_ratio;
double m_extrusion_multiplier;