Re: Issue with QwtPlotRescaler
Brought to you by:
rathmann
|
From: Sébastien P. <per...@ge...> - 2019-09-10 08:34:28
|
Hi Uwe,
Thanks for the answer!
In playground/rescaler, the ellipses are supposed to be circles due to
const QRectF area( x - r, y - r , 2 * r, 2 * r );
but this is not the case on display, of course if the rescaler mode is
None, but also for the other mode.
I add some code in RectItem::draw() to illustrate this (see code below).
It displays the ratio between the y scale and the x scale and then we can
see that the ratio is exactly 1 only if the canvas is a square.
We can also see that the line const QRectF rect =
QwtScaleMap::transform( xMap, yMap, d_rect ); does not return a square even
if d_rect is a square.
Unlike I wrote in my previous message, it seems to have nothing to do with
the flag alignCanvasToScale ...
The problem for me is that in my PlotItem::draw() implementation I rely on
a ratio equal to 1 to correctly display a not distorted rotated rectangle.
Sebastien.
virtual void draw( QPainter *painter,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF & ) const
{
if ( d_rect.isValid() )
{
* const double x_scale = qAbs((xMap.p2()-xMap.p1()) /
(xMap.s2()-xMap.s1()));*
* const double y_scale = qAbs((yMap.p2()-yMap.p1()) /
(yMap.s2()-yMap.s1()));*
const QRectF rect = QwtScaleMap::transform(
xMap, yMap, d_rect );
* const QString text = QString("%1 %2\n%3\n%4 %5")*
*
.arg(d_rect.width()).arg(d_rect.height()).arg(y_scale / x_scale)*
* .arg(rect.width()).arg(rect.height());*
painter->setPen( d_pen );
painter->setBrush( d_brush );
if ( d_type == Ellipse )
QwtPainter::drawEllipse( painter, rect );
else
QwtPainter::drawRect( painter, rect );
* QwtPainter::drawText(painter, rect, Qt::AlignCenter, text);*
}
}
Le mar. 10 sept. 2019 à 08:34, Uwe Rathmann <Uwe...@ti...> a
écrit :
> On 9/9/19 11:20 AM, Sébastien Perseval wrote:
>
> > I think the problem is that the method QwtPlotRescaler::rescale(const
> > QSize &oldSize, const QSize &newSize) uses the size of the canvas to
> > update the axes according to the reference axis, ignoring the actual
> > size of the axes.
>
> playground/rescaler shows the different modes of QwtPlotRescaler and how
> they are supposed to work.
>
> Could you please explain what exactly is missing or going wrong by
> modifying this example ?
>
> Uwe
>
>
> _______________________________________________
> qwt-interest mailing list
> qwt...@li...
> https://lists.sourceforge.net/lists/listinfo/qwt-interest
>
|