void display( struct listnode *p,int i) { int count=0,x=160,y=100; setfillstyle(SOLID_FILL,BLACK); bar(145,70,640,400); while(p!=0) { /* to display maximam 4 nodes in row */ if(count<4) { count++; drawnode(x,y,p,i); x+=120; if(count>1) nlink(x-240,y,0); } else { newlink(520,y,0); drawnode(160,y+100,p,i); x=280;y+=100; count=1; } p=p->next; } }
void displaypotpl() { int i; color(WHITE); clear(); for(i=0;i<NMAX;i++) if(potpl[i]>0) drawnode(i,RED); drawbuffer(); }
void drawtree(Tree *t, Image *m, Rectangle r) { Point p; draw(m, r, display->white, nil, ZP); replclipr(t->clipr, 1, r); p = addpt(t->offset, r.min); drawnode(t->root, m, t->clipr, p); }
// display active dominos, labels... // dominos are black, except for first, // position of first handed in as argument void displaytt(long at1,long at2) { long i,n1,n2; color(WHITE); clear(); for(i=1;i<ndominos;i++) { n1 = dominos[i].atnode1; n2 = dominos[i].atnode2; //drawdomino(n1,n2,c); drawdominocb(n1,n2,BLACK); } drawnode(at1,RED); drawnode(at2,BLUE); border(); //drawbndys(); drawnum(ndominos,100,35); drawnum(nsteps,520,35); drawnum(dominos[0].atnode1,220,35); drawnum(dominos[0].atnode2,350,35); //drawbuffer(); }
// display active dominos, labels... // display limited to available window space... void displaypart() { long i,n1,n2,c; color(WHITE); clear(); for(i=0;i<ndominos;i++) { n1 = dominos[i].atnode1; n2 = dominos[i].atnode2; c = dominos[i].color; drawdominopart(n1,n2,c); } border(); //drawbndys(); #if OBS for(i=0;i<nobs;i++) drawnode(Obs[i],BLACK); #endif #if FPTR if(funum == 0) label("very soft",520,475); if(funum == 1) label("soft",530,475); if(funum == 2) label("nhp",532,475); #endif drawnum(ndominos,100,35); drawnum(nsteps,520,35); //drawnum(dominos[0].atnode1,250,35); //drawnum(dominos[0].atnode2,350,35); //label("P = ",520,480); //drawnum(Pav,-1,-1); Printf("\nT = %.2lf",Temp); labit(280,480); if(fluxctl) { Printf("\nflux %d",netflux); labit(280,480); } //if(!histctl) drawbuffer(); }
uint drawnode(Tnode *t, Image *m, Image *clipr, Point o) { int i; char *fs, *s; uint dy; Point oo; if(t == nil) return 0; t->offset = o; oo = Pt(o.x+Nubwidth+2, o.y); // if(t->draw) // dy = (*t->draw)(t, m, clipr, oo); // else{ fs = nil; if(t->str) s = t->str; // else if(t->strfn) // fs = s = (*t->strfn)(t); else s = "???"; dy = drawtext(s, m, clipr, oo); free(fs); // } if(t->expanded) { if(t->nkid == -1 && t->expand) (*t->expand)(t); oo = Pt(o.x+Nubwidth+(Linewidth-Nubwidth)/2, o.y+dy); for(i=0; i<t->nkid; i++) oo.y += drawnode(t->kid[i], m, clipr, oo); dy = oo.y - o.y; } drawnub(m, clipr, o, t); return dy; }
struct listnode *insertnode(struct listnode *head,int *address,int t) { int info,i,x,y,count=0,position; struct listnode *p,*temp; char ch[50]; if(head==0) { getdata(300,400,0," LIST IS EMPTY"); return head; } info=getdata(300,400,2,"ENTER A NUM(2 DIGI)0 EXIT"); for(count=0,p=head;p!=0;p=p->next,count++); sprintf(ch,"ENTER POSITION(1 TO %d)",count+1); position=getdata(300,400,2,ch); if(position<=0||position>12||count+1<position) { getdata(300,400,0," INVALID POSITION "); return head; } if(count>=12) { getdata(300,400,0,"CAN'T TAKE MORE THAN 12 NODES"); return head; } temp=(struct listnode*)calloc(sizeof(struct listnode),1); if(temp==0) { getdata(100,100,0,"Memory not avilable,con't create node"); return head; } temp->pre=0; temp->next=0; temp->num=info; temp->add=*address; *address+=50; temp->padd=0; temp->nadd=0; if(position==1) { opmessage( 160, 400, ' ',"Put Link New Node to Head Node And Set Head Is New Node",MAGENTA); drawnode(160,150,temp,t); firstlink(); sleep(1); opmessage( 160, 400, ' ',"Put Link New Node to Head Node And Set Head Is New Node",BLACK); temp->next=head; head->pre=temp; head->padd=temp->add; temp->nadd=head->add; head=temp; display(head,t); return head; } for( i=2,p=head;i<position&&p->next!=0;i++,p=p->next); if(count+1==position) { opmessage( 160, 400, ' ',"Create New Node And Put Link Last Node to New Node ",MAGENTA); sleep(1); opmessage( 160, 400, ' ',"Create New Node And Put Link Last Node to New Node ",BLACK); p->next=temp; temp->pre=p; temp->padd=p->add; p->nadd=temp->add; display(head,t); return head; } sprintf(ch,"Create New Node And Put Link New Node to %d Node ",position); opmessage( 160, 400, ' ',ch,MAGENTA); sprintf(ch," And Put Link %d Node To New Node ",position-1); opmessage( 160, 410, ' ',ch,MAGENTA); delay(1000); temp->next=p->next; p->next->pre=temp; temp->nadd=p->next->add; p->next->padd=temp->add; temp->pre=p; temp->padd=p->add; p->next=temp; p->nadd=temp->add; if(position==5||position==9) { if(position==5) y=150; else y=250; x=520; newlink(x,y-50,1); drawnode(x,y,temp,t); rlinelink(x,y); sleep(1); llinelink(x,y-50); sleep(1); sprintf(ch,"Create New Node And Put Link New Node to %d Node ",position); opmessage( 160, 400, ' ',ch,BLACK); sprintf(ch," And Put Link %d Node To New Node ",position-1); opmessage( 160, 410, ' ',ch,BLACK); display(head,t); return head; } if(position>1&&position<5) y=100; if(position>5&&position<9) y=200; if(position>9&&position<12) y=300; if(position==2||position==6||position==10) x=160; if(position==3||position==7||position==11) x=280; if(position==4||position==8) x=400; drawnode(x+60,y+50,temp,t); nlink(x,y,1); rlink(x+120,y); sleep(1); llink(x,y); sleep(1); sprintf(ch,"Create New Node And Put Link New Node to %d Node ",position); opmessage( 160, 400, ' ',ch,BLACK); sprintf(ch," And Put Link %d Node To New Node ",position-1); opmessage( 160, 410, ' ',ch,BLACK); display(head,t); return head; }
void drawdominocb(long n1,long n2,long c) { float x1,y1,x2,y2; long ix1,iy1,ix2,iy2,i1,j1,i2,j2; long nn; #if 1 if(n1-n2 == 1) // for correct graphics outline... { nn = n1; n1 = n2; n2 = nn; } #endif #if 1 if(n1-n2 == -ROWL) { nn = n1; n1 = n2; n2 = nn; } #endif // domino wrap-around... // just skip for time bean... // ok, now filling in with single squares. if(n1-n2 == (ROWL-1)) goto cb; if(n2-n1 == (ROWL-1)) goto cb; if(n1-n2 == (NROWS-1)*ROWL) goto cb; if(n2-n1 == (NROWS-1)*ROWL) goto cb; i1 = n1%ROWL; j1 = n1/ROWL; x1 = i1 * CELLSZ - 1.5; y1 = j1 * CELLSZ - 1.0; x1 -= gl_oleft; x1 *= gl_oxfact; ix1 = x1; y1 -= gl_otop; y1 *= gl_oyfact; iy1 = y1 - YDISP; i2 = n2%ROWL; j2 = n2/ROWL; x2 = i2 * CELLSZ - 1.5; y2 = j2 * CELLSZ - 1.0; x2 -= gl_oleft; x2 *= gl_oxfact; ix2 = x2; y2 -= gl_otop; y2 *= gl_oyfact; iy2 = y2 - YDISP; //if(c == 0) // color(RED); //else // color(BLUE); color(c); //gl_rect(ix1+SZ1,iy1+SZ1,ix1+SZ2,iy1+SZ2); //gl_rect(ix2+SZ1,iy2+SZ1,ix2+SZ2,iy2+SZ2); brectf(ix1+SZ1,iy1+SZ1,ix2+SZ2,iy2+SZ2); color(BLACK); brect(ix1+SZ1,iy1+SZ1,ix2+SZ2,iy2+SZ2); return; cb: drawnode(n1,c); drawnode(n2,c); //nn = 3; // dummy statement //continue; }
// display active dominos, labels... void display() { long i,n1,n2,c,vdisp=(DOMY-NROWS); color(WHITE); clear(); if(!dispctl) { for(i=0;i<ndominos;i++) { n1 = dominos[i].atnode1; n2 = dominos[i].atnode2; #if CLOCK c = clocktocolor(dominos[i].clock); #else c = dominos[i].color; //c = RED; #endif if(vdisp != 0) { n1 += vdisp*ROWL; n2 += vdisp*ROWL; if(n1 >= ROWL) drawdominocb(n1,n2,c); } else drawdominocb(n1,n2,c); } } else // red/blue horizontal/vertical display { //sleep(1); for(i=0;i<ndominos;i++) { n1 = dominos[i].atnode1; n2 = dominos[i].atnode2; if((n1 == n2+1) || (n1 == n2-1) || (n1 == (n2-ROWL+1)) || (n1 == (n2+ROWL-1))) c = RED; else c = BLUE; drawdominocb(n1,n2,c); } } border(); //drawbndys(); // what did this do? #if OBS for(i=0;i<nobs;i++) drawnode(Obs[i],BLACK); #endif #if FPTR if(funum == 0) label("very soft",520,475); if(funum == 1) label("soft",530,475); if(funum == 2) label("nhp",532,475); #endif drawnum(ndominos,100,35); drawnum(nsteps,520,35); ////drawnum(totalflux,300,35); // defined in domhist.c //drawnum(dominos[0].atnode1,250,35); //drawnum(dominos[0].atnode2,350,35); //label("P = ",520,480); //drawnum(Pav,-1,-1); if(fluxctl) { Printf("\nflux %d",netflux); labit(50,480); } Printf("\nT = %.3lf",Temp); labit(280,480); //if(!histctl) drawbuffer(); }