Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes | Friends
qt_shadow_renderer_rep Class Reference

#include <qt_renderer.hpp>

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

List of all members.

Public Member Functions

 qt_shadow_renderer_rep (QPixmap _px=QPixmap())
 ~qt_shadow_renderer_rep ()
void get_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2)
void begin (void *handle)
void end ()
void get_extents (int &w, int &h)
void set_clipping (SI x1, SI y1, SI x2, SI y2, bool restore=false)
void draw (int char_code, font_glyphs fn, SI x, SI y)
void set_color (color c)
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 draw_clipped (QImage *im, int w, int h, SI x, SI y)
void draw_clipped (QPixmap *im, int w, int h, SI x, SI y)
void new_shadow (renderer &ren)
void delete_shadow (renderer &ren)
void put_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2)
void apply_shadow (SI x1, SI y1, SI x2, SI y2)
QPixmap * xpm_image (url file_name)
virtual bool interrupted (bool check=false)
color rgb (int r, int g, int b, int a=255)
void get_rgb (color col, int &r, int &g, int &b, int &a)
color get_color ()
color get_background ()
void set_background (color c)
void encode (SI &x, SI &y)
void decode (SI &x, SI &y)
void fetch (SI x1, SI y1, SI x2, SI y2, renderer ren, SI x, SI y)
cache_image_element get_image_cache (tree lookup)
void set_image_cache (tree lookup, cache_image_element ci)
void image_auto_gc ()
void image_gc (string name)
virtual bool is_printer ()
virtual bool is_x_drawable ()
virtual x_drawable_repas_x_drawable ()
virtual void next_page ()
virtual bool repainted ()
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 anchor (string label, SI x, SI y)
virtual void href (string label, SI x1, SI y1, SI x2, SI y2)
virtual void draw_rectangles (rectangles rs)
virtual void draw_selection (rectangles rs)

Public Attributes

QPixmap px
qt_renderer_repmaster
QPainter * painter
int w
int h
color cur_fg
color cur_bg
SI ox
SI oy
SI cx1
SI cy1
SI cx2
SI cy2
int sfactor
int pixel
int thicken
tree pattern
int pattern_alpha
rectangles clip_stack

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 87 of file qt_renderer.hpp.


Constructor & Destructor Documentation

qt_shadow_renderer_rep::qt_shadow_renderer_rep ( QPixmap  _px = QPixmap())

Definition at line 752 of file qt_renderer.cpp.

: qt_renderer_rep (new QPainter()), px(_px) 
{ 
  //cout << px.width() << "," << px.height() << " " << LF;
 // painter->begin(&px);
}

Definition at line 760 of file qt_renderer.cpp.

{ 
  painter->end(); 
  delete painter;
  painter = NULL;
}

Member Function Documentation

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

Reimplemented in printer_rep.

Definition at line 68 of file renderer.cpp.

                                             {
  (void) label; (void) x; (void) y;
  return;
}

Here is the caller graph for this function:

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

Reimplemented from basic_renderer_rep.

Definition at line 670 of file qt_renderer.cpp.

                                                          {
  if (master == NULL) return;
  if (painter == static_cast<qt_renderer_rep*>(master)->painter) return;
  outer_round (x1, y1, x2, y2);
  decode (x1, y1);
  decode (x2, y2);
  static_cast<qt_renderer_rep*>(master)->encode (x1, y1);
  static_cast<qt_renderer_rep*>(master)->encode (x2, y2);
  master->put_shadow (this, x1, y1, x2, y2);
}

Here is the call graph for this function:

void qt_renderer_rep::arc ( SI  x1,
SI  y1,
SI  x2,
SI  y2,
int  alpha,
int  delta 
) [virtual, inherited]

Implements renderer_rep.

Definition at line 223 of file qt_renderer.cpp.

                                                                      {
  (void) alpha; (void) delta;
  if ((x1>=x2) || (y1>=y2)) return;
  decode (x1, y1);
  decode (x2, y2);
  painter->setRenderHints (QPainter::Antialiasing);
  painter->drawArc (x1, y2, x2-x1, y1-y2, alpha / 4, delta / 4);
}

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 qt_renderer_rep::begin ( void *  handle) [virtual, inherited]

Reimplemented from basic_renderer_rep.

Definition at line 89 of file qt_renderer.cpp.

                                    {
  QPaintDevice *device = (QPaintDevice*)handle;
  painter->begin (device);
  w = painter->device()->width();
  h = painter->device()->height();
}

Here is the caller graph for this function:

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

Implements renderer_rep.

Definition at line 184 of file qt_renderer.cpp.

                                                  {
  x1= max (x1, cx1-ox); y1= max (y1, cy1-oy);
  x2= min (x2, cx2-ox); y2= min (y2, cy2-oy);
  // outer_round (x1, y1, x2, y2); might still be needed somewhere
  decode (x1, y1);
  decode (x2, y2);
  if ((x1>=x2) || (y1<=y2)) return;
  QBrush brush (to_qcolor(cur_bg));
  painter->setRenderHints (0);
  painter->fillRect (x1, y2, x2-x1, y1-y2, brush);       
}

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 basic_renderer_rep::decode ( SI x,
SI y 
) [inherited]

Here is the caller graph for this function:

void qt_renderer_rep::delete_shadow ( renderer ren) [virtual, inherited]

Reimplemented from basic_renderer_rep.

Definition at line 602 of file qt_renderer.cpp.

                                              {
  if (ren != NULL) {
    tm_delete (ren);
    ren= NULL;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void qt_renderer_rep::draw ( int  char_code,
font_glyphs  fn,
SI  x,
SI  y 
) [virtual, inherited]

Implements renderer_rep.

Definition at line 424 of file qt_renderer.cpp.

                                                         {
  // get the pixmap
  basic_character xc (c, fng, sfactor, cur_fg, 0);
  qt_image mi = character_image [xc];
  if (is_nil(mi)) {
    int r, g, b, a;
    get_rgb (cur_fg, r, g, b, a);
    SI xo, yo;
    glyph pre_gl= fng->get (c); if (is_nil (pre_gl)) return;
    glyph gl= shrink (pre_gl, sfactor, sfactor, xo, yo);
    int i, j, w= gl->width, h= gl->height;
#ifdef QTMPIXMAPS
    QTMImage *im = new QPixmap(w,h);
    {
      int nr_cols= sfactor*sfactor;
      if (nr_cols >= 64) nr_cols= 64;

      im->fill (Qt::transparent);
      QPainter pp(im);
      QPen pen(painter->pen());
      QBrush brush(pen.color());
      pp.setPen(Qt::NoPen);
      for (j=0; j<h; j++)
        for (i=0; i<w; i++) {
          int col = gl->get_x (i, j);
          brush.setColor (QColor (r, g, b, (a*col)/nr_cols));
          pp.fillRect (i, j, 1, 1, brush);
        }
      pp.end();
    }
#else
    QTMImage *im= new QImage (w, h, QImage::Format_ARGB32);
    //QTMImage *im= new QImage (w, h, QImage::Format_ARGB32_Premultiplied);
    {
      int nr_cols= sfactor*sfactor;
      if (nr_cols >= 64) nr_cols= 64;

      // the following line is disabled because
      // it causes a crash on Qt/X11 4.4.3
      //im->fill (Qt::transparent);

      for (j=0; j<h; j++)
        for (i=0; i<w; i++) {
          int col = gl->get_x (i, j);
          im->setPixel (i, j, qRgba (r, g, b, (a*col)/nr_cols));
        }
    }
#endif
    qt_image mi2 (im, xo, yo, w, h);
    mi = mi2;
    //[im release]; // qt_image retains im
    character_image (xc)= mi;
    // FIXME: we must release the image at some point 
    //        (this should be ok now, see qt_image)
  }

  // draw the character
  //cout << (char)c << ": " << cx1/256 << ","  << cy1/256 << ","  
  //<< cx2/256 << ","  << cy2/256 << LF; 
  draw_clipped (mi->img, mi->w, mi->h, x- mi->xo*sfactor, y+ mi->yo*sfactor);
}

Here is the call graph for this function:

void qt_renderer_rep::draw_clipped ( QImage *  im,
int  w,
int  h,
SI  x,
SI  y 
) [inherited]

Definition at line 400 of file qt_renderer.cpp.

                                                                   {
  (void) w; (void) h;
  int x1=cx1-ox, y1=cy2-oy, x2= cx2-ox, y2= cy1-oy;
  decode (x , y );
  decode (x1, y1);
  decode (x2, y2);
  y--; // top-left origin to bottom-left origin conversion
       // clear(x1,y1,x2,y2);
  painter->setRenderHints (0);
  painter->drawImage (x, y, *im);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void qt_renderer_rep::draw_clipped ( QPixmap *  im,
int  w,
int  h,
SI  x,
SI  y 
) [inherited]

Definition at line 413 of file qt_renderer.cpp.

                                                                    {
  decode (x , y );
  y--; // top-left origin to bottom-left origin conversion
  // clear(x1,y1,x2,y2);
  painter->setRenderHints (0);
  painter->drawPixmap (x, y, w, h, *im);
}

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 basic_renderer_rep::encode ( SI x,
SI y 
) [inherited]

Here is the caller graph for this function:

void qt_renderer_rep::end ( ) [virtual, inherited]

Reimplemented from basic_renderer_rep.

Definition at line 96 of file qt_renderer.cpp.

{ painter->end (); }

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 basic_renderer_rep::fetch ( SI  x1,
SI  y1,
SI  x2,
SI  y2,
renderer  ren,
SI  x,
SI  y 
) [virtual, inherited]

Implements renderer_rep.

void qt_renderer_rep::fill ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual, inherited]

Implements renderer_rep.

Definition at line 197 of file qt_renderer.cpp.

                                                 {
  if ((x2>x1) && ((x2-x1)<pixel)) {
    SI d= pixel-(x2-x1);
    x1 -= (d>>1);
    x2 += ((d+1)>>1);
  }
  if ((y2>y1) && ((y2-y1)<pixel)) {
    SI d= pixel-(y2-y1);
    y1 -= (d>>1);
    y2 += ((d+1)>>1);
  }

  x1= max (x1, cx1-ox); y1= max (y1, cy1-oy);
  x2= min (x2, cx2-ox); y2= min (y2, cy2-oy);
  // outer_round (x1, y1, x2, y2); might still be needed somewhere
  if ((x1>=x2) || (y1>=y2)) return;

  decode (x1, y1);
  decode (x2, y2);

  QBrush brush (to_qcolor(cur_fg));
  painter->setRenderHints (0);
  painter->fillRect (x1, y2, x2-x1, y1-y2, brush);       
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements renderer_rep.

Definition at line 233 of file qt_renderer.cpp.

                                                                           {
  (void) alpha; (void) delta;
  if ((x1>=x2) || (y1>=y2)) return;
  decode (x1, y1);
  decode (x2, y2);
  QBrush brush(to_qcolor(cur_fg));
  QPainterPath pp;
  pp.arcMoveTo (x1, y2, x2-x1, y1-y2, alpha / 64);
  pp.arcTo (x1, y2, x2-x1, y1-y2, alpha / 64, delta / 64);
  pp.closeSubpath ();
  pp.setFillRule (Qt::WindingFill);
  painter->setRenderHints (QPainter::Antialiasing);
  painter->fillPath (pp, brush);
}

Here is the call graph for this function:

color basic_renderer_rep::get_background ( ) [virtual, inherited]

Implements renderer_rep.

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:

color basic_renderer_rep::get_color ( ) [virtual, inherited]

Implements renderer_rep.

void qt_renderer_rep::get_extents ( int &  w,
int &  h 
) [virtual, inherited]

Reimplemented from basic_renderer_rep.

Definition at line 99 of file qt_renderer.cpp.

                                              {  
  if (painter->device()) {
    w2 = painter->device()->width(); h2 = painter->device()->height();
  } else {
    w2 = w; h2 = h;
  }
}

Here is the caller graph for this function:

Here is the caller graph for this function:

void basic_renderer_rep::get_rgb ( color  col,
int &  r,
int &  g,
int &  b,
int &  a 
) [inherited]

Here is the caller graph for this function:

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

Reimplemented from qt_renderer_rep.

Definition at line 768 of file qt_renderer.cpp.

                                                                            {
  // FIXME: we should use the routine fetch later
  ASSERT (ren != NULL, "invalid renderer");
  if (ren->is_printer ()) return;
  qt_shadow_renderer_rep* shadow= static_cast<qt_shadow_renderer_rep*>(ren);
  outer_round (x1, y1, x2, y2);
  x1= max (x1, cx1- ox);
  y1= max (y1, cy1- oy);
  x2= min (x2, cx2- ox);
  y2= min (y2, cy2- oy);
  shadow->ox= ox;
  shadow->oy= oy;
  shadow->cx1= x1+ ox;
  shadow->cy1= y1+ oy;
  shadow->cx2= x2+ ox;
  shadow->cy2= y2+ oy;
  shadow->master= this;
  decode (x1, y1);
  decode (x2, y2);
  if (x1<x2 && y2<y1) {
    QRect rect = QRect(x1, y2, x2-x1, y1-y2);
    shadow->painter->setClipRect(rect);

//    shadow->painter->setCompositionMode(QPainter::CompositionMode_Source);   
    shadow->painter->drawPixmap (rect, px, rect);
//    cout << "qt_shadow_renderer_rep::get_shadow " 
//         << rectangle(x1,y2,x2,y1) << LF;
//  XCopyArea (dpy, win, shadow->win, gc, x1, y2, x2-x1, y1-y2, x1, y2);
  } else {
    shadow->painter->setClipRect(QRect());
  }
}

Here is the call graph for this function:

void renderer_rep::href ( string  label,
SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual, inherited]

Reimplemented in printer_rep.

Definition at line 74 of file renderer.cpp.

                                                           {
  (void) label;
  (void) x1; (void) y1; (void) x2; (void) y2;
  return;
}

Here is the caller graph for this function:

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

Implements renderer_rep.

Definition at line 280 of file qt_renderer.cpp.

{
  // Given an image of original size (W, H),
  // we display the part (cx1 * W, xy1 * H, cx2 * W, cy2 * H)
  // at position (x, y) in a rectangle of size (w, h)
  if(cx2<=cx1 || cy2<=cy1) return;

  w= w/pixel; h= h/pixel;
  decode (x, y);

  // safety check
  url ru = resolve(u);
  u = is_none (ru) ? "$TEXMACS_PATH/misc/pixmaps/unknown.ps" : ru;
  
  QImage *pm = NULL;
  tree lookup= tuple (u->t);
  lookup << as_string (w ) << as_string (h )
         << as_string (cx1) << as_string (cy1)
         << as_string (cx2) << as_string (cy2) << "qt-image" ;
  cache_image_element ci = get_image_cache(lookup);
  if (!is_nil(ci)) {
    pm= static_cast<QImage*> (ci->ptr);
  } else {
    // rendering
    bool needs_crop= false;
    if (qt_supports (u)) {
      pm= new QImage (utf8_to_qstring (concretize (u)));
      needs_crop= true;
    }
    else if (suffix (u) == "ps" ||
             suffix (u) == "eps" ||
             suffix (u) == "pdf") {
      url temp= url_temp (".png");
      image_to_png (u, temp, w, h);
      needs_crop= true;
/*
      string idstr= eval_system ("identify",u);
      int i=0;
      int a=0,b=0;
      while(i<N(idstr)) {
        b=0;
        if(idstr[i]==' ') {
          i++;
          a=i;
          while(i<N(idstr) && idstr[i]>'0' && idstr[i]<'9')
            i++;
          if(i>=N(idstr))
            break;
          if(idstr[i] != 'x')
            continue;
          i++;
          b=i;
          while(i<N(idstr) && idstr[i]>'0' && idstr[i]<'9')
            i++;
          if(i<N(idstr) && idstr[i]==' ')
            break;
        }
        i++;
      }
      int iw,ih;
      if(b>0) {
        iw=as_int(idstr(a,b-1));
        ih=as_int(idstr(b,i));
      } else {
        int bbx1,bby1,bbx2,bby2;
        ps_bounding_box(u,bbx1,bby1,bbx2,bby2);
        iw=bbx2-bbx1;
        ih=bby2-bby1;
      }

//      float resx = 72*w/((bbx2-bbx1)*(cx2-cx1));
//      float resy = 72*h/((bby2-bby1)*(cy2-cy1));
      float resx = 144*w/(iw*(cx2-cx1));
      float resy = 144*h/(ih*(cy2-cy1));

      url temp= url_temp (".png");
      system ("convert -density " * as_string(resx) * "x" * as_string(resy)
             * " -scale 50% -crop " * as_string(w) * "x" * as_string(h)
             * "+" * as_string (cx1*w/(cx2-cx1))
             * "+" * as_string ((1-cy2)*h/(cy2-cy1))
             * "! -background white -flatten", u, temp);
*/
      pm= new QImage (to_qstring (as_string (temp)));
      remove (temp);
    }
    if (pm == NULL || pm->isNull ()) {
      cout << "TeXmacs] warning: cannot render " << concretize (u) << "\n";
      if (pm != NULL) delete pm;
      return;
    }

    if(needs_crop) {
      int iw= pm->width ();
      int ih= pm->height ();
      int x1= as_int (cx1 * iw);
      int y1= as_int (cy1 * ih);
      int x2= as_int (cx2 * iw);
      int y2= as_int (cy2 * ih);
      int ww= x2 - x1;
      int hh= y2 - y1;

      (*pm)= pm->copy(QRect (x1, hh-y2, ww, hh));
      (*pm)= pm->scaled(w,h);
    }

    ci = tm_new<qt_cache_image_rep> (w,h, texmacs_time(), pm);
    set_image_cache(lookup, ci);
    (ci->nr)++;
  }

  qreal old_opacity= painter->opacity ();
  painter->setOpacity (qreal (alpha) / qreal (255));
  painter->drawImage (x, y-h, *pm);
  painter->setOpacity (old_opacity);
};

Here is the call graph for this function:

Here is the caller graph for this function:

void basic_renderer_rep::image_auto_gc ( ) [inherited]
void basic_renderer_rep::image_gc ( string  name) [inherited]

Here is the caller 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;
}
virtual bool basic_renderer_rep::interrupted ( bool  check = false) [virtual, inherited]

Reimplemented from renderer_rep.

Here is the caller graph for this function:

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

Reimplemented in pdf_renderer_rep, and printer_rep.

Definition at line 33 of file renderer.cpp.

                          {
  return false;
}

Here is the caller graph for this function:

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 qt_renderer_rep::line ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual, inherited]

Implements renderer_rep.

Definition at line 156 of file qt_renderer.cpp.

                                                 {
  decode (x1, y1);
  decode (x2, y2);
  // y1--; y2--; // top-left origin to bottom-left origin conversion
  painter->setRenderHints (QPainter::Antialiasing);
  painter->drawLine (x1, y1, x2, y2);
}

Here is the call graph for this function:

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

Implements renderer_rep.

Definition at line 165 of file qt_renderer.cpp.

                                                {
  int i, n= N(x);
  if ((N(y) != n) || (n<1)) return;
  STACK_NEW_ARRAY (pnt, QPoint, n);
  for (i=0; i<n; i++) {
    SI xx= x[i], yy= y[i];
    decode (xx, yy);
    pnt[i].rx()= xx;
    pnt[i].ry()= yy;
    if (i>0) {
      painter->setRenderHints (QPainter::Antialiasing);
      painter->drawLine (pnt[i-1], pnt[i]); // FIX: hack
    }
  }
  // XDrawLines (dpy, win, gc, pnt, n, CoordModeOrigin);
  STACK_DELETE_ARRAY (pnt);
}

Here is the call 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 qt_renderer_rep::new_shadow ( renderer ren) [virtual, inherited]

Reimplemented from basic_renderer_rep.

Reimplemented in qt_proxy_renderer_rep.

Definition at line 585 of file qt_renderer.cpp.

                                          {
  SI mw, mh, sw, sh;
  get_extents (mw, mh);
  if (ren != NULL) {
    ren->get_extents (sw, sh);
    if (sw != mw || sh != mh) {
      delete_shadow (ren);
      ren= NULL;
    }
    // cout << "Old: " << sw << ", " << sh << "\n";
  }
  if (ren == NULL)  ren= (renderer) tm_new<qt_proxy_renderer_rep> (this);
  
  // cout << "Create " << mw << ", " << mh << "\n";
}

Here is the call graph for this function:

void renderer_rep::next_page ( ) [virtual, inherited]

Reimplemented in pdf_renderer_rep, printer_rep, and cg_renderer_rep.

Definition at line 53 of file renderer.cpp.

                         {
}

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 qt_renderer_rep::polygon ( array< SI x,
array< SI y,
bool  convex = true 
) [virtual, inherited]

Implements renderer_rep.

Definition at line 249 of file qt_renderer.cpp.

                                                               {
  int i, n= N(x);
  if ((N(y) != n) || (n<1)) return;
  QPolygonF poly(n);
  for (i=0; i<n; i++) {
    SI xx= x[i], yy= y[i];
    decode (xx, yy);
    poly[i] = QPointF (xx, yy);
  }
  QBrush brush(to_qcolor(cur_fg));
  QPainterPath pp;
  pp.addPolygon (poly);
  pp.closeSubpath ();
  pp.setFillRule (convex? Qt::OddEvenFill: Qt::WindingFill);
  painter->setRenderHints (QPainter::Antialiasing);
  painter->fillPath (pp, brush);
}

Here is the call graph for this function:

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

Reimplemented from basic_renderer_rep.

Definition at line 645 of file qt_renderer.cpp.

                                                                     {
  // FIXME: we should use the routine fetch later
  ASSERT (ren != NULL, "invalid renderer");
  if (ren->is_printer ()) return;
  if (painter == static_cast<qt_renderer_rep*>(ren)->painter) return;
  qt_shadow_renderer_rep* shadow= static_cast<qt_shadow_renderer_rep*>(ren);
  outer_round (x1, y1, x2, y2);
  x1= max (x1, cx1- ox);
  y1= max (y1, cy1- oy);
  x2= min (x2, cx2- ox);
  y2= min (y2, cy2- oy);
  decode (x1, y1);
  decode (x2, y2);
  if (x1<x2 && y2<y1) {
    QRect rect = QRect(x1, y2, x2-x1, y1-y2);
    //    cout << "qt_shadow_renderer_rep::put_shadow " 
    //         << rectangle(x1,y2,x2,y1) << LF;
    //    painter->setCompositionMode(QPainter::CompositionMode_Source);
    painter->drawPixmap (rect, shadow->px, rect);
    //  XCopyArea (dpy, shadow->win, win, gc, x1, y2, x2-x1, y1-y2, x1, y2);
  }
}

Here is the call graph for this function:

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

Definition at line 57 of file renderer.cpp.

                         {
  return true;
}
color basic_renderer_rep::rgb ( int  r,
int  g,
int  b,
int  a = 255 
) [inherited]
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;
}
void basic_renderer_rep::set_background ( color  c) [virtual, inherited]

