Skip to content

Commit

Permalink
clear counts when measurement time changes, see #54
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Jan 9, 2025
1 parent 7ccf6a6 commit 3d0f545
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions js/bloch-sphere/model/BlochSphereModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ class BlochSphereModel implements TModel {
tandem: providedOptions.tandem.createTandem( 'measurementStateProperty' )
} );

// Clear the measurement counts when the time to measurement changes, since this changes the nature of the
// measurement that is being made.
this.timeToMeasurementProperty.link( () => this.resetCounts() );

// Change the selected preset state direction to CUSTOM when the user manually changes the angles of the Bloch Sphere.
Multilink.multilink(
[
this.preparationBlochSphere.polarAngleProperty,
Expand Down Expand Up @@ -331,8 +336,11 @@ class BlochSphereModel implements TModel {
} );

if ( this.measurementStateProperty.value === 'timingObservation' ) {
this.measurementTimeProperty.value = this.measurementTimeProperty.value + dt;
if ( this.measurementTimeProperty.value > this.timeToMeasurementProperty.value ) {
this.measurementTimeProperty.value = Math.min(
this.measurementTimeProperty.value + dt,
this.timeToMeasurementProperty.value
);
if ( this.measurementTimeProperty.value >= this.timeToMeasurementProperty.value ) {

// The time when the observation should be made has been reached. Make the observation.
this.observe();
Expand Down
2 changes: 2 additions & 0 deletions js/bloch-sphere/view/MeasurementTimerControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export default class MeasurementTimerControl extends Node {
majorTickLength: 10,
minorTickLength: 5
} );

// Add the major and minor tick marks to the slider.
timeToMeasurementSlider.addMajorTick( 0, new Text( '0', { font: new PhetFont( 15 ) } ) );
timeToMeasurementSlider.addMajorTick( maxMeasurementTime, new Text( 't', { font: new PhetFont( 15 ) } ) );
_.times( NUMBER_OF_MINOR_TICKS, i => {
Expand Down

0 comments on commit 3d0f545

Please sign in to comment.