Closed pieper closed 6 years ago
Hi Steve,
Thanks for the note.
It should be possible to easily give access to the renderer from Python. Is what you mean ?
Jc
On Dec 19, 2017 4:35 PM, "Steve Pieper" notifications@github.com wrote:
First: excellent work 👍
Second: I'm running a Slicer binary provided by Mark at Queens and I want to experiment with controls and widgets but it looks like nothing is exposed in python right now - is that true?
I realize I could compile from source and work in C++ but I'd prefer to write scripted modules.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/KitwareMedical/SlicerOpenVR/issues/15, or mute the thread https://github.com/notifications/unsubscribe-auth/AANXo-ia-bAkiyQF4kJylxFG66axAzZfks5tCCwTgaJpZM4RHlpr .
Hi @jcfr - I was thinking it would be great to query the controller locations, get vtk events one button presses, that sort of thing. In Slicer we may want to mirror those values in MRML nodes but for initial experimentation we could make a lot of progress with some simple accessor methods.
For example at this point the camera controls are workable, but pretty simple. And is there any connection yet with the vtk widgets? These would be good things to try at project week.
This is awesome.
We would benefit from this as well (again via the binary from Mark/the PERK group)
@pieper : Thanks to @cpinter , you can now get a reference to qMRMLVRView using vrWidget() functions.
For example:
>>> slicer.modules.vr.widgetRepresentation().initializeVR()
>>> slicer.modules.vr.widgetRepresentation().vrWidget()
qMRMLVRView(0x623f7a0, name="VRWidget")
Note that in the near future:
vrWidget
may be changed into vrView
shortly. VirtualReality
name of function vrWidget may be changed into vrView shortly
Absolutely. I think I wanted to keep this naming convention
👍
Few snippets that work for me and may be helpful:
# Get VR module widget
vrModuleWidget = slicer.modules.virtualreality.widgetRepresentation()
if vrModuleWidget is None or vrModuleWidget.vrWidget() is None:
return
# Get VR camera
rendererCollection = vrModuleWidget.vrWidget().renderWindow().GetRenderers()
if rendererCollection.GetNumberOfItems() < 1:
logging.error('Unable to access VR renderers')
return
self.vrCamera = rendererCollection.GetItemAsObject(0).GetActiveCamera()
# Determine if VR has been initialized
vrInitialized = (vrModuleWidget is not None and vrModuleWidget.vrWidget() is not None and vrModuleWidget.vrWidget().mrmlVRViewNode() is not None)
That's helpful @cpinter !
Is it also possible to show and example of adding observers to the controller buttons and getting out the controller transform?
It would be very useful indeed and I want to have these too. I am still working on more low-level issues, such as that VTK does not handle the Oculus controller (I use an Oculus nowadays), or multi-volume rendering in Slicer. In the meantime I can give pointers where in the VTKRenderingOpenVR code the interactions are handled that need to be exposed.
Thanks - No rush - just curious!
Thanks @cpinter , added a "Python snippet" section to the README file. See https://github.com/KitwareMedical/SlicerVirtualReality/blob/master/README.md#useful-python-snippets
Great! I was thinking about adding this to the Slicer script repo, but it doesn't belong there. This way is perfect, thanks!
First: excellent work 👍
Second: I'm running a Slicer binary provided by Mark at Queens and I want to experiment with controls and widgets but it looks like nothing is exposed in python right now - is that true?
I realize I could compile from source and work in C++ but I'd prefer to write scripted modules.