changeset 2380:96b3ec054b69

reorganization in macros
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 29 Aug 2017 16:49:44 +0200
parents 4900688827a8
children b8969010b534
files CMakeLists.txt Core/DicomFormat/DicomMap.cpp Core/DicomFormat/DicomMap.h Core/HttpServer/MongooseServer.h Core/SQLite/OrthancSQLiteException.h OrthancServer/DicomProtocol/DicomServer.cpp OrthancServer/DicomProtocol/DicomServer.h OrthancServer/DicomProtocol/DicomUserConnection.h OrthancServer/FromDcmtkBridge.h OrthancServer/Internals/DicomImageDecoder.cpp OrthancServer/Internals/DicomImageDecoder.h OrthancServer/Internals/StoreScp.cpp OrthancServer/OrthancInitialization.cpp OrthancServer/OrthancInitialization.h OrthancServer/ParsedDicomFile.cpp OrthancServer/ParsedDicomFile.h OrthancServer/ServerContext.cpp OrthancServer/ServerToolbox.cpp OrthancServer/ServerToolbox.h OrthancServer/ToDcmtkBridge.h Resources/CMake/DcmtkConfiguration.cmake
diffstat 21 files changed, 217 insertions(+), 128 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Mon Aug 28 18:07:03 2017 +0200
+++ b/CMakeLists.txt	Tue Aug 29 16:49:44 2017 +0200
@@ -26,8 +26,8 @@
 SET(DCMTK_DICTIONARY_DIR "" CACHE PATH "Directory containing the DCMTK dictionaries \"dicom.dic\" and \"private.dic\" (only when using system version of DCMTK)") 
 SET(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages")
 SET(UNIT_TESTS_WITH_HTTP_CONNEXIONS ON CACHE BOOL "Allow unit tests to make HTTP requests")
-SET(ENABLE_JPEG ON CACHE BOOL "Enable JPEG decompression")
-SET(ENABLE_JPEG_LOSSLESS ON CACHE BOOL "Enable JPEG-LS (Lossless) decompression")
+SET(ENABLE_DCMTK_JPEG ON CACHE BOOL "Enable JPEG decompression in DCMTK")
+SET(ENABLE_DCMTK_JPEG_LOSSLESS ON CACHE BOOL "Enable JPEG-LS (Lossless) decompression in DCMTK")
 SET(ENABLE_PLUGINS ON CACHE BOOL "Enable plugins")
 SET(BUILD_SERVE_FOLDERS ON CACHE BOOL "Whether to build the ServeFolders plugin")
 SET(BUILD_MODALITY_WORKLISTS ON CACHE BOOL "Whether to build the sample plugin to serve modality worklists")
@@ -74,8 +74,8 @@
 
 # These options must be set to "ON" if compiling Orthanc, but might be
 # set to "OFF" in some plugins if their support is not required
-set(ENABLE_DCMTK_NETWORK ON)  # Enable support for DICOM networking in DCMTK
-set(ENABLE_LOCALE ON)         # Enable support for locales (notably in Boost)
+set(ENABLE_DCMTK_NETWORKING ON)  # Enable support for DICOM networking in DCMTK
+set(ENABLE_LOCALE ON)            # Enable support for locales (notably in Boost)
 
 # Some basic inclusions
 include(CheckIncludeFiles)
@@ -346,17 +346,17 @@
 endif()
 
 
-if (ENABLE_JPEG)
-  add_definitions(-DORTHANC_ENABLE_JPEG=1)
+if (ENABLE_DCMTK_JPEG)
+  add_definitions(-DORTHANC_ENABLE_DCMTK_JPEG=1)
 else()
-  add_definitions(-DORTHANC_ENABLE_JPEG=0)
+  add_definitions(-DORTHANC_ENABLE_DCMTK_JPEG=0)
 endif()
 
 
-if (ENABLE_JPEG_LOSSLESS)
-  add_definitions(-DORTHANC_ENABLE_JPEG_LOSSLESS=1)
+if (ENABLE_DCMTK_JPEG_LOSSLESS)
+  add_definitions(-DORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS=1)
 else()
-  add_definitions(-DORTHANC_ENABLE_JPEG_LOSSLESS=0)
+  add_definitions(-DORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS=0)
 endif()
 
 
@@ -448,9 +448,13 @@
   -DORTHANC_ENABLE_BASE64=1
   -DORTHANC_ENABLE_LOGGING=1
   -DORTHANC_ENABLE_LOGGING_PLUGIN=0
+  -DORTHANC_ENABLE_DCMTK=1
+  -DORTHANC_ENABLE_DCMTK_NETWORKING=1
+  -DORTHANC_ENABLE_JPEG=1
   -DORTHANC_ENABLE_LUA=1
   -DORTHANC_ENABLE_MD5=1
   -DORTHANC_ENABLE_PNG=1
+  -DORTHANC_ENABLE_SQLITE=1
   -DORTHANC_HAS_EMBEDDED_RESOURCES=1
   -DORTHANC_MAXIMUM_TAG_LENGTH=256
   -DORTHANC_SANDBOXED=0
--- a/Core/DicomFormat/DicomMap.cpp	Mon Aug 28 18:07:03 2017 +0200
+++ b/Core/DicomFormat/DicomMap.cpp	Tue Aug 29 16:49:44 2017 +0200
@@ -36,7 +36,9 @@
 
 #include <stdio.h>
 #include <memory>
+
 #include "../Endianness.h"
+#include "../Logging.h"
 #include "../OrthancException.h"
 
 
@@ -781,4 +783,86 @@
 
     return true;
   }
