Skip to content

Commit

Permalink
instrument OriginalCurve (see #48)
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Veillette <[email protected]>
  • Loading branch information
veillette committed Sep 22, 2022
1 parent 9216527 commit 2afe6ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
3 changes: 1 addition & 2 deletions js/common/model/CalculusGrapherModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ export default class CalculusGrapherModel {

public constructor( providedOptions: CalculusGrapherModelOptions ) {

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const options = optionize<CalculusGrapherModelOptions, SelfOptions>()( {}, 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 );
Expand Down
19 changes: 16 additions & 3 deletions js/common/model/OriginalCurve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PhetioObjectOptions, 'tandem'>;

export default class OriginalCurve extends Curve {

// the 'mode' that user is in for manipulating curves. This
Expand All @@ -49,14 +57,19 @@ export default class OriginalCurve extends Curve {
// user-manipulation.
public curveManipulationWidthProperty: NumberProperty;

public constructor() {
public constructor( providedOptions: OriginalCurveOptions ) {

const options = optionize<OriginalCurveOptions, SelfOptions>()( {}, 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' )
} );
}

Expand Down

0 comments on commit 2afe6ed

Please sign in to comment.