コード例 #1
0
ファイル: SvgTestPDF.py プロジェクト: sernst/Cadence
siteMap = session.query(model).filter(model.index == 13).first()
fileName = 'test_new.svg'
drawing = CadenceDrawing(fileName, siteMap)

xFed   = siteMap.xFederal
yFed   = siteMap.yFederal
fMap   = (xFed, yFed)
fScene = drawing.projectToScene((xFed, yFed))
xScene = fScene[0]
yScene = fScene[1]

print "siteMap.index = %s and siteMap.name = %s" % (siteMap.index, siteMap.filename)
print 'in siteMap, xFederal = %s and yFederal = %s' % fMap
print 'in scene, xFederal = %s and yFederal = %s' % (xScene, yScene)

pScene = drawing.projectToMap((xScene, yScene))

print 'and back again, to siteMap, p = (%s, %s)' % pScene
print 'scaling to scene, siteMap.xFederal maps to %s' % drawing.scaleToScene(xFed)
print 'and this maps back to %s' % drawing.scaleToMap(drawing.scaleToScene(xFed))

#===============================================================================

# place a circle of radius 5 at (100.0, 100.0) in scene coordinates
# drawing.circle((100, 100), 5, scene=True, stroke='red', fill='green')

# label it with text at (100, 10)
drawing.text("circle of radius 5 at (200, 10)", (100, 10), scene=True, stroke='blue')

# now place another circle and rect in map (not scene) coordinates below the federal marker
drawing.rect((xScene, yScene - 100), 4, 10, scene=False, fill='red')
コード例 #2
0
ファイル: SvgTest2.py プロジェクト: sernst/Cadence
session = model.createSession()
siteMap = session.query(model).filter(model.index == 13).first()
drawing = CadenceDrawing('test_2.svg', siteMap)

# --------------------------------------------------------------------------------------------------
# THIS DEMONSTRATES MAPPING BETWEEN A SITE MAP AND THE SCENE, PLUS SIMPLE SHAPES

xFed   = siteMap.xFederal
yFed   = siteMap.yFederal
fMap   = (xFed, yFed)
fScene = drawing.projectToScene((xFed, yFed))

print "siteMap.index = %s and siteMap.name = %s" % (siteMap.index, siteMap.filename)
print 'in siteMap, the federal marker is (%s, %s)' % fMap
print 'which projects into the scene as (%s, %s)' % (fScene[0], fScene[1])
print 'and projecting back to the map gives (%s, %s)' % drawing.projectToMap((fScene[0], fScene[1]))

# place a circle of radius 5 at (10.0, 10.0) in scene coordinates
drawing.circle((10, 10), 5)

# label it with text at (20, 10)
drawing.text("circle of radius 5", (20, 10), scene=True)

# now place a 20x40 rect in map coordinates (not scene coordinates) at the federal marker
drawing.rect((xFed + 40, yFed), 20, 40, scene=False)

# and another smaller one at (10, 20) in map coordinates
drawing.rect((10, 20), 4, 8, scene=False)

# place the federal coordinates as a text string 20 cm above the marker
text = "(%s, %s)" % (drawing.siteMap.federalEast, drawing.siteMap.federalNorth)