comparison Plugins/Engine/OrthancPlugins.cpp @ 1744:b3de74dec2d5 db-changes

integration mainline->db-changes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 26 Oct 2015 12:30:34 +0100
parents 4941494b5dd8 2dd5c6b0380b
children 51db4a25a741
comparison
equal deleted inserted replaced
1729:54d78925cbb6 1744:b3de74dec2d5
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
504 } 512 }
505 } 513 }
506 514
507 515
508 516
509 void OrthancPlugins::SignalChange(const ServerIndexChange& change) 517 void OrthancPlugins::SignalChangeInternal(OrthancPluginChangeType changeType,
518 OrthancPluginResourceType resourceType,
519 const char* resource)
510 { 520 {
511 boost::recursive_mutex::scoped_lock lock(pimpl_->changeCallbackMutex_); 521 boost::recursive_mutex::scoped_lock lock(pimpl_->changeCallbackMutex_);
512 522
513 for (std::list<OrthancPluginOnChangeCallback>::const_iterator 523 for (std::list<OrthancPluginOnChangeCallback>::const_iterator
514 callback = pimpl_->onChangeCallbacks_.begin(); 524 callback = pimpl_->onChangeCallbacks_.begin();
515 callback != pimpl_->onChangeCallbacks_.end(); ++callback) 525 callback != pimpl_->onChangeCallbacks_.end(); ++callback)
516 { 526 {
517 OrthancPluginErrorCode error = (*callback) 527 OrthancPluginErrorCode error = (*callback) (changeType, resourceType, resource);
518 (Plugins::Convert(change.GetChangeType()),
519 Plugins::Convert(change.GetResourceType()),
520 change.GetPublicId().c_str());
521 528
522 if (error != OrthancPluginErrorCode_Success) 529 if (error != OrthancPluginErrorCode_Success)
523 { 530 {
524 GetErrorDictionary().LogError(error, true); 531 GetErrorDictionary().LogError(error, true);
525 throw OrthancException(static_cast<ErrorCode>(error)); 532 throw OrthancException(static_cast<ErrorCode>(error));
526 } 533 }
527 } 534 }
535 }
536
537
538
539 void OrthancPlugins::SignalChange(const ServerIndexChange& change)
540 {
541 SignalChangeInternal(Plugins::Convert(change.GetChangeType()),
542 Plugins::Convert(change.GetResourceType()),
543 change.GetPublicId().c_str());
528 } 544 }
529 545
530 546
531 547
532 static void CopyToMemoryBuffer(OrthancPluginMemoryBuffer& target, 548 static void CopyToMemoryBuffer(OrthancPluginMemoryBuffer& target,
1227 ImageAccessor& target = *reinterpret_cast<ImageAccessor*>(p.image); 1243 ImageAccessor& target = *reinterpret_cast<ImageAccessor*>(p.image);
1228 const Font& font = Configuration::GetFontRegistry().GetFont(p.fontIndex); 1244 const Font& font = Configuration::GetFontRegistry().GetFont(p.fontIndex);
1229 1245
1230 font.Draw(target, p.utf8Text, p.x, p.y, p.r, p.g, p.b); 1246 font.Draw(target, p.utf8Text, p.x, p.y, p.r, p.g, p.b);
1231 } 1247 }
1248
1249
1250 void OrthancPlugins::ApplyDicomToJson(_OrthancPluginService service,
1251 const void* parameters)
1252 {
1253 const _OrthancPluginDicomToJson& p =
1254 *reinterpret_cast<const _OrthancPluginDicomToJson*>(parameters);
1255
1256 std::auto_ptr<ParsedDicomFile> dicom;
1257
1258 if (service == _OrthancPluginService_DicomBufferToJson)
1259 {
1260 dicom.reset(new ParsedDicomFile(p.buffer, p.size));
1261 }
1262 else
1263 {
1264 if (p.instanceId == NULL)
1265 {
1266 throw OrthancException(ErrorCode_ParameterOutOfRange);
1267 }
1268
1269 std::string content;
1270 pimpl_->context_->ReadFile(content, p.instanceId, FileContentType_Dicom);
1271 dicom.reset(new ParsedDicomFile(content));
1272 }
1273
1274 Json::Value json;
1275 dicom->ToJson(json, Plugins::Convert(p.format),
1276 static_cast<DicomToJsonFlags>(p.flags), p.maxStringLength);
1277
1278 Json::FastWriter writer;
1279 *p.result = CopyString(writer.write(json));
1280 }
1232 1281
1233 1282
1234 bool OrthancPlugins::InvokeService(SharedLibrary& plugin, 1283 bool OrthancPlugins::InvokeService(SharedLibrary& plugin,
1235 _OrthancPluginService service, 1284 _OrthancPluginService service,
1236 const void* parameters) 1285 const void* parameters)
1724 Toolbox::ReconstructMainDicomTags(*pimpl_->database_, storage, Plugins::Convert(p.level)); 1773 Toolbox::ReconstructMainDicomTags(*pimpl_->database_, storage, Plugins::Convert(p.level));
1725 1774
1726 return true; 1775 return true;
1727 } 1776 }
1728 1777
1778 case _OrthancPluginService_DicomBufferToJson:
1779 case _OrthancPluginService_DicomInstanceToJson:
1780 ApplyDicomToJson(service, parameters);
1781 return true;
1782
1729 default: 1783 default:
1730 { 1784 {
1731 // This service is unknown to the Orthanc plugin engine 1785 // This service is unknown to the Orthanc plugin engine
1732 return false; 1786 return false;
1733 } 1787 }