Skip to content

Conversation

@TreatTrick
Copy link

Context

SplineWidget adds new points through left mouse button clicks and confirms all points by pressing the Enter key on the keyboard.
The bug reproduction steps are as follows:

  1. Run npm run example SplineWidget to execute the SplineWidget example
  2. Click the placeWidget button on the screen to start adding SplineWidget points
  3. Left-click on the screen to add the first point
  4. Left-click on the screen to add the second point
  5. Left-click on the screen to add the third point, then without moving the mouse, directly press the Enter key on the keyboard to confirm adding the points
  6. Result: only two points are added to the splineWidget on the screen, the third point disappears

The expected result is that the third point should also be added to the SplineWidget. The cause of this phenomenon is that after the last added point, as long as the mouse hasn't moved, the visible property of model.lastHandle won't be updated to true, causing vtkSplineContextRepresentation to not render the last point.

Results

After the modification, the last point can now be correctly rendered in the above situation.

Changes

The fix is simply to add one line in the SplineWidget's loseFocus function: if lastHandle exists, set its visible property to true.

  • Documentation and TypeScript definitions were updated to match those changes

PR and Code Checklist

  • semantic-release commit messages
  • Run npm run reformat to have correctly formatted code

Testing

  • This change adds or fixes unit tests
  • Tested environment:
    • vtk.js:
    • OS: Windows11
    • Browser: Chrome 143.0.7499.193

Copy link
Member

@finetjul finetjul left a comment

Choose a reason for hiding this comment

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

Why not creating the handle "visible" by default (and not wait for the mouse to be moved) ?

@TreatTrick
Copy link
Author

Because by default, there is a moveHandle below the mouse cursor position, and this moveHandle also participates in the Spline fitting of the splineWidget.

In the scenario above, if we set lastHandle to visible immediately after clicking the third point, without moving the mouse, the SplineWidget will actually fit four points: the first three points are the ones we clicked with the mouse, and the fourth point is the movehandle generated at the current mouse position (this fourth point moveHandle is actually at the same location as the third point lastHandle).

Because it's fitting four points, the SplineWidget will behave very strangely and not match the user's expectations. This is why we cannot set the lastHandle visible by default when the mouse doesn't move.

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.

2 participants