-
Notifications
You must be signed in to change notification settings - Fork 588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switching between multiple images #1712
Comments
I'm not sure if it's helpful but I thought I would provide some additional information. loadImageObject = (data) => {
// Get new data id
const dataId = this.#dataController.getNextDataId();
this.#loadController.loadImageObject(data, dataId);
}; However, if I only load ONE image (instead of three) then it returns Another question: when submitting three images in one action to be loaded and with only one |
Hi, thanks for trying dwv! |
Hi @stylekilla, did you make some progress with your issue? |
Hi @ivmartel, I did actually make some progress in the last 24 hours! It's been a whirlwind two months of doing everything except this, so your timing to ask for an update is impeccable. Thank you for your example code and the clarification re the I ended up handling the viewer with the following code. Grabbing the DOM element and setting the inner html to empty was the only way I could get it to work. import React, { useEffect, useRef } from 'react';
import * as dwv from 'dwv';
export default function DwvComponent(props) {
// Ref to store the dwv.App instance
const appRef = useRef(null);
const containerRef = useRef(null);
useEffect(() => {
// Initialize dwv.App only once
if (!appRef.current) {
const app = new dwv.App();
const options = new dwv.AppOptions();
const viewConfig = new dwv.ViewConfig("layerGroup0");
viewConfig.colourMap = "plain";
viewConfig.opacity = 1;
options.viewOnFirstLoadItem = true;
options.dataViewConfigs = {'*': [viewConfig]};
app.init(options);
appRef.current = app;
}
const app = appRef.current;
// Cleanup previous content before loading new image
const layerGroupElement = document.getElementById("layerGroup0");
if (layerGroupElement) {
layerGroupElement.innerHTML = '';
}
// Load image object when currentImageIndex changes
if (props.imageObjects.length > 0) {
const currentImage = props.imageObjects[props.currentImageIndex];
if (currentImage) {
app.loadImageObject([currentImage]);
}
}
return () => {
// Clean up the dwv.App instance if needed
};
}, [props.currentImageIndex, props.imageObjects]);
return (
<div id="dwv" ref={containerRef}>
<div id="layerGroup0" className="layerGroup" style={{ width: '100%', height: '80vh' }}></div>
</div>
);
} And the const imageObject = {
name: modality,
filename: location.state.name,
data: buffer,
}; I'm yet to do anything more complicated with the images (I want to add Window/Level sliders), but hopefully that is more straight forward now that I have something basic working. Thanks again for your help. |
Hi ivmartel,
Nice work on creating and maintaining DWV.
I've been trying to get dwv (through npm install, v0.33) to work as a simple dicom image viewer in react (v18), but I'm having some trouble and was hoping to get some help.
I have read all of your documentation, the examples, and explored the provided dwv-react git repo.
Admittedly, I have found the documentation somewhat difficult to follow (both javascript and react are fairly new to me).
I have three independent dicom images that I want to view one at a time, changing the image .
I have generated three buttons that each pass their ID to the DWV component as a prop (see below).
The images render, but instead of overwriting what is in the layerGroup it creates a new layer within the group and I end up with three div's each with an id of
layerGroup0-layer0
(see below).Is there something basic I have missed about how DWV works?
I also can't workout why the size of each image double the size of the previous.
Any help is appreciated,
Thank you.
Updating
props.currentImageIndex
three times gives:The text was updated successfully, but these errors were encountered: