diff --git a/.webpack/webpack.common.js b/.webpack/webpack.common.js index 1b31af4bc7..20c9e03b24 100644 --- a/.webpack/webpack.common.js +++ b/.webpack/webpack.common.js @@ -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") } }, diff --git a/package.json b/package.json index c07fbbb4d2..362f38b338 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/plugins/plot/MctPlot.vue b/src/plugins/plot/MctPlot.vue index 9cd355b351..c0f1896ccd 100644 --- a/src/plugins/plot/MctPlot.vue +++ b/src/plugins/plot/MctPlot.vue @@ -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) { diff --git a/src/ui/layout/search/AnnotationSearchResult.vue b/src/ui/layout/search/AnnotationSearchResult.vue index c64e779ee9..be9faac6b7 100644 --- a/src/ui/layout/search/AnnotationSearchResult.vue +++ b/src/ui/layout/search/AnnotationSearchResult.vue @@ -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],