Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EmphasizeRightAngle attribute for angle #1924

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions cypress/e2e/DoenetML/tagSpecific/angle.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2244,4 +2244,50 @@ describe('Angle Tag Tests', function () {

})

it('emphasize right angle', () => {
cy.window().then(async (win) => {
win.postMessage({
doenetML: `
<graph>
<angle name="a1" through="(-5,0) (0,0) (0,-5)" />
<angle name="a2" through="(5,0) (0,0) (0,-5)" emphasizeRightAngle="false" />
<angle name="a3" through="(5,0) (0,0) (0,5)" emphasizeRightAngle="$bi3" />
</graph>

<p>Emphasize right angle 1: <booleanInput name="bi1" bindValueTo="$a1.emphasizeRightAngle" /></p>
<p>Emphasize right angle 2: <booleanInput name="bi2" bindValueTo="$a2.emphasizeRightAngle" /></p>
<p>Emphasize right angle 3: <booleanInput name="bi3" /></p>

<p name="emphasize">Emphasize right angle: $a1.emphasizeRightAngle, $a2.emphasizeRightAngle, $a3.emphasizeRightAngle</p>

`}, "*");
});

// TODO: How to check renderer itself?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open up a github issue or asana task to track this maybe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't open it for this line in particular. It's a bigger issue; none of the jsxgraph renderers have any test coverage, as I haven't figured out a simple way to test them. I'm pretty sure that I couldn't get cypress to drag a point or otherwise interact with the graph. I don't know how to test what jsxgraph actually puts in the DOM without depending on its internals (not that I actually put in any effort). So the TODO was more aspirational than a short term plan.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created follow up task - #1941


cy.get('#\\/emphasize').should("have.text", "Emphasize right angle: true, false, false");

cy.window().then(async (win) => {
let stateVariables = await win.returnAllStateVariables1();
expect(stateVariables['/a1'].stateValues.emphasizeRightAngle).eq(true);
expect(stateVariables['/a2'].stateValues.emphasizeRightAngle).eq(false);
expect(stateVariables['/a3'].stateValues.emphasizeRightAngle).eq(false);
})

cy.get('#\\/bi1').click();
cy.get('#\\/bi2').click();
cy.get('#\\/bi3').click();


cy.get('#\\/emphasize').should("have.text", "Emphasize right angle: false, true, true");

cy.window().then(async (win) => {
let stateVariables = await win.returnAllStateVariables1();
expect(stateVariables['/a1'].stateValues.emphasizeRightAngle).eq(false);
expect(stateVariables['/a2'].stateValues.emphasizeRightAngle).eq(true);
expect(stateVariables['/a3'].stateValues.emphasizeRightAngle).eq(true);
})

})

});
8 changes: 8 additions & 0 deletions src/Core/components/Angle.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ export default class Angle extends GraphicalComponent {
public: true,
};

attributes.emphasizeRightAngle = {
createComponentOfType: "boolean",
createStateVariable: "emphasizeRightAngle",
defaultValue: true,
public: true,
forRenderer: true,
}

return attributes;
}

Expand Down
5 changes: 4 additions & 1 deletion src/Viewer/renderers/angle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export default React.memo(function Angle(props) {
radius: SVs.numericalRadius,
fillColor: SVs.selectedStyle.fillColor,
strokeColor: SVs.selectedStyle.lineColor,
highlight: false
highlight: false,
orthoType: SVs.emphasizeRightAngle ? "square" : "sector",
};

jsxAngleAttributes.label = {
Expand Down Expand Up @@ -150,6 +151,8 @@ export default React.memo(function Angle(props) {
previousWithLabel.current = withlabel;
}

angleJXG.current.visProp.orthotype = SVs.emphasizeRightAngle ? "square" : "sector";

angleJXG.current.needsUpdate = true;
angleJXG.current.update();

Expand Down