Skip to content

Commit

Permalink
Fix a couple of issues seen in review.
Browse files Browse the repository at this point in the history
Return true from the sineWaveTool updateHighlights method so that the
general graphtool move handler doesn't overrided the coordinates set in
the updateHighlights method.

During the sine wave tool graphing phases instead of refusing to plot a
point when a down event occurs and the cursor is in an invalid location,
just plot the point where the highlight point currently is. Refusing to
plot the point can be confusing because the highlight point looks like
it is where the user wants it to be, and yet the click does nothing.
This technique needs to be implemented for all of the tools. It is
better than the previous method since it is more intuitive for the user.
  • Loading branch information
drgrice1 committed Dec 12, 2024
1 parent 13e3cb3 commit 8dfd032
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions htdocs/js/GraphTool/sinewavetool.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@
this.supportsSolidDash = true;

this.phase1 = (coords) => {
// Don't allow the point to be created off the board.
if (!gt.boardHasPoint(coords[1], coords[2])) return;
// If the current coordinates are off the board, then use the highlight point coordinates instead.
if (!gt.boardHasPoint(coords[1], coords[2])) coords = this.hlObjs.hl_point.coords.usrCoords;

gt.board.off('up');

Expand All @@ -252,13 +252,13 @@
};

this.phase2 = (coords) => {
// Don't allow the second point to be created on the same
// vertical line as the first point or off the board.
// If the current coordinates are on the same vertical line as the first point or off the board,
// then use the coordinates of the highlight point instead.
if (
Math.abs(this.shiftPoint.X() - gt.snapRound(coords[1], gt.snapSizeX)) < JXG.Math.eps ||
!gt.boardHasPoint(coords[1], coords[2])
!gt.boardHasPoint(coords[1], coords[2]) ||
Math.abs(this.shiftPoint.X() - gt.snapRound(coords[1], gt.snapSizeX)) < JXG.Math.eps
)
return;
coords = this.hlObjs.hl_point.coords.usrCoords;

gt.board.off('up');

Expand Down Expand Up @@ -291,13 +291,13 @@
};

this.phase3 = (coords) => {
// Don't allow the third point to be created on the same
// horizontal line as the first point, or off the board.
// If the current coordinates are on the same horizontal line as the first point or off the board,
// then use the highlight point coordinates instead.
if (
Math.abs(this.shiftPoint.Y() - gt.snapRound(coords[2], gt.snapSizeY)) < JXG.Math.eps ||
!gt.boardHasPoint(coords[1], coords[2])
)
return;
coords = this.hlObjs.hl_point.coords.usrCoords;

gt.board.off('up');

Expand Down Expand Up @@ -369,7 +369,7 @@
this.hlObjs.hl_point.rendNode.focus();
}

// Make sure the highlight point is not moved off the board, that the sine wave is not degenerate.
// Make sure the highlight point is not moved off the board, and that the sine wave is not degenerate.
if (e instanceof Event) {
gt.graphObjectTypes.sineWave.adjustDragPosition(
e,
Expand Down Expand Up @@ -420,6 +420,7 @@

gt.setTextCoords(this.hlObjs.hl_point.X(), this.hlObjs.hl_point.Y());
gt.board.update();
return true;
},

deactivate(gt) {
Expand Down

0 comments on commit 8dfd032

Please # to comment.