@geode/opengeodeweb-front 10.43.2 → 10.44.0-rc.2
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/Generic/Model/BlocksOptions.vue +7 -7
- package/app/components/Viewer/Generic/Model/CornersOptions.vue +7 -7
- package/app/components/Viewer/Generic/Model/LinesOptions.vue +7 -7
- package/app/components/Viewer/Generic/Model/ModelCardTabs.vue +35 -0
- package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +22 -15
- package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +22 -15
- package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +17 -5
- package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +7 -7
- 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/composables/live_data_item.ts +39 -0
- package/app/composables/model_tabs.ts +86 -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/utils/crs.ts +38 -0
- package/app/utils/import_workflow.ts +20 -7
- package/internal/stores/hybrid_viewer/scene.ts +4 -2
- package/package.json +4 -4
- package/app/components/Viewer/Options/OptionsSection.vue +0 -76
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
import BlocksOptions from "./BlocksOptions.vue";
|
|
7
7
|
import CornersOptions from "./CornersOptions.vue";
|
|
8
8
|
import LinesOptions from "./LinesOptions.vue";
|
|
9
|
-
import
|
|
9
|
+
import ModelCardTabs from "./ModelCardTabs.vue";
|
|
10
10
|
import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
|
|
11
11
|
import SurfacesOptions from "./SurfacesOptions.vue";
|
|
12
12
|
import ViewerOptionsColoringTypeSelector from "@ogw_front/components/Viewer/Options/ColoringTypeSelector.vue";
|
|
@@ -14,6 +14,7 @@ import VisibilitySwitch from "@ogw_front/components/Viewer/Options/VisibilitySwi
|
|
|
14
14
|
import { useBatchStyle } from "@ogw_front/composables/batch_style";
|
|
15
15
|
import { useDataStyleStore } from "@ogw_front/stores/data_style";
|
|
16
16
|
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
17
|
+
import { useModelTabs } from "@ogw_front/composables/model_tabs";
|
|
17
18
|
|
|
18
19
|
const dataStyleStore = useDataStyleStore();
|
|
19
20
|
const hybridViewerStore = useHybridViewerStore();
|
|
@@ -27,6 +28,11 @@ const { itemProps } = defineProps<Props>();
|
|
|
27
28
|
|
|
28
29
|
const { modelId, componentId, componentType, collections, targetComponentIds } =
|
|
29
30
|
useModelMenuContext(() => itemProps);
|
|
31
|
+
|
|
32
|
+
const { tabs, activeTab } = useModelTabs({
|
|
33
|
+
componentType,
|
|
34
|
+
componentId,
|
|
35
|
+
});
|
|
30
36
|
function visibleComponents(targetId: string): string[] {
|
|
31
37
|
return dataStyleStore.visibleMeshComponents(targetId).value || [];
|
|
32
38
|
}
|
|
@@ -87,11 +93,13 @@ const modelComponentsActiveColoring = computed<string | undefined>({
|
|
|
87
93
|
|
|
88
94
|
<template>
|
|
89
95
|
<v-sheet class="model-style-card" color="transparent">
|
|
90
|
-
<
|
|
96
|
+
<ModelCardTabs v-model="activeTab" :tabs="tabs" />
|
|
97
|
+
|
|
98
|
+
<div v-show="activeTab === 'model'">
|
|
91
99
|
<VisibilitySwitch data-testid="modelStyleVisibilitySwitch" v-model="modelVisibility" />
|
|
92
|
-
</
|
|
100
|
+
</div>
|
|
93
101
|
|
|
94
|
-
<
|
|
102
|
+
<div v-if="!componentType && !componentId" v-show="activeTab === 'components'">
|
|
95
103
|
<ViewerOptionsColoringTypeSelector
|
|
96
104
|
:id="modelId"
|
|
97
105
|
v-model:coloring_style_key="modelComponentsActiveColoring"
|
|
@@ -99,7 +107,7 @@ const modelComponentsActiveColoring = computed<string | undefined>({
|
|
|
99
107
|
:capabilities="{ color: { available: true } }"
|
|
100
108
|
:allowRandom="true"
|
|
101
109
|
/>
|
|
102
|
-
</
|
|
110
|
+
</div>
|
|
103
111
|
|
|
104
112
|
<BlocksOptions
|
|
105
113
|
v-if="componentType === 'Block'"
|
|
@@ -107,6 +115,7 @@ const modelComponentsActiveColoring = computed<string | undefined>({
|
|
|
107
115
|
:blockId="componentId"
|
|
108
116
|
:targetBlockIds="targetComponentIds"
|
|
109
117
|
:collections="collections"
|
|
118
|
+
:activeTab="activeTab"
|
|
110
119
|
/>
|
|
111
120
|
<SurfacesOptions
|
|
112
121
|
v-else-if="componentType === 'Surface'"
|
|
@@ -114,6 +123,7 @@ const modelComponentsActiveColoring = computed<string | undefined>({
|
|
|
114
123
|
:surfaceId="componentId"
|
|
115
124
|
:targetSurfaceIds="targetComponentIds"
|
|
116
125
|
:collections="collections"
|
|
126
|
+
:activeTab="activeTab"
|
|
117
127
|
/>
|
|
118
128
|
<LinesOptions
|
|
119
129
|
v-else-if="componentType === 'Line'"
|
|
@@ -121,6 +131,7 @@ const modelComponentsActiveColoring = computed<string | undefined>({
|
|
|
121
131
|
:lineId="componentId"
|
|
122
132
|
:targetLineIds="targetComponentIds"
|
|
123
133
|
:collections="collections"
|
|
134
|
+
:activeTab="activeTab"
|
|
124
135
|
/>
|
|
125
136
|
<CornersOptions
|
|
126
137
|
v-else-if="componentType === 'Corner'"
|
|
@@ -128,6 +139,7 @@ const modelComponentsActiveColoring = computed<string | undefined>({
|
|
|
128
139
|
:cornerId="componentId"
|
|
129
140
|
:targetCornerIds="targetComponentIds"
|
|
130
141
|
:collections="collections"
|
|
142
|
+
:activeTab="activeTab"
|
|
131
143
|
/>
|
|
132
144
|
</v-sheet>
|
|
133
145
|
</template>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
// oxlint-disable eslint/max-lines
|
|
3
3
|
import type { CollectionComponent } from "@ogw_front/stores/data_helpers/collections";
|
|
4
|
-
import OptionsSection from "@ogw_front/components/Viewer/Options/OptionsSection.vue";
|
|
5
4
|
import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
|
|
6
5
|
import ViewerOptionsColoringTypeSelector from "@ogw_front/components/Viewer/Options/ColoringTypeSelector.vue";
|
|
7
6
|
import VisibilitySwitch from "@ogw_front/components/Viewer/Options/VisibilitySwitch.vue";
|
|
@@ -14,6 +13,7 @@ interface Props {
|
|
|
14
13
|
surfaceId?: string;
|
|
15
14
|
targetSurfaceIds: string[];
|
|
16
15
|
collections?: CollectionComponent[];
|
|
16
|
+
activeTab?: string;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
const {
|
|
@@ -21,6 +21,7 @@ const {
|
|
|
21
21
|
surfaceId = undefined,
|
|
22
22
|
targetSurfaceIds,
|
|
23
23
|
collections = undefined,
|
|
24
|
+
activeTab = undefined,
|
|
24
25
|
} = defineProps<Props>();
|
|
25
26
|
|
|
26
27
|
const dataStyleStore = useDataStyleStore();
|
|
@@ -442,7 +443,7 @@ const attributeSchemas = {
|
|
|
442
443
|
</script>
|
|
443
444
|
|
|
444
445
|
<template>
|
|
445
|
-
<
|
|
446
|
+
<div v-show="!activeTab || activeTab === 'type'" data-testid="modelComponentTypeOptions">
|
|
446
447
|
<VisibilitySwitch data-testid="modelSurfacesVisibilitySwitch" v-model="surfacesVisibility" />
|
|
447
448
|
<ViewerOptionsColoringTypeSelector
|
|
448
449
|
:id="modelId"
|
|
@@ -465,12 +466,11 @@ const attributeSchemas = {
|
|
|
465
466
|
:schemas="attributeSchemas"
|
|
466
467
|
:allowRandom="true"
|
|
467
468
|
/>
|
|
468
|
-
</
|
|
469
|
+
</div>
|
|
469
470
|
|
|
470
|
-
<
|
|
471
|
+
<div
|
|
471
472
|
v-if="surfaceId"
|
|
472
|
-
|
|
473
|
-
class="mt-4"
|
|
473
|
+
v-show="!activeTab || activeTab === 'component'"
|
|
474
474
|
data-testid="modelComponentOptions"
|
|
475
475
|
>
|
|
476
476
|
<VisibilitySwitch v-model="surfaceVisibility" />
|
|
@@ -495,5 +495,5 @@ const attributeSchemas = {
|
|
|
495
495
|
:schemas="attributeSchemas"
|
|
496
496
|
:allowRandom="true"
|
|
497
497
|
/>
|
|
498
|
-
</
|
|
498
|
+
</div>
|
|
499
499
|
</template>
|
|
@@ -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"
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type Ref, computed, ref, watch } from "vue";
|
|
2
|
+
|
|
3
|
+
interface ModelTabItem {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
testId: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface ModelTabsOptions {
|
|
10
|
+
componentType: Ref<string | undefined>;
|
|
11
|
+
componentId: Ref<string | undefined>;
|
|
12
|
+
isTypeSupported?: (type: string) => boolean;
|
|
13
|
+
hasComponentsOptions?: Ref<boolean>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const COMPONENT_TYPE_PLURALS: Record<string, string> = {
|
|
17
|
+
Surface: "Surfaces",
|
|
18
|
+
Line: "Lines",
|
|
19
|
+
Corner: "Corners",
|
|
20
|
+
Block: "Blocks",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function getComponentTypePlural(type: string): string {
|
|
24
|
+
return COMPONENT_TYPE_PLURALS[type] ?? `${type}s`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function isFilled(value: string | undefined): value is string {
|
|
28
|
+
return value !== undefined && value !== "";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Tabs depend on where the menu was opened: data, a component type or one component.
|
|
32
|
+
// Example: a picked surface gives Model | Surfaces | Surface, with Surface active.
|
|
33
|
+
// oxlint-disable-next-line typescript/explicit-function-return-type, typescript/explicit-module-boundary-types
|
|
34
|
+
function useModelTabs(options: ModelTabsOptions) {
|
|
35
|
+
const { componentType, componentId, isTypeSupported, hasComponentsOptions } = options;
|
|
36
|
+
|
|
37
|
+
const supportedType = computed<string | undefined>(() => {
|
|
38
|
+
const type = componentType.value;
|
|
39
|
+
if (!isFilled(type)) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
if (isTypeSupported && !isTypeSupported(type)) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return type;
|
|
46
|
+
});
|
|
47
|
+
const isModelContext = computed<boolean>(
|
|
48
|
+
() => !isFilled(componentType.value) && !isFilled(componentId.value),
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const tabs = computed<ModelTabItem[]>(() => {
|
|
52
|
+
const items: ModelTabItem[] = [{ label: "Model", value: "model", testId: "modelTab_model" }];
|
|
53
|
+
const type = supportedType.value;
|
|
54
|
+
if (isModelContext.value && (hasComponentsOptions?.value ?? true)) {
|
|
55
|
+
items.push({
|
|
56
|
+
label: "Components Options",
|
|
57
|
+
value: "components",
|
|
58
|
+
testId: "modelTab_components",
|
|
59
|
+
});
|
|
60
|
+
} else if (type !== undefined) {
|
|
61
|
+
items.push({ label: getComponentTypePlural(type), value: "type", testId: "modelTab_type" });
|
|
62
|
+
if (isFilled(componentId.value)) {
|
|
63
|
+
items.push({ label: type, value: "component", testId: "modelTab_component" });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return items;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const activeTab = ref<string>("model");
|
|
70
|
+
watch(
|
|
71
|
+
[supportedType, componentId],
|
|
72
|
+
([type, id]) => {
|
|
73
|
+
if (type === undefined) {
|
|
74
|
+
activeTab.value = "model";
|
|
75
|
+
} else {
|
|
76
|
+
activeTab.value = isFilled(id) ? "component" : "type";
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{ immediate: true },
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
return { tabs, activeTab };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { getComponentTypePlural, useModelTabs };
|
|
86
|
+
export type { ModelTabItem };
|
|
@@ -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 };
|