Removing a layer clears its paint on every part, tiled and view-projected
textures run on across parts, the projection tools paint every visible part,
relief under a raised part reaches down to where the object rests, and closing
the tool no longer crashes the app.
Selecting the web Device tab, or changing the printer preset, called
load_url with the same URL. That navigated the webview again and reloaded
the printer UI, dropping its in-page state such as zoom.
PrinterWebView now remembers the URL, API key and host type of its last
finished load and skips navigation when all three match. A host type change
still reloads, since it selects the page handler. A failed load is not
remembered, so the next selection retries.
Fixes#16752
* Show Track-Switch AMS Units Under Both Nozzles in the Calibration Wizard
With a Filament Track Switch installed the device layer pins every AMS to
the main extruder and records the real binding in GetBindedExtruderSet(),
but the calibration preset page still split the AMS units by
GetExtruderId(). Every AMS landed under the right nozzle and the left
nozzle only offered its external spool.
Split the panels by the bound extruder set, blank the external spools when
the switch is installed, and take a selected filament's extruder from the
panel it was picked in rather than from its AMS.
* Run the Flow Rate Fine Pass on the Extruder the Coarse Pass Used
When the fine pass starts from the coarse page the filament comes from
the cached preset, but the extruder was resolved from whatever the
preset page currently has selected. After a restart or reconnect, or if
the selection was changed, that no longer matches and the lookup falls
back to the per-AMS map, which with a Filament Track Switch pins every
AMS to the main extruder. Take the extruder from the cache in that path;
it already records the one the coarse pass was sent with.
# Description
<!--
> Please provide a summary of the changes made in this PR. Include
details such as:
> * What issue does this PR address or fix?
> * What new features or enhancements does this PR introduce?
> * Are there any breaking changes or dependencies that need to be
considered?
-->
Fixes#16693. After slicing, the Preview listed layer pauses one or more
layers too high, and with two adjacent pauses one of them showed as
layer 0. The G-code was always right: every pause is written at the
correct height, before the correct layer. Only the Preview's layer
numbering was wrong.
## Cause
When the G-code processor reads a pause, color change or custom G-code
tag, `OptionsZCorrector::set()` stores the index of that vertex in the
move list. At the first extrusion after it, `update()` moves the vertex
to that point so it renders at the new layer's height.
A pause (and a color change) first flushes the time planner. The flush
inserts actual speed moves ahead of the flushed blocks' moves, which all
come before the vertex, so the stored index goes stale and points at an
earlier move: the previous layer's last extrusion. `update()` then moves
that extrusion past the travel to the next layer, with its old layer id,
and erases a real move. The erase also shifts every later move down one,
so the time blocks still queued for the travel and unretract after the
pause point one move off; a Debug build trips
`assert(curr_move.actual_feedrate == 0.0f)` in
`TimeMachine::calculate_time` on a Marlin profile.
This has been possible since actual speed moves were added. It became
visible with the belt printer change that renumbers the Preview's layers
on every change of a move's layer id (`f64b49ab52`): the out-of-order
move now turns into two extra layers, the layer heights stop being
sorted, and the legend's lookup misses. 2.4.2 is not affected.
## Changes
- `OptionsZCorrector::on_moves_inserted()`, called at the end of
`GCodeProcessor::calculate_time`, shifts the stored index by the moves
the flush inserted before it, read from the block id map the same
function already builds for the queued blocks.
- `OptionsZCorrector::update()` returns the index it erased, and
`process_G1` moves the queued blocks after it down by one.
No change to the G-code, the time estimates of prints without pauses, or
project files.
# Screenshots/Recordings/Graphs
<!--
> Please attach relevant screenshots to showcase the UI changes.
> Please attach images that can help explain the changes.
-->
The reporter's cube with pauses at layers 55 and 56 (Z 11 and 11.2):
main lists them at layers 56 and 60 and shows 132 layers for a 128-layer
print; with this change they are at 55 and 56, and the slider shows 128
layers.
Before:
<img width="480" height="560" alt="legend-before-main"
src="https://github.com/user-attachments/assets/d9604038-91c0-4574-8496-a7d9f49268cf"
/>
After:
<img width="480" height="560" alt="legend-after-fix"
src="https://github.com/user-attachments/assets/0ad4be7e-a258-4eaa-ae94-8eb66ef01fae"
/>
## Tests
<!--
> Please describe the tests that you have conducted to verify the
changes made in this PR.
-->
- New test in `tests/fff_print/test_gcodeprocessor.cpp`, "A pause keeps
the moves around it in order and on their own layers": three layers with
a pause before the second; checks the pause's height and that layer ids
and G-code lines never go backwards. It fails on main (the pause stays
at Z 0.2 and a layer-0 extrusion lands after layer-1 moves) and passes
with the change.
- `fff_print` suite passes (484 tests, Release, Linux), including the
`[GCodeTiming]` cases.
- On Linux, sliced the issue's project with one and two pauses on the
Anycubic Kobra 3 (Klipper) profile and checked the Preview legend and
layer slider. Marlin is covered by the new test, which runs the
processor with Marlin.
- clang-tidy check passes.
<!--
> A guide for users on how to download the artifacts from this PR.
-->
[How to Download Pull Requests Artifacts for
Testing](https://www.orcaslicer.com/wiki/how_to_download_pr_artifacts)
# Description
Slicing finely detailed models such as HueForge reliefs is up to twice
as fast. Two steps that ran on a single core
dominated these slices. G-code export spent most of its time working out
which object each extrusion belongs to, and
internal bridge detection stalled for tens of seconds on layers printed
over fully dense infill. On the relief
"Mensch oder Gott 2", the slice goes from 108 s to 54 s on an M5 Max and
from 116 s to 65 s on Windows.
Over a lower layer printed at full density, bridge detection now settles
most layers with a cheaper check before it
falls back to the full computation. That check can disagree with the
full computation in one case, which is accepted:
a solid sliver thinner than about 16 µm that Clipper's own offset
simplification folds. There, internal bridges can
come out differently from main.
No change to slicing output on any project tested. G-code and object
masses are identical to main.
# Screenshots/Recordings/Graphs
<!--
> Please attach relevant screenshots to showcase the UI changes.
> Please attach images that can help explain the changes.
-->
## Tests
New unit tests compare the bridge-detection helper with the full
computation, and cover the box-only island lookup.
Main and this branch were compared on the projects below. They were also
compared on OrcaCube variants that set each
density option below 100%, plus a spiral vase, a crowded plate and a
two-part assembly. Every case slices to
byte-identical G-code, ignoring the timestamp line, and to identical
object and body masses. Slice times are for the
CLI, two runs each, on an M5 Max:
| Project | main | this PR |
|---|---:|---:|
| Mensch oder Gott 2 | 107.7 s, 108.8 s | 54.3 s, 54.4 s |
| Stranger Things 169×250 | 100.6 s, 100.6 s | 65.2 s, 66.0 s |
| RDR Front 229×256 | 12.6 s, 12.6 s | 8.6 s, 8.6 s |
| Lupo+AMS | 13.0 s, 13.1 s | 10.0 s, 10.0 s |
| Eagle 200×200 | 34.6 s, 34.0 s | 33.7 s, 34.0 s |
and on Windows with an Intel Core Ultra 7 270K Plus (Release build,
clang-cl), where the G-code is identical to main's
too:
| Project | main | this PR |
|---|---:|---:|
| Mensch oder Gott 2 | 121.2 s, 111.7 s | 68.2 s, 61.0 s |
| Stranger Things 169×250 | 100.7 s, 93.0 s | 59.7 s, 65.1 s |
| RDR Front 229×256 | 13.9 s, 13.4 s | 10.3 s, 10.1 s |
| Lupo+AMS | 19.9 s, 13.9 s | 20.9 s, 11.4 s |
| Eagle 200×200 | 38.9 s, 37.5 s | 38.1 s, 37.1 s |
Eagle uses about 15 s less CPU on both machines, but its export is bound
by G-code generation, so its slice time does
not change. Lupo's first run on Windows was slow with both builds. Peak
memory is the same within run-to-run spread,
except that it is about 0.1–0.2 GB higher on Stranger Things on the M5
Max and about 0.1 GB higher on Mensch oder Gott 2
on Windows.
<!--
> A guide for users on how to download the artifacts from this PR.
-->
[How to Download Pull Requests Artifacts for
Testing](https://www.orcaslicer.com/wiki/how_to_download_pr_artifacts)
main has since given texture displacement a model UV channel of its own
(ModelVolume::texture_uv). That channel belongs to a part rather than to
the object, so it joins base_mesh and the paint masks in the per-part
entry each job now carries, and every part maps through its own layout.
Also kept from main in the panel: panel_tooltip() in place of the wrapped
ImGui tooltip, and the plural forms of the triangle-count note - with the
count still summed over the parts the bake will act on.
The flow ratio calibration capped its top surface and internal solid
infill speeds with a Flow built from the profile's line width and layer
height. A line width of 0 (auto) made that Flow throw for negative
spacing, which left the main loop and terminated the app.
Build the Flow from the width and height the calibration actually
prints, nozzle x 1.2 by nozzle / 2, as 2.4.2 did. This also corrects the
cap for non-zero widths, which was computed for a narrower line than the
one printed and let the test exceed the filament's max volumetric speed.
A Type2 tower with a rib or rectangle wall still carried the cone from
wipe_tower_cone_angle (30 degrees by default, hidden unless the wall type
is Cone) in two places that model the tower: the fake tower used by the
G-code path conflict check, and first_layer_wipe_tower_corners, which feeds
the first-layer convex hull and the skirt. On a tall tower that phantom cone
reported conflicts with objects the tower never reaches, enlarged the
first-layer print area, and could push a combined skirt off the bed.
Both now use the angle only for a Type2 tower with a cone wall, the same
rule construct_mesh and the footprint estimate already follow.
merge_tcr formatted the feedrate of the travel that joins two wipe tower
blocks with std::to_string, which follows the numeric locale. The GUI slices
on a thread that keeps the user's locale, so a comma-decimal locale wrote
moves such as 'G1 Y249.463 F5400,000000', which Klipper rejects. Format it
with float_to_string_decimal_point like the X and Y beside it; the output in
the C locale is unchanged.
The comma-locale test helper moves to the shared test header so the wipe
tower test can use it.
When a saved prime tower position no longer fits the estimated tower, the
load-time clamp moved it to the comfort-margin bound with no regard for the
objects on the plate, and stored it without telling the user. A tower saved
in a corner could land on the model and produce a G-code conflict the user
never caused.
The GUI reload clamp and the CLI pre-slice clamp now keep the re-placed spot
only when it is clear of every printable object and its brim. Otherwise they
take the clear spot nearest the saved position, keeping the comfort margin
where the plate allows, and only fall back to the old spot when no space is
left. The GUI shows a notification whenever a saved tower is moved, and the
CLI logs a warning.
Some calls of the same script set fewer placeholders than the others,
so a placeholder the editor offers could stop the slice with "Variable
does not exist" on one path only:
- layer_change_gcode set max_layer_z after processing the template.
- Belt brim layers ran layer_change_gcode without
most_used_physical_extruder_id or the mass values. Both layer change
paths now share one helper.
- Printers that aren't bed slingers ran time_lapse_gcode with only
layer_num, layer_z and max_layer_z. Both timelapse paths now share
one helper for the snapshot placeholders, which picks the snapshot
position only when the template uses it.
- The Type 1 wipe tower ran filament_start_gcode without layer_num,
layer_z and max_layer_z, and filament_end_gcode without
filament_extruder_id and max_layer_z. filament_extruder_id is the
filament being unloaded, as in the Type 1 filament start G-code and
the end-of-print filament end G-code.
- The first filament start G-code on Bambu Lab printers had no layer_z
or max_layer_z.
The editor looks up a script's placeholder list by its option key, but
the timelapse list was keyed timelapse_gcode while the option is
time_lapse_gcode, so the editor showed no timelapse placeholders. The
list and the name passed to placeholder_parser_process, which the
placeholder validator looks up by, are now both time_lapse_gcode.
previous_extruder and next_extruder hold filament indexes, and
previous_extruder is -1 before any filament is loaded.
filament_extruder_id is the extruder index in filament end G-code at a
tool change outside the Type 1 wipe tower, and machine end G-code gets
the value from the last end-of-print filament end G-code. layer_num is
-1 before the first layer. total_wipe_tower_filament is a length in mm.
Since #13414 (v2.4.0), NetworkAgent calls default to the Orca cloud agent, whose Bambu-only methods are stubs that return empty data. These call sites didn't pass a provider, so firmware info, the MakerWorld task list, the cloud camera URL in Part Skip and Send to Printer, and the MakerWorld rating flow got empty data instead of calling the Bambu plugin. Pass get_printer_cloud_provider() at each one, as #13756, #14688 and #15911 did for the other call sites.
Use flock instead of fcntl for the refresh token lock on POSIX. An fcntl lock is held per process, so a second thread took it without waiting, and closing that thread's fd released it for the first thread too. Another Orca instance could then send the same refresh token while the first one was still rotating it.
Quit was only bound to Cmd+Q on macOS. Add a Quit entry to the shortcut
registry bound to Ctrl+Q and handle it in the global key handler, so the
shortcut reaches the app regardless of focus. The File menu shows it as
display text. The macOS-only key check is removed; Cmd+Q now goes through
the registry.
The fit box was the whole bed, so a model could sit on a bed_exclude_area
such as the corner notch on the Qidi Q2.
Fit into the bed minus each rectangular exclusion: every rectangle
spanned by bed and exclusion edges that overlaps no exclusion. Candidates
no wider than the bed padding are dropped, otherwise a sliver at the bed
edge wins and the model is scaled to nothing. Selection::fit_rectangle
keeps the candidate that allows the largest scale.
Fix Moonraker connection threads outliving a destroyed printer agent
connect_printer and disconnect_printer detached the in-flight
connection thread, so the agent's destructor could not join it. On
exit, clear_printer_agent_cache disconnects each agent and then
destroys it, and a connection thread whose query succeeded afterwards
used the freed agent.
Each connection thread now joins the one it replaces, so the
destructor's join waits for all of them. The server info and status
queries are cancelled once their connection is superseded, so the wait
is about a second at most. A superseded connection no longer writes its
status into the next connection's cache or reports itself connected.
clear_printer_agent_cache destroys the agents after releasing the
registry lock, since destroying one now waits for its threads.
Co-authored-by: Ian Chua <iancrb00@gmail.com>
The texture displacement gizmo took the object's layer stack, its options
and its bake target from the first model part, so a multibody object was
displaced only on that part. The brush paints across every part, so the
user's paint on the others was kept and then quietly ignored, and with
only a later part painted the Bake button stayed disabled.
The bake, prepare and preview jobs now each carry a vector of parts and
run them in one job, under one progress bar, one Cancel and one undo
step. Remesh and subdivide cover every part as well, since a part left
coarse has no vertices for a height map to move. The per-unwrap fields of
a layer (LSCM seam edges, island placements, their join groups and the uv
overrides) index the owning part's mesh and chart ids, so they are dropped
for the other parts and each part unwraps on its own; everything else in
the stack applies unchanged.
The layer stack, the options and the UV and seam editors stay on the
first model part - they are object-wide settings kept on one part, not a
per-part thing - and the Fast view still shades that part alone.
Fixes#16559
The G-code processor remembers where a pause, color change or custom
G-code vertex sits in the move list, so it can move that vertex to the
first extrusion after it. A pause flushes the time planner first, which
inserts actual speed moves ahead of the vertex, so the remembered index
pointed at an earlier move: the previous layer's last extrusion was
moved instead, a real move was erased, and the time blocks queued after
the vertex were left one move off.
Shift the remembered index by the moves each flush inserts before it,
and shift the queued blocks after the erase. The Preview numbers layers
from the move order, so the stray move showed up as extra layers and
listed pauses on the wrong layer.
The painting gizmos clip the selected instance at the plate, so a sinking
object stopped at the bed with nothing to show how it continues below it, and
the plate disappeared along with the bed mesh. Give every paint tool the same
view of that region:
- Draw the part of the selected instance below the plate at 50% opacity with
depth writes off, so it reads as the object going through the plate.
- Keep the plate and its grid while the bed mesh is hidden, instead of losing
every reference plane in the scene.
- Mark the plate intersection with a 0.4 mm outline rather than an opaque
filled cap, which covered the model and hid the ghost from above.
- Gate the bed mesh and the below-plate pass on the same predicate. Texture
displacement derives from GLGizmoPainterBase like the other painters but was
missing from the gizmo type list in is_bed_visible(), so it kept its bed.
- Add GLVolume::simple_render()'s ban_color_volume so the ghost keeps its alpha
for volumes with MMU segmentation facets, whose sub-models carry their own
opaque filament colours, and stop gating the ghost on is_active: the colour
painter marks the whole instance inactive and draws it in its own pass.
# Description
Slicing performance work, split out of #14662 so it can be reviewed on
its own. No new features and no behaviour change: the same G-code,
produced faster. Nothing here knows about texture displacement.
The trigger was a plate that took about 24 min to slice at 0.1 mm once a
colour texture was baked onto it. The cause is general, not
texture-specific: ClipperLib's sweep line costs grow with the number of
edges crossing a scan line, and any layer cut into tens of thousands of
small pieces (fine relief, dense colour painting, heavily fragmented
models) makes several per-piece loops redo whole-layer work.
## What changed
**Restrict whole-layer work to the neighbourhood that needs it**
- `make_fills`: clip the layer's no-overlap area to each expolygon's box
before intersecting.
- `discover_vertical_shells`: the small-piece filter compares only
against the nearby part of the layer.
- `bridge_over_infill`: whole-layer union/diff/intersection restricted
to the candidate's neighbourhood; fill boundary expanded once per
spacing; anchor tree built only from lines crossing the scan range; bbox
pre-check in the collision test.
**Batch booleans by tile instead of per piece.**
`ClipperUtils::tile_expolygons` groups a layer's pieces into tiles, so a
huge clip contour is clipped once per tile rather than once per piece.
`detect_surfaces_type` at 0.1 mm went from about 145 s to about 50 s.
**Parallelize what is already independent:** a layer's regions in
`detect_surfaces_type`, `process_external_surfaces` and
`discover_vertical_shells`; wall generation and solid infill splitting;
colour segmentation and vertical shells.
**Stop copying polygons on move.** `MultiPoint` had no `Points &&`
constructor, so every derived move constructor passing
`std::move(points)` copied them. Added it, marked the moves `noexcept`,
and made `append(vector&&)` move its elements. Note the consequence: a
moved-from `Polygon` or `Polyline` is now really empty where it used to
silently keep its points.
**Seam placement.** `visit_nearby_points` visits candidates as the k-d
tree finds them instead of collecting them into a vector first.
**Travel ordering and sharp-tail detection** test only the pairs whose
boxes can meet, through a uniform grid and a bbox pre-filter, instead of
every pair.
## Results
| | before | after |
|---|---|---|
| Painted plate, 0.1 mm, 2000k triangles | 1447 s | 587 s |
| Same plate, default 750k | 99.5 s | 85.6 s |
| Unpainted, 0.1 mm | 523 s | 430 s |
## Tests
**179 of 179 G-code outputs byte-identical** across 11 models and 17
configurations (default, fine layers, zero and dense infill, no shells,
normal and tree supports, extra bridge layers, interface shells, three
`ensure_vertical_shell_thickness` modes, thick walls, spiral mode, five
seam modes), comparing full library builds of this branch against its
merge base. The painted plate is part of that matrix, and it is the case
whose layers reach the tiling threshold at all.
New unit tests:
- `test_kdtree.cpp`: the visiting and collecting searches return the
same points in the same order, and a radius search returns exactly the
points inside the radius.
- `test_clipper_utils.cpp`: the tiled and plain `diff_ex` and
`intersection_ex` return the same rings with the same coordinates, with
and without the safety offset, compared after rotating each ring to its
lowest point and sorting. The fixture asserts it really is split into
more than one tile, so it cannot quietly stop covering the tiled path.
Don't log a parse error for a vendor profile pruned beside its cache
Packaging deletes <vendor>.json for every vendor that ships a .opc cache, but installable_cache_version still read it to compare versions. Every packaged build logged a JSON parse error per installed vendor at startup. Check that the file exists first, as installed_vendor_version already does. The returned version does not change.
Placeholders that GCodeProcessor fills in after the G-code is generated
(print_time_total_sec and the other print_time_* parts,
used_filament_length, and the print statistics such as total_weight)
hold a tag such as @TOTAL_WEIGHT@ while the template is evaluated.
Multiplying one already failed with a type error. Adding a number
joined the tag as text, so {total_weight + 5} printed 123.455 for a
123.45 g print, and a comparison compared the tag as text, so
{if total_weight > 100} was always true. Neither gave an error.
PlaceholderParser::set_deferred() now registers such a value. Printing
it and joining it to text work as before. A calculation, a comparison,
a regex or a condition on it fails with an error that says the value is
known only after the G-code is generated, also after it was copied to a
variable or through regex_replace(). Adding a number or another
deferred value to one is treated as a sum and fails too. Text that
already contains one joins a number as text, like any other string.
filament_change() inside an {if} branch that is not taken now does
nothing. It used to set the current extruder from an uninitialized
value.
The Printer and Filament title bars now toggle on mouse down instead of mouse up. Closing a dialog over a title bar could send it a stray mouse up, which folded the section. A double click is also bound so it still toggles twice, and Label passes double clicks to its parent.
Newer Qidi firmware for the Q2, Q2C, Plus 5 and Max 4 stores a slot's color as a hex list and its filament as a material id, and filament sync crashed on it. Each slot is now read in either form, the filament type comes from the box object, and any other JSON type error fails the sync instead of closing Orca.
The tab switch queued a reload of the host's home page, which ran after the import URL and replaced it. Switch tabs synchronously first, then queue the import URL so it is the last page loaded.