Picking tube between points of PolyLineWidget

I’ed like to click on a “line” of the PolyLineWidget and add a point/handle there. I don’t know how to get the index of where I want to insert a new handle. How to do that?

Assuming I want the “cell” of the line, attempted some things with

  • HardwarePicker: I don’t know how to inteprate the attributeID (attributeID = cellID? But attributeID changes as mouse moves over same line.)
  • CellPicker: picker.getActors().length always = 0

I’m not sure how you get values for attributeID. I tried the PolyLineWidget example and failed to have an attributeID other than undefined in the widget manager.

CompositeID is only valid/useful when mousing over a GlyphMapper actor (only the GlyphMapper calls renderCompositeIndex).

Problem is, vtkPolyLineRepresentation is using a vtkTubeFilter and a regular mapper (and not a vtkGlyphMapper).
An idea 1) would be to change vtkPolyLineRepresentation to rely on the GlyphMapper (one glyph per handle) by deriving from vtkGlyphRepresentation. The glyph mesh could be a cylinder, and the “scale” would be the distance between the handle and the next handle.

You would then have an automatic mapping between the clicked cylinder and the handle state.
That is not perfect though:

  • not fixable: you wouldn’t have a nice joint between each cylinder (which the tube filter does well )
  • fixable: you would have to tweak the cylinder radius to support scaleInPixels.

Option 2: keep investigating what this attributeID is, maybe you could enhance the vtkTubeFilter polydata to pass useful information to the picker.

1 Like

Thanks for the guidance Julien!

I went with the GlyphMapper approach.

Upgrading TubeFilter looked tricky. attributeID from the HardwareSelector is the cellID (if hardwareSelector.setFieldAssociation( FieldAssociations.FIELD_ASSOCIATION_CELLS ); The TubeFilter cells are triangle strips that extend along the entire line/tube. So cellID does not help narrow down the clicked “segment.” Would need to impliment some special render mode like GlyphMapper’s renderCompositeIndex with the color coming from “segment” index/ID?