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

Add ability to register selection callbacks in usdview #663

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

aloysbaillet
Copy link
Contributor

Description of Change(s)

The UsdviewApi class now includes two new methods: AddPrimSelectionChangedCallback() and RemovePrimSelectionChangedCallback(). These methods allow third-party plugins to connect Qt slots with the signalPrimSelectionChanged Qt signal that is emitted by the internal SelectionDataModel object.
This allows plugin views to synchronise themselves as the application selection changes.

@jtran56
Copy link

jtran56 commented Oct 17, 2018

Filed as internal issue #USD-4840.

@spiffmon
Copy link
Member

spiffmon commented Nov 2, 2018

Thanks, Aloys - this is clearly needed! Can we plus the low-level Qt pattern with RAII to ensure the signal gets properly disconnected when the plugin widget dies? I.e. something like CreateSelectionSignalConnector(callback) that returns an object whose del will disconnect?

@aloysbaillet
Copy link
Contributor Author

Hi Spiff, thanks this makes sense indeed!
I'm not actually the author of the PR but I discussed with JP (who is) and we'll try to have some updates soon!

@aloysbaillet
Copy link
Contributor Author

aloysbaillet commented Nov 22, 2018

From JP:

Connect to the File > Open event

  • Expose the signalStageReplaced Qt signal, so that clients can respond to the File > Open operation and update to reflect thew newly-opened USD stage.
  • In a similar manner to the signalPrimSelectionChanged signal, we introduce two new methods on UsdviewApi:
    • AddStageReplacedCallback(): Connect a slot to this signal.
    • RemoveStageReplacedCallback(): Disconnect a slot from this signal.

Introduce RAII pattern for Qt signal-slot connection

  • There was also a request to encapsulate these in an RAII-style resource idiom. It is unclear if this adds any value, as the Qt documentation suggests signals and slots are automatically disconnected when QObjects are deleted: http://doc.qt.io/archives/qt-4.8/qobject.html#dtor.QObject
  • In any case, we have attempted to add this pattern via CreateStageReplacedConnection() and CreateSelectionChangedConnection(), each of which returns a Qt signal/slot pair encapsulated by a UsdviewSignalSlotConnection object.
  • However, in our plugin testing, we found that the del() method was never being called. According to Python documentation, we cannot guarantee that Python objects will ever be garbage collected, so Python doesn't inherently support the RAII idiom.

@aloysb

@spiffmon
Copy link
Member

spiffmon commented Jan 4, 2019

Thank you, JP, and Aloys!

Given the information you reported, it seems like the RAII mechanism I asked for is not useful indeed, and sets up conflicting terminology in the API. Could I ask you to remove it, and also provide a brief doc string for the remaining four new methods?

Thanks, looking forward to accepting this!
--spiff

@c64kernal c64kernal added the blocked Issue fix or pull request blocked until questions are answered or pending notes are addressed label Feb 22, 2019
AdamFelt pushed a commit to autodesk-forks/USD that referenced this pull request Apr 16, 2024
@aloysb
Copy link

aloysb commented Mar 13, 2025

I don't think you wanted to tag me here @aloysbaillet

Nice to meet another Aloys though :)

@jesschimein
Copy link
Collaborator

/AzurePipelines run

Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Issue fix or pull request blocked until questions are answered or pending notes are addressed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants