Mercurial > hg > orthanc-stone
comparison Framework/dev.h @ 624:573e35378999
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 May 2019 14:28:10 +0200 |
parents | 1d9deb4ee84c |
children | 6af3099ed8da |
comparison
equal
deleted
inserted
replaced
623:42dadae61fa9 | 624:573e35378999 |
---|---|
111 assert(&message.GetOrigin() == &loader_); | 111 assert(&message.GetOrigin() == &loader_); |
112 | 112 |
113 if (loader_.GetSliceCount() == 0) | 113 if (loader_.GetSliceCount() == 0) |
114 { | 114 { |
115 LOG(ERROR) << "Empty volume image"; | 115 LOG(ERROR) << "Empty volume image"; |
116 EmitMessage(ISlicedVolume::GeometryErrorMessage(*this)); | 116 BroadcastMessage(ISlicedVolume::GeometryErrorMessage(*this)); |
117 return; | 117 return; |
118 } | 118 } |
119 | 119 |
120 for (size_t i = 1; i < loader_.GetSliceCount(); i++) | 120 for (size_t i = 1; i < loader_.GetSliceCount(); i++) |
121 { | 121 { |
122 if (!IsCompatible(loader_.GetSlice(0), loader_.GetSlice(i))) | 122 if (!IsCompatible(loader_.GetSlice(0), loader_.GetSlice(i))) |
123 { | 123 { |
124 EmitMessage(ISlicedVolume::GeometryErrorMessage(*this)); | 124 BroadcastMessage(ISlicedVolume::GeometryErrorMessage(*this)); |
125 return; | 125 return; |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 double spacingZ; | 129 double spacingZ; |
143 { | 143 { |
144 if (!LinearAlgebra::IsNear(spacingZ, GetDistance(loader_.GetSlice(i - 1), loader_.GetSlice(i)), | 144 if (!LinearAlgebra::IsNear(spacingZ, GetDistance(loader_.GetSlice(i - 1), loader_.GetSlice(i)), |
145 0.001 /* this is expressed in mm */)) | 145 0.001 /* this is expressed in mm */)) |
146 { | 146 { |
147 LOG(ERROR) << "The distance between successive slices is not constant in a volume image"; | 147 LOG(ERROR) << "The distance between successive slices is not constant in a volume image"; |
148 EmitMessage(ISlicedVolume::GeometryErrorMessage(*this)); | 148 BroadcastMessage(ISlicedVolume::GeometryErrorMessage(*this)); |
149 return; | 149 return; |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 unsigned int width = loader_.GetSlice(0).GetWidth(); | 153 unsigned int width = loader_.GetSlice(0).GetWidth(); |
170 ScheduleSliceDownload(); | 170 ScheduleSliceDownload(); |
171 } | 171 } |
172 | 172 |
173 // TODO Check the DicomFrameConverter are constant | 173 // TODO Check the DicomFrameConverter are constant |
174 | 174 |
175 EmitMessage(ISlicedVolume::GeometryReadyMessage(*this)); | 175 BroadcastMessage(ISlicedVolume::GeometryReadyMessage(*this)); |
176 } | 176 } |
177 | 177 |
178 | 178 |
179 void OnSliceGeometryError(const OrthancSlicesLoader::SliceGeometryErrorMessage& message) | 179 void OnSliceGeometryError(const OrthancSlicesLoader::SliceGeometryErrorMessage& message) |
180 { | 180 { |
181 assert(&message.GetOrigin() == &loader_); | 181 assert(&message.GetOrigin() == &loader_); |
182 | 182 |
183 LOG(ERROR) << "Unable to download a volume image"; | 183 LOG(ERROR) << "Unable to download a volume image"; |
184 EmitMessage(ISlicedVolume::GeometryErrorMessage(*this)); | 184 BroadcastMessage(ISlicedVolume::GeometryErrorMessage(*this)); |
185 } | 185 } |
186 | 186 |
187 | 187 |
188 void OnSliceImageReady(const OrthancSlicesLoader::SliceImageReadyMessage& message) | 188 void OnSliceImageReady(const OrthancSlicesLoader::SliceImageReadyMessage& message) |
189 { | 189 { |
192 { | 192 { |
193 ImageBuffer3D::SliceWriter writer(*image_, VolumeProjection_Axial, message.GetSliceIndex()); | 193 ImageBuffer3D::SliceWriter writer(*image_, VolumeProjection_Axial, message.GetSliceIndex()); |
194 Orthanc::ImageProcessing::Copy(writer.GetAccessor(), message.GetImage()); | 194 Orthanc::ImageProcessing::Copy(writer.GetAccessor(), message.GetImage()); |
195 } | 195 } |
196 | 196 |
197 EmitMessage(ISlicedVolume::SliceContentChangedMessage | 197 BroadcastMessage(ISlicedVolume::SliceContentChangedMessage |
198 (*this, message.GetSliceIndex(), message.GetSlice())); | 198 (*this, message.GetSliceIndex(), message.GetSlice())); |
199 | 199 |
200 if (pendingSlices_ == 1) | 200 if (pendingSlices_ == 1) |
201 { | 201 { |
202 EmitMessage(ISlicedVolume::VolumeReadyMessage(*this)); | 202 BroadcastMessage(ISlicedVolume::VolumeReadyMessage(*this)); |
203 pendingSlices_ = 0; | 203 pendingSlices_ = 0; |
204 } | 204 } |
205 else if (pendingSlices_ > 1) | 205 else if (pendingSlices_ > 1) |
206 { | 206 { |
207 pendingSlices_ -= 1; | 207 pendingSlices_ -= 1; |
538 // These 3 values are only used to speed up the IVolumeSlicer | 538 // These 3 values are only used to speed up the IVolumeSlicer |
539 axialGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Axial)); | 539 axialGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Axial)); |
540 coronalGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Coronal)); | 540 coronalGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Coronal)); |
541 sagittalGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Sagittal)); | 541 sagittalGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Sagittal)); |
542 | 542 |
543 EmitMessage(IVolumeSlicer::GeometryReadyMessage(*this)); | 543 BroadcastMessage(IVolumeSlicer::GeometryReadyMessage(*this)); |
544 } | 544 } |
545 | 545 |
546 void OnGeometryError(const ISlicedVolume::GeometryErrorMessage& message) | 546 void OnGeometryError(const ISlicedVolume::GeometryErrorMessage& message) |
547 { | 547 { |
548 assert(&message.GetOrigin() == &volume_); | 548 assert(&message.GetOrigin() == &volume_); |
549 | 549 |
550 EmitMessage(IVolumeSlicer::GeometryErrorMessage(*this)); | 550 BroadcastMessage(IVolumeSlicer::GeometryErrorMessage(*this)); |
551 } | 551 } |
552 | 552 |
553 void OnContentChanged(const ISlicedVolume::ContentChangedMessage& message) | 553 void OnContentChanged(const ISlicedVolume::ContentChangedMessage& message) |
554 { | 554 { |
555 assert(&message.GetOrigin() == &volume_); | 555 assert(&message.GetOrigin() == &volume_); |
556 | 556 |
557 EmitMessage(IVolumeSlicer::ContentChangedMessage(*this)); | 557 BroadcastMessage(IVolumeSlicer::ContentChangedMessage(*this)); |
558 } | 558 } |
559 | 559 |
560 void OnSliceContentChanged(const ISlicedVolume::SliceContentChangedMessage& message) | 560 void OnSliceContentChanged(const ISlicedVolume::SliceContentChangedMessage& message) |
561 { | 561 { |
562 assert(&message.GetOrigin() == &volume_); | 562 assert(&message.GetOrigin() == &volume_); |
563 | 563 |
564 //IVolumeSlicer::OnSliceContentChange(slice); | 564 //IVolumeSlicer::OnSliceContentChange(slice); |
565 | 565 |
566 // TODO Improve this? | 566 // TODO Improve this? |
567 EmitMessage(IVolumeSlicer::ContentChangedMessage(*this)); | 567 BroadcastMessage(IVolumeSlicer::ContentChangedMessage(*this)); |
568 } | 568 } |
569 | 569 |
570 const VolumeImageGeometry& GetProjectionGeometry(VolumeProjection projection) | 570 const VolumeImageGeometry& GetProjectionGeometry(VolumeProjection projection) |
571 { | 571 { |
572 if (!IsGeometryReady()) | 572 if (!IsGeometryReady()) |
695 | 695 |
696 std::auto_ptr<Slice> slice(geometry.GetSlice(closest)); | 696 std::auto_ptr<Slice> slice(geometry.GetSlice(closest)); |
697 | 697 |
698 RendererFactory factory(*frame, *slice, isFullQuality); | 698 RendererFactory factory(*frame, *slice, isFullQuality); |
699 | 699 |
700 EmitMessage(IVolumeSlicer::LayerReadyMessage(*this, factory, slice->GetGeometry())); | 700 BroadcastMessage(IVolumeSlicer::LayerReadyMessage(*this, factory, slice->GetGeometry())); |
701 return; | 701 return; |
702 } | 702 } |
703 } | 703 } |
704 | 704 |
705 // Error | 705 // Error |
706 CoordinateSystem3D slice; | 706 CoordinateSystem3D slice; |
707 EmitMessage(IVolumeSlicer::LayerErrorMessage(*this, slice)); | 707 BroadcastMessage(IVolumeSlicer::LayerErrorMessage(*this, slice)); |
708 } | 708 } |
709 }; | 709 }; |
710 | 710 |
711 | 711 |
712 class VolumeImageInteractor : | 712 class VolumeImageInteractor : |
904 ReferenceLineSource(MessageBroker& broker, | 904 ReferenceLineSource(MessageBroker& broker, |
905 SliceViewerWidget& otherPlane) : | 905 SliceViewerWidget& otherPlane) : |
906 IVolumeSlicer(broker), | 906 IVolumeSlicer(broker), |
907 otherPlane_(otherPlane) | 907 otherPlane_(otherPlane) |
908 { | 908 { |
909 EmitMessage(IVolumeSlicer::GeometryReadyMessage(*this)); | 909 BroadcastMessage(IVolumeSlicer::GeometryReadyMessage(*this)); |
910 } | 910 } |
911 | 911 |
912 virtual bool GetExtent(std::vector<Vector>& points, | 912 virtual bool GetExtent(std::vector<Vector>& points, |
913 const CoordinateSystem3D& viewportSlice) | 913 const CoordinateSystem3D& viewportSlice) |
914 { | 914 { |
927 if (!GeometryToolbox::IntersectTwoPlanes(p, d, | 927 if (!GeometryToolbox::IntersectTwoPlanes(p, d, |
928 slice.GetOrigin(), slice.GetNormal(), | 928 slice.GetOrigin(), slice.GetNormal(), |
929 viewportSlice.GetOrigin(), viewportSlice.GetNormal())) | 929 viewportSlice.GetOrigin(), viewportSlice.GetNormal())) |
930 { | 930 { |
931 // The two slice are parallel, don't try and display the intersection | 931 // The two slice are parallel, don't try and display the intersection |
932 EmitMessage(IVolumeSlicer::LayerErrorMessage(*this, reference.GetGeometry())); | 932 BroadcastMessage(IVolumeSlicer::LayerErrorMessage(*this, reference.GetGeometry())); |
933 } | 933 } |
934 else | 934 else |
935 { | 935 { |
936 double x1, y1, x2, y2; | 936 double x1, y1, x2, y2; |
937 viewportSlice.ProjectPoint(x1, y1, p); | 937 viewportSlice.ProjectPoint(x1, y1, p); |
943 x1, y1, x2, y2, | 943 x1, y1, x2, y2, |
944 extent.GetX1(), extent.GetY1(), | 944 extent.GetX1(), extent.GetY1(), |
945 extent.GetX2(), extent.GetY2())) | 945 extent.GetX2(), extent.GetY2())) |
946 { | 946 { |
947 RendererFactory factory(x1, y1, x2, y2, slice); | 947 RendererFactory factory(x1, y1, x2, y2, slice); |
948 EmitMessage(IVolumeSlicer::LayerReadyMessage(*this, factory, reference.GetGeometry())); | 948 BroadcastMessage(IVolumeSlicer::LayerReadyMessage(*this, factory, reference.GetGeometry())); |
949 } | 949 } |
950 else | 950 else |
951 { | 951 { |
952 // Error: Parallel slices | 952 // Error: Parallel slices |
953 EmitMessage(IVolumeSlicer::LayerErrorMessage(*this, reference.GetGeometry())); | 953 BroadcastMessage(IVolumeSlicer::LayerErrorMessage(*this, reference.GetGeometry())); |
954 } | 954 } |
955 } | 955 } |
956 } | 956 } |
957 }; | 957 }; |
958 } | 958 } |