changeset 226:4eefa34657f0

fix build
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 13 Jan 2021 13:17:03 +0100
parents 96d1774148e7
children aff61c449308
files Applications/CMakeLists.txt Applications/Dicomizer.cpp Framework/Inputs/DicomPyramidInstance.cpp Framework/Jpeg2000Reader.cpp Resources/CMake/Version.cmake ViewerPlugin/CMakeLists.txt
diffstat 6 files changed, 38 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/CMakeLists.txt	Wed Jan 13 10:33:37 2021 +0100
+++ b/Applications/CMakeLists.txt	Wed Jan 13 13:17:03 2021 +0100
@@ -104,11 +104,6 @@
   ${ORTHANC_WSI_DIR}/Framework/Outputs/TruncatedPyramidWriter.cpp
   ${ORTHANC_WSI_DIR}/Framework/Targets/FolderTarget.cpp
   ${ORTHANC_WSI_DIR}/Framework/Targets/OrthancTarget.cpp
-
-  # To access compatibility functions
-  # "OrthancPlugins::WriteFastJson()" and "OrthancPlugins::ReadJson()"
-  # if Orthanc framework <= 1.8.2
-  ${ORTHANC_WSI_DIR}/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp
   )
 
 EmbedResources(
--- a/Applications/Dicomizer.cpp	Wed Jan 13 10:33:37 2021 +0100
+++ b/Applications/Dicomizer.cpp	Wed Jan 13 13:17:03 2021 +0100
@@ -33,7 +33,6 @@
 #include "../Framework/MultiThreading/BagOfTasksProcessor.h"
 #include "../Framework/Outputs/DicomPyramidWriter.h"
 #include "../Framework/Outputs/TruncatedPyramidWriter.h"
-#include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h"
 
 #include <Compatibility.h>  // For std::unique_ptr
 #include <DicomParsing/FromDcmtkBridge.h>
@@ -84,6 +83,28 @@
 static const char* OPTION_VERSION = "version";
 
 
+#if ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 9, 0)
+
+bool ReadJsonWithoutComments(Json::Value& target,
+                             const std::string& source)
+{
+  return Orthanc::Toolbox::ReadJsonWithoutComments(target, source);
+}
+
+#else
+
+// Backward compatibility with Orthanc framework <= 1.8.2
+#include <json/reader.h>
+
+bool ReadJsonWithoutComments(Json::Value& target,
+                             const std::string& source)
+{
+  Json::Reader reader;
+  return reader.parse(source, target, false);
+}
+#endif
+
+
 static void TranscodePyramid(OrthancWSI::PyramidWriterBase& target,
                              OrthancWSI::ITiledPyramid& source,
                              const OrthancWSI::DicomizerParameters& parameters)
@@ -298,7 +319,7 @@
     std::string content;
     Orthanc::SystemToolbox::ReadFile(content, path);
 
-    if (!OrthancPlugins::ReadJsonWithoutComments(json, content))
+    if (!ReadJsonWithoutComments(json, content))
     {
       LOG(ERROR) << "Cannot parse the JSON file in: " << path;
       throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
@@ -472,7 +493,7 @@
     Orthanc::EmbeddedResources::GetFileResource(brightfield, Orthanc::EmbeddedResources::BRIGHTFIELD_OPTICAL_PATH);
 
     Json::Value json;
-    if (!OrthancPlugins::ReadJsonWithoutComments(json, brightfield))
+    if (!ReadJsonWithoutComments(json, brightfield))
     {
       throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
     }
--- a/Framework/Inputs/DicomPyramidInstance.cpp	Wed Jan 13 10:33:37 2021 +0100
+++ b/Framework/Inputs/DicomPyramidInstance.cpp	Wed Jan 13 13:17:03 2021 +0100
@@ -23,7 +23,6 @@
 #include "DicomPyramidInstance.h"
 
 #include "../DicomToolbox.h"
-#include "../../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h"
 #include "../../Resources/Orthanc/Stone/DicomDatasetReader.h"
 #include "../../Resources/Orthanc/Stone/FullOrthancDataset.h"
 
@@ -34,6 +33,10 @@
 
 #include <cassert>
 
+#if !ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 9, 0)
+#  include <json/writer.h>
+#endif
+
 #define SERIALIZED_METADATA  "4201"   // Was "4200" if versions <= 0.7 of this plugin
 
 
@@ -350,14 +353,19 @@
     content[PHOTOMETRIC_INTERPRETATION] = Orthanc::EnumerationToString(photometric_);
     content[IMAGE_TYPE] = imageType_;
 
-    OrthancPlugins::WriteFastJson(result, content);
+#if ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 9, 0)
+    Orthanc::Toolbox::WriteFastJson(result, content);
+#else
+    Json::FastWriter writer;
+    result = writer.write(content);
+#endif
   }
 
 
   void DicomPyramidInstance::Deserialize(const std::string& s)
   {
     Json::Value content;
-    OrthancPlugins::ReadJson(content, s);
+    OrthancStone::IOrthancConnection::ParseJson(content, s);
 
     if (content.type() != Json::objectValue ||
         !content.isMember(FRAMES) ||
--- a/Framework/Jpeg2000Reader.cpp	Wed Jan 13 10:33:37 2021 +0100
+++ b/Framework/Jpeg2000Reader.cpp	Wed Jan 13 13:17:03 2021 +0100
@@ -329,9 +329,8 @@
         const unsigned int width = target.GetWidth();
         const unsigned int height = target.GetHeight();
 
-        if (0 &&   // TODO
-            width == image_->comps[channel].w &&
-            height == image_->comps[channel].h)
+        if (static_cast<int>(width) == image_->comps[channel].w &&
+            static_cast<int>(height) == image_->comps[channel].h)
         {
           const int32_t* q = image_->comps[channel].data;
           assert(q != NULL);
--- a/Resources/CMake/Version.cmake	Wed Jan 13 10:33:37 2021 +0100
+++ b/Resources/CMake/Version.cmake	Wed Jan 13 13:17:03 2021 +0100
@@ -9,7 +9,6 @@
 endif()
 
 add_definitions(
-  -DHAS_ORTHANC_EXCEPTION=1
   -DORTHANC_WSI_VERSION="${ORTHANC_WSI_VERSION}"
   )
 
--- a/ViewerPlugin/CMakeLists.txt	Wed Jan 13 10:33:37 2021 +0100
+++ b/ViewerPlugin/CMakeLists.txt	Wed Jan 13 13:17:03 2021 +0100
@@ -77,6 +77,7 @@
 #####################################################################
 
 add_definitions(
+  -DHAS_ORTHANC_EXCEPTION=1
   -DORTHANC_ENABLE_LOGGING_PLUGIN=1
   -DORTHANC_FRAMEWORK_BUILDING_PLUGIN=1
   )