Esempio n. 1
0
static void corners(
    Coord& left, Coord& bottom, Coord& right, Coord& top, const Transformer& t
) {
    Coord x1, y1, x2, y2, x3, y3, x4, y4;
    
    t.transform(left, bottom, x1, y1);
    t.transform(left, top, x2, y2);
    t.transform(right, top, x3, y3);
    t.transform(right, bottom, x4, y4);
    left = Math::min(x1, x2, x3, x4);
    bottom = Math::min(y1, y2, y3, y4);
    right = Math::max(x1, x2, x3, x4);
    top = Math::max(y1, y2, y3, y4);
}    
Esempio n. 2
0
void View::transform(
    Transformer& t, const Allocation& a, const Allocation&
) const {
    scene2view(a);
    const Allotment& ax = a.x_allotment();
    const Allotment& ay = a.y_allotment();
    csize(ax.begin(), ax.span(), ay.begin(), ay.span());
    float sx = ax.span()/XYView::width();
    float sy = ay.span()/XYView::height();
//	if (sx > sy) sx = sy;
    t.translate( -x(), -y());
    t.scale(sx, sx);
    View* v = (View*)this;
    v->x_pick_epsilon_ = pick_epsilon/sx;
    v->y_pick_epsilon_ = pick_epsilon/sx;
    t.translate((ax.begin() + ax.end())/2,(ay.begin() + ay.end())/2);
//printf("\nx origin=%g span=%g alignment=%g begin=%g end=%g\n", ax.origin(), ax.span(), ax.alignment(), ax.begin(), ax.end());
//printf("\ny origin=%g span=%g alignment=%g begin=%g end=%g\n", ay.origin(), ay.span(), ay.alignment(), ay.begin(), ay.end());
    Coord x1,y1;
    t.transform(x() - x_span_/2, y() - y_span_/2, x1, y1);
    if (!Math::equal(ax.begin(), x1, 1) || !Math::equal(ay.begin(), y1, 1)) {
        t.inverse_transform(ax.begin(), ay.begin(), x1, y1);
        v->x_span_ = 2*(x() - x1);
        v->y_span_ = 2*(y() - y1);
        v->size(x1,y1,x1+v->x_span_, y1+v->y_span_);
    }

}
Esempio n. 3
0
static bool straight(
    const Transformer& tx,
    Coord x0, Coord y0, Coord x1, Coord y1,
    Coord x2, Coord y2, Coord x3, Coord y3)
{
    Coord tx0, tx1, tx2, tx3;
    Coord ty0, ty1, ty2, ty3;
    tx.transform(x0, y0, tx0, ty0);
    tx.transform(x1, y1, tx1, ty1);
    tx.transform(x2, y2, tx2, ty2);
    tx.transform(x3, y3, tx3, ty3);
    float f = (
                  (tx1 + tx2) * (ty0 - ty3) + (ty1 + ty2) * (tx3 - tx0)
                  + 2 * (tx0 * ty3 - ty0 * tx3)
              );
    return (f * f) < smoothness;
}
Esempio n. 4
0
static void Xform_gs(
    Coord x[], Coord y[], int n, Coord tx[], Coord ty[], Graphic31* g
) {
    Transformer* t = g->transformer();
    if (t != nil) {
        register Coord* ox, * oy, *nx, *ny;
        Coord* lim;
        
        lim = &x[n];
        for (
            ox = x, oy = y, nx = tx, ny = ty; ox < lim; ox++, oy++, nx++, ny++
        ) {
            t->transform(*ox, *oy, *nx, *ny);
        }
    } else {
        Memory::copy(x, tx, n*sizeof(Coord));
        Memory::copy(y, ty, n*sizeof(Coord));
    }
}