On Thursday 04 April 2002 11:26 am, Herbert Voss wrote:
> R. Lahaye wrote:
> > "R. Lahaye" wrote:
> >>Note: this muddling up is only for the LyX View on the canvas; in the
> >> final DVI or Postscript View the bounding box coordinates seem to work
> >> fine.
> >
> > Actually, now I think that the bounding box limits have different effects
> > on the LyX View and on the final LaTeX output (DVI/Postscript).
> >
> > I noticed that clipping may make parts of the graph disappear on the
> > canvas, but to have the same effect in the DVI or Postscript output,
> > I need to modify the bounding box values!
> >
> > Bounding box and clipping has apparently different effects for the LyX
> > View graph and the final LaTeX output. One of them is thus wrongly done.
>
> maybe that I'm totally wrong here (Angus??) but the boundingbox is never
> used for the lyx-view.
>
> Herbert

Maybe you're totally wrong, but I think it is. Of course, the code may be 
buggy...

File src/graphics/GraphicsParams.C:

GParams::GParams(InsetGraphicsParams const & iparams, string const & filepath)
        : width(0),
          height(0),
          scale(0),
          angle(0)
{
        ...
        if (iparams.clip)
                bb = iparams.bb;
        ...
}

where BoundingBox bb is set so:

BoundingBox::BoundingBox(string const & bb)
{
        if (bb.empty())
                return;

        string tmp1;
        string tmp2 = split(bb, tmp1, ' ');
        if (!isValidLength(tmp1))
                return;

        LyXLength const length_xl(tmp1);

        tmp2 = split(tmp2, tmp1, ' ');
        if (!isValidLength(tmp1))
                return;

        LyXLength const length_yb(tmp1);

        tmp2 = split(tmp2, tmp1, ' ');
        if (!isValidLength(tmp1) || !isValidLength(tmp2))
                return;

        LyXLength const length_xr(tmp1);
        LyXLength const length_yt(tmp2);

        // inPixels returns the length in inches, scaled by
        // lyxrc.dpi and lyxrc.zoom.
        // We want, therefore, to undo all this lyxrc nonsense because we
        // want the bounding box in Postscript pixels.
        // Note further that there are 72 Postscript pixels per inch.
        double const scaling_factor = 7200.0 / (lyxrc.dpi * lyxrc.zoom);
        xl = uint(scaling_factor * length_xl.inPixels(1, 1));
        yb = uint(scaling_factor * length_yb.inPixels(1, 1));
        xr = uint(scaling_factor * length_xr.inPixels(1, 1));
        yt = uint(scaling_factor * length_yt.inPixels(1, 1));

        if (xr <= xl || yt <= yb) {
                xl = 0;
                yb = 0;
                xr = 0;
                yt = 0;
                return;
        }
}

Reply via email to