Skip to content

Commit

Permalink
delete tandem constructor parameters, #165
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Sep 14, 2021
1 parent 3e4c997 commit 149ac3b
Show file tree
Hide file tree
Showing 28 changed files with 108 additions and 240 deletions.
3 changes: 1 addition & 2 deletions js/common/model/FocalPoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ class FocalPoint {
/**
* @param {Property.<Vector2>} opticPositionProperty
* @param {Property.<number>} focalLengthProperty
* @param {Tandem} tandem
* @param {Object} [options]
*/
constructor( opticPositionProperty, focalLengthProperty, tandem, options ) {
constructor( opticPositionProperty, focalLengthProperty, options ) {

options = merge( {
multiplicativeFactor: 1
Expand Down
40 changes: 16 additions & 24 deletions js/common/model/GeometricOpticsModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import NumberProperty from '../../../../axon/js/NumberProperty.js';
import Property from '../../../../axon/js/Property.js';
import RangeWithValue from '../../../../dot/js/RangeWithValue.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import geometricOptics from '../../geometricOptics.js';
import ProjectorScreen from '../../lens/model/ProjectorScreen.js';
import GeometricOpticsConstants from '../GeometricOpticsConstants.js';
Expand Down Expand Up @@ -39,16 +38,13 @@ class GeometricOpticsModel {
* @param {RangeWithValue} indexOfRefractionRange
* @param {Optic.Curve} curve - initial curve of optical element
* @param {Optic.Type} type - initial type of optical element
* @param {Tandem} tandem
*/
constructor( opticPosition,
radiusOfCurvatureRange,
diameterRange,
indexOfRefractionRange,
curve,
type,
tandem ) {
assert && assert( tandem instanceof Tandem, 'invalid tandem' );
type ) {
assert && assert( opticPosition instanceof Vector2, 'invalid position' );
assert && assert( radiusOfCurvatureRange instanceof RangeWithValue, 'invalid radiusOfCurvature' );
assert && assert( diameterRange instanceof RangeWithValue, 'invalid diameterRange' );
Expand Down Expand Up @@ -84,38 +80,35 @@ class GeometricOpticsModel {
diameterRange,
indexOfRefractionRange,
curve,
type,
tandem );
type );

// @public {SourceObject} the object/ source
this.sourceObject = new SourceObject( this.optic.positionProperty, this.representationProperty, tandem );
this.sourceObject = new SourceObject( this.optic.positionProperty, this.representationProperty );

// REVIEW: perhaps instead of first/second, we could name these in optics terms, or relate them to the
// REVIEW: multiplicativeFactor? Like positiveFocalPoint, negativeFocalPoint? ordinal numbers here doesn't increase
// understanding to me. @public {FocalPoint} first principal focal point
this.firstFocalPoint = new FocalPoint( this.optic.positionProperty, this.optic.focalLengthProperty,
tandem.createTandem( 'firstFocalPoint' ) );
this.firstFocalPoint = new FocalPoint( this.optic.positionProperty, this.optic.focalLengthProperty );

// @public {FocalPoint} second principal focal point
this.secondFocalPoint = new FocalPoint( this.optic.positionProperty,
this.optic.focalLengthProperty, tandem.createTandem( 'secondFocalPoint' ), {
multiplicativeFactor: -1
} );
this.secondFocalPoint = new FocalPoint( this.optic.positionProperty, this.optic.focalLengthProperty, {
multiplicativeFactor: -1
} );

// @public {Target} model of the target/image associated with the first source
this.firstTarget = new Target( this.sourceObject.firstPositionProperty,
this.optic, this.representationProperty, tandem );
this.firstTarget = new Target( this.sourceObject.firstPositionProperty, this.optic, this.representationProperty );

// @public {Target} target/ image associated with the second source
this.secondTarget = new Target( this.sourceObject.secondPositionProperty,
this.optic, this.representationProperty, tandem );
this.secondTarget = new Target( this.sourceObject.secondPositionProperty, this.optic, this.representationProperty );

// @public {ProjectorScreen} model of the projector screen and spotlights
this.projectorScreen = new ProjectorScreen(
this.sourceObject.firstPositionProperty,
this.sourceObject.secondPositionProperty,
this.firstTarget.positionProperty,
this.secondTarget.positionProperty, this.optic, tandem );
this.secondTarget.positionProperty,
this.optic
);

// @public {LightRays} model of the light rays associated to the first source
this.firstLightRays = new LightRays( this.timeProperty,
Expand All @@ -124,8 +117,8 @@ class GeometricOpticsModel {
this.sourceObject.firstPositionProperty,
this.projectorScreen,
this.optic,
this.firstTarget,
tandem );
this.firstTarget
);

// @public {LightRays} model of the light rays associated with the second source
this.secondLightRays = new LightRays( this.timeProperty,
Expand All @@ -134,9 +127,8 @@ class GeometricOpticsModel {
this.sourceObject.secondPositionProperty,
this.projectorScreen,
this.optic,
this.secondTarget,
tandem );

this.secondTarget
);
}

/**
Expand Down
6 changes: 1 addition & 5 deletions js/common/model/LightRay.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import Vector2 from '../../../../dot/js/Vector2.js';
import Shape from '../../../../kite/js/Shape.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import geometricOptics from '../../geometricOptics.js';
import GeometricOpticsConstants from '../GeometricOpticsConstants.js';
import Ray from './Ray.js';
Expand All @@ -31,7 +30,6 @@ class LightRay {
* @param {boolean} isPrincipalRayMode - is the light ray mode set to Principal rays
* @param {boolean} isProjectorScreenPresent - is there a projector screen in the play area
* @param {function} getProjectorScreenBisectorLine - returns a Shape that bisects the middle of projector screen
* @param {Tandem} tandem
*/
constructor( initialRay,
time,
Expand All @@ -40,9 +38,7 @@ class LightRay {
isVirtual,
isPrincipalRayMode,
isProjectorScreenPresent,
getProjectorScreenBisectorLine,
tandem ) {
assert && assert( tandem instanceof Tandem, 'invalid tandem' );
getProjectorScreenBisectorLine ) {

// @public (read-only) - shape of the real rays - will be updated later
this.realShape = new Shape();
Expand Down
10 changes: 3 additions & 7 deletions js/common/model/LightRays.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Emitter from '../../../../axon/js/Emitter.js';
import Property from '../../../../axon/js/Property.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import Shape from '../../../../kite/js/Shape.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import geometricOptics from '../../geometricOptics.js';
import LightRay from './LightRay.js';
import LightRayMode from './LightRayMode.js';
Expand All @@ -29,17 +28,14 @@ class LightRays {
* @param {ProjectorScreen} projectorScreen
* @param {Optic} optic
* @param {Target} target - target model associated with this ray
* @param {Tandem} tandem
*/
constructor( timeProperty,
lightRayModeProperty,
representationProperty,
sourceObjectPositionProperty,
projectorScreen,
optic,
target,
tandem ) {
assert && assert( tandem instanceof Tandem, 'invalid tandem' );
target ) {

// @private {Property.<Vector>} target position associated with this ray
this.targetPositionProperty = target.positionProperty;
Expand Down Expand Up @@ -104,8 +100,8 @@ class LightRays {
isVirtual,
isPrincipalRayMode,
isProjectorScreenPresent,
projectorScreen.getBisectorLine.bind( projectorScreen ),
tandem );
projectorScreen.getBisectorLine.bind( projectorScreen )
);

// set the enable image to true after the first ray reaches its target
if ( lightRay.isTargetReached ) {
Expand Down
6 changes: 1 addition & 5 deletions js/common/model/Optic.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import Vector2Property from '../../../../dot/js/Vector2Property.js';
import Shape from '../../../../kite/js/Shape.js';
import Enumeration from '../../../../phet-core/js/Enumeration.js';
import merge from '../../../../phet-core/js/merge.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import geometricOptics from '../../geometricOptics.js';
import OpticShapeCollection from './OpticShapeCollection.js';

Expand All @@ -31,16 +30,13 @@ class Optic {
* @param {RangeWithValue} indexOfRefractionRange
* @param {Optic.Curve} curve - initial curve of optical element - acceptable values (CONVEX and CONCAVE)
* @param {Optic.Type} type - type of optical element - acceptable values (MIRROR and LENS)
* @param {Tandem} tandem
*/
constructor( initialPosition,
radiusOfCurvatureRange,
diameterRange,
indexOfRefractionRange,
curve,
type,
tandem ) {
assert && assert( tandem instanceof Tandem, 'invalid tandem' );
type ) {
assert && assert( initialPosition instanceof Vector2, 'invalid initialPosition' );
assert && assert( radiusOfCurvatureRange instanceof RangeWithValue, 'invalid radiusOfCurvature' );
assert && assert( diameterRange instanceof RangeWithValue, 'invalid diameterRange' );
Expand Down
5 changes: 1 addition & 4 deletions js/common/model/SourceObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import NumberProperty from '../../../../axon/js/NumberProperty.js';
import Dimension2 from '../../../../dot/js/Dimension2.js';
import Utils from '../../../../dot/js/Utils.js';
import Vector2Property from '../../../../dot/js/Vector2Property.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import geometricOptics from '../../geometricOptics.js';
import GeometricOpticsConstants from '../GeometricOpticsConstants.js';

Expand All @@ -33,10 +32,8 @@ class SourceObject {
/**
* @param {Property.<Vector2>} opticPositionProperty
* @param {Property.<Representation>} representationProperty
* @param {Tandem} tandem
*/
constructor( opticPositionProperty, representationProperty, tandem ) {
assert && assert( tandem instanceof Tandem, 'invalid tandem' );
constructor( opticPositionProperty, representationProperty ) {

const scale = representationProperty.value.isObject ? OBJECT_SCALE_FACTOR : SOURCE_SCALE_FACTOR;

Expand Down
8 changes: 1 addition & 7 deletions js/common/model/Target.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import EnabledComponent from '../../../../axon/js/EnabledComponent.js';
import Bounds2 from '../../../../dot/js/Bounds2.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import geometricOptics from '../../geometricOptics.js';
import GeometricOpticsConstants from '../GeometricOpticsConstants.js';

Expand All @@ -23,13 +22,8 @@ class Target extends EnabledComponent {
* @param {Property.<Vector2>} objectPositionProperty - position of the object/source
* @param {Optic} optic - model of the optic
* @param {Property.<Representation>} representationProperty
* @param {Tandem} tandem
*/
constructor( objectPositionProperty,
optic,
representationProperty,
tandem ) {
assert && assert( tandem instanceof Tandem, 'invalid tandem' );
constructor( objectPositionProperty, optic, representationProperty ) {

super();

Expand Down
9 changes: 1 addition & 8 deletions js/common/view/FocalPointNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import merge from '../../../../phet-core/js/merge.js';
import PlusNode from '../../../../scenery-phet/js/PlusNode.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import geometricOptics from '../../geometricOptics.js';
import GeometricOpticsColors from '../GeometricOpticsColors.js';
import GeometricOpticsConstants from '../GeometricOpticsConstants.js';
Expand All @@ -24,15 +23,9 @@ class FocalPointNode extends PlusNode {
* @param {FocalPoint} focalPoint
* @param {Property.<boolean>} visibleProperty
* @param {ModelViewTransform2} modelViewTransform
* @param {Tandem} tandem
* @param {Object} [options]
*/
constructor( focalPoint,
visibleProperty,
modelViewTransform,
tandem,
options ) {
assert && assert( tandem instanceof Tandem, 'invalid tandem' );
constructor( focalPoint, visibleProperty, modelViewTransform, options ) {

// options for plus Node. Rotated by 45 degrees to create an X shape.
options = merge( {}, FOCAL_POINT_OPTIONS,
Expand Down
10 changes: 3 additions & 7 deletions js/common/view/GeometricOpticsControlPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import Panel from '../../../../sun/js/Panel.js';
import SunConstants from '../../../../sun/js/SunConstants.js';
import VerticalAquaRadioButtonGroup from '../../../../sun/js/VerticalAquaRadioButtonGroup.js';
import VerticalCheckboxGroup from '../../../../sun/js/VerticalCheckboxGroup.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import geometricOptics from '../../geometricOptics.js';
import geometricOpticsStrings from '../../geometricOpticsStrings.js';
import GeometricOpticsConstants from '../GeometricOpticsConstants.js';
Expand Down Expand Up @@ -54,11 +53,9 @@ class GeometricOpticsControlPanel extends Panel {
* @param {Property.<LightRayMode>} lightRayModeProperty
* @param {VisibleProperties} visibleProperties
* @param {ModelViewTransform2} modelViewTransform
* @param {Tandem} tandem
* @param {Object} [options]
*/
constructor( optic, lightRayModeProperty, visibleProperties, modelViewTransform, tandem, options ) {
assert && assert( tandem instanceof Tandem, 'invalid tandem' );
constructor( optic, lightRayModeProperty, visibleProperties, modelViewTransform, options ) {

options = merge( {
hasLens: false
Expand Down Expand Up @@ -180,7 +177,7 @@ class GeometricOpticsControlPanel extends Panel {
* @param {string} string
* @param {Property} property
* @param {Object} [options]
* @returns {{node: Node, property: Property, tandem: Tandem}} item
* @returns {{node: Node, property: Property }} item
*/
const createCheckboxGroupItem = ( string, property, options ) => {
options = merge( {
Expand All @@ -195,8 +192,7 @@ class GeometricOpticsControlPanel extends Panel {

return {
node: node,
property: property,
tandem: tandem
property: property
};
};

Expand Down
9 changes: 1 addition & 8 deletions js/common/view/GeometricOpticsRulersLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,12 @@ class GeometricOpticRulersLayer extends Node {
* @param {Property.<Bounds2>} visibleBoundsProperty
* @param {Property.<number>} absoluteScaleProperty
* @param {Property.<ModelViewTransform2>} modelViewTransformProperty
* @param {Tandem} tandem
* @param {Object} [options]
*/
constructor( rulers,
visibleBoundsProperty,
absoluteScaleProperty,
modelViewTransformProperty,
tandem,
options ) {
constructor( rulers, visibleBoundsProperty, absoluteScaleProperty, modelViewTransformProperty, options ) {

super( options );


// @public {Bounds2} set to infinity, will be updated (mutated) later.
this.toolboxPanelBounds = new Bounds2( Number.NEGATIVE_INFINITY,
Number.NEGATIVE_INFINITY,
Expand Down
Loading

0 comments on commit 149ac3b

Please sign in to comment.