widget-common-container 0.0.0

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 (87) hide show
  1. package/.angular/cache/19.2.26/ng-packagr/0997d7866dbb7999756bcd6dce071e827244865f4ff149c26d049d1515686b01 +1 -0
  2. package/.angular/cache/19.2.26/ng-packagr/882519e10fb587011272af89a34932495c0e2cc97d0c030536d1033ee55ce561 +1 -0
  3. package/.angular/cache/19.2.26/ng-packagr/8b15b546ec32b4e82b20945f62d23ba911050bdc6a4a60d34875eea6fe236635 +1 -0
  4. package/.angular/cache/19.2.26/ng-packagr/9711df1afdc00e2ac901d2b22d9559a220e74d16c0bf6d3917e410c565aed496 +1 -0
  5. package/.angular/cache/19.2.26/ng-packagr/tsbuildinfo/inspark-widget-common.tsbuildinfo +1 -0
  6. package/.editorconfig +13 -0
  7. package/.eslintrc.json +28 -0
  8. package/README.md +27 -0
  9. package/angular.json +46 -0
  10. package/e2e/protractor.conf.js +28 -0
  11. package/e2e/src/app.e2e-spec.ts +14 -0
  12. package/e2e/src/app.po.ts +11 -0
  13. package/e2e/tsconfig.e2e.json +13 -0
  14. package/package.json +75 -0
  15. package/projects/widget-common/copy.json +8 -0
  16. package/projects/widget-common/karma.conf.js +31 -0
  17. package/projects/widget-common/ng-package.json +7 -0
  18. package/projects/widget-common/package-lock.json +78 -0
  19. package/projects/widget-common/package.json +23 -0
  20. package/projects/widget-common/src/assets/error.svg +6 -0
  21. package/projects/widget-common/src/assets/falsevalue.svg +6 -0
  22. package/projects/widget-common/src/assets/icon.svg +6 -0
  23. package/projects/widget-common/src/assets/none.svg +6 -0
  24. package/projects/widget-common/src/assets/success.svg +6 -0
  25. package/projects/widget-common/src/assets/warning.svg +6 -0
  26. package/projects/widget-common/src/lib/common.ts +23 -0
  27. package/projects/widget-common/src/lib/communication.service.ts +59 -0
  28. package/projects/widget-common/src/lib/echart/echart.component.html +2 -0
  29. package/projects/widget-common/src/lib/echart/echart.component.scss +40 -0
  30. package/projects/widget-common/src/lib/echart/echart.component.ts +703 -0
  31. package/projects/widget-common/src/lib/echart/en.ts +156 -0
  32. package/projects/widget-common/src/lib/echart/ru.ts +156 -0
  33. package/projects/widget-common/src/lib/forge/ParamAssign.ts +187 -0
  34. package/projects/widget-common/src/lib/forge/Script.service.ts +86 -0
  35. package/projects/widget-common/src/lib/forge/extenstion.ts +263 -0
  36. package/projects/widget-common/src/lib/forge/forge.component.html +2 -0
  37. package/projects/widget-common/src/lib/forge/forge.component.scss +6 -0
  38. package/projects/widget-common/src/lib/forge/forge.component.ts +184 -0
  39. package/projects/widget-common/src/lib/forge/forge.interface.ts +4 -0
  40. package/projects/widget-common/src/lib/loader.ts +19 -0
  41. package/projects/widget-common/src/lib/pie-chart/pie-chart.component.html +1 -0
  42. package/projects/widget-common/src/lib/pie-chart/pie-chart.component.scss +3 -0
  43. package/projects/widget-common/src/lib/pie-chart/pie-chart.component.ts +252 -0
  44. package/projects/widget-common/src/lib/shared.module.ts +40 -0
  45. package/projects/widget-common/src/lib/sprintf.ts +212 -0
  46. package/projects/widget-common/src/lib/widget-container/widget-container.component.ts +53 -0
  47. package/projects/widget-common/src/lib/widget.api.ts +24 -0
  48. package/projects/widget-common/src/lib/widget.component.ts +87 -0
  49. package/projects/widget-common/src/lib/widget.dialog.ts +14 -0
  50. package/projects/widget-common/src/lib/widget.generator.ts +1532 -0
  51. package/projects/widget-common/src/lib/widget.interface.ts +871 -0
  52. package/projects/widget-common/src/lib/widget.utils.ts +634 -0
  53. package/projects/widget-common/src/public_api.ts +9 -0
  54. package/projects/widget-common/src/scss/main.scss +24 -0
  55. package/projects/widget-common/src/test.ts +22 -0
  56. package/projects/widget-common/tsconfig.lib.json +38 -0
  57. package/projects/widget-common/tsconfig.lib.prod.json +6 -0
  58. package/projects/widget-common/tsconfig.spec.json +17 -0
  59. package/projects/widget-common/tslint.json +17 -0
  60. package/projects/widget-common/versions/full/copy.json +15 -0
  61. package/projects/widget-common/versions/full/package.json +7 -0
  62. package/projects/widget-common/versions/full/public_api.ts +19 -0
  63. package/projects/widget-common/versions/interfaces/copy.json +15 -0
  64. package/projects/widget-common/versions/interfaces/package.json +7 -0
  65. package/projects/widget-common/versions/interfaces/public_api.ts +9 -0
  66. package/src/app/app.component.html +20 -0
  67. package/src/app/app.component.scss +0 -0
  68. package/src/app/app.component.spec.ts +31 -0
  69. package/src/app/app.component.ts +10 -0
  70. package/src/app/app.module.ts +16 -0
  71. package/src/assets/.gitkeep +0 -0
  72. package/src/browserslist +11 -0
  73. package/src/environments/environment.prod.ts +3 -0
  74. package/src/environments/environment.ts +16 -0
  75. package/src/favicon.ico +0 -0
  76. package/src/index.html +14 -0
  77. package/src/karma.conf.js +31 -0
  78. package/src/main.ts +12 -0
  79. package/src/polyfills.ts +80 -0
  80. package/src/styles.scss +1 -0
  81. package/src/test.ts +20 -0
  82. package/src/tsconfig.app.json +11 -0
  83. package/src/tsconfig.spec.json +18 -0
  84. package/src/tslint.json +17 -0
  85. package/tsconfig.json +34 -0
  86. package/tslint.json +131 -0
  87. package/update_full.js +27 -0
