@geode/opengeodeweb-front 12.2.0-rc.4 → 12.2.0-rc.6
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/CameraOrientation.vue +85 -68
- package/app/components/CameraOrientationDial.vue +195 -0
- package/app/components/ClippingPlanes.vue +1 -1
- package/app/components/FactorFilterPanel.vue +1 -1
- package/app/components/Launcher.vue +3 -2
- package/app/components/ThresholdFilter.vue +1 -2
- package/app/components/Viewer/Basemap/CropOptions.vue +7 -8
- package/app/components/Viewer/Basemap/OpacityOptions.vue +7 -8
- package/app/components/Viewer/ContextMenu/CircularItems.vue +6 -43
- package/app/components/Viewer/ContextMenu/ContextMenu.vue +1 -6
- package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +14 -16
- package/app/components/Viewer/EdgedCurve/PointsOptions.vue +5 -4
- package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +10 -13
- package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +8 -11
- package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +16 -13
- package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +28 -31
- package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +9 -11
- package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +8 -11
- package/app/components/Viewer/Generic/Model/BlocksOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/CornersOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/EdgesOptions.vue +7 -8
- package/app/components/Viewer/Generic/Model/LinesOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +5 -7
- package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +5 -7
- package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +5 -7
- package/app/components/Viewer/Generic/Model/ModelStyleOptions.vue +7 -8
- package/app/components/Viewer/Generic/Model/PointsOptions.vue +7 -8
- package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +1 -1
- package/app/components/Viewer/Grid/2D/CellsOptions.vue +6 -4
- package/app/components/Viewer/Grid/2D/EdgesOptions.vue +6 -4
- package/app/components/Viewer/Grid/2D/PointsOptions.vue +5 -4
- package/app/components/Viewer/Grid/3D/CellsOptions.vue +6 -4
- package/app/components/Viewer/Grid/3D/EdgesOptions.vue +6 -4
- package/app/components/Viewer/Grid/3D/FacetsOptions.vue +6 -4
- package/app/components/Viewer/Grid/3D/PointsOptions.vue +5 -4
- package/app/components/Viewer/Image/ImageOptions.vue +10 -13
- package/app/components/Viewer/ObjectTree/Base/CommonTreeView.vue +5 -0
- package/app/components/Viewer/ObjectTree/Base/ComponentRelations.vue +2 -2
- package/app/components/Viewer/ObjectTree/Base/StickyHeader.vue +4 -1
- package/app/components/Viewer/ObjectTree/Base/TreeRow.vue +6 -8
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +10 -15
- package/app/components/Viewer/ObjectTree/Views/ModelTree.vue +3 -0
- package/app/components/Viewer/OrientationCompass.vue +11 -34
- package/app/components/Viewer/OrientationGlobe.vue +2 -2
- package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +28 -31
- package/app/components/Viewer/Scene/BackgroundOptions.vue +4 -7
- package/app/components/Viewer/Scene/OrientationWidgetOptions.vue +4 -7
- package/app/components/Viewer/Scene/TextOptions.vue +4 -7
- package/app/components/Viewer/Solid/EdgesOptions.vue +6 -4
- package/app/components/Viewer/Solid/PointsOptions.vue +5 -4
- package/app/components/Viewer/Solid/PolygonsOptions.vue +6 -4
- package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +8 -11
- package/app/components/Viewer/Surface/EdgesOptions.vue +6 -4
- package/app/components/Viewer/Surface/PointsOptions.vue +6 -4
- package/app/components/Viewer/Surface/PolygonsOptions.vue +8 -11
- package/app/components/Viewer/Surface/Triangulated/TrianglesOptions.vue +5 -4
- package/app/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue +6 -4
- package/app/components/Viewer/TetrahedralSolid/TrianglesOptions.vue +6 -4
- package/app/composables/circular_menu.ts +45 -0
- package/app/composables/compass_dial.ts +40 -0
- package/app/composables/hover_highlight.ts +1 -1
- package/app/composables/model_menu_context.ts +7 -11
- package/app/composables/model_tree.ts +3 -3
- package/app/composables/project_manager_helpers/types.ts +2 -3
- package/app/composables/use_overlapping_picker.ts +7 -19
- package/app/composables/viewer_context_menu.ts +2 -1
- package/app/stores/api.ts +6 -59
- package/app/stores/app.ts +21 -55
- package/app/stores/back.ts +86 -145
- package/app/stores/camera_manager.ts +12 -25
- package/app/stores/cloud.ts +21 -101
- package/app/stores/crs.ts +3 -2
- package/app/stores/data.ts +66 -409
- package/app/stores/data_style.ts +99 -93
- package/app/stores/feedback.ts +57 -53
- package/app/stores/infra.ts +61 -101
- package/app/stores/treeview.ts +12 -31
- package/app/stores/viewer.ts +9 -29
- package/app/stores/viewer_helpers/actions.ts +1 -23
- package/app/utils/backend_lifecycle.ts +155 -0
- package/app/utils/brand_colors.ts +9 -0
- package/app/utils/camera_orientations.ts +136 -0
- package/app/utils/import_item.ts +5 -4
- package/app/utils/orientation_compass.ts +15 -0
- package/app/utils/orientation_cube_style.ts +70 -0
- package/app/utils/threshold_sources.ts +3 -2
- package/app/utils/treeview.ts +25 -1
- package/app/utils/viewer_object_type.ts +21 -0
- package/internal/database/base_database.ts +2 -1
- package/internal/database/database.ts +90 -7
- package/internal/database/queries.ts +45 -0
- package/internal/database/tables/camera_positions.ts +11 -1
- package/internal/database/tables/data.ts +20 -1
- package/internal/database/tables/data_style.ts +3 -1
- package/internal/database/tables/model_component_datastyle.ts +3 -1
- package/internal/database/tables/model_component_type_datastyle.ts +3 -1
- package/internal/database/tables/model_components.ts +12 -1
- package/internal/database/tables/model_components_relation.ts +11 -1
- package/internal/database/tables/scene_style.ts +3 -1
- package/internal/database/tables/treeview_config.ts +31 -0
- package/internal/stores/data/items.ts +110 -0
- package/internal/stores/data/model/collections.ts +107 -0
- package/internal/stores/data/model/components.ts +129 -0
- package/internal/stores/data/model/mesh_components.ts +134 -0
- package/internal/stores/data/model/relations.ts +76 -0
- package/internal/stores/data/model/types.ts +14 -0
- package/internal/stores/data/registration.ts +54 -0
- package/internal/stores/data/snapshot.ts +83 -0
- package/internal/stores/data/types.ts +26 -0
- package/internal/stores/data_style/model/common_mutations.ts +47 -77
- package/internal/stores/data_style/model/selection.ts +3 -10
- package/internal/stores/data_style/scene.ts +2 -2
- package/internal/stores/data_style/state.ts +10 -8
- package/internal/stores/data_style/state_shared.ts +10 -7
- package/internal/stores/hybrid_viewer/highlight.ts +9 -14
- package/internal/stores/hybrid_viewer/scene.ts +1 -1
- package/internal/stores/microservice.ts +192 -0
- package/package.json +1 -1
- package/tests/browser/helpers/data/helpers/attribute.ts +2 -1
- package/app/stores/data_helpers/collections.ts +0 -122
- package/app/stores/data_helpers/mesh.ts +0 -167
- package/app/stores/data_helpers/relations.ts +0 -94
package/app/stores/viewer.ts
CHANGED
|
@@ -8,27 +8,22 @@ import opengeodeweb_viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb
|
|
|
8
8
|
|
|
9
9
|
// Local imports
|
|
10
10
|
import { type ViewerRequestArgs, callViewer } from "./viewer_helpers/request.js";
|
|
11
|
-
import {
|
|
12
|
-
fetchViewerVersion,
|
|
13
|
-
launchViewerMicroservice,
|
|
14
|
-
pickWorldPosition,
|
|
15
|
-
showRenderingWarnings,
|
|
16
|
-
} from "./viewer_helpers/actions.js";
|
|
17
11
|
import {
|
|
18
12
|
getWebsocketApiPort,
|
|
19
13
|
getWebsocketApiProtocol,
|
|
20
14
|
isCloudMode,
|
|
21
15
|
} from "@ogw_front/utils/stores.js";
|
|
16
|
+
import {
|
|
17
|
+
launchViewerMicroservice,
|
|
18
|
+
pickWorldPosition,
|
|
19
|
+
showRenderingWarnings,
|
|
20
|
+
} from "./viewer_helpers/actions.js";
|
|
21
|
+
import { useMicroserviceVersion, useRequestCounter } from "@ogw_internal/stores/microservice";
|
|
22
22
|
import { Status } from "@ogw_front/utils/status";
|
|
23
23
|
import { afterViewerReset } from "@ogw_front/composables/viewer_reset";
|
|
24
24
|
import { useInfraStore } from "@ogw_front/stores/infra";
|
|
25
25
|
|
|
26
|
-
import type {
|
|
27
|
-
JsonRpcSchema,
|
|
28
|
-
MicroserviceVersionSchema,
|
|
29
|
-
RequestHandlers,
|
|
30
|
-
ResponseOf,
|
|
31
|
-
} from "@ogw_shared/utils/types.js";
|
|
26
|
+
import type { JsonRpcSchema, RequestHandlers, ResponseOf } from "@ogw_shared/utils/types.js";
|
|
32
27
|
import type { RpcClient } from "@ogw_shared/utils/call_raw.js";
|
|
33
28
|
|
|
34
29
|
interface ViewSize {
|
|
@@ -59,9 +54,8 @@ export const useViewerStore = defineStore(
|
|
|
59
54
|
});
|
|
60
55
|
// Pixel size of the remote rendering view, as sent to the server by RemoteView.resize()
|
|
61
56
|
const view_size = ref<ViewSize>({ width: 0, height: 0 });
|
|
62
|
-
const request_counter =
|
|
57
|
+
const { request_counter, is_busy, start_request, stop_request } = useRequestCounter();
|
|
63
58
|
const status = ref(Status.NOT_CONNECTED);
|
|
64
|
-
const version = ref("0.0.0");
|
|
65
59
|
// The viewer warnings are shown once, not again on each reconnection
|
|
66
60
|
const rendering_warnings_shown = ref(false);
|
|
67
61
|
const protocol = computed(() => getWebsocketApiProtocol());
|
|
@@ -74,13 +68,6 @@ export const useViewerStore = defineStore(
|
|
|
74
68
|
viewer_url += "/ws";
|
|
75
69
|
return viewer_url;
|
|
76
70
|
});
|
|
77
|
-
function start_request(): void {
|
|
78
|
-
request_counter.value += 1;
|
|
79
|
-
}
|
|
80
|
-
function stop_request(): void {
|
|
81
|
-
request_counter.value -= 1;
|
|
82
|
-
}
|
|
83
|
-
const is_busy = computed(() => request_counter.value > 0);
|
|
84
71
|
function toggle_picking_mode(value: boolean): void {
|
|
85
72
|
picking_mode.value = value;
|
|
86
73
|
}
|
|
@@ -157,14 +144,7 @@ export const useViewerStore = defineStore(
|
|
|
157
144
|
async function connect(): Promise<void> {
|
|
158
145
|
await ws_connect();
|
|
159
146
|
}
|
|
160
|
-
|
|
161
|
-
schema: MicroserviceVersionSchema | undefined,
|
|
162
|
-
): Promise<{ microservice_version: string } | undefined> {
|
|
163
|
-
const result = await fetchViewerVersion(request, schema, (microservice_version) => {
|
|
164
|
-
version.value = microservice_version;
|
|
165
|
-
});
|
|
166
|
-
return result;
|
|
167
|
-
}
|
|
147
|
+
const { version, get_version } = useMicroserviceVersion(request);
|
|
168
148
|
return {
|
|
169
149
|
default_local_port,
|
|
170
150
|
client,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { MicroserviceVersionSchema } from "@ogw_shared/utils/types.js";
|
|
2
1
|
import type { Vector3 } from "@kitware/vtk.js/types";
|
|
3
2
|
import type { ViewerRequest } from "./request.js";
|
|
4
3
|
import { consola } from "consola";
|
|
@@ -46,27 +45,6 @@ async function launchViewerMicroservice(
|
|
|
46
45
|
return result;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
async function fetchViewerVersion(
|
|
50
|
-
request: ViewerRequest,
|
|
51
|
-
schema: MicroserviceVersionSchema | undefined,
|
|
52
|
-
onVersion: (version: string) => void,
|
|
53
|
-
): Promise<{ microservice_version: string } | undefined> {
|
|
54
|
-
if (!schema) {
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
const result = await request(
|
|
58
|
-
{
|
|
59
|
-
schema,
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
response_function: ({ microservice_version }) => {
|
|
63
|
-
onVersion(microservice_version);
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
);
|
|
67
|
-
return result;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
48
|
// Shows the viewer's warnings about its rendering setup, e.g. software rendering fallback.
|
|
71
49
|
// Informational only: a failure is logged, never thrown, so it cannot break the connection.
|
|
72
50
|
async function showRenderingWarnings(request: ViewerRequest): Promise<void> {
|
|
@@ -82,4 +60,4 @@ async function showRenderingWarnings(request: ViewerRequest): Promise<void> {
|
|
|
82
60
|
}
|
|
83
61
|
}
|
|
84
62
|
|
|
85
|
-
export {
|
|
63
|
+
export { launchViewerMicroservice, pickWorldPosition, showRenderingWarnings };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// Creates the backend: launches the local microservices, or launches / reaches the cloud service,
|
|
2
|
+
// Then connects every registered microservice. It drives the stores from outside, so the stores
|
|
3
|
+
// Only hold their own state and no store imports another one to orchestrate it.
|
|
4
|
+
import { type Microservice, useInfraStore } from "@ogw_front/stores/infra";
|
|
5
|
+
import { clearCloudUrlParam, getCloudUrlParam } from "@ogw_front/utils/cloud";
|
|
6
|
+
import { Status } from "@ogw_front/utils/status";
|
|
7
|
+
import { api_fetch } from "@ogw_internal/utils/api_fetch";
|
|
8
|
+
import { appMode } from "@ogw_shared/app_mode";
|
|
9
|
+
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
10
|
+
import cloud_api_schemas from "@geode/cloud-api/cloud_api_typed_schemas.js";
|
|
11
|
+
import { registerRunningExtensions } from "@ogw_front/utils/extension";
|
|
12
|
+
import { setAppBaseUrl } from "@ogw_shared/scripts";
|
|
13
|
+
import { useAPIStore } from "@ogw_front/stores/api";
|
|
14
|
+
import { useAppStore } from "@ogw_front/stores/app";
|
|
15
|
+
import { useBackStore } from "@ogw_front/stores/back";
|
|
16
|
+
import { useCloudStore } from "@ogw_front/stores/cloud";
|
|
17
|
+
|
|
18
|
+
const CLOUD_PROJECT_FOLDER_PATH = "/project";
|
|
19
|
+
|
|
20
|
+
interface ElectronApi {
|
|
21
|
+
electronAPI: {
|
|
22
|
+
project_folder_path: (args: { projectFolderPath: string }) => void;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare global {
|
|
27
|
+
// oxlint-disable-next-line no-var -- required for global augmentation
|
|
28
|
+
var electronAPI: ElectronApi["electronAPI"];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function launchLocalServices(): Promise<void> {
|
|
32
|
+
const infraStore = useInfraStore();
|
|
33
|
+
const appStore = useAppStore();
|
|
34
|
+
await appStore.createProjectFolder();
|
|
35
|
+
if (infraStore.app_mode === appMode.DESKTOP) {
|
|
36
|
+
globalThis.electronAPI.project_folder_path({
|
|
37
|
+
projectFolderPath: appStore.projectFolderPath,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
await setAppBaseUrl(appStore.base_url);
|
|
41
|
+
const launch_promises: Promise<unknown>[] = infraStore.microservices
|
|
42
|
+
.filter((store: Microservice) => store.launch)
|
|
43
|
+
.map(async (store: Microservice) => {
|
|
44
|
+
const result = await store.launch?.({ projectFolderPath: appStore.projectFolderPath });
|
|
45
|
+
return result;
|
|
46
|
+
});
|
|
47
|
+
launch_promises.push(registerRunningExtensions());
|
|
48
|
+
await Promise.all(launch_promises);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function onCloudConnected(url: string): Promise<void> {
|
|
52
|
+
const appStore = useAppStore();
|
|
53
|
+
useCloudStore().set_connected(true);
|
|
54
|
+
useInfraStore().set_domain_name(url);
|
|
55
|
+
appStore.set_project_folder_path(CLOUD_PROJECT_FOLDER_PATH);
|
|
56
|
+
await setAppBaseUrl(appStore.base_url);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// `authToken` is the user's Firebase ID token, checked by the Cloud API
|
|
60
|
+
async function launchCloud(authToken: string): Promise<unknown> {
|
|
61
|
+
const cloudStore = useCloudStore();
|
|
62
|
+
cloudStore.set_connecting();
|
|
63
|
+
const { PROJECT, BRANCH } = useRuntimeConfig().public;
|
|
64
|
+
const result = await useAPIStore().request(
|
|
65
|
+
{
|
|
66
|
+
schema: cloud_api_schemas.cloud_api.cloud.run,
|
|
67
|
+
params: { project: PROJECT, branch: BRANCH },
|
|
68
|
+
headers: { Authorization: `Bearer ${authToken}` },
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
request_error_function: () => {
|
|
72
|
+
cloudStore.set_connected(false);
|
|
73
|
+
},
|
|
74
|
+
response_function: async ({ url }) => {
|
|
75
|
+
await onCloudConnected(url);
|
|
76
|
+
},
|
|
77
|
+
response_error_function: () => {
|
|
78
|
+
cloudStore.set_connected(false);
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
);
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function connectExistingCloud(host: string): Promise<void> {
|
|
86
|
+
const cloudStore = useCloudStore();
|
|
87
|
+
cloudStore.set_connecting();
|
|
88
|
+
const backStore = useBackStore();
|
|
89
|
+
// Probe the candidate host directly so domain_name is only updated once the service answers.
|
|
90
|
+
try {
|
|
91
|
+
await api_fetch(
|
|
92
|
+
{
|
|
93
|
+
$id: backStore.$id,
|
|
94
|
+
base_url: backStore.base_url_for(host),
|
|
95
|
+
start_request: () => {
|
|
96
|
+
backStore.start_request();
|
|
97
|
+
},
|
|
98
|
+
stop_request: () => {
|
|
99
|
+
backStore.stop_request();
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{ schema: back_schemas.opengeodeweb_back.ping, log_success: false },
|
|
103
|
+
);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
cloudStore.set_connected(false);
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
await onCloudConnected(host);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Reuses the running service given by `?cloud_url=` when present, otherwise launches a new one.
|
|
112
|
+
// The param is single use: it is cleared whatever the outcome, so a retry launches a new service.
|
|
113
|
+
async function startCloud(authToken?: string): Promise<void> {
|
|
114
|
+
const existing_host = getCloudUrlParam();
|
|
115
|
+
if (existing_host === undefined) {
|
|
116
|
+
if (authToken === undefined) {
|
|
117
|
+
throw new Error("Launching a cloud service requires an authenticated user");
|
|
118
|
+
}
|
|
119
|
+
await launchCloud(authToken);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
await connectExistingCloud(existing_host);
|
|
124
|
+
} finally {
|
|
125
|
+
clearCloudUrlParam();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function createBackend(authToken?: string): Promise<void> {
|
|
130
|
+
const infraStore = useInfraStore();
|
|
131
|
+
if (infraStore.status === Status.CREATED) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
await navigator.locks.request("infra.create_backend", async () => {
|
|
135
|
+
if (infraStore.status === Status.CREATED) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
infraStore.set_status(Status.CREATING);
|
|
139
|
+
if (infraStore.app_mode === appMode.CLOUD) {
|
|
140
|
+
try {
|
|
141
|
+
await startCloud(authToken);
|
|
142
|
+
} catch (error) {
|
|
143
|
+
// Back to the "Load the app" button so the user is not stuck on the loading screen.
|
|
144
|
+
infraStore.set_status(Status.NOT_CREATED);
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
await launchLocalServices();
|
|
149
|
+
}
|
|
150
|
+
infraStore.set_status(Status.CREATED);
|
|
151
|
+
await infraStore.create_connection();
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export { connectExistingCloud, createBackend, launchCloud, startCloud };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Brand colors drawn by the front itself (orientation markers, camera orientation panel). Components bind
|
|
2
|
+
// Them in their styles with v-bind() so the value lives here only.
|
|
3
|
+
|
|
4
|
+
// Geode Solutions orange: the north of the compasses and of the axes globe
|
|
5
|
+
const BRAND_ORANGE = "#F48830";
|
|
6
|
+
// The north border of the round targets: the orange, a bit transparent
|
|
7
|
+
const BRAND_ORANGE_BORDER = `color-mix(in srgb, ${BRAND_ORANGE} 60%, transparent)`;
|
|
8
|
+
|
|
9
|
+
export { BRAND_ORANGE, BRAND_ORANGE_BORDER };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Camera orientations of the orientation panel (CameraOrientation.vue). Each one looks from a world
|
|
2
|
+
// Axis; with the compass marker, the labels follow the scene compass (north = world +Y, east = +X,
|
|
3
|
+
// Up = +Z, see utils/orientation_compass.ts) instead of the axis names.
|
|
4
|
+
import type { SceneOrientationWidget } from "@ogw_internal/stores/data_style/types";
|
|
5
|
+
|
|
6
|
+
const QUARTER_TURN = 90;
|
|
7
|
+
const HALF_TURN = 180;
|
|
8
|
+
|
|
9
|
+
// A type alias, not an interface: it is bound to the style of a button, whose CSS properties take an
|
|
10
|
+
// Index signature (custom properties) that interfaces do not satisfy
|
|
11
|
+
type PanelPosition = Record<"top" | "left", string>;
|
|
12
|
+
|
|
13
|
+
interface CameraOrientation {
|
|
14
|
+
// Key of hybridViewerStore.setCameraOrientation
|
|
15
|
+
value: string;
|
|
16
|
+
face: string;
|
|
17
|
+
vtkKey: string;
|
|
18
|
+
// Rotation of the label on its cube face
|
|
19
|
+
rotation: number;
|
|
20
|
+
// Place around the cube in the panel with the axes marker
|
|
21
|
+
position: PanelPosition;
|
|
22
|
+
label: string;
|
|
23
|
+
tooltip: string;
|
|
24
|
+
// Clockwise angle in degrees from north of the side it looks from, with the compass marker
|
|
25
|
+
heading?: number;
|
|
26
|
+
// Looks from above or below, with the compass marker
|
|
27
|
+
vertical?: Vertical;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type Vertical = "up" | "down";
|
|
31
|
+
|
|
32
|
+
interface OrientationEntry {
|
|
33
|
+
value: string;
|
|
34
|
+
face: string;
|
|
35
|
+
vtkKey: string;
|
|
36
|
+
rotation: number;
|
|
37
|
+
position: PanelPosition;
|
|
38
|
+
axisLabel: string;
|
|
39
|
+
compassLabel: string;
|
|
40
|
+
// Side it looks from, as read in "View from ..."
|
|
41
|
+
compassName: string;
|
|
42
|
+
heading?: number;
|
|
43
|
+
vertical?: Vertical;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const ORIENTATIONS: readonly OrientationEntry[] = [
|
|
47
|
+
{
|
|
48
|
+
value: "zplus",
|
|
49
|
+
face: "top",
|
|
50
|
+
vtkKey: "ZPlus",
|
|
51
|
+
rotation: 0,
|
|
52
|
+
position: { top: "15%", left: "50%" },
|
|
53
|
+
axisLabel: "Z+",
|
|
54
|
+
compassLabel: "Up",
|
|
55
|
+
compassName: "above",
|
|
56
|
+
vertical: "up",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
value: "zminus",
|
|
60
|
+
face: "bottom",
|
|
61
|
+
vtkKey: "ZMinus",
|
|
62
|
+
rotation: 0,
|
|
63
|
+
position: { top: "85%", left: "50%" },
|
|
64
|
+
axisLabel: "Z-",
|
|
65
|
+
compassLabel: "Down",
|
|
66
|
+
compassName: "below",
|
|
67
|
+
vertical: "down",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
value: "yplus",
|
|
71
|
+
face: "front",
|
|
72
|
+
vtkKey: "YPlus",
|
|
73
|
+
rotation: HALF_TURN,
|
|
74
|
+
position: { top: "35%", left: "22%" },
|
|
75
|
+
axisLabel: "Y+",
|
|
76
|
+
compassLabel: "N",
|
|
77
|
+
compassName: "north",
|
|
78
|
+
heading: 0,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
value: "yminus",
|
|
82
|
+
face: "back",
|
|
83
|
+
vtkKey: "YMinus",
|
|
84
|
+
rotation: 0,
|
|
85
|
+
position: { top: "65%", left: "78%" },
|
|
86
|
+
axisLabel: "Y-",
|
|
87
|
+
compassLabel: "S",
|
|
88
|
+
compassName: "south",
|
|
89
|
+
heading: HALF_TURN,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
value: "xplus",
|
|
93
|
+
face: "right",
|
|
94
|
+
vtkKey: "XPlus",
|
|
95
|
+
rotation: QUARTER_TURN,
|
|
96
|
+
position: { top: "35%", left: "78%" },
|
|
97
|
+
axisLabel: "X+",
|
|
98
|
+
compassLabel: "E",
|
|
99
|
+
compassName: "east",
|
|
100
|
+
heading: QUARTER_TURN,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
value: "xminus",
|
|
104
|
+
face: "left",
|
|
105
|
+
vtkKey: "XMinus",
|
|
106
|
+
rotation: -QUARTER_TURN,
|
|
107
|
+
position: { top: "65%", left: "22%" },
|
|
108
|
+
axisLabel: "X-",
|
|
109
|
+
compassLabel: "W",
|
|
110
|
+
compassName: "west",
|
|
111
|
+
heading: 3 * QUARTER_TURN,
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
function cameraOrientations(marker: SceneOrientationWidget): CameraOrientation[] {
|
|
116
|
+
const isCompass = marker === "compass";
|
|
117
|
+
return ORIENTATIONS.map((entry) => ({
|
|
118
|
+
value: entry.value,
|
|
119
|
+
face: entry.face,
|
|
120
|
+
vtkKey: entry.vtkKey,
|
|
121
|
+
rotation: entry.rotation,
|
|
122
|
+
position: entry.position,
|
|
123
|
+
label: isCompass ? entry.compassLabel : entry.axisLabel,
|
|
124
|
+
tooltip: isCompass ? `View from ${entry.compassName}` : `${entry.value} View`,
|
|
125
|
+
heading: isCompass ? entry.heading : undefined,
|
|
126
|
+
vertical: isCompass ? entry.vertical : undefined,
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// The north is the brand orange, as on the scene compass
|
|
131
|
+
function isNorth(orientation: CameraOrientation): boolean {
|
|
132
|
+
return orientation.heading === 0;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export { cameraOrientations, isNorth };
|
|
136
|
+
export type { CameraOrientation, Vertical };
|
package/app/utils/import_item.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Local imports
|
|
2
2
|
import { type LegacyDataId, fromLegacyDataId } from "@ogw_front/utils/legacy_data_id";
|
|
3
3
|
import { type NewDataItem, useDataStore } from "@ogw_front/stores/data";
|
|
4
|
+
import { isModel } from "@ogw_front/utils/viewer_object_type";
|
|
4
5
|
import { useDataStyleStore } from "@ogw_front/stores/data_style";
|
|
5
6
|
import { useFeedbackStore } from "@ogw_front/stores/feedback";
|
|
6
7
|
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
@@ -10,7 +11,7 @@ import { useTreeviewStore } from "@ogw_front/stores/treeview";
|
|
|
10
11
|
async function registerWhenViewable(item: NewDataItem, added: Promise<unknown>): Promise<unknown> {
|
|
11
12
|
const dataStore = useDataStore();
|
|
12
13
|
await added;
|
|
13
|
-
if (!(await dataStore.
|
|
14
|
+
if (!(await dataStore.fetchIsViewable(item.data_id))) {
|
|
14
15
|
return undefined;
|
|
15
16
|
}
|
|
16
17
|
return dataStore.registerObject(item.data_id, item.name ?? item.data_id);
|
|
@@ -22,7 +23,7 @@ async function addToViewerWhenViewable(
|
|
|
22
23
|
): Promise<unknown> {
|
|
23
24
|
const dataStore = useDataStore();
|
|
24
25
|
await added;
|
|
25
|
-
if (!(await dataStore.
|
|
26
|
+
if (!(await dataStore.fetchIsViewable(item.data_id))) {
|
|
26
27
|
return undefined;
|
|
27
28
|
}
|
|
28
29
|
return useHybridViewerStore().addItem(item.data_id);
|
|
@@ -30,7 +31,7 @@ async function addToViewerWhenViewable(
|
|
|
30
31
|
|
|
31
32
|
async function applyStyleWhenReady(item: NewDataItem, ready: Promise<unknown>): Promise<unknown> {
|
|
32
33
|
await ready;
|
|
33
|
-
if (!(await useDataStore().
|
|
34
|
+
if (!(await useDataStore().fetchIsViewable(item.data_id))) {
|
|
34
35
|
return undefined;
|
|
35
36
|
}
|
|
36
37
|
return useDataStyleStore().applyDefaultStyle(item.data_id);
|
|
@@ -50,7 +51,7 @@ async function importDataItem(item: NewDataItem): Promise<string> {
|
|
|
50
51
|
const registerTask = registerWhenViewable(item, addDataTask);
|
|
51
52
|
let addDataComponentsTask: Promise<unknown> = Promise.resolve(undefined);
|
|
52
53
|
let addDataRelationsTask: Promise<unknown> = Promise.resolve(undefined);
|
|
53
|
-
if (item
|
|
54
|
+
if (isModel(item)) {
|
|
54
55
|
addDataComponentsTask = dataStore.addComponents(item);
|
|
55
56
|
addDataRelationsTask = dataStore.addComponentRelations(item);
|
|
56
57
|
}
|
|
@@ -11,6 +11,13 @@ const MIN_COMPASS_TILT = 0.6;
|
|
|
11
11
|
// Under this heading gap in degrees, the camera already faces the direction: nothing to turn
|
|
12
12
|
const FACING_TOLERANCE = 0.5;
|
|
13
13
|
const FULL_TURN = 360;
|
|
14
|
+
const QUARTER_TURN = 90;
|
|
15
|
+
// The dials are graduated every 30 degrees, the cardinal ticks longer
|
|
16
|
+
const TICK_STEP = 30;
|
|
17
|
+
const COMPASS_TICK_ANGLES: readonly number[] = Array.from(
|
|
18
|
+
{ length: FULL_TURN / TICK_STEP },
|
|
19
|
+
(_item, index) => index * TICK_STEP,
|
|
20
|
+
);
|
|
14
21
|
|
|
15
22
|
interface DialPoint {
|
|
16
23
|
x: number;
|
|
@@ -87,16 +94,24 @@ function facingCameraPose(
|
|
|
87
94
|
};
|
|
88
95
|
}
|
|
89
96
|
|
|
97
|
+
// Whether the dial angle, clockwise in degrees from north, is a cardinal direction (N, E, S or W)
|
|
98
|
+
function isCardinalAngle(angle: number): boolean {
|
|
99
|
+
return angle % QUARTER_TURN === 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
90
102
|
function northUpCameraPose(pose: CameraPose, basis: ViewBasis): CameraPose | undefined {
|
|
91
103
|
return facingCameraPose(pose, basis, 0);
|
|
92
104
|
}
|
|
93
105
|
|
|
94
106
|
export {
|
|
107
|
+
COMPASS_TICK_ANGLES,
|
|
95
108
|
MIN_COMPASS_TILT,
|
|
109
|
+
QUARTER_TURN,
|
|
96
110
|
compassDialPoint,
|
|
97
111
|
compassHeading,
|
|
98
112
|
compassTilt,
|
|
99
113
|
facingCameraPose,
|
|
114
|
+
isCardinalAngle,
|
|
100
115
|
isFacing,
|
|
101
116
|
northUpCameraPose,
|
|
102
117
|
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Colors of the orientation cube of the camera orientation panel (CameraOrientation.vue), from the
|
|
2
|
+
// Vuetify theme it is shown in: faces a bit off the surface, labels and edges in the surface ink,
|
|
3
|
+
// The hovered face inverted. The cube is drawn by vtk.js on canvases, so it takes CSS color strings.
|
|
4
|
+
import type { ColorRGB } from "@geode/opengeodeweb-viewer/schema_types";
|
|
5
|
+
|
|
6
|
+
const HEX_BASE = 16;
|
|
7
|
+
const CHANNEL_LENGTH = 2;
|
|
8
|
+
const HEX_COLOR = /^#?(?<hex>[\da-f]{6})/iu;
|
|
9
|
+
// Part of the ink in the face color: the faces stand out of the panel without competing with labels
|
|
10
|
+
const FACE_INK_RATIO = 0.15;
|
|
11
|
+
const EDGE_OPACITY = 0.4;
|
|
12
|
+
const HOVERED_FACE_OPACITY = 0.95;
|
|
13
|
+
|
|
14
|
+
// The cube of the dark theme, when the theme has no usable surface colors
|
|
15
|
+
const DARK_SURFACE_CHANNEL = 33;
|
|
16
|
+
const MAX_CHANNEL = 255;
|
|
17
|
+
const FALLBACK_SURFACE: ColorRGB = {
|
|
18
|
+
red: DARK_SURFACE_CHANNEL,
|
|
19
|
+
green: DARK_SURFACE_CHANNEL,
|
|
20
|
+
blue: DARK_SURFACE_CHANNEL,
|
|
21
|
+
};
|
|
22
|
+
const FALLBACK_INK: ColorRGB = { red: MAX_CHANNEL, green: MAX_CHANNEL, blue: MAX_CHANNEL };
|
|
23
|
+
|
|
24
|
+
interface CubeStyle {
|
|
25
|
+
faceColor: string;
|
|
26
|
+
fontColor: string;
|
|
27
|
+
edgeColor: string;
|
|
28
|
+
hoveredFaceColor: string;
|
|
29
|
+
hoveredFontColor: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function hexChannel(hex: string, index: number): number {
|
|
33
|
+
return Number.parseInt(hex.slice(index * CHANNEL_LENGTH, (index + 1) * CHANNEL_LENGTH), HEX_BASE);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Vuetify resolves its theme colors to #RRGGBB strings
|
|
37
|
+
function parseHex(color: unknown): ColorRGB | undefined {
|
|
38
|
+
const hex = typeof color === "string" ? HEX_COLOR.exec(color)?.groups?.hex : undefined;
|
|
39
|
+
if (hex === undefined) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
return { red: hexChannel(hex, 0), green: hexChannel(hex, 1), blue: hexChannel(hex, 2) };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function rgba({ red, green, blue }: ColorRGB, alpha = 1): string {
|
|
46
|
+
return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function mix(base: ColorRGB, ink: ColorRGB, ratio: number): ColorRGB {
|
|
50
|
+
function channel(key: keyof ColorRGB): number {
|
|
51
|
+
return Math.round(base[key] * (1 - ratio) + ink[key] * ratio);
|
|
52
|
+
}
|
|
53
|
+
return { red: channel("red"), green: channel("green"), blue: channel("blue") };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Cube colors for the theme colors (Vuetify `theme.themes[name].colors`)
|
|
57
|
+
function orientationCubeStyle(colors: Record<"surface" | "on-surface", unknown>): CubeStyle {
|
|
58
|
+
const surface = parseHex(colors.surface) ?? FALLBACK_SURFACE;
|
|
59
|
+
const ink = parseHex(colors["on-surface"]) ?? FALLBACK_INK;
|
|
60
|
+
return {
|
|
61
|
+
faceColor: rgba(mix(surface, ink, FACE_INK_RATIO)),
|
|
62
|
+
fontColor: rgba(ink),
|
|
63
|
+
edgeColor: rgba(ink, EDGE_OPACITY),
|
|
64
|
+
hoveredFaceColor: rgba(ink, HOVERED_FACE_OPACITY),
|
|
65
|
+
hoveredFontColor: rgba(surface),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { orientationCubeStyle };
|
|
70
|
+
export type { CubeStyle };
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
MODEL_COMPONENT_ATTRIBUTE_SCHEMAS,
|
|
4
4
|
MODEL_COMPONENT_KINDS,
|
|
5
5
|
} from "@ogw_front/utils/attributes";
|
|
6
|
+
import { isImage, isMesh } from "@ogw_front/utils/viewer_object_type";
|
|
6
7
|
import type { AttributeSource } from "@ogw_front/utils/threshold";
|
|
7
8
|
import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
|
|
8
9
|
import { attributeSchemas } from "@ogw_front/composables/attribute_coloring_style";
|
|
@@ -33,10 +34,10 @@ async function fetchSources(
|
|
|
33
34
|
): Promise<AttributeSource[]> {
|
|
34
35
|
const item = await dataStore.item(dataId);
|
|
35
36
|
// An image shows its own colors: it has no attribute to threshold
|
|
36
|
-
if (item
|
|
37
|
+
if (isImage(item)) {
|
|
37
38
|
return [];
|
|
38
39
|
}
|
|
39
|
-
if (item
|
|
40
|
+
if (isMesh(item)) {
|
|
40
41
|
return ["vertex", MESH_ELEMENT_KINDS[item.geode_object_type]]
|
|
41
42
|
.filter((kind): kind is string => kind !== undefined)
|
|
42
43
|
.map((kind) => attributeSource(kind, "", { id: dataId }));
|
package/app/utils/treeview.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { GeodeObjectTyped, ModelIdentified } from "@ogw_front/types/identifiers";
|
|
2
2
|
import type { TreeGroup, TreeNode } from "@ogw_front/types/tree";
|
|
3
|
+
import type { DisplayItem } from "@ogw_front/composables/virtual_tree";
|
|
4
|
+
import { isBasemapId } from "@ogw_front/utils/basemap_tree";
|
|
3
5
|
|
|
4
6
|
function compareSelections<Item>(
|
|
5
7
|
current: readonly Item[],
|
|
@@ -86,7 +88,29 @@ function withPendingImports<Child extends TreeNode, Pending extends TreeNode & G
|
|
|
86
88
|
return merged;
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
|
|
91
|
+
// In the objects tree, a data row follows its data. The basemap rows and the groups of data types
|
|
92
|
+
// Always show their toggle, except the group of horizon stacks, which open their own modal
|
|
93
|
+
function isObjectTreeRowViewable(
|
|
94
|
+
row: DisplayItem,
|
|
95
|
+
isDataViewable: (dataId: string) => boolean,
|
|
96
|
+
): boolean {
|
|
97
|
+
const { id, title } = row.raw;
|
|
98
|
+
if (typeof id !== "string" || isBasemapId(id)) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
if (row.isLeaf) {
|
|
102
|
+
return isDataViewable(id);
|
|
103
|
+
}
|
|
104
|
+
return title !== "HorizonStack3D";
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
MODEL_TREE_COLORS,
|
|
109
|
+
compareSelections,
|
|
110
|
+
isObjectTreeRowViewable,
|
|
111
|
+
nextModelTreeColor,
|
|
112
|
+
withPendingImports,
|
|
113
|
+
};
|
|
90
114
|
export type {
|
|
91
115
|
DataMenuPayload,
|
|
92
116
|
GeodeObjectTypeMenuPayload,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ViewerObjectTyped } from "@ogw_front/types/identifiers";
|
|
2
|
+
|
|
3
|
+
function isModel<Item extends Partial<ViewerObjectTyped>>(
|
|
4
|
+
item: Item,
|
|
5
|
+
): item is Item & { viewer_object_type: "model" } {
|
|
6
|
+
return item.viewer_object_type === "model";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function isMesh<Item extends Partial<ViewerObjectTyped>>(
|
|
10
|
+
item: Item,
|
|
11
|
+
): item is Item & { viewer_object_type: "mesh" } {
|
|
12
|
+
return item.viewer_object_type === "mesh";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function isImage<Item extends Partial<ViewerObjectTyped>>(
|
|
16
|
+
item: Item,
|
|
17
|
+
): item is Item & { viewer_object_type: "image" } {
|
|
18
|
+
return item.viewer_object_type === "image";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { isImage, isMesh, isModel };
|
|
@@ -7,6 +7,7 @@ import { modelComponentTypeDataStyleTable } from "./tables/model_component_type_
|
|
|
7
7
|
import { modelComponentsRelationTable } from "./tables/model_components_relation";
|
|
8
8
|
import { modelComponentsTable } from "./tables/model_components";
|
|
9
9
|
import { sceneStyleTable } from "./tables/scene_style";
|
|
10
|
+
import { treeviewConfigTable } from "./tables/treeview_config";
|
|
10
11
|
|
|
11
12
|
export class BaseDatabase extends Dexie {
|
|
12
13
|
public static get initialStores(): Record<string, string> {
|
|
@@ -19,7 +20,7 @@ export class BaseDatabase extends Dexie {
|
|
|
19
20
|
[modelComponentsRelationTable.name]: modelComponentsRelationTable.schema,
|
|
20
21
|
[cameraPositionsTable.name]: cameraPositionsTable.schema,
|
|
21
22
|
[sceneStyleTable.name]: sceneStyleTable.schema,
|
|
22
|
-
|
|
23
|
+
[treeviewConfigTable.name]: treeviewConfigTable.schema,
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
26
|
|