comparison Samples/Sdl/Loader.cpp @ 779:e72a9fef3d19

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 27 May 2019 10:34:34 +0200
parents 78fcb907caf6
children f81655ed96ab
comparison
equal deleted inserted replaced
778:78fcb907caf6 779:e72a9fef3d19
766 CoordinateSystem3D geometry = instance->GetGeometry(); 766 CoordinateSystem3D geometry = instance->GetGeometry();
767 slices.AddSlice(geometry, instance.release()); 767 slices.AddSlice(geometry, instance.release());
768 } 768 }
769 769
770 volume_.SetGeometry(slices); 770 volume_.SetGeometry(slices);
771
772 BroadcastMessage(VolumeGeometryReadyMessage(*this, volume_.GetGeometry()));
773 } 771 }
774 772
775 if (volume_.GetSlicesCount() != 0) 773 if (volume_.GetSlicesCount() != 0)
776 { 774 {
777 strategy_.reset(new BasicFetchingStrategy(sorter_->CreateSorter( 775 strategy_.reset(new BasicFetchingStrategy(sorter_->CreateSorter(
781 for (unsigned int i = 0; i < simultaneousDownloads_; i++) 779 for (unsigned int i = 0; i < simultaneousDownloads_; i++)
782 { 780 {
783 ScheduleNextSliceDownload(); 781 ScheduleNextSliceDownload();
784 } 782 }
785 } 783 }
784
785 BroadcastMessage(VolumeGeometryReadyMessage(*this, volume_.GetGeometry()));
786 } 786 }
787 787
788 788
789 void LoadBestQualitySliceContent(const GetOrthancImageCommand::SuccessMessage& message) 789 void LoadBestQualitySliceContent(const GetOrthancImageCommand::SuccessMessage& message)
790 { 790 {
898 { 898 {
899 std::auto_ptr<DicomVolumeImageOrthogonalSlice> slice 899 std::auto_ptr<DicomVolumeImageOrthogonalSlice> slice
900 (new DicomSeriesVolumeImage::ExtractedOrthogonalSlice(volume_, cuttingPlane)); 900 (new DicomSeriesVolumeImage::ExtractedOrthogonalSlice(volume_, cuttingPlane));
901 901
902 assert(slice.get() != NULL && 902 assert(slice.get() != NULL &&
903 strategy_.get() != NULL); 903 strategy_.get() != NULL);
904 904
905 if (slice->IsValid() && 905 if (slice->IsValid() &&
906 slice->GetProjection() == VolumeProjection_Axial) 906 slice->GetProjection() == VolumeProjection_Axial)
907 { 907 {
908 strategy_->SetCurrent(slice->GetSliceIndex()); 908 strategy_->SetCurrent(slice->GetSliceIndex());
1591 OrthancStone::IOracle& oracle_; 1591 OrthancStone::IOracle& oracle_;
1592 OrthancStone::Scene2D scene_; 1592 OrthancStone::Scene2D scene_;
1593 std::auto_ptr<OrthancStone::VolumeSceneLayerSource> source1_, source2_; 1593 std::auto_ptr<OrthancStone::VolumeSceneLayerSource> source1_, source2_;
1594 1594
1595 1595
1596 void Refresh()
1597 {
1598 if (source1_.get() != NULL)
1599 {
1600 source1_->Update(plane_);
1601 }
1602
1603 if (source2_.get() != NULL)
1604 {
1605 source2_->Update(plane_);
1606 }
1607
1608 scene_.FitContent(1024, 768);
1609
1610 {
1611 OrthancStone::CairoCompositor compositor(scene_, 1024, 768);
1612 compositor.Refresh();
1613
1614 Orthanc::ImageAccessor accessor;
1615 compositor.GetCanvas().GetReadOnlyAccessor(accessor);
1616
1617 Orthanc::Image tmp(Orthanc::PixelFormat_RGB24, accessor.GetWidth(), accessor.GetHeight(), false);
1618 Orthanc::ImageProcessing::Convert(tmp, accessor);
1619
1620 static unsigned int count = 0;
1621 char buf[64];
1622 sprintf(buf, "scene-%06d.png", count++);
1623
1624 Orthanc::PngWriter writer;
1625 writer.WriteToFile(buf, tmp);
1626 }
1627 }
1628
1629
1596 void Handle(const OrthancStone::VolumeGeometryReadyMessage& message) 1630 void Handle(const OrthancStone::VolumeGeometryReadyMessage& message)
1597 { 1631 {
1598 printf("Geometry ready\n"); 1632 printf("Geometry ready\n");
1599 1633
1600 if (&source1_->GetSlicer() == &message.GetOrigin()) 1634 if (&source1_->GetSlicer() == &message.GetOrigin())
1602 //plane_ = message.GetGeometry().GetSagittalGeometry(); 1636 //plane_ = message.GetGeometry().GetSagittalGeometry();
1603 //plane_ = message.GetGeometry().GetAxialGeometry(); 1637 //plane_ = message.GetGeometry().GetAxialGeometry();
1604 plane_ = message.GetGeometry().GetCoronalGeometry(); 1638 plane_ = message.GetGeometry().GetCoronalGeometry();
1605 plane_.SetOrigin(message.GetGeometry().GetCoordinates(0.5f, 0.5f, 0.5f)); 1639 plane_.SetOrigin(message.GetGeometry().GetCoordinates(0.5f, 0.5f, 0.5f));
1606 } 1640 }
1641
1642 Refresh();
1607 } 1643 }
1608 1644
1609 1645
1610 void Handle(const OrthancStone::SleepOracleCommand::TimeoutMessage& message) 1646 void Handle(const OrthancStone::SleepOracleCommand::TimeoutMessage& message)
1611 { 1647 {
1615 } 1651 }
1616 else 1652 else
1617 { 1653 {
1618 printf("TIMEOUT\n"); 1654 printf("TIMEOUT\n");
1619 1655
1620 if (source1_.get() != NULL) 1656 Refresh();
1621 {
1622 source1_->Update(plane_);
1623 }
1624
1625 if (source2_.get() != NULL)
1626 {
1627 source2_->Update(plane_);
1628 }
1629
1630 scene_.FitContent(1024, 768);
1631
1632 {
1633 OrthancStone::CairoCompositor compositor(scene_, 1024, 768);
1634 compositor.Refresh();
1635
1636 Orthanc::ImageAccessor accessor;
1637 compositor.GetCanvas().GetReadOnlyAccessor(accessor);
1638
1639 Orthanc::Image tmp(Orthanc::PixelFormat_RGB24, accessor.GetWidth(), accessor.GetHeight(), false);
1640 Orthanc::ImageProcessing::Convert(tmp, accessor);
1641
1642 static unsigned int count = 0;
1643 char buf[64];
1644 sprintf(buf, "scene-%06d.png", count++);
1645
1646 Orthanc::PngWriter writer;
1647 writer.WriteToFile(buf, tmp);
1648 }
1649 1657
1650 /** 1658 /**
1651 * The sleep() leads to a crash if the oracle is still running, 1659 * The sleep() leads to a crash if the oracle is still running,
1652 * while this object is destroyed. Always stop the oracle before 1660 * while this object is destroyed. Always stop the oracle before
1653 * destroying active objects. (*) 1661 * destroying active objects. (*)