+{sideMenuOpen && (
+
{/* Viewport grid menu at top center */}
@@ -2096,6 +2113,7 @@ function App() {
boxShadow: "0 2px 8px rgba(0,0,0,0.2)",
pointerEvents: gridBtnActive ? "auto" : "none", // Only clickable when active
zIndex: 2,
+ display: gridBtnActive ? "block" : "none",
}}
onMouseLeave={() => setGridBtnActive(false)}
onBlur={() => setGridBtnActive(false)}
@@ -2452,7 +2470,8 @@ function App() {
export default App
-function setupTools() {
+function setupTools(MAIN_TOOL_GROUP_ID) {
+ console.log('Setting up tools...', MAIN_TOOL_GROUP_ID);
cornerstoneTools.addTool(PanTool)
cornerstoneTools.addTool(WindowLevelTool)
cornerstoneTools.addTool(StackScrollTool)
diff --git a/dicom-viewer/src/index.css b/dicom-viewer/src/index.css
index 35181e9..1b2960a 100644
--- a/dicom-viewer/src/index.css
+++ b/dicom-viewer/src/index.css
@@ -19,4 +19,30 @@ html, body, #root {
opacity: 1 !important;
pointer-events: auto;
}
- */
\ No newline at end of file
+ */
+.dicom-viewer-root, #root {
+ width: 100vw;
+ height: 100vh;
+ min-height: 0;
+ min-width: 0;
+ position: relative;
+}
+
+.dicom-viewer-test-root {
+ box-sizing: border-box;
+ color: rgb(128, 128, 128);
+ display: block;
+ font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
+ font-size: 16px;
+ font-weight: 400;
+ height: 500px;
+ line-height: 24px;
+ max-height: 500px;
+ overflow-x: auto;
+ overflow-y: auto;
+ text-align: start;
+ text-size-adjust: 100%;
+ unicode-bidi: isolate;
+ width: 1296px;
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
+}
\ No newline at end of file
diff --git a/dicom-viewer/src/main.tsx b/dicom-viewer/src/main.tsx
index 2bf0688..0846ffd 100644
--- a/dicom-viewer/src/main.tsx
+++ b/dicom-viewer/src/main.tsx
@@ -4,16 +4,57 @@ import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import Nifti from './Nifti.tsx'
import './index.css'
+import { createImageIds, availableImageIds } from "./lib/createImageIds.ts"
-//ReactDOM.createRoot(document.getElementById('root')!).render(
-//
-//
-// {/* */}
-// ,
-//)
+const test_containers = document.querySelectorAll(".dicom-viewer-test-root");
+test_containers.forEach((container) => {
+ const id = container.id || '';
+ const imageStacks = () => availableImageIds();
+ createRoot(container).render(
+
+ );
+});
-// Render to multiple containers
const containers = document.querySelectorAll(".dicom-viewer-root");
containers.forEach((container) => {
- createRoot(container).render(
);
+ const id = container.id || '';
+ let imageStacks;
+
+ // Helper to convert URLs to wadouri
+ const toWadouri = (arr: string[]) =>
+ arr.map(url => url.startsWith("wadouri:") ? url : `wadouri:${url}`);
+
+ // Check for data-images attribute
+ const dataImages = container.getAttribute('data-images');
+ if (dataImages) {
+ let parsed;
+ try {
+ parsed = JSON.parse(dataImages);
+ } catch (e) {
+ console.error("Invalid data-images JSON:", e);
+ parsed = [];
+ }
+ // If it's a flat list, wrap in an array to make it a stack list and convert to wadouri
+ if (Array.isArray(parsed) && parsed.length > 0 && typeof parsed[0] === "string") {
+ imageStacks = () => Promise.resolve([toWadouri(parsed)]);
+ } else if (Array.isArray(parsed)) {
+ imageStacks = () => Promise.resolve(parsed.map(
+ stack => Array.isArray(stack) ? toWadouri(stack) : []
+ ));
+ } else {
+ imageStacks = () => Promise.resolve([[]]);
+ }
+ } else {
+ imageStacks = () => Promise.resolve([[]]);
+ }
+
+ createRoot(container).render(
+
+ );
});
\ No newline at end of file
diff --git a/dicom-viewer/vite.config.ts b/dicom-viewer/vite.config.ts
index 9752594..454a4f0 100644
--- a/dicom-viewer/vite.config.ts
+++ b/dicom-viewer/vite.config.ts
@@ -29,13 +29,11 @@ import { viteCommonjs } from "@originjs/vite-plugin-commonjs"
* }
* ```
*/
-export default defineConfig({
+export default defineConfig(({ command }) => ({
plugins: [
react(),
- // for dicom-parser
viteCommonjs(),
],
- // seems like only required in dev mode
optimizeDeps: {
exclude: ["@cornerstonejs/dicom-image-loader"],
include: ["dicom-parser"],
@@ -46,4 +44,5 @@ export default defineConfig({
external: ["@icr/polyseg-wasm"],
},
},
-})
+ base: command === "build" ? "/static/dv3d/" : "/",
+}));
\ No newline at end of file