changeset 1388:240531afdd2d

Dead code removal + removed untested Dicomweb + SingleFrameViewer wasm fixes
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 28 Apr 2020 08:57:39 +0200
parents 4ebf246f3919
children 5c83be3a6be5
files Samples/Sdl/SdlHelpers.h Samples/WebAssembly/SingleFrameViewer/CMakeLists.txt Samples/WebAssembly/SingleFrameViewer/SingleFrameViewer.cpp Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApp.js Samples/WebAssembly/SingleFrameViewer/WasmWrapper.js Samples/WebAssembly/SingleFrameViewer/index.html
diffstat 6 files changed, 21 insertions(+), 186 deletions(-) [+]
line wrap: on
line diff
--- a/Samples/Sdl/SdlHelpers.h	Mon Apr 27 16:49:03 2020 +0200
+++ b/Samples/Sdl/SdlHelpers.h	Tue Apr 28 08:57:39 2020 +0200
@@ -93,44 +93,5 @@
     p.SetControlModifier(modifiers & KeyboardModifiers_Control);
     p.SetShiftModifier(modifiers & KeyboardModifiers_Shift);
   }
-
-  //inline void ParseCommonCommandLineArguments()
-  //{
-
-  //  po::options_description description("Usage:");
-
-  //  description.add_options()
-  //    ("trace", "Enable TRACE logging mode (default: false)")
-  //    ("info", "Enable INFO logging mode (default: false)")
-  //    ("orthanc", po::value<string>()->default_value("http://localhost:8042"), "Base URL of the Orthanc instance")
-
-  //  po::variables_map vm;
-  //  po::store(po::command_line_parser(argc, argv).options(description).run(), vm);
-  //  po::notify(vm);
-
-  //  if (vm.count("help"))
-  //  {
-
-  //  }
-
-  //  if (vm.count("compression"))
-  //  {
-  //    cout << "Compression level " << vm["compression"].as<int>() << endl;
-  //  }
-
-  //  return 0;
-
-  //}
-
-  //inline void DeclareOptionAndDefault(boost::program_options::options_description& options,
-  //                             const std::string& flag, const std::string& defaultValue,
-  //                             std::string help = "")
-  //{
-  //  description.add_options()
-  //    (flag, po::value<string>()->default_value(defaultValue), help);
-  //}
-
-  //inline void ProcessOptions
-
 }
 
--- a/Samples/WebAssembly/SingleFrameViewer/CMakeLists.txt	Mon Apr 27 16:49:03 2020 +0200
+++ b/Samples/WebAssembly/SingleFrameViewer/CMakeLists.txt	Tue Apr 28 08:57:39 2020 +0200
@@ -70,6 +70,5 @@
   ${CMAKE_SOURCE_DIR}/SingleFrameViewerApp.js
   ${CMAKE_SOURCE_DIR}/index.html
   ${CMAKE_CURRENT_BINARY_DIR}/SingleFrameViewerWasm.wasm
-  ${CMAKE_SOURCE_DIR}/WasmWrapper.js
   DESTINATION ${CMAKE_INSTALL_PREFIX}
   )
--- a/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewer.cpp	Mon Apr 27 16:49:03 2020 +0200
+++ b/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewer.cpp	Tue Apr 28 08:57:39 2020 +0200
@@ -44,37 +44,11 @@
 
 namespace OrthancStone
 {
-  class Observer : public IWebViewerLoadersObserver
-  {
-  public:
-    virtual void SignalSeriesUpdated(LoadedDicomResources& series)
-    {
-      LOG(INFO) << "=====================================";
-      LOG(INFO) << series.GetSize() << " series";
-
-      /*for (size_t i = 0; i < series.GetSize(); i++)
-        {
-        series.GetResource(i).Print(stdout);
-        printf("\n");
-        }*/
-    }
-    
-    virtual void SignalThumbnailLoaded(const std::string& studyInstanceUid,
-                                       const std::string& seriesInstanceUid,
-                                       SeriesThumbnailType type)
-    {
-      LOG(INFO) << "*** Thumbnail loaded: " << studyInstanceUid << " / "
-                << seriesInstanceUid << " (type " << type << ")";
-    }
-  };
 }
 
