Repository navigation
Conversation
The scene moves the node when the model reports the new position. itemChange() then moves the connections of the node. mouseMoveEvent() moved them a second time, so each connection was moved and repainted twice per mouse move. The test counts the connection lookups for one mouse move. It also checks that the connection follows the node before the release.
hoverEnterEvent() lowers the raised items that overlap the node. It called collidingItems(), which tests the shape of every overlapping item. A node always overlaps its own connections, so each hover built the stroke of every connection of the node. Only items with a z value above 0 can change. The loop now checks the z value first and runs the shape test only for those items. Connections have a z value below 0, so they build no stroke. The set of lowered items is the same as before. One test checks that a hover builds no connection stroke. A second test checks which items a hover lowers and which it keeps.
|
Thank you for the change. To save you a round trip, we rebased your two commits on the current We will merge #578. This pull request stays open until then, and we will close it when #578 is merged. We checked the hover change on a scene with 5000 nodes. The new loop does not grow with the size of the scene (0.035 ms, against 36 ms for the old |
Type of change
Description
Two performance fixes in
NodeGraphicsObject. One commit each.Move the connections of a dragged node once per mouse move.
The scene moves the node when the model reports the new position.
itemChange()thenmoves the connections of the node.
mouseMoveEvent()moved them a second time, so eachconnection was moved and repainted twice per mouse move. The second call came with the
group support. The group branch (
groupGraphicsObject().moveConnections()) is unchanged.Test only raised items for overlap when a node is hovered.
hoverEnterEvent()lowers the raised items that overlap the node. It calledcollidingItems(), which tests the shape of every overlapping item. A node always overlapsits own connections, so each hover built the stroke of every connection of the node.
Only items with a z value above 0 can change. The loop now checks the z value first and runs
the shape test only for those items. The set of lowered items is the same as before.
The loop reads
scene()->items(). This sorts the items once per hover enter, not per mousemove.
Testing
test_nodes: 98 test cases, 972 assertions)New tests:
A node drag moves the connections of the node once per mouse movecounts the connectionlookups for one mouse move, with grouping on and off. It fails without the fix (2 instead
of 1). It also checks that the connection follows the node before the release.
Hovering a node builds no connection strokesfails without the fix (1 stroke).Hovering a node lowers the raised items that overlap itpasses before and after the fix.It checks that an overlapping node and a raised connection are lowered, and that a distant
node and a group keep their z value.
Not tested here: Qt 5, Linux and macOS. I rely on CI for these.
Timing, scene only, no view and no painting. One node with N connections, 1000 events.
Grouping off. The connection painter strokes the cubic once. Both builds come from clean
build folders: master at ea8718f, this PR at its head. The table shows two runs. Run 1 is
the median of 3 interleaved rounds. Run 2 is the median of 5 rounds, and the order of the two
builds alternates per round. Each round is the median of 7 samples.
The machine is shared. Absolute times vary by about 5 to 10 % between runs. For drag with
N = 50, master varied from 527 to 644 ms between rounds, so that change is between -50 %
and -55 %.
Run 2 also counted the work of one run per scenario:
The extra lookup in each drag run comes from the final position check of the benchmark.
After each run the benchmark checked that the node, the model position, the connection
end points and the z value are correct. All runs passed this check on both builds.
Breaking changes?
No. No API or ABI change.
Related issue
None.
🤖 Generated with Claude Code