@abi-software/scaffoldvuer 0.2.2 → 0.2.3-alpha

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.
Files changed (47) hide show
  1. package/.eslintrc.js +12 -12
  2. package/CHANGELOG.md +316 -316
  3. package/LICENSE +201 -201
  4. package/README.md +164 -164
  5. package/babel.config.js +14 -14
  6. package/dist/scaffoldvuer-wc.common.js +183 -35
  7. package/dist/scaffoldvuer-wc.umd.js +183 -35
  8. package/dist/scaffoldvuer-wc.umd.min.js +183 -35
  9. package/dist/scaffoldvuer.common.js +1076 -717
  10. package/dist/scaffoldvuer.common.js.map +1 -1
  11. package/dist/scaffoldvuer.css +1 -1
  12. package/dist/scaffoldvuer.umd.js +1076 -717
  13. package/dist/scaffoldvuer.umd.js.map +1 -1
  14. package/dist/scaffoldvuer.umd.min.js +1 -1
  15. package/dist/scaffoldvuer.umd.min.js.map +1 -1
  16. package/package-lock.json +18119 -18121
  17. package/package.json +89 -89
  18. package/public/index.html +17 -17
  19. package/src/App.vue +669 -714
  20. package/src/ScaffoldVuer-wc.js +13 -13
  21. package/src/{components → app}/DropZone.vue +114 -114
  22. package/src/{components → app}/ModelsInformation.js +35 -35
  23. package/src/{components → app}/ModelsTable.vue +113 -113
  24. package/src/app/TextureDemos.js +114 -0
  25. package/src/assets/_variables.scss +43 -43
  26. package/src/assets/styles.scss +7 -7
  27. package/src/components/OpacityControls.vue +222 -222
  28. package/src/components/ScaffoldTooltip.vue +142 -141
  29. package/src/components/ScaffoldVuer.md +44 -44
  30. package/src/components/ScaffoldVuer.vue +1997 -1887
  31. package/src/components/TreeControls.vue +699 -691
  32. package/src/components/index.js +7 -7
  33. package/src/components/test.pdf +0 -0
  34. package/src/main.js +14 -14
  35. package/src/scripts/BaseModule.js +80 -80
  36. package/src/scripts/RendererModule.js +289 -289
  37. package/src/scripts/WebGL.js +94 -94
  38. package/src/scripts/annotation.js +5 -5
  39. package/src/scripts/eventNotifier.js +66 -66
  40. package/src/scripts/graphicsHighlight.js +134 -134
  41. package/src/scripts/organsRenderer.js +587 -606
  42. package/src/scripts/search.js +182 -153
  43. package/src/scripts/utilities.js +146 -43
  44. package/src/searchControls.vue +122 -0
  45. package/styleguide.config.js +22 -22
  46. package/vue.config.js +41 -41
  47. package/src/credential.json +0 -12
@@ -1,153 +1,182 @@
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
- searchTerms(terms){
100
- let results = [];
101
- terms.forEach(term => {
102
- const result = this.search(term);
103
- results.push(...result);
104
- });
105
-
106
- return results;
107
- }
108
-
109
- // search(text)
110
- // //==========
111
- // {
112
- // const options = {};
113
- // let results = [];
114
- // text = text.trim()
115
- // if (text.length > 2 && ["'", '"'].indexOf(text.slice(0, 1)) >= 0) {
116
- // text = text.replaceAll(text.slice(0, 1), '');
117
- // results = this._searchEngine.search(text, {prefix: true, combineWith: 'AND'});
118
- // } else if (text.length > 1) {
119
- // results = this._searchEngine.search(text, {prefix: true});
120
- // }
121
- // const featureResults = results.map(r => {
122
- // return {
123
- // featureId: this._featureIds[r.id],
124
- // score: r.score,
125
- // terms: r.terms,
126
- // text: r.text
127
- // }});
128
- // return new SearchResults(featureResults);
129
- // }
130
- }
131
-
132
- //==============================================================================
133
-
134
- class SearchResults
135
- {
136
- constructor(results)
137
- {
138
- this.__results = results.sort((a, b) => (b.score - a.score));
139
- this.__featureIds = results.map(r => r.featureId);
140
- }
141
-
142
- get featureIds()
143
- {
144
- return this.__featureIds;
145
- }
146
-
147
- get results()
148
- {
149
- return this.__results;
150
- }
151
- }
152
-
153
- //==============================================================================
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
+ import { createUnqiuesFromObjects } from './utilities';
27
+
28
+ //==============================================================================
29
+
30
+ // The properties of a feature we index and show
31
+
32
+ export const indexedProperties = [
33
+ 'label',
34
+ 'models',
35
+ 'source'
36
+ ];
37
+
38
+ //==============================================================================
39
+
40
+ export class SearchIndex
41
+ {
42
+ constructor()
43
+ {
44
+ this._searchEngine = new MiniSearch({
45
+ fields: ['path', 'name'],
46
+ storeFields: ['path'],
47
+ tokenize: (string, _fieldName) => string.split('"'), // indexing tokenizer
48
+ });
49
+ this._featureIds = [];
50
+ this.zincObjects = [];
51
+ this.regions = [];
52
+ }
53
+
54
+ indexMetadata(featureId, metadata)
55
+ //================================
56
+ {
57
+ const textSeen = [];
58
+ for (const prop of indexedProperties) {
59
+ if (prop in metadata) {
60
+ const text = metadata[prop];
61
+ if (!textSeen.includes(text)) {
62
+ this.addTerm_(featureId, text);
63
+ textSeen.push(text);
64
+ }
65
+ }
66
+ }
67
+ }
68
+
69
+ addZincObject(zincObject, id)
70
+ //=======================
71
+ {
72
+ const path = zincObject.getRegion().getFullPath();
73
+ const fullPath = path ? `${path}/${zincObject.groupName}` : zincObject.groupName;
74
+ const item = { path: fullPath, name: zincObject.groupName, id };
75
+ this._searchEngine.add(item, {fields: ['path', 'name']});
76
+ this.zincObjects.push(zincObject);
77
+ }
78
+
79
+ addRegion(region, id)
80
+ //=======================
81
+ {
82
+ const item = { path: region.getFullPath(), name: region.getName(), id };
83
+ this._searchEngine.add(item, {fields: ['path', 'name']});
84
+ this.regions.push(region);
85
+ }
86
+
87
+ clearResults()
88
+ //============
89
+ {
90
+ this._;
91
+ }
92
+
93
+ removeAll()
94
+ //=======================
95
+ {
96
+ this._searchEngine.removeAll();
97
+ this.zincObjects.length = 0;
98
+ this.regions.length = 0;
99
+ }
100
+
101
+ auto_suggest(text)
102
+ //================
103
+ {
104
+ const results = this._searchEngine.autoSuggest(text, {prefix: true});
105
+ return results;
106
+ }
107
+
108
+ processResults(zincObjects, searchText) {
109
+ const result = {
110
+ regionPath: undefined,
111
+ label: `Search Results for \"`,
112
+ };
113
+ if (Array.isArray(searchText)) {
114
+ result.label += ','.join(searchText);
115
+ } else {
116
+ result.label += searchText;
117
+ }
118
+ result.label += `\"`;
119
+ if (zincObjects.length === 1) {
120
+ if (zincObjects[0].isRegion) {
121
+ result.regionPath = zincObjects[0].getFullPath();
122
+ } else if (zincObjects[0].isZincObject) {
123
+ result.regionPath = zincObjects[0].getRegion().getFullPath();
124
+ result.label = zincObjects[0].groupName;
125
+ }
126
+ }
127
+ result["zincObjects"] = createUnqiuesFromObjects(zincObjects);
128
+ return result;
129
+ }
130
+
131
+ search(text) {
132
+ const results = this._searchEngine.search(text, {prefix: true});
133
+ const zincResults = this.zincObjects.filter(zincObject => results.map(r => r.id).includes(zincObject.uuid));
134
+ const regionResults = this.regions.filter(region => results.map(r => r.id).includes(region.uuid));
135
+ zincResults.push(...regionResults);
136
+ return zincResults;
137
+ }
138
+
139
+ searchTerms(terms) {
140
+ let results = [];
141
+ terms.forEach(term => {
142
+ const result = this.search(term);
143
+ results.push(...result);
144
+ });
145
+
146
+ return results;
147
+ }
148
+
149
+ searchAndProcessResult(terms) {
150
+ let zincObjectResults = [];
151
+ if (Array.isArray(terms)) {
152
+ zincObjectResults = this.searchTerms(terms);
153
+ } else {
154
+ zincObjectResults = this.search(terms);
155
+ }
156
+ return this.processResults(zincObjectResults, terms);
157
+ }
158
+
159
+ }
160
+
161
+ //==============================================================================
162
+
163
+ class SearchResults
164
+ {
165
+ constructor(results)
166
+ {
167
+ this.__results = results.sort((a, b) => (b.score - a.score));
168
+ this.__featureIds = results.map(r => r.featureId);
169
+ }
170
+
171
+ get featureIds()
172
+ {
173
+ return this.__featureIds;
174
+ }
175
+
176
+ get results()
177
+ {
178
+ return this.__results;
179
+ }
180
+ }
181
+
182
+ //==============================================================================
@@ -1,43 +1,146 @@
1
- export const createListFromPrimitives = (primitives, list) => {
2
- if (primitives) {
3
- primitives.forEach(primitive => {
4
- if (primitive && primitive.getVisibility()) {
5
- list.push({
6
- group: primitive.groupName,
7
- regionPath: primitive.region.getFullPath()
8
- });
9
- }
10
- });
11
- }
12
- return list;
13
- }
14
-
15
- export const extractAllIds = (item, list) => {
16
- list.push(item.id);
17
- if (item.children)
18
- item.children.forEach(child => extractAllIds(child, list));
19
- }
20
-
21
- export const findObjectsWithNames = (rootRegion, names, regionPath, transverse) => {
22
- let targetRegion = rootRegion;
23
- const targetObjects = [];
24
- if (regionPath)
25
- targetRegion = rootRegion.findChildFromPath(regionPath);
26
- if (targetRegion) {
27
- const isArray = Array.isArray(names);
28
- let array = names;
29
- if (!isArray)
30
- array = [array];
31
- array.forEach(name => {
32
- const temp = targetRegion.findObjectsWithGroupName(name, transverse);
33
- targetObjects.push(...temp);
34
- });
35
- }
36
- return targetObjects;
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
- }
1
+ export const createListFromPrimitives = (primitives, list) => {
2
+ if (primitives) {
3
+ let id = "";
4
+ primitives.forEach(primitive => {
5
+ id = primitive.uuid;
6
+ if (primitive.region) {
7
+ id = primitive.region.uuid + "/" + id;
8
+ }
9
+ if (primitive && primitive.getVisibility()) {
10
+ list.push(id);
11
+ }
12
+ });
13
+ }
14
+ return list;
15
+ }
16
+
17
+ export const extractAllFullPaths = (item, list) => {
18
+ let nodeName = "";
19
+ if (item.isRegion) {
20
+ nodeName = `__r${item.regionPath}`;
21
+ }
22
+ if (item.isPrimitives) {
23
+ nodeName = `${item.regionPath}/${item.label}`;
24
+ }
25
+ list.push(nodeName);
26
+ if (item.children)
27
+ item.children.forEach(child => extractAllFullPaths(child, list));
28
+ }
29
+
30
+ export const findObjectsWithNames = (rootRegion, names, regionPath, transverse) => {
31
+ let targetRegion = rootRegion;
32
+ const targetObjects = [];
33
+ if (regionPath)
34
+ targetRegion = rootRegion.findChildFromPath(regionPath);
35
+ if (targetRegion) {
36
+ const isArray = Array.isArray(names);
37
+ let array = names;
38
+ if (!isArray) {
39
+ array = [array];
40
+ }
41
+ array.forEach(name => {
42
+ const temp = targetRegion.findObjectsWithGroupName(name, transverse);
43
+ targetObjects.push(...temp);
44
+ });
45
+ }
46
+ return targetObjects;
47
+ }
48
+
49
+ export const getAllObjects = (scene) => {
50
+ let objects = scene.getRootRegion().getAllObjects(true);
51
+ let id = 1;
52
+ return objects.map(object => Object.assign(object, { id: id++ })); // Add id to each object
53
+ }
54
+
55
+ const findObjectWithUUID = (objects, uuid, remove) => {
56
+ const index = objects.findIndex(obj => obj.uuid === uuid);
57
+ let object = undefined;
58
+ if (index > -1) {
59
+ object = objects[index];
60
+ if (remove) {
61
+ objects.splice(i, 1);
62
+ }
63
+ }
64
+ return object;
65
+ }
66
+
67
+ export const convertUUIDsToFullPaths = (rootRegion, IDs) => {
68
+ const results = [];
69
+ if (rootRegion && IDs && IDs.length > 0) {
70
+ //a region to primitivs map list
71
+ const rpLists = {};
72
+ const reIDToPath = {};
73
+ const allRegions = [rootRegion, ...rootRegion.getChildRegions(true)];
74
+ let region = undefined;
75
+ let primitive = undefined;
76
+ let regionID = undefined;
77
+
78
+ IDs.forEach(id => {
79
+ const uuids = id.split("/");
80
+ regionID = uuids[0];
81
+ region = findObjectWithUUID(allRegions, regionID, false);
82
+ if (region) {
83
+ if (!reIDToPath[regionID]) {
84
+ reIDToPath[regionID] = region.getFullPath();
85
+ }
86
+ if (uuids[1]) {
87
+ if (!rpLists[regionID]) {
88
+ rpLists[regionID] = region.getAllObjects(false);
89
+ }
90
+ primitive = findObjectWithUUID(rpLists[regionID], uuids[1], true);
91
+ if (primitive) {
92
+ results.push(`${reIDToPath[regionID]}/${primitive.groupName}`);
93
+ }
94
+ } else {
95
+ results.push(`__r/${reIDToPath[regionID]}`);
96
+ }
97
+ }
98
+ });
99
+ }
100
+ return results;
101
+ }
102
+
103
+ export const createUnqiuesFromObjects = (zincObjects) => {
104
+ if (zincObjects) {
105
+ const expanded = [];
106
+ zincObjects.forEach(obj => {
107
+ if (obj.isZincObject) {
108
+ expanded.push(obj);
109
+ } else if (obj.isRegion) {
110
+ expanded.push(...obj.getAllObjects(true));
111
+ }
112
+ });
113
+ const uniq = Object.values(
114
+ expanded.reduce((acc, obj) => ({ ...acc, [obj.uuid]: obj }), {})
115
+ );
116
+ return uniq;
117
+ }
118
+ return [];
119
+ }
120
+
121
+ export const getObjectsFromAnnotations = (scene, annotations) => {
122
+ const returned = {label: "Multiple selections", regionPath: "", objects: []};
123
+ if (annotations && scene) {
124
+ const rpList = {};
125
+ const rootRegion = scene.getRootRegion();
126
+ if (annotations.length > 0) {
127
+ returned.regionPath = annotations[0].data.region;
128
+ returned.label = annotations[0].data.group;
129
+ }
130
+ annotations.forEach(annotation => {
131
+ if (!annotation.data.region.includes(returned.regionPath)) {
132
+ returned.regionPath = "";
133
+ }
134
+ if (returned.label !== annotation.data.group) {
135
+ returned.label = "Multiple selections";
136
+ }
137
+ const region = rootRegion.findChildFromPath(annotation.data.region);
138
+ if (!rpList[region.uuid]) {
139
+ rpList[region.uuid] = region.getAllObjects(false);
140
+ }
141
+ const obj = findObjectWithUUID(rpList[region.uuid], annotation.data.uuid);
142
+ if (obj) returned.objects.push(obj);
143
+ });
144
+ }
145
+ return returned;
146
+ }
@@ -0,0 +1,122 @@
1
+ <template>
2
+ <div class="search-container">
3
+ <div class="text search-text">
4
+ Search within display
5
+ </div>
6
+ <el-autocomplete class="search-box" placeholder="Search"
7
+ v-model="searchText"
8
+ :fetch-suggestions="fetchSuggestions"
9
+ @keyup.enter.native="$emit('search', searchText)"
10
+ @select="$emit('search', $event.value)"
11
+ :popper-append-to-body=false
12
+ popper-class="autocomplete-popper">
13
+ </el-autocomplete>
14
+ <map-svg-icon icon="magnifyingGlass" class="magnify"
15
+ @click.native="$emit('search', searchText)"/>
16
+ <div v-if="failedSearch" class="text not-found-text">
17
+ '{{failedSearch}}' not found
18
+ </div>
19
+ </div>
20
+ </template>
21
+
22
+ <script>
23
+ /* eslint-disable no-alert, no-console */
24
+ import Vue from "vue";
25
+ import { MapSvgIcon } from '@abi-software/svg-sprite';
26
+ import { Autocomplete } from "element-ui";
27
+ import lang from "element-ui/lib/locale/lang/en";
28
+ import locale from "element-ui/lib/locale";
29
+
30
+ locale.use(lang);
31
+ Vue.use(Autocomplete);
32
+
33
+ export default {
34
+ name: "SearchControls",
35
+ props: {
36
+ failedSearch: undefined,
37
+ },
38
+ components: {
39
+ MapSvgIcon,
40
+ },
41
+ methods: {
42
+ fetchSuggestions: function(term, cb) {
43
+ if (term === "") {
44
+ cb([]);
45
+ } else {
46
+ this.$emit('fetch-suggestions', { term, cb });
47
+ }
48
+ },
49
+ },
50
+ data: function () {
51
+ return {
52
+ searchText: "",
53
+ };
54
+ },
55
+ };
56
+ </script>
57
+
58
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
59
+ <style scoped lang="scss">
60
+ @import "~element-ui/packages/theme-chalk/src/autocomplete";
61
+
62
+ .search-container {
63
+ display:flex;
64
+ flex-direction: row;
65
+
66
+ .text {
67
+ margin-left: 8px;
68
+ margin-top: 7px;
69
+ font-weight: 500;
70
+ -moz-user-select: none;
71
+ -webkit-user-select: none;
72
+ -ms-user-select: none;
73
+ user-select: none;
74
+ line-height:18px;
75
+ }
76
+ .search-text {
77
+ margin-top: 8px;
78
+ color: $grey;
79
+ font-size: 14px;
80
+ margin-left: 1rem;
81
+ }
82
+ .not-found-text {
83
+ margin-top: 8px;
84
+ color: $warning;
85
+ font-size: 0.8rem;
86
+ margin-left: 0.5rem;
87
+ }
88
+ .search-box {
89
+ margin-top: 2px;
90
+ margin-left:0.5rem;
91
+ height:28px;
92
+ width:137px;
93
+ ::v-deep .el-input__inner {
94
+ background-color: $background;
95
+ height:28px;
96
+ line-height:28px;
97
+ border: 1px solid rgb(144, 147, 153);
98
+ border-radius: 4px;
99
+ &:focus {
100
+ border-color: $app-primary-color;
101
+ }
102
+ }
103
+ }
104
+ .magnify {
105
+ margin-top: 2px;
106
+ margin-left:0.5rem;
107
+ background: $app-primary-color;
108
+ border-radius: 4px;
109
+ height:28px;
110
+ width:28px;
111
+ cursor: pointer;
112
+ &:hover {
113
+ box-shadow: -3px 2px 4px 0 rgba(0,0,0,0.25);
114
+ }
115
+ }
116
+ ::v-deep .autocomplete-popper {
117
+ min-width:137px!important;
118
+ width: auto!important;
119
+ }
120
+ }
121
+
122
+ </style>