comparison OrthancServer/Plugins/Engine/OrthancPlugins.cpp @ 4477:0a2c9790cb41

new primitive in plugin SDK: OrthancPluginCreateDicom2()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 27 Jan 2021 16:54:03 +0100
parents c1f36fd13730
children a926f8995d0b
comparison
equal deleted inserted replaced
4476:c1f36fd13730 4477:0a2c9790cb41
3580 Toolbox::WriteFastJson(s, json); 3580 Toolbox::WriteFastJson(s, json);
3581 *p.result = CopyString(s); 3581 *p.result = CopyString(s);
3582 } 3582 }
3583 3583
3584 3584
3585 void OrthancPlugins::ApplyCreateDicom(_OrthancPluginService service, 3585 void OrthancPlugins::ApplyCreateDicom(const _OrthancPluginCreateDicom& parameters,
3586 const void* parameters) 3586 const char* privateCreatorC)
3587 { 3587 {
3588 const _OrthancPluginCreateDicom& p =
3589 *reinterpret_cast<const _OrthancPluginCreateDicom*>(parameters);
3590
3591 Json::Value json; 3588 Json::Value json;
3592 3589
3593 if (p.json == NULL) 3590 if (parameters.json == NULL)
3594 { 3591 {
3595 json = Json::objectValue; 3592 json = Json::objectValue;
3596 } 3593 }
3597 else if (!Toolbox::ReadJson(json, p.json)) 3594 else if (!Toolbox::ReadJson(json, parameters.json))
3598 { 3595 {
3599 throw OrthancException(ErrorCode_BadJson); 3596 throw OrthancException(ErrorCode_BadJson);
3600 } 3597 }
3601 3598
3602 std::string dicom; 3599 std::string dicom;
3604 { 3601 {
3605 // Fix issue 168 (Plugins can't read private tags from the 3602 // Fix issue 168 (Plugins can't read private tags from the
3606 // configuration file) 3603 // configuration file)
3607 // https://bugs.orthanc-server.com/show_bug.cgi?id=168 3604 // https://bugs.orthanc-server.com/show_bug.cgi?id=168
3608 std::string privateCreator; 3605 std::string privateCreator;
3606
3607 if (privateCreatorC == NULL)
3609 { 3608 {
3610 OrthancConfiguration::ReaderLock lock; 3609 OrthancConfiguration::ReaderLock lock;
3611 privateCreator = lock.GetConfiguration().GetDefaultPrivateCreator(); 3610 privateCreator = lock.GetConfiguration().GetDefaultPrivateCreator();
3612 } 3611 }
3612 else
3613 {
3614 // New in Orthanc 1.9.0
3615 privateCreator.assign(privateCreatorC);
3616 }
3613 3617
3614 std::unique_ptr<ParsedDicomFile> file 3618 std::unique_ptr<ParsedDicomFile> file
3615 (ParsedDicomFile::CreateFromJson(json, static_cast<DicomFromJsonFlags>(p.flags), 3619 (ParsedDicomFile::CreateFromJson(json, static_cast<DicomFromJsonFlags>(parameters.flags),
3616 privateCreator)); 3620 privateCreator));
3617 3621
3618 if (p.pixelData) 3622 if (parameters.pixelData)
3619 { 3623 {
3620 file->EmbedImage(*reinterpret_cast<const ImageAccessor*>(p.pixelData)); 3624 file->EmbedImage(*reinterpret_cast<const ImageAccessor*>(parameters.pixelData));
3621 } 3625 }
3622 3626
3623 file->SaveToMemoryBuffer(dicom); 3627 file->SaveToMemoryBuffer(dicom);
3624 } 3628 }
3625 3629
3626 CopyToMemoryBuffer(*p.target, dicom); 3630 CopyToMemoryBuffer(*parameters.target, dicom);
3627 } 3631 }
3628 3632
3629 3633
3630 void OrthancPlugins::ComputeHash(_OrthancPluginService service, 3634 void OrthancPlugins::ComputeHash(_OrthancPluginService service,
3631 const void* parameters) 3635 const void* parameters)
4198 case _OrthancPluginService_DicomInstanceToJson: 4202 case _OrthancPluginService_DicomInstanceToJson:
4199 ApplyDicomToJson(service, parameters); 4203 ApplyDicomToJson(service, parameters);
4200 return true; 4204 return true;
4201 4205
4202 case _OrthancPluginService_CreateDicom: 4206 case _OrthancPluginService_CreateDicom:
4203 ApplyCreateDicom(service, parameters); 4207 {
4204 return true; 4208 const _OrthancPluginCreateDicom& p =
4209 *reinterpret_cast<const _OrthancPluginCreateDicom*>(parameters);
4210 ApplyCreateDicom(p, NULL);
4211 return true;
4212 }
4213
4214 case _OrthancPluginService_CreateDicom2:
4215 {
4216 // New in Orthanc 1.9.0
4217 const _OrthancPluginCreateDicom2& p =
4218 *reinterpret_cast<const _OrthancPluginCreateDicom2*>(parameters);
4219 ApplyCreateDicom(p.createDicom, p.privateCreator);
4220 return true;
4221 }
4205 4222
4206 case _OrthancPluginService_WorklistAddAnswer: 4223 case _OrthancPluginService_WorklistAddAnswer:
4207 { 4224 {
4208 const _OrthancPluginWorklistAnswersOperation& p = 4225 const _OrthancPluginWorklistAnswersOperation& p =
4209 *reinterpret_cast<const _OrthancPluginWorklistAnswersOperation*>(parameters); 4226 *reinterpret_cast<const _OrthancPluginWorklistAnswersOperation*>(parameters);