Mercurial > hg > orthanc-stone
comparison Framework/Layers/SiblingSliceLocationFactory.cpp @ 53:c2dc924f1a63 wasm
removing threading out of the framework
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 27 Apr 2017 16:57:49 +0200 |
parents | 28956ed68280 |
children | e2fe9352f240 |
comparison
equal
deleted
inserted
replaced
52:37e504582af6 | 53:c2dc924f1a63 |
---|---|
47 } | 47 } |
48 | 48 |
49 | 49 |
50 void SiblingSliceLocationFactory::SetLayerIndex(size_t layerIndex) | 50 void SiblingSliceLocationFactory::SetLayerIndex(size_t layerIndex) |
51 { | 51 { |
52 boost::mutex::scoped_lock lock(mutex_); | |
53 hasLayerIndex_ = true; | 52 hasLayerIndex_ = true; |
54 layerIndex_ = layerIndex; | 53 layerIndex_ = layerIndex; |
55 } | 54 } |
56 | 55 |
57 | 56 |
58 void SiblingSliceLocationFactory::SetStyle(const RenderStyle& style) | 57 void SiblingSliceLocationFactory::SetStyle(const RenderStyle& style) |
59 { | 58 { |
60 boost::mutex::scoped_lock lock(mutex_); | |
61 style_ = style; | 59 style_ = style; |
62 } | 60 } |
63 | 61 |
64 | 62 |
65 RenderStyle SiblingSliceLocationFactory::GetRenderStyle() | 63 RenderStyle SiblingSliceLocationFactory::GetRenderStyle() |
66 { | 64 { |
67 boost::mutex::scoped_lock lock(mutex_); | |
68 return style_; | 65 return style_; |
69 } | 66 } |
70 | 67 |
71 | 68 |
72 void SiblingSliceLocationFactory::SetSlice(const SliceGeometry& slice) | 69 void SiblingSliceLocationFactory::SetSlice(const SliceGeometry& slice) |
73 { | 70 { |
74 boost::mutex::scoped_lock lock(mutex_); | |
75 slice_ = slice; | 71 slice_ = slice; |
76 | 72 |
77 if (hasLayerIndex_) | 73 if (hasLayerIndex_) |
78 { | 74 { |
79 owner_.InvalidateLayer(layerIndex_); | 75 owner_.InvalidateLayer(layerIndex_); |
82 | 78 |
83 | 79 |
84 ILayerRenderer* SiblingSliceLocationFactory::CreateLayerRenderer(const SliceGeometry& viewportSlice) | 80 ILayerRenderer* SiblingSliceLocationFactory::CreateLayerRenderer(const SliceGeometry& viewportSlice) |
85 { | 81 { |
86 Vector p, d; | 82 Vector p, d; |
87 RenderStyle style; | |
88 | 83 |
84 // Compute the line of intersection between the two slices | |
85 if (!GeometryToolbox::IntersectTwoPlanes(p, d, | |
86 slice_.GetOrigin(), slice_.GetNormal(), | |
87 viewportSlice.GetOrigin(), viewportSlice.GetNormal())) | |
89 { | 88 { |
90 boost::mutex::scoped_lock lock(mutex_); | 89 // The two slice are parallel, don't try and display the intersection |
91 | 90 return NULL; |
92 style = style_; | |
93 | |
94 // Compute the line of intersection between the two slices | |
95 if (!GeometryToolbox::IntersectTwoPlanes(p, d, | |
96 slice_.GetOrigin(), slice_.GetNormal(), | |
97 viewportSlice.GetOrigin(), viewportSlice.GetNormal())) | |
98 { | |
99 // The two slice are parallel, don't try and display the intersection | |
100 return NULL; | |
101 } | |
102 } | 91 } |
103 | 92 |
104 double x1, y1, x2, y2; | 93 double x1, y1, x2, y2; |
105 viewportSlice.ProjectPoint(x1, y1, p); | 94 viewportSlice.ProjectPoint(x1, y1, p); |
106 viewportSlice.ProjectPoint(x2, y2, p + 1000.0 * d); | 95 viewportSlice.ProjectPoint(x2, y2, p + 1000.0 * d); |
111 if (GeometryToolbox::ClipLineToRectangle(x1, y1, x2, y2, | 100 if (GeometryToolbox::ClipLineToRectangle(x1, y1, x2, y2, |
112 x1, y1, x2, y2, | 101 x1, y1, x2, y2, |
113 sx1, sy1, sx2, sy2)) | 102 sx1, sy1, sx2, sy2)) |
114 { | 103 { |
115 std::auto_ptr<ILayerRenderer> layer(new LineLayerRenderer(x1, y1, x2, y2)); | 104 std::auto_ptr<ILayerRenderer> layer(new LineLayerRenderer(x1, y1, x2, y2)); |
116 layer->SetLayerStyle(style); | 105 layer->SetLayerStyle(style_); |
117 return layer.release(); | 106 return layer.release(); |
118 } | 107 } |
119 else | 108 else |
120 { | 109 { |
121 // Parallel slices | 110 // Parallel slices |