@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,24 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "
|
|
1
|
+
import {
|
|
2
|
+
type ComponentStyleUpdate,
|
|
3
|
+
useModelComponentStyleMutations,
|
|
4
|
+
useModelComponentsPerComponentStyleMutation,
|
|
5
|
+
useModelComponentsStyleMutation,
|
|
6
|
+
} from "./common_mutations";
|
|
7
7
|
import type { ParamsOf } from "@ogw_shared/utils/types.js";
|
|
8
8
|
import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
|
|
9
|
-
import {
|
|
10
|
-
import merge from "lodash/merge";
|
|
9
|
+
import type { StyleValues } from "@ogw_internal/stores/data_style/types.js";
|
|
11
10
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
12
|
-
import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
|
|
13
11
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
14
12
|
import type viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
15
13
|
|
|
16
|
-
// The underlying dexie tables use compound array keys ([id_model, id_component] /
|
|
17
|
-
// [id_model, type]) but the shared `database` proxy types every table as
|
|
18
|
-
// Table<Record<string, unknown>, string>. Cast locally to the real key shape.
|
|
19
|
-
type ComponentTable = Table<ModelComponentStyle, [string, string]>;
|
|
20
|
-
type ComponentTypeTable = Table<ModelComponentTypeStyle, [string, string]>;
|
|
21
|
-
|
|
22
14
|
type ModelComponentSchemas = (typeof viewer_schemas)["opengeodeweb_viewer"]["model"][
|
|
23
15
|
| "corners"
|
|
24
16
|
| "lines"
|
|
@@ -32,11 +24,6 @@ function isModelColorMode(value: string): value is ModelColorMode {
|
|
|
32
24
|
return value === "constant" || value === "random";
|
|
33
25
|
}
|
|
34
26
|
|
|
35
|
-
interface ComponentStyleUpdate {
|
|
36
|
-
id_component: string;
|
|
37
|
-
values: StyleValues;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
27
|
interface UseModelCommonStyleReturn {
|
|
41
28
|
mutateComponentStyle: (
|
|
42
29
|
id_model: string,
|
|
@@ -77,105 +64,9 @@ interface UseModelCommonStyleReturn {
|
|
|
77
64
|
export function useModelCommonStyle(): UseModelCommonStyleReturn {
|
|
78
65
|
const dataStore = useDataStore();
|
|
79
66
|
const viewerStore = useViewerStore();
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
database.model_component_datastyle as unknown as ComponentTable;
|
|
84
|
-
const model_component_type_datastyle_db =
|
|
85
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- compound-key table cast; see comment above.
|
|
86
|
-
database.model_component_type_datastyle as unknown as ComponentTypeTable;
|
|
87
|
-
|
|
88
|
-
async function mutateComponentStyle(
|
|
89
|
-
id_model: string,
|
|
90
|
-
id_component: string,
|
|
91
|
-
values: StyleValues,
|
|
92
|
-
): Promise<unknown> {
|
|
93
|
-
dataStyleState.updateComponentStyleCache(id_model, id_component, values);
|
|
94
|
-
const key: [string, string] = [id_model, id_component];
|
|
95
|
-
const entry: ModelComponentStyle = (await model_component_datastyle_db.get(key)) ?? {
|
|
96
|
-
id_model,
|
|
97
|
-
id_component,
|
|
98
|
-
};
|
|
99
|
-
merge(entry, values);
|
|
100
|
-
return model_component_datastyle_db.put(structuredClone(toRaw(entry)));
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async function mutateModelComponentTypeStyle(
|
|
104
|
-
id_model: string,
|
|
105
|
-
type: string,
|
|
106
|
-
values: StyleValues,
|
|
107
|
-
): Promise<void> {
|
|
108
|
-
dataStyleState.updateModelComponentTypeStyleCache(id_model, type, values);
|
|
109
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- the shared database proxy types every table as Dexie; see comment above.
|
|
110
|
-
await (database as unknown as Dexie).transaction(
|
|
111
|
-
"rw",
|
|
112
|
-
model_component_type_datastyle_db,
|
|
113
|
-
async () => {
|
|
114
|
-
const key: [string, string] = [id_model, type];
|
|
115
|
-
const entry: ModelComponentTypeStyle = (await model_component_type_datastyle_db.get(
|
|
116
|
-
key,
|
|
117
|
-
)) ?? {
|
|
118
|
-
id_model,
|
|
119
|
-
type,
|
|
120
|
-
};
|
|
121
|
-
merge(entry, values);
|
|
122
|
-
return model_component_type_datastyle_db.put(structuredClone(toRaw(entry)));
|
|
123
|
-
},
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async function mutateComponentStyles(
|
|
128
|
-
id_model: string,
|
|
129
|
-
id_components: string[],
|
|
130
|
-
values: StyleValues,
|
|
131
|
-
): Promise<void> {
|
|
132
|
-
dataStyleState.bulkUpdateComponentStylesCache(id_model, id_components, values);
|
|
133
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- the shared database proxy types every table as Dexie; see comment above.
|
|
134
|
-
await (database as unknown as Dexie).transaction(
|
|
135
|
-
"rw",
|
|
136
|
-
model_component_datastyle_db,
|
|
137
|
-
async () => {
|
|
138
|
-
const keys: [string, string][] = id_components.map((id_component) => [
|
|
139
|
-
id_model,
|
|
140
|
-
id_component,
|
|
141
|
-
]);
|
|
142
|
-
const existing = await model_component_datastyle_db.bulkGet(keys);
|
|
143
|
-
const updates = id_components.map((id_component, index) => {
|
|
144
|
-
const style: ModelComponentStyle = existing[index] ?? { id_model, id_component };
|
|
145
|
-
merge(style, values);
|
|
146
|
-
return toRaw(style);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
return model_component_datastyle_db.bulkPut(structuredClone(updates));
|
|
150
|
-
},
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
async function bulkMutateComponentStylesPerComponent(
|
|
155
|
-
id_model: string,
|
|
156
|
-
component_updates: ComponentStyleUpdate[],
|
|
157
|
-
): Promise<void> {
|
|
158
|
-
dataStyleState.bulkUpdateComponentStyleCache(id_model, component_updates);
|
|
159
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- the shared database proxy types every table as Dexie; see comment above.
|
|
160
|
-
await (database as unknown as Dexie).transaction(
|
|
161
|
-
"rw",
|
|
162
|
-
model_component_datastyle_db,
|
|
163
|
-
async () => {
|
|
164
|
-
const keys: [string, string][] = component_updates.map((update) => [
|
|
165
|
-
id_model,
|
|
166
|
-
update.id_component,
|
|
167
|
-
]);
|
|
168
|
-
const existing = await model_component_datastyle_db.bulkGet(keys);
|
|
169
|
-
const updates = component_updates.map(({ id_component, values }, index) => {
|
|
170
|
-
const style: ModelComponentStyle = existing[index] ?? { id_model, id_component };
|
|
171
|
-
merge(style, values);
|
|
172
|
-
return toRaw(style);
|
|
173
|
-
});
|
|
174
|
-
return model_component_datastyle_db.bulkPut(structuredClone(updates));
|
|
175
|
-
},
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
67
|
+
const { mutateComponentStyle, mutateModelComponentTypeStyle } = useModelComponentStyleMutations();
|
|
68
|
+
const { mutateComponentStyles } = useModelComponentsStyleMutation();
|
|
69
|
+
const { bulkMutateComponentStylesPerComponent } = useModelComponentsPerComponentStyleMutation();
|
|
179
70
|
async function setModelTypeColor(
|
|
180
71
|
id: string,
|
|
181
72
|
component_ids: string[],
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { Dexie, Table } from "dexie";
|
|
2
|
+
import type {
|
|
3
|
+
ModelComponentStyle,
|
|
4
|
+
ModelComponentTypeStyle,
|
|
5
|
+
StyleValues,
|
|
6
|
+
} from "@ogw_internal/stores/data_style/types.js";
|
|
7
|
+
import { database } from "@ogw_internal/database/database";
|
|
8
|
+
import merge from "lodash/merge";
|
|
9
|
+
import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
|
|
10
|
+
|
|
11
|
+
// The underlying dexie tables use compound array keys ([id_model, id_component] /
|
|
12
|
+
// [id_model, type]) but the shared `database` proxy types every table as
|
|
13
|
+
// Table<Record<string, unknown>, string>. Cast locally to the real key shape.
|
|
14
|
+
type ComponentTable = Table<ModelComponentStyle, [string, string]>;
|
|
15
|
+
type ComponentTypeTable = Table<ModelComponentTypeStyle, [string, string]>;
|
|
16
|
+
|
|
17
|
+
interface ComponentStyleUpdate {
|
|
18
|
+
id_component: string;
|
|
19
|
+
values: StyleValues;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function componentDatastyleTable(): ComponentTable {
|
|
23
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- compound-key table cast; see comment above.
|
|
24
|
+
return database.model_component_datastyle as unknown as ComponentTable;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function componentTypeDatastyleTable(): ComponentTypeTable {
|
|
28
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- compound-key table cast; see comment above.
|
|
29
|
+
return database.model_component_type_datastyle as unknown as ComponentTypeTable;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface UseModelComponentStyleMutationsReturn {
|
|
33
|
+
mutateComponentStyle: (
|
|
34
|
+
id_model: string,
|
|
35
|
+
id_component: string,
|
|
36
|
+
values: StyleValues,
|
|
37
|
+
) => Promise<unknown>;
|
|
38
|
+
mutateModelComponentTypeStyle: (
|
|
39
|
+
id_model: string,
|
|
40
|
+
type: string,
|
|
41
|
+
values: StyleValues,
|
|
42
|
+
) => Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface UseModelComponentsStyleMutationReturn {
|
|
46
|
+
mutateComponentStyles: (
|
|
47
|
+
id_model: string,
|
|
48
|
+
id_components: string[],
|
|
49
|
+
values: StyleValues,
|
|
50
|
+
) => Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface UseModelComponentsPerComponentStyleMutationReturn {
|
|
54
|
+
bulkMutateComponentStylesPerComponent: (
|
|
55
|
+
id_model: string,
|
|
56
|
+
component_updates: ComponentStyleUpdate[],
|
|
57
|
+
) => Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function useModelComponentStyleMutations(): UseModelComponentStyleMutationsReturn {
|
|
61
|
+
const dataStyleState = useDataStyleState();
|
|
62
|
+
const model_component_datastyle_db = componentDatastyleTable();
|
|
63
|
+
const model_component_type_datastyle_db = componentTypeDatastyleTable();
|
|
64
|
+
|
|
65
|
+
async function mutateComponentStyle(
|
|
66
|
+
id_model: string,
|
|
67
|
+
id_component: string,
|
|
68
|
+
values: StyleValues,
|
|
69
|
+
): Promise<unknown> {
|
|
70
|
+
dataStyleState.updateComponentStyleCache(id_model, id_component, values);
|
|
71
|
+
const key: [string, string] = [id_model, id_component];
|
|
72
|
+
const entry: ModelComponentStyle = (await model_component_datastyle_db.get(key)) ?? {
|
|
73
|
+
id_model,
|
|
74
|
+
id_component,
|
|
75
|
+
};
|
|
76
|
+
merge(entry, values);
|
|
77
|
+
return model_component_datastyle_db.put(structuredClone(toRaw(entry)));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function mutateModelComponentTypeStyle(
|
|
81
|
+
id_model: string,
|
|
82
|
+
type: string,
|
|
83
|
+
values: StyleValues,
|
|
84
|
+
): Promise<void> {
|
|
85
|
+
dataStyleState.updateModelComponentTypeStyleCache(id_model, type, values);
|
|
86
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- the shared database proxy types every table as Dexie; see comment above.
|
|
87
|
+
await (database as unknown as Dexie).transaction(
|
|
88
|
+
"rw",
|
|
89
|
+
model_component_type_datastyle_db,
|
|
90
|
+
async () => {
|
|
91
|
+
const key: [string, string] = [id_model, type];
|
|
92
|
+
const entry: ModelComponentTypeStyle = (await model_component_type_datastyle_db.get(
|
|
93
|
+
key,
|
|
94
|
+
)) ?? {
|
|
95
|
+
id_model,
|
|
96
|
+
type,
|
|
97
|
+
};
|
|
98
|
+
merge(entry, values);
|
|
99
|
+
return model_component_type_datastyle_db.put(structuredClone(toRaw(entry)));
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
mutateComponentStyle,
|
|
106
|
+
mutateModelComponentTypeStyle,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function useModelComponentsStyleMutation(): UseModelComponentsStyleMutationReturn {
|
|
111
|
+
const dataStyleState = useDataStyleState();
|
|
112
|
+
const model_component_datastyle_db = componentDatastyleTable();
|
|
113
|
+
|
|
114
|
+
async function mutateComponentStyles(
|
|
115
|
+
id_model: string,
|
|
116
|
+
id_components: string[],
|
|
117
|
+
values: StyleValues,
|
|
118
|
+
): Promise<void> {
|
|
119
|
+
dataStyleState.bulkUpdateComponentStylesCache(id_model, id_components, values);
|
|
120
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- the shared database proxy types every table as Dexie; see comment above.
|
|
121
|
+
await (database as unknown as Dexie).transaction(
|
|
122
|
+
"rw",
|
|
123
|
+
model_component_datastyle_db,
|
|
124
|
+
async () => {
|
|
125
|
+
const keys: [string, string][] = id_components.map((id_component) => [
|
|
126
|
+
id_model,
|
|
127
|
+
id_component,
|
|
128
|
+
]);
|
|
129
|
+
const existing = await model_component_datastyle_db.bulkGet(keys);
|
|
130
|
+
const updates = id_components.map((id_component, index) => {
|
|
131
|
+
const style: ModelComponentStyle = existing[index] ?? { id_model, id_component };
|
|
132
|
+
merge(style, values);
|
|
133
|
+
return toRaw(style);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
return model_component_datastyle_db.bulkPut(structuredClone(updates));
|
|
137
|
+
},
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
mutateComponentStyles,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function useModelComponentsPerComponentStyleMutation(): UseModelComponentsPerComponentStyleMutationReturn {
|
|
147
|
+
const dataStyleState = useDataStyleState();
|
|
148
|
+
const model_component_datastyle_db = componentDatastyleTable();
|
|
149
|
+
|
|
150
|
+
async function bulkMutateComponentStylesPerComponent(
|
|
151
|
+
id_model: string,
|
|
152
|
+
component_updates: ComponentStyleUpdate[],
|
|
153
|
+
): Promise<void> {
|
|
154
|
+
dataStyleState.bulkUpdateComponentStyleCache(id_model, component_updates);
|
|
155
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- the shared database proxy types every table as Dexie; see comment above.
|
|
156
|
+
await (database as unknown as Dexie).transaction(
|
|
157
|
+
"rw",
|
|
158
|
+
model_component_datastyle_db,
|
|
159
|
+
async () => {
|
|
160
|
+
const keys: [string, string][] = component_updates.map((update) => [
|
|
161
|
+
id_model,
|
|
162
|
+
update.id_component,
|
|
163
|
+
]);
|
|
164
|
+
const existing = await model_component_datastyle_db.bulkGet(keys);
|
|
165
|
+
const updates = component_updates.map(({ id_component, values }, index) => {
|
|
166
|
+
const style: ModelComponentStyle = existing[index] ?? { id_model, id_component };
|
|
167
|
+
merge(style, values);
|
|
168
|
+
return toRaw(style);
|
|
169
|
+
});
|
|
170
|
+
return model_component_datastyle_db.bulkPut(structuredClone(updates));
|
|
171
|
+
},
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
bulkMutateComponentStylesPerComponent,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
export {
|
|
180
|
+
useModelComponentStyleMutations,
|
|
181
|
+
useModelComponentsStyleMutation,
|
|
182
|
+
useModelComponentsPerComponentStyleMutation,
|
|
183
|
+
};
|
|
184
|
+
export type { ComponentStyleUpdate };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { AttributeGroup, ColorGroup } from "./coloring_groups";
|
|
2
|
+
import { isModelLinesEdgeAttributeValid, type useModelLinesEdgeAttribute } from "./edge";
|
|
3
|
+
import { isModelLinesVertexAttributeValid, type useModelLinesVertexAttribute } from "./vertex";
|
|
4
|
+
import type { useModelLinesColor } from "./color";
|
|
5
|
+
|
|
6
|
+
type ColorStyle = ReturnType<typeof useModelLinesColor>;
|
|
7
|
+
type VertexAttributeStyle = ReturnType<typeof useModelLinesVertexAttribute>;
|
|
8
|
+
type EdgeAttributeStyle = ReturnType<typeof useModelLinesEdgeAttribute>;
|
|
9
|
+
|
|
10
|
+
function applyModelLinesConstantColoring(
|
|
11
|
+
modelId: string,
|
|
12
|
+
type_lines_ids: string[],
|
|
13
|
+
modelColorStyle: ColorStyle,
|
|
14
|
+
): Promise<unknown>[] {
|
|
15
|
+
const colorGroups: Record<string, ColorGroup> = {};
|
|
16
|
+
for (const line_id of type_lines_ids) {
|
|
17
|
+
const color = modelColorStyle.modelLineColor(modelId, line_id);
|
|
18
|
+
const color_key = JSON.stringify(color);
|
|
19
|
+
colorGroups[color_key] ??= { color, lines_ids: [] };
|
|
20
|
+
colorGroups[color_key].lines_ids.push(line_id);
|
|
21
|
+
}
|
|
22
|
+
return Object.values(colorGroups).map(async ({ color, lines_ids: ids }) => {
|
|
23
|
+
const result = await modelColorStyle.setModelLinesColor(modelId, ids, color, "constant");
|
|
24
|
+
return result;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function groupModelLinesVertexAttributes(
|
|
29
|
+
modelId: string,
|
|
30
|
+
type_lines_ids: string[],
|
|
31
|
+
modelLinesVertexAttribute: VertexAttributeStyle,
|
|
32
|
+
): Record<string, AttributeGroup> {
|
|
33
|
+
const vertexGroups: Record<string, AttributeGroup> = {};
|
|
34
|
+
for (const line_id of type_lines_ids) {
|
|
35
|
+
const name = modelLinesVertexAttribute.modelLinesVertexAttributeName(modelId, line_id);
|
|
36
|
+
const item = modelLinesVertexAttribute.modelLinesVertexAttributeItem(modelId, line_id);
|
|
37
|
+
const [minimum, maximum] = modelLinesVertexAttribute.modelLinesVertexAttributeRange(
|
|
38
|
+
modelId,
|
|
39
|
+
line_id,
|
|
40
|
+
);
|
|
41
|
+
const colorMap = modelLinesVertexAttribute.modelLinesVertexAttributeColorMap(modelId, line_id);
|
|
42
|
+
const no_data_color = modelLinesVertexAttribute.modelLinesVertexAttributeNoDataColor(
|
|
43
|
+
modelId,
|
|
44
|
+
line_id,
|
|
45
|
+
);
|
|
46
|
+
const attribute = {
|
|
47
|
+
name,
|
|
48
|
+
item,
|
|
49
|
+
minimum,
|
|
50
|
+
maximum,
|
|
51
|
+
colorMap,
|
|
52
|
+
no_data_color,
|
|
53
|
+
};
|
|
54
|
+
if (!isModelLinesVertexAttributeValid(attribute)) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const key = [name, item, colorMap, minimum, maximum, JSON.stringify(no_data_color)].join("_");
|
|
58
|
+
vertexGroups[key] ??= { ...attribute, lines_ids: [] };
|
|
59
|
+
vertexGroups[key].lines_ids.push(line_id);
|
|
60
|
+
}
|
|
61
|
+
return vertexGroups;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function applyModelLinesVertexColoring(
|
|
65
|
+
modelId: string,
|
|
66
|
+
type_lines_ids: string[],
|
|
67
|
+
modelLinesVertexAttribute: VertexAttributeStyle,
|
|
68
|
+
): Promise<unknown>[] {
|
|
69
|
+
const vertexGroups = groupModelLinesVertexAttributes(
|
|
70
|
+
modelId,
|
|
71
|
+
type_lines_ids,
|
|
72
|
+
modelLinesVertexAttribute,
|
|
73
|
+
);
|
|
74
|
+
return Object.values(vertexGroups).map(
|
|
75
|
+
async ({ name, item, minimum, maximum, colorMap, no_data_color, lines_ids: ids }) => {
|
|
76
|
+
const result = await modelLinesVertexAttribute.setModelLinesVertexAttribute(modelId, ids, {
|
|
77
|
+
name,
|
|
78
|
+
item,
|
|
79
|
+
minimum,
|
|
80
|
+
maximum,
|
|
81
|
+
colorMap,
|
|
82
|
+
no_data_color,
|
|
83
|
+
});
|
|
84
|
+
return result;
|
|
85
|
+
},
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function groupModelLinesEdgeAttributes(
|
|
90
|
+
modelId: string,
|
|
91
|
+
type_lines_ids: string[],
|
|
92
|
+
modelLinesEdgeAttribute: EdgeAttributeStyle,
|
|
93
|
+
): Record<string, AttributeGroup> {
|
|
94
|
+
const edgeGroups: Record<string, AttributeGroup> = {};
|
|
95
|
+
for (const line_id of type_lines_ids) {
|
|
96
|
+
const name = modelLinesEdgeAttribute.modelLinesEdgeAttributeName(modelId, line_id);
|
|
97
|
+
const item = modelLinesEdgeAttribute.modelLinesEdgeAttributeItem(modelId, line_id);
|
|
98
|
+
const [minimum, maximum] = modelLinesEdgeAttribute.modelLinesEdgeAttributeRange(
|
|
99
|
+
modelId,
|
|
100
|
+
line_id,
|
|
101
|
+
);
|
|
102
|
+
const colorMap = modelLinesEdgeAttribute.modelLinesEdgeAttributeColorMap(modelId, line_id);
|
|
103
|
+
const no_data_color = modelLinesEdgeAttribute.modelLinesEdgeAttributeNoDataColor(
|
|
104
|
+
modelId,
|
|
105
|
+
line_id,
|
|
106
|
+
);
|
|
107
|
+
const attribute = {
|
|
108
|
+
name,
|
|
109
|
+
item,
|
|
110
|
+
minimum,
|
|
111
|
+
maximum,
|
|
112
|
+
colorMap,
|
|
113
|
+
no_data_color,
|
|
114
|
+
};
|
|
115
|
+
if (!isModelLinesEdgeAttributeValid(attribute)) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const key = [name, item, colorMap, minimum, maximum, JSON.stringify(no_data_color)].join("_");
|
|
119
|
+
edgeGroups[key] ??= { ...attribute, lines_ids: [] };
|
|
120
|
+
edgeGroups[key].lines_ids.push(line_id);
|
|
121
|
+
}
|
|
122
|
+
return edgeGroups;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function applyModelLinesEdgeColoring(
|
|
126
|
+
modelId: string,
|
|
127
|
+
type_lines_ids: string[],
|
|
128
|
+
modelLinesEdgeAttribute: EdgeAttributeStyle,
|
|
129
|
+
): Promise<unknown>[] {
|
|
130
|
+
const edgeGroups = groupModelLinesEdgeAttributes(
|
|
131
|
+
modelId,
|
|
132
|
+
type_lines_ids,
|
|
133
|
+
modelLinesEdgeAttribute,
|
|
134
|
+
);
|
|
135
|
+
return Object.values(edgeGroups).map(
|
|
136
|
+
async ({ name, item, minimum, maximum, colorMap, no_data_color, lines_ids: ids }) => {
|
|
137
|
+
const result = await modelLinesEdgeAttribute.setModelLinesEdgeAttribute(modelId, ids, {
|
|
138
|
+
name,
|
|
139
|
+
item,
|
|
140
|
+
minimum,
|
|
141
|
+
maximum,
|
|
142
|
+
colorMap,
|
|
143
|
+
no_data_color,
|
|
144
|
+
});
|
|
145
|
+
return result;
|
|
146
|
+
},
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export {
|
|
151
|
+
applyModelLinesConstantColoring,
|
|
152
|
+
applyModelLinesVertexColoring,
|
|
153
|
+
applyModelLinesEdgeColoring,
|
|
154
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
|
|
2
|
+
|
|
3
|
+
interface ColorGroup {
|
|
4
|
+
color: RGBAColor | undefined;
|
|
5
|
+
lines_ids: string[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface AttributeGroup {
|
|
9
|
+
name: string;
|
|
10
|
+
item: number;
|
|
11
|
+
minimum: number;
|
|
12
|
+
maximum: number;
|
|
13
|
+
colorMap: string;
|
|
14
|
+
no_data_color?: RGBAColor;
|
|
15
|
+
lines_ids: string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type { AttributeGroup, ColorGroup };
|
|
@@ -1,27 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
applyModelLinesConstantColoring,
|
|
3
|
+
applyModelLinesEdgeColoring,
|
|
4
|
+
applyModelLinesVertexColoring,
|
|
5
|
+
} from "./apply_coloring";
|
|
4
6
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
5
7
|
import { useModelLinesColor } from "./color";
|
|
6
8
|
import { useModelLinesCommonStyle } from "./common";
|
|
9
|
+
import { useModelLinesEdgeAttribute } from "./edge";
|
|
7
10
|
import { useModelLinesPointsStyle } from "./points";
|
|
11
|
+
import { useModelLinesVertexAttribute } from "./vertex";
|
|
8
12
|
import { useModelLinesVisibility } from "./visibility";
|
|
9
13
|
|
|
10
|
-
interface ColorGroup {
|
|
11
|
-
color: RGBAColor | undefined;
|
|
12
|
-
lines_ids: string[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface AttributeGroup {
|
|
16
|
-
name: string;
|
|
17
|
-
item: number;
|
|
18
|
-
minimum: number;
|
|
19
|
-
maximum: number;
|
|
20
|
-
colorMap: string;
|
|
21
|
-
no_data_color?: RGBAColor;
|
|
22
|
-
lines_ids: string[];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
14
|
async function setModelLinesDefaultStyle(_id: string): Promise<void> {
|
|
26
15
|
// Placeholder
|
|
27
16
|
}
|
|
@@ -82,133 +71,20 @@ export function useModelLinesStyle(): ReturnType<typeof useModelLinesCommonStyle
|
|
|
82
71
|
|
|
83
72
|
for (const [type, type_lines_ids] of Object.entries(activeColoringGroups)) {
|
|
84
73
|
if (type === "constant") {
|
|
85
|
-
const colorGroups: Record<string, ColorGroup> = {};
|
|
86
|
-
for (const line_id of type_lines_ids) {
|
|
87
|
-
const color = modelColorStyle.modelLineColor(modelId, line_id);
|
|
88
|
-
const color_key = JSON.stringify(color);
|
|
89
|
-
colorGroups[color_key] ??= { color, lines_ids: [] };
|
|
90
|
-
colorGroups[color_key].lines_ids.push(line_id);
|
|
91
|
-
}
|
|
92
74
|
coloringPromises.push(
|
|
93
|
-
...
|
|
94
|
-
const result = await modelColorStyle.setModelLinesColor(
|
|
95
|
-
modelId,
|
|
96
|
-
ids,
|
|
97
|
-
color,
|
|
98
|
-
"constant",
|
|
99
|
-
);
|
|
100
|
-
return result;
|
|
101
|
-
}),
|
|
75
|
+
...applyModelLinesConstantColoring(modelId, type_lines_ids, modelColorStyle),
|
|
102
76
|
);
|
|
103
77
|
} else if (type === "random") {
|
|
104
78
|
coloringPromises.push(
|
|
105
79
|
modelColorStyle.setModelLinesColor(modelId, type_lines_ids, undefined, "random"),
|
|
106
80
|
);
|
|
107
81
|
} else if (type === "vertex") {
|
|
108
|
-
const vertexGroups: Record<string, AttributeGroup> = {};
|
|
109
|
-
for (const line_id of type_lines_ids) {
|
|
110
|
-
const name = modelLinesVertexAttribute.modelLinesVertexAttributeName(modelId, line_id);
|
|
111
|
-
const item = modelLinesVertexAttribute.modelLinesVertexAttributeItem(modelId, line_id);
|
|
112
|
-
const [minimum, maximum] = modelLinesVertexAttribute.modelLinesVertexAttributeRange(
|
|
113
|
-
modelId,
|
|
114
|
-
line_id,
|
|
115
|
-
);
|
|
116
|
-
const colorMap = modelLinesVertexAttribute.modelLinesVertexAttributeColorMap(
|
|
117
|
-
modelId,
|
|
118
|
-
line_id,
|
|
119
|
-
);
|
|
120
|
-
const no_data_color = modelLinesVertexAttribute.modelLinesVertexAttributeNoDataColor(
|
|
121
|
-
modelId,
|
|
122
|
-
line_id,
|
|
123
|
-
);
|
|
124
|
-
const attribute = {
|
|
125
|
-
name,
|
|
126
|
-
item,
|
|
127
|
-
minimum,
|
|
128
|
-
maximum,
|
|
129
|
-
colorMap,
|
|
130
|
-
no_data_color,
|
|
131
|
-
};
|
|
132
|
-
if (!isModelLinesVertexAttributeValid(attribute)) {
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
const key = [name, item, colorMap, minimum, maximum, JSON.stringify(no_data_color)].join(
|
|
136
|
-
"_",
|
|
137
|
-
);
|
|
138
|
-
vertexGroups[key] ??= { ...attribute, lines_ids: [] };
|
|
139
|
-
vertexGroups[key].lines_ids.push(line_id);
|
|
140
|
-
}
|
|
141
82
|
coloringPromises.push(
|
|
142
|
-
...
|
|
143
|
-
async ({ name, item, minimum, maximum, colorMap, no_data_color, lines_ids: ids }) => {
|
|
144
|
-
const result = await modelLinesVertexAttribute.setModelLinesVertexAttribute(
|
|
145
|
-
modelId,
|
|
146
|
-
ids,
|
|
147
|
-
{
|
|
148
|
-
name,
|
|
149
|
-
item,
|
|
150
|
-
minimum,
|
|
151
|
-
maximum,
|
|
152
|
-
colorMap,
|
|
153
|
-
no_data_color,
|
|
154
|
-
},
|
|
155
|
-
);
|
|
156
|
-
return result;
|
|
157
|
-
},
|
|
158
|
-
),
|
|
83
|
+
...applyModelLinesVertexColoring(modelId, type_lines_ids, modelLinesVertexAttribute),
|
|
159
84
|
);
|
|
160
85
|
} else if (type === "edge") {
|
|
161
|
-
const edgeGroups: Record<string, AttributeGroup> = {};
|
|
162
|
-
for (const line_id of type_lines_ids) {
|
|
163
|
-
const name = modelLinesEdgeAttribute.modelLinesEdgeAttributeName(modelId, line_id);
|
|
164
|
-
const item = modelLinesEdgeAttribute.modelLinesEdgeAttributeItem(modelId, line_id);
|
|
165
|
-
const [minimum, maximum] = modelLinesEdgeAttribute.modelLinesEdgeAttributeRange(
|
|
166
|
-
modelId,
|
|
167
|
-
line_id,
|
|
168
|
-
);
|
|
169
|
-
const colorMap = modelLinesEdgeAttribute.modelLinesEdgeAttributeColorMap(
|
|
170
|
-
modelId,
|
|
171
|
-
line_id,
|
|
172
|
-
);
|
|
173
|
-
const no_data_color = modelLinesEdgeAttribute.modelLinesEdgeAttributeNoDataColor(
|
|
174
|
-
modelId,
|
|
175
|
-
line_id,
|
|
176
|
-
);
|
|
177
|
-
const attribute = {
|
|
178
|
-
name,
|
|
179
|
-
item,
|
|
180
|
-
minimum,
|
|
181
|
-
maximum,
|
|
182
|
-
colorMap,
|
|
183
|
-
no_data_color,
|
|
184
|
-
};
|
|
185
|
-
if (!isModelLinesEdgeAttributeValid(attribute)) {
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
const key = [name, item, colorMap, minimum, maximum, JSON.stringify(no_data_color)].join(
|
|
189
|
-
"_",
|
|
190
|
-
);
|
|
191
|
-
edgeGroups[key] ??= { ...attribute, lines_ids: [] };
|
|
192
|
-
edgeGroups[key].lines_ids.push(line_id);
|
|
193
|
-
}
|
|
194
86
|
coloringPromises.push(
|
|
195
|
-
...
|
|
196
|
-
async ({ name, item, minimum, maximum, colorMap, no_data_color, lines_ids: ids }) => {
|
|
197
|
-
const result = await modelLinesEdgeAttribute.setModelLinesEdgeAttribute(
|
|
198
|
-
modelId,
|
|
199
|
-
ids,
|
|
200
|
-
{
|
|
201
|
-
name,
|
|
202
|
-
item,
|
|
203
|
-
minimum,
|
|
204
|
-
maximum,
|
|
205
|
-
colorMap,
|
|
206
|
-
no_data_color,
|
|
207
|
-
},
|
|
208
|
-
);
|
|
209
|
-
return result;
|
|
210
|
-
},
|
|
211
|
-
),
|
|
87
|
+
...applyModelLinesEdgeColoring(modelId, type_lines_ids, modelLinesEdgeAttribute),
|
|
212
88
|
);
|
|
213
89
|
}
|
|
214
90
|
}
|