@geode/opengeodeweb-front 10.13.2 → 10.14.0-rc.1
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/ContextMenuItem.vue +2 -1
- package/app/components/Viewer/Generic/Model/EdgesOptions.vue +10 -2
- package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +129 -52
- package/app/components/Viewer/Generic/Model/PointsOptions.vue +10 -2
- package/app/components/Viewer/ObjectTree/Layout.vue +6 -2
- package/app/components/Viewer/ObjectTree/Views/ModelComponents.vue +12 -8
- package/app/components/Viewer/Options/OptionsSection.vue +74 -0
- package/app/stores/data.js +2 -2
- package/app/stores/data_style.js +11 -2
- package/app/stores/menu.js +3 -0
- package/app/utils/default_styles.js +10 -1
- package/app/utils/import_workflow.js +3 -3
- package/internal/database/base_database.js +2 -0
- package/internal/database/database.js +1 -0
- package/internal/database/tables/model_component_type_datastyle.js +4 -0
- package/internal/stores/data_style/model/blocks/color.js +8 -34
- package/internal/stores/data_style/model/blocks/common.js +5 -3
- package/internal/stores/data_style/model/blocks/index.js +31 -33
- package/internal/stores/data_style/model/blocks/visibility.js +9 -36
- package/internal/stores/data_style/model/color.js +97 -0
- package/internal/stores/data_style/model/common.js +132 -0
- package/internal/stores/data_style/model/corners/color.js +8 -32
- package/internal/stores/data_style/model/corners/common.js +5 -3
- package/internal/stores/data_style/model/corners/index.js +31 -38
- package/internal/stores/data_style/model/corners/visibility.js +8 -32
- package/internal/stores/data_style/model/index.js +50 -202
- package/internal/stores/data_style/model/lines/color.js +8 -36
- package/internal/stores/data_style/model/lines/common.js +5 -3
- package/internal/stores/data_style/model/lines/index.js +30 -31
- package/internal/stores/data_style/model/lines/visibility.js +9 -36
- package/internal/stores/data_style/model/selection.js +83 -0
- package/internal/stores/data_style/model/surfaces/color.js +8 -32
- package/internal/stores/data_style/model/surfaces/common.js +5 -3
- package/internal/stores/data_style/model/surfaces/index.js +30 -33
- package/internal/stores/data_style/model/surfaces/visibility.js +9 -34
- package/internal/stores/data_style/model/visibility.js +186 -0
- package/internal/stores/data_style/state.js +24 -31
- package/package.json +3 -3
- package/tests/integration/stores/data_style/model/blocks.nuxt.test.js +11 -2
- package/tests/integration/stores/data_style/model/corners.nuxt.test.js +11 -2
- package/tests/integration/stores/data_style/model/lines.nuxt.test.js +11 -2
- package/tests/integration/stores/data_style/model/surfaces.nuxt.test.js +11 -2
|
@@ -1,231 +1,79 @@
|
|
|
1
|
-
import { database } from "@ogw_internal/database/database";
|
|
2
|
-
import { liveQuery } from "dexie";
|
|
3
1
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
4
2
|
import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
|
|
5
|
-
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
6
3
|
import { useModelBlocksStyle } from "./blocks";
|
|
4
|
+
import { useModelColorStyle } from "./color";
|
|
7
5
|
import { useModelCornersStyle } from "./corners";
|
|
8
6
|
import { useModelEdgesStyle } from "./edges";
|
|
9
7
|
import { useModelLinesStyle } from "./lines";
|
|
10
8
|
import { useModelPointsStyle } from "./points";
|
|
9
|
+
import { useModelSelection } from "./selection";
|
|
11
10
|
import { useModelSurfacesStyle } from "./surfaces";
|
|
12
|
-
import {
|
|
13
|
-
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
|
|
11
|
+
import { useModelVisibilityStyle } from "./visibility";
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const MESH_CONFIG = [{ type: "Corner" }, { type: "Line" }, { type: "Surface" }, { type: "Block" }];
|
|
18
|
-
|
|
19
|
-
const MESH_TYPES = MESH_CONFIG.map((config) => config.type);
|
|
20
|
-
|
|
21
|
-
export function useModelStyle() {
|
|
13
|
+
function useModelStyle() {
|
|
22
14
|
const dataStore = useDataStore();
|
|
23
15
|
const dataStyleState = useDataStyleState();
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
componentsByType[component.type].push(component);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const groupStyles = dataStyleState.getStyle(modelId);
|
|
42
|
-
const selection = [];
|
|
43
|
-
for (const type of MESH_TYPES) {
|
|
44
|
-
const typeComponents = componentsByType[type];
|
|
45
|
-
if (typeComponents.length === 0) {
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const typeKey = `${type.toLowerCase()}s`;
|
|
50
|
-
const defaultVisibility = groupStyles[typeKey].visibility;
|
|
51
|
-
|
|
52
|
-
let allVisible = true;
|
|
53
|
-
for (const component of typeComponents) {
|
|
54
|
-
const isVisible = stylesMap[component.geode_id]?.visibility ?? defaultVisibility;
|
|
55
|
-
if (isVisible) {
|
|
56
|
-
selection.push(component.geode_id);
|
|
57
|
-
} else {
|
|
58
|
-
allVisible = false;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (allVisible) {
|
|
62
|
-
selection.push(type);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return selection;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function modelVisibility(modelId) {
|
|
69
|
-
return dataStyleState.getStyle(modelId).visibility;
|
|
70
|
-
}
|
|
16
|
+
const modelCornersStyle = useModelCornersStyle();
|
|
17
|
+
const modelBlocksStyle = useModelBlocksStyle();
|
|
18
|
+
const modelEdgesStyle = useModelEdgesStyle();
|
|
19
|
+
const modelLinesStyle = useModelLinesStyle();
|
|
20
|
+
const modelPointsStyle = useModelPointsStyle();
|
|
21
|
+
const modelSurfacesStyle = useModelSurfacesStyle();
|
|
22
|
+
|
|
23
|
+
const componentStyleFunctions = {
|
|
24
|
+
Corner: modelCornersStyle,
|
|
25
|
+
Line: modelLinesStyle,
|
|
26
|
+
Surface: modelSurfacesStyle,
|
|
27
|
+
Block: modelBlocksStyle,
|
|
28
|
+
};
|
|
71
29
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
model_schemas.visibility,
|
|
75
|
-
{ id: modelId, visibility },
|
|
76
|
-
{
|
|
77
|
-
response_function: async () => {
|
|
78
|
-
await hybridViewerStore.setVisibility(modelId, visibility);
|
|
79
|
-
await dataStyleState.mutateStyle(modelId, { visibility });
|
|
80
|
-
return { id: modelId, visibility };
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
);
|
|
84
|
-
}
|
|
30
|
+
const modelColorStyle = useModelColorStyle(componentStyleFunctions);
|
|
31
|
+
const modelVisibilityStyle = useModelVisibilityStyle(componentStyleFunctions);
|
|
85
32
|
|
|
86
33
|
function visibleMeshComponents(id_ref) {
|
|
87
|
-
|
|
88
|
-
watch(
|
|
89
|
-
() => unref(id_ref),
|
|
90
|
-
(modelId, _prev, onCleanup) => {
|
|
91
|
-
if (!modelId) {
|
|
92
|
-
selection.value = [];
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const observable = liveQuery(async () => {
|
|
96
|
-
const allComponents = await database.model_components
|
|
97
|
-
.where("id")
|
|
98
|
-
.equals(modelId)
|
|
99
|
-
.toArray();
|
|
100
|
-
if (allComponents.length === 0) {
|
|
101
|
-
return [];
|
|
102
|
-
}
|
|
103
|
-
const componentStyles = await database.model_component_datastyle
|
|
104
|
-
.where("id_model")
|
|
105
|
-
.equals(modelId)
|
|
106
|
-
.toArray();
|
|
107
|
-
const stylesMap = Object.fromEntries(
|
|
108
|
-
componentStyles.map((style) => [style.id_component, style]),
|
|
109
|
-
);
|
|
110
|
-
return buildSelection(modelId, allComponents, stylesMap);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const subscription = observable.subscribe({
|
|
114
|
-
next: (val) => {
|
|
115
|
-
selection.value = val;
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
onCleanup(() => subscription.unsubscribe());
|
|
119
|
-
},
|
|
120
|
-
{ immediate: true },
|
|
121
|
-
);
|
|
122
|
-
return selection;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function getModelComponentColor(modelId, componentId) {
|
|
126
|
-
return dataStyleState.getComponentStyle(modelId, componentId).color;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
async function setModelComponentsVisibility(modelId, componentIds, visibility) {
|
|
130
|
-
const allComponents = await database.model_components.where("id").equals(modelId).toArray();
|
|
131
|
-
const componentsMap = Object.fromEntries(
|
|
132
|
-
allComponents.map((component) => [component.geode_id, component]),
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
return Promise.all(
|
|
136
|
-
MESH_TYPES.map(async (type) => {
|
|
137
|
-
const typeComponents = allComponents.filter((component) => component.type === type);
|
|
138
|
-
const isSelectedType = componentIds.includes(type);
|
|
139
|
-
const idsToUpdate = isSelectedType
|
|
140
|
-
? typeComponents.map((component) => component.geode_id)
|
|
141
|
-
: componentIds.filter((id) => componentsMap[id]?.type === type);
|
|
142
|
-
|
|
143
|
-
if (idsToUpdate.length === 0) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const viewerIds = await dataStore.getMeshComponentsViewerIds(modelId, idsToUpdate);
|
|
148
|
-
if (viewerIds.length > 0) {
|
|
149
|
-
const schema = model_schemas[`${type.toLowerCase()}s`].visibility;
|
|
150
|
-
await viewerStore.request(schema, { id: modelId, block_ids: viewerIds, visibility });
|
|
151
|
-
}
|
|
152
|
-
return dataStyleState.mutateComponentStyles(modelId, idsToUpdate, { visibility });
|
|
153
|
-
}),
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
async function setModelComponentsColor(modelId, componentIds, color) {
|
|
158
|
-
const allComponents = await database.model_components.where("id").equals(modelId).toArray();
|
|
159
|
-
const componentsMap = Object.fromEntries(
|
|
160
|
-
allComponents.map((component) => [component.geode_id, component]),
|
|
161
|
-
);
|
|
162
|
-
const handlers = {
|
|
163
|
-
Corner: (ids) => modelCornersStyleStore.setModelCornersColor(modelId, ids, color),
|
|
164
|
-
Line: (ids) => modelLinesStyleStore.setModelLinesColor(modelId, ids, color),
|
|
165
|
-
Surface: (ids) => modelSurfacesStyleStore.setModelSurfacesColor(modelId, ids, color),
|
|
166
|
-
Block: (ids) => modelBlocksStyleStore.setModelBlocksColor(modelId, ids, color),
|
|
167
|
-
};
|
|
168
|
-
return Promise.all(
|
|
169
|
-
MESH_TYPES.map((type) => {
|
|
170
|
-
const idsForType = componentIds.filter((id) => componentsMap[id]?.type === type);
|
|
171
|
-
return handlers[type](idsForType);
|
|
172
|
-
}),
|
|
173
|
-
);
|
|
34
|
+
return useModelSelection(id_ref, dataStyleState);
|
|
174
35
|
}
|
|
175
36
|
|
|
176
37
|
function applyModelStyle(modelId) {
|
|
177
38
|
const style = dataStyleState.getStyle(modelId);
|
|
178
|
-
const handlers = {
|
|
179
|
-
visibility: () => setModelVisibility(modelId, style.visibility),
|
|
180
|
-
corners: () => modelCornersStyleStore.applyModelCornersStyle(modelId),
|
|
181
|
-
lines: () => modelLinesStyleStore.applyModelLinesStyle(modelId),
|
|
182
|
-
surfaces: () => modelSurfacesStyleStore.applyModelSurfacesStyle(modelId),
|
|
183
|
-
blocks: () => modelBlocksStyleStore.applyModelBlocksStyle(modelId),
|
|
184
|
-
points: () => modelPointsStyleStore.applyModelPointsStyle(modelId),
|
|
185
|
-
edges: () => modelEdgesStyleStore.applyModelEdgesStyle(modelId),
|
|
186
|
-
};
|
|
187
39
|
|
|
188
|
-
return Promise.all(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
40
|
+
return Promise.all([
|
|
41
|
+
modelVisibilityStyle.setModelVisibility(modelId, style.visibility),
|
|
42
|
+
modelBlocksStyle.applyModelBlocksStyle(modelId),
|
|
43
|
+
modelSurfacesStyle.applyModelSurfacesStyle(modelId),
|
|
44
|
+
modelLinesStyle.applyModelLinesStyle(modelId),
|
|
45
|
+
modelCornersStyle.applyModelCornersStyle(modelId),
|
|
46
|
+
modelPointsStyle.applyModelPointsStyle(modelId),
|
|
47
|
+
modelEdgesStyle.applyModelEdgesStyle(modelId),
|
|
48
|
+
]);
|
|
193
49
|
}
|
|
194
50
|
|
|
195
|
-
function setModelMeshComponentsDefaultStyle(modelId) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
};
|
|
207
|
-
return Promise.all(
|
|
208
|
-
Object.keys(mesh_components)
|
|
209
|
-
.filter((key) => handlers[key])
|
|
210
|
-
.map((key) => handlers[key]()),
|
|
211
|
-
);
|
|
212
|
-
});
|
|
51
|
+
async function setModelMeshComponentsDefaultStyle(modelId) {
|
|
52
|
+
const item = await dataStore.item(modelId);
|
|
53
|
+
if (!item) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
return await Promise.all([
|
|
57
|
+
modelBlocksStyle.setModelBlocksDefaultStyle(modelId),
|
|
58
|
+
modelSurfacesStyle.setModelSurfacesDefaultStyle(modelId),
|
|
59
|
+
modelLinesStyle.setModelLinesDefaultStyle(modelId),
|
|
60
|
+
modelCornersStyle.setModelCornersDefaultStyle(modelId),
|
|
61
|
+
]);
|
|
213
62
|
}
|
|
214
63
|
|
|
215
64
|
return {
|
|
216
|
-
modelVisibility,
|
|
217
65
|
visibleMeshComponents,
|
|
218
|
-
setModelVisibility,
|
|
219
|
-
setModelComponentsVisibility,
|
|
220
|
-
getModelComponentColor,
|
|
221
|
-
setModelComponentsColor,
|
|
222
66
|
applyModelStyle,
|
|
223
67
|
setModelMeshComponentsDefaultStyle,
|
|
224
|
-
...
|
|
225
|
-
...
|
|
226
|
-
...
|
|
227
|
-
...
|
|
228
|
-
...
|
|
229
|
-
...
|
|
68
|
+
...modelColorStyle,
|
|
69
|
+
...modelVisibilityStyle,
|
|
70
|
+
...modelBlocksStyle,
|
|
71
|
+
...modelCornersStyle,
|
|
72
|
+
...modelEdgesStyle,
|
|
73
|
+
...modelLinesStyle,
|
|
74
|
+
...modelPointsStyle,
|
|
75
|
+
...modelSurfacesStyle,
|
|
230
76
|
};
|
|
231
77
|
}
|
|
78
|
+
|
|
79
|
+
export { useModelStyle };
|
|
@@ -1,48 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
|
|
3
|
-
|
|
4
|
-
// Local imports
|
|
5
|
-
import { useDataStore } from "@ogw_front/stores/data";
|
|
1
|
+
import { useModelCommonStyle } from "@ogw_internal/stores/data_style/model/common";
|
|
6
2
|
import { useModelLinesCommonStyle } from "./common";
|
|
7
|
-
import
|
|
3
|
+
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
const model_lines_schemas = viewer_schemas.opengeodeweb_viewer.model.lines;
|
|
5
|
+
const schema = viewer_schemas.opengeodeweb_viewer.model.lines.color;
|
|
11
6
|
|
|
12
|
-
export function
|
|
13
|
-
const
|
|
14
|
-
const viewerStore = useViewerStore();
|
|
7
|
+
export function useModelLinesColor() {
|
|
8
|
+
const modelCommonStyle = useModelCommonStyle();
|
|
15
9
|
const modelLinesCommonStyle = useModelLinesCommonStyle();
|
|
16
10
|
|
|
17
11
|
function modelLineColor(id, line_id) {
|
|
18
12
|
return modelLinesCommonStyle.modelLineStyle(id, line_id).color;
|
|
19
13
|
}
|
|
20
14
|
|
|
21
|
-
function setModelLinesColor(
|
|
22
|
-
|
|
23
|
-
return Promise.resolve();
|
|
24
|
-
}
|
|
25
|
-
return dataStore.getMeshComponentsViewerIds(id, line_ids).then((line_viewer_ids) => {
|
|
26
|
-
if (!line_viewer_ids || line_viewer_ids.length === 0) {
|
|
27
|
-
return modelLinesCommonStyle.mutateModelLinesStyle(id, line_ids, {
|
|
28
|
-
color,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
return viewerStore.request(
|
|
32
|
-
model_lines_schemas.color,
|
|
33
|
-
{ id, block_ids: line_viewer_ids, color },
|
|
34
|
-
{
|
|
35
|
-
response_function: () =>
|
|
36
|
-
modelLinesCommonStyle.mutateModelLinesStyle(id, line_ids, {
|
|
37
|
-
color,
|
|
38
|
-
}),
|
|
39
|
-
},
|
|
40
|
-
);
|
|
41
|
-
});
|
|
15
|
+
function setModelLinesColor(modelId, lines_ids, color, color_mode = "constant") {
|
|
16
|
+
return modelCommonStyle.setModelTypeColor(modelId, lines_ids, color, schema, color_mode);
|
|
42
17
|
}
|
|
43
18
|
|
|
44
|
-
return {
|
|
45
|
-
modelLineColor,
|
|
46
|
-
setModelLinesColor,
|
|
47
|
-
};
|
|
19
|
+
return { setModelLinesColor, modelLineColor };
|
|
48
20
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import merge from "lodash/merge";
|
|
2
2
|
import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
|
|
3
|
+
import { useModelCommonStyle } from "@ogw_internal/stores/data_style/model/common";
|
|
3
4
|
|
|
4
5
|
export function useModelLinesCommonStyle() {
|
|
5
6
|
const dataStyleState = useDataStyleState();
|
|
7
|
+
const modelCommonStyle = useModelCommonStyle();
|
|
6
8
|
|
|
7
9
|
function modelLinesStyle(id) {
|
|
8
10
|
return dataStyleState.getStyle(id).lines;
|
|
@@ -14,12 +16,12 @@ export function useModelLinesCommonStyle() {
|
|
|
14
16
|
return merge({}, groupStyle, individualStyle);
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
function mutateModelLinesStyle(id,
|
|
18
|
-
return
|
|
19
|
+
function mutateModelLinesStyle(id, lines_ids, values) {
|
|
20
|
+
return modelCommonStyle.mutateComponentStyles(id, lines_ids, values);
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
function mutateModelLineStyle(id, line_id, values) {
|
|
22
|
-
return
|
|
24
|
+
return modelCommonStyle.mutateComponentStyle(id, line_id, values);
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
return {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
// Local imports
|
|
2
1
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
3
|
-
import {
|
|
2
|
+
import { useModelLinesColor } from "./color";
|
|
4
3
|
import { useModelLinesCommonStyle } from "./common";
|
|
5
|
-
import {
|
|
4
|
+
import { useModelLinesVisibility } from "./visibility";
|
|
6
5
|
|
|
7
6
|
async function setModelLinesDefaultStyle(_id) {
|
|
8
7
|
// Placeholder
|
|
@@ -10,44 +9,44 @@ async function setModelLinesDefaultStyle(_id) {
|
|
|
10
9
|
|
|
11
10
|
export function useModelLinesStyle() {
|
|
12
11
|
const dataStore = useDataStore();
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
12
|
+
const modelCommonStyle = useModelLinesCommonStyle();
|
|
13
|
+
const modelVisibilityStyle = useModelLinesVisibility();
|
|
14
|
+
const modelColorStyle = useModelLinesColor();
|
|
16
15
|
|
|
17
|
-
async function applyModelLinesStyle(
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
16
|
+
async function applyModelLinesStyle(modelId) {
|
|
17
|
+
const lines_ids = await dataStore.getLinesGeodeIds(modelId);
|
|
18
|
+
if (!lines_ids?.length) {
|
|
20
19
|
return;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
const visibilityGroups = {};
|
|
24
23
|
const colorGroups = {};
|
|
25
24
|
|
|
26
|
-
for (const line_id of
|
|
27
|
-
const style =
|
|
25
|
+
for (const line_id of lines_ids) {
|
|
26
|
+
const style = modelCommonStyle.modelLineStyle(modelId, line_id);
|
|
28
27
|
|
|
29
|
-
const
|
|
30
|
-
if (!visibilityGroups[
|
|
31
|
-
visibilityGroups[
|
|
28
|
+
const visibility = String(style.visibility);
|
|
29
|
+
if (!visibilityGroups[visibility]) {
|
|
30
|
+
visibilityGroups[visibility] = [];
|
|
32
31
|
}
|
|
33
|
-
visibilityGroups[
|
|
32
|
+
visibilityGroups[visibility].push(line_id);
|
|
34
33
|
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const color_mode = style.color_mode || "constant";
|
|
35
|
+
const color_key = color_mode === "random" ? "random" : JSON.stringify(style.color);
|
|
36
|
+
if (!colorGroups[color_key]) {
|
|
37
|
+
colorGroups[color_key] = { color_mode, color: style.color, lines_ids: [] };
|
|
38
38
|
}
|
|
39
|
-
colorGroups[
|
|
39
|
+
colorGroups[color_key].lines_ids.push(line_id);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const promises = [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
42
|
+
const promises = [
|
|
43
|
+
...Object.entries(visibilityGroups).map(([visibility, ids]) =>
|
|
44
|
+
modelVisibilityStyle.setModelLinesVisibility(modelId, ids, visibility === "true"),
|
|
45
|
+
),
|
|
46
|
+
...Object.values(colorGroups).map(({ color_mode, color, lines_ids: ids }) =>
|
|
47
|
+
modelColorStyle.setModelLinesColor(modelId, ids, color, color_mode),
|
|
48
|
+
),
|
|
49
|
+
];
|
|
51
50
|
|
|
52
51
|
return Promise.all(promises);
|
|
53
52
|
}
|
|
@@ -55,8 +54,8 @@ export function useModelLinesStyle() {
|
|
|
55
54
|
return {
|
|
56
55
|
applyModelLinesStyle,
|
|
57
56
|
setModelLinesDefaultStyle,
|
|
58
|
-
...
|
|
59
|
-
...
|
|
60
|
-
...
|
|
57
|
+
...modelCommonStyle,
|
|
58
|
+
...modelVisibilityStyle,
|
|
59
|
+
...modelColorStyle,
|
|
61
60
|
};
|
|
62
61
|
}
|
|
@@ -1,47 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
|
|
3
|
-
|
|
4
|
-
// Local imports
|
|
5
|
-
import { useDataStore } from "@ogw_front/stores/data";
|
|
1
|
+
import { useModelCommonStyle } from "@ogw_internal/stores/data_style/model/common";
|
|
6
2
|
import { useModelLinesCommonStyle } from "./common";
|
|
7
|
-
import
|
|
3
|
+
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
const model_lines_schemas = viewer_schemas.opengeodeweb_viewer.model.lines;
|
|
5
|
+
const schema = viewer_schemas.opengeodeweb_viewer.model.lines.visibility;
|
|
11
6
|
|
|
12
|
-
export function
|
|
13
|
-
const
|
|
14
|
-
const viewerStore = useViewerStore();
|
|
7
|
+
export function useModelLinesVisibility() {
|
|
8
|
+
const modelCommonStyle = useModelCommonStyle();
|
|
15
9
|
const modelLinesCommonStyle = useModelLinesCommonStyle();
|
|
10
|
+
|
|
16
11
|
function modelLineVisibility(id, line_id) {
|
|
17
12
|
return modelLinesCommonStyle.modelLineStyle(id, line_id).visibility;
|
|
18
13
|
}
|
|
19
|
-
function setModelLinesVisibility(id, line_ids, visibility) {
|
|
20
|
-
if (!line_ids || line_ids.length === 0) {
|
|
21
|
-
return Promise.resolve();
|
|
22
|
-
}
|
|
23
14
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return modelLinesCommonStyle.mutateModelLinesStyle(id, line_ids, {
|
|
27
|
-
visibility,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return viewerStore.request(
|
|
31
|
-
model_lines_schemas.visibility,
|
|
32
|
-
{ id, block_ids: line_viewer_ids, visibility },
|
|
33
|
-
{
|
|
34
|
-
response_function: () =>
|
|
35
|
-
modelLinesCommonStyle.mutateModelLinesStyle(id, line_ids, {
|
|
36
|
-
visibility,
|
|
37
|
-
}),
|
|
38
|
-
},
|
|
39
|
-
);
|
|
40
|
-
});
|
|
15
|
+
function setModelLinesVisibility(modelId, lines_ids, visibility) {
|
|
16
|
+
return modelCommonStyle.setModelTypeVisibility(modelId, lines_ids, visibility, schema);
|
|
41
17
|
}
|
|
42
18
|
|
|
43
|
-
return {
|
|
44
|
-
modelLineVisibility,
|
|
45
|
-
setModelLinesVisibility,
|
|
46
|
-
};
|
|
19
|
+
return { setModelLinesVisibility, modelLineVisibility };
|
|
47
20
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { MESH_TYPES } from "@ogw_front/utils/default_styles";
|
|
2
|
+
import { database } from "@ogw_internal/database/database";
|
|
3
|
+
import { liveQuery } from "dexie";
|
|
4
|
+
|
|
5
|
+
function buildSelection(modelId, components, stylesMap, typeStylesMap, dataStyleState) {
|
|
6
|
+
const componentsByType = Object.fromEntries(
|
|
7
|
+
MESH_TYPES.map((componentType) => [componentType, []]),
|
|
8
|
+
);
|
|
9
|
+
for (const component of components) {
|
|
10
|
+
if (componentsByType[component.type]) {
|
|
11
|
+
componentsByType[component.type].push(component);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const groupStyles = dataStyleState.getStyle(modelId);
|
|
16
|
+
const selection = [];
|
|
17
|
+
for (const componentType of MESH_TYPES) {
|
|
18
|
+
const typeComponents = componentsByType[componentType];
|
|
19
|
+
if (typeComponents.length === 0) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const typeKey = `${componentType.toLowerCase()}s`;
|
|
24
|
+
const typeStyle = typeStylesMap[componentType];
|
|
25
|
+
const defaultVisibility = typeStyle?.visibility ?? groupStyles[typeKey]?.visibility ?? true;
|
|
26
|
+
|
|
27
|
+
let allVisible = true;
|
|
28
|
+
for (const component of typeComponents) {
|
|
29
|
+
const isVisible = stylesMap[component.geode_id]?.visibility ?? defaultVisibility;
|
|
30
|
+
if (isVisible) {
|
|
31
|
+
selection.push(component.geode_id);
|
|
32
|
+
} else {
|
|
33
|
+
allVisible = false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (allVisible) {
|
|
37
|
+
selection.push(componentType);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return selection;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function useModelSelection(id_ref, dataStyleState) {
|
|
44
|
+
const selection = ref([]);
|
|
45
|
+
watch(
|
|
46
|
+
() => unref(id_ref),
|
|
47
|
+
(modelId, _prev, onCleanup) => {
|
|
48
|
+
if (!modelId) {
|
|
49
|
+
selection.value = [];
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const observable = liveQuery(async () => {
|
|
53
|
+
const [allComponents, componentStyles, typeStyles] = await Promise.all([
|
|
54
|
+
database.model_components.where("id").equals(modelId).toArray(),
|
|
55
|
+
database.model_component_datastyle.where("id_model").equals(modelId).toArray(),
|
|
56
|
+
database.model_component_type_datastyle.where("id_model").equals(modelId).toArray(),
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
if (allComponents.length === 0) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const stylesMap = Object.fromEntries(
|
|
64
|
+
componentStyles.map((style) => [style.id_component, style]),
|
|
65
|
+
);
|
|
66
|
+
const typeStylesMap = Object.fromEntries(typeStyles.map((style) => [style.type, style]));
|
|
67
|
+
|
|
68
|
+
return buildSelection(modelId, allComponents, stylesMap, typeStylesMap, dataStyleState);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const subscription = observable.subscribe({
|
|
72
|
+
next: (val) => {
|
|
73
|
+
selection.value = val;
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
onCleanup(() => subscription.unsubscribe());
|
|
77
|
+
},
|
|
78
|
+
{ immediate: true },
|
|
79
|
+
);
|
|
80
|
+
return selection;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { buildSelection, useModelSelection };
|
|
@@ -1,44 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
|
|
3
|
-
|
|
4
|
-
// Local imports
|
|
5
|
-
import { useDataStore } from "@ogw_front/stores/data";
|
|
1
|
+
import { useModelCommonStyle } from "@ogw_internal/stores/data_style/model/common";
|
|
6
2
|
import { useModelSurfacesCommonStyle } from "./common";
|
|
7
|
-
import
|
|
3
|
+
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
const model_surfaces_schemas = viewer_schemas.opengeodeweb_viewer.model.surfaces;
|
|
5
|
+
const schema = viewer_schemas.opengeodeweb_viewer.model.surfaces.color;
|
|
11
6
|
|
|
12
|
-
export function
|
|
13
|
-
const
|
|
14
|
-
const viewerStore = useViewerStore();
|
|
7
|
+
export function useModelSurfacesColor() {
|
|
8
|
+
const modelCommonStyle = useModelCommonStyle();
|
|
15
9
|
const modelSurfacesCommonStyle = useModelSurfacesCommonStyle();
|
|
16
10
|
|
|
17
11
|
function modelSurfaceColor(id, surface_id) {
|
|
18
12
|
return modelSurfacesCommonStyle.modelSurfaceStyle(id, surface_id).color;
|
|
19
13
|
}
|
|
20
14
|
|
|
21
|
-
function setModelSurfacesColor(
|
|
22
|
-
|
|
23
|
-
return Promise.resolve();
|
|
24
|
-
}
|
|
25
|
-
return dataStore.getMeshComponentsViewerIds(id, surface_ids).then((surface_viewer_ids) => {
|
|
26
|
-
if (!surface_viewer_ids || surface_viewer_ids.length === 0) {
|
|
27
|
-
return modelSurfacesCommonStyle.mutateModelSurfacesStyle(id, surface_ids, { color });
|
|
28
|
-
}
|
|
29
|
-
return viewerStore.request(
|
|
30
|
-
model_surfaces_schemas.color,
|
|
31
|
-
{ id, block_ids: surface_viewer_ids, color },
|
|
32
|
-
{
|
|
33
|
-
response_function: () =>
|
|
34
|
-
modelSurfacesCommonStyle.mutateModelSurfacesStyle(id, surface_ids, { color }),
|
|
35
|
-
},
|
|
36
|
-
);
|
|
37
|
-
});
|
|
15
|
+
function setModelSurfacesColor(modelId, surfaces_ids, color, color_mode = "constant") {
|
|
16
|
+
return modelCommonStyle.setModelTypeColor(modelId, surfaces_ids, color, schema, color_mode);
|
|
38
17
|
}
|
|
39
18
|
|
|
40
|
-
return {
|
|
41
|
-
modelSurfaceColor,
|
|
42
|
-
setModelSurfacesColor,
|
|
43
|
-
};
|
|
19
|
+
return { setModelSurfacesColor, modelSurfaceColor };
|
|
44
20
|
}
|