@geode/opengeodeweb-front 10.44.0-rc.8 → 10.44.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/app/components/ClippingPlaneCard.vue +18 -1
- package/app/components/ClippingPlanes.vue +14 -5
- package/app/components/Screenshot.vue +8 -57
- package/app/components/Viewer/ContextMenu/CircularItems.vue +1 -2
- package/app/components/Viewer/ContextMenu/ContextMenu.vue +7 -6
- package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +4 -5
- package/app/components/Viewer/Scene/BackgroundOptions.vue +37 -0
- package/app/components/Viewer/Scene/OrientationWidgetOptions.vue +48 -0
- package/app/components/Viewer/Scene/TextOptions.vue +63 -0
- package/app/composables/clipping_planes_widget_entries.ts +1 -0
- package/app/composables/hover_highlight.ts +13 -13
- package/app/composables/use_overlapping_picker.ts +3 -1
- package/app/composables/viewer_context_menu.ts +9 -1
- package/app/stores/data_style.ts +8 -0
- package/app/stores/menu.ts +7 -0
- package/app/stores/menu_helpers/menus_data.ts +2 -0
- package/app/stores/menu_helpers/scene.ts +10 -0
- package/app/utils/clipping_planes.ts +19 -1
- package/app/utils/default_styles/constants.ts +10 -0
- package/app/utils/default_styles/index.ts +17 -1
- package/internal/database/base_database.ts +2 -0
- package/internal/database/tables/scene_style.ts +6 -0
- package/internal/stores/data_style/scene.ts +118 -0
- package/internal/stores/data_style/state.ts +4 -0
- package/internal/stores/data_style/state_shared.ts +9 -1
- package/internal/stores/data_style/types.ts +24 -1
- package/package.json +4 -4
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { getPlaneCssColor } from "@ogw_front/utils/clipping_planes";
|
|
3
3
|
|
|
4
4
|
interface Props {
|
|
5
|
-
plane: { origin?: number[]; normal: number[] };
|
|
5
|
+
plane: { origin?: number[]; normal: number[]; opacity: number };
|
|
6
6
|
index: number;
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -49,6 +49,23 @@ const emit = defineEmits<Emits>();
|
|
|
49
49
|
</v-col>
|
|
50
50
|
</v-row>
|
|
51
51
|
|
|
52
|
+
<v-row align="center" no-gutters class="mb-1">
|
|
53
|
+
<v-col cols="auto" class="text-caption text-medium-emphasis">Opacity</v-col>
|
|
54
|
+
<v-col class="px-2">
|
|
55
|
+
<v-slider
|
|
56
|
+
v-model="plane.opacity"
|
|
57
|
+
data-testid="planeOpacitySlider"
|
|
58
|
+
:min="0"
|
|
59
|
+
:max="1"
|
|
60
|
+
:step="0.05"
|
|
61
|
+
:color="getPlaneCssColor(index)"
|
|
62
|
+
track-color="grey-lighten-2"
|
|
63
|
+
density="compact"
|
|
64
|
+
hide-details
|
|
65
|
+
/>
|
|
66
|
+
</v-col>
|
|
67
|
+
</v-row>
|
|
68
|
+
|
|
52
69
|
<v-row no-gutters class="mb-1">
|
|
53
70
|
<v-col class="text-caption text-medium-emphasis">Origin [X, Y, Z]</v-col>
|
|
54
71
|
</v-row>
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
DEBOUNCE_DELAY,
|
|
4
|
+
DEFAULT_NORMALS,
|
|
5
|
+
DEFAULT_PLANE_OPACITY,
|
|
6
|
+
getPlaneRgbaColor,
|
|
7
|
+
} from "@ogw_front/utils/clipping_planes";
|
|
3
8
|
import type { ClippingPlane } from "@ogw_front/composables/clipping_planes_widget_entries";
|
|
4
9
|
import ClippingPlaneCard from "@ogw_front/components/ClippingPlaneCard.vue";
|
|
5
10
|
import SliceCard from "@ogw_front/components/SliceCard.vue";
|
|
@@ -26,7 +31,10 @@ function newItemId(): number {
|
|
|
26
31
|
lastItemId += 1;
|
|
27
32
|
return lastItemId;
|
|
28
33
|
}
|
|
29
|
-
|
|
34
|
+
function createPlane(origin: ClippingPlane["origin"], normal: number[]): ClippingPlane {
|
|
35
|
+
return { id: newItemId(), origin, normal, opacity: DEFAULT_PLANE_OPACITY };
|
|
36
|
+
}
|
|
37
|
+
const planes = ref<ClippingPlane[]>([createPlane(undefined, [1, 0, 0])]);
|
|
30
38
|
const allItems = dataStore.refRegisteredItems();
|
|
31
39
|
const targetIds = computed<string[]>(() => {
|
|
32
40
|
if (targetAllVisible.value) {
|
|
@@ -84,9 +92,10 @@ async function applyClippingPlanes(): Promise<void> {
|
|
|
84
92
|
}
|
|
85
93
|
const center = getSceneCenter();
|
|
86
94
|
const untargetedIds = getUntargetedIds();
|
|
87
|
-
const planesData = planes.value.map((plane) => ({
|
|
95
|
+
const planesData = planes.value.map((plane, index) => ({
|
|
88
96
|
origin: (plane.origin || center).map(Number),
|
|
89
97
|
normal: plane.normal.map(Number),
|
|
98
|
+
color: getPlaneRgbaColor(index, plane.opacity),
|
|
90
99
|
}));
|
|
91
100
|
if (targetIds.value.length > 0) {
|
|
92
101
|
await hybridViewerStore.setClippingPlanes(
|
|
@@ -112,7 +121,7 @@ function addPlane(): void {
|
|
|
112
121
|
// Satisfy noUncheckedIndexedAccess and are never hit at runtime.
|
|
113
122
|
const normal = DEFAULT_NORMALS[planes.value.length % DEFAULT_NORMALS.length] ??
|
|
114
123
|
DEFAULT_NORMALS[0] ?? [1, 0, 0];
|
|
115
|
-
planes.value.push(
|
|
124
|
+
planes.value.push(createPlane([...getSceneCenter()], normal));
|
|
116
125
|
}
|
|
117
126
|
|
|
118
127
|
function removePlane(index: number): void {
|
|
@@ -127,7 +136,7 @@ function flipNormal(plane: { normal: number[] }): void {
|
|
|
127
136
|
|
|
128
137
|
async function resetClippingPlanes(): Promise<void> {
|
|
129
138
|
setFromWidget(true);
|
|
130
|
-
planes.value = [
|
|
139
|
+
planes.value = [createPlane(undefined, [1, 0, 0])];
|
|
131
140
|
resetSlices();
|
|
132
141
|
updateWidgetPlacement({ isReset: true });
|
|
133
142
|
setFromWidget(false);
|
|
@@ -2,14 +2,10 @@
|
|
|
2
2
|
import viewer_schemas, {
|
|
3
3
|
type ViewerTakeScreenshotParams,
|
|
4
4
|
} from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
5
|
-
import { BACKGROUND_GREY_VALUE } from "@ogw_internal/stores/hybrid_viewer/constants";
|
|
6
|
-
import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
|
|
7
5
|
import ToolPanel from "@ogw_front/components/ToolPanel.vue";
|
|
8
|
-
import ViewerOptionsColorPicker from "@ogw_front/components/Viewer/Options/ColorPicker.vue";
|
|
9
6
|
import fileDownload from "js-file-download";
|
|
10
7
|
import { useClipboardItems } from "@vueuse/core";
|
|
11
8
|
import { useFeedbackStore } from "@ogw_front/stores/feedback";
|
|
12
|
-
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
13
9
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
14
10
|
|
|
15
11
|
const DEFAULT_PANEL_WIDTH = 260;
|
|
@@ -37,28 +33,9 @@ const output_extension = ref<ViewerTakeScreenshotParams["output_extension"]>("pn
|
|
|
37
33
|
const include_background = ref<boolean>(true);
|
|
38
34
|
const include_ui = ref<boolean>(false);
|
|
39
35
|
const screenshot_type = ref<string>("file");
|
|
40
|
-
const DEFAULT_BACKGROUND_COLOR: RGBAColor = {
|
|
41
|
-
red: BACKGROUND_GREY_VALUE,
|
|
42
|
-
green: BACKGROUND_GREY_VALUE,
|
|
43
|
-
blue: BACKGROUND_GREY_VALUE,
|
|
44
|
-
alpha: 1,
|
|
45
|
-
};
|
|
46
|
-
const background_color = ref<RGBAColor>({ ...DEFAULT_BACKGROUND_COLOR });
|
|
47
|
-
let is_capturing = false;
|
|
48
36
|
|
|
49
37
|
const { copy } = useClipboardItems();
|
|
50
38
|
|
|
51
|
-
function applyBackgroundColor(color: RGBAColor): Promise<void> {
|
|
52
|
-
const hybridViewerStore = useHybridViewerStore();
|
|
53
|
-
// oxlint-disable-next-line id-length -- the viewer schema requires { r, g, b }
|
|
54
|
-
return hybridViewerStore.setBackgroundColor({ r: color.red, g: color.green, b: color.blue });
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async function restoreBackgroundColor(): Promise<void> {
|
|
58
|
-
background_color.value = { ...DEFAULT_BACKGROUND_COLOR };
|
|
59
|
-
await applyBackgroundColor(DEFAULT_BACKGROUND_COLOR);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
39
|
async function deliverScreenshot(blob: Blob | Uint8Array, current_filename: string): Promise<void> {
|
|
63
40
|
const feedbackStore = useFeedbackStore();
|
|
64
41
|
if (screenshot_type.value === "file") {
|
|
@@ -152,35 +129,17 @@ async function takeUiScreenshot(current_filename: string): Promise<void> {
|
|
|
152
129
|
|
|
153
130
|
async function takeScreenshot(): Promise<void> {
|
|
154
131
|
const current_filename = screenshot_type.value === "file" ? filename.value : "screenshot";
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
await takeSceneScreenshot(current_filename);
|
|
164
|
-
show.value = false;
|
|
165
|
-
}
|
|
166
|
-
} finally {
|
|
167
|
-
await restoreBackgroundColor();
|
|
168
|
-
is_capturing = false;
|
|
132
|
+
if (include_ui.value) {
|
|
133
|
+
// Close the panel first so it does not appear on the captured page
|
|
134
|
+
show.value = false;
|
|
135
|
+
await nextTick();
|
|
136
|
+
await takeUiScreenshot(current_filename);
|
|
137
|
+
} else {
|
|
138
|
+
await takeSceneScreenshot(current_filename);
|
|
139
|
+
show.value = false;
|
|
169
140
|
}
|
|
170
141
|
}
|
|
171
142
|
|
|
172
|
-
watch(background_color, async (color) => {
|
|
173
|
-
if (show.value) {
|
|
174
|
-
await applyBackgroundColor(color);
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
watch(show, async (value) => {
|
|
179
|
-
if (!value && !is_capturing) {
|
|
180
|
-
await restoreBackgroundColor();
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
|
|
184
143
|
watch([output_extension, include_ui], ([extension, with_ui]) => {
|
|
185
144
|
if (extension !== "png" || with_ui) {
|
|
186
145
|
include_background.value = true;
|
|
@@ -295,14 +254,6 @@ function handleClose(): void {
|
|
|
295
254
|
class="text-caption"
|
|
296
255
|
></v-switch>
|
|
297
256
|
</v-col>
|
|
298
|
-
<v-col v-if="include_background" cols="12" class="py-1">
|
|
299
|
-
<span class="text-caption">Background color</span>
|
|
300
|
-
<ViewerOptionsColorPicker
|
|
301
|
-
data-testid="screenshotBackgroundColorPicker"
|
|
302
|
-
v-model="background_color"
|
|
303
|
-
disabled-alpha
|
|
304
|
-
/>
|
|
305
|
-
</v-col>
|
|
306
257
|
</v-row>
|
|
307
258
|
</v-container>
|
|
308
259
|
|
|
@@ -11,7 +11,6 @@ interface Props {
|
|
|
11
11
|
|
|
12
12
|
const { menuItems, id, metaData, menuItemCount } = defineProps<Props>();
|
|
13
13
|
|
|
14
|
-
const RADIUS = 80;
|
|
15
14
|
const Z_INDEX_ACTIVE_ITEM = 10;
|
|
16
15
|
const Z_INDEX_BASE_ITEM = 1;
|
|
17
16
|
const FULL_ANGLE = 360;
|
|
@@ -25,7 +24,7 @@ const menuStore = useMenuStore();
|
|
|
25
24
|
function getItemStyle(index: number): Record<string, string> {
|
|
26
25
|
const angle = (index / menuItemCount) * 2 * Math.PI;
|
|
27
26
|
return {
|
|
28
|
-
transform: `translate(${Math.cos(angle) *
|
|
27
|
+
transform: `translate(${Math.cos(angle) * menuStore.menuRadius}px, ${Math.sin(angle) * menuStore.menuRadius}px)`,
|
|
29
28
|
transition: "opacity 0.2s ease, transform 0.2s ease",
|
|
30
29
|
position: "absolute",
|
|
31
30
|
zIndex: menuStore.active_item_index === index ? Z_INDEX_ACTIVE_ITEM : Z_INDEX_BASE_ITEM,
|
|
@@ -18,7 +18,6 @@ interface Props {
|
|
|
18
18
|
|
|
19
19
|
const { id, x, y, containerWidth, containerHeight } = defineProps<Props>();
|
|
20
20
|
|
|
21
|
-
const RADIUS = 80;
|
|
22
21
|
const MARGIN_OFFSET = 40;
|
|
23
22
|
const CLOSE_DELAY = 100;
|
|
24
23
|
const TREEVIEW_MARGIN_LEFT = 10;
|
|
@@ -31,6 +30,7 @@ const menuStore = useMenuStore();
|
|
|
31
30
|
const treeviewStore = useTreeviewStore();
|
|
32
31
|
|
|
33
32
|
const meta_data = computed(() => menuStore.current_meta_data || {});
|
|
33
|
+
const isSceneMenu = computed(() => meta_data.value.viewer_type === "scene");
|
|
34
34
|
provideBatchGroup(() => meta_data.value.targetIds ?? []);
|
|
35
35
|
|
|
36
36
|
const show_menu = ref<boolean>(true);
|
|
@@ -47,7 +47,7 @@ interface Position {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
function clampPosition(posX: number, posY: number): Position {
|
|
50
|
-
const margin =
|
|
50
|
+
const margin = menuStore.menuRadius + MARGIN_OFFSET;
|
|
51
51
|
return {
|
|
52
52
|
x: Math.min(Math.max(posX, margin), containerWidth - margin),
|
|
53
53
|
y: Math.min(Math.max(posY, margin), containerHeight - margin),
|
|
@@ -158,8 +158,8 @@ const isOverToolbar = computed<boolean>(() => {
|
|
|
158
158
|
function getMenuStyle(): Record<string, string> {
|
|
159
159
|
return {
|
|
160
160
|
position: "fixed" as const,
|
|
161
|
-
left: `${menuStore.containerLeft + menuX.value -
|
|
162
|
-
top: `${menuStore.containerTop + menuY.value -
|
|
161
|
+
left: `${menuStore.containerLeft + menuX.value - menuStore.menuRadius}px`,
|
|
162
|
+
top: `${menuStore.containerTop + menuY.value - menuStore.menuRadius}px`,
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
165
|
|
|
@@ -180,7 +180,7 @@ function toggleShowName(): void {
|
|
|
180
180
|
<div class="circular-menu-drag-handle" @mousedown.stop="startDrag">
|
|
181
181
|
<div
|
|
182
182
|
class="circular-menu-items"
|
|
183
|
-
:style="{ width: `${
|
|
183
|
+
:style="{ width: `${menuStore.menuRadius * 2}px`, height: `${menuStore.menuRadius * 2}px` }"
|
|
184
184
|
>
|
|
185
185
|
<CircularItems
|
|
186
186
|
:menu-items="menu_items"
|
|
@@ -190,6 +190,7 @@ function toggleShowName(): void {
|
|
|
190
190
|
/>
|
|
191
191
|
|
|
192
192
|
<CenterButton
|
|
193
|
+
v-if="!isSceneMenu"
|
|
193
194
|
:is-over-treeview="isOverTreeview"
|
|
194
195
|
:is-over-toolbar="isOverToolbar"
|
|
195
196
|
@drag="startDrag"
|
|
@@ -197,7 +198,7 @@ function toggleShowName(): void {
|
|
|
197
198
|
/>
|
|
198
199
|
|
|
199
200
|
<InfoCard
|
|
200
|
-
v-if="meta_data.viewer_type !== 'basemap'"
|
|
201
|
+
v-if="!isSceneMenu && meta_data.viewer_type !== 'basemap'"
|
|
201
202
|
v-model:show="showName"
|
|
202
203
|
:meta-data="meta_data"
|
|
203
204
|
/>
|
|
@@ -8,7 +8,6 @@ import { useTreeviewStore } from "@ogw_front/stores/treeview";
|
|
|
8
8
|
const CARD_WIDTH = 300;
|
|
9
9
|
const CARD_HEIGHT = 500;
|
|
10
10
|
const MARGIN = 60;
|
|
11
|
-
const RADIUS = 80;
|
|
12
11
|
const OFFSET = 40;
|
|
13
12
|
|
|
14
13
|
const menuStore = useMenuStore();
|
|
@@ -36,8 +35,8 @@ const { index, itemProps, tooltip, btnImage = "", btnIcon = "" } = defineProps<P
|
|
|
36
35
|
|
|
37
36
|
const buttonCoords = computed(() => {
|
|
38
37
|
const angle = (index / itemProps.totalItems) * 2 * Math.PI;
|
|
39
|
-
const deltaX = Math.cos(angle) *
|
|
40
|
-
const deltaY = Math.sin(angle) *
|
|
38
|
+
const deltaX = Math.cos(angle) * menuStore.menuRadius;
|
|
39
|
+
const deltaY = Math.sin(angle) * menuStore.menuRadius;
|
|
41
40
|
const size = 40;
|
|
42
41
|
return {
|
|
43
42
|
x: menuStore.containerLeft + menuStore.menuX + deltaX - size / 2,
|
|
@@ -110,7 +109,7 @@ const optionsStyle = computed<Record<string, string>>(() => {
|
|
|
110
109
|
return {};
|
|
111
110
|
}
|
|
112
111
|
const angle = (index / itemProps.totalItems) * 2 * Math.PI;
|
|
113
|
-
const radius =
|
|
112
|
+
const radius = menuStore.menuRadius;
|
|
114
113
|
const absoluteButtonY = menuStore.menuY + Math.sin(angle) * radius;
|
|
115
114
|
const height = optionsHeight.value;
|
|
116
115
|
const margin = MARGIN;
|
|
@@ -127,7 +126,7 @@ const optionsStyle = computed<Record<string, string>>(() => {
|
|
|
127
126
|
const optionsClass = computed<string>(() => {
|
|
128
127
|
const loc = itemProps.tooltip_location;
|
|
129
128
|
const margin = MARGIN;
|
|
130
|
-
const radius =
|
|
129
|
+
const radius = menuStore.menuRadius;
|
|
131
130
|
if (loc === "right") {
|
|
132
131
|
return menuStore.menuX + radius + margin + CARD_WIDTH > menuStore.containerWidth
|
|
133
132
|
? "options-left"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import ViewerContextMenuItem, {
|
|
3
|
+
type ItemProps,
|
|
4
|
+
} from "@ogw_front/components/Viewer/ContextMenu/ContextMenuItem.vue";
|
|
5
|
+
import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
|
|
6
|
+
import ViewerOptionsColorPicker from "@ogw_front/components/Viewer/Options/ColorPicker.vue";
|
|
7
|
+
import { useDataStyleStore } from "@ogw_front/stores/data_style";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
itemProps: ItemProps & { index: number };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { itemProps } = defineProps<Props>();
|
|
14
|
+
|
|
15
|
+
const dataStyleStore = useDataStyleStore();
|
|
16
|
+
|
|
17
|
+
const backgroundColor = computed<RGBAColor>({
|
|
18
|
+
get: () => dataStyleStore.sceneStyle.background_color,
|
|
19
|
+
set: async (color) => {
|
|
20
|
+
await dataStyleStore.setSceneBackgroundColor(color);
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<ViewerContextMenuItem
|
|
27
|
+
data-testid="sceneBackgroundMenu"
|
|
28
|
+
:index="itemProps.index"
|
|
29
|
+
:itemProps="itemProps"
|
|
30
|
+
tooltip="Background"
|
|
31
|
+
btnIcon="mdi-image-area"
|
|
32
|
+
>
|
|
33
|
+
<template #options>
|
|
34
|
+
<ViewerOptionsColorPicker v-model="backgroundColor" disabled-alpha />
|
|
35
|
+
</template>
|
|
36
|
+
</ViewerContextMenuItem>
|
|
37
|
+
</template>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import ViewerContextMenuItem, {
|
|
3
|
+
type ItemProps,
|
|
4
|
+
} from "@ogw_front/components/Viewer/ContextMenu/ContextMenuItem.vue";
|
|
5
|
+
import type { SceneOrientationWidget } from "@ogw_internal/stores/data_style/types";
|
|
6
|
+
import { useDataStyleStore } from "@ogw_front/stores/data_style";
|
|
7
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
itemProps: ItemProps & { index: number };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { itemProps } = defineProps<Props>();
|
|
14
|
+
|
|
15
|
+
const dataStyleStore = useDataStyleStore();
|
|
16
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
17
|
+
|
|
18
|
+
const orientationWidget = computed<SceneOrientationWidget>({
|
|
19
|
+
get: () => dataStyleStore.sceneStyle.orientation_widget,
|
|
20
|
+
set: async (marker) => {
|
|
21
|
+
await dataStyleStore.setSceneOrientationWidget(marker);
|
|
22
|
+
hybridViewerStore.remoteRender();
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<ViewerContextMenuItem
|
|
29
|
+
data-testid="sceneOrientationWidgetMenu"
|
|
30
|
+
:index="itemProps.index"
|
|
31
|
+
:itemProps="itemProps"
|
|
32
|
+
tooltip="Orientation widget"
|
|
33
|
+
btnIcon="mdi-compass-outline"
|
|
34
|
+
>
|
|
35
|
+
<template #options>
|
|
36
|
+
<v-btn-toggle
|
|
37
|
+
v-model="orientationWidget"
|
|
38
|
+
data-testid="sceneOrientationWidgetToggle"
|
|
39
|
+
mandatory
|
|
40
|
+
density="compact"
|
|
41
|
+
divided
|
|
42
|
+
>
|
|
43
|
+
<v-btn value="axes" data-testid="sceneOrientationWidgetAxes">Axes</v-btn>
|
|
44
|
+
<v-btn value="compass" data-testid="sceneOrientationWidgetCompass">Compass</v-btn>
|
|
45
|
+
</v-btn-toggle>
|
|
46
|
+
</template>
|
|
47
|
+
</ViewerContextMenuItem>
|
|
48
|
+
</template>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import ViewerContextMenuItem, {
|
|
3
|
+
type ItemProps,
|
|
4
|
+
} from "@ogw_front/components/Viewer/ContextMenu/ContextMenuItem.vue";
|
|
5
|
+
import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
|
|
6
|
+
import type { SceneFontFamily } from "@ogw_internal/stores/data_style/types";
|
|
7
|
+
import ViewerOptionsColorPicker from "@ogw_front/components/Viewer/Options/ColorPicker.vue";
|
|
8
|
+
import { useDataStyleStore } from "@ogw_front/stores/data_style";
|
|
9
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
itemProps: ItemProps & { index: number };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { itemProps } = defineProps<Props>();
|
|
16
|
+
|
|
17
|
+
const dataStyleStore = useDataStyleStore();
|
|
18
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
19
|
+
|
|
20
|
+
const FONT_FAMILIES: { title: string; value: SceneFontFamily }[] = [
|
|
21
|
+
{ title: "Arial", value: "arial" },
|
|
22
|
+
{ title: "Courier", value: "courier" },
|
|
23
|
+
{ title: "Times", value: "times" },
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const textColor = computed<RGBAColor>({
|
|
27
|
+
get: () => dataStyleStore.sceneStyle.text.color,
|
|
28
|
+
set: async (color) => {
|
|
29
|
+
await dataStyleStore.setSceneTextColor(color);
|
|
30
|
+
hybridViewerStore.remoteRender();
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const fontFamily = computed<SceneFontFamily>({
|
|
35
|
+
get: () => dataStyleStore.sceneStyle.text.font_family,
|
|
36
|
+
set: async (font_family) => {
|
|
37
|
+
await dataStyleStore.setSceneFontFamily(font_family);
|
|
38
|
+
hybridViewerStore.remoteRender();
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<template>
|
|
44
|
+
<ViewerContextMenuItem
|
|
45
|
+
data-testid="sceneTextMenu"
|
|
46
|
+
:index="itemProps.index"
|
|
47
|
+
:itemProps="itemProps"
|
|
48
|
+
tooltip="Text"
|
|
49
|
+
btnIcon="mdi-format-text"
|
|
50
|
+
>
|
|
51
|
+
<template #options>
|
|
52
|
+
<v-select
|
|
53
|
+
v-model="fontFamily"
|
|
54
|
+
data-testid="sceneFontFamilySelect"
|
|
55
|
+
:items="FONT_FAMILIES"
|
|
56
|
+
label="Font"
|
|
57
|
+
density="compact"
|
|
58
|
+
hide-details
|
|
59
|
+
/>
|
|
60
|
+
<ViewerOptionsColorPicker v-model="textColor" class="mt-2" />
|
|
61
|
+
</template>
|
|
62
|
+
</ViewerContextMenuItem>
|
|
63
|
+
</template>
|
|
@@ -17,8 +17,10 @@ export function useHoverhighlight(): {
|
|
|
17
17
|
const viewerStore = useViewerStore();
|
|
18
18
|
const dataStore = useDataStore();
|
|
19
19
|
let timer: ReturnType<typeof setTimeout> | undefined = undefined;
|
|
20
|
+
// Item hovered last, whose highlight may still be pending
|
|
20
21
|
let currentId: string | undefined = undefined;
|
|
21
|
-
|
|
22
|
+
// Item the viewer was asked to highlight, the only one to unhighlight
|
|
23
|
+
let highlighted: { id: string; type: HighlightType } | undefined = undefined;
|
|
22
24
|
|
|
23
25
|
function onHoverEnter(
|
|
24
26
|
id: string,
|
|
@@ -34,7 +36,6 @@ export function useHoverhighlight(): {
|
|
|
34
36
|
|
|
35
37
|
async function highlightAction(): Promise<void> {
|
|
36
38
|
currentId = id;
|
|
37
|
-
currentType = type;
|
|
38
39
|
|
|
39
40
|
if (!(await dataStore.isItemViewable(id))) {
|
|
40
41
|
return;
|
|
@@ -55,6 +56,7 @@ export function useHoverhighlight(): {
|
|
|
55
56
|
return;
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
highlighted = { id, type };
|
|
58
60
|
const params = {
|
|
59
61
|
id,
|
|
60
62
|
visibility: true,
|
|
@@ -107,22 +109,20 @@ export function useHoverhighlight(): {
|
|
|
107
109
|
clearTimeout(timer);
|
|
108
110
|
timer = undefined;
|
|
109
111
|
}
|
|
110
|
-
if (currentId === id
|
|
111
|
-
|
|
112
|
+
if (currentId === id) {
|
|
113
|
+
currentId = undefined;
|
|
114
|
+
}
|
|
115
|
+
if (highlighted?.id === id) {
|
|
116
|
+
const { type } = highlighted;
|
|
117
|
+
const schema = vtk_schemas.opengeodeweb_viewer[type].highlight;
|
|
112
118
|
const params = {
|
|
113
119
|
id,
|
|
114
120
|
visibility: false,
|
|
115
|
-
...(
|
|
121
|
+
...(type === "model" && { block_ids: [] }),
|
|
116
122
|
};
|
|
117
123
|
// oxlint-disable-next-line typescript/no-floating-promises -- unhighlightAction catches its own errors internally.
|
|
118
|
-
unhighlightAction(
|
|
119
|
-
|
|
120
|
-
currentType = undefined;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (currentId === undefined) {
|
|
124
|
-
currentId = undefined;
|
|
125
|
-
currentType = undefined;
|
|
124
|
+
unhighlightAction(type, id, { schema, params });
|
|
125
|
+
highlighted = undefined;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
@@ -22,6 +22,8 @@ interface ProposedItem {
|
|
|
22
22
|
interface ViewerIdResult {
|
|
23
23
|
id: string | undefined;
|
|
24
24
|
viewer_id: number | undefined;
|
|
25
|
+
// True when objects were under the cursor but the user closed the picker without choosing
|
|
26
|
+
dismissed?: boolean;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
interface GetViewerIdParams {
|
|
@@ -161,7 +163,7 @@ export function useOverlappingPicker(): UseOverlappingPickerReturn {
|
|
|
161
163
|
if (chosenResult) {
|
|
162
164
|
resolve({ id: chosenResult.id, viewer_id: chosenResult.viewer_id });
|
|
163
165
|
} else {
|
|
164
|
-
resolve({ id: undefined, viewer_id: undefined });
|
|
166
|
+
resolve({ id: undefined, viewer_id: undefined, dismissed: true });
|
|
165
167
|
}
|
|
166
168
|
};
|
|
167
169
|
});
|
|
@@ -15,6 +15,11 @@ interface MenuTarget {
|
|
|
15
15
|
meta_data: MenuMetaData;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
const SCENE_MENU_TARGET: MenuTarget = {
|
|
19
|
+
id: "scene",
|
|
20
|
+
meta_data: { viewer_type: "scene", geode_object_type: "scene" },
|
|
21
|
+
};
|
|
22
|
+
|
|
18
23
|
async function treeMenuTarget(
|
|
19
24
|
dataStore: ReturnType<typeof useDataStore>,
|
|
20
25
|
payload: TreeMenuPayload,
|
|
@@ -122,8 +127,11 @@ export function useViewerContextMenu(
|
|
|
122
127
|
const rect = element.getBoundingClientRect();
|
|
123
128
|
const x = event.clientX - rect.left;
|
|
124
129
|
const yPicking = containerHeight.value - (event.clientY - rect.top);
|
|
125
|
-
const { id: pickedId, viewer_id } = await viewerComponent.get_viewer_id(x, yPicking);
|
|
130
|
+
const { id: pickedId, viewer_id, dismissed } = await viewerComponent.get_viewer_id(x, yPicking);
|
|
126
131
|
if (pickedId === undefined) {
|
|
132
|
+
if (dismissed !== true) {
|
|
133
|
+
openMenuAt(event, element, SCENE_MENU_TARGET);
|
|
134
|
+
}
|
|
127
135
|
return;
|
|
128
136
|
}
|
|
129
137
|
openMenuAt(event, element, await viewerMenuTarget(dataStore, pickedId, viewer_id));
|
package/app/stores/data_style.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
ModelComponentStyle,
|
|
3
3
|
ModelComponentTypeStyle,
|
|
4
4
|
ObjectStyle,
|
|
5
|
+
SceneStyle,
|
|
5
6
|
} from "@ogw_internal/stores/data_style/types";
|
|
6
7
|
import type { Table } from "dexie";
|
|
7
8
|
import { database } from "@ogw_internal/database/database.js";
|
|
@@ -11,11 +12,13 @@ import { useDataStore } from "@ogw_front/stores/data";
|
|
|
11
12
|
import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
|
|
12
13
|
import { useMeshStyle } from "@ogw_internal/stores/data_style/mesh/index";
|
|
13
14
|
import { useModelStyle } from "@ogw_internal/stores/data_style/model/index";
|
|
15
|
+
import { useSceneStyle } from "@ogw_internal/stores/data_style/scene";
|
|
14
16
|
|
|
15
17
|
interface DataStyleSnapshot {
|
|
16
18
|
readonly styles: Record<string, ObjectStyle>;
|
|
17
19
|
readonly componentStyles: Record<string, ModelComponentStyle>;
|
|
18
20
|
readonly modelComponentTypeStyles: Record<string, ModelComponentTypeStyle>;
|
|
21
|
+
readonly sceneStyle?: SceneStyle;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
// The database's table map is dynamically assembled at runtime (see internal/database/database.ts), so its exported type is a loose `{}`; cast it to the shape it actually has at runtime rather than widening every call site.
|
|
@@ -38,6 +41,7 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
|
|
|
38
41
|
const dataStyleState = useDataStyleState();
|
|
39
42
|
const meshStyleStore = useMeshStyle();
|
|
40
43
|
const modelStyleStore = useModelStyle();
|
|
44
|
+
const sceneStyleStore = useSceneStyle();
|
|
41
45
|
const attributeTimeStepStyle = useAttributeTimeStepStyle();
|
|
42
46
|
const dataStore = useDataStore();
|
|
43
47
|
// oxlint-disable-next-line no-unsafe-type-assertion -- the database Proxy is typed as `{}` at its export site; this cast documents its real runtime shape.
|
|
@@ -98,6 +102,7 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
|
|
|
98
102
|
styles: dataStyleState.styles.value,
|
|
99
103
|
componentStyles: dataStyleState.componentStyles.value,
|
|
100
104
|
modelComponentTypeStyles: dataStyleState.modelComponentTypeStyles.value,
|
|
105
|
+
sceneStyle: dataStyleState.sceneStyle.value,
|
|
101
106
|
};
|
|
102
107
|
}
|
|
103
108
|
|
|
@@ -135,6 +140,7 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
|
|
|
135
140
|
...model_component_type_style_promises,
|
|
136
141
|
]);
|
|
137
142
|
await dataStyleState.loadFromDatabase();
|
|
143
|
+
await sceneStyleStore.importSceneStyle(snapshot.sceneStyle);
|
|
138
144
|
}
|
|
139
145
|
|
|
140
146
|
async function applyAllStylesFromState(): Promise<void> {
|
|
@@ -152,6 +158,7 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
|
|
|
152
158
|
}
|
|
153
159
|
});
|
|
154
160
|
await Promise.all(promises);
|
|
161
|
+
await sceneStyleStore.applySceneStyle();
|
|
155
162
|
}
|
|
156
163
|
|
|
157
164
|
return {
|
|
@@ -165,6 +172,7 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
|
|
|
165
172
|
...attributeTimeStepStyle,
|
|
166
173
|
...meshStyleStore,
|
|
167
174
|
...modelStyleStore,
|
|
175
|
+
...sceneStyleStore,
|
|
168
176
|
};
|
|
169
177
|
});
|
|
170
178
|
|
package/app/stores/menu.ts
CHANGED
|
@@ -18,6 +18,9 @@ interface OpenMenuOptions {
|
|
|
18
18
|
readonly meta_data: MenuMetaData | undefined;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
const MENU_RADIUS = 80;
|
|
22
|
+
// Same gap between neighbour items as a 4-item object menu (3 items, no center button)
|
|
23
|
+
const SCENE_MENU_RADIUS = 65;
|
|
21
24
|
export const useMenuStore = defineStore("menu", () => {
|
|
22
25
|
const menus = shallowRef(menusData);
|
|
23
26
|
const display_menu = ref(false);
|
|
@@ -30,6 +33,9 @@ export const useMenuStore = defineStore("menu", () => {
|
|
|
30
33
|
const containerLeft = ref(0);
|
|
31
34
|
const active_item_index = ref<number | undefined>(undefined);
|
|
32
35
|
const current_meta_data = ref<MenuMetaData>({});
|
|
36
|
+
const menuRadius = computed(() =>
|
|
37
|
+
current_meta_data.value.viewer_type === "scene" ? SCENE_MENU_RADIUS : MENU_RADIUS,
|
|
38
|
+
);
|
|
33
39
|
|
|
34
40
|
function getMenuItems(
|
|
35
41
|
objectType: string | undefined,
|
|
@@ -117,6 +123,7 @@ export const useMenuStore = defineStore("menu", () => {
|
|
|
117
123
|
containerTop,
|
|
118
124
|
containerLeft,
|
|
119
125
|
active_item_index,
|
|
126
|
+
menuRadius,
|
|
120
127
|
getMenuItems,
|
|
121
128
|
closeMenu,
|
|
122
129
|
openMenu,
|
|
@@ -4,6 +4,7 @@ import { basemapMenus } from "./basemap.js";
|
|
|
4
4
|
import { edgedCurveMenus } from "./mesh/edged_curve.js";
|
|
5
5
|
import { gridMenus } from "./mesh/grid.js";
|
|
6
6
|
import { pointSetMenus } from "./mesh/point_set.js";
|
|
7
|
+
import { sceneMenus } from "./scene.js";
|
|
7
8
|
import { solidMenus } from "./mesh/solid.js";
|
|
8
9
|
import { surfaceMenus } from "./mesh/surface.js";
|
|
9
10
|
|
|
@@ -19,6 +20,7 @@ const menusData: Record<string, Record<string, MenuItems>> = {
|
|
|
19
20
|
model_component_type: modelComponentTypeMenus,
|
|
20
21
|
model_component: modelComponentMenus,
|
|
21
22
|
basemap: basemapMenus,
|
|
23
|
+
scene: sceneMenus,
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
export { menusData };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MenuItems } from "./types.js";
|
|
2
|
+
import SceneBackgroundOptions from "@ogw_front/components/Viewer/Scene/BackgroundOptions.vue";
|
|
3
|
+
import SceneOrientationWidgetOptions from "@ogw_front/components/Viewer/Scene/OrientationWidgetOptions.vue";
|
|
4
|
+
import SceneTextOptions from "@ogw_front/components/Viewer/Scene/TextOptions.vue";
|
|
5
|
+
|
|
6
|
+
const sceneMenus: Record<string, MenuItems> = {
|
|
7
|
+
scene: [SceneBackgroundOptions, SceneTextOptions, SceneOrientationWidgetOptions],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { sceneMenus };
|
|
@@ -2,6 +2,7 @@ const AXIS_SCALE = 0.45;
|
|
|
2
2
|
const SIZE_RATIO = 0.1;
|
|
3
3
|
const DEBOUNCE_DELAY = 200;
|
|
4
4
|
const CHANGE_THRESHOLD = 1e-4;
|
|
5
|
+
const DEFAULT_PLANE_OPACITY = 0.1;
|
|
5
6
|
// oxlint-disable no-magic-numbers
|
|
6
7
|
const COLOR_BLUE = [0.12, 0.53, 0.9];
|
|
7
8
|
const COLOR_GREEN = [0.26, 0.63, 0.28];
|
|
@@ -16,8 +17,22 @@ const NORMAL_Z = [0, 0, 1];
|
|
|
16
17
|
const DEFAULT_NORMALS = [NORMAL_X, NORMAL_Y, NORMAL_Z];
|
|
17
18
|
const RGB_MAX_VALUE = 255;
|
|
18
19
|
|
|
20
|
+
function getPlaneColor(index: number): readonly number[] {
|
|
21
|
+
return PLANE_COLORS[index % PLANE_COLORS.length] ?? COLOR_BLUE;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getPlaneRgbaColor(
|
|
25
|
+
index: number,
|
|
26
|
+
alpha: number,
|
|
27
|
+
): { red: number; green: number; blue: number; alpha: number } {
|
|
28
|
+
const [red = 0, green = 0, blue = 0] = getPlaneColor(index).map((channel) =>
|
|
29
|
+
Math.round(channel * RGB_MAX_VALUE),
|
|
30
|
+
);
|
|
31
|
+
return { red, green, blue, alpha };
|
|
32
|
+
}
|
|
33
|
+
|
|
19
34
|
function getPlaneCssColor(index: number): string {
|
|
20
|
-
const rgb =
|
|
35
|
+
const rgb = getPlaneColor(index);
|
|
21
36
|
return `rgb(${rgb.map((channel) => Math.round(channel * RGB_MAX_VALUE)).join(",")})`;
|
|
22
37
|
}
|
|
23
38
|
|
|
@@ -80,8 +95,11 @@ export {
|
|
|
80
95
|
SIZE_RATIO,
|
|
81
96
|
DEBOUNCE_DELAY,
|
|
82
97
|
CHANGE_THRESHOLD,
|
|
98
|
+
DEFAULT_PLANE_OPACITY,
|
|
83
99
|
PLANE_COLORS,
|
|
84
100
|
DEFAULT_NORMALS,
|
|
101
|
+
getPlaneColor,
|
|
102
|
+
getPlaneRgbaColor,
|
|
85
103
|
getPlaneCssColor,
|
|
86
104
|
hasPlaneChanged,
|
|
87
105
|
getPlaneStyle,
|
|
@@ -53,6 +53,12 @@ const DEFAULT_MODEL_COMPONENT_TYPE_COLORS: Record<string, RGBAColor> = {
|
|
|
53
53
|
|
|
54
54
|
const DEFAULT_NO_DATA_COLOR: RGBAColor = { red: 128, green: 128, blue: 128, alpha: 1 };
|
|
55
55
|
|
|
56
|
+
// Scene
|
|
57
|
+
const SCENE_DEFAULT_BACKGROUND_COLOR: RGBAColor = { red: 180, green: 180, blue: 180, alpha: 1 };
|
|
58
|
+
const SCENE_DEFAULT_TEXT_COLOR: RGBAColor = { red: 0, green: 0, blue: 0, alpha: 1 };
|
|
59
|
+
const SCENE_DEFAULT_FONT_FAMILY = "arial";
|
|
60
|
+
const SCENE_DEFAULT_ORIENTATION_WIDGET = "axes";
|
|
61
|
+
|
|
56
62
|
export type { RGBAColor, AttributeConfig };
|
|
57
63
|
export {
|
|
58
64
|
POINTS_DEFAULT_VISIBILITY,
|
|
@@ -85,4 +91,8 @@ export {
|
|
|
85
91
|
MESH_DEFAULT_ACTIVE_COLORING,
|
|
86
92
|
MODEL_DEFAULT_ACTIVE_COLORING,
|
|
87
93
|
DEFAULT_NO_DATA_COLOR,
|
|
94
|
+
SCENE_DEFAULT_BACKGROUND_COLOR,
|
|
95
|
+
SCENE_DEFAULT_TEXT_COLOR,
|
|
96
|
+
SCENE_DEFAULT_FONT_FAMILY,
|
|
97
|
+
SCENE_DEFAULT_ORIENTATION_WIDGET,
|
|
88
98
|
};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SCENE_DEFAULT_BACKGROUND_COLOR,
|
|
3
|
+
SCENE_DEFAULT_FONT_FAMILY,
|
|
4
|
+
SCENE_DEFAULT_ORIENTATION_WIDGET,
|
|
5
|
+
SCENE_DEFAULT_TEXT_COLOR,
|
|
6
|
+
} from "./constants";
|
|
1
7
|
import {
|
|
2
8
|
brepDefaultStyle,
|
|
3
9
|
crossSectionDefaultStyle,
|
|
@@ -14,6 +20,7 @@ import {
|
|
|
14
20
|
solidDefaultStyle,
|
|
15
21
|
surfaceDefaultStyle,
|
|
16
22
|
} from "./meshes";
|
|
23
|
+
import type { SceneStyle } from "@ogw_internal/stores/data_style/types";
|
|
17
24
|
|
|
18
25
|
function default_styles(): Record<string, unknown> {
|
|
19
26
|
return {
|
|
@@ -50,6 +57,15 @@ function getDefaultStyle(type: string): unknown {
|
|
|
50
57
|
return styles[type];
|
|
51
58
|
}
|
|
52
59
|
|
|
60
|
+
function getDefaultSceneStyle(): SceneStyle {
|
|
61
|
+
return {
|
|
62
|
+
id: "scene",
|
|
63
|
+
background_color: { ...SCENE_DEFAULT_BACKGROUND_COLOR },
|
|
64
|
+
text: { color: { ...SCENE_DEFAULT_TEXT_COLOR }, font_family: SCENE_DEFAULT_FONT_FAMILY },
|
|
65
|
+
orientation_widget: SCENE_DEFAULT_ORIENTATION_WIDGET,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
53
69
|
export { DEFAULT_MODEL_COMPONENT_TYPE_STYLES } from "./models";
|
|
54
70
|
export {
|
|
55
71
|
MESH_COMPONENT_TYPES,
|
|
@@ -58,4 +74,4 @@ export {
|
|
|
58
74
|
MODEL_DEFAULT_ACTIVE_COLORING,
|
|
59
75
|
DEFAULT_NO_DATA_COLOR,
|
|
60
76
|
} from "./constants";
|
|
61
|
-
export { getDefaultStyle };
|
|
77
|
+
export { getDefaultSceneStyle, getDefaultStyle };
|
|
@@ -6,6 +6,7 @@ import { modelComponentDataStyleTable } from "./tables/model_component_datastyle
|
|
|
6
6
|
import { modelComponentTypeDataStyleTable } from "./tables/model_component_type_datastyle";
|
|
7
7
|
import { modelComponentsRelationTable } from "./tables/model_components_relation";
|
|
8
8
|
import { modelComponentsTable } from "./tables/model_components";
|
|
9
|
+
import { sceneStyleTable } from "./tables/scene_style";
|
|
9
10
|
|
|
10
11
|
export class BaseDatabase extends Dexie {
|
|
11
12
|
public static get initialStores(): Record<string, string> {
|
|
@@ -17,6 +18,7 @@ export class BaseDatabase extends Dexie {
|
|
|
17
18
|
[modelComponentTypeDataStyleTable.name]: modelComponentTypeDataStyleTable.schema,
|
|
18
19
|
[modelComponentsRelationTable.name]: modelComponentsRelationTable.schema,
|
|
19
20
|
[cameraPositionsTable.name]: cameraPositionsTable.schema,
|
|
21
|
+
[sceneStyleTable.name]: sceneStyleTable.schema,
|
|
20
22
|
treeview_config: "id",
|
|
21
23
|
};
|
|
22
24
|
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { SceneFontFamily, SceneOrientationWidget, SceneStyle } from "./types";
|
|
2
|
+
import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
|
|
3
|
+
// Third party imports
|
|
4
|
+
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
5
|
+
|
|
6
|
+
// Local imports
|
|
7
|
+
import { getDefaultSceneStyle } from "@ogw_front/utils/default_styles";
|
|
8
|
+
import { getTable } from "@ogw_internal/database/database";
|
|
9
|
+
import { useDataStyleState } from "./state";
|
|
10
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
11
|
+
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
12
|
+
|
|
13
|
+
// Local constants
|
|
14
|
+
const text_style_schema = viewer_schemas.opengeodeweb_viewer.viewer.set_text_style;
|
|
15
|
+
const orientation_widget_schema = viewer_schemas.opengeodeweb_viewer.viewer.set_orientation_widget;
|
|
16
|
+
|
|
17
|
+
// oxlint-disable-next-line id-length -- the viewer schema requires { r, g, b }
|
|
18
|
+
function toViewerColor(color: RGBAColor): { r: number; g: number; b: number } {
|
|
19
|
+
// oxlint-disable-next-line id-length -- the viewer schema requires { r, g, b }
|
|
20
|
+
return { r: color.red, g: color.green, b: color.blue };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// oxlint-disable-next-line max-lines-per-function
|
|
24
|
+
export function useSceneStyle(): {
|
|
25
|
+
setSceneBackgroundColor: (color: RGBAColor) => Promise<void>;
|
|
26
|
+
setSceneTextColor: (color: RGBAColor) => Promise<unknown>;
|
|
27
|
+
setSceneFontFamily: (font_family: SceneFontFamily) => Promise<unknown>;
|
|
28
|
+
setSceneOrientationWidget: (marker: SceneOrientationWidget) => Promise<unknown>;
|
|
29
|
+
applySceneStyle: () => Promise<void>;
|
|
30
|
+
importSceneStyle: (snapshot: SceneStyle | undefined) => Promise<void>;
|
|
31
|
+
} {
|
|
32
|
+
const viewerStore = useViewerStore();
|
|
33
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
34
|
+
const { sceneStyle } = useDataStyleState();
|
|
35
|
+
const sceneStyleTable = getTable<SceneStyle>("scene_style");
|
|
36
|
+
|
|
37
|
+
async function saveSceneStyle(values: Partial<Omit<SceneStyle, "id">>): Promise<void> {
|
|
38
|
+
// Values may hold nested reactive proxies (e.g. an exported snapshot), which IndexedDB cannot clone
|
|
39
|
+
// oxlint-disable-next-line unicorn/prefer-structured-clone, no-unsafe-type-assertion -- JSON round-trip of a known-shape style.
|
|
40
|
+
const plainStyle = JSON.parse(JSON.stringify({ ...sceneStyle.value, ...values })) as SceneStyle;
|
|
41
|
+
sceneStyle.value = plainStyle;
|
|
42
|
+
await sceneStyleTable.put(plainStyle);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function requestTextStyle(text: SceneStyle["text"]): Promise<unknown> {
|
|
46
|
+
// Update right away so a quick second change builds on this one instead of the saved state
|
|
47
|
+
sceneStyle.value = { ...sceneStyle.value, text };
|
|
48
|
+
const params = {
|
|
49
|
+
color: toViewerColor(text.color),
|
|
50
|
+
font_family: text.font_family,
|
|
51
|
+
opacity: text.color.alpha,
|
|
52
|
+
};
|
|
53
|
+
const result = await viewerStore.request(
|
|
54
|
+
{ schema: text_style_schema, params },
|
|
55
|
+
{
|
|
56
|
+
response_function: async () => {
|
|
57
|
+
await saveSceneStyle({ text });
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function requestOrientationWidget(marker: SceneOrientationWidget): Promise<unknown> {
|
|
65
|
+
const result = await viewerStore.request(
|
|
66
|
+
{ schema: orientation_widget_schema, params: { marker } },
|
|
67
|
+
{
|
|
68
|
+
response_function: async () => {
|
|
69
|
+
await saveSceneStyle({ orientation_widget: marker });
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
);
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function setSceneBackgroundColor(color: RGBAColor): Promise<void> {
|
|
77
|
+
await hybridViewerStore.setBackgroundColor(toViewerColor(color));
|
|
78
|
+
await saveSceneStyle({ background_color: color });
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function setSceneTextColor(color: RGBAColor): Promise<unknown> {
|
|
82
|
+
const result = await requestTextStyle({ ...sceneStyle.value.text, color });
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function setSceneFontFamily(font_family: SceneFontFamily): Promise<unknown> {
|
|
87
|
+
const result = await requestTextStyle({ ...sceneStyle.value.text, font_family });
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function setSceneOrientationWidget(marker: SceneOrientationWidget): Promise<unknown> {
|
|
92
|
+
const result = await requestOrientationWidget(marker);
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function applySceneStyle(): Promise<void> {
|
|
97
|
+
const { background_color, text, orientation_widget } = sceneStyle.value;
|
|
98
|
+
await Promise.all([
|
|
99
|
+
setSceneBackgroundColor(background_color),
|
|
100
|
+
requestTextStyle(text),
|
|
101
|
+
requestOrientationWidget(orientation_widget),
|
|
102
|
+
]);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async function importSceneStyle(snapshot: SceneStyle | undefined): Promise<void> {
|
|
106
|
+
const { background_color, text, orientation_widget } = snapshot ?? getDefaultSceneStyle();
|
|
107
|
+
await saveSceneStyle({ background_color, text, orientation_widget });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
setSceneBackgroundColor,
|
|
112
|
+
setSceneTextColor,
|
|
113
|
+
setSceneFontFamily,
|
|
114
|
+
setSceneOrientationWidget,
|
|
115
|
+
applySceneStyle,
|
|
116
|
+
importSceneStyle,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -2,9 +2,11 @@ import type {
|
|
|
2
2
|
ModelComponentStyle,
|
|
3
3
|
ModelComponentTypeStyle,
|
|
4
4
|
ObjectStyle,
|
|
5
|
+
SceneStyle,
|
|
5
6
|
StyleValues,
|
|
6
7
|
} from "./types";
|
|
7
8
|
import { type SharedState, getSharedState } from "./state_shared";
|
|
9
|
+
import { getDefaultSceneStyle } from "@ogw_front/utils/default_styles";
|
|
8
10
|
import { getTable } from "@ogw_internal/database/database";
|
|
9
11
|
import merge from "lodash/merge";
|
|
10
12
|
|
|
@@ -83,9 +85,11 @@ export function useDataStyleState(): DataStyleStateApi {
|
|
|
83
85
|
dataStyleTable.clear(),
|
|
84
86
|
modelComponentDataStyleTable.clear(),
|
|
85
87
|
modelComponentTypeDataStyleTable.clear(),
|
|
88
|
+
getTable<SceneStyle>("scene_style").clear(),
|
|
86
89
|
]);
|
|
87
90
|
modelComponentTypeStyles.value = {};
|
|
88
91
|
componentStyles.value = {};
|
|
92
|
+
state.sceneStyle.value = getDefaultSceneStyle();
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
return {
|
|
@@ -2,9 +2,11 @@ import type {
|
|
|
2
2
|
ModelComponentStyle,
|
|
3
3
|
ModelComponentTypeStyle,
|
|
4
4
|
ObjectStyle,
|
|
5
|
+
SceneStyle,
|
|
5
6
|
StyleValues,
|
|
6
7
|
} from "./types";
|
|
7
8
|
import type { Observable as RxObservable } from "rxjs";
|
|
9
|
+
import { getDefaultSceneStyle } from "@ogw_front/utils/default_styles";
|
|
8
10
|
import { getTable } from "@ogw_internal/database/database";
|
|
9
11
|
import { liveQuery } from "dexie";
|
|
10
12
|
import merge from "lodash/merge";
|
|
@@ -14,6 +16,7 @@ interface SharedState {
|
|
|
14
16
|
styles: Ref<Record<string, ObjectStyle>>;
|
|
15
17
|
modelComponentTypeStyles: Ref<Record<string, ModelComponentTypeStyle>>;
|
|
16
18
|
componentStyles: Ref<Record<string, ModelComponentStyle>>;
|
|
19
|
+
sceneStyle: Ref<SceneStyle>;
|
|
17
20
|
loadFromDatabase: () => Promise<void>;
|
|
18
21
|
updateComponentStyleCache: (
|
|
19
22
|
modelId: string,
|
|
@@ -74,12 +77,16 @@ function getSharedState(): SharedState {
|
|
|
74
77
|
|
|
75
78
|
const modelComponentTypeStyles = ref<Record<string, ModelComponentTypeStyle>>({});
|
|
76
79
|
const componentStyles = ref<Record<string, ModelComponentStyle>>({});
|
|
80
|
+
const sceneStyleTable = getTable<SceneStyle>("scene_style");
|
|
81
|
+
const sceneStyle = ref<SceneStyle>(getDefaultSceneStyle());
|
|
77
82
|
|
|
78
83
|
async function loadFromDatabase(): Promise<void> {
|
|
79
|
-
const [fetchedTypeStyles, fetchedComponentStyles] = await Promise.all([
|
|
84
|
+
const [fetchedTypeStyles, fetchedComponentStyles, fetchedSceneStyle] = await Promise.all([
|
|
80
85
|
modelComponentTypeDataStyleTable.toArray(),
|
|
81
86
|
modelComponentDataStyleTable.toArray(),
|
|
87
|
+
sceneStyleTable.get("scene"),
|
|
82
88
|
]);
|
|
89
|
+
sceneStyle.value = fetchedSceneStyle ?? getDefaultSceneStyle();
|
|
83
90
|
const typeStylesMap: Record<string, ModelComponentTypeStyle> = {};
|
|
84
91
|
for (const typeStyle of fetchedTypeStyles) {
|
|
85
92
|
const cacheKey = `${typeStyle.id_model}_${typeStyle.type}`;
|
|
@@ -177,6 +184,7 @@ function getSharedState(): SharedState {
|
|
|
177
184
|
styles,
|
|
178
185
|
modelComponentTypeStyles,
|
|
179
186
|
componentStyles,
|
|
187
|
+
sceneStyle,
|
|
180
188
|
loadFromDatabase,
|
|
181
189
|
updateComponentStyleCache,
|
|
182
190
|
bulkUpdateComponentStyleCache,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
|
|
2
|
+
|
|
1
3
|
type StyleValues = Record<string, unknown>;
|
|
2
4
|
|
|
3
5
|
interface ObjectStyle {
|
|
@@ -28,4 +30,25 @@ interface ModelComponentStyle extends StyleValues {
|
|
|
28
30
|
id_component: string;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
type SceneFontFamily = "arial" | "courier" | "times";
|
|
34
|
+
type SceneOrientationWidget = "axes" | "compass";
|
|
35
|
+
|
|
36
|
+
interface SceneStyle {
|
|
37
|
+
id: "scene";
|
|
38
|
+
background_color: RGBAColor;
|
|
39
|
+
text: {
|
|
40
|
+
color: RGBAColor;
|
|
41
|
+
font_family: SceneFontFamily;
|
|
42
|
+
};
|
|
43
|
+
orientation_widget: SceneOrientationWidget;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type {
|
|
47
|
+
ModelComponentStyle,
|
|
48
|
+
ModelComponentTypeStyle,
|
|
49
|
+
ObjectStyle,
|
|
50
|
+
SceneFontFamily,
|
|
51
|
+
SceneOrientationWidget,
|
|
52
|
+
SceneStyle,
|
|
53
|
+
StyleValues,
|
|
54
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geode/opengeodeweb-front",
|
|
3
|
-
"version": "10.44.0
|
|
3
|
+
"version": "10.44.0",
|
|
4
4
|
"description": "OpenSource Vue/Nuxt/Pinia/Vuetify framework for web applications",
|
|
5
5
|
"homepage": "https://github.com/Geode-solutions/OpenGeodeWeb-Front",
|
|
6
6
|
"bugs": {
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"prepublishOnly": "npm run build"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@geode/cloud-api": "
|
|
68
|
-
"@geode/opengeodeweb-back": "
|
|
69
|
-
"@geode/opengeodeweb-viewer": "
|
|
67
|
+
"@geode/cloud-api": "latest",
|
|
68
|
+
"@geode/opengeodeweb-back": "latest",
|
|
69
|
+
"@geode/opengeodeweb-viewer": "latest",
|
|
70
70
|
"@kitware/vtk.js": "33.3.0",
|
|
71
71
|
"@mdi/font": "7.4.47",
|
|
72
72
|
"@msgpack/msgpack": "2.8.0",
|