drawing

package
v0.0.0-...-588c02a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package drawing defines Drawing struct for DXF.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SectionTypeString

func SectionTypeString(s SectionType) string

SectionTypeString converts SectionType to string. If SectionType is out of range, it returns empty string.

Types

type Drawing

type Drawing struct {
	FileName     string
	Layers       map[string]*table.Layer
	Groups       map[string]*object.Group
	Styles       map[string]*table.Style
	CurrentLayer *table.Layer
	CurrentStyle *table.Style

	Sections []Section

	PlotStyle handle.Handler
	// contains filtered or unexported fields
}

Drawing contains DXF drawing data.

func New

func New() *Drawing

New creates a new Drawing.

func (*Drawing) AddEntity

func (d *Drawing) AddEntity(e entity.Entity)

AddEntity adds a new entity.

func (*Drawing) AddLayer

func (d *Drawing) AddLayer(name string, cl color.ColorNumber, lt *table.LineType, setcurrent bool) (*table.Layer, error)

AddLayer adds a new layer with given name, color and line type. If setcurrent is true, set current layer to it.

func (*Drawing) AddLineType

func (d *Drawing) AddLineType(name string, desc string, ls ...float64) (*table.LineType, error)

AddLineType adds a new linetype.

func (*Drawing) AddStyle

func (d *Drawing) AddStyle(name string, fontname, bigfontname string, setcurrent bool) (*table.Style, error)

AddStyle adds a new text style. If setcurrent is true, set current style to it.

func (*Drawing) AddToGroup

func (d *Drawing) AddToGroup(name string, es ...entity.Entity) error

AddToGroup adds given entities to the named group. If the named group doesn't exist, returns error.

func (*Drawing) Arc

func (d *Drawing) Arc(x, y, z, r, start, end float64) (*entity.Arc, error)

Arc creates a new ARC at (x, y, z) with radius r from start to end.

func (*Drawing) ChangeLayer

func (d *Drawing) ChangeLayer(name string) error

ChangeLayer changes current layer to the named layer.

func (*Drawing) Circle

func (d *Drawing) Circle(x, y, z, r float64) (*entity.Circle, error)

Circle creates a new CIRCLE at (x, y, z) with radius r.

func (*Drawing) Close

func (d *Drawing) Close() error

Close implements the standard Close interface: it close the buffer used by the read command if one was initilized, and frees the memory held by it. Close will always return nil for the error.

func (*Drawing) Entities

func (d *Drawing) Entities() entity.Entities

Entities returns slice of all entities contained in Drawing.

func (*Drawing) Group

func (d *Drawing) Group(name, desc string, es ...entity.Entity) (*object.Group, error)

Group adds given entities to the named group. If the named group doesn't exist, create it.

func (*Drawing) Header

func (d *Drawing) Header() *header.Header

func (*Drawing) Layer

func (d *Drawing) Layer(name string, setcurrent bool) (*table.Layer, error)

Layer returns the named layer if exists. If setcurrent is true, set current layer to it.

func (*Drawing) Line

func (d *Drawing) Line(x1, y1, z1, x2, y2, z2 float64) (*entity.Line, error)

Line creates a new LINE from (x1, y1, z1) to (x2, y2, z2).

func (*Drawing) LineType

func (d *Drawing) LineType(name string) (*table.LineType, error)

LineType returns the named line type if exists.

func (*Drawing) LwPolyline

func (d *Drawing) LwPolyline(closed bool, vertices ...[]float64) (*entity.LwPolyline, error)

LwPolyline creates a new LWPOLYLINE with given vertices.

func (*Drawing) Point

func (d *Drawing) Point(x, y, z float64) (*entity.Point, error)

Point creates a new POINT at (x, y, z).

func (*Drawing) Polyline

func (d *Drawing) Polyline(closed bool, vertices ...[]float64) (*entity.Polyline, error)

Polyline creates a new POLYLINE with given vertices.

func (*Drawing) Read

func (d *Drawing) Read(p []byte) (n int, err error)

Read implements the standard Read interface: it reads data from a buffer containing the drawing, the buffer in initialized on the first read or a read call after a close. If the drawing is nil, read returns 0 for n, nil for the error.

func (*Drawing) Save

func (d *Drawing) Save() error

Save saves the drawing file. If it is the first time, use SaveAs(filename).

func (*Drawing) SaveAs

func (d *Drawing) SaveAs(filename string) error

SaveAs saves the drawing file as given filename.

func (*Drawing) SetExt

func (d *Drawing) SetExt()

SetExt sets the extents of the drawing based on the entities in the drawing. If the drawing is nil, this function will panic.

func (*Drawing) Style

func (d *Drawing) Style(name string, setcurrent bool) (*table.Style, error)

Style returns the named text style if exists. If setcurrent is true, set current style to it.

func (*Drawing) Text

func (d *Drawing) Text(str string, x, y, z, height, rotation float64) (*entity.Text, error)

Text creates a new TEXT str at (x, y, z) with given height.

func (*Drawing) ThreeDFace

func (d *Drawing) ThreeDFace(points [][]float64) (*entity.ThreeDFace, error)

ThreeDFace creates a new 3DFACE with given points.

func (*Drawing) WriteTo

func (d *Drawing) WriteTo(w io.Writer) (n int64, err error)

WriteTo write the dxf file data to the given writer until there is no more data to write or if an error occurs. The return value n is the number of bytes writer. This method full fills the io.WriterTo interface.

type Section

type Section interface {
	Format(format.Formatter)
	SetHandle(*int)
}

Section is interface for DXF sections.

type SectionType

type SectionType int

SectionType represents Section names (code 2)

const (
	HEADER SectionType = iota
	CLASSES
	TABLES
	BLOCKS
	ENTITIES
	OBJECTS
)

Section name: code 2

func SectionTypeValue

func SectionTypeValue(s string) SectionType

SectionTypeValue converts string to SectionType. If string is unknown SectionType, it returns -1.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL