comparison Framework/Radiography/RadiographyScene.cpp @ 1298:8a0a62189f46

replacing std::auto_ptr by std::unique_ptr
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 02 Mar 2020 16:31:30 +0100
parents 4f8fc8dbd2a1
children 257f2c9a02ac d4e6cd35107b
comparison
equal deleted inserted replaced
1296:86400fa16091 1298:8a0a62189f46
125 } 125 }
126 } 126 }
127 127
128 void RadiographyScene::_RegisterLayer(RadiographyLayer* layer) 128 void RadiographyScene::_RegisterLayer(RadiographyLayer* layer)
129 { 129 {
130 std::auto_ptr<RadiographyLayer> raii(layer); 130 std::unique_ptr<RadiographyLayer> raii(layer);
131 131
132 // LOG(INFO) << "Registering layer: " << countLayers_; 132 // LOG(INFO) << "Registering layer: " << countLayers_;
133 133
134 size_t index = nextLayerIndex_++; 134 size_t index = nextLayerIndex_++;
135 raii->SetIndex(index); 135 raii->SetIndex(index);
323 unsigned int fontSize, 323 unsigned int fontSize,
324 uint8_t foreground, 324 uint8_t foreground,
325 RadiographyLayer::Geometry* centerGeometry, 325 RadiographyLayer::Geometry* centerGeometry,
326 bool isCenterGeometry) 326 bool isCenterGeometry)
327 { 327 {
328 std::auto_ptr<RadiographyTextLayer> alpha(new RadiographyTextLayer(IObservable::GetBroker(), *this)); 328 std::unique_ptr<RadiographyTextLayer> alpha(new RadiographyTextLayer(IObservable::GetBroker(), *this));
329 alpha->SetText(utf8, font, fontSize, foreground); 329 alpha->SetText(utf8, font, fontSize, foreground);
330 if (centerGeometry != NULL) 330 if (centerGeometry != NULL)
331 { 331 {
332 if (isCenterGeometry) 332 if (isCenterGeometry)
333 { 333 {
351 351
352 RadiographyLayer& RadiographyScene::LoadTestBlock(unsigned int width, 352 RadiographyLayer& RadiographyScene::LoadTestBlock(unsigned int width,
353 unsigned int height, 353 unsigned int height,
354 RadiographyLayer::Geometry* geometry) 354 RadiographyLayer::Geometry* geometry)
355 { 355 {
356 std::auto_ptr<Orthanc::Image> block(new Orthanc::Image(Orthanc::PixelFormat_Grayscale8, width, height, false)); 356 std::unique_ptr<Orthanc::Image> block(new Orthanc::Image(Orthanc::PixelFormat_Grayscale8, width, height, false));
357 357
358 for (unsigned int padding = 0; 358 for (unsigned int padding = 0;
359 (width > 2 * padding) && (height > 2 * padding); 359 (width > 2 * padding) && (height > 2 * padding);
360 padding++) 360 padding++)
361 { 361 {
380 RadiographyLayer& RadiographyScene::LoadMask(const std::vector<Orthanc::ImageProcessing::ImagePoint>& corners, 380 RadiographyLayer& RadiographyScene::LoadMask(const std::vector<Orthanc::ImageProcessing::ImagePoint>& corners,
381 const RadiographyDicomLayer& dicomLayer, 381 const RadiographyDicomLayer& dicomLayer,
382 float foreground, 382 float foreground,
383 RadiographyLayer::Geometry* geometry) 383 RadiographyLayer::Geometry* geometry)
384 { 384 {
385 std::auto_ptr<RadiographyMaskLayer> mask(new RadiographyMaskLayer(IObservable::GetBroker(), *this, dicomLayer, foreground)); 385 std::unique_ptr<RadiographyMaskLayer> mask(new RadiographyMaskLayer(IObservable::GetBroker(), *this, dicomLayer, foreground));
386 mask->SetCorners(corners); 386 mask->SetCorners(corners);
387 if (geometry != NULL) 387 if (geometry != NULL)
388 { 388 {
389 mask->SetGeometry(*geometry); 389 mask->SetGeometry(*geometry);
390 } 390 }
393 } 393 }
394 394
395 395
396 RadiographyLayer& RadiographyScene::LoadAlphaBitmap(Orthanc::ImageAccessor* bitmap, RadiographyLayer::Geometry *geometry) 396 RadiographyLayer& RadiographyScene::LoadAlphaBitmap(Orthanc::ImageAccessor* bitmap, RadiographyLayer::Geometry *geometry)
397 { 397 {
398 std::auto_ptr<RadiographyAlphaLayer> alpha(new RadiographyAlphaLayer(IObservable::GetBroker(), *this)); 398 std::unique_ptr<RadiographyAlphaLayer> alpha(new RadiographyAlphaLayer(IObservable::GetBroker(), *this));
399 alpha->SetAlpha(bitmap); 399 alpha->SetAlpha(bitmap);
400 if (geometry != NULL) 400 if (geometry != NULL)
401 { 401 {
402 alpha->SetGeometry(*geometry); 402 alpha->SetGeometry(*geometry);
403 } 403 }
532 if (message.GetAnswerSize() > 0) 532 if (message.GetAnswerSize() > 0)
533 { 533 {
534 content.assign(reinterpret_cast<const char*>(message.GetAnswer()), message.GetAnswerSize()); 534 content.assign(reinterpret_cast<const char*>(message.GetAnswer()), message.GetAnswerSize());
535 } 535 }
536 536
537 std::auto_ptr<Orthanc::PamReader> reader(new Orthanc::PamReader); 537 std::unique_ptr<Orthanc::PamReader> reader(new Orthanc::PamReader);
538 reader->ReadFromMemory(content); 538 reader->ReadFromMemory(content);
539 dynamic_cast<RadiographyDicomLayer*>(layer->second)->SetSourceImage(reader.release()); 539 dynamic_cast<RadiographyDicomLayer*>(layer->second)->SetSourceImage(reader.release());
540 540
541 BroadcastMessage(ContentChangedMessage(*this, *(layer->second))); 541 BroadcastMessage(ContentChangedMessage(*this, *(layer->second)));
542 } 542 }
723 Orthanc::ImageProcessing::Set(layers, 0); 723 Orthanc::ImageProcessing::Set(layers, 0);
724 } 724 }
725 725
726 Render(layers, view, interpolation, applyWindowing); 726 Render(layers, view, interpolation, applyWindowing);
727 727
728 std::auto_ptr<Orthanc::Image> rendered(new Orthanc::Image(Orthanc::PixelFormat_Grayscale16, 728 std::unique_ptr<Orthanc::Image> rendered(new Orthanc::Image(Orthanc::PixelFormat_Grayscale16,
729 layers.GetWidth(), layers.GetHeight(), false)); 729 layers.GetWidth(), layers.GetHeight(), false));
730 730
731 Orthanc::ImageProcessing::Convert(*rendered, layers); 731 Orthanc::ImageProcessing::Convert(*rendered, layers);
732 if (invert) 732 if (invert)
733 Orthanc::ImageProcessing::Invert(*rendered, maxValue); 733 Orthanc::ImageProcessing::Invert(*rendered, maxValue);
744 bool invert, 744 bool invert,
745 ImageInterpolation interpolation) 745 ImageInterpolation interpolation)
746 { 746 {
747 LOG(INFO) << "Exporting RadiographyScene to DICOM"; 747 LOG(INFO) << "Exporting RadiographyScene to DICOM";
748 748
749 std::auto_ptr<Orthanc::Image> rendered(ExportToImage(pixelSpacingX, pixelSpacingY, interpolation, false)); // note: we don't invert the image in the pixels data because we'll set the PhotometricDisplayMode correctly in the DICOM tags 749 std::unique_ptr<Orthanc::Image> rendered(ExportToImage(pixelSpacingX, pixelSpacingY, interpolation, false)); // note: we don't invert the image in the pixels data because we'll set the PhotometricDisplayMode correctly in the DICOM tags
750 750
751 createDicomRequestContent["Tags"] = dicomTags; 751 createDicomRequestContent["Tags"] = dicomTags;
752 752
753 RadiographyPhotometricDisplayMode photometricMode = GetPreferredPhotomotricDisplayMode(); 753 RadiographyPhotometricDisplayMode photometricMode = GetPreferredPhotomotricDisplayMode();
754 if ((invert && photometricMode != RadiographyPhotometricDisplayMode_Monochrome2) || 754 if ((invert && photometricMode != RadiographyPhotometricDisplayMode_Monochrome2) ||
799 bool usePam) 799 bool usePam)
800 { 800 {
801 LOG(INFO) << "Exporting RadiographyScene to DICOM"; 801 LOG(INFO) << "Exporting RadiographyScene to DICOM";
802 VLOG(1) << "Exporting RadiographyScene to: export to image"; 802 VLOG(1) << "Exporting RadiographyScene to: export to image";
803 803
804 std::auto_ptr<Orthanc::Image> rendered(ExportToCreateDicomRequestAndImage(createDicomRequestContent, dicomTags, parentOrthancId, pixelSpacingX, pixelSpacingY, invert, interpolation)); 804 std::unique_ptr<Orthanc::Image> rendered(ExportToCreateDicomRequestAndImage(createDicomRequestContent, dicomTags, parentOrthancId, pixelSpacingX, pixelSpacingY, invert, interpolation));
805 805
806 // convert the image into base64 for inclusing in the createDicomRequest 806 // convert the image into base64 for inclusing in the createDicomRequest
807 std::string base64; 807 std::string base64;
808 808
809 { 809 {