Skip to content

Commit 09d96d8

Browse files
authored
Merge pull request #383 from Geode-solutions/feat/points-creation
feat(points): points creation with picking and multiple points creation
2 parents 2a2807f + aaea884 commit 09d96d8

3 files changed

Lines changed: 71 additions & 12 deletions

File tree

app/components/HybridRenderingView.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ function debounce(func, wait) {
4242
timeout = setTimeout(later, wait);
4343
};
4444
}
45+
46+
async function handleClick(event) {
47+
if (viewerStore.picking_mode) {
48+
const rect = container.value.$el.getBoundingClientRect();
49+
const x = event.clientX - rect.left;
50+
const y = elementHeight.value - (event.clientY - rect.top);
51+
await viewerStore.set_picked_point(x, y);
52+
return;
53+
}
54+
emit("click", event);
55+
}
4556
</script>
4657
4758
<template>
@@ -52,16 +63,19 @@ function debounce(func, wait) {
5263
<v-col
5364
class="pa-0"
5465
ref="viewer"
66+
:class="{ 'picking-cursor': viewerStore.picking_mode }"
5567
style="height: 100%; overflow: hidden; position: relative; z-index: 0"
56-
@click="emit('click', $event)"
57-
@keydown.esc="viewerStore.toggle_picking_mode(false)"
68+
@click="handleClick"
5869
/>
5970
</div>
6071
</ClientOnly>
6172
</template>
6273
63-
<style>
74+
<style scoped>
6475
img {
6576
pointer-events: none;
6677
}
78+
.picking-cursor {
79+
cursor: crosshair !important;
80+
}
6781
</style>

app/components/Viewer/Ui.vue

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const { displayMenu, containerWidth, containerHeight } = defineProps({
1414
});
1515
1616
const emit = defineEmits(["show-menu"]);
17-
1817
const dataStore = useDataStore();
1918
const dataStyleStore = useDataStyleStore();
2019
const viewerStore = useViewerStore();
@@ -56,4 +55,52 @@ defineExpose({ get_viewer_id });
5655
:container-width="containerWidth"
5756
:container-height="containerHeight"
5857
/>
58+
59+
<v-fade-transition>
60+
<div
61+
v-if="viewerStore.picking_mode"
62+
class="picking-message-container d-flex justify-center w-100 pa-4"
63+
>
64+
<v-chip
65+
color="secondary"
66+
elevation="8"
67+
size="large"
68+
variant="flat"
69+
prepend-icon="mdi-crosshairs-gps"
70+
class="pick-pulse"
71+
style="pointer-events: auto"
72+
@click="viewerStore.toggle_picking_mode(false)"
73+
>
74+
Picking active — click in the viewer &middot; Esc to stop
75+
<v-divider vertical class="mx-2 my-1" opacity="0.3" />
76+
<v-icon icon="mdi-close" size="small" />
77+
</v-chip>
78+
</div>
79+
</v-fade-transition>
5980
</template>
81+
82+
<style scoped>
83+
.picking-message-container {
84+
position: absolute;
85+
top: 20px;
86+
left: 0;
87+
pointer-events: none;
88+
z-index: 100;
89+
}
90+
91+
@keyframes pulse-ring {
92+
0% {
93+
box-shadow: 0 0 0 0 rgba(var(--v-theme-secondary), 0.7);
94+
}
95+
70% {
96+
box-shadow: 0 0 0 10px rgba(var(--v-theme-secondary), 0);
97+
}
98+
100% {
99+
box-shadow: 0 0 0 0 rgba(var(--v-theme-secondary), 0);
100+
}
101+
}
102+
103+
.pick-pulse {
104+
animation: pulse-ring 1.5s ease-out infinite;
105+
}
106+
</style>

app/stores/viewer.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const useViewerStore = defineStore(
2727
const client = ref({});
2828
const config = ref(undefined);
2929
const picking_mode = ref(false);
30-
const picked_point = ref({ x: undefined, y: undefined });
30+
const picked_point = ref({ x: undefined, y: undefined, z: undefined });
3131
const request_counter = ref(0);
3232
const status = ref(Status.NOT_CONNECTED);
3333
const buzy = ref(0);
@@ -62,14 +62,12 @@ export const useViewerStore = defineStore(
6262
}
6363

6464
async function set_picked_point(x, y) {
65-
const response = await request(schemas.opengeodeweb_viewer.generic.get_point_position, {
66-
x,
67-
y,
65+
const response = await request(schemas.opengeodeweb_viewer.viewer.get_point_position, {
66+
x: Math.round(x),
67+
y: Math.round(y),
6868
});
69-
const { x: world_x, y: world_y } = response;
70-
picked_point.value.x = world_x;
71-
picked_point.value.y = world_y;
72-
picking_mode.value = false;
69+
const { x: world_x, y: world_y, z: world_z } = response;
70+
picked_point.value = { x: world_x, y: world_y, z: world_z };
7371
}
7472

7573
function ws_connect() {

0 commit comments

Comments
 (0)