Skip to content

Commit

Permalink
fix overzealous reset of data counts, see #80
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Jan 16, 2025
1 parent 676a203 commit 0538657
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions js/bloch-sphere/model/BlochSphereModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,33 +162,34 @@ class BlochSphereModel implements TModel {
// measurement that is being made.
this.timeToMeasurementProperty.link( () => this.resetCounts() );

// Clear accumulated counts, and potentially change the selected preset state direction to
// CUSTOM when the user changes the angles of the Bloch Sphere.
// Clear accumulated counts and potentially change the selected preset state direction to CUSTOM when the user
// changes the angles of the Bloch Sphere.
Multilink.multilink(
[
this.preparationBlochSphere.polarAngleProperty,
this.preparationBlochSphere.azimuthalAngleProperty
],
[ this.preparationBlochSphere.polarAngleProperty, this.preparationBlochSphere.azimuthalAngleProperty ],
() => {
// Clear the accumulated counts.
this.resetCounts();

if ( !selectingStateDirection ) {

// Change the selected state to indicate that the user has moved away from the preset states.
this.selectedStateDirectionProperty.value = StateDirection.CUSTOM;
}
}
);

// Reset the counts when the user changes the magnetic field attributes.
Multilink.lazyMultilink(
[ this.magneticFieldStrengthProperty, this.magneticFieldEnabledProperty ],
() => this.resetCounts()
);

// Set the precession rate of the Bloch sphere based on the state of the magnetic field, the selected scene, and the
// measurement state.
Multilink.lazyMultilink(
[ this.magneticFieldStrengthProperty, this.magneticFieldEnabledProperty, this.measurementStateProperty ],
( magneticFieldStrength, showMagneticField, measurementState ) => {

// Changes to the field state should clear any accumulated counts.
this.resetCounts();

// Set the precession rate of the Bloch sphere based on the measurement state and the state of the magnetic
// field.
const rotationRate = measurementState === 'timingObservation' && showMagneticField ? magneticFieldStrength : 0;
Expand All @@ -213,6 +214,7 @@ class BlochSphereModel implements TModel {
} );
} );

// Reset accumulated data when the user changes the measurement axis.
this.measurementAxisProperty.link( () => {
this.resetCounts();
} );
Expand Down
2 changes: 1 addition & 1 deletion js/bloch-sphere/view/BlochSphereMeasurementArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export default class BlochSphereMeasurementArea extends Node {

const magneticFieldCheckbox = new Checkbox(
model.magneticFieldEnabledProperty,
// TODO: This text should be localized, see https://github.com/phetsims/quantum-measurement/issues/54
// TODO: This text should be localized, see https://github.com/phetsims/quantum-measurement/issues/80
new Text( 'Enable Magnetic Field', { font: new PhetFont( { size: 16 } ) } ),
{
spacing: 10,
Expand Down

0 comments on commit 0538657

Please sign in to comment.