Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPlugins.cpp @ 1740:5e99a70b0635
DicomToJson callable from plugins
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 22 Oct 2015 19:53:51 +0200 |
parents | 0bbcfd9695e5 |
children | 06addfcd1d4c |
comparison
equal
deleted
inserted
replaced
1739:df331354cea2 | 1740:5e99a70b0635 |
---|---|
297 sizeof(int32_t) != sizeof(OrthancPluginResourceType) || | 297 sizeof(int32_t) != sizeof(OrthancPluginResourceType) || |
298 sizeof(int32_t) != sizeof(OrthancPluginChangeType) || | 298 sizeof(int32_t) != sizeof(OrthancPluginChangeType) || |
299 sizeof(int32_t) != sizeof(OrthancPluginImageFormat) || | 299 sizeof(int32_t) != sizeof(OrthancPluginImageFormat) || |
300 sizeof(int32_t) != sizeof(OrthancPluginCompressionType) || | 300 sizeof(int32_t) != sizeof(OrthancPluginCompressionType) || |
301 sizeof(int32_t) != sizeof(OrthancPluginValueRepresentation) || | 301 sizeof(int32_t) != sizeof(OrthancPluginValueRepresentation) || |
302 sizeof(int32_t) != sizeof(_OrthancPluginDatabaseAnswerType)) | 302 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFlags) || |
303 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFormat) || | |
304 sizeof(int32_t) != sizeof(_OrthancPluginDatabaseAnswerType) || | |
305 static_cast<int>(OrthancPluginDicomToJsonFlags_IncludeBinary) != static_cast<int>(DicomToJsonFlags_IncludeBinary) || | |
306 static_cast<int>(OrthancPluginDicomToJsonFlags_IncludePrivateTags) != static_cast<int>(DicomToJsonFlags_IncludePrivateTags) || | |
307 static_cast<int>(OrthancPluginDicomToJsonFlags_IncludeUnknownTags) != static_cast<int>(DicomToJsonFlags_IncludeUnknownTags) || | |
308 static_cast<int>(OrthancPluginDicomToJsonFlags_IncludePixelData) != static_cast<int>(DicomToJsonFlags_IncludePixelData) || | |
309 static_cast<int>(OrthancPluginDicomToJsonFlags_ConvertBinaryToNull) != static_cast<int>(DicomToJsonFlags_ConvertBinaryToNull) || | |
310 static_cast<int>(OrthancPluginDicomToJsonFlags_ConvertBinaryToAscii) != static_cast<int>(DicomToJsonFlags_ConvertBinaryToAscii)) | |
303 { | 311 { |
304 /* Sanity check of the compiler */ | 312 /* Sanity check of the compiler */ |
305 throw OrthancException(ErrorCode_Plugin); | 313 throw OrthancException(ErrorCode_Plugin); |
306 } | 314 } |
307 | 315 |
1227 ImageAccessor& target = *reinterpret_cast<ImageAccessor*>(p.image); | 1235 ImageAccessor& target = *reinterpret_cast<ImageAccessor*>(p.image); |
1228 const Font& font = Configuration::GetFontRegistry().GetFont(p.fontIndex); | 1236 const Font& font = Configuration::GetFontRegistry().GetFont(p.fontIndex); |
1229 | 1237 |
1230 font.Draw(target, p.utf8Text, p.x, p.y, p.r, p.g, p.b); | 1238 font.Draw(target, p.utf8Text, p.x, p.y, p.r, p.g, p.b); |
1231 } | 1239 } |
1240 | |
1241 | |
1242 void OrthancPlugins::ApplyDicomToJson(_OrthancPluginService service, | |
1243 const void* parameters) | |
1244 { | |
1245 const _OrthancPluginDicomToJson& p = | |
1246 *reinterpret_cast<const _OrthancPluginDicomToJson*>(parameters); | |
1247 | |
1248 std::auto_ptr<ParsedDicomFile> dicom; | |
1249 | |
1250 if (service == _OrthancPluginService_DicomBufferToJson) | |
1251 { | |
1252 dicom.reset(new ParsedDicomFile(p.buffer, p.size)); | |
1253 } | |
1254 else | |
1255 { | |
1256 if (p.instanceId == NULL) | |
1257 { | |
1258 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
1259 } | |
1260 | |
1261 std::string content; | |
1262 pimpl_->context_->ReadFile(content, p.instanceId, FileContentType_Dicom); | |
1263 dicom.reset(new ParsedDicomFile(content)); | |
1264 } | |
1265 | |
1266 Json::Value json; | |
1267 dicom->ToJson(json, Plugins::Convert(p.format), | |
1268 static_cast<DicomToJsonFlags>(p.flags), p.maxStringLength); | |
1269 | |
1270 Json::FastWriter writer; | |
1271 *p.result = CopyString(writer.write(json)); | |
1272 } | |
1232 | 1273 |
1233 | 1274 |
1234 bool OrthancPlugins::InvokeService(SharedLibrary& plugin, | 1275 bool OrthancPlugins::InvokeService(SharedLibrary& plugin, |
1235 _OrthancPluginService service, | 1276 _OrthancPluginService service, |
1236 const void* parameters) | 1277 const void* parameters) |
1724 Toolbox::ReconstructMainDicomTags(*pimpl_->database_, storage, Plugins::Convert(p.level)); | 1765 Toolbox::ReconstructMainDicomTags(*pimpl_->database_, storage, Plugins::Convert(p.level)); |
1725 | 1766 |
1726 return true; | 1767 return true; |
1727 } | 1768 } |
1728 | 1769 |
1770 case _OrthancPluginService_DicomBufferToJson: | |
1771 case _OrthancPluginService_DicomInstanceToJson: | |
1772 ApplyDicomToJson(service, parameters); | |
1773 return true; | |
1774 | |
1729 default: | 1775 default: |
1730 { | 1776 { |
1731 // This service is unknown to the Orthanc plugin engine | 1777 // This service is unknown to the Orthanc plugin engine |
1732 return false; | 1778 return false; |
1733 } | 1779 } |