Polydraw/edit tool click and drag

I’m starting to implement the PolyDraw and PolyEdit tool for some pretty cool stuff.

What I have in place now is a customjs callback that triggers when the polydraw/polyedit tool’s renderer CDS changes. I also have a separate glyph/datasource of rects storing data/spatial information. The callback identifies the rects (centroid only) that are contained within the polygon the user just drew (and set them as the selected indices too just for visual aid). Then I can do useful aggregation/analysis of those arbitrarily selected points like make histograms etc. They can then also move that polygon around and or edit it’s vertices and the selection will update accordingly. Essentially I’ve just reinvented the polyselect tool with the polydraw tool but with the added benefit of being able to edit vertices (via polyedit), move that selection polygon around (via drag), and (eventually… not implemented yet), allow for multiple polygon selections in two completely different areas to happen.

Here’s what it looks like:

Example1

It’s pretty sweet and almost exactly what I want. Notice how the selection only updates when I “release” the drag? I am wondering if I can get it to work more like this d3js mona lisa example:

Where it’s updating the polydraw’s datasource dynamically while I drag it around (MouseMove?)? This question would extend to the polyedit tool, where it would update the datasource dynamically as i move a vertex around. This is how it works with the selection tool, so maybe there’s some code/logic in there I could utilize… As always, any insight appreciated!

Gaelen

@gmerritt123 looking at the source code:

The current PolyEditTool does not emit any changes during the middle of pan events, so what you are asking is not possible with the built-in tool. Two options:

  • subclass a custom extension edit tool that calls self._emit_cds_changes (see how the _pan_end method does that

  • make a GitHub Issue to request continuous updating as a configurable option

1 Like

Awesome, thanks for pointing me to the relevant source code (major shortcut for me to find the right stuff to play with). So with that in hand now I’m gonna give option 1 a try for my own learning and we’ll see how it goes. Thanks again

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.