@geode/opengeodeweb-front 10.44.0-rc.3 → 10.44.0-rc.4
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/.build/server/utils/microservices.js +9 -85
- package/.build/server/utils/microservices_process.js +85 -0
- package/app/components/ClippingPlanes.vue +16 -82
- package/app/components/DragAndDrop.vue +1 -74
- package/app/components/ThresholdCard.vue +205 -0
- package/app/components/ThresholdFilter.vue +77 -216
- package/app/components/ViewToolbar.vue +15 -231
- package/app/components/Viewer/EdgedCurve/SpecificEdgesColoring.vue +209 -0
- package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +3 -191
- package/app/components/Viewer/Generic/Mesh/CellsColoring.vue +228 -0
- package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +3 -210
- package/app/components/Viewer/Generic/Mesh/EdgesColoring.vue +211 -0
- package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +3 -192
- package/app/components/Viewer/Generic/Mesh/PolygonsColoring.vue +234 -0
- package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +3 -215
- package/app/components/Viewer/Generic/Mesh/PolyhedraColoring.vue +221 -0
- package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +3 -203
- package/app/components/Viewer/Generic/Model/ComponentPointsOptions.vue +2 -18
- package/app/components/Viewer/Generic/Model/CornerComponentOptions.vue +145 -0
- package/app/components/Viewer/Generic/Model/CornersOptions.vue +13 -294
- package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +173 -0
- package/app/components/Viewer/Generic/Model/LineComponentOptions.vue +218 -0
- package/app/components/Viewer/Generic/Model/LinesOptions.vue +13 -425
- package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +229 -0
- package/app/components/Viewer/Options/AttributeSelector.vue +26 -133
- package/app/components/Viewer/Options/ColoringTypeSelector.vue +36 -74
- package/app/components/Viewer/Options/NoDataColorInfo.vue +56 -0
- package/app/components/Viewer/Solid/SpecificPolyhedraColoring.vue +217 -0
- package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +4 -199
- package/app/components/Viewer/Surface/PolygonsColoring.vue +231 -0
- package/app/components/Viewer/Surface/PolygonsOptions.vue +3 -213
- package/app/composables/attribute_selector.ts +126 -0
- package/app/composables/clipping_slices.ts +166 -0
- package/app/composables/view_toolbar_options.ts +126 -0
- package/app/composables/view_toolbar_tool_options.ts +115 -0
- package/app/composables/view_toolbar_tools.ts +108 -0
- package/app/composables/virtual_tree.ts +20 -138
- package/app/composables/virtual_tree_flatten.ts +86 -0
- package/app/composables/virtual_tree_types.ts +81 -0
- package/app/stores/app.ts +8 -55
- package/app/stores/app_helpers/registry.ts +69 -0
- package/app/stores/menu.ts +1 -124
- package/app/stores/menu_helpers/menus_data.ts +127 -0
- package/app/stores/viewer.ts +17 -78
- package/app/stores/viewer_helpers/actions.ts +68 -0
- package/app/stores/viewer_helpers/request.ts +61 -0
- package/app/utils/clipping_planes.ts +4 -132
- package/app/utils/clipping_planes_scene.ts +131 -0
- package/app/utils/coloring_styles.ts +101 -0
- package/app/utils/default_styles/mesh_components.ts +168 -0
- package/app/utils/default_styles/meshes.ts +13 -153
- package/app/utils/default_styles/model_components.ts +170 -0
- package/app/utils/default_styles/models.ts +16 -153
- package/app/utils/drag_and_drop.ts +80 -0
- package/app/utils/model_component_coloring.ts +46 -0
- package/app/utils/threshold.ts +33 -0
- package/app/utils/threshold_sources.ts +51 -0
- package/internal/stores/data_style/mesh/cells/cell.ts +27 -150
- package/internal/stores/data_style/mesh/cells/cell_attribute.ts +74 -0
- package/internal/stores/data_style/mesh/cells/cell_config.ts +152 -0
- package/internal/stores/data_style/mesh/cells/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/cells/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/cells/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/edges/edge.ts +27 -150
- package/internal/stores/data_style/mesh/edges/edge_attribute.ts +74 -0
- package/internal/stores/data_style/mesh/edges/edge_config.ts +152 -0
- package/internal/stores/data_style/mesh/edges/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/edges/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/edges/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/points/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/points/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/points/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/polygons/polygon.ts +27 -152
- package/internal/stores/data_style/mesh/polygons/polygon_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polygons/polygon_config.ts +148 -0
- package/internal/stores/data_style/mesh/polygons/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/polygons/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polygons/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +27 -160
- package/internal/stores/data_style/mesh/polyhedra/polyhedron_attribute.ts +82 -0
- package/internal/stores/data_style/mesh/polyhedra/polyhedron_config.ts +157 -0
- package/internal/stores/data_style/mesh/polyhedra/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/polyhedra/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polyhedra/vertex_config.ts +152 -0
- package/internal/stores/data_style/model/blocks/apply_coloring.ts +173 -0
- package/internal/stores/data_style/model/blocks/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/blocks/index.ts +12 -140
- package/internal/stores/data_style/model/common.ts +10 -119
- package/internal/stores/data_style/model/common_mutations.ts +184 -0
- package/internal/stores/data_style/model/lines/apply_coloring.ts +154 -0
- package/internal/stores/data_style/model/lines/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/lines/index.ts +10 -134
- package/internal/stores/data_style/model/surfaces/apply_coloring.ts +186 -0
- package/internal/stores/data_style/model/surfaces/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/surfaces/index.ts +16 -160
- package/internal/stores/data_style/model/visibility.ts +3 -156
- package/internal/stores/data_style/model/visibility_dispatch.ts +160 -0
- package/internal/stores/data_style/state.ts +1 -181
- package/internal/stores/data_style/state_shared.ts +191 -0
- package/internal/stores/hybrid_viewer/camera.ts +7 -161
- package/internal/stores/hybrid_viewer/camera_helpers.ts +120 -0
- package/internal/stores/hybrid_viewer/camera_orientation.ts +60 -0
- package/internal/stores/hybrid_viewer/filters.ts +54 -11
- package/package.json +1 -1
- package/server/utils/microservices.ts +10 -109
- package/server/utils/microservices_process.ts +127 -0
|
@@ -1,71 +1,13 @@
|
|
|
1
1
|
import { microservicesMetadatasPath, projectMicroservices } from "./cleanup.js";
|
|
2
2
|
import { addNginxLocation, addSupervisorProgram } from "./cloud.js";
|
|
3
|
-
import { getAvailablePort
|
|
3
|
+
import { getAvailablePort } from "./scripts.js";
|
|
4
4
|
import { executablePath } from "./path.js";
|
|
5
|
-
import
|
|
5
|
+
import { DEFAULT_RUN_ARGS, backArgs, isPortInUseError, runScript, waitUntilListening } from "./microservices_process.js";
|
|
6
6
|
import { consola } from "consola";
|
|
7
7
|
import fs from "node:fs";
|
|
8
8
|
import child_process from "node:child_process";
|
|
9
9
|
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json" with { type: "json" };
|
|
10
10
|
//#region server/utils/microservices.ts
|
|
11
|
-
const MILLISECONDS_PER_SECOND = 1e3;
|
|
12
|
-
const DEFAULT_TIMEOUT_SECONDS = 120;
|
|
13
|
-
const MAX_PORT_RETRIES = 1;
|
|
14
|
-
const DEFAULT_RUN_ARGS = { projectFolderPath: "" };
|
|
15
|
-
const LISTENING_LOG_PATTERN = /^Listening on https?:\/\/.+:\d+\/?\s*$/mu;
|
|
16
|
-
async function runScript(execPath, execName, args, expectedResponse, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) {
|
|
17
|
-
const command = executablePath(execPath, execName);
|
|
18
|
-
consola.debug("runScript", command, args);
|
|
19
|
-
const child = child_process.spawn(command, args, { stdio: [
|
|
20
|
-
"ignore",
|
|
21
|
-
"pipe",
|
|
22
|
-
"pipe"
|
|
23
|
-
] });
|
|
24
|
-
child.name = command.replace(/^.*[\\/]/u, "");
|
|
25
|
-
child.on("spawn", () => {
|
|
26
|
-
consola.info(`[${child.name}] spawned, pid=${child.pid}`);
|
|
27
|
-
});
|
|
28
|
-
const controller = new AbortController();
|
|
29
|
-
const timer = setTimeout(() => {
|
|
30
|
-
controller.abort();
|
|
31
|
-
}, timeoutSeconds * MILLISECONDS_PER_SECOND);
|
|
32
|
-
if (typeof timer.unref === "function") timer.unref();
|
|
33
|
-
try {
|
|
34
|
-
const result = await waitForReady(child, expectedResponse, controller.signal);
|
|
35
|
-
clearTimeout(timer);
|
|
36
|
-
return result;
|
|
37
|
-
} catch (error) {
|
|
38
|
-
clearTimeout(timer);
|
|
39
|
-
child.kill();
|
|
40
|
-
throw error;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function isPortInUseError(error) {
|
|
44
|
-
return /EADDRINUSE|address already in use|port already in use/iu.test(String(error));
|
|
45
|
-
}
|
|
46
|
-
function resolveUploadFolderPath(projectFolderPath, uploadFolderPath) {
|
|
47
|
-
if (uploadFolderPath !== void 0 && uploadFolderPath !== "") return uploadFolderPath;
|
|
48
|
-
return path.join(projectFolderPath, "uploads");
|
|
49
|
-
}
|
|
50
|
-
function backArgs(args, port) {
|
|
51
|
-
const { projectFolderPath } = args;
|
|
52
|
-
if (!projectFolderPath) throw new Error("projectFolderPath is required");
|
|
53
|
-
const uploadFolderPath = resolveUploadFolderPath(projectFolderPath, args.uploadFolderPath);
|
|
54
|
-
const executableArgs = [
|
|
55
|
-
"--port",
|
|
56
|
-
String(port),
|
|
57
|
-
"--project_folder_path",
|
|
58
|
-
projectFolderPath,
|
|
59
|
-
"--upload_folder_path",
|
|
60
|
-
uploadFolderPath,
|
|
61
|
-
"--allowed_origins",
|
|
62
|
-
"http://localhost:*",
|
|
63
|
-
"--timeout",
|
|
64
|
-
"0"
|
|
65
|
-
];
|
|
66
|
-
if (process.env.NODE_ENV === void 0 || process.env.NODE_ENV === "development") executableArgs.push("--debug");
|
|
67
|
-
return executableArgs;
|
|
68
|
-
}
|
|
69
11
|
async function runBack(execName, execPath, args = DEFAULT_RUN_ARGS, attempts = 0) {
|
|
70
12
|
let port = void 0;
|
|
71
13
|
try {
|
|
@@ -79,7 +21,7 @@ async function runBack(execName, execPath, args = DEFAULT_RUN_ARGS, attempts = 0
|
|
|
79
21
|
consola.error("runBack error", error);
|
|
80
22
|
throw error;
|
|
81
23
|
}
|
|
82
|
-
if (attempts <=
|
|
24
|
+
if (attempts <= 1) {
|
|
83
25
|
consola.info("Retrying runBack on conflicting port", port);
|
|
84
26
|
return await runBack(execName, execPath, args, attempts + 1);
|
|
85
27
|
}
|
|
@@ -108,7 +50,7 @@ async function runViewer(execName, execPath, args = DEFAULT_RUN_ARGS, attempts =
|
|
|
108
50
|
consola.error("runViewer error", error);
|
|
109
51
|
throw error;
|
|
110
52
|
}
|
|
111
|
-
if (attempts <=
|
|
53
|
+
if (attempts <= 1) {
|
|
112
54
|
consola.info("Retrying runViewer on conflicting port", port);
|
|
113
55
|
return await runViewer(execName, execPath, args, attempts + 1);
|
|
114
56
|
}
|
|
@@ -130,48 +72,30 @@ async function runExtension(extensionId, execName, execPath, args = DEFAULT_RUN_
|
|
|
130
72
|
consola.error("runExtension error", error);
|
|
131
73
|
throw error;
|
|
132
74
|
}
|
|
133
|
-
if (attempts <=
|
|
75
|
+
if (attempts <= 1) {
|
|
134
76
|
consola.info("Retrying runExtension on conflicting port", port);
|
|
135
77
|
return await runExtension(extensionId, execName, execPath, args, attempts + 1);
|
|
136
78
|
}
|
|
137
79
|
}
|
|
138
80
|
throw new Error(`runExtension failed to run ${extensionId}`);
|
|
139
81
|
}
|
|
140
|
-
async function waitUntilListening(child) {
|
|
141
|
-
child.stderr.on("data", (data) => {
|
|
142
|
-
consola.info(`[${child.spawnfile}] STDERR:`, data.toString().trim());
|
|
143
|
-
});
|
|
144
|
-
child.on("close", (code) => {
|
|
145
|
-
consola.info(`[${child.spawnfile}] exited with code ${code}`);
|
|
146
|
-
});
|
|
147
|
-
for await (const chunk of child.stdout) {
|
|
148
|
-
const output = String(chunk);
|
|
149
|
-
consola.info(`[${child.spawnfile}] STDOUT:`, output.trim());
|
|
150
|
-
if (LISTENING_LOG_PATTERN.test(output)) {
|
|
151
|
-
child.stdout.on("data", (data) => {
|
|
152
|
-
consola.info(`[${child.spawnfile}] STDOUT:`, data.toString().trim());
|
|
153
|
-
});
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
throw new Error(`${child.spawnfile} exited before becoming ready`);
|
|
158
|
-
}
|
|
159
82
|
async function runExtensionServer(entryPath, attempts = 0) {
|
|
160
83
|
let port = void 0;
|
|
161
84
|
try {
|
|
162
85
|
port = await getAvailablePort();
|
|
163
86
|
consola.info("runExtensionServer", entryPath, port);
|
|
164
|
-
|
|
87
|
+
const child = child_process.spawn("node", [entryPath], { env: {
|
|
165
88
|
...process.env,
|
|
166
89
|
PORT: String(port)
|
|
167
|
-
} })
|
|
90
|
+
} });
|
|
91
|
+
await waitUntilListening(child);
|
|
168
92
|
return port;
|
|
169
93
|
} catch (error) {
|
|
170
94
|
if (!isPortInUseError(error)) {
|
|
171
95
|
consola.error("runExtensionServer error", error);
|
|
172
96
|
throw error;
|
|
173
97
|
}
|
|
174
|
-
if (attempts <=
|
|
98
|
+
if (attempts <= 1) {
|
|
175
99
|
consola.warn("Retrying runExtensionServer on conflicting port", port);
|
|
176
100
|
return await runExtensionServer(entryPath, attempts + 1);
|
|
177
101
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { waitForReady } from "./scripts.js";
|
|
2
|
+
import { executablePath } from "./path.js";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { consola } from "consola";
|
|
5
|
+
import child_process from "node:child_process";
|
|
6
|
+
//#region server/utils/microservices_process.ts
|
|
7
|
+
const MILLISECONDS_PER_SECOND = 1e3;
|
|
8
|
+
const DEFAULT_TIMEOUT_SECONDS = 120;
|
|
9
|
+
const MAX_PORT_RETRIES = 1;
|
|
10
|
+
const DEFAULT_RUN_ARGS = { projectFolderPath: "" };
|
|
11
|
+
const LISTENING_LOG_PATTERN = /^Listening on https?:\/\/.+:\d+\/?\s*$/mu;
|
|
12
|
+
async function runScript(execPath, execName, args, expectedResponse, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) {
|
|
13
|
+
const command = executablePath(execPath, execName);
|
|
14
|
+
consola.debug("runScript", command, args);
|
|
15
|
+
const child = child_process.spawn(command, args, { stdio: [
|
|
16
|
+
"ignore",
|
|
17
|
+
"pipe",
|
|
18
|
+
"pipe"
|
|
19
|
+
] });
|
|
20
|
+
child.name = command.replace(/^.*[\\/]/u, "");
|
|
21
|
+
child.on("spawn", () => {
|
|
22
|
+
consola.info(`[${child.name}] spawned, pid=${child.pid}`);
|
|
23
|
+
});
|
|
24
|
+
const controller = new AbortController();
|
|
25
|
+
const timer = setTimeout(() => {
|
|
26
|
+
controller.abort();
|
|
27
|
+
}, timeoutSeconds * MILLISECONDS_PER_SECOND);
|
|
28
|
+
if (typeof timer.unref === "function") timer.unref();
|
|
29
|
+
try {
|
|
30
|
+
const result = await waitForReady(child, expectedResponse, controller.signal);
|
|
31
|
+
clearTimeout(timer);
|
|
32
|
+
return result;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
clearTimeout(timer);
|
|
35
|
+
child.kill();
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function isPortInUseError(error) {
|
|
40
|
+
return /EADDRINUSE|address already in use|port already in use/iu.test(String(error));
|
|
41
|
+
}
|
|
42
|
+
function resolveUploadFolderPath(projectFolderPath, uploadFolderPath) {
|
|
43
|
+
if (uploadFolderPath !== void 0 && uploadFolderPath !== "") return uploadFolderPath;
|
|
44
|
+
return path.join(projectFolderPath, "uploads");
|
|
45
|
+
}
|
|
46
|
+
function backArgs(args, port) {
|
|
47
|
+
const { projectFolderPath } = args;
|
|
48
|
+
if (!projectFolderPath) throw new Error("projectFolderPath is required");
|
|
49
|
+
const uploadFolderPath = resolveUploadFolderPath(projectFolderPath, args.uploadFolderPath);
|
|
50
|
+
const executableArgs = [
|
|
51
|
+
"--port",
|
|
52
|
+
String(port),
|
|
53
|
+
"--project_folder_path",
|
|
54
|
+
projectFolderPath,
|
|
55
|
+
"--upload_folder_path",
|
|
56
|
+
uploadFolderPath,
|
|
57
|
+
"--allowed_origins",
|
|
58
|
+
"http://localhost:*",
|
|
59
|
+
"--timeout",
|
|
60
|
+
"0"
|
|
61
|
+
];
|
|
62
|
+
if (process.env.NODE_ENV === void 0 || process.env.NODE_ENV === "development") executableArgs.push("--debug");
|
|
63
|
+
return executableArgs;
|
|
64
|
+
}
|
|
65
|
+
async function waitUntilListening(child) {
|
|
66
|
+
child.stderr.on("data", (data) => {
|
|
67
|
+
consola.info(`[${child.spawnfile}] STDERR:`, data.toString().trim());
|
|
68
|
+
});
|
|
69
|
+
child.on("close", (code) => {
|
|
70
|
+
consola.info(`[${child.spawnfile}] exited with code ${code}`);
|
|
71
|
+
});
|
|
72
|
+
for await (const chunk of child.stdout) {
|
|
73
|
+
const output = String(chunk);
|
|
74
|
+
consola.info(`[${child.spawnfile}] STDOUT:`, output.trim());
|
|
75
|
+
if (LISTENING_LOG_PATTERN.test(output)) {
|
|
76
|
+
child.stdout.on("data", (data) => {
|
|
77
|
+
consola.info(`[${child.spawnfile}] STDOUT:`, data.toString().trim());
|
|
78
|
+
});
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
throw new Error(`${child.spawnfile} exited before becoming ready`);
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { DEFAULT_RUN_ARGS, MAX_PORT_RETRIES, backArgs, isPortInUseError, runScript, waitUntilListening };
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { DEBOUNCE_DELAY, DEFAULT_NORMALS } from "@ogw_front/utils/clipping_planes";
|
|
3
|
-
import {
|
|
4
|
-
DEFAULT_SLICE_AXIS,
|
|
5
|
-
SLICE_AXES,
|
|
6
|
-
type SliceAxis,
|
|
7
|
-
areAllGrids,
|
|
8
|
-
} from "@ogw_front/utils/slice";
|
|
9
3
|
import type { ClippingPlane } from "@ogw_front/composables/clipping_planes_widget_entries";
|
|
10
4
|
import ClippingPlaneCard from "@ogw_front/components/ClippingPlaneCard.vue";
|
|
11
5
|
import SliceCard from "@ogw_front/components/SliceCard.vue";
|
|
12
6
|
import ToolPanel from "@ogw_front/components/ToolPanel.vue";
|
|
13
7
|
import { useClippingPlanesWidget } from "@ogw_front/composables/clipping_planes_widget";
|
|
8
|
+
import { useClippingSlices } from "@ogw_front/composables/clipping_slices";
|
|
14
9
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
15
10
|
import { useDebounceFn } from "@vueuse/core";
|
|
16
11
|
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
@@ -33,19 +28,12 @@ function newItemId(): number {
|
|
|
33
28
|
}
|
|
34
29
|
const planes = ref<ClippingPlane[]>([{ id: newItemId(), origin: undefined, normal: [1, 0, 0] }]);
|
|
35
30
|
const allItems = dataStore.refRegisteredItems();
|
|
36
|
-
const sliceEnabled = ref<boolean>(false);
|
|
37
|
-
const slices = ref<{ id: number; axis: SliceAxis; index: number }[]>([
|
|
38
|
-
{ id: newItemId(), axis: DEFAULT_SLICE_AXIS, index: 0 },
|
|
39
|
-
]);
|
|
40
|
-
const sliceMaxIndices = ref<[number, number, number]>([0, 0, 0]);
|
|
41
31
|
const targetIds = computed<string[]>(() => {
|
|
42
32
|
if (targetAllVisible.value) {
|
|
43
33
|
return allItems.value.map((item) => item.id);
|
|
44
34
|
}
|
|
45
35
|
return selectedDatasetIds.value;
|
|
46
36
|
});
|
|
47
|
-
const isAllGrid = computed<boolean>(() => areAllGrids(allItems.value, targetIds.value));
|
|
48
|
-
const isSliceActive = computed<boolean>(() => isAllGrid.value && sliceEnabled.value);
|
|
49
37
|
const availableDatasets = computed<{ title: string; value: string }[]>(() =>
|
|
50
38
|
allItems.value.map((item) => ({
|
|
51
39
|
title: item.name || item.id,
|
|
@@ -54,8 +42,6 @@ const availableDatasets = computed<{ title: string; value: string }[]>(() =>
|
|
|
54
42
|
);
|
|
55
43
|
const widgetContainer = useTemplateRef("widgetContainer");
|
|
56
44
|
let debouncedApply: ((...args: unknown[]) => void) | undefined = undefined;
|
|
57
|
-
let areSlicesApplied = false;
|
|
58
|
-
let pendingSlices: Promise<void> = Promise.resolve();
|
|
59
45
|
|
|
60
46
|
const {
|
|
61
47
|
getSceneCenter,
|
|
@@ -79,6 +65,19 @@ function getUntargetedIds(): string[] {
|
|
|
79
65
|
return allItems.value.map((item) => item.id).filter((id) => !targetIds.value.includes(id));
|
|
80
66
|
}
|
|
81
67
|
|
|
68
|
+
const {
|
|
69
|
+
sliceEnabled,
|
|
70
|
+
slices,
|
|
71
|
+
sliceMaxIndices,
|
|
72
|
+
isAllGrid,
|
|
73
|
+
isSliceActive,
|
|
74
|
+
applySlices,
|
|
75
|
+
addSlice,
|
|
76
|
+
removeSlice,
|
|
77
|
+
resetSlices,
|
|
78
|
+
removeSlices,
|
|
79
|
+
} = useClippingSlices({ allItems, targetIds, getUntargetedIds, newItemId, hybridViewerStore });
|
|
80
|
+
|
|
82
81
|
async function applyClippingPlanes(): Promise<void> {
|
|
83
82
|
if (allItems.value.length === 0) {
|
|
84
83
|
return;
|
|
@@ -100,52 +99,6 @@ async function applyClippingPlanes(): Promise<void> {
|
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
|
|
103
|
-
function getSlicesPayload(isActive: boolean): { axis: SliceAxis; index: number }[] {
|
|
104
|
-
if (!isActive) {
|
|
105
|
-
return [];
|
|
106
|
-
}
|
|
107
|
-
return slices.value.map(({ axis, index }) => ({ axis, index }));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async function sendSlices(): Promise<void> {
|
|
111
|
-
if (!isAllGrid.value && !areSlicesApplied) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const isActive = isSliceActive.value;
|
|
115
|
-
const untargetedIds = getUntargetedIds();
|
|
116
|
-
if (targetIds.value.length > 0) {
|
|
117
|
-
const maxIndices = await hybridViewerStore.setSlice(
|
|
118
|
-
targetIds.value,
|
|
119
|
-
getSlicesPayload(isActive),
|
|
120
|
-
);
|
|
121
|
-
if (isAllGrid.value) {
|
|
122
|
-
sliceMaxIndices.value = maxIndices;
|
|
123
|
-
}
|
|
124
|
-
if (isActive) {
|
|
125
|
-
for (const slice of slices.value) {
|
|
126
|
-
slice.index = Math.min(slice.index, maxIndices[slice.axis]);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (areSlicesApplied && untargetedIds.length > 0) {
|
|
131
|
-
await hybridViewerStore.setSlice(untargetedIds, []);
|
|
132
|
-
}
|
|
133
|
-
areSlicesApplied = isActive;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function queueSliceTask(task: () => Promise<void>): Promise<void> {
|
|
137
|
-
const previous = pendingSlices;
|
|
138
|
-
pendingSlices = (async (): Promise<void> => {
|
|
139
|
-
await Promise.allSettled([previous]);
|
|
140
|
-
await task();
|
|
141
|
-
})();
|
|
142
|
-
return pendingSlices;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function applySlices(): Promise<void> {
|
|
146
|
-
return queueSliceTask(sendSlices);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
102
|
async function applyAll(): Promise<void> {
|
|
150
103
|
await applyClippingPlanes();
|
|
151
104
|
await applySlices();
|
|
@@ -166,19 +119,6 @@ function removePlane(index: number): void {
|
|
|
166
119
|
planes.value.splice(index, 1);
|
|
167
120
|
}
|
|
168
121
|
|
|
169
|
-
function addSlice(): void {
|
|
170
|
-
const lastSlice = slices.value.at(-1);
|
|
171
|
-
slices.value.push({
|
|
172
|
-
id: newItemId(),
|
|
173
|
-
axis: lastSlice ? SLICE_AXES[lastSlice.axis].next : DEFAULT_SLICE_AXIS,
|
|
174
|
-
index: 0,
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function removeSlice(index: number): void {
|
|
179
|
-
slices.value.splice(index, 1);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
122
|
function flipNormal(plane: { normal: number[] }): void {
|
|
183
123
|
plane.normal = plane.normal.map((component) => -component);
|
|
184
124
|
syncWidgets();
|
|
@@ -188,8 +128,7 @@ function flipNormal(plane: { normal: number[] }): void {
|
|
|
188
128
|
async function resetClippingPlanes(): Promise<void> {
|
|
189
129
|
setFromWidget(true);
|
|
190
130
|
planes.value = [{ id: newItemId(), origin: undefined, normal: [1, 0, 0] }];
|
|
191
|
-
|
|
192
|
-
slices.value = [{ id: newItemId(), axis: DEFAULT_SLICE_AXIS, index: 0 }];
|
|
131
|
+
resetSlices();
|
|
193
132
|
updateWidgetPlacement({ isReset: true });
|
|
194
133
|
setFromWidget(false);
|
|
195
134
|
await applyAll();
|
|
@@ -198,12 +137,7 @@ async function resetClippingPlanes(): Promise<void> {
|
|
|
198
137
|
async function removeClippingPlanes(): Promise<void> {
|
|
199
138
|
const allIds = allItems.value.map((item) => item.id);
|
|
200
139
|
await hybridViewerStore.setClippingPlanes(allIds, []);
|
|
201
|
-
await
|
|
202
|
-
if (areSlicesApplied) {
|
|
203
|
-
await hybridViewerStore.setSlice(allIds, []);
|
|
204
|
-
areSlicesApplied = false;
|
|
205
|
-
}
|
|
206
|
-
});
|
|
140
|
+
await removeSlices(allIds);
|
|
207
141
|
}
|
|
208
142
|
|
|
209
143
|
watch(widgetContainer, (container) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { filesFromEntry, isFileAccepted } from "@ogw_front/utils/drag_and_drop";
|
|
2
3
|
import DragAndDropInline from "./DragAndDropInternal/DragAndDropInline.vue";
|
|
3
4
|
import DragAndDropOverlay from "./DragAndDropInternal/DragAndDropOverlay.vue";
|
|
4
5
|
import type { UploadFile } from "@ogw_front/utils/upload_path";
|
|
@@ -56,8 +57,6 @@ const isInternalDrag = ref(false);
|
|
|
56
57
|
const dragCounter = ref(0);
|
|
57
58
|
const fileInput = ref<HTMLInputElement | undefined>(undefined);
|
|
58
59
|
|
|
59
|
-
const WILDCARD_SUFFIX_LENGTH = 2;
|
|
60
|
-
|
|
61
60
|
function getErrorMessage(error: unknown): string {
|
|
62
61
|
if (error instanceof Error) {
|
|
63
62
|
return error.message;
|
|
@@ -65,50 +64,6 @@ function getErrorMessage(error: unknown): string {
|
|
|
65
64
|
return String(error);
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
function isFileAccepted(file: File, acceptValue: string | string[] | undefined): boolean {
|
|
69
|
-
const fileName = (file.name || "").toLowerCase();
|
|
70
|
-
const fileType = (file.type || "").toLowerCase();
|
|
71
|
-
const isVext = fileName.endsWith(".vext");
|
|
72
|
-
|
|
73
|
-
if (!acceptValue) {
|
|
74
|
-
return !isVext;
|
|
75
|
-
}
|
|
76
|
-
let rules: string[] = [];
|
|
77
|
-
if (Array.isArray(acceptValue)) {
|
|
78
|
-
rules = acceptValue;
|
|
79
|
-
} else if (typeof acceptValue === "string") {
|
|
80
|
-
rules = acceptValue.split(",");
|
|
81
|
-
}
|
|
82
|
-
rules = rules.map((rule) => String(rule).trim()).filter(Boolean);
|
|
83
|
-
if (rules.length === 0) {
|
|
84
|
-
return !isVext;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return rules.some((rule) => {
|
|
88
|
-
let cleanRule = rule.toLowerCase();
|
|
89
|
-
if (!cleanRule) {
|
|
90
|
-
return !isVext;
|
|
91
|
-
}
|
|
92
|
-
if (cleanRule === "*" || cleanRule === "*.*") {
|
|
93
|
-
return !isVext;
|
|
94
|
-
}
|
|
95
|
-
if (cleanRule.startsWith("*.")) {
|
|
96
|
-
cleanRule = cleanRule.slice(1);
|
|
97
|
-
}
|
|
98
|
-
if (cleanRule.startsWith(".")) {
|
|
99
|
-
return fileName.endsWith(cleanRule);
|
|
100
|
-
}
|
|
101
|
-
if (cleanRule.includes("/")) {
|
|
102
|
-
if (cleanRule.endsWith("/*")) {
|
|
103
|
-
const typeGroup = cleanRule.slice(0, -WILDCARD_SUFFIX_LENGTH);
|
|
104
|
-
return fileType.startsWith(typeGroup);
|
|
105
|
-
}
|
|
106
|
-
return fileType === cleanRule;
|
|
107
|
-
}
|
|
108
|
-
return fileName.endsWith(`.${cleanRule}`);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
67
|
function triggerFileDialog(): void {
|
|
113
68
|
fileInput.value?.click();
|
|
114
69
|
}
|
|
@@ -134,34 +89,6 @@ function onDragOver(event: DragEvent): void {
|
|
|
134
89
|
}
|
|
135
90
|
}
|
|
136
91
|
|
|
137
|
-
async function readAllEntries(reader: FileSystemDirectoryReader): Promise<FileSystemEntry[]> {
|
|
138
|
-
// oxlint-disable-next-line promise/avoid-new
|
|
139
|
-
const batch = await new Promise<FileSystemEntry[]>((resolve, reject) => {
|
|
140
|
-
reader.readEntries(resolve, reject);
|
|
141
|
-
});
|
|
142
|
-
if (batch.length === 0) {
|
|
143
|
-
return [];
|
|
144
|
-
}
|
|
145
|
-
return [...batch, ...(await readAllEntries(reader))];
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async function filesFromEntry(entry: FileSystemEntry, path: string): Promise<UploadFile[]> {
|
|
149
|
-
if (entry.isFile) {
|
|
150
|
-
// oxlint-disable-next-line promise/avoid-new
|
|
151
|
-
const file = await new Promise<File>((resolve, reject) => {
|
|
152
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- isFile guarantees a FileSystemFileEntry
|
|
153
|
-
(entry as FileSystemFileEntry).file(resolve, reject);
|
|
154
|
-
});
|
|
155
|
-
return [Object.assign(file, { relativePath: path })];
|
|
156
|
-
}
|
|
157
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- not a file, so a FileSystemDirectoryEntry
|
|
158
|
-
const children = await readAllEntries((entry as FileSystemDirectoryEntry).createReader());
|
|
159
|
-
const nested = await Promise.all(
|
|
160
|
-
children.map((child) => filesFromEntry(child, `${path}/${child.name}`)),
|
|
161
|
-
);
|
|
162
|
-
return nested.flat();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
92
|
async function emitDroppedEntries(entries: FileSystemEntry[]): Promise<void> {
|
|
166
93
|
try {
|
|
167
94
|
const groups = await Promise.all(
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
type AttributeInfo,
|
|
4
|
+
type AttributeSource,
|
|
5
|
+
isValidThresholdAttribute,
|
|
6
|
+
} from "@ogw_front/utils/threshold";
|
|
7
|
+
import type { Threshold, ThresholdAttribute } from "@ogw_internal/stores/hybrid_viewer/filters";
|
|
8
|
+
import { attributeArrayName, getAttributeRange } from "@ogw_front/utils/attributes";
|
|
9
|
+
import ViewerOptionsAttributeRangeSelector from "@ogw_front/components/Viewer/Options/AttributeRangeSelector.vue";
|
|
10
|
+
import { fetchAttributeRange } from "@ogw_front/utils/attribute_range";
|
|
11
|
+
import { useBackStore } from "@ogw_front/stores/back";
|
|
12
|
+
import { useDataStyleStore } from "@ogw_front/stores/data_style";
|
|
13
|
+
|
|
14
|
+
interface Props {
|
|
15
|
+
datasetId: string;
|
|
16
|
+
sources: AttributeSource[];
|
|
17
|
+
index: number;
|
|
18
|
+
threshold: Threshold;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const { datasetId, sources, index, threshold } = defineProps<Props>();
|
|
22
|
+
|
|
23
|
+
interface Emits {
|
|
24
|
+
remove: [];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const emit = defineEmits<Emits>();
|
|
28
|
+
|
|
29
|
+
const backStore = useBackStore();
|
|
30
|
+
const dataStyleStore = useDataStyleStore();
|
|
31
|
+
const {
|
|
32
|
+
sourceIndex: selectedSourceIndex,
|
|
33
|
+
attributeName,
|
|
34
|
+
item: attributeItem,
|
|
35
|
+
minimum,
|
|
36
|
+
maximum,
|
|
37
|
+
thresholdAttribute,
|
|
38
|
+
} = toRefs(threshold);
|
|
39
|
+
const attributes = ref<AttributeInfo[]>([]);
|
|
40
|
+
|
|
41
|
+
const availableSources = computed<{ title: string; value: number }[]>(() =>
|
|
42
|
+
sources.map((source, sourceIndex) => ({
|
|
43
|
+
title: source.title,
|
|
44
|
+
value: sourceIndex,
|
|
45
|
+
})),
|
|
46
|
+
);
|
|
47
|
+
const currentSource = computed<AttributeSource | undefined>(
|
|
48
|
+
() => sources[selectedSourceIndex.value ?? -1],
|
|
49
|
+
);
|
|
50
|
+
const currentAttribute = computed<AttributeInfo | undefined>(() =>
|
|
51
|
+
attributes.value.find((attribute) => attribute.attribute_name === attributeName.value),
|
|
52
|
+
);
|
|
53
|
+
const currentTimeStep = computed<number | undefined>(() => {
|
|
54
|
+
if (!currentSource.value || !currentAttribute.value?.time_steps?.length) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const step =
|
|
58
|
+
dataStyleStore.attributeTimeStep(
|
|
59
|
+
datasetId,
|
|
60
|
+
currentSource.value.timeStepKey,
|
|
61
|
+
attributeName.value,
|
|
62
|
+
) ?? 0;
|
|
63
|
+
return Math.min(step, currentAttribute.value.time_steps.length - 1);
|
|
64
|
+
});
|
|
65
|
+
const itemOptions = computed<{ title: string; value: number }[]>(() =>
|
|
66
|
+
Array.from({ length: currentAttribute.value?.nb_items ?? 0 }, (_, itemIndex) => ({
|
|
67
|
+
title: `Item ${itemIndex + 1}`,
|
|
68
|
+
value: itemIndex,
|
|
69
|
+
})),
|
|
70
|
+
);
|
|
71
|
+
const currentThresholdAttribute = computed<ThresholdAttribute | undefined>(() => {
|
|
72
|
+
if (!currentAttribute.value) {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
const attribute = {
|
|
76
|
+
name: attributeArrayName(currentAttribute.value.attribute_name, currentTimeStep.value),
|
|
77
|
+
location: currentSource.value?.location,
|
|
78
|
+
item: attributeItem.value,
|
|
79
|
+
minimum: minimum.value,
|
|
80
|
+
maximum: maximum.value,
|
|
81
|
+
};
|
|
82
|
+
return isValidThresholdAttribute(attribute) ? attribute : undefined;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
async function resetRange(): Promise<void> {
|
|
86
|
+
const source = currentSource.value;
|
|
87
|
+
const name = attributeName.value;
|
|
88
|
+
if (!source || name === undefined) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const range = await fetchAttributeRange(source.schemas.range, source.params, name);
|
|
92
|
+
if (name !== attributeName.value) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const { min, max } = getAttributeRange(range, attributeItem.value);
|
|
96
|
+
minimum.value = min;
|
|
97
|
+
maximum.value = max;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function fetchAttributes(): Promise<void> {
|
|
101
|
+
attributes.value = [];
|
|
102
|
+
const source = currentSource.value;
|
|
103
|
+
if (!source) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const response = (await backStore.request({
|
|
107
|
+
schema: source.schemas.names,
|
|
108
|
+
params: source.params,
|
|
109
|
+
})) as { attributes: AttributeInfo[] };
|
|
110
|
+
attributes.value = response.attributes;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
onMounted(fetchAttributes);
|
|
114
|
+
|
|
115
|
+
watch(selectedSourceIndex, async () => {
|
|
116
|
+
attributeName.value = undefined;
|
|
117
|
+
await fetchAttributes();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
watch(attributeName, async () => {
|
|
121
|
+
attributeItem.value = 0;
|
|
122
|
+
await resetRange();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
watch(attributeItem, async () => {
|
|
126
|
+
await resetRange();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
watch(currentThresholdAttribute, (value) => {
|
|
130
|
+
thresholdAttribute.value = value;
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
defineExpose({ resetRange });
|
|
134
|
+
</script>
|
|
135
|
+
|
|
136
|
+
<template>
|
|
137
|
+
<v-card
|
|
138
|
+
data-testid="thresholdCard"
|
|
139
|
+
variant="outlined"
|
|
140
|
+
class="pa-2 mb-3 rounded-lg border-opacity-50"
|
|
141
|
+
>
|
|
142
|
+
<v-row align="center" justify="space-between" no-gutters class="mb-2">
|
|
143
|
+
<v-col cols="auto">
|
|
144
|
+
<v-chip size="x-small" variant="flat" color="primary" class="font-weight-bold">
|
|
145
|
+
Threshold #{{ index + 1 }}
|
|
146
|
+
</v-chip>
|
|
147
|
+
</v-col>
|
|
148
|
+
<v-col cols="auto">
|
|
149
|
+
<v-btn
|
|
150
|
+
data-testid="removeThresholdCardButton"
|
|
151
|
+
icon="mdi-trash-can-outline"
|
|
152
|
+
size="x-small"
|
|
153
|
+
variant="text"
|
|
154
|
+
color="error"
|
|
155
|
+
@click="emit('remove')"
|
|
156
|
+
/>
|
|
157
|
+
</v-col>
|
|
158
|
+
</v-row>
|
|
159
|
+
|
|
160
|
+
<v-select
|
|
161
|
+
v-model="selectedSourceIndex"
|
|
162
|
+
data-testid="thresholdAttributeTypeSelect"
|
|
163
|
+
:items="availableSources"
|
|
164
|
+
label="Select an attribute type"
|
|
165
|
+
variant="outlined"
|
|
166
|
+
density="compact"
|
|
167
|
+
hide-details
|
|
168
|
+
class="mb-3 text-caption"
|
|
169
|
+
/>
|
|
170
|
+
|
|
171
|
+
<v-select
|
|
172
|
+
v-if="selectedSourceIndex !== undefined"
|
|
173
|
+
v-model="attributeName"
|
|
174
|
+
data-testid="thresholdAttributeSelect"
|
|
175
|
+
:items="attributes.map((attribute) => attribute.attribute_name)"
|
|
176
|
+
label="Select an attribute"
|
|
177
|
+
variant="outlined"
|
|
178
|
+
density="compact"
|
|
179
|
+
hide-details
|
|
180
|
+
class="mb-3 text-caption"
|
|
181
|
+
/>
|
|
182
|
+
|
|
183
|
+
<v-select
|
|
184
|
+
v-if="currentAttribute && currentAttribute.nb_items > 1"
|
|
185
|
+
v-model="attributeItem"
|
|
186
|
+
data-testid="thresholdItemSelect"
|
|
187
|
+
:items="itemOptions"
|
|
188
|
+
label="Select an item"
|
|
189
|
+
variant="outlined"
|
|
190
|
+
density="compact"
|
|
191
|
+
hide-details
|
|
192
|
+
class="mb-3 text-caption"
|
|
193
|
+
/>
|
|
194
|
+
|
|
195
|
+
<template v-if="attributeName">
|
|
196
|
+
<span class="text-caption font-weight-bold">Range</span>
|
|
197
|
+
<ViewerOptionsAttributeRangeSelector
|
|
198
|
+
v-model:minimum="minimum"
|
|
199
|
+
v-model:maximum="maximum"
|
|
200
|
+
class="mt-2"
|
|
201
|
+
@reset="resetRange"
|
|
202
|
+
/>
|
|
203
|
+
</template>
|
|
204
|
+
</v-card>
|
|
205
|
+
</template>
|