mirror of
https://github.com/nasa/openmct.git
synced 2025-03-17 17:45:47 +00:00
remove kdbush and generalize annotation selection
This commit is contained in:
parent
85482902be
commit
87d695a454
@ -80,7 +80,6 @@ const config = {
|
||||
projectRootDir,
|
||||
"src/api/objects/object-utils.js"
|
||||
),
|
||||
"kdbush": path.join(projectRootDir, "node_modules/kdbush/kdbush.min.js"),
|
||||
utils: path.join(projectRootDir, "src/utils")
|
||||
}
|
||||
},
|
||||
|
@ -44,7 +44,6 @@
|
||||
"karma-sourcemap-loader": "0.4.0",
|
||||
"karma-spec-reporter": "0.0.36",
|
||||
"karma-webpack": "5.0.0",
|
||||
"kdbush": "3.0.0",
|
||||
"location-bar": "3.0.1",
|
||||
"lodash": "4.17.21",
|
||||
"mini-css-extract-plugin": "2.7.5",
|
||||
|
@ -214,7 +214,6 @@ import MctTicks from "./MctTicks.vue";
|
||||
import MctChart from "./chart/MctChart.vue";
|
||||
import XAxis from "./axis/XAxis.vue";
|
||||
import YAxis from "./axis/YAxis.vue";
|
||||
import KDBush from 'kdbush';
|
||||
import Flatbush from 'flatbush';
|
||||
import _ from "lodash";
|
||||
|
||||
@ -427,8 +426,8 @@ export default {
|
||||
// on clicking on a search result we highlight the annotation and zoom - we know it's an annotation result when isAnnotationSearchResult === true
|
||||
// We shouldn't zoom when we're selecting existing annotations to view them or creating new annotations.
|
||||
const selectionType = selection?.[0]?.[0]?.context?.type;
|
||||
const validSelectionTypes = ['clicked-on-plot-selection', 'plot-annotation-search-result'];
|
||||
const isAnnotationSearchResult = selectionType === 'plot-annotation-search-result';
|
||||
const validSelectionTypes = ['clicked-on-plot-selection', 'annotation-search-result'];
|
||||
const isAnnotationSearchResult = selectionType === 'annotation-search-result';
|
||||
|
||||
if (!validSelectionTypes.includes(selectionType)) {
|
||||
// wrong type of selection
|
||||
@ -1349,19 +1348,6 @@ export default {
|
||||
|
||||
return annotationsByPoints.flat();
|
||||
},
|
||||
searchWithKDTree(seriesData, seriesModel, boundingBox) {
|
||||
const kdTree = new KDBush(seriesData,
|
||||
(point) => {
|
||||
return seriesModel.getXVal(point);
|
||||
},
|
||||
(point) => {
|
||||
return seriesModel.getYVal(point);
|
||||
}
|
||||
);
|
||||
const rangeResults = kdTree.range(boundingBox.minX, boundingBox.minY, boundingBox.maxX, boundingBox.maxY);
|
||||
|
||||
return rangeResults;
|
||||
},
|
||||
searchWithFlatbush(seriesData, seriesModel, boundingBox) {
|
||||
const flatbush = new Flatbush(seriesData.length);
|
||||
seriesData.forEach(point => {
|
||||
@ -1389,14 +1375,7 @@ export default {
|
||||
const seriesData = seriesModel.getSeriesData();
|
||||
if (seriesData && seriesData.length) {
|
||||
const searchResults = [];
|
||||
let startTime = Date.now();
|
||||
let rangeResults = this.searchWithKDTree(seriesData, seriesModel, boundingBox);
|
||||
let endTime = Date.now();
|
||||
console.debug(`KD Tree Annotation search took ${endTime - startTime} ms for ${seriesData.length} points`);
|
||||
startTime = Date.now();
|
||||
rangeResults = this.searchWithFlatbush(seriesData, seriesModel, boundingBox);
|
||||
endTime = Date.now();
|
||||
console.debug(`Flatbush Tree Annotation search took ${endTime - startTime} ms for ${seriesData.length} points`);
|
||||
const rangeResults = this.searchWithFlatbush(seriesData, seriesModel, boundingBox);
|
||||
rangeResults.forEach(id => {
|
||||
const seriesDatum = seriesData[id];
|
||||
if (seriesDatum) {
|
||||
|
@ -129,11 +129,11 @@ export default {
|
||||
mounted() {
|
||||
this.previewAction = new PreviewAction(this.openmct);
|
||||
this.previewAction.on('isVisible', this.togglePreviewState);
|
||||
this.clickedPlotAnnotation = this.clickedPlotAnnotation.bind(this);
|
||||
this.fireAnnotationSelection = this.fireAnnotationSelection.bind(this);
|
||||
},
|
||||
destroyed() {
|
||||
this.previewAction.off('isVisible', this.togglePreviewState);
|
||||
this.openmct.selection.off('change', this.clickedPlotAnnotation);
|
||||
this.openmct.selection.off('change', this.fireAnnotationSelection);
|
||||
},
|
||||
methods: {
|
||||
clickedResult(event) {
|
||||
@ -146,15 +146,15 @@ export default {
|
||||
if (!this.openmct.router.isNavigatedObject(objectPath)) {
|
||||
// if we're not on the correct page, navigate to the object,
|
||||
// then wait for the selection event to fire before issuing a new selection
|
||||
if (this.result.annotationType === this.openmct.annotation.ANNOTATION_TYPES.PLOT_SPATIAL) {
|
||||
this.openmct.selection.on('change', this.clickedPlotAnnotation);
|
||||
if (this.result.annotationType) {
|
||||
this.openmct.selection.on('change', this.fireAnnotationSelection);
|
||||
}
|
||||
|
||||
this.openmct.router.navigate(resultUrl);
|
||||
} else {
|
||||
// if this is the navigated object, then we are already on the correct page
|
||||
// and just need to issue the selection event
|
||||
this.clickedPlotAnnotation();
|
||||
this.fireAnnotationSelection();
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -163,8 +163,8 @@ export default {
|
||||
this.previewAction.invoke(objectPath);
|
||||
}
|
||||
},
|
||||
clickedPlotAnnotation() {
|
||||
this.openmct.selection.off('change', this.clickedPlotAnnotation);
|
||||
fireAnnotationSelection() {
|
||||
this.openmct.selection.off('change', this.fireAnnotationSelection);
|
||||
|
||||
const targetDetails = {};
|
||||
const targetDomainObjects = {};
|
||||
@ -181,7 +181,7 @@ export default {
|
||||
element: this.$el,
|
||||
context: {
|
||||
item: this.result.targetModels[0],
|
||||
type: 'plot-annotation-search-result',
|
||||
type: 'annotation-search-result',
|
||||
targetDetails,
|
||||
targetDomainObjects,
|
||||
annotations: [this.result],
|
||||
|
Loading…
x
Reference in New Issue
Block a user