draw Package

draw Package

draw Module

Drawing classes for gtrace

class gtrace.draw.draw.Arc(center, radius, startangle, stopangle, thickness=0, angle_in_rad=True)[source]

Bases: gtrace.draw.draw.Shape

An arc

Note that angles are stored in rad.

class gtrace.draw.draw.Canvas(unit='m')[source]

Bases: object

Canvas class

add_layer(name, color=(0, 0, 0))[source]
add_shape(shape, layername)[source]
class gtrace.draw.draw.Circle(center, radius, thickness=0)[source]

Bases: gtrace.draw.draw.Shape

A circle

class gtrace.draw.draw.Layer(name, color=(0, 0, 0))[source]

Bases: object

Layer class

add_shape(shape)[source]
class gtrace.draw.draw.Line(start, stop, thickness=0)[source]

Bases: gtrace.draw.draw.Shape

Line class

exception gtrace.draw.draw.NumberOfElementError[source]

Bases: exceptions.BaseException

class gtrace.draw.draw.PolyLine(x, y, thickness=0)[source]

Bases: gtrace.draw.draw.Shape

A light weight poly-line

class gtrace.draw.draw.Rectangle(point, width, height, thickness=0)[source]

Bases: gtrace.draw.draw.Shape

A rectangle

class gtrace.draw.draw.Shape[source]

Bases: object

Shape class

class gtrace.draw.draw.Text(text, point, height=1.0, rotation=0.0, angle_in_rad=True)[source]

Bases: gtrace.draw.draw.Shape

Text

Note that angles are stored in rad.

dxf Module

dxf.py - a DXF export library for python

Sample code:

import dxf d = dxf.DXF(‘test.dxf’) d.add_layer(‘ABC’, color=5) d.add_entity(dxf.Line((1.5,5), (56,-89)), ‘ABC’) d.save_to_file()

class gtrace.draw.dxf.Arc(center, radius, startangle, stopangle, thickness=0)[source]

Bases: gtrace.draw.dxf.Entity

An arc entity

draw(layername)[source]
report_min_max()[source]

Return the coordinates of the lower left and the upper right corners of the drawing. Return value: ((xmin, ymin), (xmax, ymax))

class gtrace.draw.dxf.Circle(center, radius, thickness=0)[source]

Bases: gtrace.draw.dxf.Entity

A circle entity

draw(layername)[source]
report_min_max()[source]

Return the coordinates of the lower left and the upper right corners of the drawing. Return value: ((xmin, ymin), (xmax, ymax))

class gtrace.draw.dxf.DXF(filename='drawing.dxf')[source]

Bases: object

A DXF file class.

add_entity(entity, layername)[source]
add_layer(name, color=1, ltype='Continuous')[source]
save_to_file()[source]

Save the DXF file

class gtrace.draw.dxf.Entity[source]

Bases: object

A graphic entity

draw()[source]
report_min_max()[source]

Return the coordinates of the lower left and the upper right corners of the drawing. Return value: ((xmin, ymin), (xmax, ymax))

set_handle(handle)[source]
class gtrace.draw.dxf.Layer(name, handle, color=1, ltype='Continuous')[source]

Bases: object

Layer class

add_entity(entity)[source]
class gtrace.draw.dxf.Line(start, stop, thickness=0)[source]

Bases: gtrace.draw.dxf.Entity

A line entity

draw(layername)[source]
report_min_max()[source]

Return the coordinates of the lower left and the upper right corners of the drawing. Return value: ((xmin, ymin), (xmax, ymax))

class gtrace.draw.dxf.LwPolyLine(x, y, thickness=0)[source]

Bases: gtrace.draw.dxf.Entity

A light weight poly-line

draw(layername)[source]
report_min_max()[source]

Return the coordinates of the lower left and the upper right corners of the drawing. Return value: ((xmin, ymin), (xmax, ymax))

exception gtrace.draw.dxf.NumberOfElementError[source]

Bases: exceptions.BaseException

class gtrace.draw.dxf.Rectangle(point, width, height, thickness=0)[source]

Bases: gtrace.draw.dxf.Entity

A rectangle

draw(layername)[source]
report_min_max()[source]

Return the coordinates of the lower left and the upper right corners of the drawing. Return value: ((xmin, ymin), (xmax, ymax))

class gtrace.draw.dxf.Text(text, point, height=1.0, rotation=0.0)[source]

Bases: gtrace.draw.dxf.Entity

Text

draw(layername)[source]
report_min_max()[source]

Return the coordinates of the lower left and the upper right corners of the drawing. Return value: ((xmin, ymin), (xmax, ymax))

gtrace.draw.dxf.color_encode(color)[source]

Given a set of RGB values for a color, find the closest matching one from the pre-defined colors in the DXF specification. Then return its color code (an integer in 1 to 255).

= Input = color: A tuple of three numbers in the range of 0-255, i.e. (R,G,B)

= Return = best_color_num: integer

gtrace.draw.dxf.test_func()[source]

renderer Module

Renderer module for gtrace.draw

exception gtrace.draw.renderer.UnknownShapeError[source]

Bases: exceptions.BaseException

gtrace.draw.renderer.renderDXF(canvas, filename)[source]

Render a canvas into a DXF file

tools Module

gtrace.draw.tools.drawAllBeams(d, beamList, sigma=3.0, drawWidth=True, drawPower=False, drawROC=False, drawGouy=False, drawOptDist=False, layer=None, mode='x', fontSize=0.01)[source]
gtrace.draw.tools.drawAllOptics(d, opticsList, drawName=True, layer=None)[source]
gtrace.draw.tools.drawOptSys(optList, beamList, filename, fontSize=False)[source]
gtrace.draw.tools.rotateAll(objList, angle, center)[source]
gtrace.draw.tools.transAll(objList, transVect)[source]

Table Of Contents

Previous topic

gtrace Package

Next topic

optics Package

This Page