예제 #1
0
        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();
        }
예제 #2
0
        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();
        }
예제 #3
0
 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);
 }
예제 #4
0
 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;
             }
         }
     }
 }
예제 #5
0
 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);
 }
예제 #6
0
 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);
 }
예제 #7
0
 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;
             }
         }
     }
 }
예제 #8
0
        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();
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
            }
        }
예제 #11
0
        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;
            }
        }
예제 #12
0
 public ProcessingConnectionRef(RTIO _i1, RTIO _i2)
 {
     i1    = _i1;
     i2    = _i2;
     group = -1;
 }