PDA

View Full Version : Horizontal zooming



kecsap
12th September 2012, 22:06
I do horizontal only zooming with:

Zoomer = new MyPlotZoomer(QwtPlot::xBottom, QwtPlot::xTop, canvas());

However, I wanted to get two horizontal lines for selecting. I do this with subclassing the QwtPlotZoomer class:

void GCPlotZoomer::drawRubberBand(QPainter* painter) const
{
if (!isActive() || rubberBand() == NoRubberBand || rubberBandPen().style() == Qt::NoPen)
{
return;
}
const QPolygon Polygon = adjustedPoints(pickedPoints());

if (Polygon.count() < 2)
return;

const QPoint Point1 = Polygon[0];
const QPoint Point2 = Polygon[int(Polygon.count()-1)];
const QRect Rect = QRect(Point1, Point2).normalized();

QwtPainter::drawLine(painter, Rect.left(), 0.0, Rect.left(), 400.0);
QwtPainter::drawLine(painter, Rect.right(), 0.0, Rect.right(), 400.0);
}

But would be nice to have some API level support instead of hacking. :)