From d42c46236b7e1e52ff2b0e0463384e1c04f2a021 Mon Sep 17 00:00:00 2001 From: Sean Rhea Date: Sun, 20 Sep 2009 10:12:23 -0700 Subject: [PATCH] apply many axes patch --- qwt/examples/examples.pro | 1 + qwt/examples/many_axes/mainwindow.cpp | 56 +++++++ qwt/examples/many_axes/mainwindow.h | 22 +++ qwt/examples/many_axes/many_axes.cpp | 17 +++ qwt/examples/many_axes/many_axes.pro | 21 +++ qwt/examples/many_axes/plot.h | 152 +++++++++++++++++++ qwt/src/qwt_plot.cpp | 28 +++- qwt/src/qwt_plot.h | 7 +- qwt/src/qwt_plot_axis.cpp | 18 +++ qwt/src/qwt_plot_item.cpp | 12 +- qwt/src/qwt_plot_layout.cpp | 208 +++++++++++++++++++------- 11 files changed, 482 insertions(+), 60 deletions(-) create mode 100644 qwt/examples/many_axes/mainwindow.cpp create mode 100644 qwt/examples/many_axes/mainwindow.h create mode 100644 qwt/examples/many_axes/many_axes.cpp create mode 100644 qwt/examples/many_axes/many_axes.pro create mode 100644 qwt/examples/many_axes/plot.h diff --git a/qwt/examples/examples.pro b/qwt/examples/examples.pro index 0912d1260..876a449ec 100644 --- a/qwt/examples/examples.pro +++ b/qwt/examples/examples.pro @@ -17,6 +17,7 @@ contains(CONFIG, QwtPlot) { cpuplot \ curvdemo1 \ curvdemo2 \ + many_axes \ simple_plot \ realtime_plot \ spectrogram \ diff --git a/qwt/examples/many_axes/mainwindow.cpp b/qwt/examples/many_axes/mainwindow.cpp new file mode 100644 index 000000000..9e6a8ef8c --- /dev/null +++ b/qwt/examples/many_axes/mainwindow.cpp @@ -0,0 +1,56 @@ +#include +#include +#include +#include +#include "plot.h" +#include "mainwindow.h" + +MainWindow::MainWindow() +{ + QFrame *w = new QFrame(this); + + // create the box of checkboxes + + QGroupBox *panel = new QGroupBox("Axes", w); + QVBoxLayout *vLayout = new QVBoxLayout(panel); + + QStringList list; + list << "yLeft" << "yLeft1" << "yLeft2" << "yLeft3"; + list << "yRight" << "yRight1" << "yRight2" << "yRight3"; + + QSignalMapper* signalMapper = new QSignalMapper(this); + + QCheckBox* checkBox; + for(int i = 0; i < 8; i++) + { + checkBox = new QCheckBox(list[i], panel); + checkBox->setChecked(true); + connect(checkBox, SIGNAL(clicked()), signalMapper, SLOT(map())); + signalMapper->setMapping(checkBox, i); + vLayout->addWidget(checkBox); + } + + connect(signalMapper, SIGNAL(mapped(int)), + this, SLOT(axisCheckBoxToggled(int))); + + vLayout->addStretch(10); + + // create the plot widget + + d_plot = new Plot(w); + d_plot->replot(); + + // put the widgets in a horizontal box + + QHBoxLayout *hLayout = new QHBoxLayout(w); + hLayout->setMargin(0); + hLayout->addWidget(panel, 10); + hLayout->addWidget(d_plot, 10); + + setCentralWidget(w); +} + +void MainWindow::axisCheckBoxToggled(int axis) +{ + d_plot->enableAxis(axis, !d_plot->axisEnabled(axis)); +} diff --git a/qwt/examples/many_axes/mainwindow.h b/qwt/examples/many_axes/mainwindow.h new file mode 100644 index 000000000..76ad93154 --- /dev/null +++ b/qwt/examples/many_axes/mainwindow.h @@ -0,0 +1,22 @@ +#ifndef _MAINWINDOW_H_ +#define _MAINWINDOW_H_ + +#include + +class Plot; + +class MainWindow: public QMainWindow +{ + Q_OBJECT + + public: + MainWindow(); + + private slots: + void axisCheckBoxToggled(int axis); + + private: + Plot *d_plot; +}; + +#endif // _MAINWINDOW_H_ diff --git a/qwt/examples/many_axes/many_axes.cpp b/qwt/examples/many_axes/many_axes.cpp new file mode 100644 index 000000000..5975fcec8 --- /dev/null +++ b/qwt/examples/many_axes/many_axes.cpp @@ -0,0 +1,17 @@ +#include +#include "mainwindow.h" + +//----------------------------------------------------------------- +// many_axes.cpp +// +// An example that demonstrates a plot with many axes. +//----------------------------------------------------------------- + +int main(int argc, char **argv) +{ + QApplication a(argc, argv); + + MainWindow mainWindow; + mainWindow.show(); + return a.exec(); +} diff --git a/qwt/examples/many_axes/many_axes.pro b/qwt/examples/many_axes/many_axes.pro new file mode 100644 index 000000000..553b3ee41 --- /dev/null +++ b/qwt/examples/many_axes/many_axes.pro @@ -0,0 +1,21 @@ +# -*- mode: sh -*- ################################################ +# Qwt Widget Library +# Copyright (C) 1997 Josef Wilgen +# Copyright (C) 2002 Uwe Rathmann +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the Qwt License, Version 1.0 +################################################################### + +include( ../examples.pri ) + +TARGET = many_axes +CONFIG += static + +SOURCES = \ + many_axes.cpp \ + mainwindow.cpp + +HEADERS = \ + plot.h \ + mainwindow.h diff --git a/qwt/examples/many_axes/plot.h b/qwt/examples/many_axes/plot.h new file mode 100644 index 000000000..0d4a41d32 --- /dev/null +++ b/qwt/examples/many_axes/plot.h @@ -0,0 +1,152 @@ +#ifndef _PLOT_H_ +#define _PLOT_H_ + +#include +#include +#include +#include +#include +#include + +/*class FunctionData: public QwtSyntheticPointData +{ + public: + FunctionData(double(*y)(double)): + QwtSyntheticPointData(100), + d_y(y) + { + } + + virtual QwtSeriesData *copy() const + { + return new FunctionData(d_y); + } + + virtual double y(double x) const + { + return d_y(x); + } + + private: + double(*d_y)(double); +};*/ + +//----------------------------------------------------------------- +// simple.cpp +// +// A simple example which shows how to use QwtPlot and QwtData +//----------------------------------------------------------------- + +class SimpleData: public QwtData +{ + // The x values depend on its index and the y values + // can be calculated from the corresponding x value. + // So we don“t need to store the values. + // Such an implementation is slower because every point + // has to be recalculated for every replot, but it demonstrates how + // QwtData can be used. + +public: + SimpleData(double(*y)(double), size_t size): + d_size(size), + d_y(y) + { + } + + virtual QwtData *copy() const + { + return new SimpleData(d_y, d_size); + } + + virtual size_t size() const + { + return d_size; + } + + virtual double x(size_t i) const + { + return 0.1 * i; + } + + virtual double y(size_t i) const + { + return d_y(x(i)); + } +private: + size_t d_size; + double(*d_y)(double); +}; + +class Plot : public QwtPlot +{ + public: + Plot(QWidget* widget) : + QwtPlot(widget) + { + setTitle("A Simple QwtPlot Demonstration"); + insertLegend(new QwtLegend(), QwtPlot::RightLegend); + + // Set axes + setAxisTitle(xBottom, "xBottom"); + setAxisScale(xBottom, 0.0, 10.0); + + setAxisTitle(yLeft, "yLeft"); + setAxisScale(yLeft, -1.0, 1.0); + enableAxis(yLeft1); + setAxisTitle(yLeft1, "yLeft1"); + enableAxis(yLeft2); + setAxisTitle(yLeft2, "yLeft2"); + enableAxis(yLeft3); + setAxisTitle(yLeft3, "yLeft3"); + enableAxis(yRight); + setAxisTitle(yRight, "yRight"); + enableAxis(yRight1); + setAxisTitle(yRight1, "yRight1"); + enableAxis(yRight2); + setAxisTitle(yRight2, "yRight2"); + enableAxis(yRight3); + setAxisTitle(yRight3, "yRight3"); + + // Insert new curves + QwtPlotCurve *cSin = new QwtPlotCurve("y = sin(x)"); +#if QT_VERSION >= 0x040000 + cSin->setRenderHint(QwtPlotItem::RenderAntialiased); +#endif + cSin->setPen(QPen(Qt::red)); + cSin->attach(this); + //cSin->setAxis(QwtPlot::xBottom, QwtPlot::yLeft); + + QwtPlotCurve *cCos = new QwtPlotCurve("y = cos(x)"); +#if QT_VERSION >= 0x040000 + cCos->setRenderHint(QwtPlotItem::RenderAntialiased); +#endif + cCos->setPen(QPen(Qt::blue)); + cCos->attach(this); + //cCos->setAxis(QwtPlot::xBottom, QwtPlot::yRight); + + // Create sin and cos data + const int nPoints = 100; + cSin->setData(SimpleData(::sin, nPoints)); + cCos->setData(SimpleData(::cos, nPoints)); + + // Insert markers + + // ...a horizontal line at y = 0... + QwtPlotMarker *mY = new QwtPlotMarker(); + mY->setLabel(QString::fromLatin1("y = 0")); + mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop); + mY->setLineStyle(QwtPlotMarker::HLine); + mY->setYValue(0.0); + mY->attach(this); + + // ...a vertical line at x = 2 * pi + QwtPlotMarker *mX = new QwtPlotMarker(); + mX->setLabel(QString::fromLatin1("x = 2 pi")); + mX->setLabelAlignment(Qt::AlignRight|Qt::AlignTop); + mX->setLineStyle(QwtPlotMarker::VLine); + mX->setXValue(6.284); + mX->attach(this); + } +}; + +#endif // _PLOT_H_ diff --git a/qwt/src/qwt_plot.cpp b/qwt/src/qwt_plot.cpp index 8ca6ef8dd..508ee7d1e 100644 --- a/qwt/src/qwt_plot.cpp +++ b/qwt/src/qwt_plot.cpp @@ -313,7 +313,10 @@ QSize QwtPlot::sizeHint() const const QwtScaleDiv &scaleDiv = scaleWidget->scaleDraw()->scaleDiv(); const int majCnt = scaleDiv.ticks(QwtScaleDiv::MajorTick).count(); - if ( axisId == yLeft || axisId == yRight ) + if ( axisId == yLeft || axisId == yRight || + axisId == yLeft1 || axisId == yRight1 || + axisId == yLeft2 || axisId == yRight2 || + axisId == yLeft3 || axisId == yRight3 ) { int hDiff = (majCnt - 1) * niceDist - scaleWidget->minimumSizeHint().height(); @@ -417,8 +420,20 @@ void QwtPlot::updateLayout() QRegion r(d_data->layout->scaleRect(axisId)); if ( axisEnabled(yLeft) ) r = r.subtract(QRegion(d_data->layout->scaleRect(yLeft))); + if ( axisEnabled(yLeft1) ) + r = r.subtract(QRegion(d_data->layout->scaleRect(yLeft1))); + if ( axisEnabled(yLeft2) ) + r = r.subtract(QRegion(d_data->layout->scaleRect(yLeft2))); + if ( axisEnabled(yLeft3) ) + r = r.subtract(QRegion(d_data->layout->scaleRect(yLeft3))); if ( axisEnabled(yRight) ) r = r.subtract(QRegion(d_data->layout->scaleRect(yRight))); + if ( axisEnabled(yRight1) ) + r = r.subtract(QRegion(d_data->layout->scaleRect(yRight1))); + if ( axisEnabled(yRight2) ) + r = r.subtract(QRegion(d_data->layout->scaleRect(yRight2))); + if ( axisEnabled(yRight3) ) + r = r.subtract(QRegion(d_data->layout->scaleRect(yRight3))); r.translate(-d_data->layout->scaleRect(axisId).x(), -d_data->layout->scaleRect(axisId).y()); @@ -603,7 +618,10 @@ QwtScaleMap QwtPlot::canvasMap(int axisId) const if ( axisEnabled(axisId) ) { const QwtScaleWidget *s = axisWidget(axisId); - if ( axisId == yLeft || axisId == yRight ) + if ( axisId == yLeft || axisId == yRight || + axisId == yLeft1 || axisId == yRight1 || + axisId == yLeft2 || axisId == yRight2 || + axisId == yLeft3 || axisId == yRight3 ) { int y = s->y() + s->startBorderDist() - d_data->canvas->y(); int h = s->height() - s->startBorderDist() - s->endBorderDist(); @@ -621,7 +639,11 @@ QwtScaleMap QwtPlot::canvasMap(int axisId) const const int margin = plotLayout()->canvasMargin(axisId); const QRect &canvasRect = d_data->canvas->contentsRect(); - if ( axisId == yLeft || axisId == yRight ) + + if ( axisId == yLeft || axisId == yRight || + axisId == yLeft1 || axisId == yRight1 || + axisId == yLeft2 || axisId == yRight2 || + axisId == yLeft3 || axisId == yRight3 ) { map.setPaintInterval(canvasRect.bottom() - margin, canvasRect.top() + margin); diff --git a/qwt/src/qwt_plot.h b/qwt/src/qwt_plot.h index 42a641158..0db472b80 100644 --- a/qwt/src/qwt_plot.h +++ b/qwt/src/qwt_plot.h @@ -87,10 +87,15 @@ public: enum Axis { yLeft, + yLeft1, + yLeft2, + yLeft3, yRight, + yRight1, + yRight2, + yRight3, xBottom, xTop, - axisCnt }; diff --git a/qwt/src/qwt_plot_axis.cpp b/qwt/src/qwt_plot_axis.cpp index e85c5abe0..6432e4cf8 100644 --- a/qwt/src/qwt_plot_axis.cpp +++ b/qwt/src/qwt_plot_axis.cpp @@ -41,8 +41,20 @@ void QwtPlot::initAxesData() d_axisData[yLeft]->scaleWidget = new QwtScaleWidget(QwtScaleDraw::LeftScale, this); + d_axisData[yLeft1]->scaleWidget = + new QwtScaleWidget(QwtScaleDraw::LeftScale, this); + d_axisData[yLeft2]->scaleWidget = + new QwtScaleWidget(QwtScaleDraw::LeftScale, this); + d_axisData[yLeft3]->scaleWidget = + new QwtScaleWidget(QwtScaleDraw::LeftScale, this); d_axisData[yRight]->scaleWidget = new QwtScaleWidget(QwtScaleDraw::RightScale, this); + d_axisData[yRight1]->scaleWidget = + new QwtScaleWidget(QwtScaleDraw::RightScale, this); + d_axisData[yRight2]->scaleWidget = + new QwtScaleWidget(QwtScaleDraw::RightScale, this); + d_axisData[yRight3]->scaleWidget = + new QwtScaleWidget(QwtScaleDraw::RightScale, this); d_axisData[xTop]->scaleWidget = new QwtScaleWidget(QwtScaleDraw::TopScale, this); d_axisData[xBottom]->scaleWidget = @@ -78,7 +90,13 @@ void QwtPlot::initAxesData() } d_axisData[yLeft]->isEnabled = true; + d_axisData[yLeft1]->isEnabled = false; + d_axisData[yLeft2]->isEnabled = false; + d_axisData[yLeft3]->isEnabled = false; d_axisData[yRight]->isEnabled = false; + d_axisData[yRight1]->isEnabled = false; + d_axisData[yRight2]->isEnabled = false; + d_axisData[yRight3]->isEnabled = false; d_axisData[xBottom]->isEnabled = true; d_axisData[xTop]->isEnabled = false; } diff --git a/qwt/src/qwt_plot_item.cpp b/qwt/src/qwt_plot_item.cpp index d32cda639..6587e4c49 100644 --- a/qwt/src/qwt_plot_item.cpp +++ b/qwt/src/qwt_plot_item.cpp @@ -334,8 +334,11 @@ void QwtPlotItem::setAxis(int xAxis, int yAxis) if (xAxis == QwtPlot::xBottom || xAxis == QwtPlot::xTop ) d_data->xAxis = xAxis; - if (yAxis == QwtPlot::yLeft || yAxis == QwtPlot::yRight ) - d_data->yAxis = yAxis; + if ( yAxis == QwtPlot::yLeft || yAxis == QwtPlot::yRight || + yAxis == QwtPlot::yLeft1 || yAxis == QwtPlot::yRight1 || + yAxis == QwtPlot::yLeft2 || yAxis == QwtPlot::yRight2 || + yAxis == QwtPlot::yLeft3 || yAxis == QwtPlot::yRight3 ) + d_data->yAxis = yAxis; itemChanged(); } @@ -367,7 +370,10 @@ void QwtPlotItem::setXAxis(int axis) */ void QwtPlotItem::setYAxis(int axis) { - if (axis == QwtPlot::yLeft || axis == QwtPlot::yRight ) + if ( axis == QwtPlot::yLeft || axis == QwtPlot::yRight || + axis == QwtPlot::yLeft1 || axis == QwtPlot::yRight1 || + axis == QwtPlot::yLeft2 || axis == QwtPlot::yRight2 || + axis == QwtPlot::yLeft3 || axis == QwtPlot::yRight3 ) { d_data->yAxis = axis; itemChanged(); diff --git a/qwt/src/qwt_plot_layout.cpp b/qwt/src/qwt_plot_layout.cpp index e368e2abf..8bbcb8863 100644 --- a/qwt/src/qwt_plot_layout.cpp +++ b/qwt/src/qwt_plot_layout.cpp @@ -501,33 +501,96 @@ QSize QwtPlotLayout::minimumSizeHint(const QwtPlot *plot) const } - for ( axis = 0; axis < QwtPlot::axisCnt; axis++ ) { ScaleData &sd = scaleData[axis]; if ( sd.w && (axis == QwtPlot::xBottom || axis == QwtPlot::xTop) ) { - if ( (sd.minLeft > canvasBorder[QwtPlot::yLeft]) - && scaleData[QwtPlot::yLeft].w ) + if ( (sd.minLeft > canvasBorder[QwtPlot::yLeft3]) + && scaleData[QwtPlot::yLeft3].w ) { - int shiftLeft = sd.minLeft - canvasBorder[QwtPlot::yLeft]; - if ( shiftLeft > scaleData[QwtPlot::yLeft].w ) - shiftLeft = scaleData[QwtPlot::yLeft].w; + int shiftLeft = sd.minLeft - canvasBorder[QwtPlot::yLeft3]; + if ( shiftLeft > scaleData[QwtPlot::yLeft3].w ) + shiftLeft = scaleData[QwtPlot::yLeft3].w; sd.w -= shiftLeft; } - if ( (sd.minRight > canvasBorder[QwtPlot::yRight]) + if ( (sd.minLeft > canvasBorder[QwtPlot::yLeft3]) + && scaleData[QwtPlot::yLeft2].w ) + { + int shiftLeft = sd.minLeft - scaleData[QwtPlot::yLeft3].w - canvasBorder[QwtPlot::yLeft3]; + if ( shiftLeft > (scaleData[QwtPlot::yLeft3].w + scaleData[QwtPlot::yLeft2].w) ) + shiftLeft = scaleData[QwtPlot::yLeft3].w + scaleData[QwtPlot::yLeft2].w; + + sd.w -= shiftLeft; + } + if ( (sd.minLeft > canvasBorder[QwtPlot::yLeft3]) + && scaleData[QwtPlot::yLeft1].w ) + { + int shiftLeft = sd.minLeft - scaleData[QwtPlot::yLeft3].w - scaleData[QwtPlot::yLeft2].w - canvasBorder[QwtPlot::yLeft3]; + if ( shiftLeft > (scaleData[QwtPlot::yLeft3].w + scaleData[QwtPlot::yLeft2].w + scaleData[QwtPlot::yLeft1].w) ) + shiftLeft = scaleData[QwtPlot::yLeft3].w + scaleData[QwtPlot::yLeft2].w + scaleData[QwtPlot::yLeft1].w; + + sd.w -= shiftLeft; + } + if ( (sd.minLeft > canvasBorder[QwtPlot::yLeft3]) + && scaleData[QwtPlot::yLeft].w ) + { + int shiftLeft = sd.minLeft - scaleData[QwtPlot::yLeft3].w - scaleData[QwtPlot::yLeft2].w + - scaleData[QwtPlot::yLeft1].w - canvasBorder[QwtPlot::yLeft3]; + if ( shiftLeft > (scaleData[QwtPlot::yLeft3].w + scaleData[QwtPlot::yLeft2].w + + scaleData[QwtPlot::yLeft1].w + scaleData[QwtPlot::yLeft].w) ) + shiftLeft = scaleData[QwtPlot::yLeft3].w + scaleData[QwtPlot::yLeft2].w + + scaleData[QwtPlot::yLeft1].w + scaleData[QwtPlot::yLeft].w; + sd.w -= shiftLeft; + } + + if ( (sd.minRight > canvasBorder[QwtPlot::yRight3]) + && scaleData[QwtPlot::yRight3].w ) + { + int shiftRight = sd.minRight - canvasBorder[QwtPlot::yRight3]; + if ( shiftRight > scaleData[QwtPlot::yRight3].w ) + shiftRight = scaleData[QwtPlot::yRight3].w; + + sd.w -= shiftRight; + } + if ( (sd.minRight > canvasBorder[QwtPlot::yRight3]) + && scaleData[QwtPlot::yRight2].w ) + { + int shiftRight = sd.minRight - scaleData[QwtPlot::yRight3].w - canvasBorder[QwtPlot::yRight3]; + if ( shiftRight > (scaleData[QwtPlot::yRight3].w + scaleData[QwtPlot::yRight2].w) ) + shiftRight = scaleData[QwtPlot::yRight3].w + scaleData[QwtPlot::yRight2].w; + + sd.w -=shiftRight; + } + if ( (sd.minRight > canvasBorder[QwtPlot::yRight3]) + && scaleData[QwtPlot::yRight1].w ) + { + int shiftRight = sd.minRight - scaleData[QwtPlot::yRight3].w - scaleData[QwtPlot::yRight2].w + - canvasBorder[QwtPlot::yRight3]; + if ( shiftRight > (scaleData[QwtPlot::yRight3].w + scaleData[QwtPlot::yRight2].w + scaleData[QwtPlot::yRight1].w) ) + shiftRight = scaleData[QwtPlot::yRight3].w + scaleData[QwtPlot::yRight2].w + scaleData[QwtPlot::yRight1].w; + + sd.w -= shiftRight; + } + if ( (sd.minRight > canvasBorder[QwtPlot::yRight3]) && scaleData[QwtPlot::yRight].w ) { - int shiftRight = sd.minRight - canvasBorder[QwtPlot::yRight]; - if ( shiftRight > scaleData[QwtPlot::yRight].w ) - shiftRight = scaleData[QwtPlot::yRight].w; + int shiftRight = sd.minRight - scaleData[QwtPlot::yRight3].w - scaleData[QwtPlot::yRight2].w + - scaleData[QwtPlot::yRight1].w - canvasBorder[QwtPlot::yRight3]; + if ( shiftRight > (scaleData[QwtPlot::yRight3].w + scaleData[QwtPlot::yRight2].w + +scaleData[QwtPlot::yRight1].w + scaleData[QwtPlot::yRight].w) ) + shiftRight = scaleData[QwtPlot::yRight3].w + scaleData[QwtPlot::yRight2].w + +scaleData[QwtPlot::yRight1].w + scaleData[QwtPlot::yRight].w; sd.w -= shiftRight; } } - if ( sd.h && (axis == QwtPlot::yLeft || axis == QwtPlot::yRight) ) + if ( sd.h && (axis == QwtPlot::yLeft || axis == QwtPlot::yRight || + axis == QwtPlot::yLeft1 || axis == QwtPlot::yRight1 || + axis == QwtPlot::yLeft2 || axis == QwtPlot::yRight2 || + axis == QwtPlot::yLeft3 || axis == QwtPlot::yRight3)) { if ( (sd.minLeft > canvasBorder[QwtPlot::xBottom]) && scaleData[QwtPlot::xBottom].h ) @@ -553,7 +616,10 @@ QSize QwtPlotLayout::minimumSizeHint(const QwtPlot *plot) const const QwtPlotCanvas *canvas = plot->canvas(); const QSize minCanvasSize = canvas->minimumSize(); - int w = scaleData[QwtPlot::yLeft].w + scaleData[QwtPlot::yRight].w; + int w = scaleData[QwtPlot::yLeft].w + scaleData[QwtPlot::yRight].w + + scaleData[QwtPlot::yLeft1].w + scaleData[QwtPlot::yRight1].w + + scaleData[QwtPlot::yLeft2].w + scaleData[QwtPlot::yRight2].w + + scaleData[QwtPlot::yLeft3].w + scaleData[QwtPlot::yRight3].w; int cw = qwtMax(scaleData[QwtPlot::xBottom].w, scaleData[QwtPlot::xTop].w) + 2 * (canvas->frameWidth() + 1); w += qwtMax(cw, minCanvasSize.width()); @@ -683,7 +749,7 @@ QRect QwtPlotLayout::layoutLegend(int options, legendRect.setWidth(dim); break; case QwtPlot::RightLegend: - legendRect.setX(rect.right() - dim + 1); + legendRect.setX(rect.right() - dim + 1 ); legendRect.setWidth(dim); break; case QwtPlot::TopLegend: @@ -897,51 +963,59 @@ void QwtPlotLayout::alignScales(int options, if ( axis == QwtPlot::xTop || axis == QwtPlot::xBottom ) { - const int leftOffset = - backboneOffset[QwtPlot::yLeft] - startDist; + for (int leftAxis = QwtPlot::yLeft3; + leftAxis <= QwtPlot::yLeft; leftAxis++) + { + const int leftOffset = + backboneOffset[leftAxis] - startDist; - if ( scaleRect[QwtPlot::yLeft].isValid() ) - { - int minLeft = scaleRect[QwtPlot::yLeft].left(); - int left = axisRect.left() + leftOffset; - axisRect.setLeft(qwtMax(left, minLeft)); - } - else - { - if ( d_data->alignCanvasToScales && leftOffset < 0 ) - { + if ( scaleRect[leftAxis].isValid() ) + { + int minLeft = scaleRect[leftAxis].left(); + int left = axisRect.left() + leftOffset; + axisRect.setLeft(qwtMax(left, minLeft)); + } + else + { + if ( d_data->alignCanvasToScales && leftOffset < 0 ) + { canvasRect.setLeft(qwtMax(canvasRect.left(), - axisRect.left() - leftOffset)); - } - else - { + axisRect.left() - leftOffset)); + } + else + { if ( leftOffset > 0 ) - axisRect.setLeft(axisRect.left() + leftOffset); - } - } + axisRect.setLeft(axisRect.left() + leftOffset); + } + } + } - const int rightOffset = - backboneOffset[QwtPlot::yRight] - endDist + 1; + for (int rightAxis = QwtPlot::yRight; + rightAxis <= QwtPlot::yRight3; rightAxis++) + { + const int rightOffset = + backboneOffset[rightAxis] - endDist + 1; - if ( scaleRect[QwtPlot::yRight].isValid() ) - { - int maxRight = scaleRect[QwtPlot::yRight].right(); - int right = axisRect.right() - rightOffset; - axisRect.setRight(qwtMin(right, maxRight)); - } - else - { - if ( d_data->alignCanvasToScales && rightOffset < 0 ) - { + if ( scaleRect[rightAxis].isValid() ) + { + int maxRight = scaleRect[rightAxis].right(); + int right = axisRect.right() - rightOffset; + axisRect.setRight(qwtMin(right, maxRight)); + } + else + { + if ( d_data->alignCanvasToScales && rightOffset < 0 ) + { canvasRect.setRight( qwtMin(canvasRect.right(), - axisRect.right() + rightOffset) ); - } - else - { + axisRect.right() + rightOffset) ); + } + else + { if ( rightOffset > 0 ) - axisRect.setRight(axisRect.right() - rightOffset); - } - } + axisRect.setRight(axisRect.right() - rightOffset); + } + } + } } else // QwtPlot::yLeft, QwtPlot::yRight { @@ -1154,9 +1228,13 @@ void QwtPlotLayout::activate(const QwtPlot *plot, } d_data->canvasRect.setRect( - rect.x() + dimAxes[QwtPlot::yLeft], + rect.x() + dimAxes[QwtPlot::yLeft3] + dimAxes[QwtPlot::yLeft2] + dimAxes[QwtPlot::yLeft1] + dimAxes[QwtPlot::yLeft] + 1, rect.y() + dimAxes[QwtPlot::xTop], - rect.width() - dimAxes[QwtPlot::yRight] - dimAxes[QwtPlot::yLeft], + rect.width() - ( + dimAxes[QwtPlot::yRight] + dimAxes[QwtPlot::yRight1] + + dimAxes[QwtPlot::yRight2] + dimAxes[QwtPlot::yRight3] + ) - (dimAxes[QwtPlot::yLeft] + dimAxes[QwtPlot::yLeft1] + + dimAxes[QwtPlot::yLeft2] + dimAxes[QwtPlot::yLeft3]), rect.height() - dimAxes[QwtPlot::xBottom] - dimAxes[QwtPlot::xTop]); for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) @@ -1171,6 +1249,18 @@ void QwtPlotLayout::activate(const QwtPlot *plot, scaleRect = d_data->canvasRect; switch(axis) { + case QwtPlot::yLeft3: + scaleRect.setX(d_data->canvasRect.left() - dim - dimAxes[QwtPlot::yLeft] - dimAxes[QwtPlot::yLeft1] - dimAxes[QwtPlot::yLeft2]); + scaleRect.setWidth(dim); + break; + case QwtPlot::yLeft2: + scaleRect.setX(d_data->canvasRect.left() - dim - dimAxes[QwtPlot::yLeft] - dimAxes[QwtPlot::yLeft1]); + scaleRect.setWidth(dim); + break; + case QwtPlot::yLeft1: + scaleRect.setX(d_data->canvasRect.left() - dim - dimAxes[QwtPlot::yLeft]); + scaleRect.setWidth(dim); + break; case QwtPlot::yLeft: scaleRect.setX(d_data->canvasRect.left() - dim); scaleRect.setWidth(dim); @@ -1179,6 +1269,18 @@ void QwtPlotLayout::activate(const QwtPlot *plot, scaleRect.setX(d_data->canvasRect.right() + 1); scaleRect.setWidth(dim); break; + case QwtPlot::yRight1: + scaleRect.setX(d_data->canvasRect.right() + 1 + dimAxes[QwtPlot::yRight]); //working + scaleRect.setWidth(dim); + break; + case QwtPlot::yRight2: + scaleRect.setX(d_data->canvasRect.right() + 1 + dimAxes[QwtPlot::yRight] + dimAxes[QwtPlot::yRight1]); + scaleRect.setWidth(dim); + break; + case QwtPlot::yRight3: + scaleRect.setX(d_data->canvasRect.right() + 1 + dimAxes[QwtPlot::yRight] + dimAxes[QwtPlot::yRight1] + dimAxes[QwtPlot::yRight2]); + scaleRect.setWidth(dim); + break; case QwtPlot::xBottom: scaleRect.setY(d_data->canvasRect.bottom() + 1); scaleRect.setHeight(dim);