Skip to content

Commit

Permalink
add ability to hide histogram via phet-io, see #63
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Jan 14, 2025
1 parent 0be4a52 commit 4cc1acb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 7 additions & 3 deletions js/coins/view/CoinExperimentMeasurementArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class CoinExperimentMeasurementArea extends VBox {
public constructor( sceneModel: CoinsExperimentSceneModel, tandem: Tandem ) {

const textColorProperty = sceneModel.systemType === 'quantum' ?
QuantumMeasurementColors.quantumSceneTextColorProperty : QuantumMeasurementColors.classicalSceneTextColorProperty;
QuantumMeasurementColors.quantumSceneTextColorProperty : QuantumMeasurementColors.classicalSceneTextColorProperty;
const singleCoinInTestBoxProperty = new BooleanProperty( false );
const coinSetInTestBoxProperty = new BooleanProperty( false );

Expand Down Expand Up @@ -100,9 +100,13 @@ export default class CoinExperimentMeasurementArea extends VBox {
sceneModel.coinSet.measuredDataChangedEmitter,
{ tandem: tandem.createTandem( 'multipleCoinTestBox' ) }
);
const multiCoinExperimentHistogramTandem = tandem.createTandem( 'multiCoinExperimentHistogram' );
const multiCoinExperimentHistogram = new CoinMeasurementHistogram( sceneModel.coinSet, sceneModel.systemType, {
visibleProperty: DerivedProperty.not( sceneModel.preparingExperimentProperty ),
tandem: tandem.createTandem( 'multiCoinExperimentHistogram' ),
visibleProperty: new GatedVisibleProperty(
DerivedProperty.not( sceneModel.preparingExperimentProperty ),
multiCoinExperimentHistogramTandem
),
tandem: multiCoinExperimentHistogramTandem,
leftFillColorProperty: sceneModel.systemType === 'classical' ? QuantumMeasurementColors.headsColorProperty : QuantumMeasurementColors.upColorProperty,
rightFillColorProperty: sceneModel.systemType === 'classical' ? QuantumMeasurementColors.tailsColorProperty : QuantumMeasurementColors.downColorProperty
} );
Expand Down
6 changes: 6 additions & 0 deletions js/coins/view/CoinsExperimentSceneView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ class CoinsExperimentSceneView extends Node {
this.updateActivityAreaPositions();
} );

// Because phet-io actions can cause the size of the measurement area to change, we need to update the positions of
// the activity areas when the bounds of the measurement area change.
this.measurementArea.boundsProperty.link( () => {
this.updateActivityAreaPositions();
} );

// Set the initial position that will be used when adding the coins that move (animate) between the preparation and
// measurement areas.
this.travelingCoinsOrigin = this.globalToLocalPoint( this.preparationArea.getIndicatorCoinGlobalCenter() );
Expand Down

0 comments on commit 4cc1acb

Please sign in to comment.