void putpages(void) { int i, lasti=0; float nmh; if (maxx*WW > MW-RH/2) { Scaler = (float) (MW-RH/2) / (float) (maxx*WW); fprintf(pfd, "%f %f scale\n", Scaler, Scaler); nmh = (float) MH; nmh /= Scaler; MH = (int) nmh; } for (i = TotSteps-1; i >= 0; i--) { if (!I[i]) continue; spitbox(i, 0, 0, I[i]); } if (ldepth >= TotSteps) ldepth = TotSteps-1; for (i = 0; i <= ldepth; i++) { if (!M[i] && !L[i]) continue; /* no box here */ if (6+i*HH >= MH*pspno) { fprintf(pfd, "showpage\nrestore\n"); startpage(); } if (T[i] > 0) /* red arrow */ { int reali = i*HH; int realt = T[i]*HH; int topop = (reali)/MH; topop *= MH; reali -= topop; realt -= topop; if (M[i] == M[T[i]] && reali == realt) /* an rv handshake */ psline( M[lasti], reali+2-3*HH/2, M[i], reali, (float) 1.,(float) 0.,(float) 0., 2); else psline( M[i], reali, M[T[i]], realt, (float) 1.,(float) 0.,(float) 0., 2); if (realt >= MH) T[T[i]] = -i; } else if (T[i] < 0) /* arrow from prev page */ { int reali = (-T[i])*HH; int realt = i*HH; int topop = (realt)/MH; topop *= MH; reali -= topop; realt -= topop; psline( M[-T[i]], reali, M[i], realt, (float) 1., (float) 0., (float) 0., 2); } if (L[i]) { spitbox(M[i], 0, i, L[i]); /* free(L[i]); */ lasti = i; } } fprintf(pfd, "showpage\nrestore\n"); }
bool CReb::getFile(const QString& href, const QString& nm) { qDebug("File:%s, Name:%s", (const char*)href, (const char*)nm); QMap<QString, UInt32>::Iterator iter = m_index.find(href); if (iter != m_index.end()) { qDebug("REB:BEFORE:%u", locate()); startpage(iter.data()); qDebug("REB:AFTER:%u", locate()); return true; } else { return false; } }
void putprelude(void) { char snap[256]; FILE *fd; sprintf(snap, "%s.ps", oFname?oFname->name:"msc"); if (!(pfd = fopen(snap, MFLAGS))) fatal("cannot create file '%s'", snap); fprintf(pfd, "%%!PS-Adobe-2.0\n"); fprintf(pfd, "%%%%Creator: %s\n", SpinVersion); fprintf(pfd, "%%%%Title: MSC %s\n", oFname?oFname->name:"--"); fprintf(pfd, "%%%%BoundingBox: 119 154 494 638\n"); ntimes(pfd, 0, 1, PsPre); if (s_trail) { if (ntrail) sprintf(snap, "%s%d.trail", oFname?oFname->name:"msc", ntrail); else sprintf(snap, "%s.trail", oFname?oFname->name:"msc"); if (!(fd = fopen(snap, "r"))) { snap[strlen(snap)-2] = '\0'; if (!(fd = fopen(snap, "r"))) fatal("cannot open trail file", (char *) 0); } TotSteps = 1; while (fgets(snap, 256, fd)) TotSteps++; fclose(fd); } TotSteps += 10; R = (int *) emalloc(TotSteps * sizeof(int)); D = (int *) emalloc(TotSteps * sizeof(int)); M = (short *) emalloc(TotSteps * sizeof(short)); T = (short *) emalloc(TotSteps * sizeof(short)); L = (char **) emalloc(TotSteps * sizeof(char *)); I = (char **) emalloc(TotSteps * sizeof(char *)); ProcLine = (char *) emalloc(1024 * sizeof(char)); startpage(); }
void conv(Biobuf *Bp) { long n; int r; char special[10]; int save; inputlineno = 1; if (debug) Bprint(Bstderr, "conv(Biobufhdr *Bp=0x%x)\n", Bp); while ((r = Bgetrune(Bp)) >= 0) { /* Bprint(Bstderr, "r=<%c>,0x%x\n", r, r); */ /* Bflush(Bstderr); */ switch (r) { case 's': /* set point size */ Bgetfield(Bp, 'd', &fontsize, 0); break; case 'f': /* set font to postion */ Bgetfield(Bp, 'd', &fontpos, 0); save = inputlineno; settrfont(); inputlineno = save; /* ugh */ break; case 'c': /* print rune */ r = Bgetrune(Bp); runeout(r); break; case 'C': /* print special character */ Bgetfield(Bp, 's', special, 10); specialout(special); break; case 'N': /* print character with numeric value from current font */ Bgetfield(Bp, 'd', &n, 0); break; case 'H': /* go to absolute horizontal position */ Bgetfield(Bp, 'd', &n, 0); hgoto(n); break; case 'V': /* go to absolute vertical position */ Bgetfield(Bp, 'd', &n, 0); vgoto(n); break; case 'h': /* go to relative horizontal position */ Bgetfield(Bp, 'd', &n, 0); hmot(n); break; case 'v': /* go to relative vertical position */ Bgetfield(Bp, 'd', &n, 0); vmot(n); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': /* move right nn units, then print character c */ n = (r - '0') * 10; r = Bgetrune(Bp); if (r < 0) error(FATAL, "EOF or error reading input\n"); else if (r < '0' || r > '9') error(FATAL, "integer expected\n"); n += r - '0'; r = Bgetrune(Bp); hmot(n); runeout(r); break; case 'p': /* begin page */ Bgetfield(Bp, 'd', &n, 0); endpage(); startpage(); break; case 'n': /* end of line (information only 'b a' follows) */ Brdline(Bp, '\n'); /* toss rest of line */ inputlineno++; break; case 'w': /* paddable word space (information only) */ break; case 'D': /* graphics function */ draw(Bp); break; case 'x': /* device control functions */ devcntl(Bp); break; case '#': /* comment */ Brdline(Bp, '\n'); /* toss rest of line */ case '\n': inputlineno++; break; default: error(WARNING, "unknown troff function <%c>\n", r); break; } } endpage(); if (debug) Bprint(Bstderr, "r=0x%x\n", r); if (debug) Bprint(Bstderr, "leaving conv\n"); }
void CReb::home() { startpage(m_homepage); }