comparison OrthancStone/Sources/Loaders/SeriesThumbnailsLoader.cpp @ 1665:f62f685e0eb2

avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 19 Nov 2020 15:39:30 +0100
parents 66e5fcdf5597
children ef2f56c0311c
comparison
equal deleted inserted replaced
1664:32e765ca7193 1665:f62f685e0eb2
43 43
44 static const unsigned int JPEG_QUALITY = 70; // Only used for Orthanc source 44 static const unsigned int JPEG_QUALITY = 70; // Only used for Orthanc source
45 45
46 namespace OrthancStone 46 namespace OrthancStone
47 { 47 {
48 static SeriesThumbnailType ExtractSopClassUid(const std::string& sopClassUid)
49 {
50 if (sopClassUid == "1.2.840.10008.5.1.4.1.1.104.1") // Encapsulated PDF Storage
51 {
52 return SeriesThumbnailType_Pdf;
53 }
54 else if (sopClassUid == "1.2.840.10008.5.1.4.1.1.77.1.1.1" || // Video Endoscopic Image Storage
55 sopClassUid == "1.2.840.10008.5.1.4.1.1.77.1.2.1" || // Video Microscopic Image Storage
56 sopClassUid == "1.2.840.10008.5.1.4.1.1.77.1.4.1") // Video Photographic Image Storage
57 {
58 return SeriesThumbnailType_Video;
59 }
60 else
61 {
62 return SeriesThumbnailType_Unsupported;
63 }
64 }
65
66
67 SeriesThumbnailsLoader::Thumbnail::Thumbnail(const std::string& image, 48 SeriesThumbnailsLoader::Thumbnail::Thumbnail(const std::string& image,
68 const std::string& mime) : 49 const std::string& mime) :
69 type_(SeriesThumbnailType_Image), 50 type_(SeriesThumbnailType_Image),
70 image_(image), 51 image_(image),
71 mime_(mime) 52 mime_(mime)
257 } 238 }
258 } 239 }
259 240
260 if (ok) 241 if (ok)
261 { 242 {
262 type = ExtractSopClassUid(sopClassUid); 243 type = GetSeriesThumbnailType(StringToSopClassUid(sopClassUid));
263 } 244 }
264 } 245 }
265 246
266 GetLoader()->AcquireThumbnail(GetSource(), GetStudyInstanceUid(), 247 GetLoader()->AcquireThumbnail(GetSource(), GetStudyInstanceUid(),
267 GetSeriesInstanceUid(), new Thumbnail(type)); 248 GetSeriesInstanceUid(), new Thumbnail(type));
368 } 349 }
369 350
370 virtual void HandleSuccess(const std::string& body, 351 virtual void HandleSuccess(const std::string& body,
371 const std::map<std::string, std::string>& headers) ORTHANC_OVERRIDE 352 const std::map<std::string, std::string>& headers) ORTHANC_OVERRIDE
372 { 353 {
373 SeriesThumbnailType type = ExtractSopClassUid(body); 354 SeriesThumbnailType type = GetSeriesThumbnailType(StringToSopClassUid(body));
374 355
375 if (type == SeriesThumbnailType_Pdf || 356 if (type == SeriesThumbnailType_Pdf ||
376 type == SeriesThumbnailType_Video) 357 type == SeriesThumbnailType_Video)
377 { 358 {
378 GetLoader()->AcquireThumbnail(GetSource(), GetStudyInstanceUid(), 359 GetLoader()->AcquireThumbnail(GetSource(), GetStudyInstanceUid(),