@@ -0,0 +1,156 @@
1
+
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. 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,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ */
20
+
21
+
22
+ /**
23
+ * AUTO-GENERATED FILE. DO NOT MODIFY.
24
+ */
25
+
26
+ /*
27
+ * Licensed to the Apache Software Foundation (ASF) under one
28
+ * or more contributor license agreements. See the NOTICE file
29
+ * distributed with this work for additional information
30
+ * regarding copyright ownership. The ASF licenses this file
31
+ * to you under the Apache License, Version 2.0 (the
32
+ * "License"); you may not use this file except in compliance
33
+ * with the License. You may obtain a copy of the License at
34
+ *
35
+ * http://www.apache.org/licenses/LICENSE-2.0
36
+ *
37
+ * Unless required by applicable law or agreed to in writing,
38
+ * software distributed under the License is distributed on an
39
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
40
+ * KIND, either express or implied. See the License for the
41
+ * specific language governing permissions and limitations
42
+ * under the License.
43
+ */
44
+
45
+ /**
46
+ * Language: English.
47
+ */
48
+ export default {
49
+ time: {
50
+ month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
51
+ monthAbbr: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
52
+ dayOfWeek: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
53
+ dayOfWeekAbbr: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
54
+ },
55
+ legend: {
56
+ selector: {
57
+ all: 'All',
58
+ inverse: 'Inv'
59
+ }
60
+ },
61
+ toolbox: {
62
+ brush: {
63
+ title: {
64
+ rect: 'Box Select',
65
+ polygon: 'Lasso Select',
66
+ lineX: 'Horizontally Select',
67
+ lineY: 'Vertically Select',
68
+ keep: 'Keep Selections',
69
+ clear: 'Clear Selections'
70
+ }
71
+ },
72
+ dataView: {
73
+ title: 'Data View',
74
+ lang: ['Data View', 'Close', 'Refresh']
75
+ },
76
+ dataZoom: {
77
+ title: {
78
+ zoom: 'Zoom',
79
+ back: 'Zoom Reset'
80
+ }
81
+ },
82
+ magicType: {
83
+ title: {
84
+ line: 'Line',
85
+ bar: 'Histogram',
86
+ stack: 'Stack',
87
+ tiled: 'Tile'
88
+ }
89
+ },
90
+ restore: {
91
+ title: 'Restore'
92
+ },
93
+ saveAsImage: {
94
+ title: 'Save as Image',
95
+ lang: ['Right Click to Save Image']
96
+ }
97
+ },
98
+ series: {
99
+ typeNames: {
100
+ pie: 'Pie chart',
101
+ bar: 'Bar chart',
102
+ line: 'Line chart',
103
+ scatter: 'Scatter plot',
104
+ effectScatter: 'Ripple scatter plot',
105
+ radar: 'Radar chart',
106
+ tree: 'Tree',
107
+ treemap: 'Treemap',
108
+ boxplot: 'Boxplot',
109
+ candlestick: 'Candlestick',
110
+ k: 'K line chart',
111
+ heatmap: 'Heat map',
112
+ map: 'Map',
113
+ parallel: 'Parallel coordinate map',
114
+ lines: 'Line graph',
115
+ graph: 'Relationship graph',
116
+ sankey: 'Sankey diagram',
117
+ funnel: 'Funnel chart',
118
+ gauge: 'Gauge',
119
+ pictorialBar: 'Pictorial bar',
120
+ themeRiver: 'Theme River Map',
121
+ sunburst: 'Sunburst'
122
+ }
123
+ },
124
+ aria: {
125
+ general: {
126
+ withTitle: 'This is a chart about "{title}"',
127
+ withoutTitle: 'This is a chart'
128
+ },
129
+ series: {
130
+ single: {
131
+ prefix: '',
132
+ withName: ' with type {seriesType} named {seriesName}.',
133
+ withoutName: ' with type {seriesType}.'
134
+ },
135
+ multiple: {
136
+ prefix: '. It consists of {seriesCount} series count.',
137
+ withName: ' The {seriesId} series is a {seriesType} representing {seriesName}.',
138
+ withoutName: ' The {seriesId} series is a {seriesType}.',
139
+ separator: {
140
+ middle: '',
141
+ end: ''
142
+ }
143
+ }
144
+ },
145
+ data: {
146
+ allData: 'The data is as follows: ',
147
+ partialData: 'The first {displayCnt} items are: ',
148
+ withName: 'the data for {name} is {value}',
149
+ withoutName: '{value}',
150
+ separator: {
151
+ middle: ', ',
152
+ end: '. '
153
+ }
154
+ }
155
+ }
156
+ };
@@ -0,0 +1,156 @@
1
+
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. 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,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ */
20
+
21
+
22
+ /**
23
+ * AUTO-GENERATED FILE. DO NOT MODIFY.
24
+ */
25
+
26
+ /*
27
+ * Licensed to the Apache Software Foundation (ASF) under one
28
+ * or more contributor license agreements. See the NOTICE file
29
+ * distributed with this work for additional information
30
+ * regarding copyright ownership. The ASF licenses this file
31
+ * to you under the Apache License, Version 2.0 (the
32
+ * "License"); you may not use this file except in compliance
33
+ * with the License. You may obtain a copy of the License at
34
+ *
35
+ * http://www.apache.org/licenses/LICENSE-2.0
36
+ *
37
+ * Unless required by applicable law or agreed to in writing,
38
+ * software distributed under the License is distributed on an
39
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
40
+ * KIND, either express or implied. See the License for the
41
+ * specific language governing permissions and limitations
42
+ * under the License.
43
+ */
44
+
45
+ /**
46
+ * Language: Russian.
47
+ */
48
+ export default {
49
+ time: {
50
+ month: ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'],
51
+ monthAbbr: ['Янв', 'Фев', 'Мар', 'Апр', 'Май', 'Июн', 'Июл', 'Авг', 'Сен', 'Окт', 'Ноя', 'Дек'],
52
+ dayOfWeek: ['Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота'],
53
+ dayOfWeekAbbr: ['вс', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб']
54
+ },
55
+ legend: {
56
+ selector: {
57
+ all: 'Всё',
58
+ inverse: 'Обратить'
59
+ }
60
+ },
61
+ toolbox: {
62
+ brush: {
63
+ title: {
64
+ rect: 'Выделить область',
65
+ polygon: 'Инструмент «Лассо»',
66
+ lineX: 'Горизонтальное выделение',
67
+ lineY: 'Вертикальное выделение',
68
+ keep: 'Оставить выбранное',
69
+ clear: 'Очистить выбранное'
70
+ }
71
+ },
72
+ dataView: {
73
+ title: 'Данные',
74
+ lang: ['Данные', 'Закрыть', 'Обновить']
75
+ },
76
+ dataZoom: {
77
+ title: {
78
+ zoom: 'Увеличить',
79
+ back: 'Сбросить увеличение'
80
+ }
81
+ },
82
+ magicType: {
83
+ title: {
84
+ line: 'Линия',
85
+ bar: 'Гистограмма',
86
+ stack: 'Стак',
87
+ tiled: 'Плитка'
88
+ }
89
+ },
90
+ restore: {
91
+ title: 'Восстановить'
92
+ },
93
+ saveAsImage: {
94
+ title: 'Сохранить как картинку',
95
+ lang: ['Правый клик, чтобы сохранить картинку']
96
+ }
97
+ },
98
+ series: {
99
+ typeNames: {
100
+ pie: 'Круговая диаграмма',
101
+ bar: 'Столбчатая диаграмма',
102
+ line: 'Линейный график',
103
+ scatter: 'Точечная диаграмма',
104
+ effectScatter: 'Точечная диаграмма с волнами',
105
+ radar: 'Лепестковая диаграмма',
106
+ tree: 'Дерево',
107
+ treemap: 'Плоское дерево',
108
+ boxplot: 'Ящик с усами',
109
+ candlestick: 'Свечной график',
110
+ k: 'График К-линий',
111
+ heatmap: 'Тепловая карта',
112
+ map: 'Карта',
113
+ parallel: 'Диаграмма параллельных координат',
114
+ lines: 'Линейный граф',
115
+ graph: 'Граф отношений',
116
+ sankey: 'Диаграмма Санкей',
117
+ funnel: 'Воронкообразная диаграмма',
118
+ gauge: 'Шкала',
119
+ pictorialBar: 'Столбец-картинка',
120
+ themeRiver: 'Тематическая река',
121
+ sunburst: 'Солнечные лучи'
122
+ }
123
+ },
124
+ aria: {
125
+ general: {
126
+ withTitle: 'Это график, показывающий "{title}"',
127
+ withoutTitle: 'Это график'
128
+ },
129
+ series: {
130
+ single: {
131
+ prefix: '',
132
+ withName: ' с типом {seriesType} и именем {seriesName}.',
133
+ withoutName: ' с типом {seriesType}.'
134
+ },
135
+ multiple: {
136
+ prefix: '. Он состоит из {seriesCount} серий.',
137
+ withName: ' Серия {seriesId} имеет тип {seriesType} и показывает {seriesName}.',
138
+ withoutName: ' Серия {seriesId} имеет тип {seriesType}.',
139
+ separator: {
140
+ middle: '',
141
+ end: ''
142
+ }
143
+ }
144
+ },
145
+ data: {
146
+ allData: 'Данные таковы: ',
147
+ partialData: 'Первые {displayCnt} элементов: ',
148
+ withName: 'значение для {name} — {value}',
149
+ withoutName: '{value}',
150
+ separator: {
151
+ middle: ', ',
152
+ end: '. '
153
+ }
154
+ }
155
+ }
156
+ };
@@ -0,0 +1,187 @@
1
+ import {Extension} from './extenstion';
2
+
3
+
4
+ export interface ParamLabel {
5
+ dbId: number;
6
+ element: HTMLElement;
7
+ name: string;
8
+ }
9
+
10
+ interface Label {
11
+ label: HTMLLabelElement;
12
+ id: number;
13
+ }
14
+
15
+ export class ParamAssignExtension extends Extension {
16
+
17
+ constructor(viewer, options) {
18
+ super(viewer, options);
19
+ this._group = null;
20
+ this._button = null;
21
+ this._icons = options.icons || [];
22
+ this.options = options;
23
+ }
24
+
25
+ public static extensionName = 'ParamAssignExtension';
26
+
27
+ private static callback: (ext: ParamAssignExtension) => void = null;
28
+ _group: any;
29
+ _button: any;
30
+ _icons: ParamLabel[];
31
+ options: any;
32
+ _enabled = false;
33
+
34
+ _frags: any = {};
35
+
36
+ labels: Label[] = [];
37
+
38
+ container: HTMLDivElement | null = null;
39
+
40
+ public static registerExtension(extensionName: string, callback: (ext: ParamAssignExtension) => void) {
41
+ ParamAssignExtension.callback = callback;
42
+ super.registerExtension(ParamAssignExtension.extensionName, ParamAssignExtension);
43
+ }
44
+
45
+
46
+ public activate() {
47
+ return true;
48
+ }
49
+
50
+ public deactivate() {
51
+ return true;
52
+ }
53
+
54
+ load() {
55
+ this.container = (this.viewer as any).clientContainer;
56
+ this._enabled = true;
57
+ if (this.viewer.model && this.viewer.model.getInstanceTree()) {
58
+ this.customize();
59
+ } else {
60
+ this.viewer.addEventListener(Autodesk.Viewing.OBJECT_TREE_CREATED_EVENT, this.customize.bind(this));
61
+ }
62
+ if (ParamAssignExtension.callback) {
63
+ ParamAssignExtension.callback(this);
64
+ }
65
+ return true;
66
+ }
67
+
68
+ unload() {
69
+ // Clean our UI elements if we added any
70
+ if (this._group) {
71
+ this._group.removeControl(this._button);
72
+ if (this._group.getNumberOfControls() === 0) {
73
+ this.viewer.toolbar.removeControl(this._group);
74
+ }
75
+ }
76
+ return true;
77
+ }
78
+
79
+ customize() {
80
+ this.showIcons();
81
+ const updateIconsCallback = () => {
82
+ this.updateIcons();
83
+ };
84
+ this.viewer.addEventListener(Autodesk.Viewing.CAMERA_CHANGE_EVENT, updateIconsCallback);
85
+ this.viewer.addEventListener(Autodesk.Viewing.ISOLATE_EVENT, updateIconsCallback);
86
+ this.viewer.addEventListener(Autodesk.Viewing.HIDE_EVENT, updateIconsCallback);
87
+ this.viewer.addEventListener(Autodesk.Viewing.SHOW_EVENT, updateIconsCallback);
88
+ }
89
+
90
+
91
+ showIcons() {
92
+ const $viewer: HTMLDivElement = this.container.querySelector('.adsk-viewing-viewer');
93
+ const element = this.container.querySelector('label.markup');
94
+ // remove previous...
95
+ if (element) {
96
+ element.remove();
97
+ }
98
+
99
+ this.labels = [];
100
+
101
+ // do we have anything to show?
102
+ if (this._icons === undefined || this._icons === null) {
103
+ return;
104
+ }
105
+
106
+ // do we have access to the instance tree?
107
+ const tree = this.viewer.model && this.viewer.model.getInstanceTree();
108
+ if (tree === undefined) {
109
+ return;
110
+ }
111
+
112
+ const onClick = (e) => {
113
+ // this.viewer.select($(e.currentTarget).data('id'));
114
+ // this.viewer.utilities.fitToView();
115
+ };
116
+
117
+ this._frags = {};
118
+ for (let i = 0; i < this._icons.length; i++) {
119
+ // we need to collect all the fragIds for a given dbId
120
+ const icon = this._icons[i];
121
+ this._frags['dbId' + icon.dbId] = [];
122
+
123
+
124
+ const $label = document.createElement('label');
125
+ $label.setAttribute('data-id', '' + icon.dbId);
126
+ $label.className = 'markup update';
127
+ $label.style.setProperty('display', this.viewer.isNodeVisible(icon.dbId) ? 'block' : 'none');
128
+ $label.style.setProperty('position', 'absolute');
129
+ $label.style.setProperty('white-space', 'nowrap');
130
+ $label.style.setProperty('cursor', 'pointer');
131
+ $label.style.setProperty('z-index', '1');
132
+ $label.addEventListener('click', this.options.onClick || onClick);
133
+
134
+
135
+ $label.appendChild(icon.element);
136
+ $viewer.appendChild($label);
137
+
138
+
139
+ // now collect the fragIds
140
+ const getChildren = (topParentId, dbId) => {
141
+ if (tree.getChildCount(dbId) === 0) {
142
+ getFrags(topParentId, dbId);
143
+ } // get frags for this leaf child
144
+ tree.enumNodeChildren(dbId, (childId) => {
145
+ getChildren(topParentId, childId);
146
+ });
147
+ };
148
+ const getFrags = (topParentId, dbId) => {
149
+ tree.enumNodeFragments(dbId, (fragId) => {
150
+ this._frags['dbId' + topParentId].push(fragId);
151
+ });
152
+ };
153
+ getChildren(icon.dbId, icon.dbId);
154
+ this.labels.push({id: icon.dbId, label: $label});
155
+ }
156
+ this.updateIcons(); // re-position for each fragId found
157
+ }
158
+
159
+ getModifiedWorldBoundingBox(dbId) {
160
+ const fragList = this.viewer.model.getFragmentList();
161
+ const nodebBox = new THREE.Box3();
162
+
163
+ // for each fragId on the list, get the bounding box
164
+ for (const fragId of this._frags['dbId' + dbId]) {
165
+ const fragbBox = new THREE.Box3();
166
+ fragList.getWorldBounds(fragId, fragbBox);
167
+ nodebBox.union(fragbBox); // create a unifed bounding box
168
+ }
169
+
170
+ return nodebBox;
171
+ }
172
+
173
+ updateIcons() {
174
+
175
+ for (let i = 0; i < this.labels.length; i++) {
176
+ const pos = this.viewer.worldToClient(this.getModifiedWorldBoundingBox(this.labels[i].id).getCenter());
177
+ const label = this.labels[i].label;
178
+
179
+ label.style.setProperty('left', Math.floor(pos.x - label.offsetWidth / 2) + 'px');
180
+ label.style.setProperty('top', Math.floor(pos.y - label.offsetHeight / 2) + 'px');
181
+ label.style.setProperty('display', this.viewer.isNodeVisible(this.labels[i].id) ? 'block' : 'none');
182
+
183
+ }
184
+
185
+ }
186
+ }
187
+
@@ -0,0 +1,86 @@
1
+ import {Injectable} from '@angular/core';
2
+
3
+ declare var document: any;
4
+
5
+ const ScriptStore: any[] = [
6
+ {name: 'viewer', src: 'https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/viewer3D.min.js'},
7
+ ];
8
+ const StyleStore: any[] = [
9
+ {name: 'viewer', src: 'https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/style.min.css'},
10
+ ];
11
+
12
+ let promiseLoad: any = null;
13
+ let isLoadedStyles = false;
14
+
15
+
16
+ @Injectable()
17
+ export class ScriptService {
18
+
19
+ private scripts: any = {};
20
+ private styles: any = {};
21
+
22
+ constructor() {
23
+ ScriptStore.forEach((script: any) => {
24
+ this.scripts[script.name] = {
25
+ loaded: false,
26
+ src: script.src
27
+ };
28
+ });
29
+ }
30
+
31
+ loadStyles() {
32
+
33
+ if (!isLoadedStyles) {
34
+ isLoadedStyles = true;
35
+ StyleStore.forEach(style => {
36
+ const el = document.createElement('link');
37
+ el.rel = 'stylesheet';
38
+ el.href = style.src;
39
+ el.type = 'text/css';
40
+ document.getElementsByTagName('head')[0].appendChild(el);
41
+ });
42
+ }
43
+ }
44
+
45
+ load(...scripts: string[]) {
46
+ if (!promiseLoad) {
47
+ promiseLoad = new Promise((resolve, reject) => {
48
+ const promises: any[] = [];
49
+ scripts.forEach((script) => promises.push(this.loadScript(script)));
50
+ Promise.all(promises).then(data => {
51
+ resolve(data);
52
+ });
53
+ });
54
+ }
55
+ return promiseLoad;
56
+ }
57
+
58
+ loadScript(name: string) {
59
+ return new Promise((resolve, reject) => {
60
+ if (this.scripts[name].loaded) {
61
+ resolve({script: name, loaded: true, status: 'Already Loaded'});
62
+ } else {
63
+ const script = document.createElement('script');
64
+ script.type = 'text/javascript';
65
+ script.src = this.scripts[name].src;
66
+ if (script.readyState) { // IE
67
+ script.onreadystatechange = () => {
68
+ if (script.readyState === 'loaded' || script.readyState === 'complete') {
69
+ script.onreadystatechange = null;
70
+ this.scripts[name].loaded = true;
71
+ resolve({script: name, loaded: true, status: 'Loaded'});
72
+ }
73
+ };
74
+ } else { // Others
75
+ script.onload = () => {
76
+ this.scripts[name].loaded = true;
77
+ resolve({script: name, loaded: true, status: 'Loaded'});
78
+ };
79
+ }
80
+ script.onerror = (error: any) => resolve({script: name, loaded: false, status: 'Loaded'});
81
+ document.getElementsByTagName('head')[0].appendChild(script);
82
+ }
83
+ });
84
+ }
85
+
86
+ }