Mercurial > hg > orthanc-stone
changeset 112:948f86e61e83 wasm
start of SliceLocationSource
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 20 Sep 2017 14:37:08 +0200 |
parents | 7665ccbf33db |
children | 2eca030792aa |
files | Framework/Layers/ILayerSource.h Framework/Layers/LineLayerRenderer.cpp Framework/Layers/LineLayerRenderer.h Framework/Widgets/LayerWidget.h Framework/Widgets/WorldSceneWidget.h Framework/dev.h |
diffstat | 6 files changed, 88 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Layers/ILayerSource.h Wed Jun 14 15:54:06 2017 +0200 +++ b/Framework/Layers/ILayerSource.h Wed Sep 20 14:37:08 2017 +0200 @@ -55,8 +55,8 @@ // std::auto_ptr virtual void NotifyLayerReady(std::auto_ptr<ILayerRenderer>& layer, const ILayerSource& source, - const Slice& slice, - bool isError) = 0; + const Slice& slice, // TODO Shouldn't this be CoordinateSystem3D? Is it necessary given ILayerS::GetLayerSlice()? + bool isError) = 0; // TODO Shouldn't this be separate as NotifyLayerError? }; virtual ~ILayerSource()
--- a/Framework/Layers/LineLayerRenderer.cpp Wed Jun 14 15:54:06 2017 +0200 +++ b/Framework/Layers/LineLayerRenderer.cpp Wed Sep 20 14:37:08 2017 +0200 @@ -26,11 +26,13 @@ LineLayerRenderer::LineLayerRenderer(double x1, double y1, double x2, - double y2) : + double y2, + const CoordinateSystem3D& slice) : x1_(x1), y1_(y1), x2_(x2), - y2_(y2) + y2_(y2), + slice_(slice) { RenderStyle style; SetLayerStyle(style); @@ -38,8 +40,7 @@ bool LineLayerRenderer::RenderLayer(CairoContext& context, - const ViewportGeometry& view, - const CoordinateSystem3D& slice) + const ViewportGeometry& view) { if (visible_) {
--- a/Framework/Layers/LineLayerRenderer.h Wed Jun 14 15:54:06 2017 +0200 +++ b/Framework/Layers/LineLayerRenderer.h Wed Sep 20 14:37:08 2017 +0200 @@ -28,25 +28,31 @@ class LineLayerRenderer : public ILayerRenderer { private: - double x1_; - double y1_; - double x2_; - double y2_; - bool visible_; - uint8_t color_[3]; + double x1_; + double y1_; + double x2_; + double y2_; + CoordinateSystem3D slice_; + bool visible_; + uint8_t color_[3]; public: LineLayerRenderer(double x1, double y1, double x2, - double y2); + double y2, + const CoordinateSystem3D& slice); virtual bool RenderLayer(CairoContext& context, - const ViewportGeometry& view, - const CoordinateSystem3D& slice); + const ViewportGeometry& view); virtual void SetLayerStyle(const RenderStyle& style); + virtual const CoordinateSystem3D& GetLayerSlice() + { + return slice_; + } + virtual bool IsFullQuality() { return true;
--- a/Framework/Widgets/LayerWidget.h Wed Jun 14 15:54:06 2017 +0200 +++ b/Framework/Widgets/LayerWidget.h Wed Sep 20 14:37:08 2017 +0200 @@ -68,10 +68,11 @@ bool isError); void ResetChangedLayers(); - - protected: + + public: virtual Extent2D GetSceneExtent(); + protected: virtual bool RenderScene(CairoContext& context, const ViewportGeometry& view);
--- a/Framework/Widgets/WorldSceneWidget.h Wed Jun 14 15:54:06 2017 +0200 +++ b/Framework/Widgets/WorldSceneWidget.h Wed Sep 20 14:37:08 2017 +0200 @@ -59,10 +59,10 @@ Observers observers_; IWorldSceneInteractor* interactor_; + public: + virtual Extent2D GetSceneExtent() = 0; protected: - virtual Extent2D GetSceneExtent() = 0; - virtual bool RenderScene(CairoContext& context, const ViewportGeometry& view) = 0;
--- a/Framework/dev.h Wed Jun 14 15:54:06 2017 +0200 +++ b/Framework/dev.h Wed Sep 20 14:37:08 2017 +0200 @@ -24,6 +24,7 @@ #include "Layers/FrameRenderer.h" #include "Layers/LayerSourceBase.h" #include "Layers/SliceOutlineRenderer.h" +#include "Layers/LineLayerRenderer.h" #include "Widgets/LayerWidget.h" #include "Toolbox/DownloadStack.h" #include "Toolbox/OrthancSlicesLoader.h" @@ -759,4 +760,64 @@ } } }; + + + + class SliceLocationSource : public LayerSourceBase + { + private: + LayerWidget& otherPlane_; + + public: + SliceLocationSource(LayerWidget& otherPlane) : + otherPlane_(otherPlane) + { + NotifyGeometryReady(); + } + + virtual bool GetExtent(std::vector<Vector>& points, + const CoordinateSystem3D& viewportSlice) + { + return false; + } + + virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice) + { + Slice reference(viewportSlice, 0.001); + + Vector p, d; + + const CoordinateSystem3D& slice = otherPlane_.GetSlice(); + + // Compute the line of intersection between the two slices + if (!GeometryToolbox::IntersectTwoPlanes(p, d, + slice.GetOrigin(), slice.GetNormal(), + viewportSlice.GetOrigin(), viewportSlice.GetNormal())) + { + // The two slice are parallel, don't try and display the intersection + NotifyLayerReady(NULL, reference, false); + } + else + { + double x1, y1, x2, y2; + viewportSlice.ProjectPoint(x1, y1, p); + 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(), + extent.GetX2(), extent.GetY2())) + { + NotifyLayerReady(new LineLayerRenderer(x1, y1, x2, y2, slice), reference, false); + } + else + { + // Parallel slices + NotifyLayerReady(NULL, reference, false); + } + } + } + }; }