-
-
 static std::auto_ptr<OrthancStone::WebAssemblyLoadersContext>  context_;
 static boost::shared_ptr<OrthancStone::Application>  application_;
 
-
 extern "C"
 {
   int main(int argc, char const *argv[]) 
@@ -95,13 +69,12 @@
       context_->SetLocalOrthanc("..");
       context_->SetDicomCacheSize(128 * 1024 * 1024);  // 128MB
   
-      DISPATCH_JAVASCRIPT_EVENT("StoneInitialized");
+      DISPATCH_JAVASCRIPT_EVENT("WasmModuleInitialized");
     }
     EXTERN_CATCH_EXCEPTIONS;
 
     return 0;
   }
-
   
   EMSCRIPTEN_KEEPALIVE
   void InitializeViewport(const char* canvasId)
@@ -120,43 +93,9 @@
                                         "Only one single viewport is available for this application");
       }
 
-      {
-        std::auto_ptr<OrthancStone::Observer> observer(new OrthancStone::Observer);
-      
-#if 1
-        OrthancStone::DicomSource source1;
-        //source1.SetDicomWebSource("http://localhost:8042/dicom-web");  source1.SetDicomWebRendered(true);
-        source1.SetDicomWebThroughOrthancSource("self");  source1.SetDicomWebRendered(true);
-        //source1.SetDicomWebThroughOrthancSource("my-google");  source1.SetDicomWebRendered(false);
-        boost::shared_ptr<OrthancStone::WebViewerLoaders> app2(
-          OrthancStone::WebViewerLoaders::Create(*context_, source1, true, observer.release()));
-#else
-        OrthancStone::DicomSource source1;
-        source1.SetOrthancSource();
-        boost::shared_ptr<OrthancStone::WebViewerLoaders> app2(
-          OrthancStone::WebViewerLoaders::Create(*context_, source1, true, observer.release()));
-        //app2->AddOrthancStudy("27f7126f-4f66fb14-03f4081b-f9341db2-53925988");
-        //app2->AddOrthancSeries("1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0");
-#endif
-
-        // BRAINIX
-        //app2->AddDicomAllSeries();
-        //app2->AddDicomStudy("2.16.840.1.113669.632.20.1211.10000357775");
-        app2->AddDicomSeries("2.16.840.1.113669.632.20.1211.10000357775", "1.3.46.670589.11.0.0.11.4.2.0.8743.5.3800.2006120117110979000"); // Standard image: type 5
-
-        app2->AddDicomStudy("1.3.51.0.7.633920140505.6339234439.633987.633918098");  // "Video" type 4: video720p.dcm
-        app2->AddDicomStudy("1.2.276.0.7230010.3.1.2.2344313775.14992.1458058404.7528");  // "PDF" type 3: pdf.dcm  
-        app2->AddDicomSeries("1.2.276.0.7230010.3.1.2.296485376.1.1568899779.944131", "1.2.276.0.7230010.3.1.3.296485376.1.1568899781.944588"); // RTSTRUCT, "Unsupported" type 2: DICOM/WebViewer2/TFE/IMAGES/IM452
-
-      
-        //app2->AddDicomStudy("1.2.276.0.7230010.3.1.2.380371456.1.1544616291.954997");  // CSPO
-      }
-
       boost::shared_ptr<OrthancStone::WebGLViewport> viewport(OrthancStone::GetWebGLViewportsRegistry().Add(canvasId));
       application_ = OrthancStone::Application::Create(*context_, viewport);
 
