phetsims/vector-addition

eraser button is inconsistent for sum vectors

Closed this issue · 10 comments

This has been bothering me since we implemented #139.

It seems odd that the sum vector(s) remain on the graph after pressing the eraser button. Perhaps pressing the eraser button should uncheck the Sum checkbox(es), and remove the sum vector(s) from the graph?

For example, the current behavior is:

  1. Got to the Lab screen.
  2. Check both "Sum" checkboxes; the eraser button is still disabled.
  3. Put a blue and red vector on the graph.
  4. Press the eraser button. The eraser button is disabled, but the sum vectors remain on the graph.

Proposed behavior:

  1. Got to the Lab screen.
  2. Check both "Sum" checkboxes; the eraser button is becomes enabled.
  3. Put a blue and red vector on the graph.
  4. Press the eraser button. The eraser button is disabled, the "Sum" checkboxes are unchecked, and the sum vectors are removed from the graph.

So the state of the eraser button would include all vectors, and pressing the eraser button would remove all vectors from the graph.

@arouinfar your opinion?

Note to self: Visibility of sum vector labels is set in SumVector:

      // @private {function} isSymbolDisplayed - function to check if the sum vector should display its symbol.
      // The sum vector only displays the symbol when either a vector in its vector set is active, the sum is active, or
      // the activeVectorProperty.value is null
      this.isSymbolDisplayed = () => {
        return vectorSet.vectors.some( vector => vector === graph.activeVectorProperty.value )
               || graph.activeVectorProperty.value === this
               || graph.activeVectorProperty.value === null;
      };

Raising priority, since we're trying to get into dev testing by 10/1.

Discussed with @arouinfar on Zoom. We're going to try hiding the sum vector(s) when there are no other vectors on the graph. This seems more correct, because there's a distinction between a zero sum and the absence of a sum. This should address this weirdness, and the buggy behavior in #160.

Addressed in the above commit. The sum vector will only be displayed when the Sum checkbox is checked and the sum is defined. So we'll never have a situation where a sum vector is alone on the graph.

@arouinfar please review in master.

Rats, this is not totally fixed -- the value is being shown when "Values" is checked.

screenshot_1502

Fixed again :) I would have preferred to set a sum vector's value to something like null when the sum is undefined, instead of Vector2(0,0). But that wasn't practical - there are too many things that rely on all vectors having a non-null value. So I had to introduce a new BooleanProperty in SumVector, isDefinedProperty.

@arouinfar please review in master.

Looks good in master and dev.20 @pixelzoom, thanks!

Reopening. When "Values" is checked, the sum component vector values (and leader lines) are still being displayed in 1.0.0-dev.20. For example:

screenshot_1518

Moved the issue described in #187 (comment) to #195. Re-closing.