예제 #1
0
/*!
  \param axis Axis
  \return Map for the axis on the canvas. With this map pixel coordinates can
          translated to plot coordinates and vice versa.
  \sa QwtDiMap, QwtPlot::transform, QwtPlot::invTransform
  
*/
QwtDiMap QwtPlot::canvasMap(int axis) const
{
    QwtDiMap map;
    if ( !d_canvas )
        return map;

    const QwtScaleDiv &sd = d_as[axis].scaleDiv();
    map.setDblRange(sd.lBound(), sd.hBound(), sd.logScale());

    if ( axisEnabled(axis) )
    {
        const QwtScale *s = d_scale[axis];
        if ( axis == yLeft || axis == yRight )
        {
            int y = s->y() + s->startBorderDist() - d_canvas->y();
            int h = s->height() - s->startBorderDist() - s->endBorderDist();
            map.setIntRange(y + h - 1, y);
        }
        else
        {
            int x = s->x() + s->startBorderDist() - d_canvas->x();
            int w = s->width() - s->startBorderDist() - s->endBorderDist();
            map.setIntRange(x, x + w - 1);
        }
    }
    else
    {
        const int margin = plotLayout()->canvasMargin(axis);

        const QRect &canvasRect = d_canvas->contentsRect();
        if ( axis == yLeft || axis == yRight )
        {
            map.setIntRange(canvasRect.bottom() - margin, 
                canvasRect.top() + margin);
        }
        else
        {
            map.setIntRange(canvasRect.left() + margin, 
                canvasRect.right() - margin);
        }
    }
    return map;
}
예제 #2
0
/*!
  \param axis Axis
  \return Map for the axis on the canvas. With this map pixel coordinates can
          translated to plot coordinates and vice versa.
  \sa QwtDiMap, QwtPlot::transform, QwtPlot::invTransform
  
*/
QwtDiMap QwtPlot::canvasMap(int axis) const
{
    QwtDiMap map;
    if ( d_canvas && d_scale[axis] )
    {
        const QwtScale *s = d_scale[axis];
        map = *s->scaleDraw();
        if ( axis == yLeft || axis == yRight )
        {
            int y = s->y() + s->startBorderDist() - d_canvas->y();
            int h = s->height() - s->startBorderDist() - s->endBorderDist();
            map.setIntRange(y + h, y);
        }
        else
        {
            int x = s->x() + s->startBorderDist() - d_canvas->x();
            int w = s->width() - s->startBorderDist() - s->endBorderDist();
            map.setIntRange(x, x + w);
        }
    }
    return map;
}