diff -PruN electric-6.04ad/src/include/sim.h electric-6.04ad-tt/src/include/sim.h --- electric-6.04ad/src/include/sim.h Sun Jul 15 23:03:48 2001 +++ electric-6.04ad-tt/src/include/sim.h Tue Jul 17 20:14:04 2001 @@ -132,6 +132,7 @@ void sim_window_displaycolor(INTBIG strength, INTBIG color); INTBIG sim_window_newtrace(INTBIG, char*, INTBIG); INTSML sim_window_buscommand(void); +INTSML sim_window_reversecommand(void); INTSML sim_window_makebus(INTBIG count, INTBIG *traces); void sim_window_loaddigtrace(INTBIG, INTBIG, float*, INTSML*); void sim_window_loadanatrace(INTBIG, INTBIG, float*, float*); diff -PruN electric-6.04ad/src/sim/simalsgraph.c electric-6.04ad-tt/src/sim/simalsgraph.c --- electric-6.04ad/src/sim/simalsgraph.c Sun Jul 15 23:03:53 2001 +++ electric-6.04ad-tt/src/sim/simalsgraph.c Tue Jul 17 20:19:26 2001 @@ -147,6 +147,11 @@ case 'b': (void)sim_window_buscommand(); return(0); + + /* Reverse signal order */ + case 'm': + (void)sim_window_reversecommand(); + return(0); /* add trace */ case 'a': @@ -623,6 +628,7 @@ ttyputinstruction(" A", 4, _("Add signal to simulation window")); ttyputinstruction(" R", 4, _("Remove signal from the window")); ttyputinstruction(" B", 4, _("Combine selected signals into a bus")); + ttyputinstruction(" M", 4, _("Reverse the order of the selected signals")); ttyputinstruction("FT", 4, _("Full Trace of all events")); ttyputinstruction(" P", 4, _("Preserve snapshot of simulation window in database")); } diff -PruN electric-6.04ad/src/sim/simwindow.c electric-6.04ad-tt/src/sim/simwindow.c --- electric-6.04ad/src/sim/simwindow.c Sun Jul 15 23:03:53 2001 +++ electric-6.04ad-tt/src/sim/simwindow.c Thu Jul 19 13:59:54 2001 @@ -61,6 +61,7 @@ * CONTROL OF TRACES: * INTBIG sim_window_newtrace(line, name, data) Creates trace at "line" called "name" with user "data" * INTSML sim_window_buscommand() Creates a bus from currently selected signals + * INTSML sim_window_reversecommand() Reverses the order of the selected signals * sim_window_loaddigtrace(tr, num, time, sta) Loads trace "tr" with "num" digital signals "time/sta" * sim_window_loadanatrace(tr, num, time, val) Loads trace "tr" with "num" analog signals "time/val" * sim_window_setanarange(low, high) Sets analog display range from "low" to "high" @@ -214,6 +215,7 @@ static void sim_window_hthumbtrackingcallback(INTBIG delta); static void sim_window_mapcoord(WINDOWPART*, INTBIG*, INTBIG*); static void sim_window_moveto(INTBIG, INTBIG); +static void sim_window_movetrace(DISCHANNEL *tr, DISCHANNEL *otr, DISCHANNEL *otrprev); static char *sim_window_namesignals(INTBIG count, DISCHANNEL **list); static void sim_window_plottrace(DISCHANNEL *tr, WINDOWPART *wavewin, INTBIG highlight); static void sim_window_redisphandler(WINDOWPART*); @@ -663,6 +665,65 @@ return(0); } +/* + * Routine to reverse the order of selected signals. Returns nonzero on error. + */ +INTSML sim_window_reversecommand(void) +{ + DISCHANNEL *tr, *otr, *otrprev; + DISCHANNEL **traces; + INTBIG i, count; + char *par[2]; + + count = sim_window_highlightedtracecount; + if (count == 0) return(1); + if (count == 1) + { + ttyputerr(_("Must select multiple signals whose order to reverse")); + return(1); + } + + /* Copy list of highlighted traces into a temporary array */ + traces = (DISCHANNEL **)emalloc(count * sizeof(DISCHANNEL**), sim_tool->cluster); + for (i=0; i=1; i--) + { + tr = traces[i]; + + /* find which signal name it is dragged to */ + otrprev = NODISCHANNEL; + for(otr = sim_window_plot; otr != NODISCHANNEL; otr = otr->nextdischannel) + { + if ((otr->flags&TRACENOTDRAWN) == 0) + { + if (otr == traces[0]) break; + } + if (otr != tr) otrprev = otr; + } + + if (otr != NODISCHANNEL) { + sim_window_movetrace(tr, otr, otrprev); + } + } + + /* Highlight signals again */ + for (i=0; iposition < otr->position) - { - sim_window_addtrace(tr, otr); - } else - { - sim_window_addtrace(tr, otrprev); - } - - /* move any bus signals inside of this */ - buschain = endbuschain = NODISCHANNEL; - for(otr = sim_window_plot; otr != NODISCHANNEL; otr = nexttr) - { - nexttr = otr->nextdischannel; - if (otr->buschannel == tr) - { - sim_window_removetrace(otr); - if (endbuschain == NODISCHANNEL) endbuschain = buschain = otr; else - { - endbuschain->nextdischannel = otr; - endbuschain = otr; - } - otr->nextdischannel = NODISCHANNEL; - } - } - addloc = tr; - for(otr = buschain; otr != NODISCHANNEL; otr = nexttr) - { - nexttr = otr->nextdischannel; - sim_window_addtrace(otr, addloc); - addloc = otr; - } - - /* renumber lines in the display */ - for(i=0, otr = sim_window_plot; otr != NODISCHANNEL; otr = otr->nextdischannel) - if ((otr->flags&TRACENOTDRAWN) == 0) otr->position = i++; - - /* redisplay window */ - sim_window_redraw(); - - /* save the new configuration */ - sim_window_savesignalorder(); + sim_window_movetrace(tr, otr, otrprev); } sim_window_addhighlighttrace((INTBIG)tr); par[0] = "highlight"; @@ -3263,6 +3291,65 @@ tr->nameoff = 0; tr->buschannel = NODISCHANNEL; return(tr); +} + +/* + * Move trace tr to the position of otr. + * otrprev is the trace before otr in the linked list or NODISCHANNEL if otr is first. + * (I think sim_window_cleartracehighlight has to be called before this, not sure -TT) + */ +void sim_window_movetrace(DISCHANNEL *tr, DISCHANNEL *otr, DISCHANNEL *otrprev) +{ + DISCHANNEL *nexttr, *addloc, *buschain, *endbuschain; + INTBIG i; + + if (tr == otr) return; + + /* pull out the selected signal */ + sim_window_removetrace(tr); + + /* insert signal in new location */ + if (tr->position < otr->position) + { + sim_window_addtrace(tr, otr); + } else + { + sim_window_addtrace(tr, otrprev); + } + + /* move any bus signals inside of this */ + buschain = endbuschain = NODISCHANNEL; + for(otr = sim_window_plot; otr != NODISCHANNEL; otr = nexttr) + { + nexttr = otr->nextdischannel; + if (otr->buschannel == tr) + { + sim_window_removetrace(otr); + if (endbuschain == NODISCHANNEL) endbuschain = buschain = otr; else + { + endbuschain->nextdischannel = otr; + endbuschain = otr; + } + otr->nextdischannel = NODISCHANNEL; + } + } + addloc = tr; + for(otr = buschain; otr != NODISCHANNEL; otr = nexttr) + { + nexttr = otr->nextdischannel; + sim_window_addtrace(otr, addloc); + addloc = otr; + } + + /* renumber lines in the display */ + for(i=0, otr = sim_window_plot; otr != NODISCHANNEL; otr = otr->nextdischannel) + if ((otr->flags&TRACENOTDRAWN) == 0) otr->position = i++; + + /* redisplay window */ + sim_window_redraw(); + + /* save the new configuration */ + sim_window_savesignalorder(); } /********************************* LOW LEVEL GRAPHICS *********************************/