Skip to content

fix: preview slider shows non-support layer count instead of total Z … - #624

Open
mwz-iot wants to merge 1 commit into
process_optimistic_julyfrom
fix/preview_total_layers_shows_support_z_nodes
Open

fix: preview slider shows non-support layer count instead of total Z …#624
mwz-iot wants to merge 1 commit into
process_optimistic_julyfrom
fix/preview_total_layers_shows_support_z_nodes

Conversation

@mwz-iot

@mwz-iot mwz-iot commented Jul 27, 2026

Copy link
Copy Markdown

Description

This PR fixes the incorrect layer number display in Preview when Independent Support Layer Height is enabled.

GCodeViewer::m_layers contains all sorted Z positions, including both model layers and support-only layers. The preview slider previously displayed the index in m_layers directly as the layer number.

When independent support layer height is enabled, support paths can have additional Z positions that do not correspond to model layers. As a result:

  • The preview slider node count may increase from the actual model layer count, such as from 1000 to 1556.
  • The tooltip layer number includes support-only Z node indexes.
  • Users cannot distinguish model layers from support-only Z positions.

This PR introduces a mapping from the preview Z index to the corresponding non-support model layer number.

The main changes include:

  • Build m_preview_to_non_support_layer in GCodeViewer::load_toolpaths().
  • Identify model layers by excluding the following support extrusion roles:
    • erSupportMaterial
    • erSupportMaterialInterface
    • erSupportTransition
  • Number model layers in ascending Z order.
  • Mark support-only Z positions as -1.
  • Pass the mapping from GCodeViewer to IMSlider through GUI_Preview.
  • Display the actual model layer number for model layers.
  • Display -- for support-only Z positions.
  • Clear and rebuild the mapping when the G-code viewer is reset.
  • Fall back to the original display logic when the mapping is empty or the slider index is invalid.

The original m_layers data and slider range remain unchanged, so users can still navigate through all model and support paths.

There are no breaking changes or new external dependencies introduced by this PR.

Screenshots/Recordings/Graphs

Before

The preview tooltip directly displayed the preview Z index as the layer number.
After enabling Independent Support Layer Height, support-only Z nodes were mixed
with model layers, causing the displayed layer number to exceed the actual model
layer count.

image image

After - Model layer

Model Z positions display the correct model layer number.

04_关闭独立支撑层高_最终预览_模型层1000 01_开启独立支撑层高_最终预览_模型层1000

After - Support-only Z

Support-only Z positions remain available in the slider and display -- instead
of an incorrect model layer number.

09_纯支撑节点_Z102 07_显示横线

Tests

The following cases were tested:

  • Enabled Independent Support Layer Height and verified that model layers display the correct model layer number.
  • Verified that support-only Z positions display --.
  • Verified that the preview slider still retains all model and support Z nodes.
  • Verified that support-only toolpaths can still be selected and previewed.
  • Disabled Independent Support Layer Height and verified that the preview behavior remains compatible with the original behavior.
  • Re-sliced the model and verified that the previous mapping is cleared and rebuilt correctly.
  • Verified fallback behavior when the mapping is empty.
  • Verified index boundary checks to prevent out-of-range access.
  • Verified that the generated G-code, toolpaths, slicing result, and Z node count are unchanged.

@mwz-iot mwz-iot self-assigned this Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant