Hi all,
I have struggle with MRMLTransformSliders. since there are 3 sliders inside it, how we can access each slider’s value? Or if it is an attribute to extract transform matrix still is useful.
thanks
I guess I need to find them in findChildren attribute as:
import slicer
from qt import QSlider
# Create an instance of qMRMLTransformSliders
transformSliders = slicer.qMRMLTransformSliders()
# Find all sliders within the qMRMLTransformSliders widget
sliders = transformSliders.findChildren(QSlider)
# Access the translation sliders
translationSliders = sliders[0:3] # Assuming the translation sliders are the first three in the list
# Get the values of the translation sliders
lrTranslation = translationSliders[0].value()
paTranslation = translationSliders[1].value()
isTranslation = translationSliders[2].value()
I think it’s a better strategy to observe the transform node. Whenever there is a TransformModifiedEvent evoked by the transform node, you can take the transformation matrix (or vtkTransform) out of the transform node, and obtain the translation and rotation values using VTK.
Thanks @ungi do you have any example for that?
You can find examples in the Slicer script repository for adding observers to nodes. In this case you need to observe the TransformModified event.