rudimentary annotation

This commit is contained in:
Scott Bell 2023-04-17 14:54:23 +02:00
parent 424a2b30ac
commit 2d868cdb58
3 changed files with 63 additions and 3 deletions

View File

@ -80,6 +80,7 @@
openmct.install(openmct.plugins.example.Generator()); openmct.install(openmct.plugins.example.Generator());
openmct.install(openmct.plugins.example.EventGeneratorPlugin()); openmct.install(openmct.plugins.example.EventGeneratorPlugin());
openmct.install(openmct.plugins.example.ExampleImagery()); openmct.install(openmct.plugins.example.ExampleImagery());
openmct.install(openmct.plugins.example.ExampleTags());
openmct.install(openmct.plugins.Espresso()); openmct.install(openmct.plugins.Espresso());
openmct.install(openmct.plugins.MyItems()); openmct.install(openmct.plugins.MyItems());

View File

@ -26,15 +26,15 @@
class="c-image-canvas" class="c-image-canvas"
style="width: 100%; height: 100%;" style="width: 100%; height: 100%;"
@mousedown="mouseDown" @mousedown="mouseDown"
@mouseup="mouseUp"
@mousemove="mouseMove" @mousemove="mouseMove"
@click="mouseClick"
></canvas> ></canvas>
</template> </template>
<script> <script>
export default { export default {
inject: ['openmct', 'domainObject'], inject: ['openmct', 'domainObject', 'objectPath'],
props: { props: {
}, },
data() { data() {
@ -80,9 +80,67 @@ export default {
this.drawRectInCanvas(); this.drawRectInCanvas();
} }
}, },
mouseUp(event) { mouseClick(event) {
event.stopPropagation();
console.debug(`🐭 mouseUp, dragging disabled`); console.debug(`🐭 mouseUp, dragging disabled`);
this.dragging = false; this.dragging = false;
const keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);
const targetDetails = {};
targetDetails[keyString] = {
x: this.rectangle.x,
y: this.rectangle.y,
width: this.rectangle.width,
height: this.rectangle.height
};
const targetDomainObjects = {};
targetDomainObjects[keyString] = this.domainObject;
const annotationContext = {
type: 'clicked-on-image-selection',
targetDetails,
targetDomainObjects,
annotations: [],
annotationType: this.openmct.annotation.ANNOTATION_TYPES.PIXEL_SPATIAL,
onAnnotationChange: null
};
const selection = this.createPathSelection();
if (selection.length && this.openmct.objects.areIdsEqual(selection[0].context.item.identifier, this.domainObject.identifier)) {
selection[0].context = {
...selection[0].context,
...annotationContext
};
} else {
selection.unshift({
element: this.$el,
context: {
item: this.domainObject,
...annotationContext
}
});
}
console.debug(`🍊 firing selection event`, selection);
this.openmct.selection.select(selection, true);
// would add cancel selection here
},
createPathSelection() {
let selection = [];
selection.unshift({
element: this.$el,
context: {
item: this.domainObject
}
});
this.objectPath.forEach((pathObject, index) => {
selection.push({
element: this.openmct.layout.$refs.browseObject.$el,
context: {
item: pathObject
}
});
});
return selection;
}, },
mouseDown(event) { mouseDown(event) {
console.debug(`🐭 mouseDown`); console.debug(`🐭 mouseDown`);

View File

@ -175,6 +175,7 @@ export default {
} }
}, },
updateSelection(selection) { updateSelection(selection) {
console.debug(`🥾 selection changed`, selection);
const unobserveEntryFunctions = Object.values(this.unobserveEntries); const unobserveEntryFunctions = Object.values(this.unobserveEntries);
unobserveEntryFunctions.forEach(unobserveEntry => { unobserveEntryFunctions.forEach(unobserveEntry => {
unobserveEntry(); unobserveEntry();