Beispiel #1
0
func (v *mappingView) nodeDrawBox(n graph.NodeIf) image.Rectangle {
	ret := n.BBox()
	for _, c := range v.connections {
		if c.IsLinked(n.Name()) {
			ret = ret.Union(c.BBox())
		}
	}
	return ret
}
Beispiel #2
0
func (v *signalGraphView) selectNode(id bh.NodeIdIf) (node graph.NodeIf) {
	var n graph.NodeIf
	for _, n = range v.nodes {
		ok, nd := n.SelectNode(freesp.NodeIdFromString(n.Name(), v.graphId), id)
		if ok {
			v.repaintNode(n)
		}
		if nd != nil {
			node = nd
		}
	}
	return
}
Beispiel #3
0
func (v *mappingView) handleArchSelect(pos image.Point) {
	for _, a := range v.arch {
		hit, _ := a.CheckHit(pos)
		if !hit {
			if a.Deselect() {
				v.repaintArch(a)
			}
			continue
		}
		if a.Select() {
			v.repaintArch(a)
		}
		v.context.SelectArch(a.UserObj())
		var ok bool
		var pr pf.ProcessIf
		var ch pf.ChannelIf
		var n graph.NodeIf
		var p graph.ProcessIf
		ok, pr, p = a.GetSelectedProcess()
		if !ok {
			continue
		}
		//log.Printf("mappingView.handleArchSelect: select process %v\n", pr)
		v.context.SelectProcess(pr)
		ok, ch = a.GetSelectedChannel()
		if ok {
			//log.Printf("mappingView.handleArchSelect: select channel %v\n", ch)
			v.context.SelectChannel(ch)
			continue
		}
		ok, n = p.(*graph.ProcessMapping).GetSelectedNode()
		if !ok {
			continue
		}
		var melem mp.MappedElementIf
		nId := freesp.NodeIdFromString(n.Name(), v.mapping.Graph().Filename())
		melem, ok = v.mapping.MappedElement(nId)
		if !ok {
			// todo: unmapped node
		} else {
			v.context.SelectMapElement(melem)
		}
	}
	hit, _ := v.unmapped.CheckHit(pos)
	if !hit {
		if v.unmapped.Deselect() {
			v.repaintUnmapped(v.unmapped)
		}
		return
	}
	if v.unmapped.Select() {
		v.repaintUnmapped(v.unmapped)
	}
	var ok bool
	var n graph.NodeIf
	//log.Printf("mappingView.handleArchSelect: select process %v\n", pr)
	ok, n = v.unmapped.(*graph.ProcessMapping).GetSelectedNode()
	if !ok {
		return
	}
	var melem mp.MappedElementIf
	nId := freesp.NodeIdFromString(n.Name(), v.mapping.Graph().Filename())
	melem, ok = v.mapping.MappedElement(nId)
	if !ok {
		// todo: unmapped node
	} else {
		v.context.SelectMapElement(melem)
	}
}