+
+
+  static std::string ValueAsString(const DicomMap& summary,
+                                   const DicomTag& tag)
+  {
+    const DicomValue& value = summary.GetValue(tag);
+    if (value.IsNull())
+    {
+      return "(null)";
+    }
+    else
+    {
+      return value.GetContent();
+    }
+  }
+
+
+  void DicomMap::LogMissingTagsForStore() const
+  {
+    std::string s, t;
+
+    if (HasTag(DICOM_TAG_PATIENT_ID))
+    {
+      if (t.size() > 0)
+        t += ", ";
+      t += "PatientID=" + ValueAsString(*this, DICOM_TAG_PATIENT_ID);
+    }
+    else
+    {
+      if (s.size() > 0)
+        s += ", ";
+      s += "PatientID";
+    }
+
+    if (HasTag(DICOM_TAG_STUDY_INSTANCE_UID))
+    {
+      if (t.size() > 0)
+        t += ", ";
+      t += "StudyInstanceUID=" + ValueAsString(*this, DICOM_TAG_STUDY_INSTANCE_UID);
+    }
+    else
+    {
+      if (s.size() > 0)
+        s += ", ";
+      s += "StudyInstanceUID";
+    }
+
+    if (HasTag(DICOM_TAG_SERIES_INSTANCE_UID))
+    {
+      if (t.size() > 0)
+        t += ", ";
+      t += "SeriesInstanceUID=" + ValueAsString(*this, DICOM_TAG_SERIES_INSTANCE_UID);
+    }
+    else
+    {
+      if (s.size() > 0)
+        s += ", ";
+      s += "SeriesInstanceUID";
+    }
+
+    if (HasTag(DICOM_TAG_SOP_INSTANCE_UID))
+    {
+      if (t.size() > 0)
+        t += ", ";
+      t += "SOPInstanceUID=" + ValueAsString(*this, DICOM_TAG_SOP_INSTANCE_UID);
+    }
+    else
+    {
+      if (s.size() > 0)
+        s += ", ";
+      s += "SOPInstanceUID";
+    }
+
+    if (t.size() == 0)
+    {
+      LOG(ERROR) << "Store has failed because all the required tags (" << s << ") are missing (is it a DICOMDIR file?)";
+    }
+    else
+    {
+      LOG(ERROR) << "Store has failed because required tags (" << s << ") are missing for the following instance: " << t;
+    }
+  }
 }
--- a/Core/DicomFormat/DicomMap.h	Mon Aug 28 18:07:03 2017 +0200
+++ b/Core/DicomFormat/DicomMap.h	Tue Aug 29 16:49:44 2017 +0200
@@ -181,5 +181,7 @@
     static bool ParseDicomMetaInformation(DicomMap& result,
                                           const char* dicom,
                                           size_t size);
+
+    void LogMissingTagsForStore() const;
   };
 }
--- a/Core/HttpServer/MongooseServer.h	Mon Aug 28 18:07:03 2017 +0200
+++ b/Core/HttpServer/MongooseServer.h	Tue Aug 29 16:49:44 2017 +0200
@@ -33,6 +33,20 @@
 
 #pragma once
 
+#if !defined(ORTHANC_ENABLE_MONGOOSE)
+#  error Macro ORTHANC_ENABLE_MONGOOSE must be defined to include this file
+#endif
+
+#if !defined(ORTHANC_ENABLE_CIVETWEB)
+#  error Macro ORTHANC_ENABLE_CIVETWEB must be defined to include this file
+#endif
+
+#if (ORTHANC_ENABLE_MONGOOSE == 0 && \
+     ORTHANC_ENABLE_CIVETWEB == 0)
+#  error Either ORTHANC_ENABLE_MONGOOSE or ORTHANC_ENABLE_CIVETWEB must be set to 1
+#endif
+
+
 #include "IIncomingHttpRequestFilter.h"
 
 #include "../OrthancException.h"
--- a/Core/SQLite/OrthancSQLiteException.h	Mon Aug 28 18:07:03 2017 +0200
+++ b/Core/SQLite/OrthancSQLiteException.h	Tue Aug 29 16:49:44 2017 +0200
@@ -38,6 +38,11 @@
 #pragma once
 
 
+#if ORTHANC_ENABLE_SQLITE != 1
+#  error Macro ORTHANC_ENABLE_SQLITE must be set to 1 to use SQLite
+#endif
+
+
 #if ORTHANC_SQLITE_STANDALONE == 1
 #include <stdexcept>
 
--- a/OrthancServer/DicomProtocol/DicomServer.cpp	Mon Aug 28 18:07:03 2017 +0200
+++ b/OrthancServer/DicomProtocol/DicomServer.cpp	Tue Aug 29 16:49:44 2017 +0200
@@ -35,12 +35,11 @@
 #include "DicomServer.h"
 
 #include "../../Core/Logging.h"
+#include "../../Core/MultiThreading/RunnableWorkersPool.h"
 #include "../../Core/OrthancException.h"
 #include "../../Core/Toolbox.h"
 #include "../Internals/CommandDispatcher.h"
 #include "../OrthancInitialization.h"
-#include "EmbeddedResources.h"
-#include "../../Core/MultiThreading/RunnableWorkersPool.h"
 
 #include <boost/thread.hpp>
 
--- a/OrthancServer/DicomProtocol/DicomServer.h	Mon Aug 28 18:07:03 2017 +0200
+++ b/OrthancServer/DicomProtocol/DicomServer.h	Tue Aug 29 16:49:44 2017 +0200
@@ -33,6 +33,10 @@
 
 #pragma once
 
+#if ORTHANC_ENABLE_DCMTK_NETWORKING != 1
+#  error The macro ORTHANC_ENABLE_DCMTK_NETWORKING must be set to 1
+#endif
+
 #include "IFindRequestHandlerFactory.h"
 #include "IMoveRequestHandlerFactory.h"
 #include "IStoreRequestHandlerFactory.h"
