@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.
- package/esm2020/lib/components/carousel/carousel.component.mjs +28 -0
- package/esm2020/lib/components/chevron/chevron.component.mjs +18 -0
- package/esm2020/lib/components/detail-location/detail-location.component.mjs +168 -0
- package/esm2020/lib/components/form-location/form-location.component.mjs +237 -0
- package/esm2020/lib/components/images/images.component.mjs +107 -0
- package/esm2020/lib/components/locations/locations.component.mjs +145 -0
- package/esm2020/lib/components/locations/map/map-popup/map-popup.component.mjs +66 -0
- package/esm2020/lib/components/locations/map/map.component.mjs +91 -0
- package/esm2020/lib/components/plan-legend/plan-legend.component.mjs +47 -0
- package/esm2020/lib/components/plans/calibration/calibration.component.mjs +468 -0
- package/esm2020/lib/components/plans/edit-plan/edit-plan.component.mjs +324 -0
- package/esm2020/lib/components/plans/plans.component.mjs +225 -0
- package/esm2020/lib/components/tab-navigation/tab-navigation.component.mjs +41 -0
- package/esm2020/lib/components/visits/visits.component.mjs +283 -0
- package/esm2020/lib/components/zones/add-audio-zone/add-audio-zone.component.mjs +230 -0
- package/esm2020/lib/components/zones/add-zone/add-zone.component.mjs +315 -0
- package/esm2020/lib/components/zones/add-zone/selection/selection.component.mjs +77 -0
- package/esm2020/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.mjs +502 -0
- package/esm2020/lib/components/zones/zones.component.mjs +268 -0
- package/esm2020/lib/helper.service.mjs +134 -0
- package/esm2020/lib/ngx-smarterplan-location-routing.module.mjs +49 -0
- package/esm2020/lib/ngx-smarterplan-locations.module.mjs +125 -0
- package/esm2020/lib/ngx-smarterplan-locations.service.mjs +14 -0
- package/esm2020/lib/pipes/count-audio-sweeps.pipe.mjs +27 -0
- package/esm2020/lib/radio-button/radio-button.component.mjs +26 -0
- package/esm2020/public-api.mjs +9 -0
- package/esm2020/smarterplan-ngx-smarterplan-locations.mjs +5 -0
- package/fesm2015/smarterplan-ngx-smarterplan-locations.mjs +3991 -0
- package/fesm2015/smarterplan-ngx-smarterplan-locations.mjs.map +1 -0
- package/fesm2020/smarterplan-ngx-smarterplan-locations.mjs +3828 -0
- package/fesm2020/smarterplan-ngx-smarterplan-locations.mjs.map +1 -0
- package/lib/components/carousel/carousel.component.d.ts +12 -0
- package/lib/components/chevron/chevron.component.d.ts +9 -0
- package/lib/components/detail-location/detail-location.component.d.ts +55 -0
- package/lib/components/form-location/form-location.component.d.ts +45 -0
- package/lib/components/images/images.component.d.ts +33 -0
- package/lib/components/locations/locations.component.d.ts +51 -0
- package/lib/components/locations/map/map-popup/map-popup.component.d.ts +22 -0
- package/lib/components/locations/map/map.component.d.ts +22 -0
- package/lib/components/plan-legend/plan-legend.component.d.ts +14 -0
- package/lib/components/plans/calibration/calibration.component.d.ts +140 -0
- package/lib/components/plans/edit-plan/edit-plan.component.d.ts +55 -0
- package/lib/components/plans/plans.component.d.ts +63 -0
- package/lib/components/tab-navigation/tab-navigation.component.d.ts +13 -0
- package/lib/components/visits/visits.component.d.ts +62 -0
- package/lib/components/zones/add-audio-zone/add-audio-zone.component.d.ts +63 -0
- package/lib/components/zones/add-zone/add-zone.component.d.ts +69 -0
- package/lib/components/zones/add-zone/selection/selection.component.d.ts +44 -0
- package/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.d.ts +107 -0
- package/lib/components/zones/zones.component.d.ts +73 -0
- package/lib/helper.service.d.ts +53 -0
- package/lib/ngx-smarterplan-location-routing.module.d.ts +7 -0
- package/lib/ngx-smarterplan-locations.module.d.ts +36 -0
- package/lib/ngx-smarterplan-locations.service.d.ts +6 -0
- package/lib/pipes/count-audio-sweeps.pipe.d.ts +10 -0
- package/lib/radio-button/radio-button.component.d.ts +12 -0
- package/package.json +22 -5
- package/{src/public-api.ts → public-api.d.ts} +4 -11
- package/smarterplan-ngx-smarterplan-locations.d.ts +5 -0
- package/.browserslistrc +0 -16
- package/karma.conf.js +0 -44
- package/ng-package.json +0 -7
- package/src/lib/components/carousel/carousel.component.html +0 -13
- package/src/lib/components/carousel/carousel.component.scss +0 -0
- package/src/lib/components/carousel/carousel.component.spec.ts +0 -25
- package/src/lib/components/carousel/carousel.component.ts +0 -31
- package/src/lib/components/chevron/chevron.component.html +0 -5
- package/src/lib/components/chevron/chevron.component.scss +0 -16
- package/src/lib/components/chevron/chevron.component.spec.ts +0 -25
- package/src/lib/components/chevron/chevron.component.ts +0 -17
- package/src/lib/components/detail-location/detail-location.component.html +0 -108
- package/src/lib/components/detail-location/detail-location.component.scss +0 -0
- package/src/lib/components/detail-location/detail-location.component.spec.ts +0 -25
- package/src/lib/components/detail-location/detail-location.component.ts +0 -215
- package/src/lib/components/form-location/form-location.component.html +0 -160
- package/src/lib/components/form-location/form-location.component.scss +0 -62
- package/src/lib/components/form-location/form-location.component.spec.ts +0 -25
- package/src/lib/components/form-location/form-location.component.ts +0 -274
- package/src/lib/components/images/images.component.html +0 -27
- package/src/lib/components/images/images.component.scss +0 -0
- package/src/lib/components/images/images.component.spec.ts +0 -25
- package/src/lib/components/images/images.component.ts +0 -133
- package/src/lib/components/locations/locations.component.html +0 -63
- package/src/lib/components/locations/locations.component.scss +0 -121
- package/src/lib/components/locations/locations.component.spec.ts +0 -25
- package/src/lib/components/locations/locations.component.ts +0 -186
- package/src/lib/components/locations/map/map-popup/map-popup.component.html +0 -11
- package/src/lib/components/locations/map/map-popup/map-popup.component.scss +0 -51
- package/src/lib/components/locations/map/map-popup/map-popup.component.spec.ts +0 -25
- package/src/lib/components/locations/map/map-popup/map-popup.component.ts +0 -79
- package/src/lib/components/locations/map/map.component.html +0 -2
- package/src/lib/components/locations/map/map.component.scss +0 -0
- package/src/lib/components/locations/map/map.component.spec.ts +0 -25
- package/src/lib/components/locations/map/map.component.ts +0 -111
- package/src/lib/components/plan-legend/plan-legend.component.html +0 -9
- package/src/lib/components/plan-legend/plan-legend.component.scss +0 -38
- package/src/lib/components/plan-legend/plan-legend.component.spec.ts +0 -25
- package/src/lib/components/plan-legend/plan-legend.component.ts +0 -50
- package/src/lib/components/plans/calibration/calibration.component.html +0 -98
- package/src/lib/components/plans/calibration/calibration.component.scss +0 -136
- package/src/lib/components/plans/calibration/calibration.component.spec.ts +0 -25
- package/src/lib/components/plans/calibration/calibration.component.ts +0 -603
- package/src/lib/components/plans/edit-plan/edit-plan.component.html +0 -77
- package/src/lib/components/plans/edit-plan/edit-plan.component.scss +0 -9
- package/src/lib/components/plans/edit-plan/edit-plan.component.spec.ts +0 -25
- package/src/lib/components/plans/edit-plan/edit-plan.component.ts +0 -421
- package/src/lib/components/plans/plans.component.html +0 -102
- package/src/lib/components/plans/plans.component.scss +0 -24
- package/src/lib/components/plans/plans.component.spec.ts +0 -25
- package/src/lib/components/plans/plans.component.ts +0 -305
- package/src/lib/components/tab-navigation/tab-navigation.component.html +0 -7
- package/src/lib/components/tab-navigation/tab-navigation.component.scss +0 -27
- package/src/lib/components/tab-navigation/tab-navigation.component.spec.ts +0 -25
- package/src/lib/components/tab-navigation/tab-navigation.component.ts +0 -35
- package/src/lib/components/visits/visits.component.html +0 -134
- package/src/lib/components/visits/visits.component.scss +0 -24
- package/src/lib/components/visits/visits.component.spec.ts +0 -25
- package/src/lib/components/visits/visits.component.ts +0 -357
- package/src/lib/components/zones/add-audio-zone/add-audio-zone.component.html +0 -73
- package/src/lib/components/zones/add-audio-zone/add-audio-zone.component.scss +0 -14
- package/src/lib/components/zones/add-audio-zone/add-audio-zone.component.spec.ts +0 -25
- package/src/lib/components/zones/add-audio-zone/add-audio-zone.component.ts +0 -269
- package/src/lib/components/zones/add-zone/add-zone.component.html +0 -153
- package/src/lib/components/zones/add-zone/add-zone.component.scss +0 -44
- package/src/lib/components/zones/add-zone/add-zone.component.spec.ts +0 -25
- package/src/lib/components/zones/add-zone/add-zone.component.ts +0 -377
- package/src/lib/components/zones/add-zone/selection/selection.component.html +0 -3
- package/src/lib/components/zones/add-zone/selection/selection.component.scss +0 -16
- package/src/lib/components/zones/add-zone/selection/selection.component.spec.ts +0 -25
- package/src/lib/components/zones/add-zone/selection/selection.component.ts +0 -95
- package/src/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.html +0 -73
- package/src/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.scss +0 -23
- package/src/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.spec.ts +0 -25
- package/src/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.ts +0 -595
- package/src/lib/components/zones/zones.component.html +0 -181
- package/src/lib/components/zones/zones.component.scss +0 -36
- package/src/lib/components/zones/zones.component.spec.ts +0 -25
- package/src/lib/components/zones/zones.component.ts +0 -339
- package/src/lib/helper.service.ts +0 -161
- package/src/lib/ngx-smarterplan-location-routing.module.ts +0 -41
- package/src/lib/ngx-smarterplan-locations.module.ts +0 -74
- package/src/lib/ngx-smarterplan-locations.service.spec.ts +0 -16
- package/src/lib/ngx-smarterplan-locations.service.ts +0 -9
- package/src/lib/pipes/count-audio-sweeps.pipe.ts +0 -21
- package/src/lib/radio-button/radio-button.component.html +0 -9
- package/src/lib/radio-button/radio-button.component.scss +0 -152
- package/src/lib/radio-button/radio-button.component.spec.ts +0 -25
- package/src/lib/radio-button/radio-button.component.ts +0 -26
- package/src/test.ts +0 -27
- package/tsconfig.lib.json +0 -15
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -17
package/src/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.ts
DELETED
|
@@ -1,595 +0,0 @@
|
|
|
1
|
-
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
|
2
|
-
import { TranslateService } from '@ngx-translate/core';
|
|
3
|
-
import { getCoefficientsForImage, getMetaForImage, Navigation, NavigationService, Plan, Zone, showScanPointsOnPlanInDiv, ZoneService, PlanService } from '@smarterplan/ngx-smarterplan-core';
|
|
4
|
-
import panzoom, { PanZoom } from 'panzoom';
|
|
5
|
-
import { buttonIsInSelection, isInPolygon, Rectangle, rotate, setVisuallySelected, styleButton, SweepState } from '../../../../helper.service';
|
|
6
|
-
|
|
7
|
-
@Component({
|
|
8
|
-
selector: 'lib-sweep-plan-selection',
|
|
9
|
-
templateUrl: './sweep-plan-selection.component.html',
|
|
10
|
-
styleUrls: ['./sweep-plan-selection.component.scss']
|
|
11
|
-
})
|
|
12
|
-
export class SweepPlanSelectionComponent implements OnInit {
|
|
13
|
-
|
|
14
|
-
plans: Plan[];
|
|
15
|
-
|
|
16
|
-
@Input() spaceID: string;
|
|
17
|
-
|
|
18
|
-
@Input() chosenScansOnPlan: string[] = [];
|
|
19
|
-
|
|
20
|
-
/** if comming from Edit Plan SVG Zone creation */
|
|
21
|
-
@Input() newZoneData: any;
|
|
22
|
-
|
|
23
|
-
navIDsZoneEdit: string[] = [];
|
|
24
|
-
|
|
25
|
-
// sweeps belonging to any audio zone
|
|
26
|
-
@Input() occupiedSweeps: string[] = [];
|
|
27
|
-
|
|
28
|
-
// sweeps unavailable (cannot be chosen)
|
|
29
|
-
@Input() unavailableSweeps: string[] = [];
|
|
30
|
-
|
|
31
|
-
// if choosing sweeps for audio zone
|
|
32
|
-
@Input() editingAudioZone: boolean = false;
|
|
33
|
-
|
|
34
|
-
@Input() inputZone: Zone;
|
|
35
|
-
|
|
36
|
-
@Input() multipleFloors: boolean = false;
|
|
37
|
-
|
|
38
|
-
chosenPlan: Plan;
|
|
39
|
-
|
|
40
|
-
/** panZoom element for adding scans */
|
|
41
|
-
panZoom: PanZoom;
|
|
42
|
-
|
|
43
|
-
/** divPlan (use By panZoom) */
|
|
44
|
-
divPlan: HTMLElement;
|
|
45
|
-
|
|
46
|
-
/** all scan buttons Element */
|
|
47
|
-
buttonElements: HTMLButtonElement[] = [];
|
|
48
|
-
|
|
49
|
-
/** Scan buttons that are in the current selection */
|
|
50
|
-
buttonsInSelection: HTMLButtonElement[] = [];
|
|
51
|
-
|
|
52
|
-
@Output() sweepsSelected = new EventEmitter<{ sweeps: string[]; startSweepID: string; }>();
|
|
53
|
-
|
|
54
|
-
isSettingStartSweep = false;
|
|
55
|
-
|
|
56
|
-
startSweepID: string;
|
|
57
|
-
|
|
58
|
-
chosenSweepsPerFloor = new Map<string, string[]>(); // map matching floorID to sweeps selected
|
|
59
|
-
|
|
60
|
-
inputSweepsPerFloor = new Map<string, string[]>(); // map matching floorID to sweeps selected for zone in edition
|
|
61
|
-
|
|
62
|
-
selectionChanged = false;
|
|
63
|
-
|
|
64
|
-
constructor(
|
|
65
|
-
private zoneService: ZoneService,
|
|
66
|
-
private navigationService: NavigationService,
|
|
67
|
-
private planService: PlanService,
|
|
68
|
-
private translate: TranslateService,
|
|
69
|
-
) { }
|
|
70
|
-
|
|
71
|
-
async ngOnInit() {
|
|
72
|
-
await this.getPlans();
|
|
73
|
-
this.setSweepsOfInputZone();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
ngOnChanges() {
|
|
77
|
-
if (this.chosenPlan) {
|
|
78
|
-
this.setSweepsOfInputZone();
|
|
79
|
-
this.chosenScansOnPlan = [];
|
|
80
|
-
this.clearDivPlan();
|
|
81
|
-
this.addScanPoints();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
setSweepsOfInputZone() {
|
|
86
|
-
this.navIDsZoneEdit = this.inputZone ? this.inputZone.sweepIDs : [];
|
|
87
|
-
if (this.multipleFloors) {
|
|
88
|
-
this.plans.forEach((plan) => {
|
|
89
|
-
if (!this.inputSweepsPerFloor.get(plan.zoneID)) {
|
|
90
|
-
this.inputSweepsPerFloor.set(plan.zoneID,
|
|
91
|
-
this.navIDsZoneEdit.filter((sweep) => plan.zone.sweepIDs.includes(sweep)));
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
} else {
|
|
95
|
-
if (this.inputZone) {
|
|
96
|
-
//filter plans only for the parent Zone
|
|
97
|
-
this.plans = this.plans.filter((p) => p.zoneID === this.inputZone.parentID);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
async getPlans() {
|
|
103
|
-
this.plans = await this.planService.getSingedPlansForSpace(
|
|
104
|
-
this.spaceID,
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async onPlanClick(plan: Plan) {
|
|
109
|
-
const switchPlan = () => {
|
|
110
|
-
this.selectionChanged = false;
|
|
111
|
-
this.chosenPlan = plan;
|
|
112
|
-
this.chosenScansOnPlan = [];
|
|
113
|
-
this.clearDivPlan();
|
|
114
|
-
this.addScanPoints();
|
|
115
|
-
};
|
|
116
|
-
if (this.selectionChanged) {
|
|
117
|
-
const message = this.translate.instant("confirm.cancelModifZoneSweeps");
|
|
118
|
-
if (window.confirm(message)) {
|
|
119
|
-
switchPlan();
|
|
120
|
-
}
|
|
121
|
-
} else {
|
|
122
|
-
switchPlan();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
async addScanPoints() {
|
|
127
|
-
let wasModified = false;
|
|
128
|
-
if (this.multipleFloors) {
|
|
129
|
-
// check if we have already validated buttons for this floor
|
|
130
|
-
if (this.chosenSweepsPerFloor.get(this.chosenPlan.zoneID)) {
|
|
131
|
-
this.chosenScansOnPlan = this.chosenSweepsPerFloor.get(this.chosenPlan.zoneID);
|
|
132
|
-
wasModified = true;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
this.divPlan = document.querySelector("#planDiv") as HTMLElement;
|
|
136
|
-
const zoneOfPlan = await this.zoneService.getZone(
|
|
137
|
-
this.chosenPlan.zoneID,
|
|
138
|
-
);
|
|
139
|
-
const navigations = await this.navigationService.getNavigationsForZone(
|
|
140
|
-
zoneOfPlan,
|
|
141
|
-
);
|
|
142
|
-
if (this.newZoneData) await this.setScanByDraw(navigations);
|
|
143
|
-
this.buttonElements = await showScanPointsOnPlanInDiv(
|
|
144
|
-
this.chosenPlan,
|
|
145
|
-
this.divPlan,
|
|
146
|
-
navigations,
|
|
147
|
-
);
|
|
148
|
-
for (const element of this.buttonElements) {
|
|
149
|
-
if (this.unavailableSweeps && this.unavailableSweeps.includes(element.id)) {
|
|
150
|
-
styleButton(element, SweepState.DISABLED);
|
|
151
|
-
} else {
|
|
152
|
-
|
|
153
|
-
if (wasModified) {
|
|
154
|
-
if (this.chosenScansOnPlan.includes(element.id)) {
|
|
155
|
-
styleButton(element, SweepState.ADDED);
|
|
156
|
-
} else {
|
|
157
|
-
styleButton(element, SweepState.REMOVED);
|
|
158
|
-
}
|
|
159
|
-
} else {
|
|
160
|
-
if (
|
|
161
|
-
this.navIDsZoneEdit.length > 0 &&
|
|
162
|
-
this.navIDsZoneEdit.includes(element.id)) {
|
|
163
|
-
styleButton(element, SweepState.ADDED);
|
|
164
|
-
if (!this.chosenScansOnPlan.includes(element.id)) {
|
|
165
|
-
this.chosenScansOnPlan.push(element.id);
|
|
166
|
-
}
|
|
167
|
-
} else if (this.occupiedSweeps && this.occupiedSweeps.includes(element.id)) {
|
|
168
|
-
styleButton(element, SweepState.OCCUPIED);
|
|
169
|
-
} else {
|
|
170
|
-
styleButton(element, SweepState.REMOVED);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
//start point should be last condition
|
|
175
|
-
if (this.inputZone && this.inputZone.startSweepID === element.id) {
|
|
176
|
-
console.log("setting start point");
|
|
177
|
-
styleButton(element, SweepState.STARTPOINT);
|
|
178
|
-
}
|
|
179
|
-
element.addEventListener("click", (event) =>
|
|
180
|
-
this.onButtonScanClicked(event.target as HTMLElement),
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
this.panZoom = panzoom(this.divPlan, {
|
|
185
|
-
bounds: true,
|
|
186
|
-
boundsPadding: 0,
|
|
187
|
-
maxZoom: 3.5,
|
|
188
|
-
beforeMouseDown(e: MouseEvent) {
|
|
189
|
-
return (
|
|
190
|
-
e.button === 2
|
|
191
|
-
); /** Ignore event for right click (use for selecting) */
|
|
192
|
-
},
|
|
193
|
-
});
|
|
194
|
-
if (this.multipleFloors) {
|
|
195
|
-
this.chosenSweepsPerFloor.set(this.chosenPlan.zoneID, [...this.chosenScansOnPlan]);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/** Function if we are coming for svg editor workflow */
|
|
200
|
-
setScanByDraw(navigations: any[]): Promise<void> {
|
|
201
|
-
return new Promise(async (resolve) => {
|
|
202
|
-
const rect = {
|
|
203
|
-
width: this.newZoneData.width,
|
|
204
|
-
height: this.newZoneData.height,
|
|
205
|
-
};
|
|
206
|
-
const img = await getMetaForImage(this.chosenPlan.filepath);
|
|
207
|
-
const { coeffX, coeffY } = getCoefficientsForImage(img, rect);
|
|
208
|
-
|
|
209
|
-
const draw = this.newZoneData.elements;
|
|
210
|
-
|
|
211
|
-
draw.map(async (element: any) => {
|
|
212
|
-
switch (element.nodeName) {
|
|
213
|
-
case "rect":
|
|
214
|
-
await this.setScanInRect(
|
|
215
|
-
img,
|
|
216
|
-
coeffX,
|
|
217
|
-
coeffY,
|
|
218
|
-
element,
|
|
219
|
-
navigations,
|
|
220
|
-
);
|
|
221
|
-
break;
|
|
222
|
-
|
|
223
|
-
case "ellipse":
|
|
224
|
-
await this.setScanInCircle(
|
|
225
|
-
img,
|
|
226
|
-
coeffX,
|
|
227
|
-
coeffY,
|
|
228
|
-
element,
|
|
229
|
-
navigations,
|
|
230
|
-
);
|
|
231
|
-
break;
|
|
232
|
-
|
|
233
|
-
case "path":
|
|
234
|
-
await this.setScanInPolygon(
|
|
235
|
-
img,
|
|
236
|
-
coeffX,
|
|
237
|
-
coeffY,
|
|
238
|
-
element,
|
|
239
|
-
navigations,
|
|
240
|
-
);
|
|
241
|
-
break;
|
|
242
|
-
default:
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
resolve();
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
async setScanInRect(img: any, coeffX: number, coeffY: number,
|
|
252
|
-
element: { angle: any; cx: any; cy: any; x: number; width: any; y: number; height: any; }, navigations: any[]) {
|
|
253
|
-
const calibrage = JSON.parse(this.chosenPlan.calibration);
|
|
254
|
-
navigations.map((navigation) => {
|
|
255
|
-
const positionsOnPlan = navigation.positionOnPlan.map((entry) =>
|
|
256
|
-
JSON.parse(entry),
|
|
257
|
-
);
|
|
258
|
-
const positionOnPlan = positionsOnPlan.find(
|
|
259
|
-
(data) => data.planID === this.chosenPlan.id,
|
|
260
|
-
);
|
|
261
|
-
if (positionOnPlan) {
|
|
262
|
-
const realWidth = img.width / coeffX;
|
|
263
|
-
const realHeight = img.height / coeffY;
|
|
264
|
-
const navY = (positionOnPlan.y * realHeight) / calibrage.imgHeight;
|
|
265
|
-
const navX = (positionOnPlan.x * realWidth) / calibrage.imgWidth;
|
|
266
|
-
if (
|
|
267
|
-
navX > element.x &&
|
|
268
|
-
navX < element.x + element.width &&
|
|
269
|
-
navY > element.y &&
|
|
270
|
-
navY < element.y + element.height &&
|
|
271
|
-
!this.navIDsZoneEdit.includes(navigation.id)
|
|
272
|
-
) {
|
|
273
|
-
this.navIDsZoneEdit.push(navigation.id);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// old calibration:
|
|
278
|
-
// const position = JSON.parse(navigation.position);
|
|
279
|
-
// let navX = (calibrage.offsetX + position.x * calibrage.x) / coeffX;
|
|
280
|
-
// let navY = (calibrage.offsetY + position.z * calibrage.y) / coeffY;
|
|
281
|
-
// if (element.angle) {
|
|
282
|
-
// const rotatePos = rotate(
|
|
283
|
-
// { x: navX, y: navY },
|
|
284
|
-
// { x: element.cx, y: element.cy },
|
|
285
|
-
// element.angle,
|
|
286
|
-
// );
|
|
287
|
-
// navX = rotatePos.x;
|
|
288
|
-
// navY = rotatePos.y;
|
|
289
|
-
// }
|
|
290
|
-
/**
|
|
291
|
-
* TODO calculer la rotation du rectangle
|
|
292
|
-
*/
|
|
293
|
-
// if (
|
|
294
|
-
// navX > element.x &&
|
|
295
|
-
// navX < element.x + element.width &&
|
|
296
|
-
// navY > element.y &&
|
|
297
|
-
// navY < element.y + element.height &&
|
|
298
|
-
// !this.navIDsZoneEdit.includes(navigation.id)
|
|
299
|
-
// ) {
|
|
300
|
-
// this.navIDsZoneEdit.push(navigation.id);
|
|
301
|
-
// }
|
|
302
|
-
});
|
|
303
|
-
} // EO
|
|
304
|
-
|
|
305
|
-
async setScanInCircle(img: any, coeffX: number, coeffY: number,
|
|
306
|
-
element: { angle: any; cx: number; cy: number; rx: number; ry: number; }, navigations: Navigation[]) {
|
|
307
|
-
const calibrage = JSON.parse(this.chosenPlan.calibration);
|
|
308
|
-
navigations.map(navigation => {
|
|
309
|
-
const positionsOnPlan = navigation.positionOnPlan.map((entry) =>
|
|
310
|
-
JSON.parse(entry),
|
|
311
|
-
);
|
|
312
|
-
const positionOnPlan = positionsOnPlan.find(
|
|
313
|
-
(data) => data.planID === this.chosenPlan.id,
|
|
314
|
-
);
|
|
315
|
-
if (positionOnPlan) {
|
|
316
|
-
const realWidth = img.width / coeffX;
|
|
317
|
-
const realHeight = img.height / coeffY;
|
|
318
|
-
let navY = (positionOnPlan.y * realHeight) / calibrage.imgHeight;
|
|
319
|
-
let navX = (positionOnPlan.x * realWidth) / calibrage.imgWidth;
|
|
320
|
-
if (element.angle) {
|
|
321
|
-
const rotatePos = rotate(
|
|
322
|
-
{ x: navX, y: navY },
|
|
323
|
-
{ x: element.cx, y: element.cy },
|
|
324
|
-
element.angle,
|
|
325
|
-
);
|
|
326
|
-
navX = rotatePos.x;
|
|
327
|
-
navY = rotatePos.y;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
const valueX =
|
|
331
|
-
Math.pow(navX - element.cx, 2) / Math.pow(element.rx, 2);
|
|
332
|
-
const valueY =
|
|
333
|
-
Math.pow(navY - element.cy, 2) / Math.pow(element.ry, 2);
|
|
334
|
-
const result = valueX + valueY;
|
|
335
|
-
if (result <= 1 && !this.navIDsZoneEdit.includes(navigation.id)) {
|
|
336
|
-
this.navIDsZoneEdit.push(navigation.id);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// old calibration
|
|
341
|
-
// const position = JSON.parse(navigation.position);
|
|
342
|
-
// let navX = (calibrage.offsetX + position.x * calibrage.x) / coeffX;
|
|
343
|
-
// let navY = (calibrage.offsetY + position.z * calibrage.y) / coeffY;
|
|
344
|
-
// if (element.angle) {
|
|
345
|
-
// const rotatePos = rotate(
|
|
346
|
-
// { x: navX, y: navY },
|
|
347
|
-
// { x: element.cx, y: element.cy },
|
|
348
|
-
// element.angle,
|
|
349
|
-
// );
|
|
350
|
-
// navX = rotatePos.x;
|
|
351
|
-
// navY = rotatePos.y;
|
|
352
|
-
// }
|
|
353
|
-
|
|
354
|
-
// const valueX =
|
|
355
|
-
// Math.pow(navX - element.cx, 2) / Math.pow(element.rx, 2);
|
|
356
|
-
// const valueY =
|
|
357
|
-
// Math.pow(navY - element.cy, 2) / Math.pow(element.ry, 2);
|
|
358
|
-
// const result = valueX + valueY;
|
|
359
|
-
// if (result <= 1 && !this.navIDsZoneEdit.includes(navigation.id)) {
|
|
360
|
-
// this.navIDsZoneEdit.push(navigation.id);
|
|
361
|
-
// }
|
|
362
|
-
});
|
|
363
|
-
} // EO
|
|
364
|
-
|
|
365
|
-
async setScanInPolygon(img: any, coeffX: number, coeffY: number, element: { segList: any; }, navigations: any[]) {
|
|
366
|
-
const calibrage = JSON.parse(this.chosenPlan.calibration);
|
|
367
|
-
navigations.map(async (navigation) => {
|
|
368
|
-
|
|
369
|
-
const positionsOnPlan = navigation.positionOnPlan.map((entry) =>
|
|
370
|
-
JSON.parse(entry),
|
|
371
|
-
);
|
|
372
|
-
const positionOnPlan = positionsOnPlan.find(
|
|
373
|
-
(data) => data.planID === this.chosenPlan.id,
|
|
374
|
-
);
|
|
375
|
-
if (positionOnPlan) {
|
|
376
|
-
const realWidth = img.width / coeffX;
|
|
377
|
-
const realHeight = img.height / coeffY;
|
|
378
|
-
let navY = (positionOnPlan.y * realHeight) / calibrage.imgHeight;
|
|
379
|
-
let navX = (positionOnPlan.x * realWidth) / calibrage.imgWidth;
|
|
380
|
-
|
|
381
|
-
const p = {
|
|
382
|
-
x: navX,
|
|
383
|
-
y: navY,
|
|
384
|
-
};
|
|
385
|
-
if (
|
|
386
|
-
isInPolygon(p, element.segList) &&
|
|
387
|
-
!this.navIDsZoneEdit.includes(navigation.id)
|
|
388
|
-
) {
|
|
389
|
-
this.navIDsZoneEdit.push(navigation.id);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// old calibration
|
|
394
|
-
// const position = JSON.parse(navigation.position);
|
|
395
|
-
// const p = {
|
|
396
|
-
// x: (calibrage.offsetX + position.x * calibrage.x) / coeffX,
|
|
397
|
-
// y: (calibrage.offsetY + position.z * calibrage.y) / coeffY,
|
|
398
|
-
// };
|
|
399
|
-
// if (element.angle) {
|
|
400
|
-
// p = this.rotate(
|
|
401
|
-
// p,
|
|
402
|
-
// { x: element.cx, y: element.cy },
|
|
403
|
-
// element.angle,
|
|
404
|
-
// );
|
|
405
|
-
// }
|
|
406
|
-
// if (
|
|
407
|
-
// isInPolygon(p, element.segList) &&
|
|
408
|
-
// !this.navIDsZoneEdit.includes(navigation.id)
|
|
409
|
-
// ) {
|
|
410
|
-
// this.navIDsZoneEdit.push(navigation.id);
|
|
411
|
-
// }
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
clearDivPlan() {
|
|
416
|
-
if (this.divPlan) this.divPlan.innerHTML = "";
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Trigger each by the selectionComponent when selection change
|
|
422
|
-
* Update the current selected scan buttons
|
|
423
|
-
* @param selection new selection
|
|
424
|
-
*/
|
|
425
|
-
onSelectionChanged(selection: Rectangle) {
|
|
426
|
-
const unselectedButtons: HTMLButtonElement[] = [];
|
|
427
|
-
const newSelectedButtons = [];
|
|
428
|
-
|
|
429
|
-
/** For each button, decide whether will be add to selected list or unselected list */
|
|
430
|
-
for (const button of this.buttonElements) {
|
|
431
|
-
const isSelected = buttonIsInSelection(button, selection);
|
|
432
|
-
if (this.buttonsInSelection.includes(button)) {
|
|
433
|
-
/** If the button is already in the selected list, we check if it should be unselect */
|
|
434
|
-
if (!isSelected) {
|
|
435
|
-
unselectedButtons.push(button);
|
|
436
|
-
}
|
|
437
|
-
} else if (isSelected) {
|
|
438
|
-
newSelectedButtons.push(button);
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
/** Visually Update unselected list */
|
|
443
|
-
for (const button of unselectedButtons) {
|
|
444
|
-
setVisuallySelected(button, false);
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
/** Visually Update selected list */
|
|
448
|
-
for (const button of newSelectedButtons) {
|
|
449
|
-
setVisuallySelected(button, true);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
/** Remove unselected list */
|
|
453
|
-
this.buttonsInSelection = this.buttonsInSelection.filter((button) => {
|
|
454
|
-
return !unselectedButtons.includes(button);
|
|
455
|
-
});
|
|
456
|
-
/** Add new selected buttons */
|
|
457
|
-
this.buttonsInSelection = [
|
|
458
|
-
...this.buttonsInSelection,
|
|
459
|
-
...newSelectedButtons,
|
|
460
|
-
];
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* Trigger when the user click to add the selected scans
|
|
467
|
-
*/
|
|
468
|
-
onSelectionAdd() {
|
|
469
|
-
for (const button of this.buttonsInSelection) {
|
|
470
|
-
if (!this.chosenScansOnPlan.includes(button.id)) {
|
|
471
|
-
this.onButtonScanClicked(button);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
this.onSelectionChanged({ top: 0, left: 0, width: 0, height: 0 });
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* Trigger when the user click to remove the selected scans
|
|
480
|
-
*/
|
|
481
|
-
onSelectionRemove() {
|
|
482
|
-
for (const button of this.buttonsInSelection) {
|
|
483
|
-
if (this.chosenScansOnPlan.includes(button.id)) {
|
|
484
|
-
this.onButtonScanClicked(button);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
this.onSelectionChanged({ top: 0, left: 0, width: 0, height: 0 });
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* Trigger when the user click to select all scans
|
|
492
|
-
*/
|
|
493
|
-
onSelectAll() {
|
|
494
|
-
this.buttonsInSelection = [...this.buttonElements];
|
|
495
|
-
for (const button of this.buttonsInSelection) {
|
|
496
|
-
setVisuallySelected(button, true);
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* Trigger when the user change the size of the scan points
|
|
502
|
-
* @param event
|
|
503
|
-
*/
|
|
504
|
-
onChangeScanSize(event: any) {
|
|
505
|
-
const factor = event.target.value;
|
|
506
|
-
|
|
507
|
-
for (const button of this.buttonElements) {
|
|
508
|
-
button.style.transform = `scale(${factor})`;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* When a button representing a scan is clicked
|
|
514
|
-
* @param button
|
|
515
|
-
*/
|
|
516
|
-
onButtonScanClicked(button: HTMLElement) {
|
|
517
|
-
this.selectionChanged = true;
|
|
518
|
-
if (this.isSettingStartSweep) {
|
|
519
|
-
if (this.startSweepID === button.id) {
|
|
520
|
-
// we deselect the starting point
|
|
521
|
-
button.style.backgroundImage = `url("https://api.iconify.design/mdi:adjust.svg?color=green&height=17&width=17")`;
|
|
522
|
-
this.startSweepID = null;
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
button.style.backgroundImage = `url('https://api.iconify.design/ic/baseline-flag-circle.svg?color=white&width=17&height=17')`;
|
|
526
|
-
if (!this.chosenScansOnPlan.includes(button.id)) {
|
|
527
|
-
this.chosenScansOnPlan.push(button.id);
|
|
528
|
-
}
|
|
529
|
-
if (this.startSweepID) {
|
|
530
|
-
// we are changing start sweep
|
|
531
|
-
const btnChanged = this.buttonElements.find((btn) => btn.id === this.startSweepID);
|
|
532
|
-
btnChanged.style.backgroundImage = `url("https://api.iconify.design/mdi:adjust.svg?color=green&height=17&width=17")`;
|
|
533
|
-
}
|
|
534
|
-
this.startSweepID = button.id;
|
|
535
|
-
return;
|
|
536
|
-
}
|
|
537
|
-
if (!this.chosenScansOnPlan.includes(button.id)) {
|
|
538
|
-
// add to selection
|
|
539
|
-
button.style.backgroundImage = `url("https://api.iconify.design/mdi:adjust.svg?color=green&height=17&width=17")`;
|
|
540
|
-
this.chosenScansOnPlan.push(button.id);
|
|
541
|
-
} else {
|
|
542
|
-
// remove from selection
|
|
543
|
-
if (this.occupiedSweeps.includes(button.id) && !this.navIDsZoneEdit.includes(button.id)) {
|
|
544
|
-
// the sweep belongs to another zone => set orange
|
|
545
|
-
button.style.backgroundImage = `url("https://api.iconify.design/mdi:adjust.svg?color=orange&height=17&width=17")`;
|
|
546
|
-
} else {
|
|
547
|
-
button.style.backgroundImage = `url("https://api.iconify.design/mdi:close-circle-outline.svg?color=red&height=17&width=17")`;
|
|
548
|
-
}
|
|
549
|
-
const index = this.chosenScansOnPlan.indexOf(button.id);
|
|
550
|
-
this.chosenScansOnPlan.splice(index, 1);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
onSaveSelection() {
|
|
555
|
-
if (this.multipleFloors) {
|
|
556
|
-
// rassemble all sweeps per floors
|
|
557
|
-
let finalSweeps = [];
|
|
558
|
-
Array.from(this.inputSweepsPerFloor.keys()).forEach(floorID => {
|
|
559
|
-
if (this.chosenSweepsPerFloor.get(floorID)) {
|
|
560
|
-
// the sweeps for this floor were modified, we take them
|
|
561
|
-
finalSweeps = [...finalSweeps, ...this.chosenSweepsPerFloor.get(floorID)];
|
|
562
|
-
} else {
|
|
563
|
-
// was not modified, we take the previous values
|
|
564
|
-
finalSweeps = [...finalSweeps, ...this.inputSweepsPerFloor.get(floorID)];
|
|
565
|
-
}
|
|
566
|
-
});
|
|
567
|
-
// console.log("final sweeps", finalSweeps);
|
|
568
|
-
this.sweepsSelected.emit({ "sweeps": finalSweeps, "startSweepID": this.startSweepID });
|
|
569
|
-
} else {
|
|
570
|
-
this.sweepsSelected.emit({ "sweeps": this.chosenScansOnPlan, "startSweepID": this.startSweepID });
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
onCancel() {
|
|
575
|
-
if (this.selectionChanged) {
|
|
576
|
-
const message = this.translate.instant("confirm.cancelModifZoneSweeps");
|
|
577
|
-
if (window.confirm(message)) {
|
|
578
|
-
this.sweepsSelected.emit(null);
|
|
579
|
-
}
|
|
580
|
-
} else {
|
|
581
|
-
this.sweepsSelected.emit(null);
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
/**
|
|
586
|
-
* Adds current selection of sweeps for current floor (plan) for multifloor zone.
|
|
587
|
-
* It has to be saved anyway with onSaveSelection!
|
|
588
|
-
*/
|
|
589
|
-
onValidateForFloor() {
|
|
590
|
-
if (this.multipleFloors) {
|
|
591
|
-
this.chosenSweepsPerFloor.set(this.chosenPlan.zoneID, [...this.chosenScansOnPlan]);
|
|
592
|
-
this.selectionChanged = false;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|