Skip to content

Commit

Permalink
Only add groups for extreme elements in DC Lab - see #900
Browse files Browse the repository at this point in the history
  • Loading branch information
UniverseAndMore committed Feb 16, 2023
1 parent e4675d6 commit 15a8c61
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 33 deletions.
8 changes: 4 additions & 4 deletions js/model/Circuit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ export default class Circuit extends PhetioObject {
} );
}, () => createVertices( BATTERY_LENGTH ), {
phetioType: PhetioGroup.PhetioGroupIO( CircuitElement.CircuitElementIO ),
tandem: this.includeLabElements ? tandem.createTandem( 'extremeBatteryGroup' ) : Tandem.OPT_OUT,
tandem: ( this.includeLabElements && !this.includeACElements ) ? tandem.createTandem( 'extremeBatteryGroup' ) : Tandem.OPT_OUT,
phetioDynamicElementName: 'extremeBattery'
} );

Expand All @@ -402,7 +402,7 @@ export default class Circuit extends PhetioObject {
new Resistor( startVertex, endVertex, ResistorType.EXTREME_RESISTOR, tandem ),
() => createVertices( ResistorType.EXTREME_RESISTOR.length ), {
phetioType: PhetioGroup.PhetioGroupIO( Resistor.ResistorIO ),
tandem: tandem.createTandem( 'extremeResistorGroup' )
tandem: ( this.includeLabElements && !this.includeACElements ) ? tandem.createTandem( 'extremeResistorGroup' ) : Tandem.OPT_OUT
} );

this.householdObjectGroup = new PhetioGroup(
Expand Down Expand Up @@ -437,7 +437,7 @@ export default class Circuit extends PhetioObject {
} );
}, () => createVertices( 100 ), {
phetioType: PhetioGroup.PhetioGroupIO( CircuitElement.CircuitElementIO ),
tandem: this.includeLabElements ? tandem.createTandem( 'extremeLightBulbGroup' ) : Tandem.OPT_OUT
tandem: ( this.includeLabElements && !this.includeACElements ) ? tandem.createTandem( 'extremeLightBulbGroup' ) : Tandem.OPT_OUT
} );

this.capacitorGroup = new PhetioGroup(
Expand Down Expand Up @@ -478,7 +478,7 @@ export default class Circuit extends PhetioObject {
} );
}, () => createVertices( 100 ), {
phetioType: PhetioGroup.PhetioGroupIO( CircuitElement.CircuitElementIO ),
tandem: this.includeLabElements ? tandem.createTandem( 'realLightBulbGroup' ) : Tandem.OPT_OUT
tandem: ( this.includeLabElements && !this.includeACElements ) ? tandem.createTandem( 'realLightBulbGroup' ) : Tandem.OPT_OUT
} );

this.groups = [
Expand Down
60 changes: 31 additions & 29 deletions js/view/CircuitNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,27 +361,6 @@ export default class CircuitNode extends Node {

// Only create the relevant groups
if ( circuit.includeLabElements ) {
initializeCircuitElementType( ( e: CircuitElement ) => e instanceof Battery && e.batteryType === 'high-voltage', this.fixedCircuitElementLayer,
new PhetioGroup<CircuitElementNode, [ CircuitElement ]>( ( tandem: Tandem, circuitElement: CircuitElement ) => new BatteryNode( screenView, this, circuitElement as Battery, this.model.viewTypeProperty, tandem ),
() => [ this.circuit.batteryGroup.archetype ], {
phetioType: PhetioGroup.PhetioGroupIO( Node.NodeIO ),
tandem: tandem.createTandem( 'extremeBatteryNodeGroup' ),
supportsDynamicState: false
} ) );
initializeCircuitElementType( ( e: CircuitElement ) => e instanceof LightBulb && e.isExtreme && !e.isReal, this.fixedCircuitElementLayer,
new PhetioGroup<CircuitElementNode, [ CircuitElement ]>( ( tandem: Tandem, circuitElement: CircuitElement ) => new CCKCLightBulbNode( screenView, this, circuitElement as LightBulb, this.model.isValueDepictionEnabledProperty, this.model.viewTypeProperty, tandem ),
() => [ this.circuit.extremeLightBulbGroup.archetype ], {
phetioType: PhetioGroup.PhetioGroupIO( Node.NodeIO ),
tandem: tandem.createTandem( 'extremeLightBulbNodeGroup' ),
supportsDynamicState: false
} ) );
initializeCircuitElementType( ( e: CircuitElement ) => e instanceof LightBulb && e.isReal, this.fixedCircuitElementLayer,
new PhetioGroup<CircuitElementNode, [ CircuitElement ]>( ( tandem: Tandem, circuitElement: CircuitElement ) => new CCKCLightBulbNode( screenView, this, circuitElement as LightBulb, this.model.isValueDepictionEnabledProperty, this.model.viewTypeProperty, tandem ),
() => [ this.circuit.realLightBulbGroup.archetype ], {
phetioType: PhetioGroup.PhetioGroupIO( Node.NodeIO ),
tandem: tandem.createTandem( 'realLightBulbNodeGroup' ),
supportsDynamicState: false
} ) );
initializeCircuitElementType( ( e: CircuitElement ) => e instanceof SeriesAmmeter, this.fixedCircuitElementLayer,
new PhetioGroup<CircuitElementNode, [ CircuitElement ]>( ( tandem: Tandem, circuitElement: CircuitElement ) => new SeriesAmmeterNode( screenView, this, circuitElement as SeriesAmmeter, tandem,
this.model.isValueDepictionEnabledProperty ),
Expand All @@ -390,6 +369,37 @@ export default class CircuitNode extends Node {
tandem: tandem.createTandem( 'seriesAmmeterNodeGroup' ),
supportsDynamicState: false
} ) );
if ( !circuit.includeACElements ) {
initializeCircuitElementType( ( e: CircuitElement ) => e instanceof Battery && e.batteryType === 'high-voltage', this.fixedCircuitElementLayer,
new PhetioGroup<CircuitElementNode, [ CircuitElement ]>( ( tandem: Tandem, circuitElement: CircuitElement ) => new BatteryNode( screenView, this, circuitElement as Battery, this.model.viewTypeProperty, tandem ),
() => [ this.circuit.batteryGroup.archetype ], {
phetioType: PhetioGroup.PhetioGroupIO( Node.NodeIO ),
tandem: tandem.createTandem( 'extremeBatteryNodeGroup' ),
supportsDynamicState: false
} ) );
initializeCircuitElementType( ( e: CircuitElement ) => e instanceof Resistor && e.resistorType === ResistorType.EXTREME_RESISTOR, this.fixedCircuitElementLayer,
new PhetioGroup<CircuitElementNode, [ CircuitElement ]>( ( tandem: Tandem, circuitElement: CircuitElement ) =>
new ResistorNode( screenView, this, circuitElement as Resistor, this.model.viewTypeProperty, tandem ),
() => [ this.circuit.extremeResistorGroup.archetype ], {
phetioType: PhetioGroup.PhetioGroupIO( Node.NodeIO ),
tandem: tandem.createTandem( 'extremeResistorNodeGroup' ),
supportsDynamicState: false
} ) );
initializeCircuitElementType( ( e: CircuitElement ) => e instanceof LightBulb && e.isExtreme && !e.isReal, this.fixedCircuitElementLayer,
new PhetioGroup<CircuitElementNode, [ CircuitElement ]>( ( tandem: Tandem, circuitElement: CircuitElement ) => new CCKCLightBulbNode( screenView, this, circuitElement as LightBulb, this.model.isValueDepictionEnabledProperty, this.model.viewTypeProperty, tandem ),
() => [ this.circuit.extremeLightBulbGroup.archetype ], {
phetioType: PhetioGroup.PhetioGroupIO( Node.NodeIO ),
tandem: tandem.createTandem( 'extremeLightBulbNodeGroup' ),
supportsDynamicState: false
} ) );
initializeCircuitElementType( ( e: CircuitElement ) => e instanceof LightBulb && e.isReal, this.fixedCircuitElementLayer,
new PhetioGroup<CircuitElementNode, [ CircuitElement ]>( ( tandem: Tandem, circuitElement: CircuitElement ) => new CCKCLightBulbNode( screenView, this, circuitElement as LightBulb, this.model.isValueDepictionEnabledProperty, this.model.viewTypeProperty, tandem ),
() => [ this.circuit.realLightBulbGroup.archetype ], {
phetioType: PhetioGroup.PhetioGroupIO( Node.NodeIO ),
tandem: tandem.createTandem( 'realLightBulbNodeGroup' ),
supportsDynamicState: false
} ) );
}
}
if ( circuit.includeACElements ) {
initializeCircuitElementType( ( e: CircuitElement ) => e instanceof Capacitor, this.fixedCircuitElementLayer,
Expand Down Expand Up @@ -422,14 +432,6 @@ export default class CircuitNode extends Node {
tandem: tandem.createTandem( 'resistorNodeGroup' ),
supportsDynamicState: false
} ) );
initializeCircuitElementType( ( e: CircuitElement ) => e instanceof Resistor && e.resistorType === ResistorType.EXTREME_RESISTOR, this.fixedCircuitElementLayer,
new PhetioGroup<CircuitElementNode, [ CircuitElement ]>( ( tandem: Tandem, circuitElement: CircuitElement ) =>
new ResistorNode( screenView, this, circuitElement as Resistor, this.model.viewTypeProperty, tandem ),
() => [ this.circuit.extremeResistorGroup.archetype ], {
phetioType: PhetioGroup.PhetioGroupIO( Node.NodeIO ),
tandem: tandem.createTandem( 'extremeResistorNodeGroup' ),
supportsDynamicState: false
} ) );
initializeCircuitElementType( ( e: CircuitElement ) => e instanceof Resistor && e.resistorType !== ResistorType.RESISTOR && e.resistorType !== ResistorType.EXTREME_RESISTOR, this.fixedCircuitElementLayer,
new PhetioGroup<CircuitElementNode, [ CircuitElement ]>( ( tandem: Tandem, circuitElement: CircuitElement ) => {
if ( circuitElement instanceof Dog ) {
Expand Down

0 comments on commit 15a8c61

Please sign in to comment.