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

SciView: set active node only when centerOnNewNodes is true #551

Merged
merged 2 commits into from
Feb 12, 2024

Conversation

smlpt
Copy link
Contributor

@smlpt smlpt commented Feb 9, 2024

This fixes an issue where adding new objects to the scene would be slowed down by the fact that each new node would always be set as the active node. This would also cause excessive log outputs about each active node like:

[INFO] Custom module found: null
[INFO] Adding input scaleX/Scale X
[INFO] Custom module found: null
[INFO] Adding input scaleY/Scale Y
[INFO] Custom module found: null
[INFO] Adding input scaleZ/Scale Z
[INFO] Custom module found: null
[INFO] Adding input rotationPhi/Rotation Phi
[INFO] Custom module found: null
[INFO] Adding input rotationTheta/Rotation Theta
[INFO] Custom module found: null
[INFO] Adding input rotationPsi/Rotation Psi

With this fix, new nodes are only considered active when centerOnNewNodes is set to true.

@xulman
Copy link
Contributor

xulman commented Feb 9, 2024

the setActiveNode() (even in the new proposed position) will not follow the activePublish flag.. no? it would always trigger the publishing event (yes, a different one, but still some)

for me, the purpose of the activePublish flag was that I could temporarily suspend publishing when adding a burst of nodes, and trigger the publishing only with the last node added

just thinking now aloud

@smlpt smlpt marked this pull request as draft February 9, 2024 16:24
@smlpt
Copy link
Contributor Author

smlpt commented Feb 12, 2024

I changed it so that setActiveNode is only called if activePublish is true:

fun <N: Node?> addNode(n: N, activePublish: Boolean = true, block: N.() -> Unit = {}, parent: Node = scene): N {
        n?.let {
            it.block()
            // Ensure name is unique
            n.name = generateUniqueName(n.name)
            parent.addChild(it)
            objectService.addObject(n)
            if (blockOnNewNodes) {
                Utils.blockWhile({ this.find(n.name) == null }, 20)
                //System.out.println("find(name) " + find(n.getName()) );
            }

            if (activePublish) {
                eventService.publish(NodeAddedEvent(n))
                setActiveNode(n)
                // Set new node as centered
                if (centerOnNewNodes) {
                    centerOnNode(n)
                }
            }
        }
        return n
    }

@smlpt smlpt marked this pull request as ready for review February 12, 2024 10:57
if (centerOnNewNodes) {
centerOnNode(n)
setActiveNode(n)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking setActiveNode would go into the activePublish and the if for centerOnNode would as well, but not setActiveNode into the if from centerOnNode. I'm happy to be convinced otherwise though.

@kephale
Copy link
Member

kephale commented Feb 12, 2024

LGTM, than you @smlpt

@kephale kephale merged commit 80c8403 into main Feb 12, 2024
4 checks passed
@kephale kephale deleted the fix/fix-set-active-node branch February 12, 2024 13:01
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.

3 participants