@smarterplan/ngx-smarterplan-locations 0.2.44 → 0.2.45

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 (152) hide show
  1. package/esm2020/lib/components/carousel/carousel.component.mjs +28 -0
  2. package/esm2020/lib/components/chevron/chevron.component.mjs +18 -0
  3. package/esm2020/lib/components/detail-location/detail-location.component.mjs +168 -0
  4. package/esm2020/lib/components/form-location/form-location.component.mjs +237 -0
  5. package/esm2020/lib/components/images/images.component.mjs +107 -0
  6. package/esm2020/lib/components/locations/locations.component.mjs +145 -0
  7. package/esm2020/lib/components/locations/map/map-popup/map-popup.component.mjs +66 -0
  8. package/esm2020/lib/components/locations/map/map.component.mjs +91 -0
  9. package/esm2020/lib/components/plan-legend/plan-legend.component.mjs +47 -0
  10. package/esm2020/lib/components/plans/calibration/calibration.component.mjs +468 -0
  11. package/esm2020/lib/components/plans/edit-plan/edit-plan.component.mjs +324 -0
  12. package/esm2020/lib/components/plans/plans.component.mjs +225 -0
  13. package/esm2020/lib/components/tab-navigation/tab-navigation.component.mjs +41 -0
  14. package/esm2020/lib/components/visits/visits.component.mjs +283 -0
  15. package/esm2020/lib/components/zones/add-audio-zone/add-audio-zone.component.mjs +230 -0
  16. package/esm2020/lib/components/zones/add-zone/add-zone.component.mjs +315 -0
  17. package/esm2020/lib/components/zones/add-zone/selection/selection.component.mjs +77 -0
  18. package/esm2020/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.mjs +502 -0
  19. package/esm2020/lib/components/zones/zones.component.mjs +268 -0
  20. package/esm2020/lib/helper.service.mjs +134 -0
  21. package/esm2020/lib/ngx-smarterplan-location-routing.module.mjs +49 -0
  22. package/esm2020/lib/ngx-smarterplan-locations.module.mjs +125 -0
  23. package/esm2020/lib/ngx-smarterplan-locations.service.mjs +14 -0
  24. package/esm2020/lib/pipes/count-audio-sweeps.pipe.mjs +27 -0
  25. package/esm2020/lib/radio-button/radio-button.component.mjs +26 -0
  26. package/esm2020/public-api.mjs +9 -0
  27. package/esm2020/smarterplan-ngx-smarterplan-locations.mjs +5 -0
  28. package/fesm2015/smarterplan-ngx-smarterplan-locations.mjs +3991 -0
  29. package/fesm2015/smarterplan-ngx-smarterplan-locations.mjs.map +1 -0
  30. package/fesm2020/smarterplan-ngx-smarterplan-locations.mjs +3828 -0
  31. package/fesm2020/smarterplan-ngx-smarterplan-locations.mjs.map +1 -0
  32. package/lib/components/carousel/carousel.component.d.ts +12 -0
  33. package/lib/components/chevron/chevron.component.d.ts +9 -0
  34. package/lib/components/detail-location/detail-location.component.d.ts +55 -0
  35. package/lib/components/form-location/form-location.component.d.ts +45 -0
  36. package/lib/components/images/images.component.d.ts +33 -0
  37. package/lib/components/locations/locations.component.d.ts +51 -0
  38. package/lib/components/locations/map/map-popup/map-popup.component.d.ts +22 -0
  39. package/lib/components/locations/map/map.component.d.ts +22 -0
  40. package/lib/components/plan-legend/plan-legend.component.d.ts +14 -0
  41. package/lib/components/plans/calibration/calibration.component.d.ts +140 -0
  42. package/lib/components/plans/edit-plan/edit-plan.component.d.ts +55 -0
  43. package/lib/components/plans/plans.component.d.ts +63 -0
  44. package/lib/components/tab-navigation/tab-navigation.component.d.ts +13 -0
  45. package/lib/components/visits/visits.component.d.ts +62 -0
  46. package/lib/components/zones/add-audio-zone/add-audio-zone.component.d.ts +63 -0
  47. package/lib/components/zones/add-zone/add-zone.component.d.ts +69 -0
  48. package/lib/components/zones/add-zone/selection/selection.component.d.ts +44 -0
  49. package/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.d.ts +107 -0
  50. package/lib/components/zones/zones.component.d.ts +73 -0
  51. package/lib/helper.service.d.ts +53 -0
  52. package/lib/ngx-smarterplan-location-routing.module.d.ts +7 -0
  53. package/lib/ngx-smarterplan-locations.module.d.ts +36 -0
  54. package/lib/ngx-smarterplan-locations.service.d.ts +6 -0
  55. package/lib/pipes/count-audio-sweeps.pipe.d.ts +10 -0
  56. package/lib/radio-button/radio-button.component.d.ts +12 -0
  57. package/package.json +22 -5
  58. package/{src/public-api.ts → public-api.d.ts} +4 -11
  59. package/smarterplan-ngx-smarterplan-locations.d.ts +5 -0
  60. package/.browserslistrc +0 -16
  61. package/karma.conf.js +0 -44
  62. package/ng-package.json +0 -7
  63. package/src/lib/components/carousel/carousel.component.html +0 -13
  64. package/src/lib/components/carousel/carousel.component.scss +0 -0
  65. package/src/lib/components/carousel/carousel.component.spec.ts +0 -25
  66. package/src/lib/components/carousel/carousel.component.ts +0 -31
  67. package/src/lib/components/chevron/chevron.component.html +0 -5
  68. package/src/lib/components/chevron/chevron.component.scss +0 -16
  69. package/src/lib/components/chevron/chevron.component.spec.ts +0 -25
  70. package/src/lib/components/chevron/chevron.component.ts +0 -17
  71. package/src/lib/components/detail-location/detail-location.component.html +0 -108
  72. package/src/lib/components/detail-location/detail-location.component.scss +0 -0
  73. package/src/lib/components/detail-location/detail-location.component.spec.ts +0 -25
  74. package/src/lib/components/detail-location/detail-location.component.ts +0 -215
  75. package/src/lib/components/form-location/form-location.component.html +0 -160
  76. package/src/lib/components/form-location/form-location.component.scss +0 -62
  77. package/src/lib/components/form-location/form-location.component.spec.ts +0 -25
  78. package/src/lib/components/form-location/form-location.component.ts +0 -274
  79. package/src/lib/components/images/images.component.html +0 -27
  80. package/src/lib/components/images/images.component.scss +0 -0
  81. package/src/lib/components/images/images.component.spec.ts +0 -25
  82. package/src/lib/components/images/images.component.ts +0 -133
  83. package/src/lib/components/locations/locations.component.html +0 -63
  84. package/src/lib/components/locations/locations.component.scss +0 -121
  85. package/src/lib/components/locations/locations.component.spec.ts +0 -25
  86. package/src/lib/components/locations/locations.component.ts +0 -186
  87. package/src/lib/components/locations/map/map-popup/map-popup.component.html +0 -11
  88. package/src/lib/components/locations/map/map-popup/map-popup.component.scss +0 -51
  89. package/src/lib/components/locations/map/map-popup/map-popup.component.spec.ts +0 -25
  90. package/src/lib/components/locations/map/map-popup/map-popup.component.ts +0 -79
  91. package/src/lib/components/locations/map/map.component.html +0 -2
  92. package/src/lib/components/locations/map/map.component.scss +0 -0
  93. package/src/lib/components/locations/map/map.component.spec.ts +0 -25
  94. package/src/lib/components/locations/map/map.component.ts +0 -111
  95. package/src/lib/components/plan-legend/plan-legend.component.html +0 -9
  96. package/src/lib/components/plan-legend/plan-legend.component.scss +0 -38
  97. package/src/lib/components/plan-legend/plan-legend.component.spec.ts +0 -25
  98. package/src/lib/components/plan-legend/plan-legend.component.ts +0 -50
  99. package/src/lib/components/plans/calibration/calibration.component.html +0 -98
  100. package/src/lib/components/plans/calibration/calibration.component.scss +0 -136
  101. package/src/lib/components/plans/calibration/calibration.component.spec.ts +0 -25
  102. package/src/lib/components/plans/calibration/calibration.component.ts +0 -603
  103. package/src/lib/components/plans/edit-plan/edit-plan.component.html +0 -77
  104. package/src/lib/components/plans/edit-plan/edit-plan.component.scss +0 -9
  105. package/src/lib/components/plans/edit-plan/edit-plan.component.spec.ts +0 -25
  106. package/src/lib/components/plans/edit-plan/edit-plan.component.ts +0 -421
  107. package/src/lib/components/plans/plans.component.html +0 -102
  108. package/src/lib/components/plans/plans.component.scss +0 -24
  109. package/src/lib/components/plans/plans.component.spec.ts +0 -25
  110. package/src/lib/components/plans/plans.component.ts +0 -305
  111. package/src/lib/components/tab-navigation/tab-navigation.component.html +0 -7
  112. package/src/lib/components/tab-navigation/tab-navigation.component.scss +0 -27
  113. package/src/lib/components/tab-navigation/tab-navigation.component.spec.ts +0 -25
  114. package/src/lib/components/tab-navigation/tab-navigation.component.ts +0 -35
  115. package/src/lib/components/visits/visits.component.html +0 -134
  116. package/src/lib/components/visits/visits.component.scss +0 -24
  117. package/src/lib/components/visits/visits.component.spec.ts +0 -25
  118. package/src/lib/components/visits/visits.component.ts +0 -357
  119. package/src/lib/components/zones/add-audio-zone/add-audio-zone.component.html +0 -73
  120. package/src/lib/components/zones/add-audio-zone/add-audio-zone.component.scss +0 -14
  121. package/src/lib/components/zones/add-audio-zone/add-audio-zone.component.spec.ts +0 -25
  122. package/src/lib/components/zones/add-audio-zone/add-audio-zone.component.ts +0 -269
  123. package/src/lib/components/zones/add-zone/add-zone.component.html +0 -153
  124. package/src/lib/components/zones/add-zone/add-zone.component.scss +0 -44
  125. package/src/lib/components/zones/add-zone/add-zone.component.spec.ts +0 -25
  126. package/src/lib/components/zones/add-zone/add-zone.component.ts +0 -377
  127. package/src/lib/components/zones/add-zone/selection/selection.component.html +0 -3
  128. package/src/lib/components/zones/add-zone/selection/selection.component.scss +0 -16
  129. package/src/lib/components/zones/add-zone/selection/selection.component.spec.ts +0 -25
  130. package/src/lib/components/zones/add-zone/selection/selection.component.ts +0 -95
  131. package/src/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.html +0 -73
  132. package/src/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.scss +0 -23
  133. package/src/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.spec.ts +0 -25
  134. package/src/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.ts +0 -595
  135. package/src/lib/components/zones/zones.component.html +0 -181
  136. package/src/lib/components/zones/zones.component.scss +0 -36
  137. package/src/lib/components/zones/zones.component.spec.ts +0 -25
  138. package/src/lib/components/zones/zones.component.ts +0 -339
  139. package/src/lib/helper.service.ts +0 -161
  140. package/src/lib/ngx-smarterplan-location-routing.module.ts +0 -41
  141. package/src/lib/ngx-smarterplan-locations.module.ts +0 -74
  142. package/src/lib/ngx-smarterplan-locations.service.spec.ts +0 -16
  143. package/src/lib/ngx-smarterplan-locations.service.ts +0 -9
  144. package/src/lib/pipes/count-audio-sweeps.pipe.ts +0 -21
  145. package/src/lib/radio-button/radio-button.component.html +0 -9
  146. package/src/lib/radio-button/radio-button.component.scss +0 -152
  147. package/src/lib/radio-button/radio-button.component.spec.ts +0 -25
  148. package/src/lib/radio-button/radio-button.component.ts +0 -26
  149. package/src/test.ts +0 -27
  150. package/tsconfig.lib.json +0 -15
  151. package/tsconfig.lib.prod.json +0 -10
  152. package/tsconfig.spec.json +0 -17
