本文整理汇总了Golang中github.com/axel-freesp/sge/interface/behaviour.NodeIf类的典型用法代码示例。如果您正苦于以下问题:Golang NodeIf类的具体用法?Golang NodeIf怎么用?Golang NodeIf使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeIf类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: MenuViewCurrent
func MenuViewCurrent(menu *GoAppMenu, g *Global) {
fts := g.FTS().(tr.TreeIf)
cursor := fts.Current()
menu.viewExpand.SetSensitive(false)
menu.viewCollapse.SetSensitive(false)
if len(cursor.Path) == 0 {
return
}
obj := fts.Object(cursor)
var n bh.NodeIf
switch obj.(type) {
case bh.NodeIf:
n = obj.(bh.NodeIf)
//case mp.MappedElementIf:
// n = obj.(mp.MappedElementIf).Node()
default:
return
}
impl := n.ItsType().Implementation()
for _, i := range impl {
if i.ImplementationType() == bh.NodeTypeGraph {
menu.viewExpand.SetSensitive(true)
menu.viewCollapse.SetSensitive(true)
break
}
}
}
开发者ID:axel-freesp,项目名称:sge,代码行数:27,代码来源:menuview.go
示例2: IsProcessingNode
func IsProcessingNode(n bh.NodeIf) bool {
if len(n.InPorts()) == 0 {
return false
}
if len(n.OutPorts()) == 0 {
return false
}
return true
}
开发者ID:axel-freesp,项目名称:sge,代码行数:9,代码来源:node.go
示例3: AddNewObject
func (t *signalGraphType) AddNewObject(tree tr.TreeIf, cursor tr.Cursor, obj tr.TreeElementIf) (newCursor tr.Cursor, err error) {
switch obj.(type) {
case bh.NodeIf:
// TODO: Check if IO node and exists: copy position only and return
n := obj.(bh.NodeIf)
err = t.AddNode(n)
if err != nil {
err = fmt.Errorf("signalGraphType.AddNewObject error: %s", err)
nt := n.ItsType().(*nodeType)
if nt != nil {
ok, _ := nt.instances.Find(n)
if ok {
nt.instances.Remove(n)
}
}
return
}
newCursor = t.treeAddNewObject(tree, cursor, n)
parent := tree.Object(cursor)
switch parent.(type) {
case bh.SignalGraphIf:
case bh.ImplementationIf:
// propagate new node to all instances of embracing type
pCursor := tree.Parent(cursor)
nt := tree.Object(pCursor)
for _, nn := range nt.(bh.NodeTypeIf).Instances() {
nCursor := tree.Cursor(nn)
tCursor := tree.CursorAt(nCursor, parent)
tCursor.Position = cursor.Position
t.treeAddNewObject(tree, tCursor, n)
}
default:
log.Fatalf("signalGraphType.AddNewObject error: wrong parent type %T: %v\n", parent, parent)
}
case bh.ConnectionIf:
conn := obj.(bh.ConnectionIf)
var n bh.NodeIf
var p bh.PortIf
for _, n = range t.Nodes() {
if n.Name() == conn.From().Node().Name() {
nCursor := tree.CursorAt(cursor, n)
for _, p = range n.OutPorts() {
if conn.From().Name() == p.Name() {
pCursor := tree.CursorAt(nCursor, p)
return p.AddNewObject(tree, pCursor, obj)
}
}
}
}
default:
log.Fatalf("signalGraphType.AddNewObject error: wrong type %t: %v\n", obj, obj)
}
return
}
开发者ID:axel-freesp,项目名称:sge,代码行数:57,代码来源:signalgraphtype.go
示例4: mapelemNew
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
}
开发者ID:axel-freesp,项目名称:sge,代码行数:12,代码来源:mapelem.go
示例5: RemoveNode
func (t *signalGraphType) RemoveNode(n bh.NodeIf) {
for _, p := range n.(*node).inPort.Ports() {
for _, c := range p.Connections() {
c.RemoveConnection(p)
}
}
t.nodes.Remove(n)
RemNode(&t.inputNodes, n.(*node))
RemNode(&t.outputNodes, n.(*node))
RemNode(&t.processingNodes, n.(*node))
n.ItsType().(*nodeType).removeInstance(n.(*node))
}
开发者ID:axel-freesp,项目名称:sge,代码行数:12,代码来源:signalgraphtype.go
示例6: AddNode
func (t *signalGraphType) AddNode(n bh.NodeIf) error {
nType := n.ItsType()
if !isAutoType(nType) {
libname := nType.DefinedAt()
if len(libname) == 0 {
return fmt.Errorf("signalGraphType.AddNode error: node type %s has no DefinedAt...", nType.TypeName())
}
if !t.containsLibRef(libname) {
lib, ok := freesp.GetLibraryByName(libname)
if !ok {
return fmt.Errorf("signalGraphType.AddNode error: library %s not registered", libname)
}
t.libraries = append(t.libraries, lib)
}
}
return t.addNode(n)
}
开发者ID:axel-freesp,项目名称:sge,代码行数:17,代码来源:signalgraphtype.go
示例7: CreateXmlProcessingNode
func CreateXmlProcessingNode(n bh.NodeIf) *backend.XmlProcessingNode {
ret := backend.XmlProcessingNodeNew(n.Name(), n.ItsType().TypeName())
for _, p := range n.InPorts() {
ret.InPort = append(ret.InPort, *CreateXmlInPort(p))
}
for _, p := range n.OutPorts() {
ret.OutPort = append(ret.OutPort, *CreateXmlOutPort(p))
}
return ret
}
开发者ID:axel-freesp,项目名称:sge,代码行数:10,代码来源:backendconversions.go
示例8: treeNewObject
func (t *nodeType) treeNewObject(tree tr.TreeIf, cursor tr.Cursor, obj tr.TreeElementIf) (newCursor tr.Cursor) {
switch obj.(type) {
case bh.ImplementationIf:
cursor.Position = len(t.Implementation()) - 1
newCursor = tree.Insert(cursor)
obj.(bh.ImplementationIf).AddToTree(tree, newCursor)
case bh.PortTypeIf:
pt := obj.(bh.PortTypeIf)
newCursor = tree.Insert(cursor)
pt.AddToTree(tree, newCursor)
for _, impl := range t.Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
// bh.NodeIf linked to outer port
g := impl.Graph().(*signalGraphType)
var n bh.NodeIf
index := -len(t.Implementation())
if pt.Direction() == gr.InPort {
n = g.findInputNodeFromPortType(pt)
if cursor.Position == tr.AppendCursor {
index += len(g.InputNodes())
}
} else {
n = g.findOutputNodeFromPortType(pt)
if cursor.Position == tr.AppendCursor {
index += len(g.InputNodes()) + len(g.OutputNodes())
}
}
if n == nil {
log.Fatalf("nodeType.AddNewObject error: invalid implementation...\n")
}
if cursor.Position != tr.AppendCursor {
index += cursor.Position
}
gCursor := tree.CursorAt(cursor, impl)
gCursor.Position = index
n.AddToTree(tree, tree.Insert(gCursor))
}
}
default:
log.Fatalf("nodeType.AddNewObject error: invalid type %T\n", obj)
}
return
}
开发者ID:axel-freesp,项目名称:sge,代码行数:45,代码来源:nodetype.go
示例9: addExpandedMappings
func addExpandedMappings(m mp.MappingIf, n bh.NodeIf, parentId bh.NodeIdIf) {
idlist := m.MappedIds()
nId := behaviour.NodeIdNew(parentId, n.Name())
for _, id := range idlist {
if nId.String() == id.String() {
return
}
}
melem := m.AddMapping(n, nId, nil)
melem.SetExpanded(true)
for _, impl := range n.ItsType().Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
for _, nn := range impl.Graph().ProcessingNodes() {
addExpandedMappings(m, nn, nId)
}
}
}
}
开发者ID:axel-freesp,项目名称:sge,代码行数:18,代码来源:mapping.go
示例10: CreateXmlNodeMapList
func CreateXmlNodeMapList(m mp.MappingIf, n bh.NodeIf, path string) (xmln []backend.XmlNodeMap) {
p, ok := m.Mapped(n.Name())
if ok { // entire node is mapped to p:
pname := fmt.Sprintf("%s/%s", p.Arch().Name(), p.Name())
xmln = append(xmln, *CreateXmlNodeMap(path, pname))
}
nt := n.ItsType()
for _, impl := range nt.Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
for _, nn := range impl.Graph().ProcessingNodes() {
xmlnn := CreateXmlNodeMapList(m, nn, fmt.Sprintf("%s/%s", path, nn.Name()))
for _, x := range xmlnn {
xmln = append(xmln, x)
}
}
}
}
return
}
开发者ID:axel-freesp,项目名称:sge,代码行数:19,代码来源:backendconversions.go
示例11: nodePath
func (g *Global) nodePath(n bh.NodeIf, nCursor tr.Cursor, selectId bh.NodeIdIf) (cursor tr.Cursor) {
ids := strings.Split(selectId.String(), "/")
if len(ids) == 1 {
cursor = nCursor
return
}
nt := n.ItsType()
for _, impl := range nt.Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
for _, nn := range impl.Graph().ProcessingNodes() {
if nn.Name() == ids[1] {
nnId := behaviour.NodeIdFromString(strings.Join(ids[1:], "/"), selectId.Filename())
cursor = g.nodePath(nn, g.fts.CursorAt(nCursor, nn), nnId)
break
}
}
break
}
}
return
}
开发者ID:axel-freesp,项目名称:sge,代码行数:21,代码来源:global.go
示例12: NodeNew
func NodeNew(getPositioner GetPositioner, n bh.NodeIf, nId bh.NodeIdIf) (ret *Node) {
positioner := getPositioner(nId)
pos := positioner.Position()
dy := NumericOption(PortDY)
box := image.Rect(pos.X, pos.Y, pos.X+global.nodeWidth, pos.Y+global.nodeHeight+numPorts(n)*dy)
config := DrawConfig{ColorInit(ColorOption(NodeNormal)),
ColorInit(ColorOption(NodeHighlight)),
ColorInit(ColorOption(NodeSelected)),
ColorInit(ColorOption(BoxFrame)),
ColorInit(ColorOption(Text)),
image.Point{global.padX, global.padY}}
ret = &Node{NamedBoxObjectInit(box, config, n), n, positioner, nil, -1}
ret.RegisterOnHighlight(func(hit bool, pos image.Point) bool {
return ret.onHighlight(hit, pos)
})
ret.RegisterOnSelect(func() bool {
return ret.onSelect()
}, func() bool {
return ret.onDeselect()
})
portBox := image.Rect(0, 0, global.portW, global.portH)
portBox = portBox.Add(box.Min)
shiftIn := image.Point{global.padX + global.portX0, global.padY + global.portY0}
shiftOut := image.Point{box.Size().X - global.padX - global.portW - global.portX0, global.padY + global.portY0}
b := portBox.Add(shiftIn)
for _, p := range n.InPorts() {
p := PortNew(b, p)
ret.ports = append(ret.ports, p)
b = b.Add(image.Point{0, global.portDY})
}
b = portBox.Add(shiftOut)
for _, p := range n.OutPorts() {
p := PortNew(b, p)
ret.ports = append(ret.ports, p)
b = b.Add(image.Point{0, global.portDY})
}
return
}
开发者ID:axel-freesp,项目名称:sge,代码行数:38,代码来源:node.go
示例13: CreateXmlOutputNode
func CreateXmlOutputNode(n bh.NodeIf) *backend.XmlOutputNode {
tName := n.ItsType().TypeName()
if strings.HasPrefix(tName, "autoOutputNodeType-") {
tName = ""
}
ret := backend.XmlOutputNodeNew(n.Name(), tName)
if n.(*node).portlink != nil {
ret.NPort = n.(*node).portlink.Name()
}
for _, p := range n.InPorts() {
ret.InPort = append(ret.InPort, *CreateXmlInPort(p))
}
return ret
}
开发者ID:axel-freesp,项目名称:sge,代码行数:14,代码来源:backendconversions.go
示例14: addNode
func (t *signalGraphType) addNode(n bh.NodeIf) error {
if len(n.InPorts()) > 0 {
if len(n.OutPorts()) > 0 {
t.processingNodes = append(t.processingNodes, n.(*node))
} else {
t.outputNodes = append(t.outputNodes, n.(*node))
}
} else {
if len(n.OutPorts()) > 0 {
t.inputNodes = append(t.inputNodes, n.(*node))
} else {
return fmt.Errorf("signalGraphType.AddNode error: node has no ports")
}
}
t.nodes.Append(n.(*node))
return nil
}
开发者ID:axel-freesp,项目名称:sge,代码行数:17,代码来源:signalgraphtype.go
示例15: CreateXmlNodePosHint
func CreateXmlNodePosHint(nd bh.NodeIf, path string) (xmln []backend.XmlNodePosHint) {
xmlnd := CreateXmlIONodePosHint(nd, path)
xmlnd.Expanded = nd.Expanded()
xmln = append(xmln, *xmlnd)
nt := nd.ItsType()
for _, impl := range nt.Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
for _, n := range impl.Graph().ProcessingNodes() {
var p string
if len(path) == 0 {
p = nd.Name()
} else {
p = fmt.Sprintf("%s/%s", path, nd.Name())
}
hintlist := CreateXmlNodePosHint(n, p)
for _, h := range hintlist {
xmln = append(xmln, h)
}
}
break
}
}
return
}
开发者ID:axel-freesp,项目名称:sge,代码行数:24,代码来源:backendconversions.go
示例16: findNodeInIdList
func findNodeInIdList(n bh.NodeIf, parent bh.NodeIdIf, idlist []bh.NodeIdIf) bool {
nId := behaviour.NodeIdNew(parent, n.Name())
log.Printf("findNodeInIdList: n=%s, parent=%v\n", n.Name(), parent)
for _, id := range idlist {
if nId.String() == id.String() {
return true
}
}
for _, impl := range n.ItsType().Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
for _, nn := range impl.Graph().ProcessingNodes() {
if !findNodeInIdList(nn, nId, idlist) {
return false
}
}
return true
}
}
return false
}
开发者ID:axel-freesp,项目名称:sge,代码行数:20,代码来源:mapping.go
示例17: ExpandedNodeNew
func ExpandedNodeNew(getPositioner GetPositioner, userObj bh.NodeIf, nId bh.NodeIdIf) (ret *ExpandedNode) {
positioner := getPositioner(nId)
pos := positioner.Position()
path := nId.String()
config := DrawConfig{ColorInit(ColorOption(NormalExpandedNode)),
ColorInit(ColorOption(HighlightExpandedNode)),
ColorInit(ColorOption(SelectExpandedNode)),
ColorInit(ColorOption(BoxFrame)),
ColorInit(ColorOption(Text)),
image.Point{global.padX, global.padY}}
cconfig := ContainerConfig{expandedPortWidth, expandedPortHeight, 120, 80}
// Add children
var g bh.SignalGraphTypeIf
nt := userObj.ItsType()
for _, impl := range nt.Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
g = impl.Graph()
break
}
}
var children []ContainerChild
if g != nil {
empty := image.Point{}
first := image.Point{16, 32}
shift := image.Point{16, 16}
for i, n := range g.ProcessingNodes() {
var ch ContainerChild
var mode gr.PositionMode
if n.Expanded() {
mode = gr.PositionModeExpanded
} else {
mode = gr.PositionModeNormal
}
proxy := gr.PathModePositionerProxyNew(n)
proxy.SetActivePath(path)
proxy.SetActiveMode(mode)
log.Printf("ExpandedNodeNew TODO: position of child nodes. path=%s, mode=%v\n", path, mode)
chpos := proxy.Position()
if chpos == empty {
chpos = pos.Add(first.Add(shift.Mul(i)))
proxy.SetPosition(chpos)
}
id := freesp.NodeIdNew(nId, n.Name())
if n.Expanded() {
ch = ExpandedNodeNew(getPositioner, n, id)
} else {
ch = NodeNew(getPositioner, n, id)
}
children = append(children, ch)
}
}
ret = &ExpandedNode{ContainerInit(children, config, userObj, cconfig),
userObj, positioner, nil, nil}
ret.ContainerInit()
empty := image.Point{}
config = DrawConfig{ColorInit(ColorOption(InputPort)),
ColorInit(ColorOption(HighlightInPort)),
ColorInit(ColorOption(SelectInPort)),
ColorInit(ColorOption(BoxFrame)),
Color{},
image.Point{}}
for i, p := range userObj.InPorts() {
pos := p.ModePosition(gr.PositionModeExpanded)
if pos == empty {
pos = ret.CalcInPortPos(i)
}
positioner := gr.ModePositionerProxyNew(p, gr.PositionModeExpanded)
ret.AddPort(config, p, positioner)
}
config = DrawConfig{ColorInit(ColorOption(OutputPort)),
ColorInit(ColorOption(HighlightOutPort)),
ColorInit(ColorOption(SelectOutPort)),
ColorInit(ColorOption(BoxFrame)),
Color{},
image.Point{}}
for i, p := range userObj.OutPorts() {
pos := p.ModePosition(gr.PositionModeExpanded)
if pos == empty {
pos = ret.CalcOutPortPos(i)
}
positioner := gr.ModePositionerProxyNew(p, gr.PositionModeExpanded)
ret.AddPort(config, p, positioner)
}
for _, n := range g.ProcessingNodes() {
from, ok := ret.ChildByName(n.Name())
if !ok {
log.Printf("ExpandedNodeNew error: node %s not found\n", n.Name())
continue
}
for _, p := range n.OutPorts() {
fromId := from.OutPortIndex(p.Name())
for _, c := range p.Connections() {
to, ok := ret.ChildByName(c.Node().Name())
if ok {
toId := to.InPortIndex(c.Name())
ret.connections = append(ret.connections, ConnectionNew(from, to, fromId, toId))
} else {
portname, ok := c.Node().PortLink()
if !ok {
log.Printf("ExpandedNodeNew error: output node %s not linked\n", c.Node().Name())
//.........这里部分代码省略.........
开发者ID:axel-freesp,项目名称:sge,代码行数:101,代码来源:expandednode.go
示例18: treeAddNewObject
func (t *signalGraphType) treeAddNewObject(tree tr.TreeIf, cursor tr.Cursor, n bh.NodeIf) (newCursor tr.Cursor) {
newCursor = tree.Insert(cursor)
n.AddToTree(tree, newCursor)
return
}
开发者ID:axel-freesp,项目名称:sge,代码行数:5,代码来源:signalgraphtype.go
示例19: CreateObject
func (j *NewElementJob) CreateObject(fts *models.FilesTreeStore) (ret tr.TreeElementIf, err error) {
var parentObject tr.TreeElementIf
parentObject, err = fts.GetObjectById(j.parentId)
if err != nil {
log.Fatal("NewElementJob.CreateObject error: referenced parentObject run away...")
}
switch j.elemType {
case eNode, eInputNode, eOutputNode:
var context bh.SignalGraphTypeIf
switch parentObject.(type) {
case bh.NodeIf:
context = parentObject.(bh.NodeIf).Context()
j.parentId = getParentId(j.parentId)
case bh.SignalGraphIf:
context = parentObject.(bh.SignalGraphIf).ItsType()
case bh.SignalGraphTypeIf:
context = parentObject.(bh.SignalGraphTypeIf)
case bh.ImplementationIf:
if parentObject.(bh.ImplementationIf).ImplementationType() == bh.NodeTypeGraph {
context = parentObject.(bh.ImplementationIf).Graph()
} else {
log.Fatal("NewElementJob.CreateObject(eNode) error: parent implementation is no graph...")
}
default:
log.Fatal("NewElementJob.CreateObject(eNode) error: referenced parentObject wrong type...")
}
if j.elemType == eNode {
ntype, ok := freesp.GetNodeTypeByName(j.input[iNodeTypeSelect])
if !ok {
log.Fatal("NewElementJob.CreateObject(eNode) error: referenced parentObject type wrong...")
}
ret, err = behaviour.NodeNew(j.input[iNodeName], ntype, context)
} else if j.elemType == eInputNode {
ret, err = behaviour.InputNodeNew(j.input[iInputNodeName], j.input[iInputTypeSelect], context)
} else {
ret, err = behaviour.OutputNodeNew(j.input[iOutputNodeName], j.input[iOutputTypeSelect], context)
}
if len(j.extra) > 0 {
coords := strings.Split(j.extra, "|")
var x, y int
fmt.Sscanf(coords[0], "%d", &x)
fmt.Sscanf(coords[1], "%d", &y)
//pos := image.Point{x, y}
//log.Printf("NewElementJob.CreateObject(eNode) setting position %s: %v\n", j.extra, pos)
//ret.(bh.NodeIf).SetPosition(pos)
// TODO: SetModePosition...
}
case eNodeType:
var context string
switch parentObject.(type) {
case bh.NodeTypeIf:
context = parentObject.(bh.NodeTypeIf).DefinedAt()
j.parentId = getParentId(j.parentId)
case bh.SignalTypeIf:
j.parentId = getParentId(j.parentId)
parentObject, err = fts.GetObjectById(j.parentId)
context = parentObject.(bh.LibraryIf).Filename()
case bh.LibraryIf:
context = parentObject.(bh.LibraryIf).Filename()
default:
log.Fatal("NewElementJob.CreateObject(eNodeType) error: referenced parentObject wrong type...")
}
ret = behaviour.NodeTypeNew(j.input[iTypeName], context)
case eConnection:
switch parentObject.(type) {
case bh.PortIf:
case bh.SignalGraphTypeIf:
fromTo := strings.Split(j.extra, "/")
var n bh.NodeIf
for _, n = range parentObject.(bh.SignalGraphTypeIf).Nodes() {
if n.Name() == fromTo[0] {
for _, parentObject = range n.OutPorts() {
if parentObject.(bh.PortIf).Name() == fromTo[1] {
break
}
}
break
}
}
if parentObject == nil {
log.Fatalf("NewElementJob.CreateObject(eNodeType) error: no valid FROM port for edge job %v\n", j)
}
_ = parentObject.(bh.PortIf)
case bh.ImplementationIf:
fromTo := strings.Split(j.extra, "/")
var n bh.NodeIf
for _, n = range parentObject.(bh.ImplementationIf).Graph().Nodes() {
if n.Name() == fromTo[0] {
for _, parentObject = range n.OutPorts() {
if parentObject.(bh.PortIf).Name() == fromTo[1] {
break
}
}
break
}
}
if parentObject == nil {
log.Fatalf("NewElementJob.CreateObject(eNodeType) error: no valid FROM port for edge job %v\n", j)
//.........这里部分代码省略.........
开发者ID:axel-freesp,项目名称:sge,代码行数:101,代码来源:newelementjob.go
示例20: treeRemoveObject
func (t *nodeType) treeRemoveObject(tree tr.TreeIf, cursor tr.Cursor) (removed []tr.IdWithObject) {
parentId := tree.Parent(cursor)
if t != tree.Object(parentId) {
log.Fatal("nodeType.RemoveObject error: not removing child of mine.")
}
obj := tree.Object(cursor)
switch obj.(type) {
case bh.ImplementationIf:
impl := obj.(bh.ImplementationIf)
if impl.ImplementationType() == bh.NodeTypeGraph {
// TODO: This is redundant with implementation.go
// Simply remove all nodes? Do not traverse a modifying list...
// Removed Input- and Output nodes are NOT stored (they are
// created automatically when adding the implementation graph).
// Return all removed edges ...
for _, n := range impl.Graph().Nodes() {
nCursor := tree.Cursor(n)
for _, p := range n.OutPorts() {
pCursor := tree.CursorAt(nCursor, p)
for index, c := range p.Connections() {
conn := p.Connection(c)
removed = append(removed, tr.IdWithObject{pCursor.Path, index, conn})
}
}
}
// ... and processing nodes
for _, n := range impl.Graph().ProcessingNodes() {
nCursor := tree.Cursor(n)
gCursor := tree.Parent(nCursor)
nIndex := gCursor.Position
removed = append(removed, tr.IdWithObject{nCursor.Path, nIndex, n})
}
}
case bh.PortTypeIf:
nt := obj.(bh.PortTypeIf)
for _, impl := range t.Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
// Remove and store all edges connected to the nodes linked to the outer ports
g := impl.Graph().(*signalGraphType)
var n bh.NodeIf
if nt.Direction() == gr.InPort {
n = g.findInputNodeFromPortType(nt)
} else {
n = g.findOutputNodeFromPortType(nt)
}
if n == nil {
log.Fatalf("nodeType.RemoveObject error: invalid implementation...\n")
}
nCursor := tree.CursorAt(parentId, n)
for _, p := range n.InPorts() {
pCursor := tree.CursorAt(nCursor, p)
for _, c := range p.Connections() {
conn := p.Connection(c)
removed = append(removed, tr.IdWithObject{pCursor.Path, -1, conn})
}
}
for _, p := range n.OutPorts() {
pCursor := tree.CursorAt(nCursor, p)
for _, c := range p.Connections() {
conn := p.Connection(c)
removed = append(removed, tr.IdWithObject{pCursor.Path, -1, conn})
}
}
// Remove (but dont store) the nodes linked to the outer ports:
tree.Remove(nCursor)
}
}
default:
log.Fatalf("nodeType.RemoveObject error: invalid type %T\n", obj)
}
return
}
开发者ID:axel-freesp,项目名称:sge,代码行数:74,代码来源:nodetype.go
注:本文中的github.com/axel-freesp/sge/interface/behaviour.NodeIf类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论