Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes | Private Attributes | Friends
printer_rep Class Reference

#include <printer.hpp>

Inheritance diagram for printer_rep:
Inheritance graph
[legend]
Collaboration diagram for printer_rep:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 printer_rep (url ps_file_name, int dpi, int nr_pages, string ptype, bool landsc, double paper_w, double paper_h)
 ~printer_rep ()
bool is_printer ()
void next_page ()
void define (string comm, string defn)
void sep ()
void cr ()
void print (string s)
void print (SI x, SI y)
void move_to (SI x, SI y)
string define_alpha (int a)
void select_color (color c)
void select_line_width (SI w)
void make_tex_char (string name, QN c, glyph gl)
void select_tex_font (string name)
void generate_tex_fonts ()
void anchor (string label, SI x, SI y)
void href (string label, SI x1, SI y1, SI x2, SI y2)
void set_clipping (SI x1, SI y1, SI x2, SI y2, bool restore=false)
color get_color ()
color get_background ()
void set_color (color c)
void set_background (color c)
void draw (int char_code, font_glyphs fn, SI x, SI y)
void set_line_style (SI w, int type=0, bool round=true)
void line (SI x1, SI y1, SI x2, SI y2)
void lines (array< SI > x, array< SI > y)
void clear (SI x1, SI y1, SI x2, SI y2)
void fill (SI x1, SI y1, SI x2, SI y2)
void arc (SI x1, SI y1, SI x2, SI y2, int alpha, int delta)
void fill_arc (SI x1, SI y1, SI x2, SI y2, int alpha, int delta)
void polygon (array< SI > x, array< SI > y, bool convex=true)
void xpm (url file_name, SI x, SI y)
void image (url u, SI w, SI h, SI x, SI y, double cx1, double cy1, double cx2, double cy2, int alpha)
void fetch (SI x1, SI y1, SI x2, SI y2, renderer ren, SI x, SI y)
void new_shadow (renderer &ren)
void delete_shadow (renderer &ren)
void get_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2)
void put_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2)
void apply_shadow (SI x1, SI y1, SI x2, SI y2)
virtual bool is_x_drawable ()
virtual x_drawable_repas_x_drawable ()
virtual void get_extents (int &w, int &h)
virtual bool repainted ()
virtual bool interrupted (bool check=false)
void set_origin (SI x, SI y)
void move_origin (SI dx, SI dy)
void set_shrinking_factor (int sfactor)
void round (SI &x, SI &y)
void inner_round (SI &x1, SI &y1, SI &x2, SI &y2)
void outer_round (SI &x1, SI &y1, SI &x2, SI &y2)
bool is_visible (SI x1, SI y1, SI x2, SI y2)
virtual tree get_background_pattern (int &alpha)
virtual void set_background_pattern (tree t, int alpha=255)
virtual void clear_pattern (SI x1, SI y1, SI x2, SI y2)
virtual void triangle (SI x1, SI y1, SI x2, SI y2, SI x3, SI y3)
virtual void get_clipping (SI &x1, SI &y1, SI &x2, SI &y2)
void extra_clipping (SI x1, SI y1, SI x2, SI y2)
void clip (SI x1, SI y1, SI x2, SI y2)
void unclip ()
virtual void draw_rectangles (rectangles rs)
virtual void draw_selection (rectangles rs)

Public Attributes

SI ox
SI oy
SI cx1
SI cy1
SI cx2
SI cy2
int sfactor
int pixel
int thicken
renderer master
tree pattern
int pattern_alpha
rectangles clip_stack

Private Attributes

url ps_file_name
int dpi
int nr_pages
string page_type
bool landscape
double paper_w
double paper_h
bool use_alpha
string prologue
string body
int cur_page
int linelen
color fg
color bg
int ncols
SI lw
int nwidths
string cfn
int nfonts
SI xpos
SI ypos
bool tex_flag
hashmap< string, stringdefs
hashmap< string, stringtex_chars
hashmap< string, stringtex_width
hashmap< string, stringtex_fonts
hashmap< string, array< int > > tex_font_chars

Friends

void abs_round (SI &l)
void abs_round (SI &x, SI &y)
void abs_inner_round (SI &x1, SI &y1, SI &x2, SI &y2)
void abs_outer_round (SI &x1, SI &y1, SI &x2, SI &y2)

Detailed Description

Definition at line 19 of file printer.hpp.


Constructor & Destructor Documentation

printer_rep::printer_rep ( url  ps_file_name,
int  dpi,
int  nr_pages,
string  ptype,
bool  landsc,
double  paper_w,
double  paper_h 
)

