diff --git a/js/bloch-sphere/model/BlochSphereModel.ts b/js/bloch-sphere/model/BlochSphereModel.ts index dfabc95..a2adcde 100644 --- a/js/bloch-sphere/model/BlochSphereModel.ts +++ b/js/bloch-sphere/model/BlochSphereModel.ts @@ -18,7 +18,6 @@ import PickRequired from '../../../../phet-core/js/types/PickRequired.js'; import { PhetioObjectOptions } from '../../../../tandem/js/PhetioObject.js'; import EnumerationIO from '../../../../tandem/js/types/EnumerationIO.js'; import quantumMeasurement from '../../quantumMeasurement.js'; -import { BlochSphereScene } from './BlochSphereScene.js'; import ComplexBlochSphere from './ComplexBlochSphere.js'; import { MeasurementBasis } from './MeasurementBasis.js'; import { StateDirection } from './StateDirection.js'; @@ -29,7 +28,7 @@ type QuantumMeasurementModelOptions = SelfOptions & PickRequired; + public readonly showMagneticFieldProperty: BooleanProperty; // Bloch Spheres shown in the screen public readonly preparationBlochSphere: ComplexBlochSphere; @@ -70,10 +69,8 @@ export default class BlochSphereModel implements TModel { public constructor( providedOptions: QuantumMeasurementModelOptions ) { - this.selectedSceneProperty = new Property( BlochSphereScene.MEASUREMENT, { - tandem: providedOptions.tandem.createTandem( 'selectedSceneProperty' ), - phetioReadOnly: true, - phetioValueType: EnumerationIO( BlochSphereScene ), + this.showMagneticFieldProperty = new BooleanProperty( false, { + tandem: providedOptions.tandem.createTandem( 'showMagneticFieldProperty' ), phetioFeatured: true } ); @@ -182,13 +179,13 @@ export default class BlochSphereModel implements TModel { // Set the precession rate of the Bloch sphere based on the magnetic field strength and the selected scene. Multilink.multilink( - [ this.magneticFieldStrengthProperty, this.selectedSceneProperty ], - ( magneticFieldStrength, selectedScene ) => { - this.singleMeasurementBlochSphere.rotatingSpeedProperty.value = selectedScene === BlochSphereScene.PRECESSION ? + [ this.magneticFieldStrengthProperty, this.showMagneticFieldProperty ], + ( magneticFieldStrength, showMagneticField ) => { + this.singleMeasurementBlochSphere.rotatingSpeedProperty.value = showMagneticField ? magneticFieldStrength : 0; this.multiMeasurementBlochSpheres.forEach( blochSphere => { - blochSphere.rotatingSpeedProperty.value = selectedScene === BlochSphereScene.PRECESSION ? + blochSphere.rotatingSpeedProperty.value = showMagneticField ? magneticFieldStrength : 0; } ); @@ -268,7 +265,7 @@ export default class BlochSphereModel implements TModel { public reset(): void { this.resetCounts(); this.preparationBlochSphere.reset(); - this.selectedSceneProperty.reset(); + this.showMagneticFieldProperty.reset(); this.readyToObserveProperty.reset(); this.magneticFieldStrengthProperty.reset(); this.measurementBasisProperty.reset(); @@ -285,7 +282,7 @@ export default class BlochSphereModel implements TModel { this.multiMeasurementBlochSpheres.forEach( blochSphere => { blochSphere.step( dt ); } ); - if ( this.selectedSceneProperty.value === BlochSphereScene.PRECESSION ) { + if ( this.showMagneticFieldProperty.value ) { this.measurementTimeProperty.value += dt; this.measurementTimeProperty.value %= 2; } diff --git a/js/bloch-sphere/view/BlochSphereMeasurementArea.ts b/js/bloch-sphere/view/BlochSphereMeasurementArea.ts index 7eafd8f..1af4a2c 100644 --- a/js/bloch-sphere/view/BlochSphereMeasurementArea.ts +++ b/js/bloch-sphere/view/BlochSphereMeasurementArea.ts @@ -25,7 +25,6 @@ import QuantumMeasurementHistogram from '../../common/view/QuantumMeasurementHis import quantumMeasurement from '../../quantumMeasurement.js'; import QuantumMeasurementStrings from '../../QuantumMeasurementStrings.js'; import BlochSphereModel from '../model/BlochSphereModel.js'; -import { BlochSphereScene } from '../model/BlochSphereScene.js'; import { MeasurementBasis } from '../model/MeasurementBasis.js'; import BlochSphereNumericalEquationNode from './BlochSphereNumericalEquationNode.js'; import MagneticFieldControl from './MagneticFieldControl.js'; @@ -46,7 +45,7 @@ export default class BlochSphereMeasurementArea extends Node { } ); const magneticFieldNode = new MagneticFieldNode( model.magneticFieldStrengthProperty, { - visibleProperty: DerivedProperty.valueEqualsConstant( model.selectedSceneProperty, BlochSphereScene.PRECESSION ) + visibleProperty: model.showMagneticFieldProperty } ); const singleMeasurementBlochSphereNode = new BlochSphereNode( model.singleMeasurementBlochSphere, { @@ -143,7 +142,7 @@ export default class BlochSphereMeasurementArea extends Node { const measurementTimerControl = new MeasurementTimerControl( model.timeToMeasurementProperty, model.measurementTimeProperty, { tandem: providedOptions.tandem.createTandem( 'measurementTimerControl' ), - visibleProperty: DerivedProperty.valueEqualsConstant( model.selectedSceneProperty, BlochSphereScene.PRECESSION ) + visibleProperty: model.showMagneticFieldProperty } ); const measurementControlPanel = new Panel( new VBox( { @@ -201,7 +200,7 @@ export default class BlochSphereMeasurementArea extends Node { const magneticFieldControl = new MagneticFieldControl( model.magneticFieldStrengthProperty, { centerX: singleMeasurementBlochSphereNode.centerX, top: magneticFieldNode.bottom + 10, - visibleProperty: DerivedProperty.valueEqualsConstant( model.selectedSceneProperty, BlochSphereScene.PRECESSION ), + visibleProperty: model.showMagneticFieldProperty, tandem: providedOptions.tandem.createTandem( 'magneticFieldControl' ) } ); diff --git a/js/bloch-sphere/view/BlochSphereScreenView.ts b/js/bloch-sphere/view/BlochSphereScreenView.ts index 5863b8b..d20fd94 100644 --- a/js/bloch-sphere/view/BlochSphereScreenView.ts +++ b/js/bloch-sphere/view/BlochSphereScreenView.ts @@ -8,12 +8,11 @@ import BlochSphereModel from 'model/BlochSphereModel.js'; import PhetFont from '../../../../scenery-phet/js/PhetFont.js'; -import { Color, Line, Text, VBox } from '../../../../scenery/js/imports.js'; -import ComboBox, { ComboBoxItem } from '../../../../sun/js/ComboBox.js'; +import { Color, Line, Text } from '../../../../scenery/js/imports.js'; +import Checkbox from '../../../../sun/js/Checkbox.js'; import Tandem from '../../../../tandem/js/Tandem.js'; import QuantumMeasurementScreenView from '../../common/view/QuantumMeasurementScreenView.js'; import quantumMeasurement from '../../quantumMeasurement.js'; -import { BlochSphereScene } from '../model/BlochSphereScene.js'; import BlochSphereMeasurementArea from './BlochSphereMeasurementArea.js'; import BlochSpherePreparationArea from './BlochSpherePreparationArea.js'; @@ -43,39 +42,28 @@ export default class BlochSphereScreenView extends QuantumMeasurementScreenView } ); this.addChild( dividingLine ); - const comboBoxItems: ComboBoxItem[] = BlochSphereScene.enumeration.values.map( scene => { - return { - value: scene, - createNode: () => new Text( scene.description, { font: new PhetFont( 16 ) } ) - }; - } ); - - const sceneSelectionComboBox = new ComboBox( model.selectedSceneProperty, comboBoxItems, this, { - tandem: tandem.createTandem( 'sceneSelectionComboBox' ) - } ); - - const measurementAreaTitleAndComboBox = new VBox( { - children: [ - new Text( 'Spin Measurement', { font: new PhetFont( { size: 20, weight: 'bolder' } ) } ), - sceneSelectionComboBox - ], - spacing: 10, - centerX: this.layoutBounds.centerX + 150, - top: this.layoutBounds.top + 20 - } ); - this.addChild( measurementAreaTitleAndComboBox ); + const showMagneticFieldCheckbox = new Checkbox( + model.showMagneticFieldProperty, + new Text( 'Show Magnetic Field', { font: new PhetFont( { size: 16 } ) } ), + { + tandem: tandem.createTandem( 'showMagneticFieldCheckbox' ), + spacing: 10, + centerX: this.layoutBounds.centerX + 150, + top: this.layoutBounds.top + 20 + } ); + this.addChild( showMagneticFieldCheckbox ); const measurementArea = new BlochSphereMeasurementArea( model, { tandem: tandem.createTandem( 'measurementArea' ), left: dividingLineX + 20, - top: measurementAreaTitleAndComboBox.bottom + 20 + top: showMagneticFieldCheckbox.bottom + 20 } ); this.addChild( measurementArea ); this.pdomPlayAreaNode.pdomOrder = [ preparationArea, - measurementAreaTitleAndComboBox, + showMagneticFieldCheckbox, measurementArea ];