Exemple #1
0
def PolylineTo(mf, num, page, state):
    if state.DCs[state.curdc].pathmode:
        path = page.objs[state.DCs[state.curdc].pathobj]
        for j in range(len(mf.records[num].aptl)):
            x, y = mf.records[num].aptl[j]
            p = gmodel.Point()
            p.x, p.y = convcoords(state, x, y)
            pp = gmodel.PathPoint()
            pp.type = 2
            pp.pts.append(p)
            path.pplist.append(pp)
    else:
        pline = gmodel.Polyline()
        pline.pl0.x, pline.pl0.y = state.DCs[state.curdc].p0x, state.DCs[
            state.curdc].p0y
        for j in range(len(mf.records[num].aptl)):
            x, y = mf.records[num].aptl[j]
            p = gmodel.Point()
            p.x, p.y = convcoords(state, x, y)
            pline.pl.append(p)
        state.DCs[state.curdc].p0x, state.DCs[state.curdc].p0y = p.x, p.y
        ShapeSetStroke(pline, state, page.zoom)
        pline.pagetrafo = page.trafo
        page.objs.append(pline)
        print 'PolylineTo'
Exemple #2
0
def Polyline(mf, num, page, state):
    x, y = mf.records[num].aptl[0]
    xr, yr = convcoords(state, x, y)
    if state.DCs[state.curdc].pathmode:
        path = page.objs[state.DCs[state.curdc].pathobj]
        pp = gmodel.PathPoint()
        pp.type = 1
        p = gmodel.Point()
        p.x, p.y = xr, yr
        pp.pts.append(p)
        path.pplist.append(pp)
        for j in range(len(mf.records[num].aptl) - 1):
            x, y = mf.records[num].aptl[j + 1]
            p = gmodel.Point()
            p.x, p.y = convcoords(state, x, y)
            pp = gmodel.PathPoint()
            pp.type = 2
            pp.pts.append(p)
            path.pplist.append(pp)
    else:
        pline = gmodel.Polyline()
        pline.pl0.x, pline.pl0.y = xr, yr
        for j in range(len(mf.records[num].aptl) - 1):
            x, y = mf.records[num].aptl[j + 1]
            p = gmodel.Point()
            p.x, p.y = convcoords(state, x, y)
            pline.pl.append(p)
        ShapeSetStroke(pline, state, page.zoom)
        pline.pagetrafo = page.trafo
        page.objs.append(pline)
        print 'Polyline'
Exemple #3
0
def PolyPolygone(mf, num, page, state):
    nPolys = mf.records[num].nPolys
    erd = mf.records[num].data[2:]
    aptl = {}
    for i in range(nPolys):
        [aptl[i]] = struct.unpack('<h', erd[i * 2:i * 2 + 2])
    data = erd[nPolys * 2:]
    ppg = gmodel.PolyPolygone()
    shift = 0
    for k in range(nPolys):  ## number of polygones
        pgone = gmodel.Polygone()
        [x] = struct.unpack('<h', data[shift:shift + 2])
        [y] = struct.unpack('<h', data[shift + 2:shift + 4])
        pgone.pl0.x, pgone.pl0.y = convcoords(state, x, y)
        for j in range(aptl[k]):  ## number of gones for i-th polygone
            [x] = struct.unpack('<h', data[j * 4 + shift:j * 4 + shift + 2])
            [y] = struct.unpack('<h',
                                data[j * 4 + shift + 2:j * 4 + shift + 4])
            p = gmodel.Point()
            p.x, p.y = convcoords(state, x, y)
            pgone.pl.append(p)
        shift += aptl[k] * 4
        ppg.polys.append(pgone)
    ShapeSetFill(ppg, state)
    ShapeSetStroke(ppg, state, page.zoom)
    if state.clipflag:
        PathCopy(state, ppg)
        ppg.clipflag = state.clipflag
    page.objs.append(ppg)
