Mercurial > hg > orthanc
diff 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 |
line wrap: on
line diff
--- a/Plugins/Engine/OrthancPlugins.cpp Tue Oct 20 17:39:58 2015 +0200 +++ b/Plugins/Engine/OrthancPlugins.cpp Mon Oct 26 12:30:34 2015 +0100 @@ -299,7 +299,15 @@ sizeof(int32_t) != sizeof(OrthancPluginImageFormat) || sizeof(int32_t) != sizeof(OrthancPluginCompressionType) || sizeof(int32_t) != sizeof(OrthancPluginValueRepresentation) || - sizeof(int32_t) != sizeof(_OrthancPluginDatabaseAnswerType)) + sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFlags) || + sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFormat) || + sizeof(int32_t) != sizeof(_OrthancPluginDatabaseAnswerType) || + static_cast<int>(OrthancPluginDicomToJsonFlags_IncludeBinary) != static_cast<int>(DicomToJsonFlags_IncludeBinary) || + static_cast<int>(OrthancPluginDicomToJsonFlags_IncludePrivateTags) != static_cast<int>(DicomToJsonFlags_IncludePrivateTags) || + static_cast<int>(OrthancPluginDicomToJsonFlags_IncludeUnknownTags) != static_cast<int>(DicomToJsonFlags_IncludeUnknownTags) || + static_cast<int>(OrthancPluginDicomToJsonFlags_IncludePixelData) != static_cast<int>(DicomToJsonFlags_IncludePixelData) || + static_cast<int>(OrthancPluginDicomToJsonFlags_ConvertBinaryToNull) != static_cast<int>(DicomToJsonFlags_ConvertBinaryToNull) || + static_cast<int>(OrthancPluginDicomToJsonFlags_ConvertBinaryToAscii) != static_cast<int>(DicomToJsonFlags_ConvertBinaryToAscii)) { /* Sanity check of the compiler */ throw OrthancException(ErrorCode_Plugin); @@ -506,7 +514,9 @@ - void OrthancPlugins::SignalChange(const ServerIndexChange& change) + void OrthancPlugins::SignalChangeInternal(OrthancPluginChangeType changeType, + OrthancPluginResourceType resourceType, + const char* resource) { boost::recursive_mutex::scoped_lock lock(pimpl_->changeCallbackMutex_); @@ -514,10 +524,7 @@ callback = pimpl_->onChangeCallbacks_.begin(); callback != pimpl_->onChangeCallbacks_.end(); ++callback) { - OrthancPluginErrorCode error = (*callback) - (Plugins::Convert(change.GetChangeType()), - Plugins::Convert(change.GetResourceType()), - change.GetPublicId().c_str()); + OrthancPluginErrorCode error = (*callback) (changeType, resourceType, resource); if (error != OrthancPluginErrorCode_Success) { @@ -529,6 +536,15 @@ + void OrthancPlugins::SignalChange(const ServerIndexChange& change) + { + SignalChangeInternal(Plugins::Convert(change.GetChangeType()), + Plugins::Convert(change.GetResourceType()), + change.GetPublicId().c_str()); + } + + + static void CopyToMemoryBuffer(OrthancPluginMemoryBuffer& target, const void* data, size_t size) @@ -1229,6 +1245,39 @@ font.Draw(target, p.utf8Text, p.x, p.y, p.r, p.g, p.b); } + + + void OrthancPlugins::ApplyDicomToJson(_OrthancPluginService service, + const void* parameters) + { + const _OrthancPluginDicomToJson& p = + *reinterpret_cast<const _OrthancPluginDicomToJson*>(parameters); + + std::auto_ptr<ParsedDicomFile> dicom; + + if (service == _OrthancPluginService_DicomBufferToJson) + { + dicom.reset(new ParsedDicomFile(p.buffer, p.size)); + } + else + { + if (p.instanceId == NULL) + { + throw OrthancException(ErrorCode_ParameterOutOfRange); + } + + std::string content; + pimpl_->context_->ReadFile(content, p.instanceId, FileContentType_Dicom); + dicom.reset(new ParsedDicomFile(content)); + } + + Json::Value json; + dicom->ToJson(json, Plugins::Convert(p.format), + static_cast<DicomToJsonFlags>(p.flags), p.maxStringLength); + + Json::FastWriter writer; + *p.result = CopyString(writer.write(json)); + } bool OrthancPlugins::InvokeService(SharedLibrary& plugin, @@ -1726,6 +1775,11 @@ return true; } + case _OrthancPluginService_DicomBufferToJson: + case _OrthancPluginService_DicomInstanceToJson: + ApplyDicomToJson(service, parameters); + return true; + default: { // This service is unknown to the Orthanc plugin engine