@vcmap/viewshed 3.0.5 → 4.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.
- package/CHANGELOG.md +6 -0
- package/dist/index.js +1097 -1119
- package/package.json +25 -24
- package/src/ViewshedConfigEditor.vue +32 -34
- package/src/ViewshedWindow.vue +152 -160
- package/src/{index.js → index.ts} +63 -68
- package/src/util/{toolboxHelper.js → toolboxHelper.ts} +57 -38
- package/src/util/{windowHelper.js → windowHelper.ts} +28 -27
- package/src/{viewshed.js → viewshed.ts} +159 -202
- package/src/{viewshedCategory.js → viewshedCategory.ts} +67 -60
- package/src/{viewshedInteraction.js → viewshedInteraction.ts} +20 -14
- package/src/{viewshedManager.js → viewshedManager.ts} +130 -97
- package/src/{viewshedPrimitive.js → viewshedPrimitive.ts} +34 -19
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type { VcsMap } from '@vcmap/core';
|
|
1
2
|
import { CesiumMap, moduleIdSymbol } from '@vcmap/core';
|
|
3
|
+
import type { PluginConfigEditor, VcsPlugin, VcsUiApp } from '@vcmap/ui';
|
|
4
|
+
import type { ColorOptions, ViewshedOptions } from './viewshed.js';
|
|
2
5
|
import Viewshed, { ViewshedTypes } from './viewshed.js';
|
|
6
|
+
import type { ViewshedManager } from './viewshedManager.js';
|
|
3
7
|
import createViewshedManager, {
|
|
4
8
|
ViewshedPluginModes,
|
|
5
9
|
} from './viewshedManager.js';
|
|
@@ -7,46 +11,55 @@ import { setupViewshedWindow } from './util/windowHelper.js';
|
|
|
7
11
|
import addViewshedToolButtons from './util/toolboxHelper.js';
|
|
8
12
|
import { name, version, mapVersion } from '../package.json';
|
|
9
13
|
import ViewshedCategory, { createCategory } from './viewshedCategory.js';
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
} from './ViewshedConfigEditor.vue';
|
|
14
|
+
import type { ViewshedConfig } from './ViewshedConfigEditor.vue';
|
|
15
|
+
import ViewshedConfigEditor from './ViewshedConfigEditor.vue';
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
type ViewshedPluginState = {
|
|
18
|
+
/** Which mode the plugin is currently in. */
|
|
19
|
+
m?: ViewshedPluginModes | null;
|
|
20
|
+
/** The currents viewshed options. */
|
|
21
|
+
cv?: ViewshedOptions | null;
|
|
22
|
+
};
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
export type ViewshedPluginOptions = ColorOptions & {
|
|
25
|
+
tools?: ViewshedTypes[];
|
|
26
|
+
};
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
export function getDefaultOptions(): ViewshedConfig {
|
|
29
|
+
return {
|
|
30
|
+
visibleColor: Viewshed.getDefaultOptions().colorOptions.visibleColor,
|
|
31
|
+
shadowColor: Viewshed.getDefaultOptions().colorOptions.shadowColor,
|
|
32
|
+
tools: [...Object.values(ViewshedTypes)],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type ViewshedPlugin = VcsPlugin<
|
|
37
|
+
ViewshedPluginOptions,
|
|
38
|
+
ViewshedPluginState
|
|
39
|
+
>;
|
|
40
|
+
|
|
41
|
+
export default function plugin(options: ViewshedPluginOptions): ViewshedPlugin {
|
|
42
|
+
let app: VcsUiApp;
|
|
43
|
+
let viewshedManager: ViewshedManager;
|
|
44
|
+
let destroy = (): void => {};
|
|
45
|
+
|
|
46
|
+
const defaultOptions = getDefaultOptions();
|
|
47
|
+
const config = { ...defaultOptions, ...options };
|
|
33
48
|
|
|
34
49
|
return {
|
|
35
|
-
get name() {
|
|
50
|
+
get name(): string {
|
|
36
51
|
return name;
|
|
37
52
|
},
|
|
38
|
-
get version() {
|
|
53
|
+
get version(): string {
|
|
39
54
|
return version;
|
|
40
55
|
},
|
|
41
|
-
get mapVersion() {
|
|
56
|
+
get mapVersion(): string {
|
|
42
57
|
return mapVersion;
|
|
43
58
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*/
|
|
49
|
-
async initialize(vcsUiApp, state) {
|
|
59
|
+
async initialize(
|
|
60
|
+
vcsUiApp: VcsUiApp,
|
|
61
|
+
state?: ViewshedPluginState,
|
|
62
|
+
): Promise<void> {
|
|
50
63
|
app = vcsUiApp;
|
|
51
64
|
vcsUiApp.categoryClassRegistry.registerClass(
|
|
52
65
|
this[moduleIdSymbol],
|
|
@@ -63,7 +76,7 @@ export default function plugin(config) {
|
|
|
63
76
|
vcsUiApp,
|
|
64
77
|
viewshedManager,
|
|
65
78
|
name,
|
|
66
|
-
config.tools ||
|
|
79
|
+
config.tools || defaultOptions.tools,
|
|
67
80
|
);
|
|
68
81
|
const { destroy: destroyViewshedWindow } = setupViewshedWindow(
|
|
69
82
|
viewshedManager,
|
|
@@ -72,7 +85,7 @@ export default function plugin(config) {
|
|
|
72
85
|
);
|
|
73
86
|
|
|
74
87
|
const { activeMap } = vcsUiApp.maps;
|
|
75
|
-
function activateCachedViewshed(map) {
|
|
88
|
+
function activateCachedViewshed(map: VcsMap): void {
|
|
76
89
|
if (state?.m && state.cv && map instanceof CesiumMap) {
|
|
77
90
|
const activeViewshed = new Viewshed(state.cv);
|
|
78
91
|
if (state.m === ViewshedPluginModes.VIEW) {
|
|
@@ -97,7 +110,7 @@ export default function plugin(config) {
|
|
|
97
110
|
},
|
|
98
111
|
);
|
|
99
112
|
|
|
100
|
-
destroy = () => {
|
|
113
|
+
destroy = (): void => {
|
|
101
114
|
mapActivatedListener();
|
|
102
115
|
destroyButtons();
|
|
103
116
|
destroyViewshedWindow();
|
|
@@ -105,52 +118,40 @@ export default function plugin(config) {
|
|
|
105
118
|
viewshedManager.destroy();
|
|
106
119
|
};
|
|
107
120
|
},
|
|
108
|
-
/**
|
|
109
|
-
* should return all default values of the configuration
|
|
110
|
-
* @returns {ViewshedPluginOptions}
|
|
111
|
-
*/
|
|
112
121
|
getDefaultOptions,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
*/
|
|
117
|
-
toJSON() {
|
|
118
|
-
const serial = {};
|
|
119
|
-
if (
|
|
120
|
-
config.tools &&
|
|
121
|
-
getDefaultOptions().tools.length !== config.tools.length
|
|
122
|
-
) {
|
|
122
|
+
toJSON(): ViewshedPluginOptions {
|
|
123
|
+
const serial: ViewshedPluginOptions = {};
|
|
124
|
+
if (config.tools && defaultOptions.tools.length !== config.tools.length) {
|
|
123
125
|
serial.tools = [...config.tools];
|
|
124
126
|
}
|
|
125
127
|
if (
|
|
126
128
|
config.shadowColor &&
|
|
127
|
-
config.shadowColor !==
|
|
129
|
+
config.shadowColor !== defaultOptions.shadowColor
|
|
128
130
|
) {
|
|
129
131
|
serial.shadowColor = config.shadowColor;
|
|
130
132
|
}
|
|
131
133
|
if (
|
|
132
134
|
config.visibleColor &&
|
|
133
|
-
config.visibleColor !==
|
|
135
|
+
config.visibleColor !== defaultOptions.visibleColor
|
|
134
136
|
) {
|
|
135
137
|
serial.visibleColor = config.visibleColor;
|
|
136
138
|
}
|
|
137
139
|
return serial;
|
|
138
140
|
},
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
* @param {boolean} forUrl
|
|
142
|
-
* @returns {ViewshedPluginState}
|
|
143
|
-
*/
|
|
144
|
-
getState(forUrl) {
|
|
145
|
-
const state = {};
|
|
141
|
+
getState(forUrl?: boolean): ViewshedPluginState {
|
|
142
|
+
const state: ViewshedPluginState = {};
|
|
146
143
|
const mode = viewshedManager.mode.value;
|
|
147
144
|
const currentViewshed = viewshedManager.currentViewshed.value?.toJSON();
|
|
148
145
|
|
|
149
|
-
if (
|
|
146
|
+
if (
|
|
147
|
+
mode !== null &&
|
|
148
|
+
mode !== ViewshedPluginModes.CREATE &&
|
|
149
|
+
currentViewshed
|
|
150
|
+
) {
|
|
150
151
|
state.m = mode;
|
|
151
152
|
state.cv = currentViewshed;
|
|
152
|
-
if (forUrl && state.cv
|
|
153
|
-
if (Object.keys(state.properties).length === 1) {
|
|
153
|
+
if (forUrl && state.cv?.properties?.title) {
|
|
154
|
+
if (Object.keys(state.cv?.properties).length === 1) {
|
|
154
155
|
delete state.cv.properties;
|
|
155
156
|
} else {
|
|
156
157
|
delete state.cv.properties.title;
|
|
@@ -160,11 +161,7 @@ export default function plugin(config) {
|
|
|
160
161
|
|
|
161
162
|
return state;
|
|
162
163
|
},
|
|
163
|
-
|
|
164
|
-
* components for configuring the plugin and/ or custom items defined by the plugin
|
|
165
|
-
* @returns {Array<import("@vcmap/ui").PluginConfigEditor>}
|
|
166
|
-
*/
|
|
167
|
-
getConfigEditors() {
|
|
164
|
+
getConfigEditors(): PluginConfigEditor<object>[] {
|
|
168
165
|
return [
|
|
169
166
|
{
|
|
170
167
|
component: ViewshedConfigEditor,
|
|
@@ -176,7 +173,9 @@ export default function plugin(config) {
|
|
|
176
173
|
},
|
|
177
174
|
];
|
|
178
175
|
},
|
|
179
|
-
destroy: () =>
|
|
176
|
+
destroy: (): void => {
|
|
177
|
+
destroy();
|
|
178
|
+
},
|
|
180
179
|
i18n: {
|
|
181
180
|
en: {
|
|
182
181
|
viewshed: {
|
|
@@ -191,7 +190,6 @@ export default function plugin(config) {
|
|
|
191
190
|
heightMode: 'Height mode',
|
|
192
191
|
relative: 'Relative to ground',
|
|
193
192
|
absolute: 'Absolute',
|
|
194
|
-
new: 'New',
|
|
195
193
|
cancel: 'Cancel',
|
|
196
194
|
[ViewshedTypes.CONE]: 'Cone viewshed analysis',
|
|
197
195
|
[ViewshedTypes.THREESIXTY]: '360° viewshed analysis',
|
|
@@ -199,7 +197,6 @@ export default function plugin(config) {
|
|
|
199
197
|
[ViewshedTypes.CONE]: 'Create cone viewshed analysis',
|
|
200
198
|
[ViewshedTypes.THREESIXTY]: 'Create 360° viewshed analysis',
|
|
201
199
|
},
|
|
202
|
-
addToMyWorkspace: 'Add to My Workspace',
|
|
203
200
|
temporary: 'Temporary',
|
|
204
201
|
jumpToViewpoint: 'Jump to viewpoint',
|
|
205
202
|
returnToViewpoint: 'Return to previous viewpoint',
|
|
@@ -231,7 +228,6 @@ export default function plugin(config) {
|
|
|
231
228
|
heightMode: 'Höhenmodus',
|
|
232
229
|
relative: 'Relativ zum Gelände',
|
|
233
230
|
absolute: 'Absolut',
|
|
234
|
-
new: 'Neu',
|
|
235
231
|
cancel: 'Abbrechen',
|
|
236
232
|
[ViewshedTypes.CONE]: 'Sichtkegelanalyse',
|
|
237
233
|
[ViewshedTypes.THREESIXTY]: '360° Sichtsanalyse',
|
|
@@ -239,7 +235,6 @@ export default function plugin(config) {
|
|
|
239
235
|
[ViewshedTypes.CONE]: 'Sichtkegelanalyse erstellen',
|
|
240
236
|
[ViewshedTypes.THREESIXTY]: '360° Sichtanalyse erstellen',
|
|
241
237
|
},
|
|
242
|
-
addToMyWorkspace: 'Zu Mein Arbeitsbereich hinzufügen',
|
|
243
238
|
temporary: 'Temporäre',
|
|
244
239
|
jumpToViewpoint: 'Zu Standpunkt springen',
|
|
245
240
|
returnToViewpoint: 'Zu vorherigem Standpunkt zurück springen',
|
|
@@ -1,41 +1,53 @@
|
|
|
1
1
|
import { CesiumMap } from '@vcmap/core';
|
|
2
|
+
import type {
|
|
3
|
+
SelectToolboxComponentOptions,
|
|
4
|
+
SingleToolboxComponentOptions,
|
|
5
|
+
VcsUiApp,
|
|
6
|
+
} from '@vcmap/ui';
|
|
2
7
|
import { ToolboxType } from '@vcmap/ui';
|
|
3
8
|
import { check, ofEnum } from '@vcsuite/check';
|
|
4
9
|
import { reactive, watch } from 'vue';
|
|
5
10
|
import { ViewshedTypes } from '../viewshed.js';
|
|
6
|
-
import {
|
|
11
|
+
import { viewshedIcons } from './windowHelper.js';
|
|
12
|
+
import type { ViewshedManager } from '../viewshedManager.js';
|
|
7
13
|
import { ViewshedPluginModes } from '../viewshedManager.js';
|
|
8
14
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*/
|
|
15
|
+
type ViewshedToolbox = {
|
|
16
|
+
toolbox: SingleToolboxComponentOptions | SelectToolboxComponentOptions;
|
|
17
|
+
destroy: () => void;
|
|
18
|
+
};
|
|
14
19
|
|
|
15
20
|
/**
|
|
16
21
|
*
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
* @returns
|
|
22
|
+
* @param app The VcsUiApp instance
|
|
23
|
+
* @param manager The viewshed manager.
|
|
24
|
+
* @param name Name of toolbox.
|
|
25
|
+
* @param tools The tools to be available in the toolbox
|
|
26
|
+
* @returns A select toolbox with buttons to create 360 and cone viewshed.
|
|
22
27
|
*/
|
|
23
|
-
function createViewshedToolbox(
|
|
28
|
+
function createViewshedToolbox(
|
|
29
|
+
app: VcsUiApp,
|
|
30
|
+
manager: ViewshedManager,
|
|
31
|
+
name: string,
|
|
32
|
+
tools: string[],
|
|
33
|
+
): ViewshedToolbox {
|
|
24
34
|
/**
|
|
25
|
-
* @param
|
|
26
|
-
* @returns
|
|
35
|
+
* @param tool The tool to create.
|
|
36
|
+
* @returns A tool object.
|
|
27
37
|
*/
|
|
28
|
-
function parseTool(
|
|
38
|
+
function parseTool(
|
|
39
|
+
tool: ViewshedTypes,
|
|
40
|
+
): { name: ViewshedTypes; icon: string; title: string } | undefined {
|
|
29
41
|
if (tool === ViewshedTypes.CONE) {
|
|
30
42
|
return {
|
|
31
43
|
name: ViewshedTypes.CONE,
|
|
32
|
-
icon:
|
|
44
|
+
icon: viewshedIcons[ViewshedTypes.CONE],
|
|
33
45
|
title: `viewshed.create.${ViewshedTypes.CONE}`,
|
|
34
46
|
};
|
|
35
47
|
} else if (tool === ViewshedTypes.THREESIXTY) {
|
|
36
48
|
return {
|
|
37
49
|
name: ViewshedTypes.THREESIXTY,
|
|
38
|
-
icon:
|
|
50
|
+
icon: viewshedIcons[ViewshedTypes.THREESIXTY],
|
|
39
51
|
title: `viewshed.create.${ViewshedTypes.THREESIXTY}`,
|
|
40
52
|
};
|
|
41
53
|
} else {
|
|
@@ -43,10 +55,10 @@ function createViewshedToolbox(app, manager, name, tools) {
|
|
|
43
55
|
}
|
|
44
56
|
}
|
|
45
57
|
|
|
46
|
-
let toolbox;
|
|
47
|
-
let currentViewshedWatcher;
|
|
58
|
+
let toolbox: SingleToolboxComponentOptions | SelectToolboxComponentOptions;
|
|
59
|
+
let currentViewshedWatcher: () => void;
|
|
48
60
|
if (tools.length === 1) {
|
|
49
|
-
const tool = parseTool(tools[0])
|
|
61
|
+
const tool = parseTool(tools[0] as ViewshedTypes)!;
|
|
50
62
|
toolbox = {
|
|
51
63
|
type: ToolboxType.SINGLE,
|
|
52
64
|
action: reactive({
|
|
@@ -54,15 +66,15 @@ function createViewshedToolbox(app, manager, name, tools) {
|
|
|
54
66
|
active: false,
|
|
55
67
|
background: false,
|
|
56
68
|
disabled: !(app.maps.activeMap instanceof CesiumMap),
|
|
57
|
-
callback() {
|
|
69
|
+
async callback() {
|
|
58
70
|
if (this.active) {
|
|
59
71
|
if (this.background && manager.currentViewshed.value) {
|
|
60
72
|
manager.editViewshed(manager.currentViewshed.value);
|
|
61
73
|
} else {
|
|
62
74
|
manager.stop();
|
|
63
75
|
}
|
|
64
|
-
} else {
|
|
65
|
-
manager.createViewshed(tool.name);
|
|
76
|
+
} else if (tool) {
|
|
77
|
+
await manager.createViewshed(tool.name);
|
|
66
78
|
}
|
|
67
79
|
},
|
|
68
80
|
}),
|
|
@@ -76,7 +88,7 @@ function createViewshedToolbox(app, manager, name, tools) {
|
|
|
76
88
|
active: false,
|
|
77
89
|
background: false,
|
|
78
90
|
disabled: !(app.maps.activeMap instanceof CesiumMap),
|
|
79
|
-
callback() {
|
|
91
|
+
async callback() {
|
|
80
92
|
if (this.active) {
|
|
81
93
|
if (this.background && manager.currentViewshed.value) {
|
|
82
94
|
manager.editViewshed(manager.currentViewshed.value);
|
|
@@ -85,17 +97,17 @@ function createViewshedToolbox(app, manager, name, tools) {
|
|
|
85
97
|
}
|
|
86
98
|
} else {
|
|
87
99
|
const toolName = this.tools[this.currentIndex].name;
|
|
88
|
-
manager.createViewshed(toolName);
|
|
100
|
+
await manager.createViewshed(toolName);
|
|
89
101
|
}
|
|
90
102
|
},
|
|
91
|
-
selected(newIndex) {
|
|
103
|
+
async selected(newIndex: number) {
|
|
92
104
|
if (newIndex !== this.currentIndex) {
|
|
93
105
|
this.currentIndex = newIndex;
|
|
94
106
|
}
|
|
95
107
|
const toolName = this.tools[this.currentIndex].name;
|
|
96
|
-
manager.createViewshed(toolName);
|
|
108
|
+
await manager.createViewshed(toolName);
|
|
97
109
|
},
|
|
98
|
-
tools: tools.flatMap(parseTool),
|
|
110
|
+
tools: tools.flatMap((t) => parseTool(t as ViewshedTypes)),
|
|
99
111
|
}),
|
|
100
112
|
};
|
|
101
113
|
|
|
@@ -103,8 +115,10 @@ function createViewshedToolbox(app, manager, name, tools) {
|
|
|
103
115
|
manager.currentViewshed,
|
|
104
116
|
(currentViewshed) => {
|
|
105
117
|
if (currentViewshed) {
|
|
106
|
-
toolbox.action.currentIndex =
|
|
107
|
-
|
|
118
|
+
(toolbox as SelectToolboxComponentOptions).action.currentIndex = (
|
|
119
|
+
toolbox as SelectToolboxComponentOptions
|
|
120
|
+
).action.tools.findIndex(
|
|
121
|
+
(tool) => (tool.name as ViewshedTypes) === currentViewshed.type,
|
|
108
122
|
);
|
|
109
123
|
}
|
|
110
124
|
},
|
|
@@ -133,24 +147,29 @@ function createViewshedToolbox(app, manager, name, tools) {
|
|
|
133
147
|
});
|
|
134
148
|
|
|
135
149
|
return {
|
|
136
|
-
|
|
150
|
+
toolbox,
|
|
151
|
+
destroy(): void {
|
|
137
152
|
viewshedModeWatcher();
|
|
138
153
|
currentViewshedWatcher?.();
|
|
139
154
|
mapChangedListener();
|
|
140
155
|
},
|
|
141
|
-
toolbox,
|
|
142
156
|
};
|
|
143
157
|
}
|
|
144
158
|
|
|
145
159
|
/**
|
|
146
160
|
*
|
|
147
|
-
* @param
|
|
148
|
-
* @param
|
|
149
|
-
* @param
|
|
150
|
-
* @param
|
|
151
|
-
* @returns
|
|
161
|
+
* @param app The VcsUiApp instance
|
|
162
|
+
* @param manager The viewshed manager.
|
|
163
|
+
* @param name Name of toolbox action and owner of toolbox component
|
|
164
|
+
* @param tools The tools to be available in the toolbox
|
|
165
|
+
* @returns Function to remove toolbox component.
|
|
152
166
|
*/
|
|
153
|
-
export default function addToolButtons(
|
|
167
|
+
export default function addToolButtons(
|
|
168
|
+
app: VcsUiApp,
|
|
169
|
+
manager: ViewshedManager,
|
|
170
|
+
name: string,
|
|
171
|
+
tools: string[],
|
|
172
|
+
): () => void {
|
|
154
173
|
check(tools, [ofEnum(ViewshedTypes)]);
|
|
155
174
|
|
|
156
175
|
const { toolbox: createToolbox, destroy: destroyCreateToolbox } =
|
|
@@ -1,41 +1,40 @@
|
|
|
1
1
|
import { ref, watch } from 'vue';
|
|
2
|
+
import type {
|
|
3
|
+
CollectionComponentClass,
|
|
4
|
+
WindowComponentOptions,
|
|
5
|
+
VcsUiApp,
|
|
6
|
+
} from '@vcmap/ui';
|
|
2
7
|
import { WindowSlot, makeEditorCollectionComponentClass } from '@vcmap/ui';
|
|
3
8
|
import ViewshedWindow from '../ViewshedWindow.vue';
|
|
4
9
|
import { name } from '../../package.json';
|
|
10
|
+
import type Viewshed from '../viewshed.js';
|
|
5
11
|
import { ViewshedTypes } from '../viewshed.js';
|
|
12
|
+
import type { ViewshedManager } from '../viewshedManager.js';
|
|
6
13
|
import { ViewshedPluginModes } from '../viewshedManager.js';
|
|
7
14
|
|
|
8
|
-
export const
|
|
15
|
+
export const viewshedIcons = {
|
|
9
16
|
[ViewshedTypes.CONE]: '$vcsViewshed',
|
|
10
17
|
[ViewshedTypes.THREESIXTY]: '$vcsViewshedCone',
|
|
11
18
|
};
|
|
12
19
|
|
|
13
20
|
/**
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
16
|
-
* @
|
|
21
|
+
* @param manager The viewshed manager.
|
|
22
|
+
* @param app The VcsUiApp instance
|
|
23
|
+
* @param collectionComponent The collection component of the category.
|
|
24
|
+
* @returns The destroy function.
|
|
17
25
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* @returns {ViewshedWindow} Viewshed window api.
|
|
25
|
-
*/
|
|
26
|
-
export function setupViewshedWindow(manager, app, collectionComponent) {
|
|
27
|
-
/**
|
|
28
|
-
* @type {import("vue").Ref<undefined | string | string[]>}
|
|
29
|
-
*/
|
|
30
|
-
const headerTitle = ref();
|
|
26
|
+
export function setupViewshedWindow(
|
|
27
|
+
manager: ViewshedManager,
|
|
28
|
+
app: VcsUiApp,
|
|
29
|
+
collectionComponent: CollectionComponentClass<Viewshed>,
|
|
30
|
+
): { destroy: () => void } {
|
|
31
|
+
const headerTitle = ref<string | string[]>('');
|
|
31
32
|
const headerIcon = ref();
|
|
32
33
|
const windowId = `${collectionComponent.id}-editor`;
|
|
33
34
|
|
|
34
|
-
const editor = {
|
|
35
|
+
const editor: WindowComponentOptions = {
|
|
35
36
|
component: ViewshedWindow,
|
|
36
|
-
provides: {
|
|
37
|
-
manager,
|
|
38
|
-
},
|
|
37
|
+
provides: { manager },
|
|
39
38
|
state: {
|
|
40
39
|
headerTitle,
|
|
41
40
|
headerIcon,
|
|
@@ -49,17 +48,19 @@ export function setupViewshedWindow(manager, app, collectionComponent) {
|
|
|
49
48
|
...editor,
|
|
50
49
|
props: {
|
|
51
50
|
selection: collectionComponent.selection,
|
|
52
|
-
getViewshed: () =>
|
|
51
|
+
getViewshed: (): Viewshed | undefined =>
|
|
52
|
+
collectionComponent.collection.getByKey(item.name),
|
|
53
53
|
},
|
|
54
54
|
}),
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
function updateHeader() {
|
|
57
|
+
function updateHeader(): void {
|
|
58
58
|
if (manager.currentViewshed.value) {
|
|
59
|
-
headerIcon.value =
|
|
59
|
+
headerIcon.value = viewshedIcons[manager.currentViewshed.value.type];
|
|
60
60
|
|
|
61
61
|
if (manager.currentIsPersisted.value) {
|
|
62
|
-
headerTitle.value = manager.currentViewshed.value.properties
|
|
62
|
+
headerTitle.value = manager.currentViewshed.value.properties
|
|
63
|
+
.title as string;
|
|
63
64
|
} else if (manager.mode.value === ViewshedPluginModes.CREATE) {
|
|
64
65
|
headerTitle.value = `viewshed.create.${manager.currentViewshed.value.type}`;
|
|
65
66
|
} else {
|
|
@@ -71,7 +72,7 @@ export function setupViewshedWindow(manager, app, collectionComponent) {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
function updateWindow() {
|
|
75
|
+
function updateWindow(): void {
|
|
75
76
|
updateHeader();
|
|
76
77
|
if (
|
|
77
78
|
manager.currentViewshed.value &&
|
|
@@ -115,7 +116,7 @@ export function setupViewshedWindow(manager, app, collectionComponent) {
|
|
|
115
116
|
});
|
|
116
117
|
|
|
117
118
|
return {
|
|
118
|
-
destroy() {
|
|
119
|
+
destroy(): void {
|
|
119
120
|
app.windowManager.remove(windowId);
|
|
120
121
|
viewshedListener();
|
|
121
122
|
viewshedModeListener();
|