Repository navigation
Reduce the work of node drag and node hover - #578
Merged
Merged
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.
3 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change
Description
This is #571 by @Doome161, rebased on the current
master. The two commits are unchanged, and the author is kept. The only conflict was the list of test files intest/CMakeLists.txt: #575 and #571 both add entries at the same place. The source file merged without changes.Two performance fixes in
NodeGraphicsObject:itemChange()then moves the connections.mouseMoveEvent()moved them a second time, so each connection was moved and repainted twice per mouse move. The group branch is unchanged.hoverEnterEvent()calledcollidingItems(), which tests the shape of every overlapping item, and a node always overlaps its own connections. Now the z value is checked first, and the shape test runs only for raised items. The set of lowered items is the same as before.The timings of the author are in #571 (a drag of one node with 50 connections: about 50 % less time; a hover: 99 % less). I did not repeat that benchmark. What I measured myself, for the loops alone and without painting: with 5000 nodes (about 10000 items) the old hover loop took 36 ms and the new one 0.035 ms, and the new loop does not grow with the size of the scene.
Testing
masterplus the 3 new tests of the author).Not tested: Qt 5, Linux, Windows. I did not build each of the two commits on its own.
Breaking changes?
No API or ABI change.
Related issue
Replaces #571.