Mercurial > hg > svgui
comparison layer/Colour3DPlotLayer.cpp @ 531:0bd0b517e795
* Make a start on logarithmic vertical scale in colour 3d plot
author | Chris Cannam |
---|---|
date | Mon, 18 May 2009 13:55:47 +0000 |
parents | 43bd47468005 |
children | 188049db73fa |
comparison
equal
deleted
inserted
replaced
530:c7fd7bce3c09 | 531:0bd0b517e795 |
---|---|
41 m_cacheValidStart(0), | 41 m_cacheValidStart(0), |
42 m_cacheValidEnd(0), | 42 m_cacheValidEnd(0), |
43 m_colourScale(LinearScale), | 43 m_colourScale(LinearScale), |
44 m_colourScaleSet(false), | 44 m_colourScaleSet(false), |
45 m_colourMap(0), | 45 m_colourMap(0), |
46 m_binScale(LinearBinScale), | |
46 m_normalizeColumns(false), | 47 m_normalizeColumns(false), |
47 m_normalizeVisibleArea(false), | 48 m_normalizeVisibleArea(false), |
48 m_invertVertical(false), | 49 m_invertVertical(false), |
49 m_opaque(false), | 50 m_opaque(false), |
50 m_miny(0), | 51 m_miny(0), |
147 PropertyList list; | 148 PropertyList list; |
148 list.push_back("Colour"); | 149 list.push_back("Colour"); |
149 list.push_back("Colour Scale"); | 150 list.push_back("Colour Scale"); |
150 list.push_back("Normalize Columns"); | 151 list.push_back("Normalize Columns"); |
151 list.push_back("Normalize Visible Area"); | 152 list.push_back("Normalize Visible Area"); |
153 list.push_back("Bin Scale"); | |
152 list.push_back("Invert Vertical Scale"); | 154 list.push_back("Invert Vertical Scale"); |
153 list.push_back("Opaque"); | 155 list.push_back("Opaque"); |
154 return list; | 156 return list; |
155 } | 157 } |
156 | 158 |
161 if (name == "Colour Scale") return tr("Scale"); | 163 if (name == "Colour Scale") return tr("Scale"); |
162 if (name == "Normalize Columns") return tr("Normalize Columns"); | 164 if (name == "Normalize Columns") return tr("Normalize Columns"); |
163 if (name == "Normalize Visible Area") return tr("Normalize Visible Area"); | 165 if (name == "Normalize Visible Area") return tr("Normalize Visible Area"); |
164 if (name == "Invert Vertical Scale") return tr("Invert Vertical Scale"); | 166 if (name == "Invert Vertical Scale") return tr("Invert Vertical Scale"); |
165 if (name == "Opaque") return tr("Always Opaque"); | 167 if (name == "Opaque") return tr("Always Opaque"); |
168 if (name == "Bin Scale") return tr("Bin Scale"); | |
166 return ""; | 169 return ""; |
167 } | 170 } |
168 | 171 |
169 QString | 172 QString |
170 Colour3DPlotLayer::getPropertyIconName(const PropertyName &name) const | 173 Colour3DPlotLayer::getPropertyIconName(const PropertyName &name) const |
189 QString | 192 QString |
190 Colour3DPlotLayer::getPropertyGroupName(const PropertyName &name) const | 193 Colour3DPlotLayer::getPropertyGroupName(const PropertyName &name) const |
191 { | 194 { |
192 if (name == "Normalize Columns" || | 195 if (name == "Normalize Columns" || |
193 name == "Normalize Visible Area" || | 196 name == "Normalize Visible Area" || |
194 name == "Invert Vertical Scale" || | |
195 name == "Colour Scale") return tr("Scale"); | 197 name == "Colour Scale") return tr("Scale"); |
198 if (name == "Bin Scale" || | |
199 name == "Invert Vertical Scale") return tr("Bins"); | |
196 if (name == "Opaque" || | 200 if (name == "Opaque" || |
197 name == "Colour") return tr("Colour"); | 201 name == "Colour") return tr("Colour"); |
198 return QString(); | 202 return QString(); |
199 } | 203 } |
200 | 204 |
237 | 241 |
238 } else if (name == "Invert Vertical Scale") { | 242 } else if (name == "Invert Vertical Scale") { |
239 | 243 |
240 *deflt = 0; | 244 *deflt = 0; |
241 val = (m_invertVertical ? 1 : 0); | 245 val = (m_invertVertical ? 1 : 0); |
246 | |
247 } else if (name == "Bin Scale") { | |
248 | |
249 *min = 0; | |
250 *max = 1; | |
251 *deflt = int(LinearBinScale); | |
252 val = (int)m_binScale; | |
242 | 253 |
243 } else if (name == "Opaque") { | 254 } else if (name == "Opaque") { |
244 | 255 |
245 *deflt = 0; | 256 *deflt = 0; |
246 val = (m_opaque ? 1 : 0); | 257 val = (m_opaque ? 1 : 0); |
264 default: | 275 default: |
265 case 0: return tr("Linear"); | 276 case 0: return tr("Linear"); |
266 case 1: return tr("Log"); | 277 case 1: return tr("Log"); |
267 case 2: return tr("+/-1"); | 278 case 2: return tr("+/-1"); |
268 case 3: return tr("Absolute"); | 279 case 3: return tr("Absolute"); |
280 } | |
281 } | |
282 if (name == "Bin Scale") { | |
283 switch (value) { | |
284 default: | |
285 case 0: return tr("Linear"); | |
286 case 1: return tr("Log"); | |
269 } | 287 } |
270 } | 288 } |
271 return tr("<unknown>"); | 289 return tr("<unknown>"); |
272 } | 290 } |
273 | 291 |
290 setNormalizeVisibleArea(value ? true : false); | 308 setNormalizeVisibleArea(value ? true : false); |
291 } else if (name == "Invert Vertical Scale") { | 309 } else if (name == "Invert Vertical Scale") { |
292 setInvertVertical(value ? true : false); | 310 setInvertVertical(value ? true : false); |
293 } else if (name == "Opaque") { | 311 } else if (name == "Opaque") { |
294 setOpaque(value ? true : false); | 312 setOpaque(value ? true : false); |
313 } else if (name == "Bin Scale") { | |
314 switch (value) { | |
315 default: | |
316 case 0: setBinScale(LinearBinScale); break; | |
317 case 1: setBinScale(LogBinScale); break; | |
318 } | |
295 } | 319 } |
296 } | 320 } |
297 | 321 |
298 void | 322 void |
299 Colour3DPlotLayer::setColourScale(ColourScale scale) | 323 Colour3DPlotLayer::setColourScale(ColourScale scale) |
310 { | 334 { |
311 if (m_colourMap == map) return; | 335 if (m_colourMap == map) return; |
312 m_colourMap = map; | 336 m_colourMap = map; |
313 cacheInvalid(); | 337 cacheInvalid(); |
314 emit layerParametersChanged(); | 338 emit layerParametersChanged(); |
339 } | |
340 | |
341 void | |
342 Colour3DPlotLayer::setBinScale(BinScale binScale) | |
343 { | |
344 if (m_binScale == binScale) return; | |
345 m_binScale = binScale; | |
346 cacheInvalid(); | |
347 emit layerParametersChanged(); | |
348 } | |
349 | |
350 Colour3DPlotLayer::BinScale | |
351 Colour3DPlotLayer::getBinScale() const | |
352 { | |
353 return m_binScale; | |
315 } | 354 } |
316 | 355 |
317 void | 356 void |
318 Colour3DPlotLayer::setNormalizeColumns(bool n) | 357 Colour3DPlotLayer::setNormalizeColumns(bool n) |
319 { | 358 { |
1232 sxa[x*2 + 1] = sx1i; | 1271 sxa[x*2 + 1] = sx1i; |
1233 } | 1272 } |
1234 | 1273 |
1235 for (int y = 0; y < h; ++y) { | 1274 for (int y = 0; y < h; ++y) { |
1236 | 1275 |
1237 float sy0 = symin + (float(h - y - 1) * (symax - symin)) / h; | 1276 float sy0, sy1; |
1238 float sy1 = symin + (float(h - y) * (symax - symin)) / h; | 1277 |
1278 if (m_binScale == LinearBinScale) { | |
1279 sy0 = symin + (float(h - y - 1) * (symax - symin)) / h; | |
1280 sy1 = symin + (float(h - y) * (symax - symin)) / h; | |
1281 } else { | |
1282 float logmin = LogRange::map(symin); | |
1283 float logmax = LogRange::map(symax); | |
1284 sy0 = logmin + (float(h - y - 1) * (logmax - logmin)) / h; | |
1285 sy1 = logmin + (float(h - y) * (logmax - logmin)) / h; | |
1286 sy0 = pow10f(sy0); | |
1287 sy1 = pow10f(sy1); | |
1288 } | |
1239 | 1289 |
1240 int sy0i = int(sy0 + 0.001); | 1290 int sy0i = int(sy0 + 0.001); |
1241 int sy1i = int(sy1); | 1291 int sy1i = int(sy1); |
1242 | 1292 |
1243 uchar *targetLine = img.scanLine(y); | 1293 uchar *targetLine = img.scanLine(y); |