示例#1
0
func (ds *DrawState) Add(o object.Object) error {

	// Must have an Id to add an object
	if len(o.Id()) == 0 {
		return fmt.Errorf("Cannot add object: ID not set")
	}

	if p, ok := o.(*object.Panel); ok {
		var err error
		for panelObject := range p.Contains {
			err = ds.Add(p.Contains[panelObject])
			if err != nil {
				return err
			}
		}

		return err

	}

	// Add to users map store
	ds.Objects[o.Id()] = o

	// Add to users array object store
	ds.objectArr = append(ds.objectArr, o)

	// Add to objects Dirty array
	return ds.Dirty.Add(o.Size(), o.Coord(), o)
}
示例#2
0
func TranslateCoords(o object.Object) (*geom.Coord, error) {
	pan := o.Panel()
	coord := *o.Coord()

	var err error
	fmt.Printf("%+v \n", pan)
	tries := 0
	for pan != nil {
		fmt.Printf("%+v\n", pan)
		coord = pan.Coord().Plus(coord)
		pan = pan.Panel()
		tries++
		if tries >= object.MaxPanelDepth {
			err = fmt.Errorf("Exceeded Max Panel Depth (possible circular panel path)")
			break
		}
	}
	return &coord, err
}