@geode/opengeodeweb-front 10.43.1 → 10.43.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/components/Viewer/ObjectTree/Base/CommonTreeView.vue +18 -0
- package/app/components/ZScaling.vue +2 -1
- package/app/composables/tree_keyboard_nav.ts +18 -1
- package/app/stores/hybrid_viewer.ts +2 -5
- package/internal/stores/hybrid_viewer/camera.ts +1 -12
- package/internal/stores/hybrid_viewer/camera_animation.ts +12 -0
- package/internal/stores/hybrid_viewer/scene.ts +26 -9
- package/internal/stores/hybrid_viewer/zoom_box.ts +2 -6
- package/package.json +1 -1
|
@@ -148,6 +148,22 @@ function handleItemClick(
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
function selectAllLeaves(): void {
|
|
152
|
+
const leafIds = displayItems.value
|
|
153
|
+
.filter((rowItem) => rowItem.isLeaf)
|
|
154
|
+
.map((rowItem) => rowItem.raw[actualItemProps.value.value]);
|
|
155
|
+
emit("update:active", leafIds);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function clearActive(): boolean {
|
|
159
|
+
if (active.length === 0) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
lastActiveIndex.value = -1;
|
|
163
|
+
emit("update:active", []);
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
|
|
151
167
|
const { handleKeyDown } = useTreeKeyboardNav(
|
|
152
168
|
displayItems,
|
|
153
169
|
emit as EmitFn,
|
|
@@ -156,6 +172,8 @@ const { handleKeyDown } = useTreeKeyboardNav(
|
|
|
156
172
|
handleItemClick,
|
|
157
173
|
getScrollInfo,
|
|
158
174
|
focusedIndex,
|
|
175
|
+
selectAllLeaves,
|
|
176
|
+
clearActive,
|
|
159
177
|
);
|
|
160
178
|
</script>
|
|
161
179
|
|
|
@@ -36,7 +36,8 @@ function apply(): void {
|
|
|
36
36
|
>
|
|
37
37
|
<v-container class="pa-3 py-1">
|
|
38
38
|
<v-row dense>
|
|
39
|
-
|
|
39
|
+
<!-- ToolPanel clips its content: leave room above the slider for its thumb label -->
|
|
40
|
+
<v-col cols="12" class="pt-7 pb-1">
|
|
40
41
|
<v-slider
|
|
41
42
|
v-model="zScale"
|
|
42
43
|
:min="1"
|
|
@@ -17,6 +17,8 @@ type ReadonlyDisplayItem = Omit<DisplayItem, "raw"> & {
|
|
|
17
17
|
|
|
18
18
|
interface KeyboardEventLike {
|
|
19
19
|
readonly key: string;
|
|
20
|
+
readonly ctrlKey: boolean;
|
|
21
|
+
readonly metaKey: boolean;
|
|
20
22
|
preventDefault: () => void;
|
|
21
23
|
}
|
|
22
24
|
|
|
@@ -56,6 +58,8 @@ export function useTreeKeyboardNav(
|
|
|
56
58
|
handleItemClick: (item: ReadonlyDisplayItem, index: number) => void,
|
|
57
59
|
getScrollInfo: (() => ScrollInfo | undefined) | undefined,
|
|
58
60
|
externalFocusedIndex: Ref<number> | undefined,
|
|
61
|
+
selectAll: () => void,
|
|
62
|
+
clearActive: () => boolean,
|
|
59
63
|
): UseTreeKeyboardNavReturn {
|
|
60
64
|
const focusedIndex = externalFocusedIndex ?? ref(-1);
|
|
61
65
|
|
|
@@ -143,8 +147,21 @@ export function useTreeKeyboardNav(
|
|
|
143
147
|
return currentIndex;
|
|
144
148
|
}
|
|
145
149
|
|
|
150
|
+
function handleSelectionShortcut(event: KeyboardEventLike): boolean {
|
|
151
|
+
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "a") {
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
selectAll();
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
if (event.key === "Escape" && clearActive()) {
|
|
157
|
+
event.preventDefault();
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
|
|
146
163
|
function handleKeyDown(event: KeyboardEventLike): void {
|
|
147
|
-
if (displayItems.value.length === 0) {
|
|
164
|
+
if (handleSelectionShortcut(event) || displayItems.value.length === 0) {
|
|
148
165
|
return;
|
|
149
166
|
}
|
|
150
167
|
|
|
@@ -2,13 +2,10 @@ import {
|
|
|
2
2
|
type ViewStreamLike,
|
|
3
3
|
useHybridViewerViewport,
|
|
4
4
|
} from "@ogw_internal/stores/hybrid_viewer/viewport";
|
|
5
|
-
import {
|
|
6
|
-
applySnapshot,
|
|
7
|
-
getCameraOptions,
|
|
8
|
-
useHybridViewerCamera,
|
|
9
|
-
} from "@ogw_internal/stores/hybrid_viewer/camera";
|
|
5
|
+
import { applySnapshot, useHybridViewerCamera } from "@ogw_internal/stores/hybrid_viewer/camera";
|
|
10
6
|
import { BACKGROUND_COLOR } from "@ogw_internal/stores/hybrid_viewer/constants";
|
|
11
7
|
import type { CameraOptions } from "@ogw_internal/stores/hybrid_viewer/vtk_types";
|
|
8
|
+
import { getCameraOptions } from "@ogw_internal/stores/hybrid_viewer/camera_animation";
|
|
12
9
|
import { useHybridViewerBrightness } from "@ogw_internal/stores/hybrid_viewer/brightness";
|
|
13
10
|
import { useHybridViewerCore } from "@ogw_internal/stores/hybrid_viewer/core";
|
|
14
11
|
import { useHybridViewerFilters } from "@ogw_internal/stores/hybrid_viewer/filters";
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
SHORT_ANIMATION_DURATION,
|
|
5
5
|
animateCamera,
|
|
6
6
|
computeAnimationDuration,
|
|
7
|
+
getCameraOptions,
|
|
7
8
|
} from "./camera_animation";
|
|
8
9
|
import { requireRenderWindow, useHybridViewerCore } from "./core";
|
|
9
10
|
import { dot } from "@kitware/vtk.js/Common/Core/Math";
|
|
@@ -60,17 +61,6 @@ function getImageStyle(): CSSStyleDeclaration | undefined {
|
|
|
60
61
|
return bgImage instanceof HTMLImageElement ? bgImage.style : undefined;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
function getCameraOptions(camera: vtkCamera): CameraOptions {
|
|
64
|
-
return {
|
|
65
|
-
focal_point: [...(camera.getFocalPoint() ?? [0, 0, 0])] as Vector3,
|
|
66
|
-
view_up: [...(camera.getViewUp() ?? [0, 0, 0])] as Vector3,
|
|
67
|
-
position: [...(camera.getPosition() ?? [0, 0, 0])] as Vector3,
|
|
68
|
-
view_angle: camera.getViewAngle(),
|
|
69
|
-
clipping_range: [...(camera.getClippingRange() ?? [0, 0])] as [number, number],
|
|
70
|
-
distance: camera.getDistance(),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
64
|
function applyCameraOptions(
|
|
75
65
|
camera: vtkCamera | undefined,
|
|
76
66
|
options: Partial<CameraOptions> | undefined,
|
|
@@ -321,7 +311,6 @@ export {
|
|
|
321
311
|
applyCameraOptions,
|
|
322
312
|
applySnapshot,
|
|
323
313
|
centerCameraOnPosition,
|
|
324
|
-
getCameraOptions,
|
|
325
314
|
useHybridViewerCamera,
|
|
326
315
|
};
|
|
327
316
|
export type { CameraSnapshot };
|
|
@@ -52,6 +52,17 @@ function slerp(from: Vector3, target: Vector3, ratio: number, mid?: Vector3): Ve
|
|
|
52
52
|
];
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
function getCameraOptions(camera: vtkCamera): CameraOptions {
|
|
56
|
+
return {
|
|
57
|
+
focal_point: [...(camera.getFocalPoint() ?? [0, 0, 0])] as Vector3,
|
|
58
|
+
view_up: [...(camera.getViewUp() ?? [0, 0, 0])] as Vector3,
|
|
59
|
+
position: [...(camera.getPosition() ?? [0, 0, 0])] as Vector3,
|
|
60
|
+
view_angle: camera.getViewAngle(),
|
|
61
|
+
clipping_range: [...(camera.getClippingRange() ?? [0, 0])] as [number, number],
|
|
62
|
+
distance: camera.getDistance(),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
55
66
|
function computeAnimationDuration(startState: CameraOptions, targetState: CameraOptions): number {
|
|
56
67
|
const startDir = vecNormalize(vecSub(startState.position, startState.focal_point));
|
|
57
68
|
const targetDir = vecNormalize(vecSub(targetState.position, targetState.focal_point));
|
|
@@ -145,4 +156,5 @@ export {
|
|
|
145
156
|
SHORT_ANIMATION_DURATION,
|
|
146
157
|
animateCamera,
|
|
147
158
|
computeAnimationDuration,
|
|
159
|
+
getCameraOptions,
|
|
148
160
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ACTOR_COLOR, RGB_MAX } from "./constants";
|
|
2
|
-
import type { HybridDb, vtkActor as VtkActorInstance } from "./vtk_types";
|
|
2
|
+
import type { HybridDb, vtkActor as VtkActorInstance, vtkCamera } from "./vtk_types";
|
|
3
3
|
import { requireRenderWindow, useHybridViewerCore } from "./core";
|
|
4
4
|
import viewer_schemas, {
|
|
5
5
|
type ViewerSetBackgroundColorParams,
|
|
6
6
|
} from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
7
7
|
import { base64ToArrayBuffer } from "./base64";
|
|
8
|
+
import { getCameraOptions } from "./camera_animation";
|
|
8
9
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
9
10
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
10
11
|
import { newInstance as vtkActor } from "@kitware/vtk.js/Rendering/Core/Actor";
|
|
@@ -30,6 +31,15 @@ async function setBackgroundColor(color: ViewerSetBackgroundColorParams["color"]
|
|
|
30
31
|
await remoteRender();
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
// The actors are stretched along z around the origin: translate the camera along z so the point it looks at stays under it, keeping the user's view instead of jumping back to the whole scene.
|
|
35
|
+
function followZScaling(camera: vtkCamera, ratio: number): void {
|
|
36
|
+
const [focalX, focalY, focalZ] = camera.getFocalPoint();
|
|
37
|
+
const [positionX, positionY, positionZ] = camera.getPosition();
|
|
38
|
+
const offset = focalZ * (ratio - 1);
|
|
39
|
+
camera.setFocalPoint(focalX, focalY, focalZ + offset);
|
|
40
|
+
camera.setPosition(positionX, positionY, positionZ + offset);
|
|
41
|
+
}
|
|
42
|
+
|
|
33
43
|
// Shared via createSharedComposable (rather than merged into the parent hybridViewer store) so sibling slices, e.g. camera.ts and ruler.ts, can read hybridDb/setZScaling directly without importing the parent store and creating a cycle. A Pinia store would work too but its $id/$patch/... properties would leak into the composed store's spread and collapse its inferred type.
|
|
34
44
|
const useHybridViewerScene = createSharedComposable(() => {
|
|
35
45
|
const hybridDb = reactive<HybridDb>({});
|
|
@@ -100,6 +110,7 @@ const useHybridViewerScene = createSharedComposable(() => {
|
|
|
100
110
|
|
|
101
111
|
async function setZScaling(z_scale: number): Promise<void> {
|
|
102
112
|
const { genericRenderWindow, remoteRender } = useHybridViewerCore();
|
|
113
|
+
const ratio = z_scale / zScale.value;
|
|
103
114
|
zScale.value = z_scale;
|
|
104
115
|
const renderer = requireRenderWindow(genericRenderWindow).getRenderer();
|
|
105
116
|
// oxlint-disable-next-line no-unsafe-type-assertion -- renderer.getActors() is typed as vtkProp[] in vtk.js, but this scene only ever adds vtkActor instances.
|
|
@@ -107,17 +118,23 @@ const useHybridViewerScene = createSharedComposable(() => {
|
|
|
107
118
|
const scale = actor.getScale();
|
|
108
119
|
actor.setScale(scale[0] ?? 1, scale[1] ?? 1, z_scale);
|
|
109
120
|
}
|
|
110
|
-
renderer.
|
|
121
|
+
const camera = renderer.getActiveCamera();
|
|
122
|
+
followZScaling(camera, ratio);
|
|
123
|
+
renderer.resetCameraClippingRange();
|
|
111
124
|
const renderWindow = requireRenderWindow(genericRenderWindow).getRenderWindow();
|
|
112
125
|
renderWindow.render();
|
|
113
126
|
const viewerStore = useViewerStore();
|
|
114
|
-
const schema = viewer_schemas.opengeodeweb_viewer.viewer.set_z_scaling;
|
|
115
|
-
const params = {
|
|
116
|
-
z_scale,
|
|
117
|
-
};
|
|
118
127
|
await viewerStore.request({
|
|
119
|
-
schema,
|
|
120
|
-
params
|
|
128
|
+
schema: viewer_schemas.opengeodeweb_viewer.viewer.set_z_scaling,
|
|
129
|
+
params: {
|
|
130
|
+
z_scale,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
await viewerStore.request({
|
|
134
|
+
schema: viewer_schemas.opengeodeweb_viewer.viewer.update_camera,
|
|
135
|
+
params: {
|
|
136
|
+
camera_options: getCameraOptions(camera),
|
|
137
|
+
},
|
|
121
138
|
});
|
|
122
139
|
await remoteRender();
|
|
123
140
|
}
|
|
@@ -147,4 +164,4 @@ const useHybridViewerScene = createSharedComposable(() => {
|
|
|
147
164
|
};
|
|
148
165
|
});
|
|
149
166
|
|
|
150
|
-
export { useHybridViewerScene };
|
|
167
|
+
export { followZScaling, useHybridViewerScene };
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import type { CameraOptions, Vector3 } from "./vtk_types";
|
|
2
|
-
import {
|
|
3
|
-
applyCameraOptions,
|
|
4
|
-
centerCameraOnPosition,
|
|
5
|
-
getCameraOptions,
|
|
6
|
-
useHybridViewerCamera,
|
|
7
|
-
} from "./camera";
|
|
2
|
+
import { applyCameraOptions, centerCameraOnPosition, useHybridViewerCamera } from "./camera";
|
|
8
3
|
import { requireRenderWindow, useHybridViewerCore } from "./core";
|
|
9
4
|
import type { Position } from "@vueuse/core";
|
|
5
|
+
import { getCameraOptions } from "./camera_animation";
|
|
10
6
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
11
7
|
import { newInstance as vtkCamera } from "@kitware/vtk.js/Rendering/Core/Camera";
|
|
12
8
|
|
package/package.json
CHANGED