Mercurial > hg > svgui
comparison layer/Colour3DPlotLayer.cpp @ 970:1c37aa13bfd8
Add half-wave rectification option to Colour 3D Plot layer
author | Chris Cannam |
---|---|
date | Fri, 22 May 2015 09:17:52 +0100 |
parents | 4a578a360011 |
children | 1011ffb1b6d5 08f20a23fb81 |
comparison
equal
deleted
inserted
replaced
968:4d54882bbf73 | 970:1c37aa13bfd8 |
---|---|
52 m_binScale(LinearBinScale), | 52 m_binScale(LinearBinScale), |
53 m_normalizeColumns(false), | 53 m_normalizeColumns(false), |
54 m_normalizeVisibleArea(false), | 54 m_normalizeVisibleArea(false), |
55 m_normalizeHybrid(false), | 55 m_normalizeHybrid(false), |
56 m_invertVertical(false), | 56 m_invertVertical(false), |
57 m_rectified(false), | |
57 m_opaque(false), | 58 m_opaque(false), |
58 m_smooth(false), | 59 m_smooth(false), |
59 m_peakResolution(256), | 60 m_peakResolution(256), |
60 m_miny(0), | 61 m_miny(0), |
61 m_maxy(0) | 62 m_maxy(0) |
160 list.push_back("Normalize Columns"); | 161 list.push_back("Normalize Columns"); |
161 list.push_back("Normalize Visible Area"); | 162 list.push_back("Normalize Visible Area"); |
162 list.push_back("Gain"); | 163 list.push_back("Gain"); |
163 list.push_back("Bin Scale"); | 164 list.push_back("Bin Scale"); |
164 list.push_back("Invert Vertical Scale"); | 165 list.push_back("Invert Vertical Scale"); |
166 list.push_back("Show Rectified"); | |
165 list.push_back("Opaque"); | 167 list.push_back("Opaque"); |
166 list.push_back("Smooth"); | 168 list.push_back("Smooth"); |
167 return list; | 169 return list; |
168 } | 170 } |
169 | 171 |
173 if (name == "Colour") return tr("Colour"); | 175 if (name == "Colour") return tr("Colour"); |
174 if (name == "Colour Scale") return tr("Scale"); | 176 if (name == "Colour Scale") return tr("Scale"); |
175 if (name == "Normalize Columns") return tr("Normalize Columns"); | 177 if (name == "Normalize Columns") return tr("Normalize Columns"); |
176 if (name == "Normalize Visible Area") return tr("Normalize Visible Area"); | 178 if (name == "Normalize Visible Area") return tr("Normalize Visible Area"); |
177 if (name == "Invert Vertical Scale") return tr("Invert Vertical Scale"); | 179 if (name == "Invert Vertical Scale") return tr("Invert Vertical Scale"); |
180 if (name == "Show Rectified") return tr("Half-Wave Rectify"); | |
178 if (name == "Gain") return tr("Gain"); | 181 if (name == "Gain") return tr("Gain"); |
179 if (name == "Opaque") return tr("Always Opaque"); | 182 if (name == "Opaque") return tr("Always Opaque"); |
180 if (name == "Smooth") return tr("Smooth"); | 183 if (name == "Smooth") return tr("Smooth"); |
181 if (name == "Bin Scale") return tr("Bin Scale"); | 184 if (name == "Bin Scale") return tr("Bin Scale"); |
182 return ""; | 185 return ""; |
186 Colour3DPlotLayer::getPropertyIconName(const PropertyName &name) const | 189 Colour3DPlotLayer::getPropertyIconName(const PropertyName &name) const |
187 { | 190 { |
188 if (name == "Normalize Columns") return "normalise-columns"; | 191 if (name == "Normalize Columns") return "normalise-columns"; |
189 if (name == "Normalize Visible Area") return "normalise"; | 192 if (name == "Normalize Visible Area") return "normalise"; |
190 if (name == "Invert Vertical Scale") return "invert-vertical"; | 193 if (name == "Invert Vertical Scale") return "invert-vertical"; |
194 if (name == "Show Rectified") return "derivative"; | |
191 if (name == "Opaque") return "opaque"; | 195 if (name == "Opaque") return "opaque"; |
192 if (name == "Smooth") return "smooth"; | 196 if (name == "Smooth") return "smooth"; |
193 return ""; | 197 return ""; |
194 } | 198 } |
195 | 199 |
198 { | 202 { |
199 if (name == "Gain") return RangeProperty; | 203 if (name == "Gain") return RangeProperty; |
200 if (name == "Normalize Columns") return ToggleProperty; | 204 if (name == "Normalize Columns") return ToggleProperty; |
201 if (name == "Normalize Visible Area") return ToggleProperty; | 205 if (name == "Normalize Visible Area") return ToggleProperty; |
202 if (name == "Invert Vertical Scale") return ToggleProperty; | 206 if (name == "Invert Vertical Scale") return ToggleProperty; |
207 if (name == "Show Rectified") return ToggleProperty; | |
203 if (name == "Opaque") return ToggleProperty; | 208 if (name == "Opaque") return ToggleProperty; |
204 if (name == "Smooth") return ToggleProperty; | 209 if (name == "Smooth") return ToggleProperty; |
205 return ValueProperty; | 210 return ValueProperty; |
206 } | 211 } |
207 | 212 |
209 Colour3DPlotLayer::getPropertyGroupName(const PropertyName &name) const | 214 Colour3DPlotLayer::getPropertyGroupName(const PropertyName &name) const |
210 { | 215 { |
211 if (name == "Normalize Columns" || | 216 if (name == "Normalize Columns" || |
212 name == "Normalize Visible Area" || | 217 name == "Normalize Visible Area" || |
213 name == "Colour Scale" || | 218 name == "Colour Scale" || |
219 name == "Show Rectified" || | |
214 name == "Gain") return tr("Scale"); | 220 name == "Gain") return tr("Scale"); |
215 if (name == "Bin Scale" || | 221 if (name == "Bin Scale" || |
216 name == "Invert Vertical Scale") return tr("Bins"); | 222 name == "Invert Vertical Scale") return tr("Bins"); |
217 if (name == "Opaque" || | 223 if (name == "Opaque" || |
218 name == "Smooth" || | 224 name == "Smooth" || |
272 | 278 |
273 } else if (name == "Invert Vertical Scale") { | 279 } else if (name == "Invert Vertical Scale") { |
274 | 280 |
275 *deflt = 0; | 281 *deflt = 0; |
276 val = (m_invertVertical ? 1 : 0); | 282 val = (m_invertVertical ? 1 : 0); |
283 | |
284 } else if (name == "Show Rectified") { | |
285 | |
286 if (min) *min = 0; | |
287 if (max) *max = 0; | |
288 if (deflt) *deflt = 0; | |
289 val = (m_rectified ? 1.0 : 0.0); | |
277 | 290 |
278 } else if (name == "Bin Scale") { | 291 } else if (name == "Bin Scale") { |
279 | 292 |
280 *min = 0; | 293 *min = 0; |
281 *max = 1; | 294 *max = 1; |
353 setNormalizeColumns(value ? true : false); | 366 setNormalizeColumns(value ? true : false); |
354 } else if (name == "Normalize Visible Area") { | 367 } else if (name == "Normalize Visible Area") { |
355 setNormalizeVisibleArea(value ? true : false); | 368 setNormalizeVisibleArea(value ? true : false); |
356 } else if (name == "Invert Vertical Scale") { | 369 } else if (name == "Invert Vertical Scale") { |
357 setInvertVertical(value ? true : false); | 370 setInvertVertical(value ? true : false); |
371 } else if (name == "Show Rectified") { | |
372 setShowRectified(value > 0.5); | |
358 } else if (name == "Opaque") { | 373 } else if (name == "Opaque") { |
359 setOpaque(value ? true : false); | 374 setOpaque(value ? true : false); |
360 } else if (name == "Smooth") { | 375 } else if (name == "Smooth") { |
361 setSmooth(value ? true : false); | 376 setSmooth(value ? true : false); |
362 } else if (name == "Bin Scale") { | 377 } else if (name == "Bin Scale") { |
465 void | 480 void |
466 Colour3DPlotLayer::setInvertVertical(bool n) | 481 Colour3DPlotLayer::setInvertVertical(bool n) |
467 { | 482 { |
468 if (m_invertVertical == n) return; | 483 if (m_invertVertical == n) return; |
469 m_invertVertical = n; | 484 m_invertVertical = n; |
485 cacheInvalid(); | |
486 emit layerParametersChanged(); | |
487 } | |
488 | |
489 void | |
490 Colour3DPlotLayer::setShowRectified(bool show) | |
491 { | |
492 if (m_rectified == show) return; | |
493 m_rectified = show; | |
470 cacheInvalid(); | 494 cacheInvalid(); |
471 emit layerParametersChanged(); | 495 emit layerParametersChanged(); |
472 } | 496 } |
473 | 497 |
474 void | 498 void |
928 DenseThreeDimensionalModel::Column | 952 DenseThreeDimensionalModel::Column |
929 Colour3DPlotLayer::getColumn(int col) const | 953 Colour3DPlotLayer::getColumn(int col) const |
930 { | 954 { |
931 Profiler profiler("Colour3DPlotLayer::getColumn"); | 955 Profiler profiler("Colour3DPlotLayer::getColumn"); |
932 | 956 |
957 DenseThreeDimensionalModel::Column prev; | |
958 if (m_rectified && (col > m_model->getStartFrame())) { | |
959 prev = m_model->getColumn(col - 1); | |
960 } | |
961 | |
933 DenseThreeDimensionalModel::Column values = m_model->getColumn(col); | 962 DenseThreeDimensionalModel::Column values = m_model->getColumn(col); |
963 | |
964 if (m_rectified && !prev.empty()) { | |
965 for (int y = 0; y < values.size(); ++y) { | |
966 if (values[y] < prev[y]) values[y] = 0; | |
967 else values[y] -= prev[y]; | |
968 } | |
969 } | |
970 | |
934 while (values.size() < m_model->getHeight()) values.push_back(0.f); | 971 while (values.size() < m_model->getHeight()) values.push_back(0.f); |
935 if (!m_normalizeColumns && !m_normalizeHybrid) return values; | 972 if (!m_normalizeColumns && !m_normalizeHybrid) return values; |
936 | 973 |
937 double colMax = 0.f, colMin = 0.f; | 974 double colMax = 0.f, colMin = 0.f; |
938 double min = 0.f, max = 0.f; | 975 double min = 0.f, max = 0.f; |