Definition at line 41 of file printer.cpp.

                                                                       :
    ps_file_name (ps_file_name2), dpi (dpi2),
    nr_pages (nr_pages2), page_type (page_type2),
    landscape (landscape2), paper_w (paper_w2), paper_h (paper_h2),
    use_alpha (get_preference ("experimental alpha") == "on"),
    linelen (0), fg (-1), bg (-1), ncols (0),
    lw (-1), nwidths (0), cfn (""), nfonts (0),
    xpos (0), ypos (0), tex_flag (false),
    defs ("?"), tex_chars ("?"), tex_width ("?"),
    tex_fonts ("?"), tex_font_chars (array<int>(0))    
{
  string tex_pro, special_pro, color_pro, texps_pro;
  load_string ("$TEXMACS_PATH/misc/convert/tex.pro", tex_pro, true);
  load_string ("$TEXMACS_PATH/misc/convert/special.pro", special_pro, true);
  load_string ("$TEXMACS_PATH/misc/convert/color.pro", color_pro, true);
  load_string ("$TEXMACS_PATH/misc/convert/texps.pro", texps_pro, true);
  
  prologue   << "%!PS-Adobe-2.0\n"
            << "%%Creator: TeXmacs-" TEXMACS_VERSION "\n"
            << "%%Title: " << as_string (tail (ps_file_name)) << "\n"
            << "%%Pages: " << as_string (nr_pages) << "\n"
            << "%%PageOrder: Ascend\n";
  if (page_type != "user")
    prologue << "%%DocumentPaperSizes: " << page_type << "\n";
  if (landscape)
    prologue << "%%BoundingBox: 0 0 "
            << as_string ((int) (28.36*paper_h+ 0.5)) << " "
            << as_string ((int) (28.36*paper_w+ 0.5)) << "\n"
            << "%%Orientation: Landscape\n";
  else
    prologue << "%%BoundingBox: 0 0 "
            << as_string ((int) (28.36*paper_w+ 0.5)) << " "
            << as_string ((int) (28.36*paper_h+ 0.5)) << "\n";
  prologue   << "%%EndComments\n\n"
            << tex_pro << "\n"
            << special_pro << "\n"
            << texps_pro << "\n"
            << "TeXDict begin\n"
            << as_string ((int) (1864680.0*paper_w+ 0.5)) << " "
            << as_string ((int) (1864680.0*paper_h+ 0.5)) << " 1000 "
            << as_string (dpi) << " " << as_string (dpi)
            << " (TeXmacs) @start\n";

  define (PS_CLIP, string ("/pt4 X /pt3 X /pt2 X /pt1 X\n") *
         string ("newpath pt1 pt2 moveto pt3 pt2 lineto ") *
         string ("pt3 pt4 lineto pt1 pt4 lineto pt1 pt2 lineto clip"));
  define (PS_LINE, string ("/pt4 X /pt3 X /pt2 X /pt1 X\n") *
         string ("newpath pt1 pt2 moveto pt3 pt4 lineto stroke"));
  define (PS_FILL, string ("/pt4 X /pt3 X /pt2 X /pt1 X\n") *
         string ("newpath pt1 pt2 moveto pt3 pt2 lineto ") *
         string ("pt3 pt4 lineto pt1 pt4 lineto pt1 pt2 eofill stroke"));
  define (PS_ARC, string ("/a2 X /a1 X /r2 X /r1 X /pt2 X /pt1 X\n") *
         string ("newpath pt1 pt2 r1 r2 a1 a2 ellipse stroke"));
  define (PS_FILL_ARC, string ("/a2 X /a1 X /r2 X /r1 X /pt2 X /pt1 X\n") *
         string ("newpath pt1 pt2 r1 r2 a1 a2 ellipse eofill stroke"));
  define (PS_STROKE, string ("stroke"));
  define (PS_POL_START, string ("/pt2 X /pt1 X\n") *
         string ("newpath pt1 pt2 moveto"));
  define (PS_POL_NEXT, string ("/pt2 X /pt1 X\n") *
         string ("pt1 pt2 lineto"));
  define (PS_POL_END, string ("closepath eofill"));
  define (PS1, string ("gsave"));
  define (PS2, string ("1 -1 scale show grestore"));

  cur_page= 0;
  next_page ();
}

Here is the call graph for this function:

Definition at line 111 of file printer.cpp.

                           {
  next_page ();
  body << "\n%%Trailer\n"
       << "end\n"
       << "userdict /end-hook known{end-hook} if\n"
       << "%%EOF\n";

  generate_tex_fonts ();
  prologue << "end\n"

           << "systemdict /pdfmark known{userdict /?pdfmark systemdict /exec get put}{userdict /?pdfmark systemdict /pop get put userdict /pdfmark systemdict /cleartomark get put}ifelse\n"

           << "%%EndProlog\n\n"
          << "%%BeginSetup\n"
          << "%%Feature: *Resolution " << as_string (dpi) << "dpi\n"
          << "TeXDict begin\n";
  if (page_type != "user") {
    prologue << "%%BeginPaperSize: " << page_type << "\n";
    prologue << page_type << "\n";
    prologue << "%%EndPaperSize\n";
  }
  if (landscape)
    prologue << "@landscape\n";
  prologue << "%%EndSetup\n";

  string ps_text= prologue * "\n" * body;
  save_string (ps_file_name, ps_text);
}

Here is the call graph for this function:


Member Function Documentation

void printer_rep::anchor ( string  label,
SI  x,
SI  y 
) [virtual]

Reimplemented from renderer_rep.

Definition at line 838 of file printer.cpp.

                                             {
  string s = "(";
  s = s << prepare_text (label) << ") cvn";
  if (linelen>0) cr ();
  print ("[ /Dest");
  print (s);
  print ("/View [/XYZ");
  print (x, y);
  print ("null] /DEST pdfmark");
  cr ();
}

Here is the call graph for this function:

void printer_rep::apply_shadow ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual]

Implements renderer_rep.

Definition at line 833 of file printer.cpp.

                                                     {
  (void) x1; (void) y1; (void) x2; (void) y2;
}
void printer_rep::arc ( SI  x1,
SI  y1,
SI  x2,
SI  y2,
int  alpha,
int  delta 
) [virtual]

Implements renderer_rep.

Definition at line 662 of file printer.cpp.

                                                                  {
  print ((x1+x2)/2, (y1+y2)/2);
  print (as_string ((x2-x1)/(2*PIXEL)));
  print (as_string ((y1-y2)/(2*PIXEL)));
  print (as_string (((double) alpha)/64));
  print (as_string (((double) (alpha+delta))/64));
  print (PS_ARC);
}

Here is the call graph for this function:

x_drawable_rep * renderer_rep::as_x_drawable ( ) [virtual, inherited]

Reimplemented in x_drawable_rep.

Definition at line 48 of file renderer.cpp.

                             {
  return NULL;
}

Here is the caller graph for this function:

void printer_rep::clear ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual]

Implements renderer_rep.

Definition at line 644 of file printer.cpp.

                                              {
  select_color (bg);
  print (x1, y1);
  print (x2, y2);
  print (PS_FILL);
  select_color (fg);
}

Here is the call graph for this function:

void renderer_rep::clear_pattern ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual, inherited]

Definition at line 254 of file renderer.cpp.

                                                       {
  if (pattern == "");
  else if (is_atomic (pattern))
    clear (x1, y1, x2, y2);
  else if (is_func (pattern, PATTERN)) {
    outer_round (x1, y1, x2, y2);
    //cout << "A: " << x1 << ", " << y1 << ", " << x2 << ", " << y2 << "\n";
    //cout << "A: " << x/pixel1 << ", " << y1 << ", " << x2 << ", " << y2 << "\n";
    SI cx1, cy1, cx2, cy2;
    get_clipping (cx1, cy1, cx2, cy2);
    extra_clipping (x1, y1, x2, y2);

    url u= as_string (pattern[0]);
    int imw_pt, imh_pt;
    image_size (u, imw_pt, imh_pt);
    double pt= ((double) 600*PIXEL) / 72.0;
    SI imw= (SI) (((double) imw_pt) * pt);
    SI imh= (SI) (((double) imh_pt) * pt);

    SI w= x2 - x1, h= y2 - y1;
    if (pattern[1] == "") w= imw;
    else if (is_int (pattern[1])) w= as_int (pattern[1]);
    else if (is_percentage (pattern[1]))
      w= (SI) (as_percentage (pattern[1]) * ((double) w));
    else if (is_percentage (pattern[1], "@"))
      w= (SI) (as_percentage (pattern[1]) * ((double) h));
    if (pattern[1] == "") h= imh;
    else if (is_int (pattern[2])) h= as_int (pattern[2]);
    else if (is_percentage (pattern[2]))
      h= (SI) (as_percentage (pattern[2]) * ((double) h));
    else if (is_percentage (pattern[2], "@"))
      h= (SI) (as_percentage (pattern[2]) * ((double) w));
    w= ((w + pixel - 1) / pixel) * pixel;
    h= ((h + pixel - 1) / pixel) * pixel;

    SI sx= 0; //is_percentage (pattern[1])? 0: ox;
    SI sy= 0; //is_percentage (pattern[2])? 0: oy;
    for (int i= ((x1+sx)/w) - 1; i <= ((x2+sx)/w) + 1; i++)
      for (int j= ((y1+sy)/h) - 1; j <= ((y2+sy)/h) + 1; j++) {
       SI X1= i*w     - sx, Y1= j*h     - sy;
       SI X2= (i+1)*w - sx, Y2= (j+1)*h - sy;
       if (X1 < x2 && X2 > x1 && Y1 < y2 && Y2 > y1)
         image (u, w, h, X1, Y1, 0.0, 0.0, 1.0, 1.0, pattern_alpha);
      }
    set_clipping (cx1, cy1, cx2, cy2, true);
  }
  else clear (x1, y1, x2, y2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void renderer_rep::clip ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [inherited]

Definition at line 138 of file renderer.cpp.

                                              {
  rectangle r (cx1, cy1, cx2, cy2);
  clip_stack= rectangles (r, clip_stack);
  set_clipping (x1, y1, x2, y2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void printer_rep::cr ( )

Definition at line 189 of file printer.cpp.

                 {
  body << "\n";
  linelen= 0;
  tex_flag= false;
}

Here is the caller graph for this function:

void printer_rep::define ( string  comm,
string  defn 
)

Definition at line 171 of file printer.cpp.

                                          {
  if (defs->contains (s)) return;
  defs (defn)= s;
  prologue << "/" << s << " {" << defn << "} N\n";
}

Here is the caller graph for this function:

Definition at line 250 of file printer.cpp.

                                {
  string aa= as_string (((double) a) / 255.0);
  string s= "[ /ca " * aa * " /CA " * aa * " /SetTransparency pdfmark";
  if (!defs->contains (s)) define ("A" * as_string (a), s);
  return defs[s];
}

Here is the call graph for this function:

Here is the caller graph for this function:

void printer_rep::delete_shadow ( renderer ren) [virtual]

Implements renderer_rep.

Definition at line 818 of file printer.cpp.

                                         {
  (void) ren;
}
void printer_rep::draw ( int  char_code,
font_glyphs  fn,
SI  x,
SI  y 
) [virtual]

Implements renderer_rep.

Definition at line 594 of file printer.cpp.

                                                     {
  glyph gl= fn->get(ch);
  if (is_nil (gl)) return;
  string name= fn->res_name;
  unsigned char c= ch;
  if (ch >= 256) {
    name= name * "-" * as_string (ch / 256);
    c= (unsigned char) (ch & 255);
  }
  make_tex_char (name, c, gl);
  select_tex_font (name);
  move_to (x, y);
  print ("(" * prepare_text (string ((char) c)) * ")p");
  tex_flag= true;
  xpos += gl->lwidth;
}

Here is the call graph for this function:

void renderer_rep::draw_rectangles ( rectangles  rs) [virtual, inherited]

Definition at line 310 of file renderer.cpp.

                                            {
  rectangles it= rs;
  while (!is_nil (it)) {
    fill (it->item->x1, it->item->y1, it->item->x2, it->item->y2);
    it= it->next;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void renderer_rep::draw_selection ( rectangles  rs) [virtual, inherited]

Definition at line 319 of file renderer.cpp.

                                           {
  color fg= get_color ();
  int r, g, b, a;
  get_rgb_color (fg, r, g, b, a);
  color pfg= rgb_color (r, g, b, (a + 1) / 16);
  rectangles inn= ::thicken (rs, -pixel, -pixel);
  rectangles out= ::simplify (::correct (rs - inn));
  set_color (pfg);
  draw_rectangles (::simplify (inn));
  set_color (fg);
  draw_rectangles (out);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void renderer_rep::extra_clipping ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [inherited]

Definition at line 129 of file renderer.cpp.

                                                        {
  SI ox1, oy1, ox2, oy2;
  get_clipping (ox1, oy1, ox2, oy2);
  x1= max (x1, ox1); y1= max (y1, oy1);
  x2= max (x1, min (x2, ox2)); y2= max (y1, min (y2, oy2));
  set_clipping (x1, y1, x2, y2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void printer_rep::fetch ( SI  x1,
SI  y1,
SI  x2,
SI  y2,
renderer  ren,
SI  x,
SI  y 
) [virtual]

Implements renderer_rep.

Definition at line 807 of file printer.cpp.

                                                                        {
  (void) x1; (void) y1; (void) x2; (void) y2;
  (void) ren; (void) x; (void) y;
}
void printer_rep::fill ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual]

Implements renderer_rep.

Definition at line 653 of file printer.cpp.

                                             {
  if ((x1<x2) && (y1<y2)) {
    print (x1, y1);
    print (x2, y2);
    print (PS_FILL);
  }
}

Here is the call graph for this function:

void printer_rep::fill_arc ( SI  x1,
SI  y1,
SI  x2,
SI  y2,
int  alpha,
int  delta 
) [virtual]

Implements renderer_rep.

Definition at line 672 of file printer.cpp.

                                                                       {
  print ((x1+x2)/2, (y1+y2)/2);
  print (as_string ((x2-x1)/(2*PIXEL)));
  print (as_string ((y1-y2)/(2*PIXEL)));
  print (as_string (((double) alpha)/64));
  print (as_string (((double) (alpha+delta))/64));
  print (PS_FILL_ARC);
}

Here is the call graph for this function:

Definition at line 461 of file printer.cpp.

                                 {
  hashset<string> done;
  iterator<string> it= iterate (tex_fonts);
  while (it->busy ()) {
    string fn_name= it->next ();
    array<int> a= tex_font_chars [fn_name];
    merge_sort (a);

    int i, d, l;
    string name = tex_fonts [fn_name], ttf;
    int    pos  = search_forwards (".", fn_name);
    string root = (pos==-1? fn_name: fn_name (0, pos));
#ifndef OS_WIN32 // we need pfbtopfa
    if ((pos!=-1) && ends (fn_name, "tt")) {
      int pos2= search_backwards (":", fn_name);
      root= fn_name (0, pos2);
      url u= tt_font_find (root);
      if (suffix (u) == "pfb") {
        ttf = pfb_to_pfa (u);
      }
    }
#endif

    if (ttf != "") {
      string ttf_name= find_ps_font_name (root, ttf);
      if (!done->contains (root)) {
       prologue << "%%BeginFont: " << root << "\n";
       prologue << ttf;
       prologue << "\n%%EndFont\n";
       done->insert (root);
      }

      array<string> cum;
      cum << "{}" * as_string (N(a));
      for (i=0; i<N(a); i++) {
        string w= tex_width [fn_name * "-" * as_string (a[i])];
        d= (i==0? a[0]: (a[i]-a[i-1]-1));
        if (d>0) cum << as_string (d) * "[";
        cum << w * " ";
      }
      d= 255-a[i-1];
      if (d>0) cum << as_string (d) * "[";

      int szpos = pos-1;
      while ((szpos>0) && is_numeric (fn_name[szpos-1])) szpos--;
      double sz = as_double (fn_name (szpos, pos));
      double dpi= as_double (fn_name (pos+1, N(fn_name)-2));
      string mag= as_string (83.022 * (sz/10.0) * (dpi/600.0));

      string fdef;
      for (i=N(cum)-1; i>=0; i--) fdef << cum[i];
      fdef= "/" * name * " " * fdef * " " * mag * " /" * ttf_name * " rf";
      for (i=0, l=0; i<N(fdef); i++, l++)
        if ((l<70) || (fdef[i]!=' ')) prologue << fdef[i];
        else { prologue << '\n'; l=-1; }
      prologue << "\n";
    }
    else {
      prologue << "/" << tex_fonts [fn_name]
              << " " << as_string (N(a))
              << " " << as_string (a[N(a)-1]+1) << " df\n";
      for (i=0; i<N(a); i++) {
        int end;
        string hex_code= tex_chars [fn_name * "-" * as_string (a[i])];
        for (end=1; end < N(hex_code); end++)
          if (hex_code[end-1]=='>') break;
        string after= hex_code (end, N(hex_code));
        if ((i>0) && (a[i]==(a[i-1]+1))) after << "I";
        else after << as_string (a[i]) << " D";
        if (i==(N(a)-1)) after << " E";
        hex_code= hex_code (0, end);
      
        int j, l, n= N(hex_code);
        for (j=0; j<n; j+=79) {
          if (n < (j+79)) prologue << hex_code (j, n);
          else prologue << hex_code (j, j+79) << "\n";
        }
        l= 79-(n%79);
        if (l<N(after)) prologue << "\n";
        prologue << after << "\n";
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements renderer_rep.

Definition at line 576 of file printer.cpp.

                             {
  return bg;
}
tree renderer_rep::get_background_pattern ( int &  alpha) [virtual, inherited]

Definition at line 238 of file renderer.cpp.

                                                {
  alpha= pattern_alpha;
  if (is_atomic (pattern) || is_func (pattern, PATTERN, 4))
    return pattern;
  else {
    tree s= get_named_color (get_background ());
    if (is_func (pattern, PATTERN, 3))
      return pattern * tree (PATTERN, s);
    else return s;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void renderer_rep::get_clipping ( SI x1,
SI y1,
SI x2,
SI y2 
) [virtual, inherited]

Definition at line 115 of file renderer.cpp.

                                                          {
  x1= cx1- ox; y1= cy1- oy;
  x2= cx2- ox; y2= cy2- oy;
}

Here is the caller graph for this function:

Implements renderer_rep.

Definition at line 571 of file printer.cpp.

                        {
  return fg;
}
void renderer_rep::get_extents ( int &  w,
int &  h 
) [virtual, inherited]

Reimplemented in basic_renderer_rep, qt_renderer_rep, and x_drawable_rep.

Definition at line 43 of file renderer.cpp.

                                         {
  w= h= 0;
}

Here is the caller graph for this function:

void printer_rep::get_shadow ( renderer  ren,
SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual]

Implements renderer_rep.

Definition at line 823 of file printer.cpp.

                                                                 {
  (void) ren; (void) x1; (void) y1; (void) x2; (void) y2;
}
void printer_rep::href ( string  label,
SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual]

Reimplemented from renderer_rep.

Definition at line 851 of file printer.cpp.

                                                           {
  if (linelen>0) cr ();
  print ("[");
  if (starts (label, "#")) {
    print ("/Dest");
    print ("(" * prepare_text (label) * ") cvn");
  }
  else {
    print ("/Action");
    print ("<< /Subtype /URI /URI (" * prepare_text (label) * ") >>");
  }
  print ("/Rect [");
  print (x1 - 5*PIXEL, y1 - 10*PIXEL);
  print (x2 + 5*PIXEL, y2 + 10*PIXEL);
  print ("]");
  print ("/Border [16 16 1 [3 10]] /Color [0.75 0.5 1.0]");
  print ("/Subtype /Link");
  print ("/ANN pdfmark");
  cr ();
}

Here is the call graph for this function:

void printer_rep::image ( url  u,
SI  w,
SI  h,
SI  x,
SI  y,
double  cx1,
double  cy1,
double  cx2,
double  cy2,
int  alpha 
) [virtual]

Implements renderer_rep.

Definition at line 720 of file printer.cpp.

{
  (void) alpha; // FIXME
  int bx1, by1, bx2, by2;
  ps_bounding_box (u, bx1, by1, bx2, by2);
  int x1= bx1 + (int) (cx1 * (bx2 - bx1) + 0.5);
  int y1= by1 + (int) (cy1 * (by2 - by1) + 0.5);
  int x2= bx1 + (int) (cx2 * (bx2 - bx1) + 0.5);
  int y2= by1 + (int) (cy2 * (by2 - by1) + 0.5);

  double sc_x= (72.0/dpi) * ((double) (w/PIXEL)) / ((double) (x2-x1));
  double sc_y= (72.0/dpi) * ((double) (h/PIXEL)) / ((double) (y2-y1));
  cr ();
  cr ();

  print (x, y);
  print ("a");
  print ("currentpoint");
  print ("currentpoint");
  print ("translate");
  print (as_string (sc_x));
  print (as_string (sc_y));
  print ("scale");
  print ("neg");
  print ("exch");
  print ("neg");
  print ("exch");
  print ("translate");
  print (x, y);
  print ("a");
  cr ();
  /* Black Black 248 3155 a currentpoint currentpoint translate
     0.37114 0.37114 scale neg exch neg exch translate 248 3155 a */

  print ("@beginspecial");
  print (as_string (x1));
  print ("@llx");
  print (as_string (y1));
  print ("@lly");
  print (as_string (x2));
  print ("@urx");
  print (as_string (y2));
  print ("@ury");
  print (as_string (10*(x2-x1)));
  print ("@rwi");
  print ("@clip");
  print ("@setspecial");
  cr ();
  /* @beginspecial 0 @llx 0 @lly 613.291260 @urx 613.291260 @ury 6110 @rwi
     @clip @setspecial */
  
  string ps_image= ps_load (u);
  string imtext= is_ramdisc (u)? "inline image": as_string (u);
  body << "%%BeginDocument: " << imtext  << "\n";
  body << ps_image; // incorporate_postscript (ps_image);
  body << "%%EndDocument";
  cr ();

  print ("@endspecial");
  print (x, y);
  print ("a");
  print ("currentpoint");
  print ("currentpoint");
  print ("translate");
  print (as_string (1/sc_x));
  print (as_string (1/sc_y));
  print ("scale");
  print ("neg");
  print ("exch");
  print ("neg");
  print ("exch");
  print ("translate");
  print (x, y);
  print ("a");
  cr ();
  cr ();
  
  /* @endspecial 248 3155 a currentpoint currentpoint translate
     1 0.37114 div 1 0.37114 div scale neg exch neg exch translate
     248 3155 a 660 3073 a ... */

  (void) w; (void) h;
}

Here is the call graph for this function:

void renderer_rep::inner_round ( SI x1,
SI y1,
SI x2,
SI y2 
) [inherited]

Definition at line 167 of file renderer.cpp.

                                                         {
  x1= RND (x1+ox+pixel-1) - ox;
  y1= RND (y1+oy+pixel-1) - oy;
  x2= RND (x2+ox) - ox;
  y2= RND (y2+oy) - oy;
}
bool renderer_rep::interrupted ( bool  check = false) [virtual, inherited]

Reimplemented in basic_renderer_rep, and x_drawable_rep.

Definition at line 62 of file renderer.cpp.

                                     {
  (void) check;
  return false;
}

Here is the caller graph for this function:

bool printer_rep::is_printer ( ) [virtual]

Reimplemented from renderer_rep.

Definition at line 141 of file printer.cpp.

                         {
  return true;
}
bool renderer_rep::is_visible ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [inherited]

Definition at line 152 of file renderer.cpp.

                                                    {
  return
    (x2 >= (cx1- ox)) && (y2 >= (cy1- oy)) &&
    (x1 <  (cx2- ox)) && (y1 <  (cy2- oy));
}

Here is the caller graph for this function:

bool renderer_rep::is_x_drawable ( ) [virtual, inherited]

Reimplemented in x_drawable_rep.

Definition at line 38 of file renderer.cpp.

                             {
  return false;
}
void printer_rep::line ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual]

Implements renderer_rep.

Definition at line 624 of file printer.cpp.

                                             {
  print (x1, y1);
  print (x2, y2);
  print (PS_LINE);
}

Here is the call graph for this function:

void printer_rep::lines ( array< SI x,
array< SI y 
) [virtual]

Implements renderer_rep.

Definition at line 631 of file printer.cpp.

                                            {
  int i, n= N(x);
  if ((N(y) != n) || (n<1)) return;
  print (x[0], y[0]);
  print (PS_POL_START);
  for (i=1; i<n; i++) {
    print (x[i], y[i]);
    print (PS_POL_NEXT);
  }
  print (PS_STROKE);
}

Here is the call graph for this function:

void printer_rep::make_tex_char ( string  name,
QN  c,
glyph  gl 
)

Definition at line 324 of file printer.cpp.

                                                                  {
  // cout << "Make char " << (int) c << " of " << name << "\n";
  string char_name (name * "-" * as_string ((int) c));
  if (tex_chars->contains (char_name)) return;
  if (!tex_fonts->contains (name)) {
    tex_fonts (name)= "F" * as_string (nfonts);
    tex_font_chars (name)= array<int> (0);
    nfonts++;
  }
  tex_font_chars (name) << ((int) c);

  string hex_code;
  int i, j, count=0, cur= 0;
  for (j=0; j < gl->height; j++)
    for (i=0; i < ((gl->width+7) & (-8)); i++) {
      cur= cur << 1;
      if ((i<gl->width) && (gl->get_x(i,j)>0)) cur++;
      count++;
      if (count==4) {
        hex_code << hex_string[cur];
        cur  = 0;
        count= 0;
      }
    }

  int d1= gl->width;
  int d2= gl->height;
  int d3= 130+ gl->xoff;
  int d4= 126+ gl->yoff;
  int d5= gl->lwidth;
  if ((d1<256) && (d2<256) && (d3<256) && (d4<256) && (d5<256)) {
    hex_code << as_hexadecimal (d1, 2) << as_hexadecimal (d2, 2)
            << as_hexadecimal (d3, 2) << as_hexadecimal (d4, 2)
            << as_hexadecimal (d5, 2);
    hex_code= "<" * hex_code * ">";
  }
  else {
    hex_code= "[<" * hex_code * ">";
    hex_code << as_string (d1) << " " << as_string (d2) << " "
            << as_string (d3) << " " << as_string (d4) << " "
            << as_string (d5) << " ";
  }

  tex_chars (char_name)= hex_code;
  tex_width (char_name)= as_string (d5);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void renderer_rep::move_origin ( SI  dx,
SI  dy 
) [inherited]

Definition at line 92 of file renderer.cpp.

                                       {
  ox += dx;
  oy += dy;
}

Here is the caller graph for this function:

void printer_rep::move_to ( SI  x,
SI  y 
)

Definition at line 224 of file printer.cpp.

                                {
  x += ox; y += oy;
  if (x>=0) x= x/PIXEL; else x= (x-PIXEL+1)/PIXEL;
  if (y>=0) y= y/PIXEL; else y= (y-PIXEL+1)/PIXEL;
  if (tex_flag && (xpos==x) && (ypos==y)) return;
  if (tex_flag && (ypos==y)) {
    body->resize (N(body)-1);
    linelen -= 1;
    tex_flag= false;

    int diff= x-xpos;
    if ((diff>=-4) && (diff<=4)) print (string ((char) ('p'+diff)));
    else {
      print (as_string (diff));
      print ("b");
    }
    xpos= x;
    return;
  }
  xpos= x; ypos= y;
  print (as_string (x-dpi));
  print (as_string (-y-dpi));
  print ("a");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void printer_rep::new_shadow ( renderer ren) [virtual]

Implements renderer_rep.

Definition at line 813 of file printer.cpp.

                                      {
  (void) ren;
}
void printer_rep::next_page ( ) [virtual]

Reimplemented from renderer_rep.

Definition at line 146 of file printer.cpp.

                        {
  if (cur_page > 0) print ("eop\n");
  if (cur_page >= nr_pages) return;
  cur_page++;
  body << "\n%%Page: " << as_string (cur_page) << " "
       << as_string (cur_page) << "\n"
       << as_string (cur_page) << " "
       << as_string (cur_page-1) << " bop\n";

  set_clipping (0, (int) (-(dpi*PIXEL*paper_h)/2.54),
              (int) ((dpi*PIXEL*paper_w)/2.54), 0);

  fg  = -1;
  bg  = -1;
  lw  = -1;
  cfn = "";
  xpos= 0;
  ypos= 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void renderer_rep::outer_round ( SI x1,
SI y1,
SI x2,
SI y2 
) [inherited]

Definition at line 175 of file renderer.cpp.

                                                         {
  x1= RND (x1+ox) - ox;
  y1= RND (y1+oy) - oy;
  x2= RND (x2+ox+pixel-1) - ox;
  y2= RND (y2+oy+pixel-1) - oy;
}

Here is the caller graph for this function:

void printer_rep::polygon ( array< SI x,
array< SI y,
bool  convex = true 
) [virtual]

Implements renderer_rep.

Definition at line 682 of file printer.cpp.

                                                           {
  (void) convex;
  int i, n= N(x);
  if ((N(y) != n) || (n<1)) return;
  print (x[0], y[0]);
  print (PS_POL_START);
  for (i=1; i<n; i++) {
    print (x[i], y[i]);
    print (PS_POL_NEXT);
  }
  print (PS_POL_END);
}

Here is the call graph for this function:

Definition at line 196 of file printer.cpp.

                            {
  if (N(s)==0) return;
  if ((linelen>0) && (linelen+N(s)>79)) {
    body << "\n";
    linelen= 0;
    tex_flag= false;
  }
  else if (s[0]!='(') sep ();
  if (tex_flag && (s[0]=='(')) {
    body->resize (N(body)-2);
    linelen -= 2;
    s= s (1,N(s));
  }
  body << s;
  linelen += N(s);
  tex_flag= false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void printer_rep::print ( SI  x,
SI  y 
)

Definition at line 215 of file printer.cpp.

                              {
  x += ox; y += oy;
  if (x>=0) x= x/PIXEL; else x= (x-PIXEL+1)/PIXEL;
  if (y>=0) y= y/PIXEL; else y= (y-PIXEL+1)/PIXEL;
  print (as_string (x-dpi));
  print (as_string (-y-dpi));
}

Here is the call graph for this function:

void printer_rep::put_shadow ( renderer  ren,
SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual]

Implements renderer_rep.

Definition at line 828 of file printer.cpp.

                                                                 {
  (void) ren; (void) x1; (void) y1; (void) x2; (void) y2;
}
bool renderer_rep::repainted ( ) [virtual, inherited]

Definition at line 57 of file renderer.cpp.

                         {
  return true;
}
void renderer_rep::round ( SI x,
SI y 
) [inherited]

Definition at line 161 of file renderer.cpp.

                                 {
  x= RND (x+ ox)- ox;
  y= RND (y+ oy)- oy;
}

Definition at line 258 of file printer.cpp.

                                  {
  int r, g, b, a;
  get_rgb_color (c, r, g, b, a);
  r= 10000+ ((r*1000)/255);
  g= 10000+ ((g*1000)/255);
  b= 10000+ ((b*1000)/255);
  string rr= as_string (r); rr= rr(1,2) * "." * rr(2,5);
  string gg= as_string (g); gg= gg(1,2) * "." * gg(2,5);
  string bb= as_string (b); bb= bb(1,2) * "." * bb(2,5);
  string s = rr * " " * gg * " " * bb * " setrgbcolor";
  if (use_alpha) s= s * " " * define_alpha (a);
  if (!defs->contains (s)) {
    define ("C" * as_string (ncols), s);
    ncols++;
  }
  print (defs[s]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 277 of file printer.cpp.

                                    {
  w= w/PIXEL; if (w<1) w=1;
  string s = as_string (w) * " setlinewidth";
  if (!defs->contains (s)) {
    define ("W" * as_string (nwidths), s);
    nwidths++;
  }
  print (defs[s]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 311 of file printer.cpp.

                                         {
  if (cfn==name) return;
  cfn= name;
  print (tex_fonts [name]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void printer_rep::sep ( )

Definition at line 178 of file printer.cpp.

                  {
  if ((N(body) > 0) &&
      (body [N(body)-1] != ')') &&
      (body [N(body)-1] != '\n')) {
    body << " ";
    linelen++;
    tex_flag= false;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void printer_rep::set_background ( color  c) [virtual]

Implements renderer_rep.

Definition at line 588 of file printer.cpp.

                                    {
  if (bg==c) return;
  bg= c;
}
void renderer_rep::set_background_pattern ( tree  t,
int  alpha = 255 
) [virtual, inherited]

Definition at line 227 of file renderer.cpp.

                                                         {
  pattern= pat;
  pattern_alpha= alpha;
  if (pattern == "");
  else if (is_atomic (pattern))
    set_background (named_color (pat->label, alpha));
  else if (is_func (pattern, PATTERN, 4))
    set_background (named_color (as_string (pattern[3]), alpha));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void printer_rep::set_clipping ( SI  x1,
SI  y1,
SI  x2,
SI  y2,
bool  restore = false 
) [virtual]

Reimplemented from renderer_rep.

Definition at line 551 of file printer.cpp.

                                                                   {
  outer_round (x1, y1, x2, y2);
  renderer_rep::set_clipping (x1, y1, x2, y2);
  if (restore) {
    print (PS_CLIP_POP);
    cfn= "";
  }
  else {
    print (PS_CLIP_PUSH);
    print (x1, y1);
    print (x2, y2);
    print (PS_CLIP);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void printer_rep::set_color ( color  c) [virtual]

Implements renderer_rep.

Definition at line 581 of file printer.cpp.

                               {
  if (fg==c) return;
  fg= c;
  select_color (c);
}

Here is the call graph for this function:

void printer_rep::set_line_style ( SI  w,
int  type = 0,
bool  round = true 
) [virtual]

Implements renderer_rep.

Definition at line 612 of file printer.cpp.

                                                       {
  (void) type;
  (void) round;
  // if (lw == w) return;
  // FIXME: apparently, the line width can be overidden by some of
  // the graphical constructs (example file: newimpl.tm, in which
  // the second dag was not printed using the right width)
  lw= w;
  select_line_width (w);
}

Here is the call graph for this function:

void renderer_rep::set_origin ( SI  x,
SI  y 
) [inherited]

Definition at line 86 of file renderer.cpp.

                                    {
  ox= x;
  oy= y;
}

Here is the caller graph for this function:

void renderer_rep::set_shrinking_factor ( int  sfactor) [inherited]

Definition at line 98 of file renderer.cpp.

                                          {
  ox  /= sfactor; oy  /= sfactor;
  cx1 /= sfactor; cy1 /= sfactor;
  cx2 /= sfactor; cy2 /= sfactor;
  sfactor= sf;
  pixel  = sf*PIXEL;
  thicken= (sf>>1)*PIXEL;
  ox  *= sfactor; oy  *= sfactor;
  cx1 *= sfactor; cy1 *= sfactor;
  cx2 *= sfactor; cy2 *= sfactor;
}

Here is the caller graph for this function:

void renderer_rep::triangle ( SI  x1,
SI  y1,
SI  x2,
SI  y2,
SI  x3,
SI  y3 
) [virtual, inherited]

Definition at line 218 of file renderer.cpp.

                                                                {
  array<SI> x (3), y (3);
  x[0]= x1; y[0]= y1;
  x[1]= x2; y[1]= y2;
  x[2]= x3; y[2]= y3;
  polygon (x, y);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void renderer_rep::unclip ( ) [inherited]

Definition at line 145 of file renderer.cpp.

                      {
  rectangle r (clip_stack->item);
  set_clipping (r->x1- ox, r->y1- oy, r->x2- ox, r->y2- oy);
  clip_stack= clip_stack->next;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void printer_rep::xpm ( url  file_name,
SI  x,
SI  y 
) [virtual]

Implements renderer_rep.

Definition at line 696 of file printer.cpp.

                                           {
  (void) file_name; (void) x; (void) y;
  FAILED ("not yet implemented");
}

Friends And Related Function Documentation

void abs_inner_round ( SI x1,
SI y1,
SI x2,
SI y2 
) [friend, inherited]

Definition at line 198 of file renderer.cpp.

                                                 {
  x1= RND (x1+PIXEL-1);
  y1= RND (y1+PIXEL-1);
  x2= RND (x2);
  y2= RND (y2);
}
void abs_outer_round ( SI x1,
SI y1,
SI x2,
SI y2 
) [friend, inherited]

Definition at line 206 of file renderer.cpp.

                                                 {
  x1= RND (x1);
  y1= RND (y1);
  x2= RND (x2+PIXEL-1);
  y2= RND (y2+PIXEL-1);
}
void abs_round ( SI l) [friend, inherited]

Definition at line 187 of file renderer.cpp.

                  {
  l= RND (l);
}
void abs_round ( SI x,
SI y 
) [friend, inherited]

Definition at line 192 of file renderer.cpp.

                         {
  x= RND (x);
  y= RND (y);
}

Member Data Documentation

Definition at line 33 of file printer.hpp.

Definition at line 29 of file printer.hpp.

Definition at line 37 of file printer.hpp.

Definition at line 44 of file renderer.hpp.

int printer_rep::cur_page [private]

Definition at line 30 of file printer.hpp.

SI renderer_rep::cx1 [inherited]

Definition at line 37 of file renderer.hpp.

SI renderer_rep::cx2 [inherited]

Definition at line 37 of file renderer.hpp.

SI renderer_rep::cy1 [inherited]

Definition at line 37 of file renderer.hpp.

SI renderer_rep::cy2 [inherited]

Definition at line 37 of file renderer.hpp.

Definition at line 42 of file printer.hpp.

int printer_rep::dpi [private]

Definition at line 21 of file printer.hpp.

Definition at line 33 of file printer.hpp.

bool printer_rep::landscape [private]

Definition at line 24 of file printer.hpp.

int printer_rep::linelen [private]

Definition at line 31 of file printer.hpp.

SI printer_rep::lw [private]

Definition at line 35 of file printer.hpp.

Reimplemented in qt_shadow_renderer_rep.

Definition at line 41 of file renderer.hpp.

int printer_rep::ncols [private]

Definition at line 34 of file printer.hpp.

int printer_rep::nfonts [private]

Definition at line 38 of file printer.hpp.

int printer_rep::nr_pages [private]

Definition at line 22 of file printer.hpp.

int printer_rep::nwidths [private]

Definition at line 36 of file printer.hpp.

SI renderer_rep::ox [inherited]

Definition at line 36 of file renderer.hpp.

SI renderer_rep::oy [inherited]

Definition at line 36 of file renderer.hpp.

Definition at line 23 of file printer.hpp.

double printer_rep::paper_h [private]

Definition at line 26 of file printer.hpp.

double printer_rep::paper_w [private]

Definition at line 25 of file printer.hpp.

Definition at line 42 of file renderer.hpp.

int renderer_rep::pattern_alpha [inherited]

Definition at line 43 of file renderer.hpp.

int renderer_rep::pixel [inherited]

Definition at line 39 of file renderer.hpp.

Definition at line 28 of file printer.hpp.

Definition at line 20 of file printer.hpp.

int renderer_rep::sfactor [inherited]

Definition at line 38 of file renderer.hpp.

Definition at line 43 of file printer.hpp.

bool printer_rep::tex_flag [private]

Definition at line 40 of file printer.hpp.

Definition at line 46 of file printer.hpp.

Definition at line 45 of file printer.hpp.

Definition at line 44 of file printer.hpp.

int renderer_rep::thicken [inherited]

Definition at line 40 of file renderer.hpp.

bool printer_rep::use_alpha [private]

Definition at line 27 of file printer.hpp.

SI printer_rep::xpos [private]

Definition at line 39 of file printer.hpp.

SI printer_rep::ypos [private]

Definition at line 39 of file printer.hpp.


The documentation for this class was generated from the following files: