Ejemplo n.º 1
0
func (v *mappingView) Select2(obj interface{}, id string) {
	switch obj.(type) {
	case bh.NodeIf:
		p, ok := v.mapping.Mapped(id)
		if !ok {
			// todo: unmapped nodes
			return
		}
		var a graph.ArchIf
		a, ok = v.focusArchFromUserObject(p.Arch())
		if !ok {
			log.Printf("mappingView.Select error: arch %s not found\n", a.Name())
			return
		}
		/*
			pr := a.SelectProcess(p)
			if pr == nil {
				log.Printf("mappingView.Select error: process %v not found\n", p)
				return
			}
			* */
		for _, n := range v.nodes {
			// TODO: filenames...
			modified, _ := n.SelectNode(freesp.NodeIdFromString(n.Name(), ""),
				freesp.NodeIdFromString(id, ""))
			if modified {
				v.repaintArch(a)
			}
		}
	}
}
Ejemplo n.º 2
0
func (v *mappingView) archDrawBox(a graph.ArchIf) image.Rectangle {
	ret := a.BBox()
	for _, aa := range v.arch {
		if aa.IsLinked(a.Name()) {
			ret = ret.Union(aa.BBox())
		}
	}
	return ret
}
Ejemplo n.º 3
0
func (v *platformView) selectArch(toSelect graph.ArchIf) {
	var a graph.ArchIf
	for _, a = range v.arch {
		if a.Name() == toSelect.Name() {
			if !a.Select() {
				v.repaintArch(a)
			}
		}
	}
}
Ejemplo n.º 4
0
func (v *mappingView) selectArch(toSelect graph.ArchIf) {
	var a graph.ArchIf
	for _, a = range v.arch {
		if a.Name() == toSelect.Name() {
			if a.Select() {
				v.repaintArch(a)
			}
			return
		}
	}
}
Ejemplo n.º 5
0
func (v *mappingView) Select(obj interface{}) {
	switch obj.(type) {
	case pf.ArchIf:
		arch := obj.(pf.ArchIf)
		a, ok := v.focusArchFromUserObject(arch)
		if ok {
			v.selectArch(a)
		}
	case pf.ProcessIf:
		pr := obj.(pf.ProcessIf)
		a, ok := v.focusArchFromUserObject(pr.Arch())
		if ok {
			a.SelectProcess(pr)
			v.repaintArch(a)
		}
	case pf.ChannelIf:
		ch := obj.(pf.ChannelIf)
		a, ok := v.focusArchFromUserObject(ch.Process().Arch())
		if ok {
			a.SelectChannel(ch)
			v.repaintArch(a)
		}
	case mp.MappedElementIf:
		melem := obj.(mp.MappedElementIf)
		p, isMapped := melem.Process()
		var pr graph.ProcessIf
		var a graph.ArchIf
		if !isMapped {
			pr = v.unmapped
		} else {
			var ok bool
			a, ok = v.focusArchFromUserObject(p.Arch())
			if !ok {
				log.Printf("mappingView.Select error: arch %s not found\n", a.Name())
				return
			}
			pr = a.SelectProcess(p)
			if pr == nil {
				log.Printf("mappingView.Select error: process %v not found\n", p)
				return
			}
		}
		pr.(*graph.ProcessMapping).SelectNode(melem.NodeId(), melem.NodeId())
		if isMapped {
			v.repaintArch(a)
		} else {
			v.repaintUnmapped(v.unmapped)
		}
	default:
	}
}