Skip to content

Polygon Tool: Add + Delete Points#396

Merged
floryst merged 10 commits intoKitware:mainfrom
PaulHax:polygon-add-delete-points
Aug 30, 2023
Merged

Polygon Tool: Add + Delete Points#396
floryst merged 10 commits intoKitware:mainfrom
PaulHax:polygon-add-delete-points

Conversation

@PaulHax
Copy link
Collaborator

@PaulHax PaulHax commented Aug 22, 2023

Left click polygon line to add a point. Right click a point to show delete point context menu.

TODO

  • immediately set added point to "activeState" after click. At the moment have to move mouse (ping WidgetManager to updateSelection?)
  • Hold left button to immediately drag added point
  • Docs

Closes #388

@netlify
Copy link

netlify bot commented Aug 22, 2023

Deploy Preview for volview-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 21e2c82
🔍 Latest deploy log https://app.netlify.com/sites/volview-dev/deploys/64ee064804350700084cca16
😎 Deploy Preview https://deploy-preview-396--volview-dev.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@PaulHax
Copy link
Collaborator Author

PaulHax commented Aug 22, 2023

After I drop a new Polygon handle, it is under the mouse. But the next click starts a new polygon instead of triggering a grab on the handle. WidgetManager only updates selection on mouse move.

Is there a way to poke WidgetManger to run its updateSelection() manualy? Craft an event for the renderWindow interacter?

@PaulHax PaulHax changed the title Polygon add delete points Polygon Tool: Add + Delete Points Aug 22, 2023
@floryst
Copy link
Contributor

floryst commented Aug 22, 2023

Maybe unrelated, but I wonder if picking during animation will help here. I have some pending changes to the WidgetManager to support this.

@PaulHax
Copy link
Collaborator Author

PaulHax commented Aug 22, 2023

If the widget behavior could trigger an animation on left click and the handle under the mouse gets selected, that would do it.

It might make sense to have just have "widgetManager.setSelectedWidget" so widget behaviors could trigger "dragging" state syncronously right after button down that placed a new widget?

@floryst
Copy link
Contributor

floryst commented Aug 24, 2023

Would widgetManager.grabFocus(widget) work for your use case?

@PaulHax
Copy link
Collaborator Author

PaulHax commented Aug 24, 2023

Would widgetManager.grabFocus(widget) work for your use case?

That would be perfect. Let me try.

@PaulHax PaulHax marked this pull request as ready for review August 28, 2023 12:15
@PaulHax
Copy link
Collaborator Author

PaulHax commented Aug 28, 2023

Regarding synchronously selecting/dragging a handle:

Would widgetManager.grabFocus(widget) work for your use case?

This was the right concept... and the right function was publicWidgetAPI.activateHandle()

Still have a slight behavior bugaboo: Can't immidatly drag a handle after finishing a polygon without mouse movement. But this PR is ready for review.

@PaulHax PaulHax requested a review from floryst August 28, 2023 14:24
Copy link
Contributor

@floryst floryst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be waiting for the LineGlyphRepresentation from your vtk.js PR?

PaulHax added 10 commits August 29, 2023 10:52
Factor out watchState to ToolWidgetUtils
Calling model.widgetState.deactivate() in mouse up means we could
not click and grab the handle again without first moving the mouse
to re-activate the widget handle.
Would keep adding points if:
1. Clicked on a segment and drop handle.
2. Without moving mouse, click again.
3. Dropped another handle instead of grabbing current handle.
Double clicking anywhere on polygon would trigger finish placing
logic.
@PaulHax
Copy link
Collaborator Author

PaulHax commented Aug 29, 2023

Don't think we should wait for LineGlyphRepresentation PR to land in VTK.js. LineGlyphRepresentation files are idential now, we can switch over to VTK.js import latter.

PR good to go... again.

Copy link
Contributor

@floryst floryst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

For the future, we will look into improving the WidgetManager's picking scenarios. Additionally, when we start supporting dragging annotations, adding points might become a right click context menu action.

@PaulHax
Copy link
Collaborator Author

PaulHax commented Aug 29, 2023

Musings on WidgetManager picking, methinks we need to call this sometimes:
https://github.com/Kitware/vtk-js/blob/7f404e99c414d5ce4e6e66da724df09dbc6b999b/Sources/Widgets/Core/WidgetManager/index.js#L130

Idea A: Let a widget explicitly trigger 'updateSelection' after it has done something (change camera, added/moved handle, etc)

idea B: WidgetManager calls 'updateSelection' after animation or widget interaction end event fired by widget. Implict.

Another note: took me a while to realize widgetModel.activeState is the currently hovered on handle. I was confused as it is manged/set by WidgetManager via activateHandle, even though widget behavor.js changes activeState as well. Maybe push activateHandle code into widget code (AbstractWidget?) and WidgetManger simply sends PointerHover, PointerDown, PointerUp, etc events to widgets.

WidgetManager does so much. Maybe extract the "when to Hardware Pick" logic into seperate code chunk which caches Hardware Picker results. WidgetManager observes CachedHardwarePicker. WidgetManager then just dispatches events to (focused?) widgets. Or something.

@floryst floryst merged commit 64170c0 into Kitware:main Aug 30, 2023
PaulHax pushed a commit to PaulHax/VolView that referenced this pull request Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Polygon Tool: Add and delete points

2 participants