-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
190 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,8 @@ | |
}, | ||
"screen.rlc": { | ||
"value": "RLC" | ||
}, | ||
"screen.lab": { | ||
"value": "Lab" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright 2019, University of Colorado Boulder | ||
|
||
/** | ||
* The "Lab" screen. | ||
* | ||
* @author Sam Reid (PhET Interactive Simulations) | ||
*/ | ||
define( require => { | ||
'use strict'; | ||
|
||
// modules | ||
const CCKCConstants = require( 'CIRCUIT_CONSTRUCTION_KIT_COMMON/CCKCConstants' ); | ||
const circuitConstructionKitAc = require( 'CIRCUIT_CONSTRUCTION_KIT_AC/circuitConstructionKitAc' ); | ||
const Image = require( 'SCENERY/nodes/Image' ); | ||
const LabModel = require( 'CIRCUIT_CONSTRUCTION_KIT_AC/lab/model/LabModel' ); | ||
const LabScreenView = require( 'CIRCUIT_CONSTRUCTION_KIT_AC/lab/view/LabScreenView' ); | ||
const Property = require( 'AXON/Property' ); | ||
const Rectangle = require( 'SCENERY/nodes/Rectangle' ); | ||
const Screen = require( 'JOIST/Screen' ); | ||
|
||
// strings | ||
const screenLabString = require( 'string!CIRCUIT_CONSTRUCTION_KIT_AC/screen.lab' ); // eslint-disable-line | ||
|
||
// images | ||
const lightBulbImage = require( 'mipmap!CIRCUIT_CONSTRUCTION_KIT_COMMON/lightbulb-middle.png' ); | ||
const lightBulbImageIcon = require( 'mipmap!CIRCUIT_CONSTRUCTION_KIT_COMMON/lightbulb-middle-icon.png' ); | ||
|
||
class LabScreen extends Screen { | ||
|
||
/** | ||
* @param {Tandem} tandem | ||
*/ | ||
constructor( tandem ) { | ||
|
||
// Create the icon | ||
const homeScreenIcon = Rectangle.dimension( Screen.MINIMUM_HOME_SCREEN_ICON_SIZE, { | ||
fill: CCKCConstants.BACKGROUND_COLOR | ||
} ); | ||
homeScreenIcon.addChild( new Image( lightBulbImage, { | ||
scale: 0.95, | ||
center: homeScreenIcon.center | ||
} ) ); | ||
|
||
// Render a smaller icon for Edge because it is aliasing the image (even with mipmap on) | ||
// see https://github.com/phetsims/circuit-construction-kit-dc/issues/120 | ||
const navigationBarIcon = Rectangle.dimension( Screen.MINIMUM_NAVBAR_ICON_SIZE, { | ||
fill: CCKCConstants.BACKGROUND_COLOR | ||
} ); | ||
navigationBarIcon.addChild( new Image( lightBulbImageIcon, { | ||
scale: 1.05, | ||
center: navigationBarIcon.center | ||
} ) ); | ||
|
||
const options = { | ||
name: screenLabString, | ||
backgroundColorProperty: new Property( CCKCConstants.BACKGROUND_COLOR ), | ||
homeScreenIcon: homeScreenIcon, | ||
navigationBarIcon: navigationBarIcon, | ||
tandem: tandem, | ||
maxDT: CCKCConstants.MAX_DT | ||
}; | ||
|
||
super( | ||
() => new LabModel( tandem.createTandem( 'model' ) ), | ||
model => new LabScreenView( model, tandem.createTandem( 'view' ) ), | ||
options | ||
); | ||
} | ||
} | ||
|
||
return circuitConstructionKitAc.register( 'LabScreen', LabScreen ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2019, University of Colorado Boulder | ||
|
||
/** | ||
* Model for the Lab Screen. | ||
* | ||
* @author Sam Reid (PhET Interactive Simulations) | ||
*/ | ||
define( require => { | ||
'use strict'; | ||
|
||
// modules | ||
const BooleanProperty = require( 'AXON/BooleanProperty' ); | ||
const circuitConstructionKitAc = require( 'CIRCUIT_CONSTRUCTION_KIT_AC/circuitConstructionKitAc' ); | ||
const CircuitConstructionKitModel = require( 'CIRCUIT_CONSTRUCTION_KIT_COMMON/model/CircuitConstructionKitModel' ); | ||
|
||
class LabModel extends CircuitConstructionKitModel { | ||
|
||
/** | ||
* @param {Tandem} tandem | ||
* @constructor | ||
*/ | ||
constructor( tandem ) { | ||
super( tandem ); | ||
|
||
// @public {Property.<boolean>} - true if the stopwatch should be shown in the play area | ||
this.showStopwatchProperty = new BooleanProperty( false, { | ||
tandem: tandem.createTandem( 'showStopwatchProperty' ) | ||
} ); | ||
} | ||
} | ||
|
||
return circuitConstructionKitAc.register( 'LabModel', LabModel ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright 2019, University of Colorado Boulder | ||
|
||
/** | ||
* The view for the Lab screen. | ||
* | ||
* @author Sam Reid (PhET Interactive Simulations) | ||
*/ | ||
define( require => { | ||
'use strict'; | ||
|
||
// modules | ||
const BooleanProperty = require( 'AXON/BooleanProperty' ); | ||
const CCKCScreenView = require( 'CIRCUIT_CONSTRUCTION_KIT_COMMON/view/CCKCScreenView' ); | ||
const circuitConstructionKitAc = require( 'CIRCUIT_CONSTRUCTION_KIT_AC/circuitConstructionKitAc' ); | ||
const CircuitElementToolFactory = require( 'CIRCUIT_CONSTRUCTION_KIT_COMMON/view/CircuitElementToolFactory' ); | ||
const NumberProperty = require( 'AXON/NumberProperty' ); | ||
const TimerNode = require( 'SCENERY_PHET/TimerNode' ); | ||
|
||
class LabScreenView extends CCKCScreenView { | ||
|
||
/** | ||
* @param {LabModel} model | ||
* @param {Tandem} tandem | ||
*/ | ||
constructor( model, tandem ) { | ||
const circuitElementToolFactory = new CircuitElementToolFactory( model.circuit, model.showLabelsProperty, model.viewTypeProperty, | ||
point => this.circuitLayerNode.globalToLocalPoint( point ) ); | ||
|
||
// Tool nodes that appear on every screen. Pagination for the carousel, each page should begin with wire node | ||
const circuitElementToolNodes = [ | ||
|
||
// This page is duplicated in the Lab Screen View | ||
circuitElementToolFactory.createWireToolNode( 25, tandem.createTandem( 'wireToolNode' ) ), | ||
circuitElementToolFactory.createRightBatteryToolNode( 10, tandem.createTandem( 'rightBatteryToolNode' ) ), | ||
circuitElementToolFactory.createACVoltageToolNode( 10, tandem.createTandem( 'rightBatteryToolNode' ) ), | ||
circuitElementToolFactory.createLightBulbToolNode( 10, tandem.createTandem( 'lightBulbToolNode' ) ), | ||
circuitElementToolFactory.createResistorToolNode( 10, tandem.createTandem( 'resistorToolNode' ) ), | ||
circuitElementToolFactory.createCapacitorToolNode( 10, tandem.createTandem( 'capacitorToolNode' ) ), | ||
circuitElementToolFactory.createInductorToolNode( 10, tandem.createTandem( 'inductorToolNode' ) ), | ||
circuitElementToolFactory.createSwitchToolNode( 5, tandem.createTandem( 'switchToolNode' ) ) | ||
]; | ||
|
||
super( model, circuitElementToolNodes, tandem, { | ||
toolboxOrientation: 'vertical', // The toolbox should be vertical | ||
showResetAllButton: true, // The reset all button should be shown. | ||
showResistivityControl: false, | ||
showBatteryResistanceControl: false, | ||
showCharts: true, | ||
itemsPerPage: circuitElementToolNodes.length, | ||
pageHeight: 400, | ||
hideDisabledButtons: true | ||
} ); | ||
|
||
// @public - the TimerNode | ||
// TODO: consider generalizing Stopwatch and StopwatchNode from gas-properties | ||
const timerNodeTandem = tandem.createTandem( 'timerNode' ); | ||
this.timerNode = new TimerNode( new NumberProperty( 0 ), new BooleanProperty( false, { | ||
tandem: timerNodeTandem.createTandem( 'isRunningProperty' ) | ||
} ), { | ||
tandem: timerNodeTandem | ||
} ); | ||
this.addChild( this.timerNode ); | ||
|
||
// Show the TimerNode when the checkbox is checked | ||
model.showStopwatchProperty.link( showStopwatch => { | ||
this.timerNode.visible = showStopwatch; | ||
} ); | ||
} | ||
} | ||
|
||
return circuitConstructionKitAc.register( 'LabScreenView', LabScreenView ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters