Example #1
0
func (a Arch) drawLocalChannel(ctxt interface{}, ch pf.ChannelIf) {
	switch ctxt.(type) {
	case *cairo.Context:
		context := ctxt.(*cairo.Context)
		link := ch.Link()
		if ch.Process().Arch().Name() != a.Name() {
			log.Fatal("Arch.drawLocalChannel: channel not in arch %s\n", a.Name())
		}
		if link.Process().Arch().Name() == a.Name() {
			var r, g, b float64
			p1 := a.channelMap[ch]
			p2 := a.channelMap[link]
			if p1.IsSelected() || p2.IsSelected() {
				r, g, b, _ = ColorOption(SelectChannelLine)
			} else if p1.IsHighlighted() || p2.IsHighlighted() {
				r, g, b, _ = ColorOption(HighlightChannelLine)
			} else {
				r, g, b, _ = ColorOption(NormalChannelLine)
			}
			context.SetLineWidth(2)
			context.SetSourceRGB(r, g, b)
			var pos1, pos2 image.Point
			if ch.Direction() == gr.InPort {
				pos1 = link.ModePosition(a.mode).Add(image.Point{procPortWidth, procPortHeight}.Div(2))
				pos2 = ch.ModePosition(a.mode).Add(image.Point{procPortWidth, procPortHeight}.Div(2))
			} else {
				pos1 = ch.ModePosition(a.mode).Add(image.Point{procPortWidth, procPortHeight}.Div(2))
				pos2 = link.ModePosition(a.mode).Add(image.Point{procPortWidth, procPortHeight}.Div(2))
			}
			DrawArrow(context, pos1, pos2)
		}
	}
}
Example #2
0
func (a Arch) channelIsExtern(c pf.ChannelIf) bool {
	link := c.Link()
	cp := link.Process()
	ca := cp.Arch()
	return ca != a.userObj
}