Skip to content

Commit

Permalink
sufficient to add FieldPositionsNode only in BarMagnetScreenView, #146
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Mar 29, 2024
1 parent 8fe778e commit 4a78bad
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 23 deletions.
12 changes: 9 additions & 3 deletions js/bar-magnet/view/BarMagnetScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import EarthNode from '../../common/view/EarthNode.js';
import BarMagnetDeveloperAccordionBox from './BarMagnetDeveloperAccordionBox.js';
import BarMagnetPanels from './BarMagnetPanels.js';
import FELScreenView from '../../common/view/FELScreenView.js';
import FELQueryParameters from '../../common/FELQueryParameters.js';
import FieldPositionsNode from '../../common/view/FieldPositionsNode.js';

export default class BarMagnetScreenView extends FELScreenView {

Expand Down Expand Up @@ -76,11 +78,15 @@ export default class BarMagnetScreenView extends FELScreenView {
developerAccordionBox
]
} );
if ( this.fieldPositionsNode ) {
screenViewRootNode.addChild( this.fieldPositionsNode );
}
this.addChild( screenViewRootNode );

// Debugging tool, to verify that FieldNode is rendering needles in the correct positions. This is sufficient
// to check in one screen, since FieldNode is instantiated in the FELScreenView base class that is shared by
// all screens.
if ( FELQueryParameters.showFieldPositions ) {
screenViewRootNode.addChild( new FieldPositionsNode( this.visibleBoundsProperty ) );
}

// Play Area focus order, see https://github.com/phetsims/faradays-electromagnetic-lab/issues/81
this.pdomPlayAreaNode.pdomOrder = [
barMagnetNode,
Expand Down
2 changes: 2 additions & 0 deletions js/common/FELQueryParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ const SCHEMA_MAP = {

// Debugging tool, puts a yellow dot (small circle) where the center of each needle should be in the B-field
// visualization. If the dots are not centered on the needles, then positioning in FieldNode is incorrect.
// This applies to the Bar Magnet screen only, which is sufficient since all screens share the same FELScreenView
// base class, which instantiates FieldNode.
showFieldPositions: {
type: 'flag'
}
Expand Down
8 changes: 0 additions & 8 deletions js/common/view/FELScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import Property from '../../../../axon/js/Property.js';
import PickupCoilNode from './PickupCoilNode.js';
import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import isResettingAllProperty from '../isResettingAllProperty.js';
import FELQueryParameters from '../FELQueryParameters.js';
import FieldPositionsNode from './FieldPositionsNode.js';

type SelfOptions = {

Expand All @@ -53,7 +51,6 @@ export default class FELScreenView extends ScreenView {

// It is the subclass' responsibility to add these to the scene graph and pdomOrder.
protected readonly fieldNode: Node;
protected readonly fieldPositionsNode?: Node;
protected readonly fieldMeterNode: Node;
protected readonly compassNode: Node;
protected readonly resetAllButton: Node;
Expand All @@ -73,11 +70,6 @@ export default class FELScreenView extends ScreenView {

this.fieldNode = new FieldNode( options.magnet, this.visibleBoundsProperty, options.tandem.createTandem( 'fieldNode' ) );

// Debugging tool, to verify that FieldNode is rendering needles in the correct positions.
if ( FELQueryParameters.showFieldPositions ) {
this.fieldPositionsNode = new FieldPositionsNode( this.visibleBoundsProperty );
}

this.compassNode = new CompassNode( options.compass, {
// See https://github.com/phetsims/faradays-electromagnetic-lab/issues/10#issuecomment-1911160748
dragBoundsProperty: new DerivedProperty( [ this.visibleBoundsProperty, options.panels.boundsProperty ],
Expand Down
3 changes: 0 additions & 3 deletions js/electromagnet/view/ElectromagnetScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ export default class ElectromagnetScreenView extends FELScreenView {
developerAccordionBox
]
} );
if ( this.fieldPositionsNode ) {
screenViewRootNode.addChild( this.fieldPositionsNode );
}
this.addChild( screenViewRootNode );

// Play Area focus order, see https://github.com/phetsims/faradays-electromagnetic-lab/issues/81
Expand Down
3 changes: 0 additions & 3 deletions js/generator/view/GeneratorScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ export default class GeneratorScreenView extends FELScreenView {
pickupCoilDebuggerPanel
]
} );
if ( this.fieldPositionsNode ) {
screenViewRootNode.addChild( this.fieldPositionsNode );
}
this.addChild( screenViewRootNode );

// Play Area focus order, see https://github.com/phetsims/faradays-electromagnetic-lab/issues/81
Expand Down
3 changes: 0 additions & 3 deletions js/pickup-coil/view/PickupCoilScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ export default class PickupCoilScreenView extends FELScreenView {
pickupCoilDebuggerPanel
]
} );
if ( this.fieldPositionsNode ) {
screenViewRootNode.addChild( this.fieldPositionsNode );
}
this.addChild( screenViewRootNode );

// Play Area focus order, see https://github.com/phetsims/faradays-electromagnetic-lab/issues/81
Expand Down
3 changes: 0 additions & 3 deletions js/transformer/view/TransformerScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ export default class TransformerScreenView extends FELScreenView {
pickupCoilDebuggerPanel
]
} );
if ( this.fieldPositionsNode ) {
screenViewRootNode.addChild( this.fieldPositionsNode );
}
this.addChild( screenViewRootNode );

// Play Area focus order, see https://github.com/phetsims/faradays-electromagnetic-lab/issues/81
Expand Down

0 comments on commit 4a78bad

Please sign in to comment.