public void RemoveIO(RTIO node) { int idx = connectedIOs.IndexOf(node); node.connectedTo = null; if (idx < 0) { throw new Exception("Bad call"); } int i = 0; while (i < connections.Count) { if (connections[i].Contains(idx)) { connections.RemoveAt(i); } else { i++; } } FixGraph(); }
public void addConnection(RTIO IOstart, RTIO IOstop) { Boolean foundStart = false; Boolean foundStop = false; int idxStart = -1; int idxStop = -1; for (int i = 0; i < connectedIOs.Count; i++) { if (connectedIOs[i] == IOstart) { foundStart = true; idxStart = i; } if (connectedIOs[i] == IOstop) { foundStop = true; idxStop = i; } } // Add new connection if (!foundStart) { idxStart = connectedIOs.Count; connectedIOs.Add(IOstart); } if (!foundStop) { idxStop = connectedIOs.Count; connectedIOs.Add(IOstop); } // Check for existing pair Boolean exists = false; foreach (ProcessingConnection pc in connections) { if (pc.Connects(idxStart, idxStop)) { exists = true; } } if (!exists) { connections.Add(new ProcessingConnection(idxStart, idxStop)); } if ((IOstart.connectedTo != null) && (IOstart.connectedTo != this)) { throw new Exception("Connnection of two nets - not handled properly!"); } if ((IOstop.connectedTo != null) && (IOstop.connectedTo != this)) { throw new Exception("Connnection of two nets - not handled properly!"); } IOstart.connectedTo = this; IOstop.connectedTo = this; CheckValidity(); }
public RTIO findIO(Vector v) { v = toScreen(v); foreach (RTForm rf in elements) { RTIO rio = rf.findIO(v); if (rio != null) { return(rio); } } return(null); }
private void sortRank(List <RTIO> io, List <int> crit) { for (int i = 0; i < io.Count - 1; i++) { for (int j = i + 1; j < io.Count; j++) { if (crit[i] > crit[j]) { RTIO tio = io[i]; io[i] = io[j]; io[j] = tio; int tcrit = crit[i]; crit[i] = crit[j]; crit[j] = tcrit; } } } }
public DataBuffer getDataOutputBuffer(RTIO io) { if (io == null) { return(null); } if (io.connectedTo == null) { return(null); } if (io.IOtype != RTIO.ProcessingIOType.DataOutput) { return(null); } return(io.connectedTo.dataInput); }
public SignalBuffer getSignalOutputBuffer(RTIO io) { if (io == null) { return(null); } if (io.connectedTo == null) { return(null); } if (io.IOtype != RTIO.ProcessingIOType.SignalOutput) { return(null); } return(io.connectedTo.signalInput); }
public virtual void Disconnect() { // Remove Object from the Panel foreach (Control ct in Controls) { if (ct is RTIO) { RTIO io = (RTIO)ct; if (io.connectedTo != null) { io.connectedTo.RemoveIO(io); io.connectedTo = null; } } } }
public void createConnection(RTIO io, RTIO ioto) { if (io == ioto) { return; // Loop back not allowed } // Check for attached nets if ((ioto.connectedTo != null) && (io.connectedTo != null)) { // Both connected already if (ioto.connectedTo == io.connectedTo) { return; // Already connected! } // Merge Nets ProcessingNet voidNet = ioto.connectedTo; LockWorker(); io.connectedTo.MergeFrom(ioto.connectedTo); nets.Remove(voidNet); io.connectedTo.addConnection(io, ioto); UnLockWorker(); return; } if (io.connectedTo != null) { LockWorker(); io.connectedTo.addConnection(io, ioto); UnLockWorker(); return; } if (ioto.connectedTo != null) { LockWorker(); ioto.connectedTo.addConnection(io, ioto); UnLockWorker(); return; } // Still here --> create new net ProcessingNet net = new ProcessingNet(this); LockWorker(); net.addConnection(io, ioto); nets.Add(net); UnLockWorker(); }
public int GetIOId(RTIO io) { int ctr = 0; foreach (Control ct in Controls) { if (ct is RTIO) { RTIO i = (RTIO)ct; if (i == io) { return(ctr); } ctr++; } } return(-1); }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (dragMode == DragMode.drawLine) { _highlighted = false; Invalidate(); dragMode = DragMode.Idle; RTForm el = element; el.owner.hideTemporaryConnection(); Vector to = el.owner.fromScreen(Vector.V(el.Location) + Vector.V(Location) + Vector.V(e.Location)); RTIO ioto = el.owner.findIO(to); if (ioto != null) { el.owner.createConnection(this, ioto); } } else { forwardOnMouseUp(e); } }
private void getNamedPoints(RTIO io, out Vector pstart, out Vector pstop, out Vector textpos, out Vector textdir) { Vector pos = Vector.Zero; Vector dir = Vector.Zero; VectorRect vr = VectorRect.Empty; int rank = 0; io.getPosAndDir(ref pos, ref dir, ref vr, ref rank); pstart = owner.toScreen(pos); VectorBox vx = GraphicsUtil.sizeText(owner.netNameFont, _name, 2, -1, -1); pstop = pstart + dir * owner.scale * (vx.boundingDim().x + 20); if (dir.x < 0) { textpos = pstop - dir * owner.scale * 10; textdir = -dir; } else { textpos = pstart + dir * owner.scale * 10; textdir = dir; } }
public ProcessingConnectionRef(RTIO _i1, RTIO _i2) { i1 = _i1; i2 = _i2; group = -1; }