func mapelemNew(n bh.NodeIf, nId bh.NodeIdIf, p pf.ProcessIf, mapping mp.MappingIf) (m *mapelem) { m = &mapelem{*gr.ModePositionerObjectNew(), n, nId, p, mapping, false, make([]gr.ModePositionerObject, len(n.InPorts())), make([]gr.ModePositionerObject, len(n.OutPorts()))} for i := 0; i < len(m.inports); i++ { m.inports[i] = *gr.ModePositionerObjectNew() } for i := 0; i < len(m.outports); i++ { m.outports[i] = *gr.ModePositionerObjectNew() } return }
func unmappedProcessNew() *unmappedProcess { return &unmappedProcess{*gr.ModePositionerObjectNew()} }
func (v *mappingView) Sync() { g := v.mapping.Graph() //gFilename := g.Filename() v.nodes = make([]graph.NodeIf, len(g.Nodes())) var numberOfConnections = 0 for _, n := range g.Nodes() { for _, p := range n.OutPorts() { numberOfConnections += len(p.Connections()) } } v.connections = make([]graph.ConnectIf, numberOfConnections) // Construct node tree mapping := v.mapping getPositioner := func(nId bh.NodeIdIf) gr.ModePositioner { melem, ok := mapping.MappedElement(nId) if !ok { log.Printf("mappingView.Sync warning: no mapped element for node %s\n", nId) return gr.ModePositionerObjectNew() } return melem } for i, n := range g.Nodes() { nId := freesp.NodeIdFromString(n.Name(), g.Filename()) melem, ok := v.mapping.MappedElement(nId) if !ok { log.Printf("mappingView.Sync error: node %s is expanded\n", n.Name()) continue } if melem.Expanded() { n.SetExpanded(true) v.nodes[i] = graph.ExpandedNodeNew(getPositioner, n, nId) } else { melem.SetActiveMode(gr.PositionModeNormal) v.nodes[i] = graph.NodeNew(getPositioner, n, nId) } } // Construct edges var index = 0 for _, n := range g.Nodes() { from, ok := v.findNode(n.Name()) if !ok { log.Printf("mappingView.Sync error: from node %s not in nodelist\n", n.Name()) continue } for _, p := range n.OutPorts() { fromId := from.OutPortIndex(p.Name()) for _, c := range p.Connections() { to, ok := v.findNode(c.Node().Name()) if !ok { log.Printf("mappingView.Sync error: to node %s not in nodelist\n", c.Node().Name()) continue } toId := to.InPortIndex(c.Name()) v.connections[index] = graph.ConnectionNew(from, to, fromId, toId) index++ } } } // Construct node leaves mapping p := v.mapping.Platform() v.arch = make([]graph.ArchIf, len(p.Arch())) for i, a := range p.Arch() { v.arch[i] = graph.ArchMappingNew(a, v.nodes, v.mapping) } // Handle unmapped nodes var unmappedNodes []graph.NodeIf var unmappedIds []bh.NodeIdIf /* for _, n := range v.nodes { nId := freesp.NodeIdFromString(n.Name(), g.Filename()) _, ok := v.mapping.Mapped(n.Name()) if !ok { unmappedNodes = append(unmappedNodes, n) unmappedIds = append(unmappedIds, nId) } } */ for _, id := range v.mapping.MappedIds() { melem, ok := v.mapping.MappedElement(id) if !ok { log.Fatalf("mappingView.Sync FIXME: internal error inconsistent maplist\n") } if !melem.Expanded() { _, ok = melem.Process() if !ok { // we want unmapped nodes n, ok := findNodeByPath(v.nodes, melem.NodeId().String()) if !ok { log.Printf("mappingView.Sync: unmapped node %s not found\n", melem.NodeId().String()) continue } unmappedNodes = append(unmappedNodes, n) unmappedIds = append(unmappedIds, id) } } } for _, n := range v.nodes { if n.UserObj().Expanded() { n.Layout() } } v.unmapped = graph.ProcessMappingNew(unmappedNodes, unmappedIds, v.unmappedObj) v.area.SetSizeRequest(v.calcSceneWidth(), v.calcSceneHeight()) v.drawAll() }
func ChannelNew(dir gr.PortDirection, iotype pf.IOTypeIf, process pf.ProcessIf, linkText string) *channel { return &channel{*gr.ModePositionerObjectNew(), dir, iotype, nil, process, linkText, nil} }
func archPortNew(ch pf.ChannelIf) *archPort { return &archPort{*gr.ModePositionerObjectNew(), ch} }
func ArchNew(name string, platform pf.PlatformIf) *arch { return &arch{*gr.ModePositionerObjectNew(), name, ioTypeListInit(), processListInit(), platform, nil} }
func ProcessNew(name string, arch pf.ArchIf) *process { return &process{*gr.ModePositionerObjectNew(), name, channelListInit(), channelListInit(), arch} }