comparison Framework/Layers/OrthancFrameLayerSource.cpp @ 97:d18dcc963930 wasm

separation of the renderers vs. viewport slice
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 30 May 2017 14:09:11 +0200
parents f8bce1bebe01
children a33abae66344
comparison
equal deleted inserted replaced
96:f8bce1bebe01 97:d18dcc963930
75 { 75 {
76 loader_.ScheduleLoadInstance(instanceId_, frame_); 76 loader_.ScheduleLoadInstance(instanceId_, frame_);
77 } 77 }
78 78
79 79
80 bool OrthancFrameLayerSource::GetExtent(double& x1, 80 bool OrthancFrameLayerSource::GetExtent(std::vector<Vector>& points,
81 double& y1,
82 double& x2,
83 double& y2,
84 const SliceGeometry& viewportSlice) 81 const SliceGeometry& viewportSlice)
85 { 82 {
86 bool ok = false; 83 size_t index;
84 if (loader_.IsGeometryReady() &&
85 loader_.LookupSlice(index, viewportSlice))
86 {
87 const Slice& slice = loader_.GetSlice(index);
88 const SliceGeometry& plane = slice.GetGeometry();
87 89
88 if (loader_.IsGeometryReady()) 90 double sx = slice.GetPixelSpacingX();
91 double sy = slice.GetPixelSpacingY();
92 double w = static_cast<double>(slice.GetWidth());
93 double h = static_cast<double>(slice.GetHeight());
94
95 points.clear();
96 points.push_back(plane.MapSliceToWorldCoordinates(-0.5 * sx, -0.5 * sy));
97 points.push_back(plane.MapSliceToWorldCoordinates((w - 0.5) * sx, -0.5 * sy));
98 points.push_back(plane.MapSliceToWorldCoordinates(-0.5 * sx, (h - 0.5) * sy));
99 points.push_back(plane.MapSliceToWorldCoordinates((w - 0.5) * sx, (h - 0.5) * sy));
100 return true;
101 }
102 else
89 { 103 {
90 double tx1, ty1, tx2, ty2; 104 return false;
91
92 for (size_t i = 0; i < loader_.GetSliceCount(); i++)
93 {
94 if (FrameRenderer::ComputeFrameExtent(tx1, ty1, tx2, ty2, viewportSlice, loader_.GetSlice(i)))
95 {
96 if (ok)
97 {
98 x1 = std::min(x1, tx1);
99 y1 = std::min(y1, ty1);
100 x2 = std::min(x2, tx2);
101 y2 = std::min(y2, ty2);
102 }
103 else
104 {
105 // This is the first slice parallel to the viewport
106 x1 = tx1;
107 y1 = ty1;
108 x2 = tx2;
109 y2 = ty2;
110 ok = true;
111 }
112 }
113 }
114 } 105 }
115
116 return ok;
117 } 106 }
118 107
119 108
120 void OrthancFrameLayerSource::ScheduleLayerCreation(const SliceGeometry& viewportSlice) 109 void OrthancFrameLayerSource::ScheduleLayerCreation(const SliceGeometry& viewportSlice)
121 { 110 {
123 112
124 if (loader_.IsGeometryReady()) 113 if (loader_.IsGeometryReady())
125 { 114 {
126 if (loader_.LookupSlice(index, viewportSlice)) 115 if (loader_.LookupSlice(index, viewportSlice))
127 { 116 {
128 //loader_.ScheduleLoadSliceImage(index, SliceImageQuality_Full); 117 loader_.ScheduleLoadSliceImage(index, SliceImageQuality_Full);
129 loader_.ScheduleLoadSliceImage(index, SliceImageQuality_Jpeg50); 118 //loader_.ScheduleLoadSliceImage(index, SliceImageQuality_Jpeg50);
130 } 119 }
131 else 120 else
132 { 121 {
133 Slice slice; 122 Slice slice;
134 LayerSourceBase::NotifyLayerReady(NULL, slice, true); 123 LayerSourceBase::NotifyLayerReady(NULL, slice, true);