@abi-software/scaffoldvuer 0.1.60 → 0.1.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/scaffoldvuer-wc.common.js +187 -23
- package/dist/scaffoldvuer-wc.umd.js +187 -23
- package/dist/scaffoldvuer-wc.umd.min.js +187 -23
- package/dist/scaffoldvuer.common.js +617 -181
- package/dist/scaffoldvuer.common.js.map +1 -1
- package/dist/scaffoldvuer.css +1 -1
- package/dist/scaffoldvuer.umd.js +617 -181
- package/dist/scaffoldvuer.umd.js.map +1 -1
- package/dist/scaffoldvuer.umd.min.js +1 -1
- package/dist/scaffoldvuer.umd.min.js.map +1 -1
- package/package-lock.json +6 -1
- package/package.json +2 -1
- package/src/App.vue +152 -99
- package/src/components/ScaffoldVuer.vue +198 -101
- package/src/components/TreeControls.vue +2 -2
- package/src/scripts/RendererModule.js +2 -0
- package/src/scripts/organsRenderer.js +4 -0
- package/src/scripts/search.js +143 -0
- package/src/scripts/utilities.js +6 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
|
|
3
|
+
Flatmap viewer and annotation tool
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2019 David Brooks
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
|
|
19
|
+
******************************************************************************/
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
//==============================================================================
|
|
23
|
+
|
|
24
|
+
import MiniSearch from 'minisearch';
|
|
25
|
+
|
|
26
|
+
//==============================================================================
|
|
27
|
+
|
|
28
|
+
// The properties of a feature we index and show
|
|
29
|
+
|
|
30
|
+
export const indexedProperties = [
|
|
31
|
+
'label',
|
|
32
|
+
'models',
|
|
33
|
+
'source'
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
//==============================================================================
|
|
37
|
+
|
|
38
|
+
export class SearchIndex
|
|
39
|
+
{
|
|
40
|
+
constructor()
|
|
41
|
+
{
|
|
42
|
+
this._searchEngine = new MiniSearch({
|
|
43
|
+
fields: ['groupName'],
|
|
44
|
+
storeFields: ['groupName'],
|
|
45
|
+
tokenize: (string, _fieldName) => string.split('"'), // indexing tokenizer
|
|
46
|
+
});
|
|
47
|
+
this._featureIds = [];
|
|
48
|
+
this.zincObjects = [];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
indexMetadata(featureId, metadata)
|
|
52
|
+
//================================
|
|
53
|
+
{
|
|
54
|
+
const textSeen = [];
|
|
55
|
+
for (const prop of indexedProperties) {
|
|
56
|
+
if (prop in metadata) {
|
|
57
|
+
const text = metadata[prop];
|
|
58
|
+
if (!textSeen.includes(text)) {
|
|
59
|
+
this.addTerm_(featureId, text);
|
|
60
|
+
textSeen.push(text);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
addZincObject(zincObject, id)
|
|
67
|
+
//=======================
|
|
68
|
+
{
|
|
69
|
+
const item = { groupName: zincObject.groupName, id };
|
|
70
|
+
this._searchEngine.add(item, {fields: ['groupName']});
|
|
71
|
+
this.zincObjects.push(zincObject);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
clearResults()
|
|
75
|
+
//============
|
|
76
|
+
{
|
|
77
|
+
this._;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
removeAll()
|
|
81
|
+
//=======================
|
|
82
|
+
{
|
|
83
|
+
this._searchEngine.removeAll();
|
|
84
|
+
this.zincObjects.length = 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
auto_suggest(text)
|
|
88
|
+
//================
|
|
89
|
+
{
|
|
90
|
+
return this._searchEngine.autoSuggest(text, {prefix: true});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
search(text){
|
|
94
|
+
let results = this._searchEngine.search(text, {prefix: true});
|
|
95
|
+
let zincResults = this.zincObjects.filter(zincObject => results.map(r => r.id).includes(zincObject.searchIndexId));
|
|
96
|
+
return zincResults;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// search(text)
|
|
100
|
+
// //==========
|
|
101
|
+
// {
|
|
102
|
+
// const options = {};
|
|
103
|
+
// let results = [];
|
|
104
|
+
// text = text.trim()
|
|
105
|
+
// if (text.length > 2 && ["'", '"'].indexOf(text.slice(0, 1)) >= 0) {
|
|
106
|
+
// text = text.replaceAll(text.slice(0, 1), '');
|
|
107
|
+
// results = this._searchEngine.search(text, {prefix: true, combineWith: 'AND'});
|
|
108
|
+
// } else if (text.length > 1) {
|
|
109
|
+
// results = this._searchEngine.search(text, {prefix: true});
|
|
110
|
+
// }
|
|
111
|
+
// const featureResults = results.map(r => {
|
|
112
|
+
// return {
|
|
113
|
+
// featureId: this._featureIds[r.id],
|
|
114
|
+
// score: r.score,
|
|
115
|
+
// terms: r.terms,
|
|
116
|
+
// text: r.text
|
|
117
|
+
// }});
|
|
118
|
+
// return new SearchResults(featureResults);
|
|
119
|
+
// }
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
//==============================================================================
|
|
123
|
+
|
|
124
|
+
class SearchResults
|
|
125
|
+
{
|
|
126
|
+
constructor(results)
|
|
127
|
+
{
|
|
128
|
+
this.__results = results.sort((a, b) => (b.score - a.score));
|
|
129
|
+
this.__featureIds = results.map(r => r.featureId);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
get featureIds()
|
|
133
|
+
{
|
|
134
|
+
return this.__featureIds;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
get results()
|
|
138
|
+
{
|
|
139
|
+
return this.__results;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//==============================================================================
|
package/src/scripts/utilities.js
CHANGED
|
@@ -35,3 +35,9 @@ export const findObjectsWithNames = (rootRegion, names, regionPath, transverse)
|
|
|
35
35
|
}
|
|
36
36
|
return targetObjects;
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
export const getAllObjects = (scene) => {
|
|
40
|
+
let objects = scene.getRootRegion().getAllObjects(true);
|
|
41
|
+
let id = 1;
|
|
42
|
+
return objects.map(object => Object.assign(object, { id: id++ })); // Add id to each object
|
|
43
|
+
}
|