Skip to content
Draft

temp #382

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/components/Viewer/ObjectTree/Views/GlobalObjects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ function handleHoverLeave({ item }) {
</template>

<template #append="{ item }">
<v-btn
v-if="item.viewer_type"
icon="mdi-image-filter-center-focus"
size="small"
variant="text"
v-tooltip="'Focus camera on object'"
@click.stop="hybridViewerStore.focusCameraOnObject(item.id)"
/>
<v-btn
v-if="isModel(item)"
icon="mdi-magnify-expand"
Expand Down
13 changes: 13 additions & 0 deletions app/components/Viewer/ObjectTree/Views/ModelComponents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import FetchingData from "@ogw_front/components/FetchingData.vue";
import ObjectTreeControls from "@ogw_front/components/Viewer/ObjectTree/Base/Controls.vue";
import ObjectTreeItemLabel from "@ogw_front/components/Viewer/ObjectTree/Base/ItemLabel.vue";
import { useHoverhighlight } from "@ogw_front/composables/hover_highlight";
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
import { useModelComponents } from "@ogw_front/composables/model_components";
import { useTreeviewStore } from "@ogw_front/stores/treeview";

const { id } = defineProps({ id: { type: String, required: true } });
const { onHoverEnter, onHoverLeave } = useHoverhighlight();
const hybridViewerStore = useHybridViewerStore();
const emit = defineEmits(["show-menu"]);

const treeviewStore = useTreeviewStore();
Expand Down Expand Up @@ -150,6 +152,17 @@ function handleHoverLeave() {
@contextmenu.prevent.stop="showContextMenu($event, item)"
/>
</template>

<template #append="{ item }">
<v-btn
v-if="item.category"
icon="mdi-image-filter-center-focus"
size="small"
variant="text"
v-tooltip="'Focus camera on object'"
@click.stop="hybridViewerStore.focusCameraOnObject(id)"
/>
</template>
</CommonTreeView>
</div>
</template>
Expand Down
16 changes: 16 additions & 0 deletions app/stores/hybrid_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
WHEEL_TIME_OUT_MS,
applySnapshot,
computeAverageBrightness,
focusCameraOnBounds,
getCameraOptions,
performCameraOrientation,
performClickPicking,
Expand Down Expand Up @@ -159,6 +160,18 @@
syncRemoteCamera();
}

function focusCameraOnObject(id) {
if (!hybridDb[id]) {
return;
}
const bounds = hybridDb[id].actor.getBounds();
focusCameraOnBounds(bounds, {
genericRenderWindow: genericRenderWindow.value,
imageStyle,
syncRemoteCamera,
});
}

function setCameraOrientation(orientation) {
performCameraOrientation(orientation, {
genericRenderWindow: genericRenderWindow.value,
Expand Down Expand Up @@ -229,6 +242,7 @@
return;
}
is_moving.value = false;
genericRenderWindow.value.getRenderer().resetCameraClippingRange();
syncRemoteCamera();
},
});
Expand All @@ -240,6 +254,7 @@
clearTimeout(wheelEventEndTimeout);
wheelEventEndTimeout = setTimeout(() => {
is_moving.value = false;
genericRenderWindow.value.getRenderer().resetCameraClippingRange();
syncRemoteCamera();
}, WHEEL_TIME_OUT_MS);
});
Expand Down Expand Up @@ -309,6 +324,7 @@
remoteRender,
resize,
resetCamera,
focusCameraOnObject,
setCameraOrientation,
setContainer,
zScale,
Expand All @@ -320,4 +336,4 @@
latestImage,
getAverageBrightness,
};
});

Check failure on line 339 in app/stores/hybrid_viewer.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(max-lines)

File has too many lines (312).
27 changes: 25 additions & 2 deletions app/utils/local/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,32 @@

function commandExistsSync(execName) {
const envPath = process.env.PATH || "";
return envPath.split(path.delimiter).some((dir) => {
const paths = envPath.split(path.delimiter);

let currentDir = process.cwd();
while (currentDir !== path.parse(currentDir).root) {
const venvScripts = path.join(
currentDir,
".venv",
process.platform === "win32" ? "Scripts" : "bin",
);
if (fs.existsSync(venvScripts)) {
paths.unshift(venvScripts);
break;
}
currentDir = path.dirname(currentDir);
}

return paths.some((dir) => {
const filePath = path.join(dir, execName);
return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) return true;

Check failure on line 29 in app/utils/local/scripts.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(curly)

Expected { after 'if' condition.
if (process.platform === "win32") {
return [".exe", ".cmd", ".bat", ".ps1"].some((ext) => {
const withExt = `${filePath}${ext}`;
return fs.existsSync(withExt) && fs.statSync(withExt).isFile();
});
}
return false;
});
}

Expand Down
15 changes: 15 additions & 0 deletions internal/stores/hybrid_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@
);
}

function focusCameraOnBounds(bounds, options) {
const { genericRenderWindow, imageStyle, syncRemoteCamera } = options;
if (!bounds || bounds.length < 6 || bounds.some((v) => !isFinite(v))) {

Check failure on line 134 in internal/stores/hybrid_viewer.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint-plugin-unicorn(prefer-number-properties)

Use `Number.isFinite` instead of the global `isFinite`

Check failure on line 134 in internal/stores/hybrid_viewer.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(no-magic-numbers)

No magic number: 6

Check failure on line 134 in internal/stores/hybrid_viewer.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(id-length)

Identifier name is too short (< 3).
return;
}
const renderer = genericRenderWindow.getRenderer();
renderer.resetCamera(bounds);
if (imageStyle) {
imageStyle.opacity = 0;
}
genericRenderWindow.getRenderWindow().render();
syncRemoteCamera();
}

function performClickPicking(event, options) {
const { container, viewerStore, viewer_schemas, genericRenderWindow, syncRemoteCamera } = options;
const rect = container.getBoundingClientRect();
Expand Down Expand Up @@ -270,6 +284,7 @@
applySnapshot,
centerCameraOnPosition,
computeAverageBrightness,
focusCameraOnBounds,
getCameraOptions,
performCameraOrientation,
performClickPicking,
Expand Down
Loading