changeset 546:fb7f4a5bdfc0 ct-pet-dose-struct

Merged in dev (pull request #1) Merge from dev
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 02 Apr 2019 09:38:50 +0000
parents 7428c5dfa5df (current diff) e1ba16436d59 (diff)
children 0f43e479b49c
files
diffstat 6 files changed, 58 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Generic/NativeStoneApplicationRunner.cpp	Tue Mar 19 16:29:07 2019 +0100
+++ b/Applications/Generic/NativeStoneApplicationRunner.cpp	Tue Apr 02 09:38:50 2019 +0000
@@ -141,6 +141,13 @@
     if (parameters.count("verbose"))
     {
       Orthanc::Logging::EnableInfoLevel(true);
+      LOG(INFO) << "Verbose logs are enabled";
+    }
+
+    if (parameters.count("trace"))
+    {
+      Orthanc::Logging::EnableTraceLevel(true);
+      VLOG(1) << "Trace logs are enabled";
     }
 
     ParseCommandLineOptions(parameters);
--- a/Framework/Radiography/RadiographyScene.cpp	Tue Mar 19 16:29:07 2019 +0100
+++ b/Framework/Radiography/RadiographyScene.cpp	Tue Apr 02 09:38:50 2019 +0000
@@ -558,8 +558,6 @@
       throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
     }
 
-    LOG(INFO) << "Exporting DICOM";
-
     Extent2D extent = GetSceneExtent();
 
     int w = static_cast<int>(std::ceil(extent.GetWidth() / pixelSpacingX));
@@ -603,6 +601,9 @@
                                                     ImageInterpolation interpolation,
                                                     bool usePam)
   {
+    LOG(INFO) << "Exporting RadiographyScene to DICOM";
+    VLOG(1) << "Exporting RadiographyScene to: export to image";
+
     std::auto_ptr<Orthanc::Image> rendered(ExportToImage(pixelSpacingX, pixelSpacingY, interpolation)); // note: we don't invert the image in the pixels data because we'll set the PhotometricDisplayMode correctly in the DICOM tags
 
     std::string base64;
@@ -612,6 +613,7 @@
 
       if (usePam)
       {
+        VLOG(1) << "Exporting RadiographyScene: convert to PAM";
         Orthanc::PamWriter writer;
         writer.WriteToMemory(content, *rendered);
       }
@@ -621,6 +623,7 @@
         writer.WriteToMemory(content, *rendered);
       }
 
+      VLOG(1) << "Exporting RadiographyScene: encoding to base64";
       Orthanc::Toolbox::EncodeBase64(base64, content);
     }
 
@@ -667,6 +670,7 @@
       createDicomRequestContent["Parent"] = parentOrthancId;
     }
 
+    VLOG(1) << "Exporting RadiographyScene: create-dicom request is ready";
   }
 
 
--- a/Platforms/Wasm/wasm-application-runner.ts	Tue Mar 19 16:29:07 2019 +0100
+++ b/Platforms/Wasm/wasm-application-runner.ts	Tue Apr 02 09:38:50 2019 +0000
@@ -107,7 +107,7 @@
     // Prevent scrolling
     document.body.addEventListener('touchmove', function (event) {
       event.preventDefault();
-    }, { passive: false});
+    }, { passive: false}); // must not be passive if calling event.preventDefault, ie to cancel scroll or zoom of the whole interface
 
     _InitializeWasmApplication(orthancBaseUrl);
   });
--- a/Platforms/Wasm/wasm-viewport.ts	Tue Mar 19 16:29:07 2019 +0100
+++ b/Platforms/Wasm/wasm-viewport.ts	Tue Apr 02 09:38:50 2019 +0000
@@ -1,5 +1,4 @@
 import wasmApplicationRunner = require('./wasm-application-runner');
-//import stoneFrameworkLoader = require('./stone-framework-loader');
 import * as Logger from './logger'
 
 var isPendingRedraw = false;
@@ -31,13 +30,6 @@
  
 (<any>window).CreateWasmViewport = CreateWasmViewport;
 
