changeset 2408:98305a65df7c refactoring

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 15 Nov 2026 13:56:43 +0100
parents 2348952105b2
children 50384488da51
files Applications/Samples/WebAssembly/CMakeLists.txt Applications/Samples/WebAssembly/RtViewer/RtViewerWasmApp.js Applications/Samples/WebAssembly/RtViewer/RtViewerWasmWrapper.js Applications/Samples/WebAssembly/RtViewer/app.js Applications/Samples/WebAssembly/RtViewer/index.html Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewer.cpp Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApp.js Applications/Samples/WebAssembly/SingleFrameViewer/app.js Applications/Samples/WebAssembly/SingleFrameViewer/index.html
diffstat 9 files changed, 209 insertions(+), 257 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Samples/WebAssembly/CMakeLists.txt	Sun Nov 15 13:50:32 2026 +0100
+++ b/Applications/Samples/WebAssembly/CMakeLists.txt	Sun Nov 15 13:56:43 2026 +0100
@@ -135,7 +135,7 @@
 # ---------------------------------------------------------------
 install(
   FILES
-  ${CMAKE_SOURCE_DIR}/RtViewer/RtViewerWasmApp.js
+  ${CMAKE_SOURCE_DIR}/RtViewer/app.js
   ${CMAKE_SOURCE_DIR}/RtViewer/index.html
   ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.wasm
   DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/RtViewer/
@@ -181,7 +181,7 @@
 # ---------------------------------------------------------------
 install(
   FILES
-  ${CMAKE_SOURCE_DIR}/SingleFrameViewer/SingleFrameViewerApp.js
+  ${CMAKE_SOURCE_DIR}/SingleFrameViewer/app.js
   ${CMAKE_SOURCE_DIR}/SingleFrameViewer/index.html
   ${CMAKE_CURRENT_BINARY_DIR}/SingleFrameViewerWasm.wasm
   DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/SingleFrameViewer/
--- a/Applications/Samples/WebAssembly/RtViewer/RtViewerWasmApp.js	Sun Nov 15 13:50:32 2026 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2023 Osimis S.A., Belgium
- * Copyright (C) 2021-2026 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-
-// This object wraps the functions exposed by the wasm module
-
-const WasmModuleWrapper = function() {
-  this._InitializeViewport = undefined;
-};
-
-WasmModuleWrapper.prototype.Setup = function(Module) {
-  this._SetArgument = Module.cwrap('SetArgument', null, [ 'string', 'string' ]);
-  this._Initialize = Module.cwrap('Initialize', null, [ 'string' ]);
-};
-
-WasmModuleWrapper.prototype.SetArgument = function(key, value) {
-  this._SetArgument(key, value);
-};
-
-WasmModuleWrapper.prototype.Initialize = function(canvasId) {
-  this._Initialize(canvasId);
-};
-
-var wasmModuleWrapper = new WasmModuleWrapper();
-
-$(document).ready(function() {
-
-  window.addEventListener('WasmModuleInitialized', function() {
-
-    // bind the C++ global functions
-    wasmModuleWrapper.Setup(Module);
-
-    console.warn('Native C++ module initialized');
-
-    // Loop over the GET arguments
-    var parameters = window.location.search.substr(1);
-    if (parameters != null && parameters != '') {
-      var tokens = parameters.split('&');
-      for (var i = 0; i < tokens.length; i++) {
-        var arg = tokens[i].split('=');
-        if (arg.length == 2) {
-          // Send each GET argument to WebAssembly
-          wasmModuleWrapper.SetArgument(arg[0], decodeURIComponent(arg[1]));
-        }
-      }
-    }
-    wasmModuleWrapper.Initialize();
-  });
-
-  window.addEventListener('StoneException', function() {
-    alert('Exception caught in C++ code');
-  });    
-
-  var scriptSource;
-
-  if ('WebAssembly' in window) {
-    console.warn('Loading WebAssembly');
-    scriptSource = 'RtViewerWasm.js';
-  } else {
-    console.error('Your browser does not support WebAssembly!');
-  }
-
-  // Option 1: Loading script using plain HTML
-  
-  /*
-    var script = document.createElement('script');
-    script.src = scriptSource;
-    script.type = 'text/javascript';
-    document.body.appendChild(script);
-  */
-
-  // Option 2: Loading script using AJAX (gives the opportunity to
-  // report explicit errors)
-  
-  axios.get(scriptSource)
-    .then(function (response) {
-      var script = document.createElement('script');
-      script.innerHTML = response.data;
-      script.type = 'text/javascript';
-      document.body.appendChild(script);
-    })
-    .catch(function (error) {
-      alert('Cannot load the WebAssembly framework');
-    });
-});
-
-// http://localhost:9979/stone-rtviewer/index.html?loglevel=trace&ctseries=a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa&rtdose=830a69ff-8e4b5ee3-b7f966c8-bccc20fb-d322dceb&rtstruct=54460695-ba3885ee-ddf61ac0-f028e31d-a6e474d9
-
--- a/Applications/Samples/WebAssembly/RtViewer/RtViewerWasmWrapper.js	Sun Nov 15 13:50:32 2026 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2023 Osimis S.A., Belgium
- * Copyright (C) 2021-2026 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-
-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();
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Samples/WebAssembly/RtViewer/app.js	Sun Nov 15 13:56:43 2026 +0100
@@ -0,0 +1,106 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2023 Osimis S.A., Belgium
+ * Copyright (C) 2021-2026 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+
+// This object wraps the functions exposed by the wasm module
+
+const WasmModuleWrapper = function() {
+  this._InitializeViewport = undefined;
+};
+
+WasmModuleWrapper.prototype.Setup = function(Module) {
+  this._SetArgument = Module.cwrap('SetArgument', null, [ 'string', 'string' ]);
+  this._Initialize = Module.cwrap('Initialize', null, [ 'string' ]);
+};
+
+WasmModuleWrapper.prototype.SetArgument = function(key, value) {
+  this._SetArgument(key, value);
+};
+
+WasmModuleWrapper.prototype.Initialize = function(canvasId) {
+  this._Initialize(canvasId);
+};
+
+var wasmModuleWrapper = new WasmModuleWrapper();
+
+$(document).ready(function() {
+
+  window.addEventListener('WasmModuleInitialized', function() {
+
+    // bind the C++ global functions
+    wasmModuleWrapper.Setup(Module);
+
+    console.warn('Native C++ module initialized');
+
+    // Loop over the GET arguments
+    var parameters = window.location.search.substr(1);
+    if (parameters != null && parameters != '') {
+      var tokens = parameters.split('&');
+      for (var i = 0; i < tokens.length; i++) {
+        var arg = tokens[i].split('=');
+        if (arg.length == 2) {
+          // Send each GET argument to WebAssembly
+          wasmModuleWrapper.SetArgument(arg[0], decodeURIComponent(arg[1]));
+        }
+      }
+    }
+    wasmModuleWrapper.Initialize();
+  });
+
+  window.addEventListener('StoneException', function() {
+    alert('Exception caught in C++ code');
+  });    
+
+  var scriptSource;
+
+  if ('WebAssembly' in window) {
+    console.warn('Loading WebAssembly');
+    scriptSource = 'RtViewerWasm.js';
+  } else {
+    console.error('Your browser does not support WebAssembly!');
+  }
+
+  // Option 1: Loading script using plain HTML
+  
+  /*
+    var script = document.createElement('script');
+    script.src = scriptSource;
+    script.type = 'text/javascript';
+    document.body.appendChild(script);
+  */
+
+  // Option 2: Loading script using AJAX (gives the opportunity to
+  // report explicit errors)
+  
+  axios.get(scriptSource)
+    .then(function (response) {
+      var script = document.createElement('script');
+      script.innerHTML = response.data;
+      script.type = 'text/javascript';
+      document.body.appendChild(script);
+    })
+    .catch(function (error) {
+      alert('Cannot load the WebAssembly framework');
+    });
+});
+
+// http://localhost:9979/stone-rtviewer/index.html?loglevel=trace&ctseries=a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa&rtdose=830a69ff-8e4b5ee3-b7f966c8-bccc20fb-d322dceb&rtstruct=54460695-ba3885ee-ddf61ac0-f028e31d-a6e474d9
+
--- a/Applications/Samples/WebAssembly/RtViewer/index.html	Sun Nov 15 13:50:32 2026 +0100
+++ b/Applications/Samples/WebAssembly/RtViewer/index.html	Sun Nov 15 13:56:43 2026 +0100
@@ -59,6 +59,6 @@
     <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="RtViewerWasmApp.js"></script>
+    <script src="app.js"></script>
   </body>
 </html>
--- a/Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewer.cpp	Sun Nov 15 13:50:32 2026 +0100
+++ b/Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewer.cpp	Sun Nov 15 13:56:43 2026 +0100
@@ -205,8 +205,8 @@
       configuration.SetDicomCacheSize(128 * 1024 * 1024);  // 128MB
 
       boost::shared_ptr<OrthancStone::ISingleViewportApplicationCore> core;
-      core.reset(new OrthancStone::SimpleViewerCore);
-      //core.reset(new OrthancStone::VolumeViewerCore);
+      //core.reset(new OrthancStone::SimpleViewerCore);
+      core.reset(new OrthancStone::VolumeViewerCore);
       application_.reset(new OrthancStone::SingleViewportWebAssemblyApplication(configuration, core));
 
 #if 0
@@ -237,9 +237,9 @@
   {
     try
     {
-      //dynamic_cast<OrthancStone::VolumeViewerCore&>(*application_->GetCore()).LoadSeriesFromOrthanc(OrthancStone::VolumeProjection_Coronal, "a7e40137-e4b37f56-14ce875b-9a81702d-eac823bf");
+      dynamic_cast<OrthancStone::VolumeViewerCore&>(*application_->GetCore()).LoadSeriesFromOrthanc(OrthancStone::VolumeProjection_Coronal, "a7e40137-e4b37f56-14ce875b-9a81702d-eac823bf");
 
-      dynamic_cast<OrthancStone::SimpleViewerCore&>(*application_->GetCore()).LoadFrameFromOrthanc(instance, frame);
+      //dynamic_cast<OrthancStone::SimpleViewerCore&>(*application_->GetCore()).LoadFrameFromOrthanc(instance, frame);
     }
     EXTERN_CATCH_EXCEPTIONS;
   }
--- a/Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApp.js	Sun Nov 15 13:50:32 2026 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2023 Osimis S.A., Belgium
- * Copyright (C) 2021-2026 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-
-// This object wraps the functions exposed by the wasm module
-
-const WasmModuleWrapper = function() {
-  this._InitializeViewport = undefined;
-  this._LoadFromOrthanc = undefined;
-};
-
-WasmModuleWrapper.prototype.Setup = function(Module) {
-  this._InitializeViewport = Module.cwrap('InitializeViewport', null, [ 'string' ]);
-  this._LoadFromOrthanc = Module.cwrap('LoadFromOrthanc', null, [ 'string', 'int' ]);
-};
-
-WasmModuleWrapper.prototype.InitializeViewport = function(canvasId) {
-  this._InitializeViewport(canvasId);
-};
-
-WasmModuleWrapper.prototype.LoadFromOrthanc = function(instance, frame) {
-  this._LoadFromOrthanc(instance, frame);
-};
-
-var wasmModuleWrapper = new WasmModuleWrapper();
-
-$(document).ready(function() {
-
-  window.addEventListener('WasmModuleInitialized', function() {
-    wasmModuleWrapper.Setup(Module);
-    console.warn('Native C++ module initialized');
-
-    wasmModuleWrapper.InitializeViewport('viewport');
-  });
-
-  window.addEventListener('StoneException', function() {
-    alert('Exception caught in C++ code');
-  });    
-
-  var scriptSource;
-
-  if ('WebAssembly' in window) {
-    console.warn('Loading WebAssembly');
-    scriptSource = 'SingleFrameViewerWasm.js';
-  } else {
-    console.error('Your browser does not support WebAssembly!');
-  }
-
-  // Option 1: Loading script using plain HTML
-  
-  /*
-    var script = document.createElement('script');
-    script.src = scriptSource;
-    script.type = 'text/javascript';
-    document.body.appendChild(script);
-  */
-
-  // Option 2: Loading script using AJAX (gives the opportunity to
-  // report explicit errors)
-  
-  axios.get(scriptSource)
-    .then(function (response) {
-      var script = document.createElement('script');
-      script.innerHTML = response.data;
-      script.type = 'text/javascript';
-      document.body.appendChild(script);
-    })
-    .catch(function (error) {
-      alert('Cannot load the WebAssembly framework');
-    });
-});
-
-
-$('#orthancLoad').click(function() {
-  wasmModuleWrapper.LoadFromOrthanc($('#orthancInstance').val(),
-                    $('#orthancFrame').val());
-});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Samples/WebAssembly/SingleFrameViewer/app.js	Sun Nov 15 13:56:43 2026 +0100
@@ -0,0 +1,95 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2023 Osimis S.A., Belgium
+ * Copyright (C) 2021-2026 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+
+// This object wraps the functions exposed by the wasm module
+
+const WasmModuleWrapper = function() {
+  this._InitializeViewport = undefined;
+  this._LoadFromOrthanc = undefined;
+};
+
+WasmModuleWrapper.prototype.Setup = function(Module) {
+  this._InitializeViewport = Module.cwrap('InitializeViewport', null, [ 'string' ]);
+  this._LoadFromOrthanc = Module.cwrap('LoadFromOrthanc', null, [ 'string', 'int' ]);
+};
+
+WasmModuleWrapper.prototype.InitializeViewport = function(canvasId) {
+  this._InitializeViewport(canvasId);
+};
+
+WasmModuleWrapper.prototype.LoadFromOrthanc = function(instance, frame) {
+  this._LoadFromOrthanc(instance, frame);
+};
+
+var wasmModuleWrapper = new WasmModuleWrapper();
+
+$(document).ready(function() {
+
+  window.addEventListener('WasmModuleInitialized', function() {
+    wasmModuleWrapper.Setup(Module);
+    console.warn('Native C++ module initialized');
+
+    wasmModuleWrapper.InitializeViewport('viewport');
+  });
+
+  window.addEventListener('StoneException', function() {
+    alert('Exception caught in C++ code');
+  });    
+
+  var scriptSource;
+
+  if ('WebAssembly' in window) {
+    console.warn('Loading WebAssembly');
+    scriptSource = 'SingleFrameViewerWasm.js';
+  } else {
+    console.error('Your browser does not support WebAssembly!');
+  }
+
+  // Option 1: Loading script using plain HTML
+  
+  /*
+    var script = document.createElement('script');
+    script.src = scriptSource;
+    script.type = 'text/javascript';
+    document.body.appendChild(script);
+  */
+
+  // Option 2: Loading script using AJAX (gives the opportunity to
+  // report explicit errors)
+  
+  axios.get(scriptSource)
+    .then(function (response) {
+      var script = document.createElement('script');
+      script.innerHTML = response.data;
+      script.type = 'text/javascript';
+      document.body.appendChild(script);
+    })
+    .catch(function (error) {
+      alert('Cannot load the WebAssembly framework');
+    });
+});
+
+
+$('#orthancLoad').click(function() {
+  wasmModuleWrapper.LoadFromOrthanc($('#orthancInstance').val(),
+                    $('#orthancFrame').val());
+});
--- a/Applications/Samples/WebAssembly/SingleFrameViewer/index.html	Sun Nov 15 13:50:32 2026 +0100
+++ b/Applications/Samples/WebAssembly/SingleFrameViewer/index.html	Sun Nov 15 13:56:43 2026 +0100
@@ -38,6 +38,6 @@
     <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="SingleFrameViewerApp.js"></script>
+    <script src="app.js"></script>
   </body>
 </html>