# HG changeset patch # User Sebastien Jodogne # Date 1734703882 -3600 # Node ID 3fc2ef580095329e76d5496e365088a24f6e2770 # Parent 03d33290cba16e094f3ddbd53187067415259a21 sharing code for IIIF manifest diff -r 03d33290cba1 -r 3fc2ef580095 ViewerPlugin/IIIF.cpp --- a/ViewerPlugin/IIIF.cpp Fri Dec 20 14:56:08 2024 +0100 +++ b/ViewerPlugin/IIIF.cpp Fri Dec 20 15:11:22 2024 +0100 @@ -579,6 +579,37 @@ } +static std::string GetTagValue(const Json::Value& tags, + const std::string& key) +{ + if (tags.isMember(key)) + { + return tags[key].asString(); + } + else + { + return ""; + } +} + + +static void FillManifest(Json::Value& manifest, + const std::string& base, + const Json::Value& study, + const Json::Value& series) +{ + static const char* const MAIN_DICOM_TAGS = "MainDicomTags"; + + manifest["@context"] = "http://iiif.io/api/presentation/3/context.json"; + manifest["id"] = base + "/manifest.json"; + manifest["type"] = "Manifest"; + manifest["label"]["en"].append(GetTagValue(study[MAIN_DICOM_TAGS], "StudyDate") + " - " + + GetTagValue(series[MAIN_DICOM_TAGS], "Modality") + " - " + + GetTagValue(study[MAIN_DICOM_TAGS], "StudyDescription") + " - " + + GetTagValue(series[MAIN_DICOM_TAGS], "SeriesDescription")); +} + + void ServeIIIFManifest(OrthancPluginRestOutput* output, const char* url, const OrthancPluginHttpRequest* request) @@ -619,16 +650,8 @@ const std::string sopClassUid = Orthanc::Toolbox::StripSpaces(oneInstance[SOP_CLASS_UID].asString()); - const std::string base = iiifPublicUrl_ + "series/" + seriesId; - Json::Value manifest; - manifest["@context"] = "http://iiif.io/api/presentation/3/context.json"; - manifest["id"] = base + "/manifest.json"; - manifest["type"] = "Manifest"; - manifest["label"]["en"].append(study["MainDicomTags"]["StudyDate"].asString() + " - " + - series["MainDicomTags"]["Modality"].asString() + " - " + - study["MainDicomTags"]["StudyDescription"].asString() + " - " + - series["MainDicomTags"]["SeriesDescription"].asString()); + FillManifest(manifest, iiifPublicUrl_ + "series/" + seriesId, study, series); if (sopClassUid == OrthancWSI::VL_WHOLE_SLIDE_MICROSCOPY_IMAGE_STORAGE_IOD) { @@ -811,16 +834,9 @@ } const std::string resourceBase = "frames-pyramids/" + instanceId + "/" + boost::lexical_cast(frameNumber); - const std::string base = iiifPublicUrl_ + resourceBase; Json::Value manifest; - manifest["@context"] = "http://iiif.io/api/presentation/3/context.json"; - manifest["id"] = base + "/manifest.json"; - manifest["type"] = "Manifest"; - manifest["label"]["en"].append(study["MainDicomTags"]["StudyDate"].asString() + " - " + - series["MainDicomTags"]["Modality"].asString() + " - " + - study["MainDicomTags"]["StudyDescription"].asString() + " - " + - series["MainDicomTags"]["SeriesDescription"].asString()); + FillManifest(manifest, iiifPublicUrl_ + resourceBase, study, series); /** * This is based on IIIF cookbook: "Support Deep Viewing with Basic