-//  export declare type InitializationCallback = () => void;
-  
-//  export declare var StoneFrameworkModule : any;
-  
-  //const ASSETS_FOLDER : string = "assets/lib";
-  //const WASM_FILENAME : string = "orthanc-framework";
-
 export class WasmViewport {
 
     private static viewportsMapByCppHandle_ : Map<number, WasmViewport> = new Map<number, WasmViewport>(); // key = the C++ handle
@@ -235,7 +227,7 @@
         var y = event.pageY - this.offsetTop;
         that.ViewportMouseWheel(that.pimpl_, event.deltaY, x, y, event.ctrlKey);
         event.preventDefault();
-      });
+      }, {passive: false}); // must not be passive if calling event.preventDefault, ie to cancel scroll or zoom of the whole interface
 
       this.htmlCanvas_.addEventListener('touchstart', function(event: TouchEvent) {
         // don't propagate events to the whole body (this could zoom the entire page instead of zooming the viewport)
@@ -263,7 +255,7 @@
         }
 
         that.ViewportTouchStart(that.pimpl_, event.targetTouches.length, x0, y0, x1, y1, x2, y2);
-      });
+      }, {passive: false}); // must not be passive if calling event.preventDefault, ie to cancel scroll or zoom of the whole interface
     
       this.htmlCanvas_.addEventListener('touchend', function(event) {
         // don't propagate events to the whole body (this could zoom the entire page instead of zooming the viewport)
@@ -323,53 +315,7 @@
         that.ViewportTouchMove(that.pimpl_, event.targetTouches.length, x0, y0, x1, y1, x2, y2);
         return;
 
-        // if (!that.touchGestureInProgress_) {
-        //   // starting a new gesture
-        //   that.touchCount_ = event.targetTouches.length;
-        //   for (var t = 0; t < event.targetTouches.length; t++) {
-        //     that.touchGestureLastCoordinates_.push([event.targetTouches[t].pageX, event.targetTouches[t].pageY]);
-        //   }
-        //   that.touchGestureInProgress_ = true;
-        // } else {
-        //   // continuing a gesture
-        //   // TODO: we shall probably forward all touches to the C++ code and let the "interactors/trackers" handle them
-
-        //   if (that.touchCount_ == 1) { // consider it's a left mouse drag
-
-        //   }
-        // }
-
-        // TODO: we shall probably forward all touches to the C++ code and let the "interactors/trackers" handle them
-
-        if (that.touchTranslation_.length == 2) { // 
-          var t = that.GetTouchTranslation(event);
-          that.ViewportMouseMove(that.pimpl_, t[0], t[1]);
-        }
-        else if (that.touchZoom_.length == 3) {
-          var z0 = that.touchZoom_;
-          var z1 = that.GetTouchZoom(event);
-          that.ViewportMouseMove(that.pimpl_, z0[0], z0[1] - z0[2] + z1[2]);
-        }
-        else {
-          // Realize the gesture event
-          if (event.targetTouches.length == 1) {
-            // Exactly one finger inside the canvas => Setup a translation
-            that.touchTranslation_ = that.GetTouchTranslation(event);
-            that.ViewportMouseDown(that.pimpl_, 
-                                  0 /* left button */,
-                                  that.touchTranslation_[0],
-                                  that.touchTranslation_[1], 0);
-          } else if (event.targetTouches.length == 2) {
-            // Exactly 2 fingers inside the canvas => Setup a pinch/zoom
-            that.touchZoom_ = that.GetTouchZoom(event);
-            var z0 = that.touchZoom_;
-            that.ViewportMouseDown(that.pimpl_, 
-                                  2 /* right button */,
-                                  z0[0],
-                                  z0[1], 0);
-          }        
-        }
-      });
+      }, {passive: false}); // must not be passive if calling event.preventDefault, ie to cancel scroll or zoom of the whole interface
     }  
 
   public ResetTouch() {
@@ -380,10 +326,6 @@
 
     this.touchTranslation_ = false;
     this.touchZoom_ = false;
-
-    // this.touchGestureInProgress_ = false;
-    // this.touchCount_ = 0;
-    // this.touchGestureLastCoordinates_ = [];
   }
   
   public GetTouchTranslation(event) {
@@ -406,7 +348,5 @@
       d
     ];
   }
-    
+   
 }
-
-  
\ No newline at end of file
--- a/Resources/CodeGeneration/stonegentool.py	Tue Mar 19 16:29:07 2019 +0100
+++ b/Resources/CodeGeneration/stonegentool.py	Tue Apr 02 09:38:50 2019 +0000
@@ -82,6 +82,7 @@
   retVal = canonicalTypename
   retVal = retVal.replace("map", "std::map")
   retVal = retVal.replace("vector", "std::vector")
+  retVal = retVal.replace("set", "std::set")
   retVal = retVal.replace("string", "std::string")
   retVal = retVal.replace("int32", "int32_t")
   retVal = retVal.replace("float32", "float")
@@ -98,6 +99,7 @@
   retVal = canonicalTypename
   retVal = retVal.replace("map", "Map")
   retVal = retVal.replace("vector", "Array")
+  retVal = retVal.replace("set", "Set")
   retVal = retVal.replace("int32", "number")
   retVal = retVal.replace("float32", "number")
   retVal = retVal.replace("float64", "number")
--- a/Resources/CodeGeneration/template.in.h.j2	Tue Mar 19 16:29:07 2019 +0100
+++ b/Resources/CodeGeneration/template.in.h.j2	Tue Apr 02 09:38:50 2019 +0000
@@ -13,6 +13,7 @@
 #include <sstream>
 #include <assert.h>
 #include <memory>
+#include <set>
 #include <json/json.h>
 
 //#define STONEGEN_NO_CPP11 1
@@ -199,6 +200,43 @@
     return out;
   }
 
+  /** Throws in case of problem */
+  template<typename T>
+  void _StoneDeserializeValue(
+    std::set<T>& destValue, const Json::Value& jsonValue)
+  {
+    destValue.clear();
+    for (Json::Value::ArrayIndex i = 0; i != jsonValue.size(); i++)
+    {
+      T innerDestValue;
+      _StoneDeserializeValue(innerDestValue, jsonValue[i]);
+      destValue.insert(innerDestValue);
+    }
+  }
+
+  template<typename T>
+  Json::Value _StoneSerializeValue(const std::set<T>& value)
+  {
+    Json::Value result(Json::arrayValue);
+    for (typename std::set<T>::const_iterator it = value.begin(); it != value.end(); ++it)
+    {
+      result.append(_StoneSerializeValue(*it));
+    }
+    return result;
+  }
+
+  template<typename T>
+  std::ostream& StoneDumpValue(std::ostream& out, const std::set<T>& value, size_t indent)
+  {
+    out << MakeIndent(indent) << "[\n";
+    for (typename std::set<T>::const_iterator it = value.begin(); it != value.end(); ++it)
+    {
+      StoneDumpValue(out, *it, indent+2);
+    }
+    out << MakeIndent(indent) << "]\n";
+    return out;
+  }
+
   inline void StoneCheckSerializedValueTypeGeneric(const Json::Value& value)
   {
     if ((!value.isMember("type")) || (!value["type"].isString()))