@geode/opengeodeweb-front 10.43.2-rc.1 → 10.44.0-rc.1
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/app/components/CrsSelector.vue +53 -46
- package/app/components/FeedBack/Snackers.vue +27 -0
- package/app/components/ProjectCrs.vue +37 -0
- package/app/components/Viewer/ContextMenu/InfoCard.vue +30 -0
- package/app/components/Viewer/ObjectTree/Base/ItemLabel.vue +71 -1
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +1 -0
- package/app/components/Viewer/Ui.vue +4 -0
- package/app/components/ZScaling.vue +2 -1
- package/app/composables/live_data_item.ts +39 -0
- package/app/composables/project_manager.ts +16 -1
- package/app/stores/crs.ts +136 -0
- package/app/stores/data.ts +24 -1
- package/app/stores/feedback.ts +12 -2
- package/app/stores/hybrid_viewer.ts +2 -5
- package/app/utils/crs.ts +38 -0
- package/app/utils/import_workflow.ts +20 -7
- package/internal/stores/hybrid_viewer/camera.ts +1 -12
- package/internal/stores/hybrid_viewer/camera_animation.ts +12 -0
- package/internal/stores/hybrid_viewer/scene.ts +30 -11
- package/internal/stores/hybrid_viewer/zoom_box.ts +2 -6
- package/package.json +1 -1
|
@@ -1,63 +1,45 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const schema = schemas.opengeodeweb_back.geographic_coordinate_systems;
|
|
6
|
-
|
|
7
|
-
interface Emits {
|
|
8
|
-
update_values: [values: Record<string, unknown>];
|
|
9
|
-
increment_step: [];
|
|
10
|
-
decrement_step: [];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const emit = defineEmits<Emits>();
|
|
2
|
+
import type { CRSList } from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
3
|
+
import { useCrsStore } from "@ogw_front/stores/crs";
|
|
14
4
|
|
|
15
5
|
interface Props {
|
|
16
6
|
geodeObjectType: string;
|
|
17
|
-
|
|
7
|
+
// Narrow containers: one "AUTHORITY:CODE" column and a truncated name
|
|
8
|
+
compact?: boolean;
|
|
18
9
|
}
|
|
19
10
|
|
|
20
|
-
const { geodeObjectType,
|
|
11
|
+
const { geodeObjectType, compact = false } = defineProps<Props>();
|
|
12
|
+
const selectedCrs = defineModel<CRSList | undefined>();
|
|
21
13
|
|
|
22
14
|
const search = ref<string>("");
|
|
23
15
|
const data_table_loading = ref<boolean>(false);
|
|
24
|
-
|
|
25
|
-
const
|
|
16
|
+
// Thousands of rows that are never mutated: no deep reactivity
|
|
17
|
+
const crs_list = shallowRef<CRSList[]>([]);
|
|
18
|
+
// Keys of the selected rows: the item-value of the table, "AUTHORITY:CODE"
|
|
19
|
+
const selected_crs = ref<string[]>([]);
|
|
26
20
|
const toggle_loading = useToggle(data_table_loading);
|
|
27
|
-
const
|
|
21
|
+
const crsStore = useCrsStore();
|
|
22
|
+
|
|
23
|
+
// Codes are only unique within an authority (e.g. EPSG:4812 and ESRI:4812)
|
|
24
|
+
function crs_key(crs: CRSList): string {
|
|
25
|
+
return `${crs.authority}:${crs.code}`;
|
|
26
|
+
}
|
|
28
27
|
|
|
29
|
-
function get_selected_crs(
|
|
30
|
-
|
|
31
|
-
if (crs.code === crs_code) {
|
|
32
|
-
return crs;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
28
|
+
function get_selected_crs(key: string | undefined): CRSList | undefined {
|
|
29
|
+
return crs_list.value.find((crs) => crs_key(crs) === key);
|
|
35
30
|
}
|
|
36
31
|
|
|
37
32
|
watch(selected_crs, (new_value) => {
|
|
38
|
-
|
|
39
|
-
const keys_values_object = {
|
|
40
|
-
[keyToUpdate]: crs,
|
|
41
|
-
};
|
|
42
|
-
emit("update_values", keys_values_object);
|
|
43
|
-
emit("increment_step");
|
|
33
|
+
selectedCrs.value = get_selected_crs(new_value[0]);
|
|
44
34
|
});
|
|
45
35
|
|
|
46
|
-
async function get_crs_table(): void {
|
|
47
|
-
const params = { geode_object_type: geodeObjectType };
|
|
36
|
+
async function get_crs_table(): Promise<void> {
|
|
48
37
|
toggle_loading();
|
|
49
|
-
await
|
|
50
|
-
{ schema, params },
|
|
51
|
-
{
|
|
52
|
-
response_function: (response) => {
|
|
53
|
-
crs_list.value = response.crs_list;
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
);
|
|
38
|
+
crs_list.value = await crsStore.geographicList(geodeObjectType);
|
|
57
39
|
toggle_loading();
|
|
58
40
|
}
|
|
59
41
|
|
|
60
|
-
const
|
|
42
|
+
const full_headers = [
|
|
61
43
|
{
|
|
62
44
|
title: "Authority",
|
|
63
45
|
align: "start",
|
|
@@ -68,24 +50,41 @@ const headers = [
|
|
|
68
50
|
{ title: "Name", align: "end", key: "name" },
|
|
69
51
|
] as const;
|
|
70
52
|
|
|
71
|
-
//
|
|
72
|
-
|
|
53
|
+
// A max width of 0 lets the name take the remaining space and truncate instead of wrapping
|
|
54
|
+
const compact_headers = [
|
|
55
|
+
{ title: "Code", align: "start", key: "code", value: crs_key, width: 110, nowrap: true },
|
|
56
|
+
{ title: "Name", align: "start", key: "name", maxWidth: 0, nowrap: true },
|
|
57
|
+
] as const;
|
|
58
|
+
|
|
59
|
+
// "All" would render the whole list (thousands of rows) at once
|
|
60
|
+
// oxlint-disable-next-line no-magic-numbers -- the page sizes Vuetify offers by default, "All" aside
|
|
61
|
+
const items_per_page_options = [10, 25, 50, 100];
|
|
62
|
+
|
|
63
|
+
const headers = computed(() => (compact ? compact_headers : full_headers));
|
|
64
|
+
|
|
65
|
+
// Not awaited in setup: the table renders right away with its loader
|
|
66
|
+
onMounted(async () => {
|
|
67
|
+
await get_crs_table();
|
|
68
|
+
});
|
|
73
69
|
</script>
|
|
74
70
|
|
|
75
71
|
<template>
|
|
76
72
|
<v-text-field
|
|
77
73
|
v-model="search"
|
|
78
|
-
|
|
74
|
+
data-testid="crsSearchInput"
|
|
75
|
+
:append-icon="compact ? undefined : 'mdi-magnify'"
|
|
76
|
+
:prepend-inner-icon="compact ? 'mdi-magnify' : undefined"
|
|
79
77
|
label="Search"
|
|
80
78
|
single-line
|
|
81
79
|
hide-details
|
|
82
80
|
></v-text-field>
|
|
83
81
|
<v-data-table
|
|
84
82
|
v-model="selected_crs"
|
|
85
|
-
:
|
|
83
|
+
:items-per-page="10"
|
|
84
|
+
:items-per-page-options="items_per_page_options"
|
|
86
85
|
:headers="headers"
|
|
87
86
|
:items="crs_list"
|
|
88
|
-
item-value="
|
|
87
|
+
:item-value="crs_key"
|
|
89
88
|
class="elevation-1"
|
|
90
89
|
density="compact"
|
|
91
90
|
fixed-header
|
|
@@ -94,5 +93,13 @@ await get_crs_table();
|
|
|
94
93
|
:search="search"
|
|
95
94
|
:loading="data_table_loading"
|
|
96
95
|
loading-text="Loading... Please wait"
|
|
97
|
-
|
|
96
|
+
>
|
|
97
|
+
<template v-if="compact" #[`item.name`]="{ value }">
|
|
98
|
+
<v-tooltip :text="value" location="top">
|
|
99
|
+
<template #activator="{ props: tooltipProps }">
|
|
100
|
+
<span v-bind="tooltipProps">{{ value }}</span>
|
|
101
|
+
</template>
|
|
102
|
+
</v-tooltip>
|
|
103
|
+
</template>
|
|
104
|
+
</v-data-table>
|
|
98
105
|
</template>
|
|
@@ -10,6 +10,15 @@ const show = ref<boolean>(true);
|
|
|
10
10
|
function calc_margin(index: number): string {
|
|
11
11
|
return `${index * MARGIN_BETWEEN_SNACKERS + FIRST_SNACKER_MARGIN}px`;
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
function runAction(feedback: (typeof feedbackStore.feedbacks)[number]): void {
|
|
15
|
+
try {
|
|
16
|
+
feedback.action?.onClick();
|
|
17
|
+
} finally {
|
|
18
|
+
// The snackbar closes even when the action fails
|
|
19
|
+
feedbackStore.delete_feedback(feedback.id);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
13
22
|
</script>
|
|
14
23
|
|
|
15
24
|
<template>
|
|
@@ -62,9 +71,27 @@ function calc_margin(index: number): string {
|
|
|
62
71
|
</v-tooltip>
|
|
63
72
|
</v-col>
|
|
64
73
|
<v-spacer />
|
|
74
|
+
<v-col v-if="feedback.action" cols="auto">
|
|
75
|
+
<v-tooltip location="top" :text="feedback.action.label">
|
|
76
|
+
<template #activator="{ props }">
|
|
77
|
+
<v-btn
|
|
78
|
+
v-bind="props"
|
|
79
|
+
icon
|
|
80
|
+
variant="flat"
|
|
81
|
+
size="20"
|
|
82
|
+
:color="feedback.type"
|
|
83
|
+
data-testid="feedbackActionBtn"
|
|
84
|
+
@click.stop="runAction(feedback)"
|
|
85
|
+
>
|
|
86
|
+
<v-icon icon="mdi-pencil" size="20" color="white" />
|
|
87
|
+
</v-btn>
|
|
88
|
+
</template>
|
|
89
|
+
</v-tooltip>
|
|
90
|
+
</v-col>
|
|
65
91
|
<v-col cols="auto">
|
|
66
92
|
<v-btn
|
|
67
93
|
icon
|
|
94
|
+
data-testid="feedbackCloseBtn"
|
|
68
95
|
variant="flat"
|
|
69
96
|
size="20"
|
|
70
97
|
:color="feedback.type"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { formatCrs, formatCrsCode } from "@ogw_front/utils/crs";
|
|
3
|
+
import { useCrsStore } from "@ogw_front/stores/crs";
|
|
4
|
+
|
|
5
|
+
const crsStore = useCrsStore();
|
|
6
|
+
const label = computed<string>(() =>
|
|
7
|
+
crsStore.projectCrs
|
|
8
|
+
? `CRS: ${formatCrsCode(crsStore.projectCrs)} · ${crsStore.projectCrs.name}`
|
|
9
|
+
: "No CRS",
|
|
10
|
+
);
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<!-- Under the XYZ axes, drawn by the viewer in the bottom right corner -->
|
|
15
|
+
<v-btn
|
|
16
|
+
data-testid="projectCrs"
|
|
17
|
+
class="project-crs text-none"
|
|
18
|
+
size="small"
|
|
19
|
+
variant="tonal"
|
|
20
|
+
prepend-icon="mdi-earth"
|
|
21
|
+
:disabled="!crsStore.crsEditEnabled"
|
|
22
|
+
v-tooltip="formatCrs(crsStore.projectCrs)"
|
|
23
|
+
@click="crsStore.requestProjectCrsEdit()"
|
|
24
|
+
>
|
|
25
|
+
<span class="text-truncate">{{ label }}</span>
|
|
26
|
+
</v-btn>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<style scoped>
|
|
30
|
+
.project-crs {
|
|
31
|
+
position: absolute;
|
|
32
|
+
right: 16px;
|
|
33
|
+
bottom: 12px;
|
|
34
|
+
z-index: 1;
|
|
35
|
+
max-width: 360px;
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { formatCrs, formatCrsCode } from "@ogw_front/utils/crs";
|
|
2
3
|
import GlassCard from "@ogw_front/components/GlassCard.vue";
|
|
3
4
|
import { consola } from "consola";
|
|
4
5
|
import { middleTruncate } from "@ogw_front/utils/string";
|
|
5
6
|
import { useCopyToClipboard } from "@ogw_front/composables/copy_to_clipboard";
|
|
7
|
+
import { useCrsStore } from "@ogw_front/stores/crs";
|
|
6
8
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
9
|
+
import { useLiveDataItem } from "@ogw_front/composables/live_data_item";
|
|
7
10
|
import { useMenuStore } from "@ogw_front/stores/menu";
|
|
8
11
|
|
|
9
12
|
interface Props {
|
|
@@ -126,6 +129,13 @@ function formatId(id: string | undefined): string {
|
|
|
126
129
|
}
|
|
127
130
|
|
|
128
131
|
const formattedId = computed<string>(() => formatId(metaData.id));
|
|
132
|
+
|
|
133
|
+
const crsStore = useCrsStore();
|
|
134
|
+
// A model component shares the model CRS: the CRS row is only shown for a data
|
|
135
|
+
const isData = computed<boolean>(() => metaData.id !== undefined && metaData.modelId === undefined);
|
|
136
|
+
// The menu metadata is a snapshot taken when it opened: read the item live so a CRS edit shows at once
|
|
137
|
+
const liveItem = useLiveDataItem(() => (isData.value ? metaData.id : undefined));
|
|
138
|
+
const liveCrs = computed(() => liveItem.value?.crs ?? metaData.crs);
|
|
129
139
|
</script>
|
|
130
140
|
|
|
131
141
|
<template>
|
|
@@ -168,6 +178,26 @@ const formattedId = computed<string>(() => formatId(metaData.id));
|
|
|
168
178
|
class="ml-1"
|
|
169
179
|
/>
|
|
170
180
|
</v-col>
|
|
181
|
+
<v-col
|
|
182
|
+
v-if="isData"
|
|
183
|
+
class="mt-1 d-inline-flex align-center px-2 py-0.5 text-caption"
|
|
184
|
+
style="font-size: 0.6rem"
|
|
185
|
+
>
|
|
186
|
+
<span class="font-weight-black text-secondary mr-1">CRS</span>
|
|
187
|
+
<span class="id-text" data-testid="infoCrsValue">{{ formatCrsCode(liveCrs) }}</span>
|
|
188
|
+
<v-tooltip activator="parent" location="top">{{ formatCrs(liveCrs) }}</v-tooltip>
|
|
189
|
+
<v-btn
|
|
190
|
+
v-if="crsStore.crsEditEnabled"
|
|
191
|
+
data-testid="infoEditCrsBtn"
|
|
192
|
+
icon="mdi-pencil"
|
|
193
|
+
variant="text"
|
|
194
|
+
density="compact"
|
|
195
|
+
size="x-small"
|
|
196
|
+
color="white"
|
|
197
|
+
class="ml-1"
|
|
198
|
+
@click.stop="crsStore.requestCrsEdit(metaData.id)"
|
|
199
|
+
/>
|
|
200
|
+
</v-col>
|
|
171
201
|
|
|
172
202
|
<template v-if="componentItem">
|
|
173
203
|
<v-divider class="w-100 my-2" opacity="0.2" />
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { formatCrs, formatCrsCode } from "@ogw_front/utils/crs";
|
|
2
3
|
import ComponentRelations from "@ogw_front/components/Viewer/ObjectTree/Base/ComponentRelations.vue";
|
|
3
4
|
import type { DisplayItem } from "@ogw_front/composables/virtual_tree";
|
|
4
5
|
import { middleTruncate } from "@ogw_front/utils/string";
|
|
5
6
|
import { useClipboard } from "@vueuse/core";
|
|
7
|
+
import { useCrsStore } from "@ogw_front/stores/crs";
|
|
6
8
|
import { useFeedbackStore } from "@ogw_front/stores/feedback";
|
|
9
|
+
import { useLiveDataItem } from "@ogw_front/composables/live_data_item";
|
|
7
10
|
import { useResponsiveMiddleTruncate } from "@ogw_front/composables/responsive_middle_truncate";
|
|
8
11
|
|
|
9
12
|
const feedbackStore = useFeedbackStore();
|
|
@@ -12,10 +15,11 @@ const { copy } = useClipboard();
|
|
|
12
15
|
interface Props {
|
|
13
16
|
item: DisplayItem;
|
|
14
17
|
isLeaf?: boolean;
|
|
18
|
+
showCrs?: boolean;
|
|
15
19
|
modelId?: string;
|
|
16
20
|
}
|
|
17
21
|
|
|
18
|
-
const { item, isLeaf, modelId = "" } = defineProps<Props>();
|
|
22
|
+
const { item, isLeaf, showCrs = false, modelId = "" } = defineProps<Props>();
|
|
19
23
|
|
|
20
24
|
interface Emits {
|
|
21
25
|
contextmenu: [event: MouseEvent];
|
|
@@ -55,6 +59,40 @@ const tooltipTitle = computed<string>(() =>
|
|
|
55
59
|
),
|
|
56
60
|
);
|
|
57
61
|
|
|
62
|
+
const crsStore = useCrsStore();
|
|
63
|
+
const tooltipOpen = ref(false);
|
|
64
|
+
// Only top-level data carry a CRS: their stored item is read live, and only while the
|
|
65
|
+
// Tooltip is open, so the rows of a long tree do not each keep a database query
|
|
66
|
+
const dataItem = useLiveDataItem(() =>
|
|
67
|
+
showCrs && tooltipOpen.value ? actualItem.value.id : undefined,
|
|
68
|
+
);
|
|
69
|
+
const crsLabel = computed<string>(
|
|
70
|
+
() =>
|
|
71
|
+
middleTruncate(
|
|
72
|
+
formatCrs(dataItem.value?.crs),
|
|
73
|
+
TOOLTIP_NAME_MAX_LENGTH,
|
|
74
|
+
TOOLTIP_NAME_START_CHARS,
|
|
75
|
+
TOOLTIP_NAME_END_CHARS,
|
|
76
|
+
) ?? "",
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// Read from the store map: one database query for the whole tree, not one per row
|
|
80
|
+
const mismatched = computed(() => showCrs && crsStore.mismatchedCrs.has(actualItem.value.id));
|
|
81
|
+
const mismatchTooltip = computed<string>(() => {
|
|
82
|
+
const project = formatCrsCode(crsStore.projectCrs);
|
|
83
|
+
const crs = crsStore.mismatchedCrs.get(actualItem.value.id);
|
|
84
|
+
return crs === undefined
|
|
85
|
+
? `No CRS, project in ${project}. Georeference it to show it on the map.`
|
|
86
|
+
: `In ${formatCrsCode(crs)}, project in ${project}. Convert it to show it on the map.`;
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// The warning opens the CRS dialog of the data, when the app hosts it
|
|
90
|
+
function editCrs(): void {
|
|
91
|
+
if (crsStore.crsEditEnabled) {
|
|
92
|
+
crsStore.requestCrsEdit(actualItem.value.id);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
58
96
|
const tooltipDisabled = computed<boolean>(() => {
|
|
59
97
|
if (actualItem.value.category !== undefined) {
|
|
60
98
|
return false;
|
|
@@ -78,6 +116,7 @@ async function copyToClipboard(text: string, label: string): Promise<void> {
|
|
|
78
116
|
class="tree-item-label-container w-100"
|
|
79
117
|
>
|
|
80
118
|
<v-tooltip
|
|
119
|
+
v-model="tooltipOpen"
|
|
81
120
|
:disabled="tooltipDisabled"
|
|
82
121
|
location="right"
|
|
83
122
|
open-delay="400"
|
|
@@ -129,6 +168,22 @@ async function copyToClipboard(text: string, label: string): Promise<void> {
|
|
|
129
168
|
<v-icon size="12">mdi-content-copy</v-icon>
|
|
130
169
|
</v-btn>
|
|
131
170
|
</span>
|
|
171
|
+
<span v-if="showCrs" class="text-caption d-flex align-center">
|
|
172
|
+
<strong class="text-white mr-1">CRS:</strong>
|
|
173
|
+
<span data-testid="tooltipCrsValue">{{ crsLabel }}</span>
|
|
174
|
+
<v-btn
|
|
175
|
+
v-if="crsStore.crsEditEnabled"
|
|
176
|
+
data-testid="editCrsBtn"
|
|
177
|
+
icon
|
|
178
|
+
variant="text"
|
|
179
|
+
density="compact"
|
|
180
|
+
class="ml-1 text-white"
|
|
181
|
+
style="width: 18px; height: 18px; min-width: 18px; min-height: 18px"
|
|
182
|
+
@click.stop="crsStore.requestCrsEdit(actualItem.id)"
|
|
183
|
+
>
|
|
184
|
+
<v-icon size="12">mdi-pencil</v-icon>
|
|
185
|
+
</v-btn>
|
|
186
|
+
</span>
|
|
132
187
|
<span v-if="actualItem.is_active !== undefined" class="text-caption d-flex align-center">
|
|
133
188
|
<strong class="text-white mr-1">Status:</strong>
|
|
134
189
|
<i class="ml-1">{{ actualItem.is_active ? "Active" : "Inactive" }}</i>
|
|
@@ -140,6 +195,21 @@ async function copyToClipboard(text: string, label: string): Promise<void> {
|
|
|
140
195
|
/>
|
|
141
196
|
</div>
|
|
142
197
|
</v-tooltip>
|
|
198
|
+
<v-tooltip v-if="mismatched" location="right">
|
|
199
|
+
<template #activator="{ props: warningProps }">
|
|
200
|
+
<v-icon
|
|
201
|
+
v-bind="warningProps"
|
|
202
|
+
data-testid="crsMismatchIcon"
|
|
203
|
+
icon="mdi-alert"
|
|
204
|
+
color="warning"
|
|
205
|
+
size="14"
|
|
206
|
+
class="ml-1 flex-shrink-0"
|
|
207
|
+
:class="{ 'cursor-pointer': crsStore.crsEditEnabled }"
|
|
208
|
+
@click.stop="editCrs"
|
|
209
|
+
/>
|
|
210
|
+
</template>
|
|
211
|
+
{{ mismatchTooltip }}
|
|
212
|
+
</v-tooltip>
|
|
143
213
|
</div>
|
|
144
214
|
</template>
|
|
145
215
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
// oxlint-disable max-dependencies
|
|
2
3
|
import {
|
|
3
4
|
type ViewerIdResult,
|
|
4
5
|
useOverlappingPicker,
|
|
5
6
|
} from "@ogw_front/composables/use_overlapping_picker";
|
|
6
7
|
import OverlappingObjectsPicker from "@ogw_front/components/Viewer/OverlappingObjectsPicker.vue";
|
|
8
|
+
import ProjectCrs from "@ogw_front/components/ProjectCrs.vue";
|
|
7
9
|
import ToolActiveChip from "@ogw_front/components/Viewer/ToolActiveChip.vue";
|
|
8
10
|
import type { TreeMenuPayload } from "@ogw_front/utils/treeview";
|
|
9
11
|
import ViewerContextMenu from "@ogw_front/components/Viewer/ContextMenu/ContextMenu.vue";
|
|
@@ -106,6 +108,8 @@ defineExpose({ get_viewer_id });
|
|
|
106
108
|
:container-height="containerHeight"
|
|
107
109
|
/>
|
|
108
110
|
|
|
111
|
+
<ProjectCrs />
|
|
112
|
+
|
|
109
113
|
<OverlappingObjectsPicker
|
|
110
114
|
:display-intermediate="displayIntermediate"
|
|
111
115
|
:intermediate-items="intermediateItems"
|
|
@@ -36,7 +36,8 @@ function apply(): void {
|
|
|
36
36
|
>
|
|
37
37
|
<v-container class="pa-3 py-1">
|
|
38
38
|
<v-row dense>
|
|
39
|
-
|
|
39
|
+
<!-- ToolPanel clips its content: leave room above the slider for its thumb label -->
|
|
40
|
+
<v-col cols="12" class="pt-7 pb-1">
|
|
40
41
|
<v-slider
|
|
41
42
|
v-model="zScale"
|
|
42
43
|
:min="1"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type DataItem, useDataStore } from "@ogw_front/stores/data";
|
|
2
|
+
import type { EffectScope, MaybeRefOrGetter, ShallowRef } from "vue";
|
|
3
|
+
|
|
4
|
+
// Live view of a data item whose id can change: tree labels are reused by the virtual list,
|
|
5
|
+
// And the info card shows whichever object the menu was last opened on.
|
|
6
|
+
export function useLiveDataItem(
|
|
7
|
+
id: MaybeRefOrGetter<string | undefined>,
|
|
8
|
+
): ShallowRef<DataItem | undefined> {
|
|
9
|
+
const dataStore = useDataStore();
|
|
10
|
+
const item = shallowRef<DataItem | undefined>(undefined);
|
|
11
|
+
let itemScope: EffectScope | undefined = undefined;
|
|
12
|
+
|
|
13
|
+
watch(
|
|
14
|
+
() => toValue(id),
|
|
15
|
+
(newId) => {
|
|
16
|
+
itemScope?.stop();
|
|
17
|
+
itemScope = undefined;
|
|
18
|
+
item.value = undefined;
|
|
19
|
+
if (newId === undefined) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
itemScope = effectScope();
|
|
23
|
+
itemScope.run(() => {
|
|
24
|
+
const liveItem = dataStore.refItem(newId);
|
|
25
|
+
watch(
|
|
26
|
+
liveItem,
|
|
27
|
+
(value) => {
|
|
28
|
+
item.value = value;
|
|
29
|
+
},
|
|
30
|
+
{ immediate: true },
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
{ immediate: true },
|
|
35
|
+
);
|
|
36
|
+
onScopeDispose(() => itemScope?.stop());
|
|
37
|
+
|
|
38
|
+
return item;
|
|
39
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import back_schemas
|
|
1
|
+
import back_schemas, {
|
|
2
|
+
type CRSList,
|
|
3
|
+
} from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
2
4
|
import fileDownload from "js-file-download";
|
|
3
5
|
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
4
6
|
|
|
@@ -9,8 +11,10 @@ import type { CameraSnapshot } from "@ogw_internal/stores/hybrid_viewer/camera";
|
|
|
9
11
|
import type { ModelComponentRecord } from "@ogw_front/stores/data_helpers/mesh.js";
|
|
10
12
|
import type { ModelComponentRelationRecord } from "@ogw_front/stores/data.js";
|
|
11
13
|
import { importWorkflowFromSnapshot } from "@ogw_front/utils/import_workflow";
|
|
14
|
+
import { oldestCrs } from "@ogw_front/utils/crs";
|
|
12
15
|
import { useAppStore } from "@ogw_front/stores/app";
|
|
13
16
|
import { useBackStore } from "@ogw_front/stores/back";
|
|
17
|
+
import { useCrsStore } from "@ogw_front/stores/crs";
|
|
14
18
|
import { useFeedbackStore } from "@ogw_front/stores/feedback";
|
|
15
19
|
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
16
20
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
@@ -26,6 +30,7 @@ interface ProjectSnapshot {
|
|
|
26
30
|
data?: ProjectDataSnapshot;
|
|
27
31
|
hybridViewer?: CameraSnapshot;
|
|
28
32
|
dataStyle?: DataStyleSnapshot;
|
|
33
|
+
crs?: { projectCrs?: CRSList };
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
async function exportProject(): Promise<{ result: Blob }> {
|
|
@@ -73,6 +78,7 @@ async function importProject(file: File): Promise<void> {
|
|
|
73
78
|
const dataStore = useDataStore();
|
|
74
79
|
const treeviewStore = useTreeviewStore();
|
|
75
80
|
const hybridViewerStore = useHybridViewerStore();
|
|
81
|
+
const crsStore = useCrsStore();
|
|
76
82
|
|
|
77
83
|
await viewerStore.ws_connect();
|
|
78
84
|
|
|
@@ -84,6 +90,7 @@ async function importProject(file: File): Promise<void> {
|
|
|
84
90
|
treeviewStore.clear();
|
|
85
91
|
await dataStore.clear();
|
|
86
92
|
hybridViewerStore.clear();
|
|
93
|
+
crsStore.reset();
|
|
87
94
|
|
|
88
95
|
const importProjectSchema = back_schemas.opengeodeweb_back.import_project;
|
|
89
96
|
const form = new FormData();
|
|
@@ -108,6 +115,14 @@ async function importProject(file: File): Promise<void> {
|
|
|
108
115
|
|
|
109
116
|
const items = snapshot.data?.items ?? [];
|
|
110
117
|
await importWorkflowFromSnapshot(items);
|
|
118
|
+
// After every data item is added: on partial data the project CRS would follow them.
|
|
119
|
+
// A project saved without a project CRS takes the one of its oldest data, read in the
|
|
120
|
+
// Snapshot: the stored items carry the import time as creation date
|
|
121
|
+
crsStore.importStores(
|
|
122
|
+
snapshot.crs?.projectCrs === undefined
|
|
123
|
+
? { projectCrs: oldestCrs(snapshot.data?.items ?? []) }
|
|
124
|
+
: snapshot.crs,
|
|
125
|
+
);
|
|
111
126
|
await hybridViewerStore.importStores(snapshot.hybridViewer);
|
|
112
127
|
if (snapshot.dataStyle !== undefined) {
|
|
113
128
|
await dataStyleStore.importStores(snapshot.dataStyle);
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import back_schemas, {
|
|
2
|
+
type CRSList,
|
|
3
|
+
} from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
4
|
+
import { oldestCrs, sameCrs } from "@ogw_front/utils/crs";
|
|
5
|
+
import { useBackStore } from "@ogw_front/stores/back";
|
|
6
|
+
import { useDataStore } from "@ogw_front/stores/data";
|
|
7
|
+
|
|
8
|
+
// Session cache of the available CRS, the project CRS, and the channel the shared components use to ask the host app for a CRS edit
|
|
9
|
+
// oxlint-disable-next-line max-lines-per-function, max-statements
|
|
10
|
+
export const useCrsStore = defineStore("crs", () => {
|
|
11
|
+
const backStore = useBackStore();
|
|
12
|
+
// OpenGeode geosciences lists the same geographic CRS for 2D and 3D data: one list for all types
|
|
13
|
+
let geographicListPromise: Promise<CRSList[]> | undefined = undefined;
|
|
14
|
+
const crsEditEnabled = ref(false);
|
|
15
|
+
const crsEditRequest = ref<string | undefined>(undefined);
|
|
16
|
+
const dataStore = useDataStore();
|
|
17
|
+
const crsItems = dataStore.refCrsItems();
|
|
18
|
+
const projectCrs = ref<CRSList | undefined>(undefined);
|
|
19
|
+
const projectCrsEditRequest = ref(false);
|
|
20
|
+
|
|
21
|
+
// The project follows its data: once every georeferenced data is in one CRS, it is the project
|
|
22
|
+
// CRS. Data already mixed before any project CRS: the oldest one is the reference
|
|
23
|
+
watch(
|
|
24
|
+
() => {
|
|
25
|
+
const georeferenced = crsItems.value.filter((item) => item.crs !== undefined);
|
|
26
|
+
const [first] = georeferenced;
|
|
27
|
+
if (first === undefined) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
if (georeferenced.every((item) => sameCrs(item.crs, first.crs))) {
|
|
31
|
+
return first.crs;
|
|
32
|
+
}
|
|
33
|
+
return projectCrs.value ?? oldestCrs(georeferenced);
|
|
34
|
+
},
|
|
35
|
+
(reference) => {
|
|
36
|
+
if (reference !== undefined && !sameCrs(reference, projectCrs.value)) {
|
|
37
|
+
projectCrs.value = reference;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{ immediate: true },
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
// Data without CRS are listed too (value undefined): they could not follow the project
|
|
44
|
+
const mismatchedCrs = computed(() => {
|
|
45
|
+
const project = projectCrs.value;
|
|
46
|
+
const mismatched = new Map<string, CRSList | undefined>();
|
|
47
|
+
for (const item of crsItems.value) {
|
|
48
|
+
if (project !== undefined && !sameCrs(item.crs, project)) {
|
|
49
|
+
mismatched.set(item.id, item.crs);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return mismatched;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
async function fetchGeographicList(geodeObjectType: string): Promise<CRSList[]> {
|
|
56
|
+
try {
|
|
57
|
+
const response = await backStore.request({
|
|
58
|
+
schema: back_schemas.opengeodeweb_back.crs.geographic_list,
|
|
59
|
+
params: { geode_object_type: geodeObjectType },
|
|
60
|
+
});
|
|
61
|
+
if (response?.crs_list !== undefined) {
|
|
62
|
+
return response.crs_list;
|
|
63
|
+
}
|
|
64
|
+
} catch {
|
|
65
|
+
// The back store already reports the error to the user
|
|
66
|
+
}
|
|
67
|
+
// A failed request is not cached: the next call retries
|
|
68
|
+
geographicListPromise = undefined;
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function geographicList(geodeObjectType: string): Promise<CRSList[]> {
|
|
73
|
+
// The promise is cached, so dialogs opened together share a single request.
|
|
74
|
+
// The back still checks each CRS against the list of the data dimension
|
|
75
|
+
geographicListPromise ??= fetchGeographicList(geodeObjectType);
|
|
76
|
+
const list = await geographicListPromise;
|
|
77
|
+
return list;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function enableCrsEdit(): void {
|
|
81
|
+
crsEditEnabled.value = true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function requestCrsEdit(id: string): void {
|
|
85
|
+
crsEditRequest.value = id;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function clearCrsEditRequest(): void {
|
|
89
|
+
crsEditRequest.value = undefined;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function setProjectCrs(crs: CRSList): void {
|
|
93
|
+
projectCrs.value = crs;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function requestProjectCrsEdit(): void {
|
|
97
|
+
projectCrsEditRequest.value = true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function clearProjectCrsEditRequest(): void {
|
|
101
|
+
projectCrsEditRequest.value = false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// A new project: its data set the project CRS again
|
|
105
|
+
function reset(): void {
|
|
106
|
+
projectCrs.value = undefined;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function exportStores(): { projectCrs?: CRSList } {
|
|
110
|
+
return { projectCrs: projectCrs.value };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Called once the project data is imported: a project saved without it falls back to its oldest data
|
|
114
|
+
function importStores(snapshot: { projectCrs?: CRSList } | undefined): void {
|
|
115
|
+
projectCrs.value = snapshot?.projectCrs ?? oldestCrs(crsItems.value);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
crsItems,
|
|
120
|
+
geographicList,
|
|
121
|
+
crsEditEnabled,
|
|
122
|
+
enableCrsEdit,
|
|
123
|
+
crsEditRequest,
|
|
124
|
+
requestCrsEdit,
|
|
125
|
+
clearCrsEditRequest,
|
|
126
|
+
projectCrs,
|
|
127
|
+
mismatchedCrs,
|
|
128
|
+
setProjectCrs,
|
|
129
|
+
projectCrsEditRequest,
|
|
130
|
+
requestProjectCrsEdit,
|
|
131
|
+
clearProjectCrsEditRequest,
|
|
132
|
+
reset,
|
|
133
|
+
exportStores,
|
|
134
|
+
importStores,
|
|
135
|
+
};
|
|
136
|
+
});
|
package/app/stores/data.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// oxlint-disable eslint/max-lines
|
|
2
2
|
// Third party imports
|
|
3
|
+
import type { CRSList } from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
3
4
|
import type { Table } from "dexie";
|
|
4
5
|
import { useObservable } from "@vueuse/rxjs";
|
|
5
6
|
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
@@ -22,8 +23,12 @@ interface DataItem {
|
|
|
22
23
|
created_at: string;
|
|
23
24
|
is_viewable?: boolean;
|
|
24
25
|
binary_light_viewable?: string;
|
|
26
|
+
crs?: CRSList;
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
// What the CRS features read of a data: light to copy on each change
|
|
30
|
+
type CrsItem = Pick<DataItem, "id" | "name" | "crs" | "created_at">;
|
|
31
|
+
|
|
27
32
|
interface ModelComponentInput {
|
|
28
33
|
geode_id: string;
|
|
29
34
|
type: string;
|
|
@@ -43,6 +48,9 @@ interface NewDataItem {
|
|
|
43
48
|
geode_object_type: string;
|
|
44
49
|
is_viewable?: boolean;
|
|
45
50
|
binary_light_viewable?: string;
|
|
51
|
+
crs?: CRSList;
|
|
52
|
+
// Set on saved data: kept by the project snapshot
|
|
53
|
+
created_at?: string;
|
|
46
54
|
mesh_components?: ModelComponentInput[];
|
|
47
55
|
collection_components?: ModelComponentInput[];
|
|
48
56
|
nb_vertices?: number;
|
|
@@ -152,6 +160,17 @@ export const useDataStore = defineStore("data", () => {
|
|
|
152
160
|
},
|
|
153
161
|
);
|
|
154
162
|
}
|
|
163
|
+
// The CRS features only need these fields: the geometry stays out of the copies made on each change
|
|
164
|
+
function refCrsItems(): Ref<CrsItem[]> {
|
|
165
|
+
return useObservable(
|
|
166
|
+
liveObservable(async () => {
|
|
167
|
+
const items = await data_db.toArray();
|
|
168
|
+
return items.map(({ id, name, crs, created_at }) => ({ id, name, crs, created_at }));
|
|
169
|
+
}),
|
|
170
|
+
{ initialValue: [] as CrsItem[] },
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
155
174
|
function refAllItems(): Ref<DataItem[]> {
|
|
156
175
|
return useObservable(
|
|
157
176
|
liveObservable(async () => {
|
|
@@ -219,6 +238,9 @@ export const useDataStore = defineStore("data", () => {
|
|
|
219
238
|
if (new_item.binary_light_viewable !== undefined && new_item.binary_light_viewable !== null) {
|
|
220
239
|
itemData.binary_light_viewable = new_item.binary_light_viewable;
|
|
221
240
|
}
|
|
241
|
+
if (new_item.crs !== undefined) {
|
|
242
|
+
itemData.crs = new_item.crs;
|
|
243
|
+
}
|
|
222
244
|
const id = await data_db.put(itemData);
|
|
223
245
|
return id;
|
|
224
246
|
}
|
|
@@ -375,6 +397,7 @@ export const useDataStore = defineStore("data", () => {
|
|
|
375
397
|
}
|
|
376
398
|
return {
|
|
377
399
|
refAllItems,
|
|
400
|
+
refCrsItems,
|
|
378
401
|
refRegisteredItems,
|
|
379
402
|
isRegistered,
|
|
380
403
|
item,
|
|
@@ -415,4 +438,4 @@ export const useDataStore = defineStore("data", () => {
|
|
|
415
438
|
};
|
|
416
439
|
});
|
|
417
440
|
|
|
418
|
-
export type { DataItem, NewDataItem, ModelComponentInput, ModelComponentRelationRecord };
|
|
441
|
+
export type { CrsItem, DataItem, NewDataItem, ModelComponentInput, ModelComponentRelationRecord };
|
package/app/stores/feedback.ts
CHANGED
|
@@ -5,6 +5,11 @@ const DEFAULT_FEEDBACKS_TIMEOUT_SECONDS = 10;
|
|
|
5
5
|
|
|
6
6
|
type FeedbackType = "error" | "success" | "warning";
|
|
7
7
|
|
|
8
|
+
interface FeedbackAction {
|
|
9
|
+
label: string;
|
|
10
|
+
onClick: () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
interface Feedback {
|
|
9
14
|
id: string;
|
|
10
15
|
type: FeedbackType;
|
|
@@ -12,6 +17,7 @@ interface Feedback {
|
|
|
12
17
|
route?: string;
|
|
13
18
|
name?: string;
|
|
14
19
|
description?: string;
|
|
20
|
+
action?: FeedbackAction;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
export const useFeedbackStore = defineStore("feedback", {
|
|
@@ -35,23 +41,25 @@ export const useFeedbackStore = defineStore("feedback", {
|
|
|
35
41
|
this.delete_feedback(feedbackId);
|
|
36
42
|
}, this.feedbacks_timeout_miliseconds);
|
|
37
43
|
},
|
|
38
|
-
add_success(description: string) {
|
|
44
|
+
add_success(description: string, action?: FeedbackAction) {
|
|
39
45
|
const feedbackId = uuidv4();
|
|
40
46
|
this.feedbacks.push({
|
|
41
47
|
id: feedbackId,
|
|
42
48
|
type: "success",
|
|
43
49
|
description,
|
|
50
|
+
...(action === undefined ? {} : { action }),
|
|
44
51
|
});
|
|
45
52
|
setTimeout(() => {
|
|
46
53
|
this.delete_feedback(feedbackId);
|
|
47
54
|
}, this.feedbacks_timeout_miliseconds);
|
|
48
55
|
},
|
|
49
|
-
add_warning(description: string) {
|
|
56
|
+
add_warning(description: string, action?: FeedbackAction) {
|
|
50
57
|
const feedbackId = uuidv4();
|
|
51
58
|
this.feedbacks.push({
|
|
52
59
|
id: feedbackId,
|
|
53
60
|
type: "warning",
|
|
54
61
|
description,
|
|
62
|
+
...(action === undefined ? {} : { action }),
|
|
55
63
|
});
|
|
56
64
|
setTimeout(() => {
|
|
57
65
|
this.delete_feedback(feedbackId);
|
|
@@ -65,3 +73,5 @@ export const useFeedbackStore = defineStore("feedback", {
|
|
|
65
73
|
},
|
|
66
74
|
},
|
|
67
75
|
});
|
|
76
|
+
|
|
77
|
+
export type { FeedbackAction };
|
|
@@ -2,13 +2,10 @@ import {
|
|
|
2
2
|
type ViewStreamLike,
|
|
3
3
|
useHybridViewerViewport,
|
|
4
4
|
} from "@ogw_internal/stores/hybrid_viewer/viewport";
|
|
5
|
-
import {
|
|
6
|
-
applySnapshot,
|
|
7
|
-
getCameraOptions,
|
|
8
|
-
useHybridViewerCamera,
|
|
9
|
-
} from "@ogw_internal/stores/hybrid_viewer/camera";
|
|
5
|
+
import { applySnapshot, useHybridViewerCamera } from "@ogw_internal/stores/hybrid_viewer/camera";
|
|
10
6
|
import { BACKGROUND_COLOR } from "@ogw_internal/stores/hybrid_viewer/constants";
|
|
11
7
|
import type { CameraOptions } from "@ogw_internal/stores/hybrid_viewer/vtk_types";
|
|
8
|
+
import { getCameraOptions } from "@ogw_internal/stores/hybrid_viewer/camera_animation";
|
|
12
9
|
import { useHybridViewerBrightness } from "@ogw_internal/stores/hybrid_viewer/brightness";
|
|
13
10
|
import { useHybridViewerCore } from "@ogw_internal/stores/hybrid_viewer/core";
|
|
14
11
|
import { useHybridViewerFilters } from "@ogw_internal/stores/hybrid_viewer/filters";
|
package/app/utils/crs.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CrsItem, NewDataItem } from "@ogw_front/stores/data";
|
|
2
|
+
import type { CRSList } from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
3
|
+
|
|
4
|
+
function formatCrs(crs: CRSList | undefined): string {
|
|
5
|
+
return crs ? `${crs.authority}:${crs.code} — ${crs.name}` : "None";
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Code alone, for narrow places: the full name goes in a tooltip
|
|
9
|
+
function formatCrsCode(crs: CRSList | undefined): string {
|
|
10
|
+
return crs ? `${crs.authority}:${crs.code}` : "None";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// The name is only a label: two CRS are the same when their authority code is
|
|
14
|
+
function sameCrs(left: CRSList | undefined, right: CRSList | undefined): boolean {
|
|
15
|
+
return (
|
|
16
|
+
left !== undefined &&
|
|
17
|
+
right !== undefined &&
|
|
18
|
+
left.authority === right.authority &&
|
|
19
|
+
left.code === right.code
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Same CRS, or both still in local coordinates
|
|
24
|
+
function sameCrsState(left: CRSList | undefined, right: CRSList | undefined): boolean {
|
|
25
|
+
return (left === undefined && right === undefined) || sameCrs(left, right);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// The CRS of the oldest georeferenced data: the project CRS of a project saved before it was stored
|
|
29
|
+
function oldestCrs(
|
|
30
|
+
items: readonly Pick<CrsItem, "crs" | "created_at">[] | readonly NewDataItem[],
|
|
31
|
+
): CRSList | undefined {
|
|
32
|
+
return items
|
|
33
|
+
.filter((item) => item.crs !== undefined)
|
|
34
|
+
.toSorted((left, right) => (left.created_at ?? "").localeCompare(right.created_at ?? ""))[0]
|
|
35
|
+
?.crs;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { formatCrs, formatCrsCode, oldestCrs, sameCrs, sameCrsState };
|
|
@@ -162,21 +162,33 @@ async function importWorkflowFromSnapshot(items: readonly NewDataItem[]): Promis
|
|
|
162
162
|
return ids;
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
//
|
|
166
|
-
async function
|
|
167
|
-
|
|
165
|
+
// Reloads the viewer object under the same id with its stored style, after the back rewrote its files.
|
|
166
|
+
async function reloadObject(
|
|
167
|
+
id: string,
|
|
168
|
+
{ rebuildActor = false }: { rebuildActor?: boolean } = {},
|
|
169
|
+
): Promise<void> {
|
|
168
170
|
const dataStore = useDataStore();
|
|
169
171
|
const dataStyleStore = useDataStyleStore();
|
|
170
172
|
const hybridViewerStore = useHybridViewerStore();
|
|
171
|
-
await backStore.request({
|
|
172
|
-
schema: back_schemas.opengeodeweb_back.apply_time_series,
|
|
173
|
-
params: { id, filename },
|
|
174
|
-
});
|
|
175
173
|
const item = await dataStore.item(id);
|
|
176
174
|
await dataStore.deregisterObject(id);
|
|
177
175
|
await dataStore.registerObject(id, item.name ?? id);
|
|
176
|
+
// Only when the geometry moved: the local actor is rebuilt from the stored light viewable
|
|
177
|
+
if (rebuildActor) {
|
|
178
|
+
await hybridViewerStore.addItem(id);
|
|
179
|
+
}
|
|
178
180
|
await dataStyleStore.applyDefaultStyle(id);
|
|
179
181
|
await hybridViewerStore.remoteRender();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// The time series only adds attributes to the model, so the viewer object is reloaded.
|
|
185
|
+
async function applyTimeSeriesWorkflow(filename: string, id: string): Promise<string> {
|
|
186
|
+
const backStore = useBackStore();
|
|
187
|
+
await backStore.request({
|
|
188
|
+
schema: back_schemas.opengeodeweb_back.apply_time_series,
|
|
189
|
+
params: { id, filename },
|
|
190
|
+
});
|
|
191
|
+
await reloadObject(id);
|
|
180
192
|
return id;
|
|
181
193
|
}
|
|
182
194
|
|
|
@@ -186,4 +198,5 @@ export {
|
|
|
186
198
|
importWorkflowFromSnapshot,
|
|
187
199
|
importItem,
|
|
188
200
|
applyTimeSeriesWorkflow,
|
|
201
|
+
reloadObject,
|
|
189
202
|
};
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
SHORT_ANIMATION_DURATION,
|
|
5
5
|
animateCamera,
|
|
6
6
|
computeAnimationDuration,
|
|
7
|
+
getCameraOptions,
|
|
7
8
|
} from "./camera_animation";
|
|
8
9
|
import { requireRenderWindow, useHybridViewerCore } from "./core";
|
|
9
10
|
import { dot } from "@kitware/vtk.js/Common/Core/Math";
|
|
@@ -60,17 +61,6 @@ function getImageStyle(): CSSStyleDeclaration | undefined {
|
|
|
60
61
|
return bgImage instanceof HTMLImageElement ? bgImage.style : undefined;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
function getCameraOptions(camera: vtkCamera): CameraOptions {
|
|
64
|
-
return {
|
|
65
|
-
focal_point: [...(camera.getFocalPoint() ?? [0, 0, 0])] as Vector3,
|
|
66
|
-
view_up: [...(camera.getViewUp() ?? [0, 0, 0])] as Vector3,
|
|
67
|
-
position: [...(camera.getPosition() ?? [0, 0, 0])] as Vector3,
|
|
68
|
-
view_angle: camera.getViewAngle(),
|
|
69
|
-
clipping_range: [...(camera.getClippingRange() ?? [0, 0])] as [number, number],
|
|
70
|
-
distance: camera.getDistance(),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
64
|
function applyCameraOptions(
|
|
75
65
|
camera: vtkCamera | undefined,
|
|
76
66
|
options: Partial<CameraOptions> | undefined,
|
|
@@ -321,7 +311,6 @@ export {
|
|
|
321
311
|
applyCameraOptions,
|
|
322
312
|
applySnapshot,
|
|
323
313
|
centerCameraOnPosition,
|
|
324
|
-
getCameraOptions,
|
|
325
314
|
useHybridViewerCamera,
|
|
326
315
|
};
|
|
327
316
|
export type { CameraSnapshot };
|
|
@@ -52,6 +52,17 @@ function slerp(from: Vector3, target: Vector3, ratio: number, mid?: Vector3): Ve
|
|
|
52
52
|
];
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
function getCameraOptions(camera: vtkCamera): CameraOptions {
|
|
56
|
+
return {
|
|
57
|
+
focal_point: [...(camera.getFocalPoint() ?? [0, 0, 0])] as Vector3,
|
|
58
|
+
view_up: [...(camera.getViewUp() ?? [0, 0, 0])] as Vector3,
|
|
59
|
+
position: [...(camera.getPosition() ?? [0, 0, 0])] as Vector3,
|
|
60
|
+
view_angle: camera.getViewAngle(),
|
|
61
|
+
clipping_range: [...(camera.getClippingRange() ?? [0, 0])] as [number, number],
|
|
62
|
+
distance: camera.getDistance(),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
55
66
|
function computeAnimationDuration(startState: CameraOptions, targetState: CameraOptions): number {
|
|
56
67
|
const startDir = vecNormalize(vecSub(startState.position, startState.focal_point));
|
|
57
68
|
const targetDir = vecNormalize(vecSub(targetState.position, targetState.focal_point));
|
|
@@ -145,4 +156,5 @@ export {
|
|
|
145
156
|
SHORT_ANIMATION_DURATION,
|
|
146
157
|
animateCamera,
|
|
147
158
|
computeAnimationDuration,
|
|
159
|
+
getCameraOptions,
|
|
148
160
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ACTOR_COLOR, RGB_MAX } from "./constants";
|
|
2
|
-
import type { HybridDb, vtkActor as VtkActorInstance } from "./vtk_types";
|
|
2
|
+
import type { HybridDb, vtkActor as VtkActorInstance, vtkCamera } from "./vtk_types";
|
|
3
3
|
import { requireRenderWindow, useHybridViewerCore } from "./core";
|
|
4
4
|
import viewer_schemas, {
|
|
5
5
|
type ViewerSetBackgroundColorParams,
|
|
6
6
|
} from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
7
7
|
import { base64ToArrayBuffer } from "./base64";
|
|
8
|
+
import { getCameraOptions } from "./camera_animation";
|
|
8
9
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
9
10
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
10
11
|
import { newInstance as vtkActor } from "@kitware/vtk.js/Rendering/Core/Actor";
|
|
@@ -30,6 +31,15 @@ async function setBackgroundColor(color: ViewerSetBackgroundColorParams["color"]
|
|
|
30
31
|
await remoteRender();
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
// The actors are stretched along z around the origin: translate the camera along z so the point it looks at stays under it, keeping the user's view instead of jumping back to the whole scene.
|
|
35
|
+
function followZScaling(camera: vtkCamera, ratio: number): void {
|
|
36
|
+
const [focalX, focalY, focalZ] = camera.getFocalPoint();
|
|
37
|
+
const [positionX, positionY, positionZ] = camera.getPosition();
|
|
38
|
+
const offset = focalZ * (ratio - 1);
|
|
39
|
+
camera.setFocalPoint(focalX, focalY, focalZ + offset);
|
|
40
|
+
camera.setPosition(positionX, positionY, positionZ + offset);
|
|
41
|
+
}
|
|
42
|
+
|
|
33
43
|
// Shared via createSharedComposable (rather than merged into the parent hybridViewer store) so sibling slices, e.g. camera.ts and ruler.ts, can read hybridDb/setZScaling directly without importing the parent store and creating a cycle. A Pinia store would work too but its $id/$patch/... properties would leak into the composed store's spread and collapse its inferred type.
|
|
34
44
|
const useHybridViewerScene = createSharedComposable(() => {
|
|
35
45
|
const hybridDb = reactive<HybridDb>({});
|
|
@@ -59,12 +69,14 @@ const useHybridViewerScene = createSharedComposable(() => {
|
|
|
59
69
|
const property = actor.getProperty();
|
|
60
70
|
property.setColor(ACTOR_COLOR);
|
|
61
71
|
actor.setMapper(mapper);
|
|
72
|
+
// The scene z-scaling also applies to actors added after it was set
|
|
73
|
+
actor.setScale(1, 1, zScale.value);
|
|
62
74
|
const renderer = genericRenderWindow.value.getRenderer();
|
|
75
|
+
// Replacing an actor keeps the camera where the user left it
|
|
76
|
+
const isFirst = !hybridDb[id] && renderer.getActors().length === 0;
|
|
63
77
|
if (hybridDb[id]) {
|
|
64
78
|
renderer.removeActor(hybridDb[id].actor);
|
|
65
79
|
}
|
|
66
|
-
const actors = renderer.getActors();
|
|
67
|
-
const isFirst = actors.length === 0;
|
|
68
80
|
renderer.addActor(actor);
|
|
69
81
|
if (isFirst) {
|
|
70
82
|
renderer.resetCamera();
|
|
@@ -100,6 +112,7 @@ const useHybridViewerScene = createSharedComposable(() => {
|
|
|
100
112
|
|
|
101
113
|
async function setZScaling(z_scale: number): Promise<void> {
|
|
102
114
|
const { genericRenderWindow, remoteRender } = useHybridViewerCore();
|
|
115
|
+
const ratio = z_scale / zScale.value;
|
|
103
116
|
zScale.value = z_scale;
|
|
104
117
|
const renderer = requireRenderWindow(genericRenderWindow).getRenderer();
|
|
105
118
|
// oxlint-disable-next-line no-unsafe-type-assertion -- renderer.getActors() is typed as vtkProp[] in vtk.js, but this scene only ever adds vtkActor instances.
|
|
@@ -107,17 +120,23 @@ const useHybridViewerScene = createSharedComposable(() => {
|
|
|
107
120
|
const scale = actor.getScale();
|
|
108
121
|
actor.setScale(scale[0] ?? 1, scale[1] ?? 1, z_scale);
|
|
109
122
|
}
|
|
110
|
-
renderer.
|
|
123
|
+
const camera = renderer.getActiveCamera();
|
|
124
|
+
followZScaling(camera, ratio);
|
|
125
|
+
renderer.resetCameraClippingRange();
|
|
111
126
|
const renderWindow = requireRenderWindow(genericRenderWindow).getRenderWindow();
|
|
112
127
|
renderWindow.render();
|
|
113
128
|
const viewerStore = useViewerStore();
|
|
114
|
-
const schema = viewer_schemas.opengeodeweb_viewer.viewer.set_z_scaling;
|
|
115
|
-
const params = {
|
|
116
|
-
z_scale,
|
|
117
|
-
};
|
|
118
129
|
await viewerStore.request({
|
|
119
|
-
schema,
|
|
120
|
-
params
|
|
130
|
+
schema: viewer_schemas.opengeodeweb_viewer.viewer.set_z_scaling,
|
|
131
|
+
params: {
|
|
132
|
+
z_scale,
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
await viewerStore.request({
|
|
136
|
+
schema: viewer_schemas.opengeodeweb_viewer.viewer.update_camera,
|
|
137
|
+
params: {
|
|
138
|
+
camera_options: getCameraOptions(camera),
|
|
139
|
+
},
|
|
121
140
|
});
|
|
122
141
|
await remoteRender();
|
|
123
142
|
}
|
|
@@ -147,4 +166,4 @@ const useHybridViewerScene = createSharedComposable(() => {
|
|
|
147
166
|
};
|
|
148
167
|
});
|
|
149
168
|
|
|
150
|
-
export { useHybridViewerScene };
|
|
169
|
+
export { followZScaling, useHybridViewerScene };
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import type { CameraOptions, Vector3 } from "./vtk_types";
|
|
2
|
-
import {
|
|
3
|
-
applyCameraOptions,
|
|
4
|
-
centerCameraOnPosition,
|
|
5
|
-
getCameraOptions,
|
|
6
|
-
useHybridViewerCamera,
|
|
7
|
-
} from "./camera";
|
|
2
|
+
import { applyCameraOptions, centerCameraOnPosition, useHybridViewerCamera } from "./camera";
|
|
8
3
|
import { requireRenderWindow, useHybridViewerCore } from "./core";
|
|
9
4
|
import type { Position } from "@vueuse/core";
|
|
5
|
+
import { getCameraOptions } from "./camera_animation";
|
|
10
6
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
11
7
|
import { newInstance as vtkCamera } from "@kitware/vtk.js/Rendering/Core/Camera";
|
|
12
8
|
|
package/package.json
CHANGED