Skip to content

Commit

Permalink
address pr review
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbell committed Oct 6, 2023
1 parent 5fcd118 commit 3084032
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ test.describe('Example Imagery Object', () => {
await expect(page.getByText('Driving')).toBeHidden();
await expect(page.getByText('Science')).toBeHidden();

test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/7083'
});
// click on annotation again and expect tags to appear
await page.mouse.click(canvasCenterX - 50, canvasCenterY - 50);
await expect(page.getByText('Driving')).toBeVisible();
Expand Down
34 changes: 20 additions & 14 deletions src/plugins/imagery/components/AnnotationsCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,9 @@ export default {
)?.rectangle;
const annotationRectangleForPixelDepth =
this.transformRectangleToPixelDense(annotationRectangle);
let { x, y, width, height } = annotationRectangleForPixelDepth;
let x2 = x + width;
let y2 = y + height;
// if height or width are negative, we need to adjust the x and y
if (width < 0) {
x2 = x;
x = x + width;
}
if (height < 0) {
y2 = y;
y = y + height;
}
const { x, y, x2, y2 } = this.transformAnnotationRectangleToFlatbushRectangle(

Check warning on line 81 in src/plugins/imagery/components/AnnotationsCanvas.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/imagery/components/AnnotationsCanvas.vue#L81

Added line #L81 was not covered by tests
annotationRectangleForPixelDepth
);
const indexNumber = builtAnnotationsIndex.add(x, y, x2, y2);

Check warning on line 84 in src/plugins/imagery/components/AnnotationsCanvas.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/imagery/components/AnnotationsCanvas.vue#L84

Added line #L84 was not covered by tests
this.indexToAnnotationMap[indexNumber] = annotation;
});
Expand Down Expand Up @@ -133,6 +122,23 @@ export default {
this.selectedAnnotations = annotations;
this.$emit('annotations-changed', annotations);
},
transformAnnotationRectangleToFlatbushRectangle(annotationRectangle) {
let { x, y, width, height } = annotationRectangle;

Check warning on line 126 in src/plugins/imagery/components/AnnotationsCanvas.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/imagery/components/AnnotationsCanvas.vue#L126

Added line #L126 was not covered by tests
let x2 = x + width;
let y2 = y + height;

Check warning on line 128 in src/plugins/imagery/components/AnnotationsCanvas.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/imagery/components/AnnotationsCanvas.vue#L128

Added line #L128 was not covered by tests
// if height or width are negative, we need to adjust the x and y
if (width < 0) {
x2 = x;
x = x + width;
}

Check warning on line 134 in src/plugins/imagery/components/AnnotationsCanvas.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/imagery/components/AnnotationsCanvas.vue#L131-L134

Added lines #L131 - L134 were not covered by tests
if (height < 0) {
y2 = y;
y = y + height;
}

Check warning on line 138 in src/plugins/imagery/components/AnnotationsCanvas.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/imagery/components/AnnotationsCanvas.vue#L137-L138

Added lines #L137 - L138 were not covered by tests
return { x, y, x2, y2 };

Check warning on line 140 in src/plugins/imagery/components/AnnotationsCanvas.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/imagery/components/AnnotationsCanvas.vue#L140

Added line #L140 was not covered by tests
},
updateSelection(selection) {
const selectionContext = selection?.[0]?.[0]?.context?.item;
const selectionType = selection?.[0]?.[0]?.context?.type;
Expand Down

0 comments on commit 3084032

Please sign in to comment.