From 2afe6ede18769062e50cfa1ad2b8a8addacbc11e Mon Sep 17 00:00:00 2001 From: Martin Veillette Date: Thu, 22 Sep 2022 09:33:03 -0400 Subject: [PATCH] instrument OriginalCurve (see #48) Signed-off-by: Martin Veillette --- js/common/model/CalculusGrapherModel.ts | 3 +-- js/common/model/OriginalCurve.ts | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/js/common/model/CalculusGrapherModel.ts b/js/common/model/CalculusGrapherModel.ts index ce3fabe1..f8e9c1bb 100644 --- a/js/common/model/CalculusGrapherModel.ts +++ b/js/common/model/CalculusGrapherModel.ts @@ -27,10 +27,9 @@ export default class CalculusGrapherModel { public constructor( providedOptions: CalculusGrapherModelOptions ) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars const options = optionize()( {}, providedOptions ); - this.originalCurve = new OriginalCurve(); + this.originalCurve = new OriginalCurve( options ); this.derivativeCurve = new DerivativeCurve( this.originalCurve ); this.secondDerivativeCurve = new DerivativeCurve( this.derivativeCurve ); this.integralCurve = new IntegralCurve( this.originalCurve ); diff --git a/js/common/model/OriginalCurve.ts b/js/common/model/OriginalCurve.ts index 21f6fef8..35406588 100644 --- a/js/common/model/OriginalCurve.ts +++ b/js/common/model/OriginalCurve.ts @@ -27,17 +27,25 @@ import EnumerationProperty from '../../../../axon/js/EnumerationProperty.js'; import NumberProperty from '../../../../axon/js/NumberProperty.js'; import Utils from '../../../../dot/js/Utils.js'; import Vector2 from '../../../../dot/js/Vector2.js'; +import optionize, { EmptySelfOptions } from '../../../../phet-core/js/optionize.js'; +import PickRequired from '../../../../phet-core/js/types/PickRequired.js'; +import { PhetioObjectOptions } from '../../../../tandem/js/PhetioObject.js'; import calculusGrapher from '../../calculusGrapher.js'; import CalculusGrapherConstants from '../CalculusGrapherConstants.js'; import CalculusGrapherQueryParameters from '../CalculusGrapherQueryParameters.js'; import Curve from './Curve.js'; import CurveManipulationMode from './CurveManipulationMode.js'; + // constants const CURVE_MANIPULATION_WIDTH_RANGE = CalculusGrapherConstants.CURVE_MANIPULATION_WIDTH_RANGE; const SMOOTHING_WINDOW_WIDTH = CalculusGrapherQueryParameters.smoothingWindowWidth; const POINTS_PER_COORDINATE = CalculusGrapherQueryParameters.pointsPerCoordinate; +type SelfOptions = EmptySelfOptions; + +export type OriginalCurveOptions = SelfOptions & PickRequired; + export default class OriginalCurve extends Curve { // the 'mode' that user is in for manipulating curves. This @@ -49,14 +57,19 @@ export default class OriginalCurve extends Curve { // user-manipulation. public curveManipulationWidthProperty: NumberProperty; - public constructor() { + public constructor( providedOptions: OriginalCurveOptions ) { + + const options = optionize()( {}, providedOptions ); super(); - this.curveManipulationModeProperty = new EnumerationProperty( CurveManipulationMode.HILL ); + this.curveManipulationModeProperty = new EnumerationProperty( CurveManipulationMode.HILL, { + tandem: options.tandem.createTandem( 'curveManipulationModeProperty' ) + } ); this.curveManipulationWidthProperty = new NumberProperty( CURVE_MANIPULATION_WIDTH_RANGE.defaultValue, { - range: CURVE_MANIPULATION_WIDTH_RANGE + range: CURVE_MANIPULATION_WIDTH_RANGE, + tandem: options.tandem.createTandem( 'curveManipulationWidthProperty' ) } ); }