Exemple #4
0
def PolyPolygone(mf, num, page, state):
    aPolyCounts = mf.records[num].aPolyCounts
    aptl = mf.records[num].aptl
    if state.DCs[state.curdc].pathmode:
        path = page.objs[state.DCs[state.curdc].pathobj]
        shift = 0
        for k in range(len(aPolyCounts)):  ## number of polygones
            x, y = aptl[shift]
            p = gmodel.Point()
            p.x, p.y = convcoords(state, x, y)
            pp = gmodel.PathPoint()
            pp.type = 1
            pp.pts.append(p)
            path.pplist.append(pp)
            for j in range(aPolyCounts[k] -
                           1):  ## number of gones for i-th polygone
                x, y = aptl[j + 1 + shift]
                p = gmodel.Point()
                p.x, p.y = convcoords(state, x, y)
                pp = gmodel.PathPoint()
                pp.type = 2
                pp.pts.append(p)
                path.pplist.append(pp)
            pp = gmodel.PathPoint()
            pp.type = 4
            path.pplist.append(pp)
            shift += aPolyCounts[k]
    else:
        ppg = gmodel.PolyPolygone()
        shift = 0
        for k in range(len(aPolyCounts)):  ## number of polygones
            x, y = aptl[shift]
            pgone = gmodel.Polygone()
            pgone.pl0.x, pgone.pl0.y = convcoords(state, x, y)
            for j in range(aPolyCounts[k] -
                           1):  ## number of gones for i-th polygone
                x, y = aptl[j + 1 + shift]
                p = gmodel.Point()
                p.x, p.y = convcoords(state, x, y)
                pgone.pl.append(p)
            shift += aPolyCounts[k]
            ppg.polys.append(pgone)
        ShapeSetFill(ppg, state)
        ShapeSetStroke(ppg, state, page.zoom)
        ppg.pagetrafo = page.trafo
        page.objs.append(ppg)
Exemple #5
0
def Polybezier(mf, num, page, state):
    x, y = mf.records[num].aptl[0]
    xr, yr = convcoords(state, x, y)
    if state.DCs[state.curdc].pathmode:
        path = page.objs[state.DCs[state.curdc].pathobj]
        pp = gmodel.PathPoint()
        pp.type = 1
        p = gmodel.Point()
        p.x, p.y = xr, yr
        pp.pts.append(p)
        path.pplist.append(pp)
        for j in range(len(mf.records[num].aptl) / 3):
            pp = gmodel.PathPoint()
            pp.type = 3
            p = gmodel.Point()
            x, y = mf.records[num].aptl[j * 3 + 1]
            xr, yr = convcoords(state, x, y)
            p.x, p.y = xr, yr
            pp.pts.append(p)
            p = gmodel.Point()
            x, y = mf.records[num].aptl[j * 3 + 2]
            xr, yr = convcoords(state, x, y)
            p.x, p.y = xr, yr
            pp.pts.append(p)
            p = gmodel.Point()
            x, y = mf.records[num].aptl[j * 3 + 3]
            xr, yr = convcoords(state, x, y)
            p.x, p.y = xr, yr
            pp.pts.append(p)
            path.pplist.append(pp)
    else:
        curve = gmodel.Polybezier()
        curve.p0.x, curve.p0.y = xr, yr
        for j in range(len(mf.records[num].aptl) / 3):
            trpl = gmodel.Triple()
            x1, y1 = mf.records[num].aptl[j * 3 + 1]
            trpl.x1, trpl.y1 = convcoords(state, x1, y1)
            x2, y2 = mf.records[num].aptl[j * 3 + 2]
            trpl.x2, trpl.y2 = convcoords(state, x2, y2)
            x3, y3 = mf.records[num].aptl[j * 3 + 3]
            trpl.x3, trpl.y3 = convcoords(state, x3, y3)
            curve.trpl.append(trpl)
        ShapeSetStroke(curve, state, page.zoom)
        curve.pagetrafo = page.trafo
        page.objs.append(curve)
Exemple #6
0
def Rectangle(mf, num, page, state):
    x1, y1, x2, y2 = mf.records[num].values
    xr1, yr1 = convcoords(state, x1, y1)
    xr2, yr2 = convcoords(state, x2, y2)
    if state.DCs[state.curdc].pathmode:
        path = page.obj(state.DCs[state.curdc].pathobj)
        pp = gmodel.PathPoint()
        pp.type = 1
        p = gmodel.Point()
        p.x, p.y = xr1, yr1
        pp.pts.append(p)
        path.pplist.append(pp)
        pp = gmodel.PathPoint()
        pp.type = 2
        p = gmodel.Point()
        p.x, p.y = xr1, yr2
        pp.pts.append(p)
        path.pplist.append(pp)
        pp = gmodel.PathPoint()
        pp.type = 2
        p = gmodel.Point()
        p.x, p.y = xr2, yr2
        pp.pts.append(p)
        path.pplist.append(pp)
        pp = gmodel.PathPoint()
        pp.type = 2
        p = gmodel.Point()
        p.x, p.y = xr2, yr1
        pp.pts.append(p)
        path.pplist.append(pp)
        pp = gmodel.PathPoint()
        pp.type = 4
        pp.pts.append(p)
        path.pplist.append(pp)
    else:
        rect = gmodel.Rect()
        rect.p0.x, rect.p0.y = xr1, yr1
        rect.pe.x, rect.pe.y = xr2, yr2
        ShapeSetFill(rect, state)
        ShapeSetStroke(rect, state, page.zoom)
        rect.pagetrafo = page.trafo
        page.objs.append(rect)
