Esempio n. 1
0
func (tg *teg) Model(copy bool) *Teg {
	model := &Teg{
		Id: tg.id,

		Places:      make([]*Place, 0, len(tg.places)),
		Transitions: make([]*Transition, len(tg.transitions)),
		Groups:      make([]*Group, len(tg.groups)),
	}
	if copy {
		model.Id = util.GenUUID()
	}
	ignore := make(map[*place]bool, len(tg.places))
	for i, t := range tg.transitions {
		model.Transitions[i] = t.Model()
		for _, p := range t.in {
			ignore[p] = true
		}
		for _, p := range t.out {
			ignore[p] = true
		}
	}
	for _, p := range tg.places {
		if !ignore[p] {
			model.Places = append(model.Places, p.Model())
		}
	}
	for i, g := range tg.groups {
		model.Groups[i] = g.Model(copy)
	}
	return model
}
Esempio n. 2
0
func (g *group) Model(copy bool) *Group {
	model := &Group{
		Id: g.id,
		X:  g.X(), Y: g.Y(),

		Label:  g.label,
		Folded: g.folded,
		Model:  g.model.Model(copy),

		Inputs:  make([]*Transition, len(g.inputs)),
		Outputs: make([]*Transition, len(g.outputs)),
		Iostate: make(map[string]string, len(g.inputs)+len(g.outputs)),
	}
	if copy {
		model.Id = util.GenUUID()
	}
	for i, t := range g.inputs {
		model.Inputs[i] = t.Model()
	}
	for i, t := range g.outputs {
		model.Outputs[i] = t.Model()
	}
	for proxy, io := range g.iostate {
		model.Iostate[io.id] = proxy.id
	}
	return model
}
Esempio n. 3
0
func newTransition(x, y float64) *transition {
	return &transition{
		Rect: geometry.NewRect(x-TransitionWidth/2, y-TransitionHeight/2,
			TransitionWidth, TransitionHeight),
		id: util.GenUUID(),
	}
}
Esempio n. 4
0
func newGroup() *group {
	return &group{
		model:   newTeg(),
		inputs:  make([]*transition, 0, 8),
		outputs: make([]*transition, 0, 8),
		id:      util.GenUUID(),
	}
}
Esempio n. 5
0
func newTeg() *teg {
	return &teg{
		util:        &utility{},
		infos:       make(map[string]*planeview.Plane, 20),
		places:      make([]*place, 0, 256),
		transitions: make([]*transition, 0, 256),
		groups:      make([]*group, 0, 32),
		selected:    make(map[item]bool, 256),
		updated:     make(chan interface{}, 100),
		updatedInfo: make(chan interface{}, 100),
		id:          util.GenUUID(),
	}
}
Esempio n. 6
0
func newPlace(x, y float64) *place {
	return &place{
		Circle: geometry.NewCircle(x, y, PlaceRadius),
		id:     util.GenUUID(),
	}
}