@geode/opengeodeweb-front 12.2.0-rc.2 → 12.2.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/tests/browser/helpers/image.js +25 -0
- package/.build/tests/browser/helpers/object_trees/common.js +3 -1
- package/.build/tests/browser/helpers/object_trees/model_tree_bar.js +41 -0
- package/.build/tests/browser/helpers/wait_for_action_settled.js +2 -2
- package/.build/tests/browser/suites/image/raster_image.js +33 -0
- package/.build/tests/browser/suites/index.js +4 -0
- package/.build/tests/browser/suites/model/collections.js +1 -1
- package/.build/tests/browser/suites/object_tree/controls.js +2 -1
- package/.build/tests/browser/suites/object_tree/model_tree_bar.js +81 -0
- package/app/components/Viewer/Image/ImageOptions.vue +67 -0
- package/app/components/Viewer/ObjectTree/Base/CommonTreeView.vue +12 -1
- package/app/components/Viewer/ObjectTree/Base/Controls.vue +26 -2
- package/app/components/Viewer/ObjectTree/Box.vue +30 -5
- package/app/components/Viewer/ObjectTree/Layout.vue +183 -54
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +3 -2
- package/app/composables/hover_highlight.ts +6 -5
- package/app/composables/model_tree_drag.ts +56 -0
- package/app/composables/use_adaptive_styles.ts +15 -8
- package/app/composables/use_overlapping_picker.ts +6 -1
- package/app/composables/virtual_tree.ts +7 -1
- package/app/stores/data_style.ts +12 -1
- package/app/stores/menu_helpers/image.ts +11 -0
- package/app/stores/menu_helpers/menus_data.ts +2 -0
- package/app/stores/treeview.ts +29 -1
- package/app/types/identifiers.ts +8 -0
- package/app/utils/default_styles/images.ts +16 -0
- package/app/utils/default_styles/index.ts +3 -2
- package/app/utils/threshold_sources.ts +5 -1
- package/internal/stores/data_style/image/index.ts +107 -0
- package/internal/stores/hybrid_viewer/brightness.ts +36 -19
- package/package.json +1 -1
- package/tests/browser/helpers/image.ts +33 -0
- package/tests/browser/helpers/object_trees/common.ts +4 -0
- package/tests/browser/helpers/object_trees/model_tree_bar.ts +78 -0
- package/tests/browser/helpers/wait_for_action_settled.ts +2 -3
- package/tests/browser/suites/image/raster_image.ts +40 -0
- package/tests/browser/suites/model/collections.ts +2 -1
- package/tests/browser/suites/object_tree/controls.ts +3 -0
- package/tests/browser/suites/object_tree/model_tree_bar.ts +125 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ImageOptions from "@ogw_front/components/Viewer/Image/ImageOptions.vue";
|
|
2
|
+
import type { MenuItems } from "./types.js";
|
|
3
|
+
|
|
4
|
+
const Image_menu = [ImageOptions];
|
|
5
|
+
|
|
6
|
+
const imageMenus: Record<string, MenuItems> = {
|
|
7
|
+
RasterImage2D: Image_menu,
|
|
8
|
+
RasterImage3D: Image_menu,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { imageMenus };
|
|
@@ -3,12 +3,14 @@ import type { MenuItems } from "./types.js";
|
|
|
3
3
|
import { basemapMenus } from "./basemap.js";
|
|
4
4
|
import { edgedCurveMenus } from "./mesh/edged_curve.js";
|
|
5
5
|
import { gridMenus } from "./mesh/grid.js";
|
|
6
|
+
import { imageMenus } from "./image.js";
|
|
6
7
|
import { pointSetMenus } from "./mesh/point_set.js";
|
|
7
8
|
import { sceneMenus } from "./scene.js";
|
|
8
9
|
import { solidMenus } from "./mesh/solid.js";
|
|
9
10
|
import { surfaceMenus } from "./mesh/surface.js";
|
|
10
11
|
|
|
11
12
|
const menusData: Record<string, Record<string, MenuItems>> = {
|
|
13
|
+
image: imageMenus,
|
|
12
14
|
mesh: {
|
|
13
15
|
...edgedCurveMenus,
|
|
14
16
|
...gridMenus,
|
package/app/stores/treeview.ts
CHANGED
|
@@ -29,6 +29,8 @@ interface OpenedView extends Partial<GeodeObjectTyped> {
|
|
|
29
29
|
opened: string[];
|
|
30
30
|
// Ties a model tree to its row in the objects tree
|
|
31
31
|
color?: string;
|
|
32
|
+
// A model tree reduced to its button in the activity bar: still open, with its state kept
|
|
33
|
+
collapsed?: boolean;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
interface TreeviewChild extends TreeNode, GeodeIdentified, GeodeObjectTyped, ViewerObjectTyped {
|
|
@@ -318,12 +320,35 @@ export const useTreeviewStore = defineStore("treeview", () => {
|
|
|
318
320
|
});
|
|
319
321
|
}
|
|
320
322
|
|
|
323
|
+
function setCollapsed(id: string, collapsed: boolean): void {
|
|
324
|
+
const existing = opened_views.value.find((view: ReadonlyOpenedView) => view.id === id);
|
|
325
|
+
if (existing) {
|
|
326
|
+
existing.collapsed = collapsed;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function toggleCollapsed(id: string): void {
|
|
331
|
+
const existing = opened_views.value.find((view: ReadonlyOpenedView) => view.id === id);
|
|
332
|
+
setCollapsed(id, existing?.collapsed !== true);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function setAllCollapsed(collapsed: boolean): void {
|
|
336
|
+
for (const view of opened_views.value) {
|
|
337
|
+
if (view.type === "component") {
|
|
338
|
+
view.collapsed = collapsed;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
321
343
|
function setHoveredModel(id: string | undefined): void {
|
|
322
344
|
hoveredModelId.value = id;
|
|
323
345
|
}
|
|
324
346
|
|
|
347
|
+
// The objects tree keeps its place, first: only the model trees move
|
|
325
348
|
function moveView(from_index: number, to_index: number): void {
|
|
326
|
-
|
|
349
|
+
const moved = opened_views.value[from_index];
|
|
350
|
+
const target = opened_views.value[to_index];
|
|
351
|
+
if (moved && target && moved.id !== "main" && target.id !== "main") {
|
|
327
352
|
const [element] = opened_views.value.splice(from_index, 1);
|
|
328
353
|
if (element) {
|
|
329
354
|
opened_views.value.splice(to_index, 0, element);
|
|
@@ -455,6 +480,9 @@ export const useTreeviewStore = defineStore("treeview", () => {
|
|
|
455
480
|
displayAdditionalTree,
|
|
456
481
|
closeView,
|
|
457
482
|
toggleView,
|
|
483
|
+
setCollapsed,
|
|
484
|
+
toggleCollapsed,
|
|
485
|
+
setAllCollapsed,
|
|
458
486
|
moveView,
|
|
459
487
|
importStores,
|
|
460
488
|
displayFileTree,
|
package/app/types/identifiers.ts
CHANGED
|
@@ -7,12 +7,18 @@ import type {
|
|
|
7
7
|
// Id of a component of a model (a corner, a line, a surface or a block): its geode_id
|
|
8
8
|
type ModelComponentId = GeodeId;
|
|
9
9
|
|
|
10
|
+
// The data of an image, the data an image style applies to
|
|
11
|
+
type ImageId = DataId;
|
|
12
|
+
|
|
10
13
|
// The data of a mesh, the data a mesh style applies to
|
|
11
14
|
type MeshId = DataId;
|
|
12
15
|
|
|
13
16
|
// The data of a model, the data a model style or a model component applies to
|
|
14
17
|
type ModelId = DataId;
|
|
15
18
|
|
|
19
|
+
// The viewer objects the viewer can highlight: images are not pickable
|
|
20
|
+
type HighlightableObjectType = Exclude<ViewerObjectType, "image">;
|
|
21
|
+
|
|
16
22
|
// A corner of a model, by its id in the model
|
|
17
23
|
type CornerId = ModelComponentId;
|
|
18
24
|
|
|
@@ -52,6 +58,8 @@ export type {
|
|
|
52
58
|
DataIdentified,
|
|
53
59
|
GeodeIdentified,
|
|
54
60
|
GeodeObjectTyped,
|
|
61
|
+
HighlightableObjectType,
|
|
62
|
+
ImageId,
|
|
55
63
|
LineId,
|
|
56
64
|
MeshId,
|
|
57
65
|
ModelComponentId,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Opacity, Visibility } from "@geode/opengeodeweb-viewer/schema_types";
|
|
2
|
+
|
|
3
|
+
interface ImageStyle {
|
|
4
|
+
visibility: Visibility;
|
|
5
|
+
opacity: Opacity;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function imageDefaultStyle(): ImageStyle {
|
|
9
|
+
return {
|
|
10
|
+
visibility: true,
|
|
11
|
+
opacity: 1,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { imageDefaultStyle };
|
|
16
|
+
export type { ImageStyle };
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
} from "./meshes";
|
|
23
23
|
import type { ColorRGBA } from "@geode/opengeodeweb-viewer/schema_types";
|
|
24
24
|
import type { SceneStyle } from "@ogw_internal/stores/data_style/types";
|
|
25
|
+
import { imageDefaultStyle } from "./images";
|
|
25
26
|
|
|
26
27
|
function default_styles(): Record<string, unknown> {
|
|
27
28
|
return {
|
|
@@ -40,8 +41,8 @@ function default_styles(): Record<string, unknown> {
|
|
|
40
41
|
PolygonalSurface2D: surfaceDefaultStyle(),
|
|
41
42
|
PolygonalSurface3D: surfaceDefaultStyle(),
|
|
42
43
|
PolyhedralSolid3D: solidDefaultStyle(),
|
|
43
|
-
RasterImage2D:
|
|
44
|
-
RasterImage3D:
|
|
44
|
+
RasterImage2D: imageDefaultStyle(),
|
|
45
|
+
RasterImage3D: imageDefaultStyle(),
|
|
45
46
|
RegularGrid2D: grid2dDefaultStyle(),
|
|
46
47
|
RegularGrid3D: grid3dDefaultStyle(),
|
|
47
48
|
Section: sectionDefaultStyle(),
|
|
@@ -32,7 +32,11 @@ async function fetchSources(
|
|
|
32
32
|
dataId: DataId,
|
|
33
33
|
): Promise<AttributeSource[]> {
|
|
34
34
|
const item = await dataStore.item(dataId);
|
|
35
|
-
|
|
35
|
+
// An image shows its own colors: it has no attribute to threshold
|
|
36
|
+
if (item.viewer_object_type === "image") {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
if (item.viewer_object_type === "mesh") {
|
|
36
40
|
return ["vertex", MESH_ELEMENT_KINDS[item.geode_object_type]]
|
|
37
41
|
.filter((kind): kind is string => kind !== undefined)
|
|
38
42
|
.map((kind) => attributeSource(kind, "", { id: dataId }));
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Opacity, Visibility } from "@geode/opengeodeweb-viewer/schema_types";
|
|
2
|
+
import type { ImageId } from "@ogw_front/types/identifiers";
|
|
3
|
+
// Third party imports
|
|
4
|
+
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
5
|
+
|
|
6
|
+
// Local imports
|
|
7
|
+
import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
|
|
8
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
9
|
+
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
10
|
+
import { whenDefined } from "@ogw_internal/stores/data_style/when_defined";
|
|
11
|
+
|
|
12
|
+
// Local constants
|
|
13
|
+
const imageSchemas = viewer_schemas.opengeodeweb_viewer.image;
|
|
14
|
+
|
|
15
|
+
interface ImageStyleStore {
|
|
16
|
+
imageVisibility: (imageId: ImageId) => Visibility | undefined;
|
|
17
|
+
setImageVisibility: (imageId: ImageId, visibility: Visibility) => Promise<unknown>;
|
|
18
|
+
imageOpacity: (imageId: ImageId) => Opacity | undefined;
|
|
19
|
+
setImageOpacity: (imageId: ImageId, opacity: Opacity) => Promise<unknown>;
|
|
20
|
+
applyImageStyle: (imageId: ImageId) => Promise<unknown[]>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// An image shows its own colors: only its visibility and its opacity are styled
|
|
24
|
+
// oxlint-disable-next-line max-lines-per-function
|
|
25
|
+
export function useImageStyle(): ImageStyleStore {
|
|
26
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
27
|
+
const viewerStore = useViewerStore();
|
|
28
|
+
const dataStyleState = useDataStyleState();
|
|
29
|
+
|
|
30
|
+
function imageVisibility(imageId: ImageId): Visibility | undefined {
|
|
31
|
+
return dataStyleState.getStyle(imageId).visibility;
|
|
32
|
+
}
|
|
33
|
+
async function setImageVisibility(imageId: ImageId, visibility: Visibility): Promise<unknown> {
|
|
34
|
+
const params = { id: imageId, visibility };
|
|
35
|
+
const result = await viewerStore.request(
|
|
36
|
+
{
|
|
37
|
+
schema: imageSchemas.visibility,
|
|
38
|
+
params,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
response_function: async () => {
|
|
42
|
+
hybridViewerStore.setVisibility(imageId, visibility);
|
|
43
|
+
const mutatedId = await dataStyleState.mutateStyle(imageId, { visibility });
|
|
44
|
+
return mutatedId;
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function imageOpacity(imageId: ImageId): Opacity | undefined {
|
|
52
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- opacity shape is defined by the data style schema.
|
|
53
|
+
return dataStyleState.getStyle(imageId).opacity as Opacity | undefined;
|
|
54
|
+
}
|
|
55
|
+
async function setImageOpacity(imageId: ImageId, opacity: Opacity): Promise<unknown> {
|
|
56
|
+
const params = { id: imageId, opacity };
|
|
57
|
+
const result = await viewerStore.request(
|
|
58
|
+
{
|
|
59
|
+
schema: imageSchemas.opacity,
|
|
60
|
+
params,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
response_function: async () => {
|
|
64
|
+
const mutatedId = await dataStyleState.mutateStyle(imageId, { opacity });
|
|
65
|
+
return mutatedId;
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
);
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function applyImageStyle(imageId: ImageId): Promise<unknown[]> {
|
|
73
|
+
const style = dataStyleState.getStyle(imageId);
|
|
74
|
+
const promise_array: unknown[] = [];
|
|
75
|
+
for (const key of Object.keys(style)) {
|
|
76
|
+
if (key === "visibility") {
|
|
77
|
+
promise_array.push(
|
|
78
|
+
whenDefined(imageVisibility(imageId), async (visibility) => {
|
|
79
|
+
const applied = await setImageVisibility(imageId, visibility);
|
|
80
|
+
return applied;
|
|
81
|
+
}),
|
|
82
|
+
);
|
|
83
|
+
} else if (key === "opacity") {
|
|
84
|
+
promise_array.push(
|
|
85
|
+
whenDefined(imageOpacity(imageId), async (opacity) => {
|
|
86
|
+
const applied = await setImageOpacity(imageId, opacity);
|
|
87
|
+
return applied;
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
90
|
+
} else if (key === "data_id") {
|
|
91
|
+
continue;
|
|
92
|
+
} else {
|
|
93
|
+
throw new Error(`Unknown image key: ${key}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const results = await Promise.all(promise_array);
|
|
97
|
+
return results;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
imageVisibility,
|
|
102
|
+
setImageVisibility,
|
|
103
|
+
imageOpacity,
|
|
104
|
+
setImageOpacity,
|
|
105
|
+
applyImageStyle,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -40,11 +40,18 @@ function mapRect(rect: Rect, latestImage: DrawableImage, canvasRect: DOMRect): R
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
// Darkest and brightest pixels under the rect: dark text has to stay readable over the first, light text over
|
|
44
|
+
// The second
|
|
45
|
+
interface BrightnessRange {
|
|
46
|
+
darkest: number;
|
|
47
|
+
brightest: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function sampleBrightnessRange(
|
|
44
51
|
ctx: CanvasRenderingContext2D,
|
|
45
52
|
image: DrawableImage,
|
|
46
53
|
relRect: RelativeRect,
|
|
47
|
-
):
|
|
54
|
+
): BrightnessRange {
|
|
48
55
|
ctx.drawImage(
|
|
49
56
|
image,
|
|
50
57
|
Math.max(0, relRect.relX),
|
|
@@ -57,14 +64,14 @@ function sampleMinBrightness(
|
|
|
57
64
|
SAMPLE_SIZE,
|
|
58
65
|
);
|
|
59
66
|
const { data } = ctx.getImageData(0, 0, SAMPLE_SIZE, SAMPLE_SIZE);
|
|
60
|
-
let
|
|
67
|
+
let darkest = 1;
|
|
68
|
+
let brightest = 0;
|
|
61
69
|
for (let i = 0; i < TOTAL_CHANNELS; i += RGBA_CHANNELS) {
|
|
62
70
|
const brightness = ((data[i] ?? 0) + (data[i + 1] ?? 0) + (data[i + 2] ?? 0)) / (3 * RGB_MAX);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
71
|
+
darkest = Math.min(darkest, brightness);
|
|
72
|
+
brightest = Math.max(brightest, brightness);
|
|
66
73
|
}
|
|
67
|
-
return
|
|
74
|
+
return { darkest, brightest };
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
// Brightness of the scene background a reset viewer draws, for as long as no viewer image can be sampled
|
|
@@ -73,11 +80,16 @@ function defaultBackgroundBrightness(): number {
|
|
|
73
80
|
return (red + green + blue) / (3 * RGB_MAX);
|
|
74
81
|
}
|
|
75
82
|
|
|
76
|
-
function
|
|
83
|
+
function defaultBackgroundRange(): BrightnessRange {
|
|
84
|
+
const brightness = defaultBackgroundBrightness();
|
|
85
|
+
return { darkest: brightness, brightest: brightness };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function computeBrightnessRange(rect: Rect, options: BrightnessOptions): BrightnessRange {
|
|
77
89
|
const { latestImage, offscreenCtx, offscreenCanvas } = options;
|
|
78
90
|
const { genericRenderWindow } = useHybridViewerCore();
|
|
79
91
|
if (!latestImage || !offscreenCtx || !offscreenCanvas || !genericRenderWindow.value) {
|
|
80
|
-
return
|
|
92
|
+
return defaultBackgroundRange();
|
|
81
93
|
}
|
|
82
94
|
// oxlint-disable-next-line no-unsafe-assignment -- vtk.js has no types for getApiSpecificRenderWindow(); narrowed below.
|
|
83
95
|
const webGLRenderWindow = genericRenderWindow.value.getApiSpecificRenderWindow();
|
|
@@ -87,21 +99,21 @@ function computeAverageBrightness(rect: Rect, options: BrightnessOptions): numbe
|
|
|
87
99
|
};
|
|
88
100
|
const canvas = apiSpecificRenderWindow.getCanvas();
|
|
89
101
|
if (canvas === undefined || canvas === null) {
|
|
90
|
-
return
|
|
102
|
+
return defaultBackgroundRange();
|
|
91
103
|
}
|
|
92
104
|
if (rect.width <= 0 || rect.height <= 0) {
|
|
93
|
-
return
|
|
105
|
+
return defaultBackgroundRange();
|
|
94
106
|
}
|
|
95
107
|
const relRect = mapRect(rect, latestImage, canvas.getBoundingClientRect());
|
|
96
108
|
if (relRect.relW <= 0 || relRect.relH <= 0) {
|
|
97
|
-
return
|
|
109
|
+
return defaultBackgroundRange();
|
|
98
110
|
}
|
|
99
111
|
offscreenCanvas.width = SAMPLE_SIZE;
|
|
100
112
|
offscreenCanvas.height = SAMPLE_SIZE;
|
|
101
113
|
try {
|
|
102
|
-
return
|
|
114
|
+
return sampleBrightnessRange(offscreenCtx, latestImage, relRect);
|
|
103
115
|
} catch {
|
|
104
|
-
return
|
|
116
|
+
return defaultBackgroundRange();
|
|
105
117
|
}
|
|
106
118
|
}
|
|
107
119
|
function createOffscreenCanvas(): HTMLCanvasElement | undefined {
|
|
@@ -113,7 +125,7 @@ function createOffscreenCanvas(): HTMLCanvasElement | undefined {
|
|
|
113
125
|
|
|
114
126
|
function useHybridViewerBrightness(): {
|
|
115
127
|
latestImage: Ref<DrawableImage | undefined>;
|
|
116
|
-
|
|
128
|
+
getBrightnessRange: (rect: Rect) => BrightnessRange;
|
|
117
129
|
} {
|
|
118
130
|
const latestImage = ref<DrawableImage | undefined>(undefined);
|
|
119
131
|
const offscreenCanvas: HTMLCanvasElement | undefined = createOffscreenCanvas();
|
|
@@ -122,8 +134,8 @@ function useHybridViewerBrightness(): {
|
|
|
122
134
|
willReadFrequently: true,
|
|
123
135
|
}) ?? undefined)
|
|
124
136
|
: undefined;
|
|
125
|
-
function
|
|
126
|
-
return
|
|
137
|
+
function getBrightnessRange(rect: Rect): BrightnessRange {
|
|
138
|
+
return computeBrightnessRange(rect, {
|
|
127
139
|
latestImage: latestImage.value,
|
|
128
140
|
offscreenCtx,
|
|
129
141
|
offscreenCanvas,
|
|
@@ -131,7 +143,12 @@ function useHybridViewerBrightness(): {
|
|
|
131
143
|
}
|
|
132
144
|
return {
|
|
133
145
|
latestImage,
|
|
134
|
-
|
|
146
|
+
getBrightnessRange,
|
|
135
147
|
};
|
|
136
148
|
}
|
|
137
|
-
export {
|
|
149
|
+
export {
|
|
150
|
+
type BrightnessRange,
|
|
151
|
+
computeBrightnessRange,
|
|
152
|
+
defaultBackgroundBrightness,
|
|
153
|
+
useHybridViewerBrightness,
|
|
154
|
+
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Third party imports
|
|
2
|
+
import type { Page } from "@playwright/test";
|
|
3
|
+
|
|
4
|
+
// Local imports
|
|
5
|
+
import { ensureMenuOpen, moveMouseOutOfTheWay } from "./viewer_interaction";
|
|
6
|
+
import { openDataContextMenu } from "./object_trees/main_object_tree";
|
|
7
|
+
import { waitForActionSettled } from "./wait_for_action_settled";
|
|
8
|
+
|
|
9
|
+
const IMAGE_MENU_TEST_ID = "imageMenu";
|
|
10
|
+
|
|
11
|
+
// Images are not pickable: their menu opens from the object tree
|
|
12
|
+
async function openImageMenu(
|
|
13
|
+
window: Page,
|
|
14
|
+
geodeObjectType: string,
|
|
15
|
+
dataName: string,
|
|
16
|
+
): Promise<void> {
|
|
17
|
+
await openDataContextMenu(window, geodeObjectType, dataName);
|
|
18
|
+
await ensureMenuOpen(window, IMAGE_MENU_TEST_ID);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function setImageOpacity(window: Page, opacity: number): Promise<void> {
|
|
22
|
+
await ensureMenuOpen(window, IMAGE_MENU_TEST_ID);
|
|
23
|
+
const track = window.getByTestId("imageOpacitySlider").locator(".v-slider").first();
|
|
24
|
+
const box = await track.boundingBox();
|
|
25
|
+
if (!box) {
|
|
26
|
+
throw new Error("Could not get bounding box of the image opacity slider");
|
|
27
|
+
}
|
|
28
|
+
await track.click({ position: { x: box.width * opacity, y: box.height / 2 } });
|
|
29
|
+
await moveMouseOutOfTheWay(window);
|
|
30
|
+
await waitForActionSettled(window);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { IMAGE_MENU_TEST_ID, openImageMenu, setImageOpacity };
|
|
@@ -62,6 +62,10 @@ async function toggleSearchObjects(window: Page): Promise<void> {
|
|
|
62
62
|
|
|
63
63
|
async function fillSearchQuery(window: Page, query: string, tree: Locator): Promise<void> {
|
|
64
64
|
const searchInput = tree.getByTestId("searchObjectsInput").locator("input");
|
|
65
|
+
// An empty search folds back once the toolbar is left: open it again
|
|
66
|
+
if (!(await searchInput.isVisible())) {
|
|
67
|
+
await tree.getByTestId("searchObjectsButton").click();
|
|
68
|
+
}
|
|
65
69
|
await searchInput.fill(query);
|
|
66
70
|
await moveMouseOutOfTheWay(window);
|
|
67
71
|
await waitForActionSettled(window);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Locator, Page } from "@playwright/test";
|
|
2
|
+
import { getModelComponentsObjectTree } from "./model_components_object_tree";
|
|
3
|
+
import { moveMouseOutOfTheWay } from "#browser_helpers/app_interaction";
|
|
4
|
+
import { waitForActionSettled } from "#browser_helpers/wait_for_action_settled";
|
|
5
|
+
|
|
6
|
+
// The model trees in the activity bar: a button per open model tree, and one for them all
|
|
7
|
+
const DRAG_STEPS = 10;
|
|
8
|
+
|
|
9
|
+
function getModelTreeToggles(window: Page): Locator {
|
|
10
|
+
return window.getByTestId("modelTreeToggle");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getModelTreeRows(window: Page): Locator {
|
|
14
|
+
return getModelComponentsObjectTree(window).getByTestId("treeRowWrapper");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function clickModelTreeBarButton(window: Page, locator: Locator): Promise<void> {
|
|
18
|
+
await locator.click();
|
|
19
|
+
await moveMouseOutOfTheWay(window);
|
|
20
|
+
await waitForActionSettled(window);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// The colors of the model trees, in the order of their panels and of their buttons in the activity bar
|
|
24
|
+
async function getModelTreePanelColors(window: Page): Promise<string[]> {
|
|
25
|
+
const colors = await window.locator(".tree-box").evaluateAll((boxes) =>
|
|
26
|
+
boxes
|
|
27
|
+
.map((box) => {
|
|
28
|
+
if (box instanceof HTMLElement) {
|
|
29
|
+
return box.style.getPropertyValue("--tree-box-accent");
|
|
30
|
+
}
|
|
31
|
+
return "";
|
|
32
|
+
})
|
|
33
|
+
.filter((color) => color !== ""),
|
|
34
|
+
);
|
|
35
|
+
return colors;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function getModelTreeButtonColors(window: Page): Promise<string[]> {
|
|
39
|
+
const colors = await getModelTreeToggles(window).evaluateAll((toggles) =>
|
|
40
|
+
toggles.map((toggle) => {
|
|
41
|
+
if (toggle instanceof HTMLElement) {
|
|
42
|
+
return toggle.style.getPropertyValue("--model-tree-color");
|
|
43
|
+
}
|
|
44
|
+
return "";
|
|
45
|
+
}),
|
|
46
|
+
);
|
|
47
|
+
return colors;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Drags a model button over another one with the mouse, as the native drag and drop needs
|
|
51
|
+
async function dragModelTreeButton(
|
|
52
|
+
window: Page,
|
|
53
|
+
fromIndex: number,
|
|
54
|
+
toIndex: number,
|
|
55
|
+
): Promise<void> {
|
|
56
|
+
const source = await getModelTreeToggles(window).nth(fromIndex).boundingBox();
|
|
57
|
+
const target = await getModelTreeToggles(window).nth(toIndex).boundingBox();
|
|
58
|
+
if (source === null || target === null) {
|
|
59
|
+
throw new Error("The model buttons are not displayed.");
|
|
60
|
+
}
|
|
61
|
+
await window.mouse.move(source.x + source.width / 2, source.y + source.height / 2);
|
|
62
|
+
await window.mouse.down();
|
|
63
|
+
await window.mouse.move(target.x + target.width / 2, target.y + target.height / 2, {
|
|
64
|
+
steps: DRAG_STEPS,
|
|
65
|
+
});
|
|
66
|
+
await window.mouse.up();
|
|
67
|
+
await moveMouseOutOfTheWay(window);
|
|
68
|
+
await waitForActionSettled(window);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
clickModelTreeBarButton,
|
|
73
|
+
dragModelTreeButton,
|
|
74
|
+
getModelTreeButtonColors,
|
|
75
|
+
getModelTreePanelColors,
|
|
76
|
+
getModelTreeRows,
|
|
77
|
+
getModelTreeToggles,
|
|
78
|
+
};
|
|
@@ -40,7 +40,7 @@ const MUTATION_QUIET_MS = 250;
|
|
|
40
40
|
const MUTATION_POLL_INTERVAL_MS = 20;
|
|
41
41
|
|
|
42
42
|
async function waitForDomSettled(window: Page, budgetMs: number): Promise<void> {
|
|
43
|
-
await window.evaluate((
|
|
43
|
+
await window.evaluate(() => {
|
|
44
44
|
globalThis.e2eLastMutationAt = performance.now();
|
|
45
45
|
if (!globalThis.e2eMutationObserver) {
|
|
46
46
|
const observer = new MutationObserver(() => {
|
|
@@ -49,8 +49,7 @@ async function waitForDomSettled(window: Page, budgetMs: number): Promise<void>
|
|
|
49
49
|
observer.observe(document.body, { attributes: true, childList: true, subtree: true });
|
|
50
50
|
globalThis.e2eMutationObserver = observer;
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
}, MUTATION_QUIET_MS);
|
|
52
|
+
});
|
|
54
53
|
|
|
55
54
|
await window
|
|
56
55
|
.waitForFunction(
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Local imports
|
|
2
|
+
import { IMAGE_MENU_TEST_ID, openImageMenu, setImageOpacity } from "#browser_helpers/image";
|
|
3
|
+
import type { SuiteRuntime } from "#browser_helpers/suite_runtime";
|
|
4
|
+
import { closeAllMenus } from "#browser_helpers/app_interaction";
|
|
5
|
+
import { expandMainObjectTree } from "#browser_helpers/object_trees/main_object_tree";
|
|
6
|
+
import { setVisibilityGeneric } from "#browser_helpers/viewer_interaction";
|
|
7
|
+
|
|
8
|
+
// Constants
|
|
9
|
+
const inputFilename = "test_texture.png";
|
|
10
|
+
const dataName = "test_texture";
|
|
11
|
+
const geodeObjectType = "RasterImage2D";
|
|
12
|
+
const halfOpacity = 0.5;
|
|
13
|
+
|
|
14
|
+
// Shared with the apps built on this layer: each one runs it with its own test fixture and data loader
|
|
15
|
+
function registerTests({ test, loadTestDatas }: SuiteRuntime): void {
|
|
16
|
+
test.describe.configure({ mode: "serial" });
|
|
17
|
+
|
|
18
|
+
test("load shows the image colors", async ({ window }) => {
|
|
19
|
+
await loadTestDatas(window, [inputFilename]);
|
|
20
|
+
await expandMainObjectTree(window);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("image menu", async ({ window }) => {
|
|
24
|
+
await openImageMenu(window, geodeObjectType, dataName);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("image opacity", async ({ window }) => {
|
|
28
|
+
await setImageOpacity(window, halfOpacity);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("image hidden", async ({ window }) => {
|
|
32
|
+
await setVisibilityGeneric(window, IMAGE_MENU_TEST_ID, "imageVisibilitySwitch", false);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("close image menu", async ({ window }) => {
|
|
36
|
+
await closeAllMenus(window);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { registerTests };
|
|
@@ -25,7 +25,8 @@ import type { SuiteRuntime } from "#browser_helpers/suite_runtime";
|
|
|
25
25
|
// Constants
|
|
26
26
|
const structuralModelFilename = "test.og_strm";
|
|
27
27
|
const collectionTypeRowName = "ModelBoundaries";
|
|
28
|
-
|
|
28
|
+
// Start of the collection id, still shown once the label is truncated in the middle
|
|
29
|
+
const collectionRowName = "019ea684-37";
|
|
29
30
|
const vertexAttributeName = "test_vertex";
|
|
30
31
|
|
|
31
32
|
// Shared with the apps built on this layer: each one runs it with its own test fixture and data loader
|
|
@@ -7,6 +7,7 @@ import { expect } from "@playwright/test";
|
|
|
7
7
|
import {
|
|
8
8
|
checkFilterCategory,
|
|
9
9
|
copyTreeRowId,
|
|
10
|
+
expandGeodeObjectTypeInTree,
|
|
10
11
|
fillSearchQuery,
|
|
11
12
|
getTreeRowId,
|
|
12
13
|
hideObjectInTree,
|
|
@@ -88,6 +89,8 @@ function registerTests({ test, loadTestDatas }: SuiteRuntime): void {
|
|
|
88
89
|
|
|
89
90
|
test("search by id", async ({ window, screenshotMask }) => {
|
|
90
91
|
const mainObjectTree = getMainObjectTree(window);
|
|
92
|
+
// Clearing the search folded the groups back as they were before it
|
|
93
|
+
await expandGeodeObjectTypeInTree(window, brepGeodeObjectType, mainObjectTree);
|
|
91
94
|
const brepLabel = mainObjectTree
|
|
92
95
|
.locator('[data-testid^="treeRow-"]', { hasText: "test" })
|
|
93
96
|
.first();
|