Exemple #7
0
def PathCopy(state, shape):
    for j in state.DCs[state.curdc].cliplist:
        p = gmodel.Path()
        for i in j.pplist:
            pp = gmodel.PathPoint()
            pp.type = i.type
            if i.type > 0 and i.type < 4:
                pts = gmodel.Point()
                pts.x = i.pts[0].x
                pts.y = i.pts[0].y
                pp.pts.append(pts)
            if i.type == 3:
                pts = gmodel.Point()
                pts.x = i.pts[1].x
                pts.x = i.pts[1].y
                pp.pts.append(pts)
                pts = gmodel.Point()
                pts.x = i.pts[2].x
                pts.x = i.pts[2].y
                pp.pts.append(pts)
            p.pplist.append(pp)
        shape.cliplist.append(p)
Exemple #8
0
def Polyline(mf, num, page, state):
    pline = gmodel.Polyline()
    x, y = mf.records[num].aptl[0]
    pline.pl0.x, pline.pl0.y = convcoords(state, x, y)
    for j in range(len(mf.records[num].aptl) - 1):
        x, y = mf.records[num].aptl[j + 1]
        p = gmodel.Point()
        p.x, p.y = convcoords(state, x, y)
        pline.pl.append(p)
    ShapeSetStroke(pline, state, page.zoom)
    if state.clipflag:
        PathCopy(state, pline)
        pline.clipflag = state.clipflag
    page.objs.append(pline)
Exemple #9
0
def MoveTo(mf, num, page, state):
    x, y = mf.records[num].values
    xr1, yr1 = convcoords(state, x, y)
    if state.DCs[state.curdc].pathmode:
        path = page.objs[state.DCs[state.curdc].pathobj]
        pp = gmodel.PathPoint()
        pp.type = 1
        p = gmodel.Point()
        p.x, p.y = xr1, yr1
        pp.pts.append(p)
        path.pplist.append(pp)
    else:
        state.DCs[state.curdc].p0x = xr1
        state.DCs[state.curdc].p0y = yr1
Exemple #10
0
def IntersectClipRect(mf, num, page, state):
    b, r, t, l = mf.records[num].values
    xr1, yr1 = convcoords(state, l, t)
    xr2, yr2 = convcoords(state, r, b)
    path = gmodel.Path()
    path.pagetrafo = page.trafo
    pp = gmodel.PathPoint()
    pp.type = 1
    p = gmodel.Point()
    p.x, p.y = xr1, yr1
    pp.pts.append(p)
    path.pplist.append(pp)
    pp = gmodel.PathPoint()
    pp.type = 2
    p = gmodel.Point()
    p.x, p.y = xr1, yr2
    pp.pts.append(p)
    path.pplist.append(pp)
    pp = gmodel.PathPoint()
    pp.type = 2
    p = gmodel.Point()
    p.x, p.y = xr2, yr2
    pp.pts.append(p)
    path.pplist.append(pp)
    pp = gmodel.PathPoint()
    pp.type = 2
    p = gmodel.Point()
    p.x, p.y = xr2, yr1
    pp.pts.append(p)
    path.pplist.append(pp)
    pp = gmodel.PathPoint()
    pp.type = 4
    pp.pts.append(p)
    path.pplist.append(pp)
    state.DCs[state.curdc].cliplist.append(path)
    state.clipflag = 1
    state.DCs[state.curdc].clipset = 1
Exemple #11
0
def LineTo(mf, num, page, state):
    x, y = mf.records[num].values
    xr1, yr1 = convcoords(state, x, y)
    if state.DCs[state.curdc].pathmode:
        path = page.objs[state.DCs[state.curdc].pathobj]
        pp = gmodel.PathPoint()
        pp.type = 2
        p = gmodel.Point()
        p.x, p.y = xr1, yr1
        pp.pts.append(p)
        path.pplist.append(pp)
    else:
        line = gmodel.LineTo()
        line.p0.x = state.DCs[state.curdc].p0x
        line.p0.y = state.DCs[state.curdc].p0y
        line.pe.x = xr1
        line.pe.y = yr1
        state.DCs[state.curdc].p0x = xr1
        state.DCs[state.curdc].p0y = yr1
        ShapeSetStroke(line, state, page.zoom)
        line.pagetrafo = page.trafo
        page.objs.append(line)