ivmartel / dwv-jqmobile

Medical image viewer using DWV (DICOM Web Viewer) and jQuery Mobile.
https://ivmartel.github.io/dwv-jqmobile/
GNU General Public License v3.0
31 stars 26 forks source link

how to select and edit annotations after db saving #104

Closed shameerasl closed 6 months ago

shameerasl commented 2 years ago

i was able to draw and save annoattions in the database. but i cannot select and edit the drawings after fetched from database. even i cant able to select the draw. how this problem can be solved? Thanks in advance

ikhizarwork commented 7 months ago

hi @shameerasl , can you please help me with annotations saving in the database and later on retrieving it ? like how you implemented this ?

ivmartel commented 7 months ago

You should be able to load a state file via a app.loadURLs.

ikhizarwork commented 7 months ago

got the following error when trying to load the state from the db :-

Error fetching annotations: TypeError: Cannot read properties of undefined (reading 'split')
    at on.loadURLs (dwv.min.js:1:378291)
    at Vn.loadURLs (dwv.min.js:1:450130)
    at applauncher.js:254:15

here is my code , please let me know if i am doing something wrong over here :-

dbRef.once('value')
.then(function (snapshot) {
  const annotations = snapshot.val();
  if (annotations) {
    const drawings = JSON.parse(annotations);
    myapp.loadURLs(drawings);
  }
})
.catch(function (error) {
  console.error('Error fetching annotations:', error);
});
ivmartel commented 7 months ago

app.loadURLs takes the url of a state file. If you want to process the request as you do in your example, you can pass the JSON string directly to app.applyJsonState(annotations).

ikhizarwork commented 7 months ago

i was getting the following error :-

Error fetching annotations: TypeError: Cannot read properties of undefined (reading 'getActiveViewLayer')
    at At.apply (dwv.min.js:1:347437)
    at Vn.applyJsonState (dwv.min.js:1:454413)
    at applauncher.js:254:15

but i applied a timer to delay the loading of the annotations , and it has solved my problem :)

thanks alot for your help :)

ivmartel commented 6 months ago

Closing for now, feel free to comment if you need.