--- a/OrthancServer/DicomProtocol/DicomUserConnection.h	Mon Aug 28 18:07:03 2017 +0200
+++ b/OrthancServer/DicomProtocol/DicomUserConnection.h	Tue Aug 29 16:49:44 2017 +0200
@@ -33,6 +33,10 @@
 
 #pragma once
 
+#if ORTHANC_ENABLE_DCMTK_NETWORKING != 1
+#  error The macro ORTHANC_ENABLE_DCMTK_NETWORKING must be set to 1
+#endif
+
 #include "DicomFindAnswers.h"
 #include "../ServerEnumerations.h"
 #include "RemoteModalityParameters.h"
--- a/OrthancServer/FromDcmtkBridge.h	Mon Aug 28 18:07:03 2017 +0200
+++ b/OrthancServer/FromDcmtkBridge.h	Tue Aug 29 16:49:44 2017 +0200
@@ -44,12 +44,12 @@
 #include <dcmtk/dcmdata/dcfilefo.h>
 #include <json/json.h>
 
-#if !defined(ORTHANC_BUILD_UNIT_TESTS)
-#  error The macro ORTHANC_BUILD_UNIT_TESTS must be defined
+#if !defined(ORTHANC_ENABLE_LUA)
+#  error The macro ORTHANC_ENABLE_LUA must be defined
 #endif
 
-#if !defined(ORTHANC_ENABLE_LUA)
-#  error The macro ORTHANC_ENABLE_LUA must be defined
+#if ORTHANC_ENABLE_DCMTK != 1
+#  error The macro ORTHANC_ENABLE_DCMTK must be set to 1
 #endif
 
 #if ORTHANC_BUILD_UNIT_TESTS == 1
--- a/OrthancServer/Internals/DicomImageDecoder.cpp	Mon Aug 28 18:07:03 2017 +0200
+++ b/OrthancServer/Internals/DicomImageDecoder.cpp	Tue Aug 29 16:49:44 2017 +0200
@@ -81,27 +81,33 @@
 #include "../../Core/OrthancException.h"
 #include "../../Core/Images/Image.h"
 #include "../../Core/Images/ImageProcessing.h"
-#include "../../Core/Images/PngWriter.h"
-#include "../../Core/Images/JpegWriter.h"
 #include "../../Core/DicomFormat/DicomIntegerPixelAccessor.h"
 #include "../ToDcmtkBridge.h"
 #include "../FromDcmtkBridge.h"
 #include "../ParsedDicomFile.h"
 #include "../OrthancInitialization.h"
 
+#if ORTHANC_ENABLE_PNG == 1
+#  include "../../Core/Images/PngWriter.h"
+#endif
+
+#if ORTHANC_ENABLE_JPEG == 1
+#  include "../../Core/Images/JpegWriter.h"
+#endif
+
 #include <boost/lexical_cast.hpp>
 
 #include <dcmtk/dcmdata/dcfilefo.h>
 #include <dcmtk/dcmdata/dcrleccd.h>
 #include <dcmtk/dcmdata/dcrlecp.h>
 
-#if ORTHANC_ENABLE_JPEG_LOSSLESS == 1
+#if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1
 #  include <dcmtk/dcmjpls/djcodecd.h>
 #  include <dcmtk/dcmjpls/djcparam.h>
 #  include <dcmtk/dcmjpeg/djrplol.h>
 #endif
 
-#if ORTHANC_ENABLE_JPEG == 1
+#if ORTHANC_ENABLE_DCMTK_JPEG == 1
 #  include <dcmtk/dcmjpeg/djcodecd.h>
 #  include <dcmtk/dcmjpeg/djcparam.h>
 #  include <dcmtk/dcmjpeg/djdecbas.h>
@@ -518,7 +524,7 @@
     }
 
 
-#if ORTHANC_ENABLE_JPEG_LOSSLESS == 1
+#if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1
     /**
      * Deal with JPEG-LS images.
      **/
