How to display a line with interaction handles by python?

How to display a line (vtkMRMLMarkupsLineNode) with interaction handles by python?

@lassoan@Juicy@jamesobutler @jcfr @pieper

like that:

  1. First get the reference to vtkMRMLMarkupsLineNode (see get-mrml-node-from-the-scene)
  2. Get the DisplayNode for that Line Node. (similar to change-markup-fiducial-display-properties)
  3. The interactive handles can be set from the DisplayNode. SetHandlesInteractive.
2 Likes

Great! Thanks!
DisplayNode.SetHandlesInteractive(True)

@jamesobutler

Is it possible to further control the position of the “origin” and “rotation” or “translate” of the handle?
是否可以进一步控制handle的"原点"的位置以及"rotation"或者"translate"呢?

Yes. They are all methods in the Markups Display Node class.

1 Like

@jamesobutler

I want the “Origin” of this Handle to be at the end of the line segment instead of the midpoint, how to do it?

我想让这个Handle的原点,在线段的一端而不是中点,怎么做呢?

That’s not something that I believe is possible at the moment.

@jamesobutler
Thanks

You can position a line shaped actor (e.g., that you generated using SlicerIGT extension’s Create Models module) using a transform. You can update the transform from a markups plane node by a few lines of Python code. This technique is used in the Bone Reconstruction Planner extension.