Mercurial > hg > orthanc-stone
diff Framework/dev.h @ 551:90f3a60576a9 dev rtviewer19
Merged in ct-pet-dose-struct (pull request #2)
Ct pet dose struct
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 02 Apr 2019 14:02:12 +0000 |
parents | 1d9deb4ee84c |
children | 573e35378999 |
line wrap: on
line diff
--- a/Framework/dev.h Fri Mar 29 15:21:33 2019 +0100 +++ b/Framework/dev.h Tue Apr 02 14:02:12 2019 +0000 @@ -51,7 +51,7 @@ std::auto_ptr<DownloadStack> downloadStack_; bool computeRange_; size_t pendingSlices_; - + void ScheduleSliceDownload() { assert(downloadStack_.get() != NULL); @@ -70,20 +70,20 @@ if (!GeometryToolbox::IsParallel(a.GetGeometry().GetNormal(), b.GetGeometry().GetNormal())) { - LOG(ERROR) << "Some slice in the volume image is not parallel to the others"; + LOG(ERROR) << "A slice in the volume image is not parallel to the others."; return false; } if (a.GetConverter().GetExpectedPixelFormat() != b.GetConverter().GetExpectedPixelFormat()) { - LOG(ERROR) << "The pixel format changes across the slices of the volume image"; + LOG(ERROR) << "The pixel format changes across the slices of the volume image."; return false; } if (a.GetWidth() != b.GetWidth() || a.GetHeight() != b.GetHeight()) { - LOG(ERROR) << "The width/height of the slices change across the volume image"; + LOG(ERROR) << "The slices dimensions (width/height) are varying throughout the volume image"; return false; } @@ -109,7 +109,7 @@ void OnSliceGeometryReady(const OrthancSlicesLoader::SliceGeometryReadyMessage& message) { assert(&message.GetOrigin() == &loader_); - + if (loader_.GetSliceCount() == 0) { LOG(ERROR) << "Empty volume image"; @@ -156,13 +156,13 @@ LOG(INFO) << "Creating a volume image of size " << width << "x" << height << "x" << loader_.GetSliceCount() << " in " << Orthanc::EnumerationToString(format); - image_.reset(new ImageBuffer3D(format, width, height, loader_.GetSliceCount(), computeRange_)); + image_.reset(new ImageBuffer3D(format, width, height, static_cast<unsigned int>(loader_.GetSliceCount()), computeRange_)); image_->SetAxialGeometry(loader_.GetSlice(0).GetGeometry()); image_->SetVoxelDimensions(loader_.GetSlice(0).GetPixelSpacingX(), loader_.GetSlice(0).GetPixelSpacingY(), spacingZ); image_->Clear(); - downloadStack_.reset(new DownloadStack(loader_.GetSliceCount())); + downloadStack_.reset(new DownloadStack(static_cast<unsigned int>(loader_.GetSliceCount()))); pendingSlices_ = loader_.GetSliceCount(); for (unsigned int i = 0; i < 4; i++) // Limit to 4 simultaneous downloads @@ -175,7 +175,7 @@ EmitMessage(ISlicedVolume::GeometryReadyMessage(*this)); } - + void OnSliceGeometryError(const OrthancSlicesLoader::SliceGeometryErrorMessage& message) { assert(&message.GetOrigin() == &loader_); @@ -184,7 +184,7 @@ EmitMessage(ISlicedVolume::GeometryErrorMessage(*this)); } - + void OnSliceImageReady(const OrthancSlicesLoader::SliceImageReadyMessage& message) { assert(&message.GetOrigin() == &loader_); @@ -210,7 +210,7 @@ ScheduleSliceDownload(); } - + void OnSliceImageError(const OrthancSlicesLoader::SliceImageErrorMessage& message) { assert(&message.GetOrigin() == &loader_); @@ -312,11 +312,11 @@ double sliceThickness_; CoordinateSystem3D reference_; DicomFrameConverter converter_; - + double ComputeAxialThickness(const OrthancVolumeImage& volume) const { double thickness; - + size_t n = volume.GetSliceCount(); if (n > 1) { @@ -342,11 +342,11 @@ return thickness; } } - + void SetupAxial(const OrthancVolumeImage& volume) { const Slice& axial = volume.GetSlice(0); - + width_ = axial.GetWidth(); height_ = axial.GetHeight(); depth_ = volume.GetSliceCount(); @@ -364,7 +364,7 @@ double axialThickness = ComputeAxialThickness(volume); width_ = axial.GetWidth(); - height_ = volume.GetSliceCount(); + height_ = static_cast<unsigned int>(volume.GetSliceCount()); depth_ = axial.GetHeight(); pixelSpacingX_ = axial.GetPixelSpacingX(); @@ -373,11 +373,11 @@ Vector origin = axial.GetGeometry().GetOrigin(); origin += (static_cast<double>(volume.GetSliceCount() - 1) * - axialThickness * axial.GetGeometry().GetNormal()); - + axialThickness * axial.GetGeometry().GetNormal()); + reference_ = CoordinateSystem3D(origin, axial.GetGeometry().GetAxisX(), - -axial.GetGeometry().GetNormal()); + - axial.GetGeometry().GetNormal()); } void SetupSagittal(const OrthancVolumeImage& volume) @@ -386,7 +386,7 @@ double axialThickness = ComputeAxialThickness(volume); width_ = axial.GetHeight(); - height_ = volume.GetSliceCount(); + height_ = static_cast<unsigned int>(volume.GetSliceCount()); depth_ = axial.GetWidth(); pixelSpacingX_ = axial.GetPixelSpacingY(); @@ -395,8 +395,8 @@ Vector origin = axial.GetGeometry().GetOrigin(); origin += (static_cast<double>(volume.GetSliceCount() - 1) * - axialThickness * axial.GetGeometry().GetNormal()); - + axialThickness * axial.GetGeometry().GetNormal()); + reference_ = CoordinateSystem3D(origin, axial.GetGeometry().GetAxisY(), axial.GetGeometry().GetNormal()); @@ -415,20 +415,20 @@ switch (projection) { - case VolumeProjection_Axial: - SetupAxial(volume); - break; + case VolumeProjection_Axial: + SetupAxial(volume); + break; - case VolumeProjection_Coronal: - SetupCoronal(volume); - break; + case VolumeProjection_Coronal: + SetupCoronal(volume); + break; - case VolumeProjection_Sagittal: - SetupSagittal(volume); - break; + case VolumeProjection_Sagittal: + SetupSagittal(volume); + break; - default: - throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + default: + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } } @@ -441,7 +441,7 @@ { return reference_.GetNormal(); } - + bool LookupSlice(size_t& index, const CoordinateSystem3D& slice) const { @@ -452,14 +452,14 @@ { return false; } - + double z = (reference_.ProjectAlongNormal(slice.GetOrigin()) - reference_.ProjectAlongNormal(reference_.GetOrigin())) / sliceThickness_; int s = static_cast<int>(boost::math::iround(z)); if (s < 0 || - s >= static_cast<int>(depth_)) + s >= static_cast<int>(depth_)) { return false; } @@ -507,9 +507,9 @@ RendererFactory(const Orthanc::ImageAccessor& frame, const Slice& slice, bool isFullQuality) : - frame_(frame), - slice_(slice), - isFullQuality_(isFullQuality) + frame_(frame), + slice_(slice), + isFullQuality_(isFullQuality) { } @@ -525,35 +525,35 @@ std::auto_ptr<VolumeImageGeometry> coronalGeometry_; std::auto_ptr<VolumeImageGeometry> sagittalGeometry_; - + bool IsGeometryReady() const { return axialGeometry_.get() != NULL; } - + void OnGeometryReady(const ISlicedVolume::GeometryReadyMessage& message) { assert(&message.GetOrigin() == &volume_); - + // These 3 values are only used to speed up the IVolumeSlicer axialGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Axial)); coronalGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Coronal)); sagittalGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Sagittal)); - + EmitMessage(IVolumeSlicer::GeometryReadyMessage(*this)); } void OnGeometryError(const ISlicedVolume::GeometryErrorMessage& message) { assert(&message.GetOrigin() == &volume_); - + EmitMessage(IVolumeSlicer::GeometryErrorMessage(*this)); } void OnContentChanged(const ISlicedVolume::ContentChangedMessage& message) { assert(&message.GetOrigin() == &volume_); - + EmitMessage(IVolumeSlicer::ContentChangedMessage(*this)); } @@ -576,17 +576,17 @@ switch (projection) { - case VolumeProjection_Axial: - return *axialGeometry_; + case VolumeProjection_Axial: + return *axialGeometry_; - case VolumeProjection_Sagittal: - return *sagittalGeometry_; + case VolumeProjection_Sagittal: + return *sagittalGeometry_; - case VolumeProjection_Coronal: - return *coronalGeometry_; + case VolumeProjection_Coronal: + return *coronalGeometry_; - default: - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + default: + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); } } @@ -625,11 +625,11 @@ public: - VolumeImageMPRSlicer(MessageBroker& broker, + VolumeImageMPRSlicer(MessageBroker& broker, OrthancVolumeImage& volume) : - IVolumeSlicer(broker), - IObserver(broker), - volume_(volume) + IVolumeSlicer(broker), + IObserver(broker), + volume_(volume) { volume_.RegisterObserverCallback( new Callable<VolumeImageMPRSlicer, ISlicedVolume::GeometryReadyMessage> @@ -652,7 +652,7 @@ const CoordinateSystem3D& viewportSlice) ORTHANC_OVERRIDE { VolumeProjection projection; - + if (!IsGeometryReady() || !DetectProjection(projection, viewportSlice)) { @@ -664,16 +664,15 @@ // we only consider one single reference slice (the one with index 0). std::auto_ptr<Slice> slice(GetProjectionGeometry(projection).GetSlice(0)); slice->GetExtent(points); - + return true; } } - virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice) ORTHANC_OVERRIDE { VolumeProjection projection; - + if (IsGeometryReady() && DetectProjection(projection, viewportSlice)) { @@ -688,7 +687,7 @@ std::auto_ptr<Orthanc::Image> frame; { - ImageBuffer3D::SliceReader reader(volume_.GetImage(), projection, closest); + ImageBuffer3D::SliceReader reader(volume_.GetImage(), projection, static_cast<unsigned int>(closest)); // TODO Transfer ownership if non-axial, to avoid memcpy frame.reset(Orthanc::Image::Clone(reader.GetAccessor())); @@ -738,11 +737,15 @@ virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& widget, const ViewportGeometry& view, MouseButton button, + KeyboardModifiers modifiers, + int viewportX, + int viewportY, double x, double y, - IStatusBar* statusBar) + IStatusBar* statusBar, + const std::vector<Touch>& touches) ORTHANC_OVERRIDE { - return NULL; + return NULL; } virtual void MouseOver(CairoContext& context, @@ -750,29 +753,29 @@ const ViewportGeometry& view, double x, double y, - IStatusBar* statusBar) + IStatusBar* statusBar) ORTHANC_OVERRIDE { } virtual void MouseWheel(WorldSceneWidget& widget, MouseWheelDirection direction, KeyboardModifiers modifiers, - IStatusBar* statusBar) + IStatusBar* statusBar) ORTHANC_OVERRIDE { int scale = (modifiers & KeyboardModifiers_Control ? 10 : 1); switch (direction) { - case MouseWheelDirection_Up: - OffsetSlice(-scale); - break; + case MouseWheelDirection_Up: + OffsetSlice(-scale); + break; - case MouseWheelDirection_Down: - OffsetSlice(scale); - break; + case MouseWheelDirection_Down: + OffsetSlice(scale); + break; - default: - break; + default: + break; } } @@ -780,16 +783,16 @@ KeyboardKeys key, char keyChar, KeyboardModifiers modifiers, - IStatusBar* statusBar) + IStatusBar* statusBar) ORTHANC_OVERRIDE { switch (keyChar) { - case 's': - widget.FitContent(); - break; + case 's': + widget.FitContent(); + break; - default: - break; + default: + break; } } @@ -798,9 +801,9 @@ OrthancVolumeImage& volume, SliceViewerWidget& widget, VolumeProjection projection) : - IObserver(broker), - widget_(widget), - projection_(projection) + IObserver(broker), + widget_(widget), + projection_(projection) { widget.SetInteractor(*this); @@ -839,7 +842,7 @@ if (slice >= static_cast<int>(slices_->GetSliceCount())) { - slice = slices_->GetSliceCount() - 1; + slice = static_cast<unsigned int>(slices_->GetSliceCount()) - 1; } if (slice != static_cast<int>(slice_)) @@ -898,7 +901,7 @@ SliceViewerWidget& otherPlane_; public: - ReferenceLineSource(MessageBroker& broker, + ReferenceLineSource(MessageBroker& broker, SliceViewerWidget& otherPlane) : IVolumeSlicer(broker), otherPlane_(otherPlane) @@ -915,7 +918,7 @@ virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice) { Slice reference(viewportSlice, 0.001); - + Vector p, d; const CoordinateSystem3D& slice = otherPlane_.GetSlice(); @@ -935,7 +938,7 @@ viewportSlice.ProjectPoint(x2, y2, p + 1000.0 * d); const Extent2D extent = otherPlane_.GetSceneExtent(); - + if (GeometryToolbox::ClipLineToRectangle(x1, y1, x2, y2, x1, y1, x2, y2, extent.GetX1(), extent.GetY1(),