Skip to content

Commit

Permalink
add button to erase measurement counts, see #80
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Jan 16, 2025
1 parent 0538657 commit 7a5d981
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion js/bloch-sphere/model/BlochSphereModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class BlochSphereModel implements TModel {
/**
* Resets the measurement counts.
*/
private resetCounts(): void {
public resetCounts(): void {
this.upMeasurementCountProperty.reset();
this.downMeasurementCountProperty.reset();
}
Expand Down
12 changes: 10 additions & 2 deletions js/bloch-sphere/view/BlochSphereMeasurementArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import DerivedStringProperty from '../../../../axon/js/DerivedStringProperty.js'
import optionize, { EmptySelfOptions } from '../../../../phet-core/js/optionize.js';
import WithRequired from '../../../../phet-core/js/types/WithRequired.js';
import PhetFont from '../../../../scenery-phet/js/PhetFont.js';
import EraserButton from '../../../../scenery-phet/js/buttons/EraserButton.js';
import { HBox, Node, NodeOptions, RichText, RichTextOptions, Text, VBox } from '../../../../scenery/js/imports.js';
import AquaRadioButtonGroup, { AquaRadioButtonGroupItem } from '../../../../sun/js/AquaRadioButtonGroup.js';
import RectangularRadioButtonGroup from '../../../../sun/js/buttons/RectangularRadioButtonGroup.js';
Expand Down Expand Up @@ -135,14 +136,20 @@ export default class BlochSphereMeasurementArea extends Node {
}
);

const resetCountsButton = new EraserButton( {
listener: () => model.resetCounts(),
tandem: providedOptions.tandem.createTandem( 'resetCountsButton' )
} );

const radioButtonItems = [ true, false ].map(
isSingleMeasurement => {
return {
createNode: () => new Text( isSingleMeasurement ? 'Single' : 'Multiple', { font: new PhetFont( 16 ) } ),
value: isSingleMeasurement,
tandemName: isSingleMeasurement ? 'singleMeasurementRadioButton' : 'multipleMeasurementRadioButton'
};
} );
}
);
const singleOrMultipleRadioButtonGroup = new AquaRadioButtonGroup( model.isSingleMeasurementModeProperty, radioButtonItems, {
orientation: 'vertical',
tandem: providedOptions.tandem.createTandem( 'singleOrMultipleRadioButtonGroup' )
Expand Down Expand Up @@ -231,10 +238,11 @@ export default class BlochSphereMeasurementArea extends Node {

const measurementControls = new VBox( {
left: singleMeasurementBlochSphereNode.right + 20,
top: equationNodePanel.bottom - 40,
top: 10,
spacing: 10,
children: [
measurementResultHistogram,
resetCountsButton,
measurementControlPanel,
prepareObserveButton
]
Expand Down

0 comments on commit 7a5d981

Please sign in to comment.