Skip to content

Commit

Permalink
add debugOpticalAxis query param, #283
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Dec 23, 2021
1 parent ab318fd commit 20888bb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions js/common/GOQueryParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ const SCHEMA = {
type: 'number',
defaultValue: 400,
isValidValue: ( value: number ) => ( value >= 100 )
},

// The optical axis is drawn using 2 Nodes, OpticalAxisNode and OpticalAxisForegroundNode.
// This flag uses 'red' stroke for the segments drawn by OpticalAxisForegroundNode.
debugOpticalAxis: {
type: 'flag'
}
};

Expand Down
11 changes: 9 additions & 2 deletions js/common/view/OpticalAxisForegroundNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import Property from '../../../../axon/js/Property.js';
import Bounds2 from '../../../../dot/js/Bounds2.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import Shape from '../../../../kite/js/Shape.js';
import merge from '../../../../phet-core/js/merge.js';
import ModelViewTransform2 from '../../../../phetcommon/js/view/ModelViewTransform2.js';
import geometricOptics from '../../geometricOptics.js';
import Barrier from '../model/Barrier.js';
import Representation from '../model/Representation.js';
import OpticalAxisNode, { OpticalAxisNodeOptions } from './OpticalAxisNode.js';
import GOQueryParameters from '../GOQueryParameters.js';

class OpticalAxisForegroundNode extends OpticalAxisNode {

Expand All @@ -31,7 +33,7 @@ class OpticalAxisForegroundNode extends OpticalAxisNode {
* @param barrier
* @param modelBoundsProperty
* @param modelViewTransform
* @param options
* @param providedOptions
*/
constructor( opticPositionProperty: IReadOnlyProperty<Vector2>,
representationProperty: IReadOnlyProperty<Representation>,
Expand All @@ -41,7 +43,12 @@ class OpticalAxisForegroundNode extends OpticalAxisNode {
barrier: Barrier | null,
modelBoundsProperty: IReadOnlyProperty<Bounds2>,
modelViewTransform: ModelViewTransform2,
options: OpticalAxisNodeOptions ) {
providedOptions: OpticalAxisNodeOptions ) {

const options = merge( {}, providedOptions ) as OpticalAxisNodeOptions;
if ( GOQueryParameters.debugOpticalAxis ) {
options.stroke = 'red';
}

// create optical axis line, with arbitrary length values.
super( opticPositionProperty, modelBoundsProperty, modelViewTransform, options );
Expand Down
1 change: 1 addition & 0 deletions js/common/view/OpticalAxisNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import GOColors from '../GOColors.js';
import GOConstants from '../GOConstants.js';

type OpticalAxisNodeOptions = {
stroke?: ColorDef,
visibleProperty: IProperty<boolean>
};

Expand Down

0 comments on commit 20888bb

Please sign in to comment.