@geode/opengeodeweb-front 10.14.0-rc.6 → 10.14.0-rc.8

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.
@@ -16,7 +16,7 @@ const { itemProps } = defineProps({
16
16
 
17
17
  const modelId = computed(() => itemProps.meta_data.modelId || itemProps.id);
18
18
  const componentId = computed(() => itemProps.meta_data.pickedComponentId);
19
- const selection = dataStyleStore.visibleMeshComponents(modelId);
19
+ const selection = dataStyleStore.visibleMeshComponents(modelId.value);
20
20
  const componentType = ref(undefined);
21
21
 
22
22
  watchEffect(async () => {
@@ -2,14 +2,18 @@
2
2
  import ObjectTreeControls from "@ogw_front/components/Viewer/ObjectTree/Base/Controls.vue";
3
3
  import ObjectTreeItemLabel from "@ogw_front/components/Viewer/ObjectTree/Base/ItemLabel.vue";
4
4
  import { compareSelections } from "@ogw_front/utils/treeview";
5
+ import { useDataStore } from "@ogw_front/stores/data";
5
6
  import { useDataStyleStore } from "@ogw_front/stores/data_style";
7
+ import { useHoverhighlight } from "@ogw_front/composables/use_hover_highlight";
6
8
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
7
9
  import { useTreeFilter } from "@ogw_front/composables/use_tree_filter";
8
10
  import { useTreeviewStore } from "@ogw_front/stores/treeview";
9
11
 
10
12
  const treeviewStore = useTreeviewStore();
13
+ const dataStore = useDataStore();
11
14
  const dataStyleStore = useDataStyleStore();
12
15
  const hybridViewerStore = useHybridViewerStore();
16
+ const { onHoverEnter, onHoverLeave } = useHoverhighlight();
13
17
 
14
18
  const emit = defineEmits(["show-menu"]);
15
19
 
@@ -62,6 +66,21 @@ function isModel(item) {
62
66
  actualItem.viewer_type === "model" || ["BRep", "Section"].includes(actualItem.geode_object_type)
63
67
  );
64
68
  }
69
+
70
+ async function handleHoverEnter(item) {
71
+ const actualItem = item.raw || item;
72
+ const is_model = isModel(item);
73
+ let block_ids = [];
74
+ if (is_model) {
75
+ block_ids = await dataStore.getAllModelComponentsViewerIds(actualItem.id);
76
+ }
77
+ onHoverEnter(actualItem.id, block_ids, is_model ? "model" : "mesh");
78
+ }
79
+
80
+ function handleHoverLeave(item) {
81
+ const actualItem = item.raw || item;
82
+ onHoverLeave(actualItem.id);
83
+ }
65
84
  </script>
66
85
 
67
86
  <template>
@@ -89,6 +108,8 @@ function isModel(item) {
89
108
  <template #title="{ item }">
90
109
  <ObjectTreeItemLabel
91
110
  :item="item"
111
+ @mouseenter="handleHoverEnter(item)"
112
+ @mouseleave="handleHoverLeave(item)"
92
113
  @contextmenu="emit('show-menu', { event: $event, itemId: item.id })"
93
114
  />
94
115
  </template>
@@ -5,11 +5,13 @@ import ObjectTreeItemLabel from "@ogw_front/components/Viewer/ObjectTree/Base/It
5
5
  import { compareSelections } from "@ogw_front/utils/treeview";
6
6
  import { useDataStore } from "@ogw_front/stores/data";
7
7
  import { useDataStyleStore } from "@ogw_front/stores/data_style";
8
+ import { useHoverhighlight } from "@ogw_front/composables/use_hover_highlight";
8
9
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
9
10
  import { useTreeFilter } from "@ogw_front/composables/use_tree_filter";
10
11
  import { useTreeviewStore } from "@ogw_front/stores/treeview";
11
12
 
12
13
  const { id: viewId } = defineProps({ id: { type: String, required: true } });
14
+ const { onHoverEnter, onHoverLeave } = useHoverhighlight();
13
15
  const emit = defineEmits(["show-menu"]);
14
16
 
15
17
  const dataStore = useDataStore();
@@ -63,6 +65,18 @@ function showContextMenu(event, item) {
63
65
  modelComponentType: actualItem.category ? undefined : actualItem.id,
64
66
  });
65
67
  }
68
+
69
+ function handleHoverEnter(item) {
70
+ const actualItem = item.raw || item;
71
+ const block_ids = actualItem.category
72
+ ? [actualItem.viewer_id]
73
+ : actualItem.children?.map((child) => child.viewer_id) || [];
74
+ onHoverEnter(viewId, block_ids);
75
+ }
76
+
77
+ function handleHoverLeave() {
78
+ onHoverLeave(viewId);
79
+ }
66
80
  </script>
67
81
 
68
82
  <template>
@@ -95,6 +109,8 @@ function showContextMenu(event, item) {
95
109
  <ObjectTreeItemLabel
96
110
  :item="item"
97
111
  show-tooltip
112
+ @mouseenter="handleHoverEnter(item)"
113
+ @mouseleave="handleHoverLeave(item)"
98
114
  @contextmenu="showContextMenu($event, item)"
99
115
  />
100
116
  </template>
@@ -0,0 +1,48 @@
1
+ import { useViewerStore } from "@ogw_front/stores/viewer";
2
+ import vtk_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
3
+
4
+ const HOVER_DELAY = 1000;
5
+
6
+ export function useHoverhighlight() {
7
+ const viewerStore = useViewerStore();
8
+ let timer = undefined;
9
+ let currentId = undefined;
10
+ let currentType = undefined;
11
+
12
+ function onHoverEnter(id, block_ids = [], type = "model") {
13
+ if (timer) {
14
+ clearTimeout(timer);
15
+ }
16
+ const schema = vtk_schemas.opengeodeweb_viewer[type].highlight;
17
+ timer = setTimeout(async () => {
18
+ currentId = id;
19
+ currentType = type;
20
+ const params = {
21
+ id,
22
+ visibility: true,
23
+ ...(type === "model" && { block_ids }),
24
+ };
25
+ await viewerStore.request(schema, params);
26
+ }, HOVER_DELAY);
27
+ }
28
+
29
+ function onHoverLeave(id) {
30
+ if (timer) {
31
+ clearTimeout(timer);
32
+ timer = undefined;
33
+ }
34
+ if (currentId === id) {
35
+ const schema = vtk_schemas.opengeodeweb_viewer[currentType].highlight;
36
+ const params = {
37
+ id,
38
+ visibility: false,
39
+ ...(currentType === "model" && { block_ids: [] }),
40
+ };
41
+ viewerStore.request(schema, params);
42
+ currentId = undefined;
43
+ currentType = undefined;
44
+ }
45
+ }
46
+
47
+ return { onHoverEnter, onHoverLeave };
48
+ }
@@ -63,6 +63,7 @@ export const useDataStore = defineStore("data", () => {
63
63
  id: meshComponent.geode_id,
64
64
  title: meshComponent.name,
65
65
  category: meshComponent.type,
66
+ viewer_id: meshComponent.viewer_id,
66
67
  is_active: meshComponent.is_active,
67
68
  })),
68
69
  }));
