|
1 | 1 | <template>
|
2 | 2 | <ClientOnly>
|
3 |
| - <div style="position: relative; width: 100%; height: 100%"> |
| 3 | + <div style="position: relative; width: 100%; height: calc(100vh - 80px)"> |
4 | 4 | <view-toolbar />
|
5 | 5 | <div
|
6 | 6 | style="
|
|
35 | 35 |
|
36 | 36 | <script setup>
|
37 | 37 | import vtkRemoteView from "@kitware/vtk.js/Rendering/Misc/RemoteView"
|
38 |
| - import { useElementSize } from "@vueuse/core" |
| 38 | + import { useElementSize, useWindowSize } from "@vueuse/core" |
39 | 39 | import viewer_schemas from "@geode/opengeodeweb-viewer/schemas.json"
|
40 | 40 |
|
41 | 41 | const viewer_store = use_viewer_store()
|
42 | 42 | const { client, is_running, picking_mode } = storeToRefs(viewer_store)
|
43 | 43 |
|
| 44 | + const viewer = ref(null) |
| 45 | + const { width, height } = useElementSize(viewer) |
| 46 | +
|
| 47 | + const { width: windowWidth, height: windowHeight } = useWindowSize() |
| 48 | +
|
44 | 49 | function get_x_y(event) {
|
45 | 50 | if (picking_mode.value === true) {
|
46 | 51 | const { offsetX, offsetY } = event
|
|
56 | 61 | viewId: { type: String, default: "-1" },
|
57 | 62 | })
|
58 | 63 |
|
59 |
| - const viewer = ref(null) |
60 |
| - const { width, height } = useElementSize(viewer) |
61 |
| -
|
62 |
| - function resize() { |
63 |
| - view.getCanvasView().setSize(0, 0) |
64 |
| - view.resize() |
65 |
| - } |
66 |
| -
|
67 |
| - watch(picking_mode, (value) => { |
68 |
| - const cursor = value == true ? "crosshair" : "pointer" |
69 |
| - view.getCanvasView().setCursor(cursor) |
70 |
| - }) |
71 |
| - watch(width, (value) => { |
72 |
| - resize() |
73 |
| - }) |
74 |
| - watch(height, (value) => { |
75 |
| - resize() |
76 |
| - }) |
77 | 64 | const { viewId } = toRefs(props)
|
78 | 65 | const connected = ref(false)
|
79 | 66 |
|
80 | 67 | const view = vtkRemoteView.newInstance({
|
81 | 68 | rpcWheelEvent: "viewport.mouse.zoom.wheel",
|
82 | 69 | })
|
83 |
| - // default of 0.5 causes 2x size labels on high-DPI screens. 1 good for demo, not for production. |
| 70 | +
|
84 | 71 | if (location.hostname.split(".")[0] === "localhost") {
|
85 | 72 | view.setInteractiveRatio(1)
|
86 | 73 | }
|
87 | 74 |
|
88 |
| - watch(client, (new_client) => { |
| 75 | + function resize() { |
| 76 | + if (view) { |
| 77 | + view.getCanvasView().setSize(0, 0) |
| 78 | + view.resize() |
| 79 | + } |
| 80 | + } |
| 81 | +
|
| 82 | + watch([windowWidth, windowHeight], () => { |
| 83 | + resize() |
| 84 | + }) |
| 85 | +
|
| 86 | + watch(picking_mode, (value) => { |
| 87 | + const cursor = value ? "crosshair" : "pointer" |
| 88 | + view.getCanvasView().setCursor(cursor) |
| 89 | + }) |
| 90 | +
|
| 91 | + watch([width, height], () => { |
| 92 | + resize() |
| 93 | + }) |
| 94 | +
|
| 95 | + watch(client, () => { |
89 | 96 | connect()
|
90 | 97 | })
|
91 | 98 |
|
|
96 | 103 | }
|
97 | 104 | })
|
98 | 105 |
|
99 |
| - onMounted(async () => { |
100 |
| - if (process.client) { |
101 |
| - window.addEventListener("resize", resize) |
102 |
| - await nextTick() |
103 |
| - view.setContainer(viewer.value.$el) |
104 |
| - connect() |
105 |
| - resize() |
106 |
| - } |
107 |
| - }) |
108 |
| -
|
109 | 106 | function connect() {
|
110 | 107 | if (!is_running.value) {
|
111 | 108 | return
|
|
116 | 113 | connected.value = true
|
117 | 114 | view.render()
|
118 | 115 | }
|
| 116 | +
|
| 117 | + onMounted(async () => { |
| 118 | + if (process.client) { |
| 119 | + window.addEventListener("resize", resize) |
| 120 | + await nextTick() |
| 121 | + view.setContainer(viewer.value.$el) |
| 122 | + connect() |
| 123 | + resize() |
| 124 | + } |
| 125 | + }) |
119 | 126 | </script>
|
120 | 127 |
|
121 | 128 | <style scoped>
|
|
0 commit comments