-      // Paint the viewport to black
-      
       {
         OrthancStone::WebGLViewportsRegistry::Accessor accessor(
           OrthancStone::GetWebGLViewportsRegistry(), canvasId);
@@ -172,8 +111,8 @@
 
   
   EMSCRIPTEN_KEEPALIVE
-  void LoadOrthanc(const char* instance,
-                   int frame)
+  void LoadFromOrthanc(const char* instance,
+                       int frame)
   {
     try
     {
@@ -188,11 +127,11 @@
 
   
   EMSCRIPTEN_KEEPALIVE
-  void LoadDicomWeb(const char* server,
-                    const char* studyInstanceUid,
-                    const char* seriesInstanceUid,
-                    const char* sopInstanceUid,
-                    int frame)
+  void LoadFromDicomWeb(const char* server,
+                        const char* studyInstanceUid,
+                        const char* seriesInstanceUid,
+                        const char* sopInstanceUid,
+                        int frame)
   {
     try
     {
--- a/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApp.js	Mon Apr 27 16:49:03 2020 +0200
+++ b/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApp.js	Tue Apr 28 08:57:39 2020 +0200
@@ -9,35 +9,35 @@
 
 WasmModuleWrapper.prototype.Setup = function(Module) {
   this._InitializeViewport = Module.cwrap('InitializeViewport', null, [ 'string' ]);
-  this._LoadOrthanc = Module.cwrap('LoadOrthanc', null, [ 'string', 'int' ]);
-  this._LoadDicomWeb = Module.cwrap('LoadDicomWeb', null, [ 'string', 'string', 'string', 'string', 'int' ]);
+  this._LoadFromOrthanc = Module.cwrap('LoadFromOrthanc', null, [ 'string', 'int' ]);
+  this._LoadFromDicomWeb = Module.cwrap('LoadFromDicomWeb', null, [ 'string', 'string', 'string', 'string', 'int' ]);
 };
 
 WasmModuleWrapper.prototype.InitializeViewport = function(canvasId) {
   this._InitializeViewport(canvasId);
 };
 
-WasmModuleWrapper.prototype.LoadOrthanc = function(instance, frame) {
-  this._LoadOrthanc(instance, frame);
+WasmModuleWrapper.prototype.LoadFromOrthanc = function(instance, frame) {
+  this._LoadFromOrthanc(instance, frame);
 };
 
-WasmModuleWrapper.prototype.LoadDicomWeb = function(server, studyInstanceUid, seriesInstanceUid, sopInstanceUid, frame) {
-  this._LoadDicomWeb(server, studyInstanceUid, seriesInstanceUid, sopInstanceUid, frame);
+WasmModuleWrapper.prototype.LoadFromDicomWeb = function(server, studyInstanceUid, seriesInstanceUid, sopInstanceUid, frame) {
+  this._LoadFromDicomWeb(server, studyInstanceUid, seriesInstanceUid, sopInstanceUid, frame);
 };
 
-var moduleWrapper = new WasmModuleWrapper();
+var wasmModuleWrapper = new WasmModuleWrapper();
 
 $(document).ready(function() {
 
-  window.addEventListener('StoneInitialized', function() {
-    stone.Setup(Module);
-    console.warn('Native Stone properly intialized');
+  window.addEventListener('WasmModuleInitialized', function() {
+    wasmModuleWrapper.Setup(Module);
+    console.warn('Native C++ module initialized');
 
-    stone.InitializeViewport('viewport');
+    wasmModuleWrapper.InitializeViewport('viewport');
   });
 
   window.addEventListener('StoneException', function() {
-    alert('Exception caught in Stone');
+    alert('Exception caught in C++ code');
   });    
 
   var scriptSource;
@@ -75,15 +75,6 @@
 
 
 $('#orthancLoad').click(function() {
-  stone.LoadOrthanc($('#orthancInstance').val(),
+  wasmModuleWrapper.LoadFromOrthanc($('#orthancInstance').val(),
                     $('#orthancFrame').val());
 });
-
-
-$('#dicomWebLoad').click(function() {
-  stone.LoadDicomWeb($('#dicomWebServer').val(),
-                     $('#dicomWebStudy').val(),
-                     $('#dicomWebSeries').val(),
-                     $('#dicomWebInstance').val(),
-                     $('#dicomWebFrame').val());
-});
--- a/Samples/WebAssembly/SingleFrameViewer/WasmWrapper.js	Mon Apr 27 16:49:03 2020 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-
-const Stone = function() {
-  this._InitializeViewport = undefined;
-  this._LoadOrthanc = undefined;
-  this._LoadDicomWeb = undefined;
-};
-
-Stone.prototype.Setup = function(Module) {
-  this._InitializeViewport = Module.cwrap('InitializeViewport', null, [ 'string' ]);
-  this._LoadOrthanc = Module.cwrap('LoadOrthanc', null, [ 'string', 'int' ]);
-  this._LoadDicomWeb = Module.cwrap('LoadDicomWeb', null, [ 'string', 'string', 'string', 'string', 'int' ]);
-};
-
-Stone.prototype.InitializeViewport = function(canvasId) {
-  this._InitializeViewport(canvasId);
-};
-
-Stone.prototype.LoadOrthanc = function(instance, frame) {
-  this._LoadOrthanc(instance, frame);
-};
-
-Stone.prototype.LoadDicomWeb = function(server, studyInstanceUid, seriesInstanceUid, sopInstanceUid, frame) {
-  this._LoadDicomWeb(server, studyInstanceUid, seriesInstanceUid, sopInstanceUid, frame);
-};
-
-var stone = new Stone();
-
--- a/Samples/WebAssembly/SingleFrameViewer/index.html	Mon Apr 27 16:49:03 2020 +0200
+++ b/Samples/WebAssembly/SingleFrameViewer/index.html	Tue Apr 28 08:57:39 2020 +0200
@@ -27,10 +27,6 @@
     <p>
       Orthanc instance: <input type="text" id="orthancInstance" size="80"
                                value="5eb2dd5f-3fca21a8-fa7565fd-63e112ae-344830a4">
-      <!-- Orthanc instance: <input type="text" id="orthancInstance" size="80"
-                               value="61f3143e-96f34791-ad6bbb8d-62559e75-45943e1b"> -->
-      <!-- Orthanc instance: <input type="text" id="orthancInstance" size="80"
-                               value="8dddbd75-f4095768-6e66f851-22305751-18782bdd"> -->
     </p>
     <p>
       Frame number: <input type="text" id="orthancFrame" value="0">
@@ -39,33 +35,9 @@
       <button id="orthancLoad">Load</button>
     </p>
 
-    <h1>Load from DICOMweb</h1>
-    <p>
-      Server name in Orthanc: <input type="text" id="dicomWebServer" value="self">
-    </p>
-    <p>
-      Study instance UID: <input type="text" id="dicomWebStudy" size="80"
-                                 value="1.2.840.113543.6.6.4.7.64067529866380271256212683512383713111129">
-    </p>
-    <p>
-      Series instance UID: <input type="text" id="dicomWebSeries" size="80"
-                                  value="1.2.840.113543.6.6.4.7.63556916880112768082712975118701689357177">
-    </p>
-    <p>
-      SOP instance UID: <input type="text" id="dicomWebInstance" size="80"
-                               value="1.2.840.113543.6.6.4.7.64234348190163144631511103849051737563212">
-    </p>
-    <p>
-      Frame number: <input type="text" id="dicomWebFrame" value="0">
-    </p>
-    <p>
-      <button id="dicomWebLoad">Load</button>
-    </p>
-
     <script src="https://code.jquery.com/jquery-3.4.1.js"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.0/axios.js"></script>
     
-    <script src="WasmWrapper.js"></script>
     <script src="SingleFrameViewerApp.js"></script>
   </body>
 </html>