Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CURA-11830 Add z-seam approach distance #18988

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cura/LayerDataBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def build(self, material_color_map, line_type_brightness = 1.0):
# Set material_colors with indices where line_types (also numpy array) == MoveCombingType
material_colors[line_types == LayerPolygon.MoveCombingType] = colors[line_types == LayerPolygon.MoveCombingType]
material_colors[line_types == LayerPolygon.MoveRetractionType] = colors[line_types == LayerPolygon.MoveRetractionType]
material_colors[line_types == LayerPolygon.MoveUnretractionType] = colors[line_types == LayerPolygon.MoveUnretractionType]

attributes = {
"line_dimensions": {
Expand Down
12 changes: 7 additions & 5 deletions cura/LayerPolygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ class LayerPolygon:
MoveRetractionType = 9
SupportInterfaceType = 10
PrimeTowerType = 11
__number_of_types = 12
MoveUnretractionType = 12
__number_of_types = 13

__jump_map = numpy.logical_or(numpy.logical_or(numpy.arange(__number_of_types) == NoneType,
numpy.arange(__number_of_types) == MoveCombingType),
numpy.arange(__number_of_types) == MoveRetractionType)
__jump_map = numpy.logical_or(numpy.arange(__number_of_types) == NoneType, numpy.arange(__number_of_types) == MoveCombingType)
__jump_map = numpy.logical_or(__jump_map, numpy.arange(__number_of_types) == MoveRetractionType)
__jump_map = numpy.logical_or(__jump_map, numpy.arange(__number_of_types) == MoveUnretractionType)

def __init__(self, extruder: int, line_types: numpy.ndarray, data: numpy.ndarray,
line_widths: numpy.ndarray, line_thicknesses: numpy.ndarray, line_feedrates: numpy.ndarray) -> None:
Expand Down Expand Up @@ -272,7 +273,8 @@ def getColorMap(cls) -> numpy.ndarray:
theme.getColor("layerview_move_combing").getRgbF(), # MoveCombingType
theme.getColor("layerview_move_retraction").getRgbF(), # MoveRetractionType
theme.getColor("layerview_support_interface").getRgbF(), # SupportInterfaceType
theme.getColor("layerview_prime_tower").getRgbF() # PrimeTowerType
theme.getColor("layerview_prime_tower").getRgbF(), # PrimeTowerType
theme.getColor("layerview_move_unretraction").getRgbF(), # MoveUnretractionType
])

