Skip to content

Commit c156eab

Browse files
committed
test
1 parent fca8a2a commit c156eab

File tree

4 files changed

+71
-74
lines changed

4 files changed

+71
-74
lines changed

composables/project_manager.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,8 @@ export function useProjectManager() {
3535
try {
3636
await useInfraStore().create_connection()
3737

38-
const schemaImport = back_schemas.opengeodeweb_back.import_project
39-
const form = new FormData()
40-
form.append("file", file, file?.name)
41-
42-
const result = await $fetch(schemaImport.$id, {
43-
baseURL: geode.base_url,
44-
method: "POST",
45-
body: form,
46-
})
47-
const snapshot = result?.snapshot ?? {}
38+
const viewerStore = useViewerStore()
39+
await viewerStore.ws_connect()
4840

4941
await viewer_call({
5042
schema: viewer_schemas.opengeodeweb_viewer.import_project,
@@ -55,13 +47,28 @@ export function useProjectManager() {
5547
params: {},
5648
})
5749

50+
const dataBaseStore = useDataBaseStore()
5851
const treeviewStore = useTreeviewStore()
52+
const hybridViewerStore = useHybridViewerStore()
53+
treeviewStore.clear()
54+
dataBaseStore.clear()
55+
hybridViewerStore.clear()
56+
57+
const schemaImport = back_schemas.opengeodeweb_back.import_project
58+
const form = new FormData()
59+
form.append("file", file, file?.name)
60+
61+
const result = await $fetch(schemaImport.$id, {
62+
baseURL: geode.base_url,
63+
method: "POST",
64+
body: form,
65+
})
66+
const snapshot = result?.snapshot ?? {}
67+
5968
treeviewStore.isImporting = true
6069
await treeviewStore.importStores(snapshot?.treeview)
6170

62-
const hybridViewerStore = useHybridViewerStore()
6371
await hybridViewerStore.initHybridViewer()
64-
hybridViewerStore.clear()
6572
await hybridViewerStore.importStores(snapshot?.hybridViewer)
6673

6774
const snapshotDataBase = snapshot?.dataBase?.db || {}
@@ -77,7 +84,6 @@ export function useProjectManager() {
7784

7885
await importWorkflowFromSnapshot(items)
7986

80-
// Appliquer la caméra importée après avoir créé les actors
8187
await hybridViewerStore.importStores(snapshot?.hybridViewer)
8288

8389
const dataStyleStore = useDataStyleStore()

stores/data_base.js

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,33 @@ export const useDataBaseStore = defineStore("dataBase", () => {
106106
)
107107
}
108108

109+
function getCornersUuids(id) {
110+
const { mesh_components } = itemMetaDatas(id)
111+
return Object.values(mesh_components["Corner"])
112+
}
113+
114+
function getLinesUuids(id) {
115+
const { mesh_components } = itemMetaDatas(id)
116+
return Object.values(mesh_components["Line"])
117+
}
118+
function getSurfacesUuids(id) {
119+
const { mesh_components } = itemMetaDatas(id)
120+
return Object.values(mesh_components["Surface"])
121+
}
122+
function getBlocksUuids(id) {
123+
const { mesh_components } = itemMetaDatas(id)
124+
return Object.values(mesh_components["Block"])
125+
}
126+
127+
function getFlatIndexes(id, mesh_component_ids) {
128+
const { uuid_to_flat_index } = itemMetaDatas(id)
129+
const flat_indexes = []
130+
for (const mesh_component_id of mesh_component_ids) {
131+
flat_indexes.push(uuid_to_flat_index[mesh_component_id])
132+
}
133+
return flat_indexes
134+
}
135+
109136
function exportStores() {
110137
const snapshotDb = {}
111138
for (const [id, item] of Object.entries(db)) {
@@ -137,31 +164,10 @@ export const useDataBaseStore = defineStore("dataBase", () => {
137164
}
138165
}
139166

140-
function getCornersUuids(id) {
141-
const { mesh_components } = itemMetaDatas(id)
142-
return Object.values(mesh_components["Corner"])
143-
}
144-
145-
function getLinesUuids(id) {
146-
const { mesh_components } = itemMetaDatas(id)
147-
return Object.values(mesh_components["Line"])
148-
}
149-
function getSurfacesUuids(id) {
150-
const { mesh_components } = itemMetaDatas(id)
151-
return Object.values(mesh_components["Surface"])
152-
}
153-
function getBlocksUuids(id) {
154-
const { mesh_components } = itemMetaDatas(id)
155-
return Object.values(mesh_components["Block"])
156-
}
157-
158-
function getFlatIndexes(id, mesh_component_ids) {
159-
const { uuid_to_flat_index } = itemMetaDatas(id)
160-
const flat_indexes = []
161-
for (const mesh_component_id of mesh_component_ids) {
162-
flat_indexes.push(uuid_to_flat_index[mesh_component_id])
167+
function clear() {
168+
for (const id of Object.keys(db)) {
169+
delete db[id]
163170
}
164-
return flat_indexes
165171
}
166172

167173
return {
@@ -180,5 +186,6 @@ export const useDataBaseStore = defineStore("dataBase", () => {
180186
getFlatIndexes,
181187
exportStores,
182188
importStores,
189+
clear,
183190
}
184191
})

stores/hybrid_viewer.js

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,6 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
1919
let viewStream
2020
let gridActor = null
2121

22-
// Helper: conversion stricte aux types/schema + logs des types
23-
function sanitizeCameraOptions(opts) {
24-
if (!opts) return null
25-
const toNums = (arr, size) =>
26-
Array.from(arr || [])
27-
.slice(0, size)
28-
.map((n) => Number(n))
29-
return {
30-
focal_point: toNums(opts.focal_point, 3),
31-
view_up: toNums(opts.view_up, 3),
32-
position: toNums(opts.position, 3),
33-
view_angle: Number(opts.view_angle),
34-
clipping_range: toNums(opts.clipping_range, 2),
35-
}
36-
}
37-
38-
function logCameraOptions(label, opts) {
39-
const types = (arr) => Array.from(arr || []).map((v) => typeof v)
40-
console.log(`[Camera] ${label}`, {
41-
focal_point: opts?.focal_point,
42-
focal_point_types: types(opts?.focal_point),
43-
view_up: opts?.view_up,
44-
view_up_types: types(opts?.view_up),
45-
position: opts?.position,
46-
position_types: types(opts?.position),
47-
view_angle: opts?.view_angle,
48-
view_angle_type: typeof opts?.view_angle,
49-
clipping_range: opts?.clipping_range,
50-
clipping_range_types: types(opts?.clipping_range),
51-
})
52-
}
53-
5422
async function initHybridViewer() {
5523
if (status.value !== Status.NOT_CREATED) return
5624
status.value = Status.CREATING
@@ -265,7 +233,6 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
265233
const renderer = genericRenderWindow.value.getRenderer()
266234
const camera = renderer.getActiveCamera()
267235

268-
// Appliquer les composantes (x, y, z), pas le tableau
269236
camera.setFocalPoint(...cam.focal_point)
270237
camera.setViewUp(...cam.view_up)
271238
camera.setPosition(...cam.position)
@@ -274,7 +241,6 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
274241

275242
genericRenderWindow.value.getRenderWindow().render()
276243

277-
// Envoyer uniquement les champs conformes au schéma (sans distance)
278244
const payload = {
279245
camera_options: {
280246
focal_point: cam.focal_point,

stores/treeview.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,32 @@ export const useTreeviewStore = defineStore("treeview", () => {
8484
function finalizeImportSelection() {
8585
const ids = pendingSelectionIds.value || []
8686
const rebuilt = []
87-
for (const group of items.value) {
88-
for (const child of group.children) {
89-
if (ids.includes(child.id)) rebuilt.push(child)
87+
if (ids.length === 0) {
88+
for (const group of items.value) {
89+
for (const child of group.children) {
90+
rebuilt.push(child)
91+
}
92+
}
93+
} else {
94+
for (const group of items.value) {
95+
for (const child of group.children) {
96+
if (ids.includes(child.id)) rebuilt.push(child)
97+
}
9098
}
9199
}
92100
selection.value = rebuilt
93101
pendingSelectionIds.value = []
94102
}
95103

104+
function clear() {
105+
items.value = []
106+
selection.value = []
107+
components_selection.value = []
108+
pendingSelectionIds.value = []
109+
model_id.value = ""
110+
selectedTree.value = null
111+
}
112+
96113
return {
97114
items,
98115
selection,
@@ -110,5 +127,6 @@ export const useTreeviewStore = defineStore("treeview", () => {
110127
exportStores,
111128
importStores,
112129
finalizeImportSelection,
130+
clear,
113131
}
114132
})

0 commit comments

Comments
 (0)