# HG changeset patch # User Chris Cannam # Date 1232118743 0 # Node ID b77b79413cdb17a6e2f9773aa6f2b7911d560f2a # Parent 69089c9dc42eb588836e22f8830a6ed8d83184f6 * fix some warnings, remove debug diff -r 69089c9dc42e -r b77b79413cdb layer/Colour3DPlotLayer.cpp --- a/layer/Colour3DPlotLayer.cpp Thu Jan 15 18:20:40 2009 +0000 +++ b/layer/Colour3DPlotLayer.cpp Fri Jan 16 15:12:23 2009 +0000 @@ -44,6 +44,7 @@ m_normalizeColumns(false), m_normalizeVisibleArea(false), m_invertVertical(false), + m_opaque(false), m_miny(0), m_maxy(0) { @@ -134,6 +135,7 @@ list.push_back("Normalize Columns"); list.push_back("Normalize Visible Area"); list.push_back("Invert Vertical Scale"); + list.push_back("Opaque"); return list; } @@ -145,6 +147,7 @@ if (name == "Normalize Columns") return tr("Normalize Columns"); 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"); return ""; } @@ -154,6 +157,7 @@ if (name == "Normalize Columns") return "normalise-columns"; if (name == "Normalize Visible Area") return "normalise"; if (name == "Invert Vertical Scale") return "invert-vertical"; + if (name == "Opaque") return "opaque"; return ""; } @@ -163,6 +167,7 @@ if (name == "Normalize Columns") return ToggleProperty; if (name == "Normalize Visible Area") return ToggleProperty; if (name == "Invert Vertical Scale") return ToggleProperty; + if (name == "Opaque") return ToggleProperty; return ValueProperty; } @@ -173,6 +178,8 @@ name == "Normalize Visible Area" || name == "Invert Vertical Scale" || name == "Colour Scale") return tr("Scale"); + if (name == "Opaque" || + name == "Colour") return tr("Colour"); return QString(); } @@ -218,6 +225,11 @@ *deflt = 0; val = (m_invertVertical ? 1 : 0); + } else if (name == "Opaque") { + + *deflt = 0; + val = (m_opaque ? 1 : 0); + } else { val = Layer::getPropertyRangeAndValue(name, min, max, deflt); } @@ -261,6 +273,8 @@ setNormalizeVisibleArea(value ? true : false); } else if (name == "Invert Vertical Scale") { setInvertVertical(value ? true : false); + } else if (name == "Opaque") { + setOpaque(value ? true : false); } } @@ -322,6 +336,14 @@ emit layerParametersChanged(); } +void +Colour3DPlotLayer::setOpaque(bool n) +{ + if (m_opaque == n) return; + m_opaque = n; + emit layerParametersChanged(); +} + bool Colour3DPlotLayer::getInvertVertical() const { @@ -329,6 +351,12 @@ } bool +Colour3DPlotLayer::getOpaque() const +{ + return m_opaque; +} + +bool Colour3DPlotLayer::isLayerScrollable(const View *v) const { if (m_normalizeVisibleArea) return false; @@ -540,6 +568,7 @@ } if (max == min) max = min + 1.0; + if (mmax == mmin) mmax = mmin + 1.0; paint.setPen(v->getForeground()); paint.drawRect(4, 10, cw - 8, ch+1); @@ -550,10 +579,13 @@ value = LogRange::map(value); } int pixel = int(((value - mmin) * 256) / (mmax - mmin)); - QRgb c = m_cache->color(pixel); -// QRgb c = m_cache->color(((ch - y) * 255) / ch); - paint.setPen(QColor(qRed(c), qGreen(c), qBlue(c))); - paint.drawLine(5, 11 + y, cw - 5, 11 + y); + if (pixel >= 0 && pixel < 256) { + QRgb c = m_cache->color(pixel); + paint.setPen(QColor(qRed(c), qGreen(c), qBlue(c))); + paint.drawLine(5, 11 + y, cw - 5, 11 + y); + } else { + std::cerr << "WARNING: Colour3DPlotLayer::paintVerticalScale: value " << value << ", mmin " << mmin << ", mmax " << mmax << " leads to invalid pixel " << pixel << std::endl; + } } QString minstr = QString("%1").arg(min); @@ -896,7 +928,8 @@ std::cerr << "Colour3DPlotLayer::paint: height = "<< m_model->getHeight() << ", modelStart = " << modelStart << ", resolution = " << modelResolution << ", model rate = " << m_model->getSampleRate() << std::endl; #endif - if (int(m_model->getHeight()) >= v->height() || + if (m_opaque || + int(m_model->getHeight()) >= v->height() || int(modelResolution * m_model->getSampleRate()) < v->getZoomLevel() / 2) { #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT std::cerr << "calling paintDense" << std::endl; @@ -1116,13 +1149,17 @@ "normalizeColumns=\"%3\" " "normalizeVisibleArea=\"%4\" " "minY=\"%5\" " - "maxY=\"%6\" ") + "maxY=\"%6\" " + "invertVertical=\"%7\" " + "opaque=\"%8\"") .arg((int)m_colourScale) .arg(m_colourMap) .arg(m_normalizeColumns ? "true" : "false") .arg(m_normalizeVisibleArea ? "true" : "false") .arg(m_miny) - .arg(m_maxy); + .arg(m_maxy) + .arg(m_invertVertical ? "true" : "false") + .arg(m_opaque ? "true" : "false"); Layer::toXml(stream, indent, extraAttributes + " " + s); } @@ -1146,6 +1183,14 @@ (attributes.value("normalizeVisibleArea").trimmed() == "true"); setNormalizeVisibleArea(normalizeVisibleArea); + bool invertVertical = + (attributes.value("invertVertical").trimmed() == "true"); + setInvertVertical(invertVertical); + + bool opaque = + (attributes.value("opaque").trimmed() == "true"); + setNormalizeVisibleArea(opaque); + float min = attributes.value("minY").toFloat(&ok); float max = attributes.value("maxY").toFloat(&alsoOk); if (ok && alsoOk) setDisplayExtents(min, max); diff -r 69089c9dc42e -r b77b79413cdb layer/Colour3DPlotLayer.h --- a/layer/Colour3DPlotLayer.h Thu Jan 15 18:20:40 2009 +0000 +++ b/layer/Colour3DPlotLayer.h Fri Jan 16 15:12:23 2009 +0000 @@ -99,6 +99,9 @@ void setInvertVertical(bool i); bool getInvertVertical() const; + void setOpaque(bool i); + bool getOpaque() const; + virtual bool getValueExtents(float &min, float &max, bool &logarithmic, QString &unit) const; @@ -134,6 +137,7 @@ bool m_normalizeColumns; bool m_normalizeVisibleArea; bool m_invertVertical; + bool m_opaque; int m_miny; int m_maxy; diff -r 69089c9dc42e -r b77b79413cdb view/View.cpp --- a/view/View.cpp Thu Jan 15 18:20:40 2009 +0000 +++ b/view/View.cpp Fri Jan 16 15:12:23 2009 +0000 @@ -1577,7 +1577,7 @@ getXForFrame(m_centreFrame); if (dx > -width() && dx < width()) { -#if defined(Q_WS_WIN32) || defined(Q_WS_MAC) +#if defined(Q_WS_WIN32) || defined(Q_WS_MAC) || defined(NO_PIXMAP_COPY_TO_SELF) // Copying a pixmap to itself doesn't work properly on Windows // or Mac (it only works when moving in one direction) static QPixmap *tmpPixmap = 0;