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
Improve Event Delegation in qMRMLThreeDView and qMRMLSliceView #7311
Improve Event Delegation in qMRMLThreeDView and qMRMLSliceView #7311
Conversation
6b58b0e
to
d7492b3
Compare
d7492b3
to
2f7a6cc
Compare
Refactor vtkMRMLThreeDViewInteractorStyle and vtkMRMLSliceViewInteractorStyle to derive from vtkObject and implement event delegation to MRML displayable managers and associated widgets by observing the interactor style. This will allows to associate specialized interactor styles like vtkOpenXRInteractorStyle or vtkOpenVRInteractorStyle with render window while maintaining the MRML specific event delegation. Co-authored-by: Lucas Gandel <lucas.gandel@kitware.com>
2f7a6cc
to
80fba35
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t like going back to using interactor style, as it is just an unnecessary additional layer that adds complexity and not sufficient to actually handle all interactions in complex applications. Interactor styles should be rather removed from VTK, too (and let VTK widgets handle camera movement).
However, I cannot pinpoint any functional errors with the changes and I see that you worked a lot on this and would not want to hold up things that depend on these changes, so I'm OK if the changes are merged.
return; | ||
} | ||
this->Superclass::OnKeyPress(); | ||
this->GetInteractorStyle()->OnKeyPress(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If all we do is calling the Superclass implementation then it is better to remove the method completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intended to keep the same behavior as we had before, I will create a follow-up pull request and/or issue to move forward with simplification
@@ -37,43 +40,44 @@ class vtkTimerLog; | |||
/// Some additional high-level events (such as click and double-click) | |||
/// are generated here. | |||
class VTK_MRML_DISPLAYABLEMANAGER_EXPORT vtkMRMLViewInteractorStyle : | |||
public vtkInteractorStyle3D | |||
public vtkObject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why it is not based on an interactor style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because our vtkMRMLViewInteractorStyle
are technically observer and not interactor style anymore. For more details, see section Refactor Interactor Styles
in #7310
For sake of reducing the amount of changes and allowing easy review, I didn't rename our classes. For more details, see section Renaming Interactor Styles
in #7310.
@@ -110,7 +111,8 @@ bool vtkMRMLThreeDViewInteractorStyle::DelegateInteractionEventToDisplayableMana | |||
// Get display and world position | |||
int* displayPositionInt = this->GetInteractor()->GetEventPosition(); | |||
vtkRenderer* pokedRenderer = this->GetInteractor()->FindPokedRenderer(displayPositionInt[0], displayPositionInt[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FindPokedRenderer
is error-prone. If somebody adds any content to the render window in a new renderer then it may break picking and or interaction with other widgets. It would be safer to pass the main 3D content renderer, not whatever renderer happened to be found at that position.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, this can be improved and I will create a dedicated issue to improve and address this. In prefer to keep the existing behavior and focus this pull request on only revisiting the observation of the interactor style events.
After discussion with @LucasGandel, we indeed acknowledge that the VTK interactor style currently implemented in the
Thanks for reviewing and provided detailed feedback. As you indicated, while this is not the "best" path forward, it allows to move forward 🙏 Now that I commented inline, let me know if you have other questions before approving ✔️ |
As a point of clarification, this pull-request does not add any functional changes.
Doing so allows to associate the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the responses, I have no further questions.
This pull request is aimed at streamlining the review process and testing by consolidating several independent changes, each of which will be contributed separately.
The primary focus for review in this pull request is the last commit, titled
ENH: Improve Event Delegation in qMRMLThreeDView and qMRMLSliceView
.In this commit, we've refactored
vtkMRMLThreeDViewInteractorStyle
andvtkMRMLSliceViewInteractorStyle
to inherit fromvtkObject
and have implemented event delegation to MRML displayable managers and their associated widgets by observing the interactor style.This enhancement allows for the association of specialized interactor styles, such as
vtkOpenXRInteractorStyle
orvtkOpenVRInteractorStyle
, with the render window while still maintaining MRML-specific event delegation.Dependent Changes
The introduction of the commit
ENH: Allow virtual func to be called during MRML(ThreeD|Slice)View pimpl init
necessitates an update to CTK, which can be found in the following pull request:Update: CTK pull request commontk/CTK#1153 has been integrated upstream and corresponding
External_CTK.cmake
update has been added to this pull request by integrating the commits being contributed in the following pull request:Associated independent changes are being contributed in these pull requests: