mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-11 19:17:33 +00:00
Fix and consolidate number tab creation
This commit is contained in:
@@ -354,6 +354,7 @@ void CalibPressureAdvancePattern::set_starting_point(Vec2d pt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_starting_point = pt;
|
m_starting_point = pt;
|
||||||
|
m_last_pos = pt;
|
||||||
};
|
};
|
||||||
|
|
||||||
CustomGCode::Info CalibPressureAdvancePattern::generate_gcodes()
|
CustomGCode::Info CalibPressureAdvancePattern::generate_gcodes()
|
||||||
@@ -413,22 +414,11 @@ CustomGCode::Info CalibPressureAdvancePattern::generate_gcodes()
|
|||||||
|
|
||||||
// glyph on every other line
|
// glyph on every other line
|
||||||
for (int j = 0; j < num_patterns; j += 2) {
|
for (int j = 0; j < num_patterns; j += 2) {
|
||||||
double current_glyph_start_x =
|
|
||||||
m_starting_point.x() +
|
|
||||||
(j * (m_pattern_spacing + line_width())) +
|
|
||||||
(j * ((m_wall_count - 1) * line_spacing_angle())) // this aligns glyph starts with first pattern perim
|
|
||||||
;
|
|
||||||
// shift glyph center to middle of pattern walls. m_digit_segment_len = half of x width of glyph
|
|
||||||
current_glyph_start_x +=
|
|
||||||
(((m_wall_count - 1) / 2) * line_spacing_angle()) - m_digit_segment_len
|
|
||||||
;
|
|
||||||
current_glyph_start_x += pattern_shift();
|
|
||||||
|
|
||||||
gcode << draw_number(
|
gcode << draw_number(
|
||||||
current_glyph_start_x,
|
glyph_start_x(j),
|
||||||
m_starting_point.y() + frame_size_y() + m_glyph_padding_vertical + line_width(),
|
m_starting_point.y() + frame_size_y() + m_glyph_padding_vertical + line_width(),
|
||||||
m_params.start + (j * m_params.step),
|
m_params.start + (j * m_params.step),
|
||||||
DrawDigitMode::Bottom_To_Top,
|
m_draw_digit_mode,
|
||||||
m_line_width,
|
m_line_width,
|
||||||
m_height_layer,
|
m_height_layer,
|
||||||
m_writer
|
m_writer
|
||||||
@@ -442,8 +432,8 @@ CustomGCode::Info CalibPressureAdvancePattern::generate_gcodes()
|
|||||||
double to_y = m_starting_point.y();
|
double to_y = m_starting_point.y();
|
||||||
double side_length = m_wall_side_length;
|
double side_length = m_wall_side_length;
|
||||||
|
|
||||||
|
// shrink first layer to fit inside frame
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
// shrink first layer to fit inside frame
|
|
||||||
double shrink =
|
double shrink =
|
||||||
(
|
(
|
||||||
line_spacing_anchor() * (m_anchor_perimeters - 1) +
|
line_spacing_anchor() * (m_anchor_perimeters - 1) +
|
||||||
@@ -748,30 +738,55 @@ double CalibPressureAdvancePattern::object_size_y()
|
|||||||
line_width_anchor();
|
line_width_anchor();
|
||||||
}
|
}
|
||||||
|
|
||||||
double CalibPressureAdvancePattern::glyph_start_x()
|
double CalibPressureAdvancePattern::glyph_start_x(int pattern_i)
|
||||||
{
|
{
|
||||||
return
|
// note that pattern_i is zero-based!
|
||||||
|
// align glyph's start with first perimeter of specified pattern
|
||||||
|
double x =
|
||||||
|
// starting offset
|
||||||
m_starting_point.x() +
|
m_starting_point.x() +
|
||||||
(((m_wall_count - 1) / 2) * line_spacing_angle() - 2)
|
pattern_shift() +
|
||||||
|
|
||||||
|
// width of pattern extrusions
|
||||||
|
pattern_i * (m_wall_count - 1) * line_spacing_angle() + // center to center distance of extrusions
|
||||||
|
pattern_i * line_width() + // endcaps. center to end on either side = 1 line width
|
||||||
|
|
||||||
|
// space between each pattern
|
||||||
|
pattern_i * m_pattern_spacing
|
||||||
;
|
;
|
||||||
|
|
||||||
|
// align to middle of pattern walls
|
||||||
|
x += m_wall_count * line_spacing_angle() / 2;
|
||||||
|
|
||||||
|
// shift so glyph is centered on pattern
|
||||||
|
// m_digit_segment_len = half of X length of glyph
|
||||||
|
x -= (glyph_length_x() / 2);
|
||||||
|
|
||||||
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
double CalibPressureAdvancePattern::glyph_end_x()
|
double CalibPressureAdvancePattern::glyph_length_x() {
|
||||||
{
|
// half of line_width sticks out on each side
|
||||||
return
|
return line_width() + (2 * m_digit_segment_len);
|
||||||
m_starting_point.x() +
|
|
||||||
(get_num_patterns() - 1) * (m_pattern_spacing + line_width()) +
|
|
||||||
(get_num_patterns() - 1) * ((m_wall_count - 1) * line_spacing_angle()) +
|
|
||||||
4
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double CalibPressureAdvancePattern::glyph_tab_max_x()
|
double CalibPressureAdvancePattern::glyph_tab_max_x()
|
||||||
{
|
{
|
||||||
|
// only every other glyph is shown, starting with 1
|
||||||
|
int num = get_num_patterns();
|
||||||
|
int max_num =
|
||||||
|
(num % 2 == 0)
|
||||||
|
? num - 1
|
||||||
|
: num
|
||||||
|
;
|
||||||
|
|
||||||
|
// padding at end should be same as padding at start
|
||||||
|
double padding = glyph_start_x(0) - m_starting_point.x();
|
||||||
|
|
||||||
return
|
return
|
||||||
glyph_end_x() +
|
glyph_start_x(max_num - 1) + // glyph_start_x is zero-based
|
||||||
m_glyph_padding_horizontal +
|
(glyph_length_x() - line_width() / 2) +
|
||||||
line_width_anchor() / 2
|
padding
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -796,15 +811,10 @@ double CalibPressureAdvancePattern::max_numbering_height()
|
|||||||
|
|
||||||
double CalibPressureAdvancePattern::pattern_shift()
|
double CalibPressureAdvancePattern::pattern_shift()
|
||||||
{
|
{
|
||||||
auto shift =
|
return
|
||||||
m_starting_point.x() -
|
(m_anchor_perimeters - 1) * line_spacing_anchor() +
|
||||||
glyph_start_x() +
|
line_width_anchor() +
|
||||||
m_glyph_padding_horizontal
|
m_glyph_padding_horizontal
|
||||||
;
|
;
|
||||||
|
|
||||||
if (shift > 0) {
|
|
||||||
return shift + line_width_anchor() / 2;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|||||||
@@ -223,7 +223,12 @@ private:
|
|||||||
double to_radians(double degrees) const { return degrees * M_PI / 180; };
|
double to_radians(double degrees) const { return degrees * M_PI / 180; };
|
||||||
double get_distance(Vec2d from, Vec2d to);
|
double get_distance(Vec2d from, Vec2d to);
|
||||||
|
|
||||||
// from slic3r documentation: spacing = extrusion_width - layer_height * (1 - PI/4)
|
/*
|
||||||
|
from slic3r documentation: spacing = extrusion_width - layer_height * (1 - PI/4)
|
||||||
|
"spacing" = center-to-center distance of adjacent extrusions, which partially overlap
|
||||||
|
https://manual.slic3r.org/advanced/flow-math
|
||||||
|
https://ellis3dp.com/Print-Tuning-Guide/articles/misconceptions.html#two-04mm-perimeters--08mm
|
||||||
|
*/
|
||||||
double line_spacing() { return line_width() - m_height_layer * (1 - M_PI / 4); };
|
double line_spacing() { return line_width() - m_height_layer * (1 - M_PI / 4); };
|
||||||
double line_spacing_anchor() { return line_width_anchor() - m_height_first_layer * (1 - M_PI / 4); };
|
double line_spacing_anchor() { return line_width_anchor() - m_height_first_layer * (1 - M_PI / 4); };
|
||||||
double line_spacing_angle() { return line_spacing() / std::sin(to_radians(m_corner_angle) / 2); };
|
double line_spacing_angle() { return line_spacing() / std::sin(to_radians(m_corner_angle) / 2); };
|
||||||
@@ -232,8 +237,8 @@ private:
|
|||||||
double object_size_y();
|
double object_size_y();
|
||||||
double frame_size_y() { return std::sin(to_radians(double(m_corner_angle) / 2)) * m_wall_side_length * 2; };
|
double frame_size_y() { return std::sin(to_radians(double(m_corner_angle) / 2)) * m_wall_side_length * 2; };
|
||||||
|
|
||||||
double glyph_start_x();
|
double glyph_start_x(int pattern_num = 0);
|
||||||
double glyph_end_x();
|
double glyph_length_x();
|
||||||
double glyph_tab_max_x();
|
double glyph_tab_max_x();
|
||||||
double max_numbering_height();
|
double max_numbering_height();
|
||||||
|
|
||||||
@@ -244,7 +249,7 @@ private:
|
|||||||
const Calib_Params& m_params;
|
const Calib_Params& m_params;
|
||||||
const PrintConfig& m_config;
|
const PrintConfig& m_config;
|
||||||
GCodeWriter& m_writer;
|
GCodeWriter& m_writer;
|
||||||
Vec2d m_starting_point;
|
Vec2d m_starting_point {-1, -1};
|
||||||
PatternSettings m_pattern_settings;
|
PatternSettings m_pattern_settings;
|
||||||
|
|
||||||
const double m_handle_xy_size {5};
|
const double m_handle_xy_size {5};
|
||||||
|
|||||||
Reference in New Issue
Block a user