# HG changeset patch # User Chris Cannam # Date 1353086052 0 # Node ID 156a120345aebfa74dcca1d02d6a7dfa26bed483 # Parent 7ac63919fd52761b5ffc2cf3a4686b2e4ee88932 Add discrete-curve drawing mode for time-value layer diff -r 7ac63919fd52 -r 156a120345ae layer/SingleColourLayer.h --- a/layer/SingleColourLayer.h Tue Aug 21 13:29:22 2012 +0100 +++ b/layer/SingleColourLayer.h Fri Nov 16 17:14:12 2012 +0000 @@ -26,11 +26,29 @@ Q_OBJECT public: + /** + * Set the colour used to draw primary items in the layer. The + * colour value is a colour database index as returned by + * ColourDatabase::getColourIndex(). + */ virtual void setBaseColour(int); + + /** + * Retrieve the current primary drawing colour, as a + * ColourDatabase index value. + */ virtual int getBaseColour() const; + /** + * Return true if the layer currently has a dark colour on a light + * background, false if it has a light colour on a dark + * background. + */ virtual bool hasLightBackground() const; + /** + * Implements Layer::getLayerColourSignificance() + */ virtual ColourSignificance getLayerColourSignificance() const { return ColourDistinguishes; } diff -r 7ac63919fd52 -r 156a120345ae layer/TimeValueLayer.cpp --- a/layer/TimeValueLayer.cpp Tue Aug 21 13:29:22 2012 +0100 +++ b/layer/TimeValueLayer.cpp Fri Nov 16 17:14:12 2012 +0000 @@ -160,7 +160,7 @@ } else if (name == "Plot Type") { if (min) *min = 0; - if (max) *max = 5; + if (max) *max = 6; if (deflt) *deflt = int(PlotConnectedPoints); val = int(m_plotStyle); @@ -218,6 +218,7 @@ case 3: return tr("Lines"); case 4: return tr("Curve"); case 5: return tr("Segmentation"); + case 6: return tr("Discrete Curves"); } } else if (name == "Vertical Scale") { switch (value) { @@ -307,7 +308,8 @@ // they're always scrollable if (m_plotStyle == PlotLines || - m_plotStyle == PlotCurve) return true; + m_plotStyle == PlotCurve || + m_plotStyle == PlotDiscreteCurves) return true; QPoint discard; return !v->shouldIlluminateLocalFeatures(this, discard); @@ -915,6 +917,8 @@ } } + int prevFrame = 0; + for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); i != points.end(); ++i) { @@ -932,6 +936,12 @@ int x = v->getXForFrame(p.frame); int y = getYForValue(v, value); + bool gap = false; + if (m_plotStyle == PlotDiscreteCurves) { + gap = (p.frame > prevFrame && + (p.frame - prevFrame >= m_model->getResolution() * 2)); + } + if (m_plotStyle != PlotSegmentation) { textY = y - paint.fontMetrics().height() + paint.fontMetrics().ascent(); @@ -941,7 +951,8 @@ } bool haveNext = false; - int nx = v->getXForFrame(v->getModelsEndFrame()); + int nf = v->getModelsEndFrame(); + int nx = v->getXForFrame(nf); int ny = y; SparseTimeValueModel::PointList::const_iterator j = i; @@ -951,7 +962,8 @@ const SparseTimeValueModel::Point &q(*j); float nvalue = q.value; if (m_derivative) nvalue -= p.value; - nx = v->getXForFrame(q.frame); + nf = q.frame; + nx = v->getXForFrame(nf); ny = getYForValue(v, nvalue); haveNext = true; } @@ -960,15 +972,19 @@ // << ", nx = " << nx << std::endl; if (w < 1) w = 1; - paint.setPen(getBaseQColor()); - if (m_plotStyle == PlotSegmentation) { + if (m_plotStyle == PlotDiscreteCurves) { + paint.setPen(QPen(getBaseQColor(), 3)); + paint.setBrush(Qt::NoBrush); + } else if (m_plotStyle == PlotSegmentation) { paint.setPen(getForegroundQColor(v)); paint.setBrush(getColourForValue(v, value)); } else if (m_plotStyle == PlotLines || m_plotStyle == PlotCurve) { + paint.setPen(getBaseQColor()); paint.setBrush(Qt::NoBrush); } else { + paint.setPen(getBaseQColor()); paint.setBrush(brushColour); } @@ -999,6 +1015,7 @@ //or curve mode if (m_plotStyle != PlotCurve && + m_plotStyle != PlotDiscreteCurves && m_plotStyle != PlotLines) { paint.setPen(getForegroundQColor(v)); } @@ -1006,6 +1023,7 @@ if (m_plotStyle != PlotLines && m_plotStyle != PlotCurve && + m_plotStyle != PlotDiscreteCurves && m_plotStyle != PlotSegmentation) { if (m_plotStyle != PlotStems || w > 1) { @@ -1015,6 +1033,7 @@ if (m_plotStyle == PlotConnectedPoints || m_plotStyle == PlotLines || + m_plotStyle == PlotDiscreteCurves || m_plotStyle == PlotCurve) { if (haveNext) { @@ -1044,7 +1063,15 @@ float y0 = y; float y1 = ny; - if (pointCount == 0) { + if (m_plotStyle == PlotDiscreteCurves) { + bool nextGap = nf - p.frame >= m_model->getResolution() * 2; + if (nextGap) { + x1 = x0; + y1 = y0; + } + } + + if (pointCount == 0 || gap) { path.moveTo((x0 + x1) / 2, (y0 + y1) / 2); } ++pointCount; @@ -1091,9 +1118,12 @@ // paint.drawText(x + 5, textY, p.label); } } + + prevFrame = p.frame; } - if ((m_plotStyle == PlotCurve || m_plotStyle == PlotLines) + if ((m_plotStyle == PlotCurve || m_plotStyle == PlotDiscreteCurves || + m_plotStyle == PlotLines) && !path.isEmpty()) { paint.setRenderHint(QPainter::Antialiasing, pointCount <= v->width()); paint.drawPath(path); diff -r 7ac63919fd52 -r 156a120345ae layer/TimeValueLayer.h --- a/layer/TimeValueLayer.h Tue Aug 21 13:29:22 2012 +0100 +++ b/layer/TimeValueLayer.h Fri Nov 16 17:14:12 2012 +0000 @@ -92,7 +92,8 @@ PlotConnectedPoints, PlotLines, PlotCurve, - PlotSegmentation + PlotSegmentation, + PlotDiscreteCurves }; void setPlotStyle(PlotStyle style); diff -r 7ac63919fd52 -r 156a120345ae view/PaneStack.cpp --- a/view/PaneStack.cpp Tue Aug 21 13:29:22 2012 +0100 +++ b/view/PaneStack.cpp Fri Nov 16 17:14:12 2012 +0000 @@ -42,6 +42,7 @@ m_splitter(new QSplitter), m_propertyStackStack(new QStackedWidget), m_viewManager(viewManager), + m_propertyStackMinWidth(100), m_layoutStyle(PropertyStackPerPaneLayout) { QHBoxLayout *layout = new QHBoxLayout;