return cls.__color_map
2 changes: 1 addition & 1 deletion plugins/GCodeReader/FlavorParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _createPolygon(self, layer_thickness: float, path: List[List[Union[float, in
if i > 0:
line_feedrates[i - 1] = point[3]
line_types[i - 1] = point[5]
if point[5] in [LayerPolygon.MoveCombingType, LayerPolygon.MoveRetractionType]:
if point[5] in [LayerPolygon.MoveCombingType, LayerPolygon.MoveRetractionType, LayerPolygon.MoveUnretractionType]:
line_widths[i - 1] = 0.1
line_thicknesses[i - 1] = 0.0 # Travels are set as zero thickness lines
else:
Expand Down
1 change: 1 addition & 0 deletions plugins/SimulationView/SimulationView.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ def calculateColorSchemeLimits(self) -> None:
if self.getShowTravelMoves():
visible_line_types.append(LayerPolygon.MoveCombingType)
visible_line_types.append(LayerPolygon.MoveRetractionType)
visible_line_types.append(LayerPolygon.MoveUnretractionType)

for node in DepthFirstIterator(self.getController().getScene().getRoot()):
layer_data = node.callDecoration("getLayerData")
Expand Down
16 changes: 12 additions & 4 deletions plugins/SimulationView/layers.shader
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ vertex =
gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * a_vertex;
// shade the color depending on the extruder index
v_color = a_color;
// 8 and 9 are travel moves
if ((a_line_type != 8.0) && (a_line_type != 9.0)) {
// 8, 9 and 12 are travel moves
if ((a_line_type != 8.0) && (a_line_type != 9.0) && (a_line_type != 12.0) {
v_color = (a_extruder == u_active_extruder) ? v_color : vec4(u_shade_factor * v_color.rgb, v_color.a);
}

Expand All @@ -48,7 +48,11 @@ fragment =

void main()
{
if ((u_show_travel_moves == 0) && (v_line_type >= 7.5) && (v_line_type <= 9.5)) { // actually, 8 and 9
// travel moves: 8, 9 or 12
if ((u_show_travel_moves == 0) &&
(((v_line_type >= 7.5) && (v_line_type <= 9.5)) ||
((v_line_type >= 11.5) && (v_line_type <= 12.5))))
{
// discard movements
discard;
}
Expand Down Expand Up @@ -120,7 +124,11 @@ fragment41core =

void main()
{
if ((u_show_travel_moves == 0) && (v_line_type >= 7.5) && (v_line_type <= 9.5)) { // actually, 8 and 9
// travel moves: 8, 9 or 12
if ((u_show_travel_moves == 0) &&
(((v_line_type >= 7.5) && (v_line_type <= 9.5)) ||
((v_line_type >= 11.5) && (v_line_type <= 12.5))))
{
// discard movements
discard;
}
Expand Down
8 changes: 4 additions & 4 deletions plugins/SimulationView/layers3d.shader
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ geometry41core =
if ((v_extruder_opacity[0][int(mod(v_extruder[0], 4))][v_extruder[0] / 4] == 0.0) && (v_line_type[0] != 8) && (v_line_type[0] != 9)) {
return;
}
// See LayerPolygon; 8 is MoveCombingType, 9 is RetractionType
if ((u_show_travel_moves == 0) && ((v_line_type[0] == 8) || (v_line_type[0] == 9))) {
// See LayerPolygon; 8 is MoveCombingType, 9 is RetractionType, 12 is MoveUnretractionType
if ((u_show_travel_moves == 0) && ((v_line_type[0] == 8) || (v_line_type[0] == 9) || (v_line_type[0] == 12))) {
return;
}
if ((u_show_helpers == 0) && ((v_line_type[0] == 4) || (v_line_type[0] == 5) || (v_line_type[0] == 7) || (v_line_type[0] == 10) || v_line_type[0] == 11)) {
Expand All @@ -256,7 +256,7 @@ geometry41core =
return;
}

if ((v_line_type[0] == 8) || (v_line_type[0] == 9)) {
if ((v_line_type[0] == 8) || (v_line_type[0] == 9) || (v_line_type[0] == 12)) {
// fixed size for movements
size_x = 0.05;
} else {
Expand All @@ -274,7 +274,7 @@ geometry41core =
g_vertex_normal_vert = vec3(0.0, 1.0, 0.0); //Upwards normal vector.
g_vertex_offset_vert = vec4(g_vertex_normal_vert * size_y, 0.0); //Upwards offset vector. Goes up by half the layer thickness.

if ((v_line_type[0] == 8) || (v_line_type[0] == 9)) { //Travel or retraction moves.
if ((v_line_type[0] == 8) || (v_line_type[0] == 9) || (v_line_type[0] == 12)) { //Travel or retraction moves.
vec4 va_head = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head + g_vertex_offset_vert);
vec4 va_up = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert);
vec4 va_down = viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert);
Expand Down
8 changes: 4 additions & 4 deletions plugins/SimulationView/layers3d_shadow.shader
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ geometry41core =
if ((v_extruder_opacity[0][int(mod(v_extruder[0], 4))][v_extruder[0] / 4] == 0.0) && (v_line_type[0] != 8) && (v_line_type[0] != 9)) {
return;
}
// See LayerPolygon; 8 is MoveCombingType, 9 is RetractionType
if ((u_show_travel_moves == 0) && ((v_line_type[0] == 8) || (v_line_type[0] == 9))) {
// See LayerPolygon; 8 is MoveCombingType, 9 is RetractionType, 12 is MoveUnretractionType
if ((u_show_travel_moves == 0) && ((v_line_type[0] == 8) || (v_line_type[0] == 9) || (v_line_type[0] == 12))) {
return;
}
if ((u_show_helpers == 0) && ((v_line_type[0] == 4) || (v_line_type[0] == 5) || (v_line_type[0] == 7) || (v_line_type[0] == 10))) {
Expand All @@ -123,7 +123,7 @@ geometry41core =
return;
}

if ((v_line_type[0] == 8) || (v_line_type[0] == 9)) {
if ((v_line_type[0] == 8) || (v_line_type[0] == 9) || (v_line_type[0] == 12)) {
// fixed size for movements
size_x = 0.05;
} else {
Expand All @@ -141,7 +141,7 @@ geometry41core =
g_vertex_normal_vert = vec3(0.0, 1.0, 0.0);
g_vertex_offset_vert = vec4(g_vertex_normal_vert * size_y, 0.0);

if ((v_line_type[0] == 8) || (v_line_type[0] == 9)) {
if ((v_line_type[0] == 8) || (v_line_type[0] == 9) || (v_line_type[0] == 12)) {
vec4 va_head = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head + g_vertex_offset_vert);
vec4 va_up = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert);
vec4 va_down = viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert);
Expand Down
11 changes: 8 additions & 3 deletions plugins/SimulationView/layers_shadow.shader
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ fragment =

void main()
{
if ((u_show_travel_moves == 0) && (v_line_type >= 7.5) && (v_line_type <= 9.5))
{ // actually, 8 and 9
// travel moves: 8, 9 or 12
if ((u_show_travel_moves == 0) &&
(((v_line_type >= 7.5) && (v_line_type <= 9.5)) ||
((v_line_type >= 11.5) && (v_line_type <= 12.5))))
// discard movements
discard;
}
Expand Down Expand Up @@ -124,7 +126,10 @@ fragment41core =

void main()
{
if ((u_show_travel_moves == 0) && (v_line_type >= 7.5) && (v_line_type <= 9.5)) { // actually, 8 and 9
// travel moves: 8, 9 or 12
if ((u_show_travel_moves == 0) &&
(((v_line_type >= 7.5) && (v_line_type <= 9.5)) ||
((v_line_type >= 11.5) && (v_line_type <= 12.5))))
// discard movements
discard;
}
Expand Down
23 changes: 23 additions & 0 deletions resources/definitions/fdmprinter.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,29 @@
"enabled": "z_seam_type == 'back'",
"limit_to_extruder": "wall_0_extruder_nr",
"settable_per_mesh": true
},
"z_seam_approach_distance":
{
"label": "Z Seam approach distance",
"description": "When starting to print a wall, if it starts after a rectracted travel mode, do not travel directly to the start position. Instead, move to a transitory position tangent to the first printed segment, at a certain distance equal to Approach Distance.",
"unit": "mm",
"type": "float",
"default_value": 15,
"minimum_value": "0",
"limit_to_extruder": "wall_0_extruder_nr",
"settable_per_mesh": true
},
"z_seam_approach_inset":
{
"label": "Z Seam approach inset",
"description": "When starting to print a wall, unretract while inside the model. This distance is how much we should be inside the model.",
"unit": "mm",
"type": "float",
"default_value": 0,
"minimum_value": "0",
"value": "wall_line_width_0",
"limit_to_extruder": "wall_0_extruder_nr",
"settable_per_mesh": true
}
}
},
Expand Down
1 change: 1 addition & 0 deletions resources/themes/cura-light/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@
"layerview_move_retraction": [128, 127, 255, 255],
"layerview_support_interface": [63, 127, 255, 127],
"layerview_prime_tower": [0, 255, 255, 255],
"layerview_move_unretraction": [111, 195, 255, 255],
"layerview_nozzle": [224, 192, 16, 64],
"layerview_starts": [255, 255, 255, 255],

Expand Down
Loading