Exemplo n.º 1
0
static PetscErrorCode PetscDrawString_X(PetscDraw draw,PetscReal x,PetscReal  y,int c,const char chrs[])
{
  PetscErrorCode ierr;
  int            xx,yy;
  size_t         len;
  PetscDraw_X    *XiWin = (PetscDraw_X*)draw->data;
  char           *substr;
  PetscToken     token;

  PetscFunctionBegin;
  xx = XTRANS(draw,XiWin,x);  yy = YTRANS(draw,XiWin,y);
  PetscDrawXiSetColor(XiWin,c);

  ierr = PetscTokenCreate(chrs,'\n',&token);CHKERRQ(ierr);
  ierr = PetscTokenFind(token,&substr);CHKERRQ(ierr);
  ierr = PetscStrlen(substr,&len);CHKERRQ(ierr);
  XDrawString(XiWin->disp,PetscDrawXiDrawable(XiWin),XiWin->gc.set,xx,yy - XiWin->font->font_descent,substr,len);
  ierr = PetscTokenFind(token,&substr);CHKERRQ(ierr);
  while (substr) {
    yy  += 4*XiWin->font->font_descent;
    ierr = PetscStrlen(substr,&len);CHKERRQ(ierr);
    XDrawString(XiWin->disp,PetscDrawXiDrawable(XiWin),XiWin->gc.set,xx,yy - XiWin->font->font_descent,substr,len);
    ierr = PetscTokenFind(token,&substr);CHKERRQ(ierr);
  }
  ierr = PetscTokenDestroy(&token);CHKERRQ(ierr);

  PetscFunctionReturn(0);
}
Exemplo n.º 2
0
static PetscErrorCode PetscDrawString_Image(PetscDraw draw,PetscReal x,PetscReal y,int c,const char text[])
{
  PetscImage     img = (PetscImage)draw->data;
  PetscToken     token;
  char           *subtext;
  PetscErrorCode ierr;
  PetscFunctionBegin;
  PetscDrawValidColor(c);
  {
    int xx = XTRANS(draw,img,x);
    int yy = YTRANS(draw,img,y);
    ierr = PetscTokenCreate(text,'\n',&token);CHKERRQ(ierr);
    ierr = PetscTokenFind(token,&subtext);CHKERRQ(ierr);
    while (subtext) {
      PetscImageDrawText(img,xx,yy,c,subtext);
      yy += PetscImageFontHeight;
      ierr = PetscTokenFind(token,&subtext);CHKERRQ(ierr);
    }
    ierr = PetscTokenDestroy(&token);CHKERRQ(ierr);
  }
  PetscFunctionReturn(0);
}