comparison Framework/dev.h @ 112:948f86e61e83 wasm

start of SliceLocationSource
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 Sep 2017 14:37:08 +0200
parents 53025eecbc95
children 2eca030792aa
comparison
equal deleted inserted replaced
111:7665ccbf33db 112:948f86e61e83
22 #pragma once 22 #pragma once
23 23
24 #include "Layers/FrameRenderer.h" 24 #include "Layers/FrameRenderer.h"
25 #include "Layers/LayerSourceBase.h" 25 #include "Layers/LayerSourceBase.h"
26 #include "Layers/SliceOutlineRenderer.h" 26 #include "Layers/SliceOutlineRenderer.h"
27 #include "Layers/LineLayerRenderer.h"
27 #include "Widgets/LayerWidget.h" 28 #include "Widgets/LayerWidget.h"
28 #include "Toolbox/DownloadStack.h" 29 #include "Toolbox/DownloadStack.h"
29 #include "Toolbox/OrthancSlicesLoader.h" 30 #include "Toolbox/OrthancSlicesLoader.h"
30 #include "Volumes/ImageBuffer3D.h" 31 #include "Volumes/ImageBuffer3D.h"
31 #include "Volumes/SlicedVolumeBase.h" 32 #include "Volumes/SlicedVolumeBase.h"
757 slice_ = slice; 758 slice_ = slice;
758 widget_.SetSlice(slices_->GetSlice(slice_).GetGeometry()); 759 widget_.SetSlice(slices_->GetSlice(slice_).GetGeometry());
759 } 760 }
760 } 761 }
761 }; 762 };
763
764
765
766 class SliceLocationSource : public LayerSourceBase
767 {
768 private:
769 LayerWidget& otherPlane_;
770
771 public:
772 SliceLocationSource(LayerWidget& otherPlane) :
773 otherPlane_(otherPlane)
774 {
775 NotifyGeometryReady();
776 }
777
778 virtual bool GetExtent(std::vector<Vector>& points,
779 const CoordinateSystem3D& viewportSlice)
780 {
781 return false;
782 }
783
784 virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice)
785 {
786 Slice reference(viewportSlice, 0.001);
787
788 Vector p, d;
789
790 const CoordinateSystem3D& slice = otherPlane_.GetSlice();
791
792 // Compute the line of intersection between the two slices
793 if (!GeometryToolbox::IntersectTwoPlanes(p, d,
794 slice.GetOrigin(), slice.GetNormal(),
795 viewportSlice.GetOrigin(), viewportSlice.GetNormal()))
796 {
797 // The two slice are parallel, don't try and display the intersection
798 NotifyLayerReady(NULL, reference, false);
799 }
800 else
801 {
802 double x1, y1, x2, y2;
803 viewportSlice.ProjectPoint(x1, y1, p);
804 viewportSlice.ProjectPoint(x2, y2, p + 1000.0 * d);
805
806 const Extent2D extent = otherPlane_.GetSceneExtent();
807
808 if (GeometryToolbox::ClipLineToRectangle(x1, y1, x2, y2,
809 x1, y1, x2, y2,
810 extent.GetX1(), extent.GetY1(),
811 extent.GetX2(), extent.GetY2()))
812 {
813 NotifyLayerReady(new LineLayerRenderer(x1, y1, x2, y2, slice), reference, false);
814 }
815 else
816 {
817 // Parallel slices
818 NotifyLayerReady(NULL, reference, false);
819 }
820 }
821 }
822 };
762 } 823 }