[vtk-developers] Just making sure I submitted everything right

Jon Garner thehappydog84 at gmail.com
Fri Jan 13 16:48:03 EST 2017

This was my first submit to any open source project before so I'm just
check to make sure I did this all right.  My Merge request is linked
below.  I tagged a couple of people that had helped me when I was working
through getting it all submitted, just thought I'd put this out there in
case I should have tagged someone else.



Here's my commit notes of the class I submitted if anyone is interested.

vtkInteractorStyleDrawPolygonType2 is an interactor style that will allow
the user to draw a straight-line polygon in the render window using left
mouse button clicks to create nodes. A straight-line is drawn from node to
node. When the right mouse button is pressed, a SelectionChangedEvent will
be fired.

My intention in creating this style is to ultimately use it in conjunction
with another class (that will need to be created) to create a polygonal
selection tool to select specific points in point cloud data. As best as I
could tell this capability doesn't exist in VTK and I noticed a few people
asking for it. It is something I find critical when working with point
cloud selection and I¿m sure there are other applications where this could
come in handy.

Currently there is a vtkInteractorStyleDrawPolygon interactor style, I
would consider this a 'DrawLasso' at least in comparison to other software
naming conventions (photoshop), so I wasn't sure what to call this style so
I went with 'DrawPolygonType2'. I figure that 'Type2' could be renamed to
something more appropriate by someone more knowledgeable.

The basic process for of the class is as follows: (1) Once the class is
initiated (press 'o'... not sure if that is used for something else) it
then starts looking for the OnLeftButtonDown event. (2) On the first
OnLeftButtonDown the initial node is drawn and a toggle is triggered to
allow OnMouseMove to begin. (3) OnMouseMove draws the whole polygon
connecting the current mouse position back to the last node and the
starting node with a straight line. (I'll return to this further down) (4)
Each OnLeftButtonDown draws a new node at the cursor position. (5)
OnRightButtonDown Invokes SelectionChangedEvent additionally it toggles the
interactor style back to trackball camera, pressing 'o' does the toggle

Issues I see and what I'd like to add/fix: (1) Issue: when Left Clicking
very near the edge of the render window I sometimes get a crash, I think
this is from the pixels being out of range I used similar conditions from
vtkInteractorStyleDrawPolygon, but I do still get the crash. Need to work
on this some more. (2) Issue/Feature: As mentioned in note (3) above the
OnMouseMove draws the entire pixel array at every movement causing a
flicker of the line. This is where my lack of knowledge of VTK isn't
helping, I recall reading about layered rendering within VTK but I haven¿t
had time to dig back through the manual or examples to find what I'm
looking for. What I¿m thinking is the only thing that needs to be redrawn
during OnMouseMove is the lines from the cursor to the first and last
node(so use a separate Renderer or something in the same renderwindow?? I'm
not sure, like I said I need to read and play around with stuff some more)
(3) Feature: Eventually I'd like to be able to select a node and adjust it
as needed. Haven't put a lot of thought into this, it'd just be nice. (4)
Feature: Would like to be able to pan/zoom and keep the polygon in it's
relative position (not a priority at all may come back to it once I get the
selection class worked out), can explain further if anyone is interested.


Jon Garner
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20170113/c1490cdd/attachment.html>

More information about the vtk-developers mailing list