changeset 1674:0621e523b670

number of frames in badge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 23 Nov 2020 17:05:24 +0100
parents dd50f8a1a2be
children 6fa05252b085
files Applications/StoneWebViewer/WebApplication/app.js Applications/StoneWebViewer/WebApplication/index.html Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp
diffstat 3 files changed, 56 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebApplication/app.js	Mon Nov 23 16:21:33 2020 +0100
+++ b/Applications/StoneWebViewer/WebApplication/app.js	Mon Nov 23 17:05:24 2020 +0100
@@ -50,7 +50,7 @@
       stone: stone,  // To access global object "stone" from "index.html"
       status: 'waiting',
       currentFrame: 0,
-      framesCount: 0,
+      numberOfFrames: 0,
       quality: '',
       cineControls: false,
       cineIncrement: 0,
@@ -125,7 +125,7 @@
     window.addEventListener('FrameUpdated', function(args) {
       if (args.detail.canvasId == that.canvasId) {
         that.currentFrame = (args.detail.currentFrame + 1);
-        that.framesCount = args.detail.framesCount;
+        that.numberOfFrames = args.detail.numberOfFrames;
         that.quality = args.detail.quality;
       }
     });
@@ -422,7 +422,7 @@
             var study = studies[indexStudies[studyInstanceUid]];
             study.series.push(i);
             series.push({
-              //'length' : 4,
+              'numberOfFrames' : 0,
               'complete' : false,
               'type' : stone.ThumbnailType.LOADING,
               'color': study.color,
@@ -581,10 +581,14 @@
         series.complete = stone.IsSeriesComplete(seriesInstanceUid);
         
         if (!oldComplete &&
-            series.complete &&
-            seriesInstanceUid in pendingSeriesPdf_) {
-          stone.FetchPdf(studyInstanceUid, seriesInstanceUid);
-          delete pendingSeriesPdf_[seriesInstanceUid];
+            series.complete)
+        {
+          series.numberOfFrames = stone.GetSeriesNumberOfFrames(seriesInstanceUid);
+          
+          if (seriesInstanceUid in pendingSeriesPdf_) {
+            stone.FetchPdf(studyInstanceUid, seriesInstanceUid);
+            delete pendingSeriesPdf_[seriesInstanceUid];
+          }
         }
 
         // https://fr.vuejs.org/2016/02/06/common-gotchas/#Why-isn%E2%80%99t-the-DOM-updating
--- a/Applications/StoneWebViewer/WebApplication/index.html	Mon Nov 23 16:21:33 2020 +0100
+++ b/Applications/StoneWebViewer/WebApplication/index.html	Mon Nov 23 17:05:24 2020 +0100
@@ -219,7 +219,7 @@
                                    />
                               
                               <div v-bind:class="'wvSerieslist__badge--' + study.color"
-                                   v-if="'length' in series[seriesIndex]">{{ series[seriesIndex].length }}</div>
+                                   v-if="series[seriesIndex].numberOfFrames != 0">{{ series[seriesIndex].numberOfFrames }}</div>
                             </div>
                           </div>
 
@@ -556,7 +556,7 @@
                     {{ series.tags['0020,0011'] }} | {{ series.tags['0008,103e'] }}
                   </div>
                   <div class="wv-overlay-timeline-wrapper wvPrintExclude">
-                    <div style="text-align:left; padding:5px" v-show="framesCount != 0">
+                    <div style="text-align:left; padding:5px" v-show="numberOfFrames != 0">
                       <div style="width: 12em; padding: 1em;" v-show="cineControls">
                         <label>
                           Frame rate
@@ -570,7 +570,7 @@
                       <button class="btn btn-primary btn-sm" @click="DecrementFrame()">
                         <i class="fa fa-chevron-circle-left"></i>
                       </button>
-                      &nbsp;&nbsp;{{ currentFrame }} / {{ framesCount }}&nbsp;&nbsp;
+                      &nbsp;&nbsp;{{ currentFrame }} / {{ numberOfFrames }}&nbsp;&nbsp;
                       <button class="btn btn-primary btn-sm" @click="IncrementFrame()">
                         <i class="fa fa-chevron-circle-right"></i>
                       </button>
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Mon Nov 23 16:21:33 2020 +0100
+++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Mon Nov 23 17:05:24 2020 +0100
@@ -462,6 +462,35 @@
     }
   }
 
+  size_t GetSeriesNumberOfFrames(const std::string& seriesInstanceUid) const
+  {
+    OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
+    
+    if (accessor.IsComplete())
+    {
+      size_t count = 0;
+      
+      for (size_t i = 0; i < accessor.GetInstancesCount(); i++)
+      {
+        uint32_t f;
+        if (accessor.GetInstance(i).ParseUnsignedInteger32(f, Orthanc::DICOM_TAG_NUMBER_OF_FRAMES))
+        {
+          count += f;
+        }
+        else
+        {
+          count++;
+        }
+      }
+
+      return count;
+    }
+    else
+    {
+      return 0;
+    }
+  }
+
   void AcquireObserver(IObserver* observer)
   {  
     observer_.reset(observer);
@@ -2360,7 +2389,7 @@
         customEvent.initCustomEvent("FrameUpdated", false, false,
                                     { "canvasId" : UTF8ToString($0),
                                         "currentFrame" : $1,
-                                        "framesCount" : $2,
+                                        "numberOfFrames" : $2,
                                         "quality" : $3 });
         window.dispatchEvent(customEvent);
       },
@@ -2933,4 +2962,16 @@
     EXTERN_CATCH_EXCEPTIONS;
     return 0;
   }
+
+
+  EMSCRIPTEN_KEEPALIVE
+  unsigned int GetSeriesNumberOfFrames(const char* seriesInstanceUid)
+  {
+    try
+    {
+      return GetResourcesLoader().GetSeriesNumberOfFrames(seriesInstanceUid);
+    }
+    EXTERN_CATCH_EXCEPTIONS;
+    return 0;
+  }    
 }