Closed ikhizarwork closed 2 weeks ago
@ivmartel ??? i am stuck , please guide me thru this .
dwv provides a drawLayer.deleteDraws()
that could be useful. In what context are you? Do you have access to the app?
dwv provides a
drawLayer.deleteDraws()
that could be useful. In what context are you? Do you have access to the app?
Thank you for your suggestion.
I am using the DWV-Jqmobile DICOM viewer to display multiple series and allow users to draw and save annotations. When the user switches between series, the annotations from the previous series are not being cleared, and they are incorrectly displayed on the new series.
Here is my current setup:
I have access to the dwv.App instance, referred to as myapp in my code. I am able to load and display DICOM series and handle user annotations. I need to clear/reset the annotations when switching from one series to another. You mentioned that drawLayer.deleteDraws() could be useful. Could you please guide me on how to correctly access the drawLayer within the context of the myapp instance to call deleteDraws()?
Here is a snippet of my current code where I attempt to clear the annotations before loading a new series:
function loadFolderContents(urls, seriesName) {
clearAnnotations();
myapp.reset();
myapp.init(options);
myapp.loadURLs(urls);
toolboxGui.setCurrentSeries(seriesName);
// Load the specific annotations for the series
const database = window.firebaseApp.database();
const annotationsPath = `${AnnotationPath}/Annotations`;
database.ref(annotationsPath).once('value')
.then(snapshot => {
const allAnnotations = snapshot.val();
const seriesAnnotations = allAnnotations && allAnnotations[seriesName];
if (seriesAnnotations && seriesAnnotations.AnnotationJson) {
myapp.addEventListener('loadend', function () {
// Application is fully loaded, now safe to call applyJsonState
myapp.applyJsonState(seriesAnnotations.AnnotationJson);
});
} else {
myapp.addEventListener('loadend', function () {
// No annotations found for the series
});
console.warn(`No annotations found for series: ${seriesName}`);
}
})
.catch(error => {
console.error('Error fetching series annotations:', error);
});
}
function clearAnnotations() {
const activeLayerGroup = myapp.getActiveLayerGroup();
if (activeLayerGroup && activeLayerGroup.drawLayer) {
activeLayerGroup.drawLayer.deleteDraws();
} else {
console.warn('No active draw layer found to clear annotations.');
}
}
@ivmartel please guide me thru this.
@ivmartel ??????
Your code seems correct, it should work if you have just one draw layer. Does it give errors?
@ivmartel there is no error , and it is not clearing up the annotations , i am still getting the annotations shown up whenever i am switching up the series .
Ah, it's the way you access the draw layer, it should be activeLayerGroup.getActiveDrawLayer()
is this how i am suppose to use this @ivmartel ?
myapp.activeLayerGroup.getActiveDrawLayer().deleteDraws();
If you start from myapp, you should call: myapp.getActiveLayerGroup().getActiveDrawLayer().deleteDraws()
.
deleteDraws
has an optional argument which is the undo/redo callback, so to be complete, you should do:
myapp.getActiveLayerGroup().getActiveDrawLayer().deleteDraws(myapp.addToUndoStack)
I hope my last comment helped. Closing for now, feel free to comment if you need.
i am viewing multiple series data of one single patient , since currently the DWV doesnt support multiple series at the moment , so i have created an dropdown option using which i can select multiple different series and view it one by one , and also provided an option to save the Annotations as per the series names that is getting viewed ,
the problem i am getting is while showing the Annotations , suppose i have saved Annotations for Series A , and for series B only , and if select Series C , then Annotations state of say Series A or Series B is also getting shown up for Series C, which should not happen , since i havent saved the annotations for that series .
i want to show the jsonState only for the series for which i have saved it , and reset or clear the jsonState for those series for whom i havent saved the annotation .
please help me thru this .