@@ -550,7 +556,7 @@
 #endif
 
 
-#if ORTHANC_ENABLE_JPEG == 1
+#if ORTHANC_ENABLE_DCMTK_JPEG == 1
     /**
      * Deal with JPEG images.
      **/
@@ -775,6 +781,7 @@
   }
 
 
+#if ORTHANC_ENABLE_PNG == 1
   void DicomImageDecoder::ExtractPngImage(std::string& result,
                                           std::auto_ptr<ImageAccessor>& image,
                                           ImageExtractionMode mode,
@@ -785,8 +792,10 @@
     PngWriter writer;
     writer.WriteToMemory(result, *image);
   }
+#endif
 
 
+#if ORTHANC_ENABLE_JPEG == 1
   void DicomImageDecoder::ExtractJpegImage(std::string& result,
                                            std::auto_ptr<ImageAccessor>& image,
                                            ImageExtractionMode mode,
@@ -805,4 +814,5 @@
     writer.SetQuality(quality);
     writer.WriteToMemory(result, *image);
   }
+#endif
 }
--- a/OrthancServer/Internals/DicomImageDecoder.h	Mon Aug 28 18:07:03 2017 +0200
+++ b/OrthancServer/Internals/DicomImageDecoder.h	Tue Aug 29 16:49:44 2017 +0200
@@ -41,8 +41,16 @@
 #  error The macro ORTHANC_ENABLE_JPEG must be defined
 #endif
 
-#if !defined(ORTHANC_ENABLE_JPEG_LOSSLESS)
-#  error The macro ORTHANC_ENABLE_JPEG_LOSSLESS must be defined
+#if !defined(ORTHANC_ENABLE_PNG)
+#  error The macro ORTHANC_ENABLE_PNG must be defined
+#endif
+
+#if !defined(ORTHANC_ENABLE_DCMTK_JPEG)
+#  error The macro ORTHANC_ENABLE_DCMTK_JPEG must be defined
+#endif
+
+#if !defined(ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS)
+#  error The macro ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS must be defined
 #endif
 
 
@@ -91,15 +99,19 @@
     static ImageAccessor *Decode(ParsedDicomFile& dicom,
                                  unsigned int frame);
 
+#if ORTHANC_ENABLE_PNG == 1
     static void ExtractPngImage(std::string& result,
                                 std::auto_ptr<ImageAccessor>& image,
                                 ImageExtractionMode mode,
                                 bool invert);
+#endif
 
+#if ORTHANC_ENABLE_JPEG == 1
     static void ExtractJpegImage(std::string& result,
                                  std::auto_ptr<ImageAccessor>& image,
                                  ImageExtractionMode mode,
                                  bool invert,
                                  uint8_t quality);
+#endif
   };
 }
--- a/OrthancServer/Internals/StoreScp.cpp	Mon Aug 28 18:07:03 2017 +0200
+++ b/OrthancServer/Internals/StoreScp.cpp	Tue Aug 29 16:49:44 2017 +0200
@@ -84,7 +84,6 @@
 #include "StoreScp.h"
 
 #include "../FromDcmtkBridge.h"
-#include "../ServerToolbox.h"
 #include "../ToDcmtkBridge.h"
 #include "../OrthancInitialization.h"
 #include "../../Core/OrthancException.h"
@@ -213,7 +212,7 @@
 
                 if (e.GetErrorCode() == ErrorCode_InexistentTag)
                 {
-                  ServerToolbox::LogMissingRequiredTag(summary);
+                  summary.LogMissingTagsForStore();
                 }
                 else
                 {
--- a/OrthancServer/OrthancInitialization.cpp	Mon Aug 28 18:07:03 2017 +0200
+++ b/OrthancServer/OrthancInitialization.cpp	Tue Aug 29 16:49:44 2017 +0200
@@ -51,12 +51,12 @@
 #include <boost/thread/recursive_mutex.hpp>
 
 
-#if ORTHANC_ENABLE_JPEG == 1
+#if ORTHANC_ENABLE_DCMTK_JPEG == 1
 #  include <dcmtk/dcmjpeg/djdecode.h>
 #endif
 
 
-#if ORTHANC_ENABLE_JPEG_LOSSLESS == 1
+#if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1
 #  include <dcmtk/dcmjpls/djdecode.h>
 #endif
 
@@ -495,12 +495,12 @@
     FromDcmtkBridge::InitializeDictionary(GetGlobalBoolParameterInternal("LoadPrivateDictionary", true));
     LoadCustomDictionary(configuration_);
 
-#if ORTHANC_ENABLE_JPEG_LOSSLESS == 1
+#if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1
     LOG(WARNING) << "Registering JPEG Lossless codecs";
     DJLSDecoderRegistration::registerCodecs();    
 #endif
 
-#if ORTHANC_ENABLE_JPEG == 1
+#if ORTHANC_ENABLE_DCMTK_JPEG == 1
     LOG(WARNING) << "Registering JPEG codecs";
     DJDecoderRegistration::registerCodecs(); 
 #endif
@@ -518,12 +518,12 @@
     boost::recursive_mutex::scoped_lock lock(globalMutex_);
     HttpClient::GlobalFinalize();
 
-#if ORTHANC_ENABLE_JPEG_LOSSLESS == 1
+#if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1
     // Unregister JPEG-LS codecs
     DJLSDecoderRegistration::cleanup();
 #endif
 
-#if ORTHANC_ENABLE_JPEG == 1
+#if ORTHANC_ENABLE_DCMTK_JPEG == 1
     // Unregister JPEG codecs
     DJDecoderRegistration::cleanup();
 #endif
--- a/OrthancServer/OrthancInitialization.h	Mon Aug 28 18:07:03 2017 +0200
+++ b/OrthancServer/OrthancInitialization.h	Tue Aug 29 16:49:44 2017 +0200
@@ -47,12 +47,12 @@
 #include "IDatabaseWrapper.h"
 #include "ServerEnumerations.h"
 
-#if !defined(ORTHANC_ENABLE_JPEG)
-#  error The macro ORTHANC_ENABLE_JPEG must be defined
+#if !defined(ORTHANC_ENABLE_DCMTK_JPEG)
+#  error The macro ORTHANC_ENABLE_DCMTK_JPEG must be defined
 #endif
 
-#if !defined(ORTHANC_ENABLE_JPEG_LOSSLESS)
-#  error The macro ORTHANC_ENABLE_JPEG_LOSSLESS must be defined
+#if !defined(ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS)
+#  error The macro ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS must be defined
 #endif
 
 
--- a/OrthancServer/ParsedDicomFile.cpp	Mon Aug 28 18:07:03 2017 +0200
+++ b/OrthancServer/ParsedDicomFile.cpp	Tue Aug 29 16:49:44 2017 +0200
@@ -82,16 +82,21 @@
 #include "ParsedDicomFile.h"
 
 #include "OrthancInitialization.h"
-#include "ServerToolbox.h"
 #include "FromDcmtkBridge.h"
 #include "ToDcmtkBridge.h"
 #include "Internals/DicomFrameIndex.h"
-#include "../Core/Images/JpegReader.h"
-#include "../Core/Images/PngReader.h"
 #include "../Core/Logging.h"
 #include "../Core/OrthancException.h"
 #include "../Core/Toolbox.h"
 
+#if ORTHANC_ENABLE_JPEG == 1
+#  include "../Core/Images/JpegReader.h"
+#endif
+
+#if ORTHANC_ENABLE_PNG == 1
+#  include "../Core/Images/PngReader.h"
+#endif
+
 #include <list>
 #include <limits>
 
@@ -1016,10 +1021,23 @@
 
     Toolbox::ToLowerCase(mime);
 
-    if (mime == "image/png" ||
-        mime == "image/jpeg")
+    if (mime == "image/png")
     {
+#if ORTHANC_ENABLE_PNG == 1
       EmbedImage(mime, content);
+#else
+      LOG(ERROR) << "Orthanc was compiled without support of PNG";
+      throw OrthancException(ErrorCode_NotImplemented);
+#endif
+    }
+    else if (mime == "image/jpeg")
+    {
+#if ORTHANC_ENABLE_JPEG == 1
+      EmbedImage(mime, content);
+#else
+      LOG(ERROR) << "Orthanc was compiled without support of JPEG";
+      throw OrthancException(ErrorCode_NotImplemented);
+#endif
     }
     else if (mime == "application/pdf")
     {
@@ -1044,6 +1062,8 @@
   }
 
 
+#if (ORTHANC_ENABLE_JPEG == 1 &&  \
+     ORTHANC_ENABLE_PNG == 1)
   void ParsedDicomFile::EmbedImage(const std::string& mime,
                                    const std::string& content)
   {
@@ -1064,6 +1084,7 @@
       throw OrthancException(ErrorCode_NotImplemented);
     }
   }
+#endif
 
 
   void ParsedDicomFile::EmbedImage(const ImageAccessor& accessor)
--- a/OrthancServer/ParsedDicomFile.h	Mon Aug 28 18:07:03 2017 +0200
+++ b/OrthancServer/ParsedDicomFile.h	Tue Aug 29 16:49:44 2017 +0200
@@ -40,6 +40,14 @@
 #include "../Core/Toolbox.h"
 #include "ServerEnumerations.h"
 
+#if !defined(ORTHANC_ENABLE_JPEG)
+#  error Macro ORTHANC_ENABLE_JPEG must be defined to use this file
+#endif
+
+#if !defined(ORTHANC_ENABLE_PNG)
+#  error Macro ORTHANC_ENABLE_PNG must be defined to use this file
+#endif
+
 class DcmDataset;
 class DcmFileFormat;
 
@@ -144,8 +152,11 @@
 
     void EmbedImage(const ImageAccessor& accessor);
 
+#if (ORTHANC_ENABLE_JPEG == 1 &&  \
+     ORTHANC_ENABLE_PNG == 1)
     void EmbedImage(const std::string& mime,
                     const std::string& content);
+#endif
 
     Encoding GetEncoding() const;
 
--- a/OrthancServer/ServerContext.cpp	Mon Aug 28 18:07:03 2017 +0200
+++ b/OrthancServer/ServerContext.cpp	Tue Aug 29 16:49:44 2017 +0200
@@ -314,7 +314,7 @@
     {
       if (e.GetErrorCode() == ErrorCode_InexistentTag)
       {
-        ServerToolbox::LogMissingRequiredTag(dicom.GetSummary());
+        dicom.GetSummary().LogMissingTagsForStore();
       }
 
       throw;
--- a/OrthancServer/ServerToolbox.cpp	Mon Aug 28 18:07:03 2017 +0200
+++ b/OrthancServer/ServerToolbox.cpp	Tue Aug 29 16:49:44 2017 +0200
@@ -135,88 +135,6 @@
     }
 
 
-    static std::string ValueAsString(const DicomMap& summary,
-                                     const DicomTag& tag)
-    {
-      const DicomValue& value = summary.GetValue(tag);
-      if (value.IsNull())
-      {
-        return "(null)";
-      }
-      else
-      {
-        return value.GetContent();
-      }
-    }
-
-
-    void LogMissingRequiredTag(const DicomMap& summary)
-    {
-      std::string s, t;
-
-      if (summary.HasTag(DICOM_TAG_PATIENT_ID))
-      {
-        if (t.size() > 0)
-          t += ", ";
-        t += "PatientID=" + ValueAsString(summary, DICOM_TAG_PATIENT_ID);
-      }
-      else
-      {
-        if (s.size() > 0)
-          s += ", ";
-        s += "PatientID";
-      }
-
-      if (summary.HasTag(DICOM_TAG_STUDY_INSTANCE_UID))
-      {
-        if (t.size() > 0)
-          t += ", ";
-        t += "StudyInstanceUID=" + ValueAsString(summary, DICOM_TAG_STUDY_INSTANCE_UID);
-      }
-      else
-      {
-        if (s.size() > 0)
-          s += ", ";
-        s += "StudyInstanceUID";
-      }
-
-      if (summary.HasTag(DICOM_TAG_SERIES_INSTANCE_UID))
-      {
-        if (t.size() > 0)
-          t += ", ";
-        t += "SeriesInstanceUID=" + ValueAsString(summary, DICOM_TAG_SERIES_INSTANCE_UID);
-      }
-      else
-      {
-        if (s.size() > 0)
-          s += ", ";
-        s += "SeriesInstanceUID";
-      }
-
-      if (summary.HasTag(DICOM_TAG_SOP_INSTANCE_UID))
-      {
-        if (t.size() > 0)
-          t += ", ";
-        t += "SOPInstanceUID=" + ValueAsString(summary, DICOM_TAG_SOP_INSTANCE_UID);
-      }
-      else
-      {
-        if (s.size() > 0)
-          s += ", ";
-        s += "SOPInstanceUID";
-      }
-
-      if (t.size() == 0)
-      {
-        LOG(ERROR) << "Store has failed because all the required tags (" << s << ") are missing (is it a DICOMDIR file?)";
-      }
-      else
-      {
-        LOG(ERROR) << "Store has failed because required tags (" << s << ") are missing for the following instance: " << t;
-      }
-    }
-
-
     static void StoreMainDicomTagsInternal(IDatabaseWrapper& database,
                                            int64_t resource,
                                            const DicomMap& tags)
--- a/OrthancServer/ServerToolbox.h	Mon Aug 28 18:07:03 2017 +0200
+++ b/OrthancServer/ServerToolbox.h	Tue Aug 29 16:49:44 2017 +0200
@@ -45,8 +45,6 @@
                       const Json::Value& source,
                       DicomToJsonFormat format);
 
-    void LogMissingRequiredTag(const DicomMap& summary);
-
     void StoreMainDicomTags(IDatabaseWrapper& database,
                             int64_t resource,
                             ResourceType level,
--- a/OrthancServer/ToDcmtkBridge.h	Mon Aug 28 18:07:03 2017 +0200
+++ b/OrthancServer/ToDcmtkBridge.h	Tue Aug 29 16:49:44 2017 +0200
@@ -33,6 +33,10 @@
 
 #pragma once
 
+#if ORTHANC_ENABLE_DCMTK != 1
+#  error The macro ORTHANC_ENABLE_DCMTK must be set to 1
+#endif
+
 #include "../Core/DicomFormat/DicomMap.h"
 #include <dcmtk/dcmdata/dcdatset.h>
 
--- a/Resources/CMake/DcmtkConfiguration.cmake	Mon Aug 28 18:07:03 2017 +0200
+++ b/Resources/CMake/DcmtkConfiguration.cmake	Tue Aug 29 16:49:44 2017 +0200
@@ -151,7 +151,7 @@
       )
   endif()
 
-  if (ENABLE_JPEG)
+  if (ENABLE_DCMTK_JPEG)
     AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc DCMTK_SOURCES)
     AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpeg/libijg8 DCMTK_SOURCES)
     AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpeg/libijg12 DCMTK_SOURCES)
@@ -179,7 +179,7 @@
   endif()
 
 
-  if (ENABLE_JPEG_LOSSLESS)
+  if (ENABLE_DCMTK_JPEG_LOSSLESS)
     AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpls/libsrc DCMTK_SOURCES)
     AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpls/libcharls DCMTK_SOURCES)
     include_directories(