Example #1
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'
Example #2
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'
Example #3
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)
Example #4
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)
Example #5
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)
Example #6
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
Example #7
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
Example #8
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)
Example #9
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)
Example #10
0
def CloseFigure(mf, num, page, state):
    pp = gmodel.PathPoint()
    pp.type = 4
    page.objs[state.DCs[state.curdc].pathobj].pplist.append(pp)