Skip to content

Commit

Permalink
make magnetic field prominent during measurement timing and faint oth…
Browse files Browse the repository at this point in the history
…erwise, see #80
  • Loading branch information
jbphet committed Jan 15, 2025
1 parent 3dfc9f3 commit a40b7ac
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion js/bloch-sphere/view/BlochSphereMeasurementArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ export default class BlochSphereMeasurementArea extends Node {
new Dimension2( 150, 180 ),
model.magneticFieldEnabledProperty,
model.magneticFieldStrengthProperty,
model.isSingleMeasurementModeProperty
model.isSingleMeasurementModeProperty,
model.measurementStateProperty
);

const magneticFieldAndStrengthControl = new HBox( {
Expand Down
10 changes: 9 additions & 1 deletion js/bloch-sphere/view/MagneticFieldNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@
*/

import NumberProperty from '../../../../axon/js/NumberProperty.js';
import Property from '../../../../axon/js/Property.js';
import Dimension2 from '../../../../dot/js/Dimension2.js';
import { combineOptions } from '../../../../phet-core/js/optionize.js';
import { Node, NodeOptions } from '../../../../scenery/js/imports.js';
import quantumMeasurement from '../../quantumMeasurement.js';
import { SpinMeasurementState } from '../model/SpinMeasurementState.js';
import MagneticFieldArrowNode from './MagneticFieldArrowNode.js';

const SIZE = new Dimension2( 150, 170 );

export default class MagneticFieldNode extends Node {

public constructor( magneticFieldStrength: NumberProperty, providedOptions?: NodeOptions ) {
public constructor( magneticFieldStrength: NumberProperty,
measurementStateProperty: Property<SpinMeasurementState>,
providedOptions?: NodeOptions ) {

const columns = 5;
const rows = 5;
Expand All @@ -39,6 +43,10 @@ export default class MagneticFieldNode extends Node {
const options = combineOptions<NodeOptions>( { children: arrowNodes }, providedOptions );

super( options );

measurementStateProperty.link( ( measurementState: SpinMeasurementState ) => {
this.opacity = measurementState === 'timingObservation' ? 1 : 0.25;
} );
}
}

Expand Down
7 changes: 5 additions & 2 deletions js/bloch-sphere/view/SystemUnderTestNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import NumberProperty from '../../../../axon/js/NumberProperty.js';
import Property from '../../../../axon/js/Property.js';
import TReadOnlyProperty from '../../../../axon/js/TReadOnlyProperty.js';
import Dimension2 from '../../../../dot/js/Dimension2.js';
import { combineOptions } from '../../../../phet-core/js/optionize.js';
import PhetFont from '../../../../scenery-phet/js/PhetFont.js';
import ShadedSphereNode from '../../../../scenery-phet/js/ShadedSphereNode.js';
import { Color, HBox, Node, NodeOptions, Rectangle, Text, VBox } from '../../../../scenery/js/imports.js';
import quantumMeasurement from '../../quantumMeasurement.js';
import { SpinMeasurementState } from '../model/SpinMeasurementState.js';
import MagneticFieldNode from './MagneticFieldNode.js';

const ATOM_RADIUS = 18; // in view coordinates
Expand All @@ -32,12 +34,14 @@ class SystemUnderTestNode extends Node {
* @param magneticFieldEnabledProperty - whether the magnetic field is enabled
* @param magneticFieldStrengthProperty - the property that indicates the magnetic field strength
* @param isSingleMeasurementModeProperty - whether the system is in single measurement mode
* @param measurementStateProperty - the state of the spin measurement
* @param providedOptions - options for the node, mostly used for positioning if at all
*/
public constructor( size: Dimension2,
magneticFieldEnabledProperty: TReadOnlyProperty<boolean>,
magneticFieldStrengthProperty: NumberProperty,
isSingleMeasurementModeProperty: TReadOnlyProperty<boolean>,
measurementStateProperty: Property<SpinMeasurementState>,
providedOptions?: NodeOptions ) {

const rect = new Rectangle( 0, 0, size.width, size.height, {
Expand All @@ -46,9 +50,8 @@ class SystemUnderTestNode extends Node {
cornerRadius: 8
} );

const magneticFieldNode = new MagneticFieldNode( magneticFieldStrengthProperty, {
const magneticFieldNode = new MagneticFieldNode( magneticFieldStrengthProperty, measurementStateProperty, {
center: rect.center,
opacity: 0.25,
visibleProperty: magneticFieldEnabledProperty
} );

Expand Down

0 comments on commit a40b7ac

Please sign in to comment.