@@ -206,6 +207,11 @@ export const useDataStore = defineStore("data", () => {
206
207
  return await getMeshComponentGeodeIds(modelId, "Block");
207
208
  }
208
209
 
210
+ async function getAllModelComponentsViewerIds(modelId) {
211
+ const components = await database.model_components.where("id").equals(modelId).toArray();
212
+ return components.map((component) => Number.parseInt(component.viewer_id, 10));
213
+ }
214
+
209
215
  async function getMeshComponentsViewerIds(modelId, meshComponentGeodeIds) {
210
216
  const components = await database.model_components
211
217
  .where("[id+geode_id]")
@@ -245,6 +251,7 @@ export const useDataStore = defineStore("data", () => {
245
251
  getLinesGeodeIds,
246
252
  getSurfacesGeodeIds,
247
253
  getBlocksGeodeIds,
254
+ getAllModelComponentsViewerIds,
248
255
  getMeshComponentGeodeIds,
249
256
  getMeshComponentsViewerIds,
250
257
  getComponentByViewerId,
@@ -31,8 +31,8 @@ function useModelStyle() {
31
31
  const modelColorStyle = useModelColorStyle(componentStyleFunctions);
32
32
  const modelVisibilityStyle = useModelVisibilityStyle(componentStyleFunctions);
33
33
 
34
- function visibleMeshComponents(id_ref) {
35
- return useModelSelection(id_ref, dataStyleState);
34
+ function visibleMeshComponents(modelId) {
35
+ return useModelSelection(modelId, dataStyleState);
36
36
  }
37
37
 
38
38
  function applyModelStyle(modelId) {
@@ -44,6 +44,9 @@ function buildSelection(modelId, components, stylesMap, typeStylesMap, dataStyle
44
44
  function useModelSelection(modelId, dataStyleState) {
45
45
  return useObservable(
46
46
  liveQuery(async () => {
47
+ if (!modelId) {
48
+ return [];
49
+ }
47
50
  const [allComponents, componentStyles, typeStyles] = await Promise.all([
48
51
  database.model_components.where("id").equals(modelId).toArray(),
49
52
  database.model_component_datastyle.where("id_model").equals(modelId).toArray(),
@@ -55,9 +58,10 @@ function useModelSelection(modelId, dataStyleState) {
55
58
  const stylesMap = Object.fromEntries(
56
59
  componentStyles.map((style) => [style.id_component, style]),
57
60
  );
58
- const typeStylesMap = Object.fromEntries(typeStyles.map((style) => [style.type, style]));
59
- return buildSelection(modelId, allComponents, stylesMap, typeStylesMap, dataStyleState);
61
+ const stylesByTypeMap = Object.fromEntries(typeStyles.map((style) => [style.type, style]));
62
+ return buildSelection(modelId, allComponents, stylesMap, stylesByTypeMap, dataStyleState);
60
63
  }),
64
+ { initialValue: [] },
61
65
  );
62
66
  }
63
67
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geode/opengeodeweb-front",
3
- "version": "10.14.0-rc.6",
3
+ "version": "10.14.0-rc.8",
4
4
  "description": "OpenSource Vue/Nuxt/Pinia/Vuetify framework for web applications",
5
5
  "homepage": "https://github.com/Geode-solutions/OpenGeodeWeb-Front",
6
6
  "bugs": {