Here is situation. I have a class inherited from QwtPlot. I use QwtPlotIntervalCurve to plot squares of certain height regardless of scaling (i.e. width between top and bottom side of square set by QwtPlotInterval must be always constant if I zoom in or zoom out). But it looks like if I use something like QWidget::mapToGlobal() or QWidget::mapFromGlobal of QwtPlotCanvas (this->canvas()->mapFromGlobal()) all conversions are done inside of QwtPlotCanvas automatically, and size of square is wrong. Am I right about it? In that case is it possible in Qwt to play with local and global coordinates for solving that situation, and if answer is "yes", how can it be done?
P.S. Am I right that every coordinate that we specify to plot elements are firstly exist in global coordinate space and QwtPlot converts it to local coordinate space itself?
Here is code I used:
...
const qreal c_dYCoord = findMiddleYCoordByInterval(m_vYCoords[c_uCurveNum]);
const qreal c_dSquareheight = qMax(static_cast<qreal>(msc_iTextHeight), msc_iLineNonEmptyWidth * c_dPercents / msc_uMaxPercents);
const QPointF c_top
= this
->canvas
()->mapFromGlobal
(QPoint(0, c_dYCoord
+ c_dSquareheight
));
const QPointF c_bottom
= this
->canvas
()->mapFromGlobal
(QPoint(0, c_dYCoord
- c_dSquareheight
));
const qreal c_dRealHeight = c_top.y() - c_bottom.y();
const QwtInterval c_intervalToAttach(c_dYCoord - c_dRealHeight, c_dYCoord + c_dRealHeight);
...
currentCurve.push_back(QwtIntervalSample(dCurTime_sec, c_intervalToAttach)); //currentCurve is actually vector of QwtIntervalSample
currPlotElement->setSamples(currentCurve); //currPlotElement is QwtPlotIntervalCurve* sample.
...
...
const qreal c_dYCoord = findMiddleYCoordByInterval(m_vYCoords[c_uCurveNum]);
const qreal c_dSquareheight = qMax(static_cast<qreal>(msc_iTextHeight), msc_iLineNonEmptyWidth * c_dPercents / msc_uMaxPercents);
const QPointF c_top = this->canvas()->mapFromGlobal(QPoint(0, c_dYCoord + c_dSquareheight));
const QPointF c_bottom = this->canvas()->mapFromGlobal(QPoint(0, c_dYCoord - c_dSquareheight));
const qreal c_dRealHeight = c_top.y() - c_bottom.y();
const QwtInterval c_intervalToAttach(c_dYCoord - c_dRealHeight, c_dYCoord + c_dRealHeight);
...
currentCurve.push_back(QwtIntervalSample(dCurTime_sec, c_intervalToAttach)); //currentCurve is actually vector of QwtIntervalSample
currPlotElement->setSamples(currentCurve); //currPlotElement is QwtPlotIntervalCurve* sample.
...
To copy to clipboard, switch view to plain text mode
Thanks,
Toniy.
Bookmarks