As an exercise of advanced custom tool, I started to write a bezier spline editing HDA, to reproduce the workflow I have in e.g. Inkscape. I implemented this using the new python ViewerStates available since H17, which are great, but I need a bit of help to make thing clean regarding the following points:
1. Display-only geometry. How to use geometry for display only, not as object data? For instance, I generate geometry in the subnetwork to visualize the tangents, but I don't want them to be listed in geometry spreadsheet. I may need to manually call some render line function, but I don't see where/how.
2. Custom handles. I use the curvepoint handle, but I would like to set per control point shape and color. And curvepoint does not trigger onHandleToState when moving points around, etc. Is it possible to build its own handle? It might be solved by the previous question, but is there an “official” way to do so?
3. Multiple tools. I have different ways of interacting with my spline: adding points, moving points, selecting points, etc. Should I implement them in a single viewer state, using button parameters to switch tool, or is it more idiomatic to write several viewer states? The current implementation uses the former.
4. When a click triggers onMouseEvent, how to detect that it hit a handle? I would like to have behavior such as “add a point at the click position unless it was a click on the translate handle”.
5. Handle activation. How to deactivate (hide) a handle in onStateToHandle? For translate node, I went for the hacky “tx = 99999.9”. For the curvepoint handle, I tried to set the pointlist parameter to an empty string but it “breaks” it, namely when I switch the value back to a non empty string, the handle remains invisible unless I deselect-reselect the node.
6. Selection. Should I rely on houdini's selection mechanism to select the points I want my handle to move around, or should I implement my own selection process?
You can find a HDA in attachements.
The main script of the module: https://gist.github.com/eliemichel/7bd59adc6d134b602d59861406fb5933 [gist.github.com]