@@ -1,603 +0,0 @@
1
- import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
2
- import { ActivatedRoute, Router } from '@angular/router';
3
- import { TranslateService } from '@ngx-translate/core';
4
- import { getDocument } from 'pdfjs-dist';
5
- import { PDFDocumentProxy } from 'ng2-pdf-viewer';
6
- import {
7
- Zone,
8
- MenuItem,
9
- Plan,
10
- Space,
11
- Navigation,
12
- PlanService,
13
- ZoneService,
14
- SpaceService,
15
- NavigationService,
16
- getMetaForImage,
17
- MatterportImportService,
18
- } from '@smarterplan/ngx-smarterplan-core';
19
- import panzoom from 'panzoom';
20
-
21
- @Component({
22
- selector: 'lib-calibration',
23
- templateUrl: './calibration.component.html',
24
- styleUrls: ['./calibration.component.scss'],
25
- })
26
- export class CalibrationComponent implements OnInit {
27
- /** Item to display for the navbar */
28
- menuItems: MenuItem[] = [];
29
-
30
- /** Canvas (Plan) */
31
- canvas;
32
-
33
- /** CanvasDiv (Div that contain the canvas + matterport iframe) */
34
- @ViewChild('canvasDiv') canvasDiv: ElementRef;
35
-
36
- /** Size of the canvas & matterport iframe */
37
- canvasSize: { w: number; h: number; };
38
-
39
- /** Zoom ratio of the canvas/plan */
40
- canvasZoom = 0;
41
-
42
- /** Opacity for matterport iframe */
43
- opacity: number = 50;
44
-
45
- /** Current rotation for matterport, [0-360], matterport rotation is bind to input range */
46
- rotation: number = 180;
47
-
48
- /** Previous rotation, use to calculate the deltaRotation to rotate, when user change rotation value using range input */
49
- prevRotation: number = 180;
50
-
51
- /** Current Camera Pose */
52
- cameraPose: any;
53
-
54
- /** True when the user is currently rotating with the input range, the matterport rotation events will be ignored */
55
- isRotatingRange: boolean = false;
56
-
57
- /** Rotating queue event to send to matterport */
58
- rotatingQueueEvent: number[] = [];
59
-
60
- /** True when Vertical symmetry is enabled */
61
- reflectV = false;
62
-
63
- /** True when Horizontal symmetry is enabled */
64
- reflectH = false;
65
-
66
- chosenPlan: Plan;
67
-
68
- spaceID: string;
69
-
70
- currentSpace: Space;
71
-
72
- currentZone: Zone;
73
-
74
- chosenPlanIsPdf = false;
75
-
76
- /** First Point in visit, used to determine the calibration */
77
- firstMarkVisit = { x: 0, y: 0 };
78
-
79
- /** Second Point in visit, used to determine the calibration */
80
- secondMarkVisit = { x: 0.5, y: 0.5 };
81
-
82
- /** Equivalent of 'firstMarkVisit' in canvas */
83
- firstMarkPlan: { x: number; y: number; } = { x: 0, y: 0 };
84
-
85
- /** Equivalent of 'secondMarkVisit' in canvas */
86
- secondMarkPlan: { x: number; y: number; } = { x: 0, y: 0 };
87
-
88
- /** Calibration result, (offsetX, offsetY, x, y) */
89
- calibrage: any = {};
90
-
91
- /** Is in preview mode (see scan result) */
92
- preview = false;
93
-
94
- /** Matterport is loading */
95
- loading = true;
96
-
97
- /* for pan and zoom of canvas */
98
- panzoom: any;
99
-
100
- currentNavigations: Navigation[];
101
-
102
- positions: { navID: string; planID: string; x: number; y: number; }[] = [];
103
-
104
- floors: any[] = [];
105
-
106
- currentFloor;
107
-
108
- zoomCanBeChanged: boolean = false;
109
-
110
- constructor(
111
- private matterportImportService: MatterportImportService,
112
- private planService: PlanService,
113
- private route: ActivatedRoute,
114
- private router: Router,
115
- private zoneService: ZoneService,
116
- private spaceService: SpaceService,
117
- private navigationService: NavigationService,
118
- private translate: TranslateService
119
- ) { }
120
-
121
- ngOnDestroy(): void {
122
- if (!this.loading) {
123
- this.matterportImportService.removeFrame();
124
- }
125
- }
126
-
127
- async ngOnInit(): Promise<void> {
128
- this.spaceID = this.route.snapshot.queryParams.spaceID;
129
- this.currentSpace = await this.spaceService.getSpace(this.spaceID);
130
-
131
- /** Menu nav bar */
132
- this.setupMenuItems();
133
-
134
- this.chosenPlan = this.planService.getChosenPlan();
135
-
136
- if (this.chosenPlan) {
137
- this.chosenPlanIsPdf = this.chosenPlan.annexe.includes('pdf');
138
- this.launchViewer();
139
- setTimeout(() => {
140
- this.configureCanvas().then(() => {
141
- this.panzoom = panzoom(this.canvas, {
142
- bounds: true,
143
- boundsPadding: 0,
144
- maxZoom: 2.5,
145
- minZoom: 0.1,
146
- initialZoom: 1,
147
- zoomSpeed: 0.02,
148
- });
149
- });
150
- }, 500);
151
- } else {
152
- this.router.navigate(['/dashboard/localisation', this.spaceID, 'plans']);
153
- }
154
- }
155
-
156
- /** **********************************************************************************************
157
- * MENU NAV BAR
158
- *********************************************************************************************** */
159
- setupMenuItems() {
160
- this.menuItems = [
161
- { label: 'Locations', url: '/localisation' },
162
- {
163
- label: this.currentSpace.name,
164
- url: `/localisation/${this.spaceID}`,
165
- },
166
- {
167
- label: 'Plans',
168
- url: `/localisation/${this.currentSpace.id}/plans`,
169
- },
170
- {
171
- label: 'Calibration',
172
- url: `/localisation/${this.currentSpace.id}/plan-calibration?spaceID=${this.currentSpace.id}`,
173
- },
174
- ];
175
- }
176
-
177
- /** **********************************************************************************************
178
- * CANVAS
179
- *********************************************************************************************** */
180
-
181
- /** Display the plan */
182
- async configureCanvas() {
183
- /** Get canvas */
184
- if (!this.canvas) {
185
- const canvas = document.querySelector('#canvas') as HTMLCanvasElement;
186
- this.canvas = canvas;
187
- }
188
-
189
- if (!this.chosenPlanIsPdf) {
190
- const image = await getMetaForImage(this.chosenPlan.filepath);
191
- /** Compute the new size for the canvas/matterport, base on the dimension of the plan, keeping the ratio */
192
- const size = this.getSizeForCanvas(image.width, image.height);
193
-
194
- /** Compute the plan zoom ratio (use for the calibration later) */
195
- this.canvasZoom = size.w / image.width;
196
-
197
- this.resizeView(size);
198
-
199
- /** Draw Plan on the canvas */
200
- this.drawImage(this.chosenPlan.filepath);
201
- } else {
202
- // TODO
203
- this.pdfToCanvas();
204
- }
205
- }
206
-
207
- /** Update size of the canvas/matterport */
208
- resizeView(size) {
209
- this.canvasDiv.nativeElement.style.width = `${size.w}px`;
210
- this.canvasDiv.nativeElement.style.height = `${size.h}px`;
211
- this.canvas.style.width = `${size.w}px`;
212
- this.canvas.style.height = `${size.h}px`;
213
- this.canvas.width = size.w;
214
- this.canvas.height = size.h;
215
- this.canvasSize = size;
216
- }
217
-
218
- /** Draw something on the canvas */
219
- drawImage(url: string, x = 0, y = 0, icone = false) {
220
- const image = new Image();
221
- const size = this.canvasSize;
222
- const context = this.canvas.getContext('2d');
223
-
224
- /** Flip the context, for symmetry */
225
- // if (this.reflectV) {
226
- // context.translate(size.w, 0);
227
- // context.scale(-1, 1);
228
- // }
229
- // if (this.reflectH) {
230
- // context.translate(0, size.h);
231
- // context.scale(1, -1);
232
- // }
233
-
234
- let imageWidth = size.w;
235
- let imageHeight = size.h;
236
- image.addEventListener('load', () => {
237
- if (icone) {
238
- imageWidth = image.width;
239
- imageHeight = image.height;
240
- }
241
- context.drawImage(
242
- image,
243
- 0,
244
- 0,
245
- image.width,
246
- image.height,
247
- x,
248
- y,
249
- imageWidth,
250
- imageHeight
251
- );
252
- });
253
- image.src = url;
254
- }
255
-
256
- /** Get the size for the canvas, based on the plan size, keeping the ratio */
257
- getSizeForCanvas(w, h) {
258
- let canvasW = this.canvasDiv.nativeElement.offsetWidth;
259
- let canvasH = this.canvasDiv.nativeElement.offsetHeight;
260
-
261
- const imageRatio = w / h;
262
- const canvasRatio = canvasW / canvasH;
263
-
264
- if (imageRatio > canvasRatio) {
265
- canvasH = canvasW / imageRatio;
266
- } else {
267
- canvasW = canvasH * imageRatio;
268
- }
269
- return { w: canvasW, h: canvasH };
270
- }
271
-
272
- /** [TODO] Convert a PDF to a Canvas */
273
- async pdfToCanvas() {
274
- const pdfjs = await import('pdfjs-dist/build/pdf');
275
- const pdfjsWorker = await import('pdfjs-dist/build/pdf.worker.entry');
276
-
277
- pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
278
-
279
- const pdf: PDFDocumentProxy = await getDocument(this.chosenPlan.filepath)
280
- .promise;
281
- const page = await pdf.getPage(1);
282
-
283
- const viewPortParameters = { scale: 1 };
284
- const viewport = page.getViewport(viewPortParameters);
285
-
286
- this.canvas.height = viewport.height;
287
- this.canvas.width = viewport.width;
288
-
289
- const size = this.getSizeForCanvas(viewport.width, viewport.height);
290
- console.log(size);
291
- this.canvasSize = size;
292
-
293
- this.canvasZoom = size.w / viewport.width;
294
-
295
- const context = this.canvas.getContext('2d') as CanvasRenderingContext2D;
296
- const renderContext = {
297
- canvasContext: context,
298
- viewport,
299
- };
300
- const renderTask = page.render(renderContext).promise;
301
-
302
- renderTask.then(() => console.log('Page rendered'));
303
-
304
- // const res = canvas.toDataURL();
305
- // if (pdf != null) pdf.destroy();
306
- // return res;
307
- }
308
-
309
- /** User click to user Symmetry Vertical */
310
- onReflectV() {
311
- this.reflectV = !this.reflectV;
312
- this.configureCanvas();
313
- }
314
-
315
- /** User click to user Symmetry Horizontal */
316
- onReflectH() {
317
- this.reflectH = !this.reflectH;
318
- this.configureCanvas();
319
- }
320
-
321
- /** **********************************************************************************************
322
- * MATTERPORT
323
- *********************************************************************************************** */
324
-
325
- /** Launch matterport */
326
- async launchViewer() {
327
- await this.matterportImportService.initSdkForModel(this.chosenPlan.model3d);
328
-
329
- const { sdk } = this.matterportImportService;
330
- this.floors = Object.values(this.matterportImportService.floors);
331
- // console.log(this.floors);
332
- setTimeout(async () => {
333
- /** Move Floor mode */
334
- sdk.Mode.moveTo(sdk.Mode.Mode.FLOORPLAN).then(async (nextMode) => {
335
- /** Display the correct floor for the plan */
336
- try {
337
- const matterportFloor = this.chosenPlan.zone.metadata ?
338
- JSON.parse(this.chosenPlan.zone.metadata).matterportFloorSequence : null;
339
- await this.matterportImportService.moveToFloor(this.chosenPlan.zone.name, matterportFloor);
340
-
341
- /** When the user try to change the view mode we set it back to floorpan */
342
- sdk.on(sdk.Mode.Event.CHANGE_END, (oldMode, newMode) => {
343
- if (newMode !== sdk.Mode.Mode.FLOORPLAN) {
344
- sdk.Mode.moveTo(sdk.Mode.Mode.FLOORPLAN, {
345
- transition: 'transition.instant',
346
- });
347
- }
348
- });
349
- } catch {
350
- console.log('couldnot move to floor');
351
- }
352
- });
353
-
354
- /** We can display the matterport view now */
355
- this.loading = false;
356
- }, 1000);
357
-
358
- /** Update current camera pose and rotation */
359
- sdk.Camera.pose.subscribe((event) => {
360
- /** We update only if the user is not changing the rotation with the <input> range, to not override the <input> value */
361
- if (!this.isRotatingRange) {
362
- this.rotation = event.rotation.y + 180;
363
- this.prevRotation = this.rotation;
364
- this.cameraPose = event;
365
- }
366
- });
367
- }
368
-
369
- /** When the <input> range, for rotation, change */
370
- async onRotationChange() {
371
- const rotationDelta = this.rotation - this.prevRotation;
372
- this.prevRotation = this.rotation;
373
-
374
- /** Send the rotationDelta to th queue event in order to be send to matterport */
375
- this.rotatingQueueEvent.push(rotationDelta);
376
-
377
- /** Start to process the queue, if it's the first event */
378
- if (!this.isRotatingRange) {
379
- this.isRotatingRange = true;
380
- this.processRotatingQueueEvent();
381
- }
382
- }
383
-
384
- /** Process the rotating event queue, send event one by one to matterport */
385
- async processRotatingQueueEvent() {
386
- const { sdk } = this.matterportImportService;
387
-
388
- /** While the queue is not empty */
389
- while (this.rotatingQueueEvent.length > 0) {
390
- /** Rotate matterport by deltaRotation and remove event from queue */
391
- await sdk.Camera.rotate(this.rotatingQueueEvent.shift(), 0, {
392
- speed: 360,
393
- });
394
- }
395
-
396
- /** When the queue is empty, then the user is not rotating with the <input> range anymore */
397
- this.isRotatingRange = false;
398
- }
399
-
400
- /** **********************************************************************************************
401
- * USER ACTIONS
402
- *********************************************************************************************** */
403
-
404
- /** Preview calibration */
405
- async onPreview() {
406
- this.preview = true;
407
- /** Place sweeps */
408
- this.onPlaceSweeps();
409
- }
410
-
411
- async calibrate() {
412
- const [navigation] = this.currentNavigations;
413
- const position = JSON.parse(navigation.position);
414
- this.firstMarkPlan =
415
- await this.matterportImportService.sdk.Renderer.getScreenPosition({
416
- x: position.x,
417
- y: position.y,
418
- z: position.z,
419
- });
420
- this.secondMarkPlan =
421
- await this.matterportImportService.sdk.Renderer.getScreenPosition({
422
- x: position.x,
423
- y: 0,
424
- z: 0,
425
- });
426
- const deltaZVisit = 0 - position.z;
427
- let deltaXPlan = this.secondMarkPlan.x - this.firstMarkPlan.x;
428
- if (deltaXPlan === 0) {
429
- // console.log("we moved along Y axis on Plan");
430
- const deltaYPlan = this.secondMarkPlan.y - this.firstMarkPlan.y;
431
- this.calibrage.nameYAxis = 'z';
432
- this.calibrage.nameXAxis = 'x';
433
- this.calibrage.offsetY = this.secondMarkPlan.y;
434
- this.calibrage.scaleY = deltaYPlan / deltaZVisit;
435
- } else {
436
- // console.log(" we moved along X axis on Plan");
437
- this.calibrage.nameYAxis = 'x';
438
- this.calibrage.nameXAxis = 'z';
439
- this.calibrage.offsetX = this.secondMarkPlan.x;
440
- this.calibrage.scaleX = deltaXPlan / deltaZVisit;
441
- }
442
- const thirdMarkPlan =
443
- await this.matterportImportService.sdk.Renderer.getScreenPosition({
444
- x: 0,
445
- y: 0,
446
- z: position.z,
447
- });
448
- const deltaXVisit = 0 - position.x;
449
- if (deltaXPlan === 0) {
450
- // console.log(" we moved along X axis on Plan");
451
- deltaXPlan = thirdMarkPlan.x - this.firstMarkPlan.x;
452
- this.calibrage.offsetX = thirdMarkPlan.x;
453
- this.calibrage.scaleX = deltaXPlan / deltaXVisit;
454
- } else {
455
- const deltaYPlan = thirdMarkPlan.y - this.firstMarkPlan.y;
456
- this.calibrage.offsetY = thirdMarkPlan.y;
457
- this.calibrage.scaleY = deltaYPlan / deltaXVisit;
458
- }
459
-
460
- /** Take considiration of pan and zoom of plan on canvas */
461
- const transformInfo = this.panzoom.getTransform();
462
- const { scale, x, y } = transformInfo;
463
- // console.log(transformInfo);
464
- this.calibrage.offsetXPlan = x;
465
- this.calibrage.offsetYPlan = y;
466
- this.calibrage.scalePlan = scale;
467
- console.log(this.calibrage);
468
- }
469
-
470
- /** Place sweeps */
471
- async onPlaceSweeps() {
472
- /** Display all scan */
473
- const zone = await this.zoneService.getZone(this.chosenPlan.zoneID);
474
-
475
- if (zone) {
476
- this.currentZone = zone;
477
- const navigations = await this.navigationService.getNavigationsForZone(
478
- this.currentZone
479
- );
480
- this.currentNavigations = navigations;
481
- await this.calibrate();
482
- if (navigations.length > 0) {
483
- for (const navigation of navigations) {
484
- const testPosition = JSON.parse(navigation.position);
485
- const positionX =
486
- this.calibrage.nameXAxis === 'x' ? testPosition.x : testPosition.z;
487
- const positionY =
488
- this.calibrage.nameYAxis === 'x' ? testPosition.x : testPosition.z;
489
- const testX =
490
- positionX * this.calibrage.scaleX + this.calibrage.offsetX;
491
- const testY =
492
- positionY * this.calibrage.scaleY + this.calibrage.offsetY;
493
- // console.log("test position GREEN", testX, testY);
494
- const transformedX =
495
- (testX - this.calibrage.offsetXPlan) / this.calibrage.scalePlan; // we are undoing the pan and zoom
496
- const transformedY =
497
- (testY - this.calibrage.offsetYPlan) / this.calibrage.scalePlan;
498
- this.positions.push({
499
- navID: navigation.id,
500
- planID: this.chosenPlan.id,
501
- x: transformedX,
502
- y: transformedY,
503
- });
504
- const iconSize = 30 * this.calibrage.scalePlan;
505
- const shift = iconSize / 2;
506
- this.drawImage(
507
- 'https://api.iconify.design/mdi:adjust.svg?color=green&height=30&width=30',
508
- transformedX - shift,
509
- transformedY - shift,
510
- true
511
- );
512
- }
513
- }
514
- }
515
- }
516
-
517
- /** Save calibration */
518
- async onSave() {
519
- if (this.currentZone) {
520
- /** Normalize with the zoom */
521
- // this.calibrage.offsetX /= this.canvasZoom;
522
- // this.calibrage.offsetY /= this.canvasZoom;
523
- // this.calibrage.x /= this.canvasZoom;
524
- // this.calibrage.y /= this.canvasZoom;
525
- this.calibrage.new = true;
526
- this.calibrage.imgWidth = this.canvasSize.w;
527
- this.calibrage.imgHeight = this.canvasSize.h;
528
-
529
- await this.planService.updatePlan({
530
- id: this.chosenPlan.id,
531
- calibration: JSON.stringify(this.calibrage),
532
- });
533
- await Promise.all(
534
- this.positions.map(async (position) => {
535
- const { navID } = position;
536
- delete position.navID;
537
- const nav = this.currentNavigations.find((_nav) => _nav.id === navID);
538
- let positionsDataToUpdate;
539
- if (nav.positionOnPlan) {
540
- const positionOnPlan = nav.positionOnPlan.map((entry) =>
541
- JSON.parse(entry)
542
- );
543
- const positionForCurrentPlan = positionOnPlan.find(
544
- (entry) => entry.planID === this.chosenPlan.id
545
- );
546
- if (positionForCurrentPlan) {
547
- positionOnPlan.splice(
548
- positionOnPlan.indexOf(positionForCurrentPlan),
549
- 1,
550
- position
551
- );
552
- } else {
553
- positionOnPlan.push(position);
554
- }
555
- positionsDataToUpdate = [...positionOnPlan];
556
- } else {
557
- positionsDataToUpdate = [position];
558
- }
559
- // console.log(positionsDataToUpdate);
560
- await this.navigationService.updateNavigation({
561
- id: navID,
562
- positionOnPlan: positionsDataToUpdate.map((entry) =>
563
- JSON.stringify(entry)
564
- ),
565
- });
566
- })
567
- );
568
- }
569
- this.matterportImportService.removeFrame();
570
-
571
- this.router.navigate(['/dashboard/localisation', this.spaceID, 'plans']);
572
- alert(this.translate.instant('calibration.success'));
573
- }
574
-
575
- /** Reset the canvas */
576
- onReset() {
577
- this.reflectH = false;
578
- this.reflectV = false;
579
- this.preview = false;
580
-
581
- this.configureCanvas();
582
- }
583
-
584
- /** Cancel, leave */
585
- onCancel() {
586
- this.matterportImportService.removeFrame();
587
- this.router.navigate(['/dashboard/localisation', this.spaceID, 'plans']);
588
- alert(this.translate.instant('calibration.canceled'));
589
- }
590
-
591
- async onFloorClick(floor) {
592
- this.currentFloor = floor;
593
- await this.matterportImportService.moveToFloor(floor.id);
594
- }
595
-
596
- onActivateZoomChange() {
597
- this.zoomCanBeChanged = !this.zoomCanBeChanged;
598
- const iframe = document.querySelector('#viewer-frame') as HTMLElement;
599
- if (iframe) {
600
- iframe.style.zIndex = this.zoomCanBeChanged ? '1' : '0';
601
- }
602
- }
603
- }
@@ -1,77 +0,0 @@
1
- <div class="row mt-3">
2
- <div class="col">
3
- <div class="m-3">
4
- <lib-tab-navigation [menuItems]='menuItems'></lib-tab-navigation>
5
- </div>
6
- </div>
7
- </div>
8
- <lib-add-zone *ngIf="isNewZone" [images360]="images360" [spaceID]="spaceID" [navigationIDs]="navigations"
9
- [zoneEdit]="editedZone" [zones]="zones" (updatedZone)="onNewZone($event)" [chosenPlan]="editedPlan"
10
- [newZoneDataFromEditor]="newZoneData"></lib-add-zone>
11
- <iframe *ngIf="editorUrl" #svgEditor [src]="editorUrl | safeUrl" frameborder="0"
12
- style="height:100%;width:100%;min-height:550px;max-height:750px" (load)="onLoad(svgEditor)"></iframe>
13
- <!-- chosenPlan && -->
14
- <!-- ./../../../../../../assets/svgeditor/index.html -->
15
-
16
- <img #imgPng *ngIf="chosenPlan && chosenPlan.extension !== 'svg' && svgEditor" [src]="chosenPlan.filepath"
17
- (load)="onLoadImg(imgPng)" style="display: none;">
18
-
19
- <canvas id="canvas4pdf" style="display: none;"></canvas>
20
-
21
- <ng-template #dialog let-modal>
22
-
23
- <div class="modal-header">
24
- <h4 class="modal-title">{{'Submit' | translate}}</h4>
25
- <button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')">
26
- <span aria-hidden="true">&times;</span>
27
- </button>
28
- </div>
29
- <div class="modal-body">
30
- {{'save plan edited' | translate}}
31
- </div>
32
- <div class="modal-footer">
33
- <button type="button" class="btn btn-outline-dark" (click)="newSvg();modal.close('Close click')">{{'Yes' |
34
- translate}}</button>
35
- <button type="button" class="btn btn-outline-dark" (click)="updateSvg();modal.close('Close click')">{{'No' |
36
- translate}}</button>
37
- </div>
38
-
39
- </ng-template>
40
-
41
- <ng-template #dialogZone let-modal>
42
-
43
- <div class="modal-header">
44
- <h4 class="modal-title">{{'Submit' | translate}}</h4>
45
- <button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')">
46
- <span aria-hidden="true">&times;</span>
47
- </button>
48
- </div>
49
- <div class="modal-body">
50
- {{'confirm.new-zone-from-plan' | translate}}
51
- </div>
52
- <div class="modal-footer">
53
- <button type="button" class="btn btn-outline-dark"
54
- (click)="isNewZone = true;modal.close('Close click')">{{'Validate' |
55
- translate}}</button>
56
- <button type="button" class="btn btn-outline-dark" (click)="modal.close('Close click')">{{'Cancel' |
57
- translate}}</button>
58
- </div>
59
-
60
- </ng-template>
61
-
62
- <ng-template #preparing let-modal>
63
- <div class="modal-header">
64
- <h4 class="modal-title">{{'Processing' | translate}}</h4>
65
- <button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')">
66
- <span aria-hidden="true">&times;</span>
67
- </button>
68
- </div>
69
- <div class="modal-body">
70
- <div class="d-flex justify-content-center">
71
- <div class="spinner-border" role="status">
72
- <span class="visually-hidden">Loading...</span>
73
- </div>
74
- </div>
75
- </div>
76
-
77
- </ng-template>
@@ -1,9 +0,0 @@
1
- app-add-zone {
2
- position: absolute;
3
- top: 0;
4
- left: 0;
5
- background-color: white;
6
- width: 100%;
7
- height: 100%;
8
- padding: 30px;
9
- }