Implements renderer_rep.

Here is the caller graph for this function:

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 qt_renderer_rep::set_clipping ( SI  x1,
SI  y1,
SI  x2,
SI  y2,
bool  restore = false 
) [virtual, inherited]

Reimplemented from basic_renderer_rep.

Definition at line 112 of file qt_renderer.cpp.

{
  (void) restore;
  basic_renderer_rep::set_clipping (x1, y1, x2, y2);
  outer_round (x1, y1, x2, y2);
  decode (x1, y1);
  decode (x2, y2);
  if ((x1<x2) && (y2<y1)) {
    QRect r(x1,y2,x2-x1,y1-y2);
    painter->setClipRect(r);
  } else {
    painter->setClipRect(QRect());
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void qt_renderer_rep::set_color ( color  c) [virtual, inherited]

Reimplemented from basic_renderer_rep.

Definition at line 134 of file qt_renderer.cpp.

                                   {
  basic_renderer_rep::set_color(c);
  QPen p (painter->pen ());
  QBrush b (painter->brush ());
  p.setColor (to_qcolor(cur_fg));
  b.setColor (to_qcolor(cur_fg));
  painter->setPen (p);
  painter->setBrush (b);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void basic_renderer_rep::set_image_cache ( tree  lookup,
cache_image_element  ci 
) [inherited]

Here is the caller graph for this function:

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

Implements renderer_rep.

Definition at line 145 of file qt_renderer.cpp.

                                                            {
  (void) type;
  QPen p (painter->pen ());
  if (lw <= pixel) p.setWidth (0);
  else p.setWidth ((lw+thicken) / (1.0*pixel));
  p.setCapStyle (round? Qt::RoundCap: Qt::SquareCap);
  p.setJoinStyle (Qt::RoundJoin);
  painter->setPen (p);
}
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 qt_renderer_rep::xpm ( url  file_name,
SI  x,
SI  y 
) [virtual, inherited]

Implements renderer_rep.

Definition at line 522 of file qt_renderer.cpp.

                                               {
  y -= pixel; // counter balance shift in draw_clipped
  QPixmap* image = xpm_image (file_name);
  ASSERT (sfactor == 1, "shrinking factor should be 1");
  int w, h;
  w = image->width ();
  h = image->height ();
  int old_clip= char_clip;
  char_clip= true;
  draw_clipped (image, w, h, x, y);
  char_clip=old_clip;
}

Here is the call graph for this function:

QPixmap * qt_renderer_rep::xpm_image ( url  file_name) [inherited]

Definition at line 493 of file qt_renderer.cpp.

                                         {
  QPixmap *pxm= NULL;
  qt_pixmap mi= images [as_string (file_name)];
  if (is_nil (mi)) {
    string sss;
    if (suffix (file_name) == "xpm") {
      url png_equiv= glue (unglue (file_name, 3), "png");
      load_string ("$TEXMACS_PIXMAP_PATH" * png_equiv, sss, false);
    }
    if (sss == "")
      load_string ("$TEXMACS_PIXMAP_PATH" * file_name, sss, false);
    if (sss == "")
      load_string ("$TEXMACS_PATH/misc/pixmaps/TeXmacs.xpm", sss, true);
    uchar *buf= (uchar*) as_charp (sss);
    pxm= new QPixmap();
    pxm->loadFromData (buf, N(sss));
    tm_delete_array ((char*) buf);
    //out << sss;
    //cout << "pxm: " << file_name << "(" << pxm->size().width()
    //     << "," <<  pxm->size().height() << ")\n";
    qt_pixmap mi2 (pxm, 0, 0, pxm->width(), pxm->height());
    mi= mi2;
    images (as_string (file_name))= mi2;
  }
  else pxm=  mi->img ;
  return pxm;
}

Here is the call graph for this function:

Here is the caller graph for this function:


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 44 of file renderer.hpp.

Definition at line 79 of file basic_renderer.hpp.

Definition at line 79 of file basic_renderer.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.

int basic_renderer_rep::h [inherited]

Definition at line 78 of file basic_renderer.hpp.

Reimplemented from renderer_rep.

Definition at line 90 of file qt_renderer.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.

QPainter* qt_renderer_rep::painter [inherited]

Definition at line 40 of file qt_renderer.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 89 of file qt_renderer.hpp.

int renderer_rep::sfactor [inherited]

Definition at line 38 of file renderer.hpp.

int renderer_rep::thicken [inherited]

Definition at line 40 of file renderer.hpp.

int basic_renderer_rep::w [inherited]

Definition at line 78 of file basic_renderer.hpp.


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