23 #include <QtCore/QEvent>
24 #include <qwt_plot_canvas.h>
25 #include <qwt_plot_layout.h>
26 #include <qwt_scale_engine.h>
28 #include <QtGui/QResizeEvent>
29 #include <QtCore/QChildEvent>
42 return QString().sprintf(
"%.4g", pos.y());
44 return QString().sprintf(
"%.4g", pos.x());
46 return QString().sprintf(
"%.4g, %.4g", pos.x(), pos.y());
71 x = qwtMax(x, zoomBase().left());
72 x = qwtMin(x, zoomBase().right() - zoomRect().width());
74 y = qwtMax(y, zoomBase().top());
75 y = qwtMin(y, zoomBase().bottom() - zoomRect().height());
77 if (x != zoomRect().left() || y != zoomRect().top())
80 QwtDoubleRect & rect =
const_cast<QwtDoubleRect &
>(zoomStack()[zoomRectIndex()]);
83 const int xAxis = QwtPlotZoomer::xAxis();
84 const QwtScaleEngine *sex = plot()->axisScaleEngine(xAxis);
86 if (dynamic_cast<const QwtLog10ScaleEngine*>(sex))
89 double factor = rect.right() / rect.left();
90 rect.setRight(x * factor);
98 const int yAxis = QwtPlotZoomer::yAxis();
100 const QwtScaleEngine *sey = plot()->axisScaleEngine(yAxis);
102 if (dynamic_cast<const QwtLog10ScaleEngine*>(sey))
105 double factor = rect.bottom() / rect.top();
106 rect.setBottom(y * factor);
127 #
if QT_VERSION < 0x040000
128 mode(Q3ScrollView::Auto)
130 mode(Qt::ScrollBarAsNeeded)
142 #if QT_VERSION < 0x040000
143 Q3ScrollView::ScrollBarMode
mode;
145 Qt::ScrollBarPolicy
mode;
153 d_cornerWidget(NULL),
173 QwtPlotZoomer::rescale();
187 SIGNAL(valueChanged(Qt::Orientation,
double,
double)),
204 #if QT_VERSION < 0x040000
210 if (hScrollBarMode() != mode)
212 d_hScrollData->mode = mode;
217 #if QT_VERSION < 0x040000
223 if (vScrollBarMode() != mode)
225 d_vScrollData->mode = mode;
230 #if QT_VERSION < 0x040000
237 return d_hScrollData->mode;
240 #if QT_VERSION < 0x040000
247 return d_vScrollData->mode;
289 #if QT_VERSION < 0x040000
314 const int fw = ((QwtPlotCanvas *)canvas())->frameWidth();
317 rect.setSize(((QResizeEvent *)e)->size());
318 rect.setRect(rect.x() + fw, rect.y() + fw,
319 rect.width() - 2 * fw, rect.height() - 2 * fw);
324 case QEvent::ChildRemoved:
326 const QObject *child = ((QChildEvent *)e)->child();
342 return QwtPlotZoomer::eventFilter(o, e);
347 #if QT_VERSION < 0x040000
348 Q3ScrollView::ScrollBarMode mode;
350 Qt::ScrollBarPolicy mode;
352 double zoomMin, zoomMax, baseMin, baseMax;
354 if (o == Qt::Horizontal)
357 baseMin = zoomBase().left();
358 baseMax = zoomBase().right();
359 zoomMin = zoomRect().left();
360 zoomMax = zoomRect().right();
365 baseMin = zoomBase().top();
366 baseMax = zoomBase().bottom();
367 zoomMin = zoomRect().top();
368 zoomMax = zoomRect().bottom();
375 #if QT_VERSION < 0x040000
376 case Q3ScrollView::AlwaysOn:
378 case Qt::ScrollBarAlwaysOn:
382 #if QT_VERSION < 0x040000
383 case Q3ScrollView::AlwaysOff:
385 case Qt::ScrollBarAlwaysOff:
391 if (baseMin < zoomMin || baseMax > zoomMax)
406 const int xAxis = QwtPlotZoomer::xAxis();
407 const int yAxis = QwtPlotZoomer::yAxis();
409 int xScrollBarAxis = xAxis;
414 int yScrollBarAxis = yAxis;
419 QwtPlotLayout *layout = plot()->plotLayout();
427 sb->setPalette(plot()->palette());
429 const QwtScaleEngine *se = plot()->axisScaleEngine(xAxis);
430 sb->
setInverted(se->testAttribute(QwtScaleEngine::Inverted));
431 sb->
setLogScale(dynamic_cast<const QwtLog10ScaleEngine*>(se));
433 sb->
setBase(zoomBase().left(), zoomBase().right());
434 sb->
moveSlider(zoomRect().left(), zoomRect().right());
436 if (!sb->isVisibleTo(canvas()))
439 layout->setCanvasMargin(layout->canvasMargin(xScrollBarAxis)
440 + sb->
extent(), xScrollBarAxis);
448 layout->setCanvasMargin(layout->canvasMargin(xScrollBarAxis)
459 sb->setPalette(plot()->palette());
461 const QwtScaleEngine *se = plot()->axisScaleEngine(yAxis);
462 sb->
setInverted(!(se->testAttribute(QwtScaleEngine::Inverted)));
463 sb->
setLogScale(dynamic_cast<const QwtLog10ScaleEngine*>(se));
465 sb->
setBase(zoomBase().top(), zoomBase().bottom());
466 sb->
moveSlider(zoomRect().top(), zoomRect().bottom());
468 if (!sb->isVisibleTo(canvas()))
471 layout->setCanvasMargin(layout->canvasMargin(yScrollBarAxis)
472 + sb->
extent(), yScrollBarAxis);
480 layout->setCanvasMargin(layout->canvasMargin(yScrollBarAxis)
485 if (showHScrollBar && showVScrollBar)
519 const int hdim = hScrollBar ? hScrollBar->
extent() : 0;
520 const int vdim = vScrollBar ? vScrollBar->
extent() : 0;
522 if (hScrollBar && hScrollBar->isVisible())
525 int y = (hPos == QwtPlot::xTop)
526 ? rect.top() : rect.bottom() - hdim + 1;
527 int w = rect.width();
529 if (vScrollBar && vScrollBar->isVisible())
531 if (vPos == QwtPlot::yLeft)
537 hScrollBar->setGeometry(x, y, w, hdim);
540 if (vScrollBar && vScrollBar->isVisible())
547 int x = (vPos == QwtPlot::yLeft)
548 ? rect.left() : rect.right() - vdim + 1;
551 int h = rect.height();
553 if (hScrollBar && hScrollBar->isVisible())
555 if (hPos == QwtPlot::xTop)
561 vScrollBar->setGeometry(x, y, vdim, h);
564 if (hScrollBar && hScrollBar->isVisible() &&
565 vScrollBar && vScrollBar->isVisible())
570 vScrollBar->pos().x(), hScrollBar->pos().y(),
579 if (o == Qt::Horizontal)
580 move(min, zoomRect().top());
582 move(zoomRect().left(), min);
584 emit zoomed(zoomRect());
591 case QwtPlot::xBottom:
592 return QwtPlot::xTop;
594 return QwtPlot::xBottom;
596 return QwtPlot::yRight;
597 case QwtPlot::yRight:
598 return QwtPlot::yLeft;
virtual void move(double x, double y)
LogPlotZoomer(QwtPlotCanvas *canvas)
virtual QwtText trackerText(const QwtDoublePoint &pos) const