# HG changeset patch # User Chris Cannam # Date 1242654947 0 # Node ID 0bd0b517e795d5acd41be5024cb3b0fde29b75c6 # Parent c7fd7bce3c09713c2a5204518420efc4dc5a0201 * Make a start on logarithmic vertical scale in colour 3d plot diff -r c7fd7bce3c09 -r 0bd0b517e795 layer/Colour3DPlotLayer.cpp --- a/layer/Colour3DPlotLayer.cpp Mon Mar 30 13:47:00 2009 +0000 +++ b/layer/Colour3DPlotLayer.cpp Mon May 18 13:55:47 2009 +0000 @@ -43,6 +43,7 @@ m_colourScale(LinearScale), m_colourScaleSet(false), m_colourMap(0), + m_binScale(LinearBinScale), m_normalizeColumns(false), m_normalizeVisibleArea(false), m_invertVertical(false), @@ -149,6 +150,7 @@ list.push_back("Colour Scale"); list.push_back("Normalize Columns"); list.push_back("Normalize Visible Area"); + list.push_back("Bin Scale"); list.push_back("Invert Vertical Scale"); list.push_back("Opaque"); return list; @@ -163,6 +165,7 @@ if (name == "Normalize Visible Area") return tr("Normalize Visible Area"); if (name == "Invert Vertical Scale") return tr("Invert Vertical Scale"); if (name == "Opaque") return tr("Always Opaque"); + if (name == "Bin Scale") return tr("Bin Scale"); return ""; } @@ -191,8 +194,9 @@ { if (name == "Normalize Columns" || name == "Normalize Visible Area" || - name == "Invert Vertical Scale" || name == "Colour Scale") return tr("Scale"); + if (name == "Bin Scale" || + name == "Invert Vertical Scale") return tr("Bins"); if (name == "Opaque" || name == "Colour") return tr("Colour"); return QString(); @@ -240,6 +244,13 @@ *deflt = 0; val = (m_invertVertical ? 1 : 0); + } else if (name == "Bin Scale") { + + *min = 0; + *max = 1; + *deflt = int(LinearBinScale); + val = (int)m_binScale; + } else if (name == "Opaque") { *deflt = 0; @@ -268,6 +279,13 @@ case 3: return tr("Absolute"); } } + if (name == "Bin Scale") { + switch (value) { + default: + case 0: return tr("Linear"); + case 1: return tr("Log"); + } + } return tr(""); } @@ -292,6 +310,12 @@ setInvertVertical(value ? true : false); } else if (name == "Opaque") { setOpaque(value ? true : false); + } else if (name == "Bin Scale") { + switch (value) { + default: + case 0: setBinScale(LinearBinScale); break; + case 1: setBinScale(LogBinScale); break; + } } } @@ -315,6 +339,21 @@ } void +Colour3DPlotLayer::setBinScale(BinScale binScale) +{ + if (m_binScale == binScale) return; + m_binScale = binScale; + cacheInvalid(); + emit layerParametersChanged(); +} + +Colour3DPlotLayer::BinScale +Colour3DPlotLayer::getBinScale() const +{ + return m_binScale; +} + +void Colour3DPlotLayer::setNormalizeColumns(bool n) { if (m_normalizeColumns == n) return; @@ -1234,8 +1273,19 @@ for (int y = 0; y < h; ++y) { - float sy0 = symin + (float(h - y - 1) * (symax - symin)) / h; - float sy1 = symin + (float(h - y) * (symax - symin)) / h; + float sy0, sy1; + + if (m_binScale == LinearBinScale) { + sy0 = symin + (float(h - y - 1) * (symax - symin)) / h; + sy1 = symin + (float(h - y) * (symax - symin)) / h; + } else { + float logmin = LogRange::map(symin); + float logmax = LogRange::map(symax); + sy0 = logmin + (float(h - y - 1) * (logmax - logmin)) / h; + sy1 = logmin + (float(h - y) * (logmax - logmin)) / h; + sy0 = pow10f(sy0); + sy1 = pow10f(sy1); + } int sy0i = int(sy0 + 0.001); int sy1i = int(sy1); diff -r c7fd7bce3c09 -r 0bd0b517e795 layer/Colour3DPlotLayer.h --- a/layer/Colour3DPlotLayer.h Mon Mar 30 13:47:00 2009 +0000 +++ b/layer/Colour3DPlotLayer.h Mon May 18 13:55:47 2009 +0000 @@ -97,6 +97,17 @@ void setColourMap(int map); int getColourMap() const; + enum BinScale { + LinearBinScale, + LogBinScale + }; + + /** + * Specify the scale for the y axis. + */ + void setBinScale(BinScale); + BinScale getBinScale() const; + void setNormalizeColumns(bool n); bool getNormalizeColumns() const; @@ -142,6 +153,7 @@ ColourScale m_colourScale; bool m_colourScaleSet; int m_colourMap; + BinScale m_binScale; bool m_normalizeColumns; bool m_normalizeVisibleArea; bool m_invertVertical;