Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

Commit

Permalink
changing annotation flag doesOverlapSelf -> overlapsSelf for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
tnrich committed Aug 5, 2021
1 parent 80381c8 commit 2cc6377
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 63 deletions.
16 changes: 8 additions & 8 deletions cypress/integration/partTypes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ describe("partTypes", function () {
});
it(`parts that overlap with themselves should be supported`, () => {
cy.tgToggle("allowPartsToOverlapSelf");
cy.get(".veRowViewPart.doesOverlapSelf").should("not.exist");
cy.get(".veCircularViewPart.doesOverlapSelf").should("not.exist");
cy.get(".veRowViewPart.overlapsSelf").should("not.exist");
cy.get(".veCircularViewPart.overlapsSelf").should("not.exist");
cy.contains(".veLabelText", "Part 0").trigger("contextmenu");
cy.contains(".bp3-menu-item", "Edit Part").click();
cy.contains(".bp3-dialog div", "Advanced").click();
cy.contains(".bp3-dialog div", "Overlaps Self").click();
cy.contains(".bp3-dialog button", "Save").click();

cy.get(".veRowViewPart.doesOverlapSelf").should("exist");
cy.get(".veCircularViewPart.doesOverlapSelf").should("exist");
cy.get(".veRowViewPart.overlapsSelf").should("exist");
cy.get(".veCircularViewPart.overlapsSelf").should("exist");
cy.contains(".veLabelText", "Part 0").trigger("contextmenu");
cy.contains(".bp3-menu-item", "Edit Part").click();
//this should already be open!
Expand Down Expand Up @@ -46,10 +46,10 @@ describe("partTypes", function () {
cy.get(".tg-select").click();
cy.contains(".tg-select-option", "misc_RNA").click();
cy.get(".bp3-dialog-body").contains("Save").click();
cy.contains(
".veRowViewFeaturesContainer text",
"test feature"
).trigger("contextmenu", { force: true });
cy.contains(".veRowViewFeaturesContainer text", "test feature").trigger(
"contextmenu",
{ force: true }
);
cy.contains(".bp3-menu-item", "Make a Part from Feature").click();
cy.get(".bp3-menu").should("not.exist");
cy.contains(".veRowViewPart title", "test feature").trigger("contextmenu", {
Expand Down
2 changes: 1 addition & 1 deletion demo/src/EditorDemo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ sequenceData: {
then a new option will appear in the
Edit/Create Part Dialog that a user can use to create a
part that "wraps around the whole sequence and back over itself".
This will cause part.doesOverlapSelf = true
This will cause part.overlapsSelf = true
`
})}
{renderToggle({
Expand Down
6 changes: 3 additions & 3 deletions src/CircularView/Part.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export default function Part({
annotationHeight,
totalAngle,
color,
doesOverlapSelf,
overlapsSelf,
className
}) {
let path = drawDirectedPiePiece({
const path = drawDirectedPiePiece({
radius,
doesOverlapSelf,
overlapsSelf,
annotationHeight,
totalAngle,
arrowheadLength,
Expand Down
27 changes: 12 additions & 15 deletions src/CircularView/drawAnnotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,14 @@ function drawAnnotations({
return -getRangeLength(a, sequenceLength);
})
.map((annotation) => {
let {
startAngle,
endAngle,
totalAngle,
centerAngle,
locationAngles
} = getRangeAngles(
positionBy ? positionBy(annotation) : annotation,
sequenceLength
);
const { startAngle, endAngle, totalAngle, centerAngle, locationAngles } =
getRangeAngles(
positionBy ? positionBy(annotation) : annotation,
sequenceLength
);

let spansOrigin = startAngle > endAngle;
let annotationCopy = {
const spansOrigin = startAngle > endAngle;
const annotationCopy = {
...annotation,
startAngle,
endAngle,
Expand All @@ -69,7 +64,9 @@ function drawAnnotations({
};
if (!allOnSameLevel) {
//expand the end angle if annotation spans the origin
let expandedEndAngle = spansOrigin ? endAngle + 2 * Math.PI : endAngle;
const expandedEndAngle = spansOrigin
? endAngle + 2 * Math.PI
: endAngle;
let yOffset1;
let yOffset2;
if (spansOrigin) {
Expand Down Expand Up @@ -188,7 +185,7 @@ function drawAnnotations({
};
}

let annotationColor = getColor
const annotationColor = getColor
? getColor(annotation)
: annotation.color || "purple";

Expand All @@ -204,7 +201,7 @@ function drawAnnotations({
annotationType,
showLabels,
Annotation,
doesOverlapSelf: annotation.doesOverlapSelf,
overlapsSelf: annotation.overlapsSelf,
labelCenter: centerAngle,
startAngle,
endAngle,
Expand Down
46 changes: 26 additions & 20 deletions src/CircularView/drawDirectedPiePiece.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ export default function drawDirectedPiePiece({
tailThickness = 0.6,
arrowheadLength = 1,
radius,
doesOverlapSelf,
overlapsSelf,
annotationHeight,
totalAngle
}) {
let tailHeight = annotationHeight * tailThickness;
const tailHeight = annotationHeight * tailThickness;

let arrowheadOuterRadius = radius + annotationHeight / 2;
let arrowheadInnerRadius = radius - annotationHeight / 2;
let tailOuterRadius = radius + tailHeight / 2;
let tailInnerRadius = radius - tailHeight / 2;
const arrowheadOuterRadius = radius + annotationHeight / 2;
const arrowheadInnerRadius = radius - annotationHeight / 2;
const tailOuterRadius = radius + tailHeight / 2;
const tailInnerRadius = radius - tailHeight / 2;

// var arrowheadAngle = totalAngle / 2
let arrowheadAngle = arrowheadLength / (Math.PI * 2);
Expand All @@ -31,35 +31,41 @@ export default function drawDirectedPiePiece({
//set arrowhead length to the angle in radians length
arrowheadAngle = totalAngle;
}
let arcAngle = totalAngle - arrowheadAngle;
const arcAngle = totalAngle - arrowheadAngle;

//the main points we need to draw the arrow and in the order we draw them in:
let arrowheadPoint = polarToSpecialCartesian(radius, 0);
const arrowheadPoint = polarToSpecialCartesian(radius, 0);

let arrowheadPointInner = polarToSpecialCartesian(radius, -stickOutThisMuch);
const arrowheadPointInner = polarToSpecialCartesian(
radius,
-stickOutThisMuch
);

let arrowheadBottom = polarToSpecialCartesian(
const arrowheadBottom = polarToSpecialCartesian(
arrowheadInnerRadius,
arrowheadAngle
);
let arcLeftBottom = polarToSpecialCartesian(tailInnerRadius, arrowheadAngle);
let arcRightBottom = polarToSpecialCartesian(tailInnerRadius, totalAngle);
let arcRightTop = polarToSpecialCartesian(tailOuterRadius, totalAngle);
let arcRightMiddle = polarToSpecialCartesian(radius, totalAngle);
let arcRightMiddleOuter = polarToSpecialCartesian(
const arcLeftBottom = polarToSpecialCartesian(
tailInnerRadius,
arrowheadAngle
);
const arcRightBottom = polarToSpecialCartesian(tailInnerRadius, totalAngle);
const arcRightTop = polarToSpecialCartesian(tailOuterRadius, totalAngle);
const arcRightMiddle = polarToSpecialCartesian(radius, totalAngle);
const arcRightMiddleOuter = polarToSpecialCartesian(
radius,
totalAngle + stickOutThisMuch
);
let arcLeftTop = polarToSpecialCartesian(tailOuterRadius, arrowheadAngle);
let arrowheadTop = polarToSpecialCartesian(
const arcLeftTop = polarToSpecialCartesian(tailOuterRadius, arrowheadAngle);
const arrowheadTop = polarToSpecialCartesian(
arrowheadOuterRadius,
arrowheadAngle
);

let largeArcFlag = arcAngle > Math.PI ? 1 : 0;
const largeArcFlag = arcAngle > Math.PI ? 1 : 0;
let path = Path().moveto(arrowheadPoint.x, arrowheadPoint.y);

if (doesOverlapSelf) {
if (overlapsSelf) {
path = path
.lineto(arrowheadPointInner.x, arrowheadPointInner.y)
.lineto(arrowheadPoint.x, arrowheadPoint.y);
Expand All @@ -78,7 +84,7 @@ export default function drawDirectedPiePiece({
y: arcRightBottom.y
});

if (doesOverlapSelf) {
if (overlapsSelf) {
path = path
.lineto(arcRightMiddle.x, arcRightMiddle.y)
.lineto(arcRightMiddleOuter.x, arcRightMiddleOuter.y)
Expand Down
4 changes: 2 additions & 2 deletions src/RowItem/StackedAnnotations/PointedAnnotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ class PointedAnnotation extends React.PureComponent {
const widthMinusOne = width - charWN;
let path;
let hasAPoint = false;
const endLine = annotation.doesOverlapSelf
const endLine = annotation.overlapsSelf
? `L 0,${height / 2}
L -10,${height / 2}
L 0,${height / 2} `
: "";
const arrowLine = annotation.doesOverlapSelf
const arrowLine = annotation.overlapsSelf
? `L ${width + 10},${height / 2}
L ${width},${height / 2} `
: "";
Expand Down
17 changes: 7 additions & 10 deletions src/helperComponents/AddOrEditAnnotationDialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class AddOrEditAnnotationDialog extends React.Component {
annotationVisibilityShow,
renderLocations,
locations,
doesOverlapSelf,
overlapsSelf,
start,
end,
advancedOptions,
Expand Down Expand Up @@ -226,7 +226,7 @@ class AddOrEditAnnotationDialog extends React.Component {

const newAnnotation = tidyUpAnnotation(
convertRangeTo0Based({
doesOverlapSelf: data.doesOverlapSelf,
overlapsSelf: data.overlapsSelf,
...updatedData,
...(annotationTypePlural === "primers" //if we're making a primer it should automatically have a type of primer
? { type: "primer_bind" }
Expand All @@ -235,8 +235,8 @@ class AddOrEditAnnotationDialog extends React.Component {
...(hasJoinedLocations && {
//only add locations if there are locations
start: updatedData.locations[0].start, //override the start and end to use the start and end of the joined locations
end:
updatedData.locations[updatedData.locations.length - 1].end,
end: updatedData.locations[updatedData.locations.length - 1]
.end,
locations: updatedData.locations.map(convertRangeTo0Based)
})
}),
Expand Down Expand Up @@ -348,9 +348,7 @@ class AddOrEditAnnotationDialog extends React.Component {
style={{ marginBottom: 15, marginTop: -5, fontStyle: "italic" }}
>
Length:{" "}
{doesOverlapSelf
? sequenceLength + annotationLength
: annotationLength}
{overlapsSelf ? sequenceLength + annotationLength : annotationLength}
</div>
<Notes readOnly={this.props.readOnly} notes={this.notes}></Notes>
<Advanced
Expand Down Expand Up @@ -429,8 +427,7 @@ export default ({ formName, getProps, dialogProps }) => {
"In a non-circular sequence, joined spans must be in ascending order"
};
errors.locations[values.locations.length - 1] = {
end:
"In a non-circular sequence, joined spans must be in ascending order"
end: "In a non-circular sequence, joined spans must be in ascending order"
};
}
values.locations.forEach((loc, index) => {
Expand Down Expand Up @@ -473,7 +470,7 @@ export default ({ formName, getProps, dialogProps }) => {
return errors;
}
}),
formValues("start", "end", "doesOverlapSelf", "locations")
formValues("start", "end", "overlapsSelf", "locations")
)(AddOrEditAnnotationDialog);
};

Expand Down
4 changes: 2 additions & 2 deletions src/helperComponents/AddOrEditPartDialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const renderAdvancedOptions = ({ readOnly }) => (
inlineLabel
tooltipError
disabled={readOnly}
name="doesOverlapSelf"
name="overlapsSelf"
label={
<div style={{ display: "flex", alignItems: "center" }}>
Part Overlaps Self
Expand Down Expand Up @@ -85,7 +85,7 @@ export default AddOrEditAnnotationDialog({
},
getProps: (props) => ({
upsertAnnotation: props.upsertPart,
advancedDefaultOpen: get(props, "initialValues.doesOverlapSelf"),
advancedDefaultOpen: get(props, "initialValues.overlapsSelf"),
advancedOptions: props.allowPartsToOverlapSelf
? renderAdvancedOptions({ readOnly: props.readOnly })
: undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/utils/getAnnotationClassnames.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import classnames from "classnames";
import { startCase } from "lodash";

export default function getAnnotationClassnames(
{ doesOverlapSelf },
{ overlapsSelf },
{ viewName, type }
) {
const Type = startCase(type);
return classnames(`ve${Type}`, `ve${viewName}${Type}`, {
doesOverlapSelf
overlapsSelf
});
}

0 comments on commit 2cc6377

Please sign in to comment.