IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29815


Ignore:
Timestamp:
Nov 24, 2010, 11:54:39 AM (15 years ago)
Author:
eugene
Message:

add ResizeByImage and DefineSectionByImage; fix image and graph overlay in png and ps

Location:
branches/eam_branches/ipp-20101103/Ohana/src/kapa2
Files:
1 added
19 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/Makefile

    r25757 r29815  
    4242$(SRC)/bDrawObjects.$(ARCH).o             $(SRC)/bDrawFrame.$(ARCH).o         \
    4343$(SRC)/bDrawLabels.$(ARCH).o              $(SRC)/bDrawIt.$(ARCH).o            \
     44$(SRC)/bDrawImage.$(ARCH).o               \
    4445$(SRC)/PNGit.$(ARCH).o                    $(SRC)/PPMit.$(ARCH).o              \
    4546$(SRC)/PSit.$(ARCH).o                     $(SRC)/CrossHairs.$(ARCH).o         \
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/include/prototypes.h

    r29783 r29815  
    4040void          DrawYErrors         PROTO((KapaGraphWidget *graph, Gobjects *objects));
    4141void          DrawTick            PROTO((Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis));
    42 void          AxisTickScale       PROTO((Axis *axis, double *major, double *minor));
     42void          AxisTickScale       PROTO((Axis *axis, double *major, double *minor, int *nsignif));
    4343TickMarkData *CreateAxisTicks     PROTO((Axis *axis, int *nticks));
    44 int           PrintTick           PROTO((char *string, double value, double min, double max));
     44int           PrintTick           PROTO((char *string, double value, double min, double max, int nsignif));
    4545
    4646/* EventLoop */
     
    6868int           MoveSection         PROTO((int sock));
    6969int           DefineSection       PROTO((int sock));
     70int           DefineSectionByImage PROTO((int sock));
    7071int           SetFont             PROTO((int sock));
    7172int           EraseCurrentPlot    PROTO((void));
     
    127128
    128129/* kapa bDraw Functions */
    129 int           bDrawFrame          PROTO((KapaGraphWidget *graph));
    130 int           bDrawObjects        PROTO((KapaGraphWidget *graph));
    131 void          bDrawLabels         PROTO((KapaGraphWidget *graph));
    132 void          bDrawTextlines      PROTO((KapaGraphWidget *graph));
    133 void          bDrawConnect        PROTO((KapaGraphWidget *graph, Gobjects *object));
    134 void          bDrawHistogram      PROTO((KapaGraphWidget *graph, Gobjects *object));
    135 void          bDrawPoints         PROTO((KapaGraphWidget *graph, Gobjects *object));
    136 void          bDrawXErrors        PROTO((KapaGraphWidget *graph, Gobjects *object));
    137 void          bDrawYErrors        PROTO((KapaGraphWidget *graph, Gobjects *object));
    138 void          bDrawTick           PROTO((Axis *axis, int P, TickMarkData *tick, int naxis));
    139 void          bDrawClipLine       PROTO((double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0));
    140 bDrawBuffer  *bDrawIt             PROTO((void));
    141 void          bDrawGraph          PROTO((KapaGraphWidget *graph));
     130int           bDrawFrame          PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph));
     131int           bDrawObjects        PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph));
     132void          bDrawLabels         PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph));
     133void          bDrawTextlines      PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph));
     134void          bDrawConnect        PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
     135void          bDrawHistogram      PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
     136void          bDrawPoints         PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
     137void          bDrawXErrors        PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
     138void          bDrawYErrors        PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
     139void          bDrawTick           PROTO((bDrawBuffer *buffer, Axis *axis, int P, TickMarkData *tick, int naxis));
     140void          bDrawClipLine       PROTO((bDrawBuffer *buffer, double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0));
     141void          bDrawGraph          PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph));
     142int           bDrawImage          PROTO((bDrawBuffer *buffer, KapaImageWidget *image, Graphic *graphic));
     143bDrawBuffer  *bDrawIt             PROTO((png_color *palette, int Npalette, int Nbyte));
    142144
    143145/* misc support */
     
    245247int           GetActiveSocket (void);
    246248void          InvertButton (Graphic *graphic, Button *button);
    247 void          bDrawOverlay (KapaImageWidget *image, int N);
     249void          bDrawOverlay (bDrawBuffer *buffer, KapaImageWidget *image, int N);
    248250
    249251/* color cube tools */
     
    265267int SetColorScale3D_CC (Graphic *graphic, KapaImageWidget *image);
    266268int SetColorCubeHistogram (void);
     269int GetGraphBoundary (Section *section, double *x0, double *y0, double *x1, double *y1, int *dXm, int *dXp, int *dYm, int *dYp);
     270int ResizeByImage (int sock);
     271
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/include/structures.h

    r29539 r29815  
    148148  int IsMajor;
    149149  int IsLabel;
     150  int nsignif;
    150151} TickMarkData;
    151152
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/CheckPipe.c

    r29783 r29815  
    137137  }
    138138
     139  if (!strcmp (word, "ISIZ")) {
     140    status = ResizeByImage (sock);
     141    KiiSendCommand (sock, 4, "DONE");
     142    FINISHED (TRUE);
     143  }
     144 
    139145  if (!strcmp (word, "MOVE")) {
    140146    status = Relocate (sock);
     
    217223  if (!strcmp (word, "DSEC")) {
    218224    status = DefineSection (sock);
     225    KiiSendCommand (sock, 4, "DONE");
     226    FINISHED (TRUE);
     227  }
     228 
     229  if (!strcmp (word, "ISEC")) {
     230    status = DefineSectionByImage (sock);
    219231    KiiSendCommand (sock, 4, "DONE");
    220232    FINISHED (TRUE);
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/DefineSection.c

    r27790 r29815  
    4040  return (TRUE);
    4141}
     42
     43// define the section, but do not create a graph or image
     44int DefineSectionByImage (int sock) {
     45 
     46  int N, bg;
     47  char name[128];
     48  double x, y, dx, dy;
     49  int dXm, dXp, dYm, dYp;
     50  double x0, y0, x1, y1, expand;
     51  Section *section;
     52  Graphic *graphic;
     53  KapaImageWidget *image;
     54
     55  KiiScanMessage (sock, "%s %lf %lf %d", name, &x, &y, &bg);
     56
     57  N = GetSectionByName (name);
     58  section = GetSectionByNumber (N);
     59  image = section->image;
     60  if (!image) {
     61    fprintf (stderr, "no image to define section\n");
     62    return (TRUE);
     63  }
     64  SetActiveSectionByNumber (N);
     65
     66  graphic = GetGraphic ();
     67
     68  GetGraphBoundary (section, &x0, &y0, &x1, &y1, &dXm, &dXp, &dYm, &dYp);
     69
     70  expand = 1.0;
     71  if (image[0].picture.expand > 0) {
     72    expand = image[0].picture.expand;
     73  }
     74  if (image[0].picture.expand < 0) {
     75    expand = 1.0 / fabs((double)image[0].picture.expand);
     76  }
     77
     78  // pixel dimensions of the imaging region + boundary
     79  dx = image[0].image[0].matrix.Naxis[0]*expand + x1;
     80  dy = image[0].image[0].matrix.Naxis[1]*expand + y1;
     81
     82  section[0].x = x;
     83  section[0].y = y;
     84  section[0].bg = bg;
     85  section[0].dx = dx / graphic[0].dx;
     86  section[0].dy = dy / graphic[0].dy;
     87
     88  // if (section[0].x != x)   MoveSection = TRUE;
     89  // if (section[0].y != y)   MoveSection = TRUE;
     90  // if (section[0].dx != dx) MoveSection = TRUE;
     91  // if (section[0].dy != dy) MoveSection = TRUE;
     92
     93  SetSectionSizes (section);
     94  Refresh ();
     95
     96  return (TRUE);
     97}
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/DrawFrame.c

    r29539 r29815  
    55int DrawFrame (KapaGraphWidget *graph) {
    66 
    7   int i, j, Nticks, P;
    8   double fx, fy, dfx, dfy, lweight;
     7  int i, j, Nticks, P, doffset;
     8  double fx, fy, dfx, dfy, dx, dy, lweight;
    99  Graphic *graphic;
    1010  TickMarkData *ticks;
     
    1515  /* each axis is drawn independently, but ticks and labels are placed according to perpendicular distance. */
    1616  for (i = 0; i < 4; i++) {
    17     fx  = graph[0].axis[i].fx;
    18     fy  = graph[0].axis[i].fy;
    19     dfx = graph[0].axis[i].dfx;
    20     dfy = graph[0].axis[i].dfy;
    21     P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);
    22 
    2317    lweight = MAX (0, MIN (10, graph[0].axis[i].lweight));
    2418    color = MAX (0, MIN (15, graph[0].axis[i].color));
     19
     20    /* temporarily assume rectilinear axes */
     21    doffset = ((int)(lweight) % 2) ? 0.5*(lweight - 1) : 0.5*lweight;
     22    if (i == 0) { dx = doffset; dy = 0.0; }
     23    if (i == 2) { dx = doffset; dy = 0.0; }
     24    if (i == 1) { dx = 0.0; dy = doffset; }
     25    if (i == 3) { dx = 0.0; dy = doffset; }
     26
     27    fx  = graph[0].axis[i].fx - dx;
     28    fy  = graph[0].axis[i].fy - dy;
     29    dfx = graph[0].axis[i].dfx + 2*dx;
     30    dfy = graph[0].axis[i].dfy + 2*dy;
     31
     32    P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);
     33    P *= (1 + 0.25*lweight);
    2534
    2635    XSetLineAttributes (graphic->display, graphic->gc, lweight, LineSolid, CapNotLast, JoinMiter);
     
    4352}
    4453
    45 int PrintTick (char *string, double value, double min, double max) {
     54int PrintTick (char *string, double value, double min, double max, int nsignif) {
    4655
    4756  int Nexp = 0;
     
    5463  }
    5564
    56   double lvalue = log10(fabs(value));
    57 
    58   if (isfinite(lvalue)) {
    59     Nexp = fabs(lvalue);
    60   } else {
    61     Nexp = 0;
    62   }
    63  
     65//   double lvalue = log10(fabs(value));
     66//   if (isfinite(lvalue)) {
     67//     Nexp = fabs(lvalue);
     68//   } else {
     69//     Nexp = 0;
     70//   }
     71 
     72  Nexp = abs(nsignif);
     73
    6474  if (Nexp > 3) {
    6575    Nchar = sprintf (string, "%.1e", value);
    6676  } else {
    67     Nchar = sprintf (string, "%.1f", value);
     77    if (nsignif < 0) {
     78      char format[16];
     79      snprintf (format, 16, "%%.%df", -1 * nsignif);
     80      Nchar = sprintf (string, format, value);
     81    } else {
     82      Nchar = sprintf (string, "%.1f", value);
     83    }
    6884  }
    6985  return Nchar;
     
    129145    yt = fy + (value-min)*dfy/(max - min) + dy;
    130146
    131     PrintTick (string, value, min, max);
     147    PrintTick (string, value, min, max, tick->nsignif);
    132148    DrawRotText (xt, yt, string, pos, 0.0);
    133149  }
     
    136152# define MIN_RANGE 1e-10
    137153
    138 void AxisTickScale (Axis *axis, double *major, double *minor) {
     154void AxisTickScale (Axis *axis, double *major, double *minor, int *nsignif) {
    139155
    140156  double range, lrange, factor, mantis, fmantis, power;
     
    152168  }
    153169 
     170  // how many significant digits are needed?
     171
    154172  power = MAX(pow(10.0, factor), MIN_RANGE);
    155173  fmantis = pow(10.0, mantis);
     
    160178    *major = 0.5 * power;
    161179    *minor = 0.1 * power;
     180    *nsignif = factor - 1;
    162181    if (axis[0].areticks == 1) {
    163182      *major = 0.25 * power;
    164183      *minor = 0.05 * power;
     184      *nsignif = factor - 2;
    165185    }     
    166186  }
     
    168188    *major = 1.0 * power;
    169189    *minor = 0.2 * power;
     190    *nsignif = factor;
    170191    if (axis[0].areticks == 1) {
    171192      *major = 0.5 * power;
    172193      *minor = 0.1 * power;
     194      *nsignif = factor - 1;
    173195    }     
    174196  }
     
    176198    *major = 1.0 * power;
    177199    *minor = 0.5 * power;
     200    *nsignif = factor;
    178201    if (axis[0].areticks == 1) {
    179202      *major = 1.0 * power;
    180203      *minor = 0.2 * power;
     204      *nsignif = factor;
    181205    }     
    182206  }
     
    184208    *major = 2.0 * power;
    185209    *minor = 0.5 * power;
     210    *nsignif = factor;
    186211    if (axis[0].areticks == 1) {
    187212      *major = 1.0 * power;
    188213      *minor = 0.5 * power;
     214      *nsignif = factor;
    189215    }     
    190216  }
     
    192218    *major = 2.5 * power;
    193219    *minor = 0.5 * power;
     220      *nsignif = factor - 1;
    194221    if (axis[0].areticks == 1) {
    195222      *major = 2.0 * power;
    196223      *minor = 0.5 * power;
     224      *nsignif = factor;
    197225    }     
    198226  }
     
    203231  TickMarkData *ticks;
    204232  double range, major, minor, first, value, dPixels, overshoot;
    205   int i, NTICKS, nPixels, done, ifirst;
     233  int i, NTICKS, nPixels, done, ifirst, nsignif;
    206234
    207235  *nticks = 0;
     
    223251  dPixels = nPixels / range; // axis pixel-scale
    224252
    225   AxisTickScale (axis, &major, &minor);
     253  AxisTickScale (axis, &major, &minor, &nsignif);
    226254
    227255  // be a little generous
     
    256284    ticks[i].IsLabel = (ticks[i].IsMajor && axis->islabel);
    257285    ticks[i].value = value;
     286    ticks[i].nsignif = nsignif;
    258287    if (range > 0)
    259288      value += minor;
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/JPEGit24.c

    r29783 r29815  
    202202    palette = KapaPNGPalette (&Npalette);
    203203
    204     buffer = bDrawBufferCreate (dx, dy);
    205     bDrawSetBuffer (buffer);
     204    buffer = bDrawBufferCreate (dx, dy, 1, palette, Npalette);
    206205    for (i = 0; i < NOVERLAYS; i++) {
    207       if (image[0].overlay[i].active) bDrawOverlay (image, i);
     206      if (image[0].overlay[i].active) bDrawOverlay (buffer, image, i);
    208207    }
    209208
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/PNGit.c

    r29783 r29815  
    66   3) decision on output based on the existence of images or not
    77*/
    8 
    9 bDrawBuffer *bDrawBufferCreate8bitRGB (int Nx, int Ny);
    10 int bDrawImage (bDrawBuffer *buffer, Graphic *graphic);
    118
    129int PNGcommand (int sock) {
     
    2522  png_structp png_ptr;
    2623  png_infop info_ptr;
    27   int status, Npalette;
     24  int i, status, Npalette, Nsection;
    2825  bDrawBuffer *buffer = NULL;
    2926  Graphic *graphic = NULL;
    3027  png_color *palette = NULL;
     28  Section *section;
    3129
    3230  graphic = GetGraphic();
     
    6866  png_init_io (png_ptr, f);
    6967
     68  palette = KapaPNGPalette (&Npalette);
     69
     70  // do we have an image in any of the sections?
     71  Nsection = GetNumberOfSections ();
     72  int haveImage = FALSE;
     73  for (i = 0; !haveImage && (i < Nsection); i++) {
     74    section = GetSectionByNumber (i);
     75    haveImage = (section->image != NULL);
     76  }
     77
    7078  /* see docs for write-row-callback to provide progress info */
    71 # define PALETTE 1
    72   if (PALETTE) {
    73     png_set_IHDR (png_ptr, info_ptr, graphic->dx, graphic->dy, 8, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
    74     palette = KapaPNGPalette (&Npalette);
    75     png_set_PLTE (png_ptr, info_ptr, palette, Npalette);
    76   } else {
     79  if (haveImage) {
    7780    // png_set_IHDR (png_ptr, info_ptr, graphic->dx, graphic->dy, 16, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
    7881    png_set_IHDR (png_ptr, info_ptr, graphic->dx, graphic->dy, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
    7982    png_set_sRGB (png_ptr, info_ptr, PNG_sRGB_INTENT_ABSOLUTE);
     83  } else {
     84    png_set_IHDR (png_ptr, info_ptr, graphic->dx, graphic->dy, 8, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
     85    png_set_PLTE (png_ptr, info_ptr, palette, Npalette);
    8086  }
    8187
     
    8793  png_write_info (png_ptr, info_ptr);
    8894
    89   if (PALETTE) {
    90     buffer = bDrawIt ();
     95  if (haveImage) {
     96    buffer = bDrawIt (palette, Npalette, 3);
     97    // bDrawImage (buffer, graphic);
    9198  } else {
    92     buffer = bDrawBufferCreate8bitRGB(graphic->dx, graphic->dy);
    93     bDrawImage (buffer, graphic);
     99    buffer = bDrawIt (palette, Npalette, 1);
    94100  }
    95101
     
    99105 
    100106  bDrawBufferFree (buffer);
    101   free (palette);
    102107  fclose (f);
    103108  return (TRUE);
    104109
    105110}
    106 
    107 /* For color images, I need to define the relationship between the drawing colors and the RGB values? */
    108 
    109 
    110 bDrawBuffer *bDrawBufferCreate8bitRGB (int Nx, int Ny) {
    111 
    112   int i, j;
    113   bDrawBuffer *buffer;
    114 
    115   ALLOCATE (buffer, bDrawBuffer, 1);
    116   buffer[0].Nx = Nx;
    117   buffer[0].Ny = Ny;
    118 
    119   ALLOCATE (buffer[0].pixels, bDrawColor *, Ny);
    120   for (i = 0; i < Ny; i++) {
    121     ALLOCATE (buffer[0].pixels[i], bDrawColor, 3*Nx);
    122     for (j = 0; j < 3*Nx; j+=3) {
    123       buffer[0].pixels[i][j+0] = 0xff;
    124       buffer[0].pixels[i][j+1] = 0xff;
    125       buffer[0].pixels[i][j+2] = 0xff;
    126     }
    127   }
    128   return (buffer);
    129 }
    130 
    131 # define WHITE_R 255
    132 # define WHITE_G 255
    133 # define WHITE_B 255
    134 # define MY_SWAP_INT(A,B) { int tmp; tmp = A; A = B; B = tmp; }
    135 
    136 int bDrawImage (bDrawBuffer *buffer, Graphic *graphic) {
    137  
    138   Section *section;
    139   KapaImageWidget *image;
    140 
    141   int ii, i, j;
    142   int i_start, i_end, j_start, j_end;
    143   int I_start, J_start;
    144   int dropback;  /* this is a bit of a kludge... */
    145   int dx, dy, DX, DY, inDX, inDY;
    146   int expand_in, expand_out;
    147   double expand, Ix, Iy;
    148   unsigned char *out_pix;
    149   unsigned short *in_pix, *in_pix_ref;
    150   unsigned char *pixel1, *pixel2, *pixel3;
    151 
    152   bDrawColor *line_buffer;
    153 
    154   section = GetActiveSection();
    155   image   = section->image;
    156   if (image == NULL) return (TRUE);
    157 
    158   ALLOCATE (pixel1, unsigned char, graphic[0].Npixels);
    159   ALLOCATE (pixel2, unsigned char, graphic[0].Npixels);
    160   ALLOCATE (pixel3, unsigned char, graphic[0].Npixels);
    161 
    162   /** cmap[i].pixel must be defined even if X is not used **/
    163   for (i = 0; i < graphic[0].Npixels; i++) { /* set up pixel array */
    164     pixel1[i] = graphic[0].cmap[i].red >> 8;
    165     pixel2[i] = graphic[0].cmap[i].green >> 8;
    166     pixel3[i] = graphic[0].cmap[i].blue >> 8;
    167   }
    168 
    169   assert ((image[0].picture.expand >= 1) || (image[0].picture.expand <= -2));
    170   expand = expand_in = expand_out = 1.0;
    171   if (image[0].picture.expand > 0) {
    172     expand = 1 / (1.0*image[0].picture.expand);
    173     expand_out = image[0].picture.expand;
    174     expand_in  = 1;
    175   }
    176   if (image[0].picture.expand < 0) {
    177     expand = fabs((double)image[0].picture.expand);
    178     expand_out = 1;
    179     expand_in  = -image[0].picture.expand;
    180   }
    181 
    182   dx = image[0].picture.dx;
    183   dy = image[0].picture.dy;
    184   DX = image[0].image[0].matrix.Naxis[0];
    185   DY = image[0].image[0].matrix.Naxis[1];
    186 
    187   // i_start, j_start are the closest lit screen pixel to 0,0
    188   // I_start, J_start are the image pixel corresponding to i_start, j_start
    189   Picture_Lower (&i_start, &j_start, &I_start, &J_start, &image[0].image[0].matrix, &image[0].picture);
    190 
    191   // i_end, j_end are the closest lit screen pixel to dx, dy
    192   // I_end, J_end are the image pixel corresponding to i_end, j_end
    193   Picture_Upper (&i_end, &j_end, i_start, j_start, &image[0].image[0].matrix, &image[0].picture);
    194 
    195   assert (i_start <= i_end);
    196   assert (j_start <= j_end);
    197 
    198   Ix = image[0].picture.flipx ? I_start - 1 : I_start;
    199   Iy = image[0].picture.flipy ? J_start - 1 : J_start;
    200 
    201   inDX = image[0].picture.flipx ? -1 : +1;
    202   inDY = image[0].picture.flipy ? -1 : +1;
    203 
    204   dropback = expand_out - (i_end - i_start) % expand_out;
    205   if ((i_end - i_start) % expand_out == 0) dropback = 0;
    206 
    207   ALLOCATE (line_buffer, bDrawColor, 3*dx);
    208 
    209   in_pix_ref  = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)];
    210 
    211   /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
    212 
    213   /**** fill in bottom area ****/
    214   out_pix = line_buffer;
    215   for (i = 0; i < dx; i++, out_pix+=3) {
    216     out_pix[0] = WHITE_R;
    217     out_pix[1] = WHITE_G;
    218     out_pix[2] = WHITE_B;
    219   }
    220   for (j = 0; j < j_start; j++) {
    221     memcpy (buffer[0].pixels[j], line_buffer, 3*dx);
    222   }
    223  
    224   /*** fill in the image data region ***/
    225   for (j = j_start; j < j_end; j+= expand_out, in_pix_ref += inDY*expand_in*DX) {
    226    
    227     /* create one output image line */
    228     in_pix = in_pix_ref;
    229     out_pix = line_buffer;
    230 
    231     /**** fill in area to the left of the picture ****/
    232     for (i = 0; i < i_start; i++, out_pix+=3) {
    233       out_pix[0] = WHITE_R;
    234       out_pix[1] = WHITE_G;
    235       out_pix[2] = WHITE_B;
    236     }
    237    
    238     /*** fill in the picture region ***/
    239     for (i = i_start; i < i_end; i+=expand_out, in_pix += inDX*expand_in) {
    240       for (ii = 0; ii < expand_out; ii++, out_pix+=3) {
    241         out_pix[0] = pixel1[*in_pix];
    242         out_pix[1] = pixel2[*in_pix];
    243         out_pix[2] = pixel3[*in_pix];
    244       }
    245     }
    246    
    247     /**** fill in area to the right of the picture ****/
    248     for (i = i_end; i < dx; i++, out_pix+=3) {
    249       out_pix[0] = WHITE_R;
    250       out_pix[1] = WHITE_G;
    251       out_pix[2] = WHITE_B;
    252     }
    253 
    254     /* write out the image line expand_out times */
    255     for (i = 0; i < expand_out; i++) {
    256       memcpy (buffer[0].pixels[j + i], line_buffer, 3*dx);
    257     }
    258   }
    259 
    260   /**** fill in top area ****/
    261   out_pix = line_buffer;
    262   for (i = 0; i < dx; i++, out_pix+=3) {
    263     out_pix[0] = WHITE_R;
    264     out_pix[1] = WHITE_G;
    265     out_pix[2] = WHITE_B;
    266   }
    267   for (j = j_end; j < dy; j++) {
    268     memcpy (buffer[0].pixels[j], line_buffer, 3*dx);
    269   }
    270 
    271   free (pixel1);
    272   free (pixel2);
    273   free (pixel3);
    274   free (line_buffer);
    275 
    276   return (TRUE);
    277 }
    278 
    279 # if (0)
    280 
    281   /* I need to write the overlay objects on the jpeg image.
    282      if i can write / overwrite data in jpeg buffer, then do it here,
    283      otherwise i need to create a temporary image buffer, then write the
    284      scanlines to that buffer */
    285 
    286   {
    287     int Npalette;
    288     png_color *palette;
    289     bDrawColor white, color;
    290     bDrawBuffer *buffer;
    291 
    292     palette = KapaPNGPalette (&Npalette);
    293 
    294     buffer = bDrawBufferCreate (dx, dy);
    295     bDrawSetBuffer (buffer);
    296     for (i = 0; i < NOVERLAYS; i++) {
    297       if (image[i].overlay[i].active) bDrawOverlay (image, i);
    298     }
    299 
    300     white = KapaColorByName ("white");
    301     for (j = 0; j < dy; j++) {
    302       for (i = 0; i < dx; i++) {
    303         color = buffer[0].pixels[j][i];
    304         if (color == white) continue;
    305         image_buffer[j*3*dx + 3*i + 0] = palette[color].red;
    306         image_buffer[j*3*dx + 3*i + 1] = palette[color].green;
    307         image_buffer[j*3*dx + 3*i + 2] = palette[color].blue;
    308       }
    309     }
    310     bDrawBufferFree (buffer);
    311   }
    312 
    313 # endif
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/PPMit.c

    r27435 r29815  
    3030  fprintf (f, "255\n");
    3131
    32   buffer = bDrawIt ();
     32  buffer = bDrawIt (palette, Npalette, 1);
    3333
    3434  ALLOCATE (line, char, 3*dx);
     
    4747  bDrawBufferFree (buffer);
    4848  return (TRUE);
    49 
    5049}
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/PSFrame.c

    r29539 r29815  
    44int PSFrame (KapaGraphWidget *graph, FILE *f) {
    55 
    6   int i, j, Nticks, P;
    7   double fx, fy, dfx, dfy, lweight;
     6  int i, j, Nticks, P, doffset;
     7  double fx, fy, dfx, dfy, dx, dy, lweight;
    88  Graphic *graphic;
    99  TickMarkData *ticks;
     
    1515  fprintf (f, "1 setlinewidth\n");
    1616  for (i = 0; i < 4; i++) {
    17     fx  = graph[0].axis[i].fx;
    18     fy  = graphic->dy - graph[0].axis[i].fy;
    19     dfx = graph[0].axis[i].dfx;
    20     dfy = -graph[0].axis[i].dfy;
    21     P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);
    22 
    2317    lweight = MAX (0, MIN (10, graph[0].axis[i].lweight));
    2418    color = MAX (0, MIN (15, graph[0].axis[i].color));
     19
     20    /* temporarily assume rectilinear axes */
     21    doffset = ((int)(lweight) % 2) ? 0.5*(lweight - 1) : 0.5*lweight;
     22    if (i == 0) { dx = doffset; dy = 0.0; }
     23    if (i == 2) { dx = doffset; dy = 0.0; }
     24    if (i == 1) { dx = 0.0; dy = doffset; }
     25    if (i == 3) { dx = 0.0; dy = doffset; }
     26
     27    fx  = graph[0].axis[i].fx - dx;
     28    fy  = graphic->dy - graph[0].axis[i].fy - dy;
     29    dfx = graph[0].axis[i].dfx + 2*dx;
     30    dfy = -graph[0].axis[i].dfy + 2*dy;
     31
     32    P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);
     33    P *= (1 + 0.25*lweight);
    2534
    2635    fprintf (f, "%.1f setlinewidth\n", lweight);
     
    95104    yt = fy + (value-min)*dfy/(max - min) + dy;
    96105
    97     PrintTick (string, value, min, max);
     106    PrintTick (string, value, min, max, tick->nsignif);
    98107    PSRotText (f, xt, yt, string, pos, 0.0);
    99108  }
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/PSimage.c

    r14913 r29815  
    1313  graphic = GetGraphic();
    1414
    15   fprintf (f, " newpath 0 0 moveto %d 0 lineto %d %d lineto 0 %d lineto closepath clip\n\n",
    16            image[0].picture.dx, image[0].picture.dx, image[0].picture.dy, image[0].picture.dy);
     15  fprintf (f, " newpath %d %d moveto %d %d lineto %d %d lineto %d %d lineto closepath\n\n",
     16           (int) image[0].picture.x,                       graphic->dy - (int) image[0].picture.y,
     17           (int) image[0].picture.x + image[0].picture.dx, graphic->dy - (int) image[0].picture.y,
     18           (int) image[0].picture.x + image[0].picture.dx, graphic->dy - (int) image[0].picture.y - image[0].picture.dy,
     19           (int) image[0].picture.x,                       graphic->dy - (int) image[0].picture.y - image[0].picture.dy);
    1720  fprintf (f, "gsave %% encloses image\n");
     21  fprintf (f, "%d %d translate\n", (int) image[0].picture.x, graphic->dy - (int) image[0].picture.y - image[0].picture.dy);
    1822  fprintf (f, "%d %d 8\n", image[0].picture.dx, image[0].picture.dy);
    1923  fprintf (f, "[1 0 0 1 0 0]\n");
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/PSit.c

    r13479 r29815  
    8787  for (i = 0; i < Nsection; i++) {
    8888    section = GetSectionByNumber (i);
     89    if (section->image) {
     90      PSimage (section->image, f);
     91    }
    8992    if (section->graph) {
    9093      PSFrame (section->graph, f);
     
    9295      PSLabels (section->graph, f);
    9396      PSTextlines (section->graph, f);
    94     }
    95     if (section->image) {
    96       PSimage (section->image, f);
    9797    }
    9898  }
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/Resize.c

    r26891 r29815  
    3939  return (TRUE);
    4040}
     41
     42// resise the window so the image in the currently active window fills its section
     43int ResizeByImage (int sock) {
     44 
     45  int i, Nsection;
     46  unsigned int NX, NY;
     47  double dx, dy;
     48  int dXm, dXp, dYm, dYp;
     49  double x0, y0, x1, y1, expand;
     50  Section *section;
     51  Graphic *graphic;
     52  KapaImageWidget *image;
     53
     54  graphic = GetGraphic();
     55
     56  section = GetActiveSection();
     57
     58  image = section->image;
     59  if (!image) {
     60    fprintf (stderr, "no image to define size\n");
     61    return (TRUE);
     62  }
     63
     64  GetGraphBoundary (section, &x0, &y0, &x1, &y1, &dXm, &dXp, &dYm, &dYp);
     65
     66  expand = 1.0;
     67  if (image[0].picture.expand > 0) {
     68    expand = image[0].picture.expand;
     69  }
     70  if (image[0].picture.expand < 0) {
     71    expand = 1.0 / fabs((double)image[0].picture.expand);
     72  }
     73
     74  // pixel dimensions of the imaging region + boundary
     75  dx = image[0].image[0].matrix.Naxis[0]*expand + x1;
     76  dy = image[0].image[0].matrix.Naxis[1]*expand + y1;
     77
     78  NX = dx / section[0].dx;
     79  NY = dy / section[0].dy;
     80
     81  NX = MAX(NX, MIN_WIDTH);
     82  NY = MAX(NY, MIN_HEIGHT);
     83
     84  // if the new size is the same as the old size, do nothing.
     85  if ((graphic->dx == NX) && (graphic->dy == NY)) return (TRUE);
     86
     87  // set the new window size
     88  graphic->dx = NX;
     89  graphic->dy = NY;
     90
     91  if (USE_XWINDOW) XResizeWindow (graphic->display, graphic->window, NX, NY);
     92
     93  // reset the sizes for all sections
     94  Nsection = GetNumberOfSections ();
     95  for (i = 0; i < Nsection; i++) {
     96      section = GetSectionByNumber (i);
     97      SetSectionSizes (section);
     98  }
     99
     100  if (USE_XWINDOW) XClearWindow (graphic->display, graphic->window);
     101  Refresh ();
     102
     103  return (TRUE);
     104}
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/SetGraphSize.c

    r29539 r29815  
    55
    66void SetGraphSize (Section *section) {
     7
     8  int dXm, dXp, dYm, dYp;
     9  double x0, y0, x1, y1;
     10  KapaGraphWidget *graph;
     11  Graphic *graphic;
     12
     13  GetGraphBoundary(section, &x0, &y0, &x1, &y1, &dXm, &dXp, &dYm, &dYp);
     14
     15  if (section == NULL) return;
     16  graph = section->graph;
     17  if (graph == NULL) return;
     18
     19  graphic = GetGraphic ();
     20
     21  double X0 = graphic[0].dx * section[0].x  + x0;
     22  double Y0 = graphic[0].dy * section[0].y  + y0;
     23  double dX = graphic[0].dx * section[0].dx - x1;
     24  double dY = graphic[0].dy * section[0].dy - y1;
     25
     26  /* define locations of coordinate axes */
     27  graph[0].axis[0].fx  = X0;
     28  graph[0].axis[0].fy  = graphic->dy - Y0;
     29  graph[0].axis[0].dfx = dX;
     30  graph[0].axis[0].dfy = 0;
     31
     32  graph[0].axis[1].fx  = X0;
     33  graph[0].axis[1].fy  = graphic->dy - Y0;
     34  graph[0].axis[1].dfx = 0;
     35  graph[0].axis[1].dfy = -dY;
     36
     37  graph[0].axis[2].fx  = X0;
     38  graph[0].axis[2].fy  = graphic->dy - Y0 - dY;
     39  graph[0].axis[2].dfx = dX;
     40  graph[0].axis[2].dfy = 0;
     41
     42  graph[0].axis[3].fx  = X0 + dX;
     43  graph[0].axis[3].fy  = graphic->dy - Y0;
     44  graph[0].axis[3].dfx = 0;
     45  graph[0].axis[3].dfy = -dY;
     46
     47  /* define locations of axis labels */
     48  graph[0].label[LABELLL].x = graph[0].axis[0].fx;
     49  graph[0].label[LABELLL].y = graph[0].axis[0].fy + dXm;
     50  graph[0].label[LABELX0].x = graph[0].axis[0].fx + 0.5*graph[0].axis[0].dfx;
     51  graph[0].label[LABELX0].y = graph[0].axis[0].fy + dXm;
     52  graph[0].label[LABELLR].x = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     53  graph[0].label[LABELLR].y = graph[0].axis[0].fy + dXm;
     54
     55  graph[0].label[LABELUL].x = graph[0].axis[2].fx;
     56  graph[0].label[LABELUL].y = graph[0].axis[2].fy - dXp;
     57  graph[0].label[LABELX1].x = graph[0].axis[2].fx + 0.5*graph[0].axis[2].dfx;
     58  graph[0].label[LABELX1].y = graph[0].axis[2].fy - dXp;
     59  graph[0].label[LABELUR].x = graph[0].axis[2].fx + graph[0].axis[2].dfx;
     60  graph[0].label[LABELUR].y = graph[0].axis[2].fy - dXp;
     61
     62  graph[0].label[LABELY0].y = graph[0].axis[1].fy + 0.5*graph[0].axis[1].dfy;
     63  graph[0].label[LABELY0].x = graph[0].axis[1].fx - dYm;
     64
     65  graph[0].label[LABELY1].y = graph[0].axis[3].fy + 0.5*graph[0].axis[3].dfy;
     66  graph[0].label[LABELY1].x = graph[0].axis[3].fx + dYp;
     67
     68  return;
     69}
     70
     71int GetGraphBoundary (Section *section, double *x0, double *y0, double *x1, double *y1, int *dXm, int *dXp, int *dYm, int *dYp) {
    772
    873  int i, Nticks;
    974  int fontsize, Nc = 0;
    1075  int textpad, textdY, WdY;
    11   int dXm, dXp, dYm, dYp;
    1276  double padXm, padXp, padYm, padYp;
    1377  double minPADx, maxPADx, minPADy;
    1478  double minPAD, maxPAD;
    15   double X0, Y0, dX, dY;
    1679  char string[64], *fontname;
    1780  KapaGraphWidget *graph;
     
    1982  TickMarkData *ticks;
    2083
    21   if (section == NULL) return;
     84  *x0 = 0.0;
     85  *y0 = 0.0;
     86  *x1 = 0.0;
     87  *y1 = 0.0;
     88
     89  *dXm = 0;
     90  *dXp = 0;
     91  *dYm = 0;
     92  *dYp = 0;
     93
     94  if (section == NULL) return FALSE;
    2295  graph = section->graph;
    23   if (graph == NULL) return;
     96  if (graph == NULL) return FALSE;
    2497
    2598  graphic = GetGraphic ();
     
    40113  // these depend on (a) existence of tick labels and (b) auto-offset or not
    41114  if (isnan(graph[0].axis[0].labelPad)) {
    42     dXm = (graph[0].axis[0].islabel) ? maxPAD  : minPAD;
    43   } else {
    44     dXm = graph[0].axis[0].labelPad * fontsize;
     115    *dXm = (graph[0].axis[0].islabel) ? maxPAD  : minPAD;
     116  } else {
     117    *dXm = graph[0].axis[0].labelPad * fontsize;
    45118  }
    46119  if (isnan(graph[0].axis[0].pad)) {
     
    53126  // these depend on (a) existence of tick labels and (b) auto-offset or not
    54127  if (isnan(graph[0].axis[2].labelPad)) {
    55     dXp = (graph[0].axis[2].islabel) ? maxPAD : minPAD;
    56   } else {
    57     dXp = graph[0].axis[2].labelPad * fontsize;
     128    *dXp = (graph[0].axis[2].islabel) ? maxPAD : minPAD;
     129  } else {
     130    *dXp = graph[0].axis[2].labelPad * fontsize;
    58131  }
    59132  if (isnan(graph[0].axis[2].pad)) {
     
    73146      if (!ticks[i].IsMajor) continue;
    74147
    75       int Nchar = PrintTick (string, ticks[i].value, graph[0].axis[1].min, graph[0].axis[1].max);
     148      int Nchar = PrintTick (string, ticks[i].value, graph[0].axis[1].min, graph[0].axis[1].max, ticks[i].nsignif);
    76149
    77150      Nc = MAX (Nc, Nchar);
     
    80153  }
    81154  if (isnan(graph[0].axis[1].labelPad)) {
    82     dYm = (graph[0].axis[1].islabel) ? (0.7*(Nc + 1.5)*fontsize) : minPAD;
    83   } else {
    84     dYm = graph[0].axis[1].labelPad * fontsize;
     155    *dYm = (graph[0].axis[1].islabel) ? (0.7*(Nc + 1.5)*fontsize) : minPAD;
     156  } else {
     157    *dYm = graph[0].axis[1].labelPad * fontsize;
    85158  }
    86159  if (isnan(graph[0].axis[1].pad)) {
     
    98171    for (i = 0; i < Nticks; i++) {
    99172      if (!ticks[i].IsMajor) continue;
    100       int Nchar = PrintTick (string, ticks[i].value, graph[0].axis[3].min, graph[0].axis[3].max);
     173      int Nchar = PrintTick (string, ticks[i].value, graph[0].axis[3].min, graph[0].axis[3].max, ticks[i].nsignif);
    101174      Nc = MAX (Nc, Nchar);
    102175    }
     
    104177  }
    105178  if (isnan(graph[0].axis[3].labelPad)) {
    106     dYp = (graph[0].axis[3].islabel) ? (0.7*(Nc + 1.5)*fontsize) : minPAD;
    107   } else {
    108     dYp = graph[0].axis[3].labelPad * fontsize;
     179    *dYp = (graph[0].axis[3].islabel) ? (0.7*(Nc + 1.5)*fontsize) : minPAD;
     180  } else {
     181    *dYp = graph[0].axis[3].labelPad * fontsize;
    109182  }
    110183  if (isnan(graph[0].axis[3].pad)) {
     
    115188
    116189  /* basic size of the graph in Xwindow coordinates, but measured from lower-left corner */
    117   X0 = graphic[0].dx * section[0].x + padYm;
    118   Y0 = graphic[0].dy * section[0].y + padXm;
    119   dX = graphic[0].dx * section[0].dx - padYm - padYp;
    120   dY = graphic[0].dy * section[0].dy - padXm - padXp;
     190  *x0 = padYm;
     191  *y0 = padXm;
     192  *x1 = padYm + padYp;
     193  *y1 = padXm + padXp;
    121194
    122195  // if we are tied to an image, make mods as needed
     
    128201    switch (section->image->location) {
    129202      case 0:
    130         // no changes?
    131203        break;
    132204      case 1:
    133         Y0 = graphic[0].dy * section[0].y  + padXm        + 2*PAD1 + WdY + 2;
    134         dY = graphic[0].dy * section[0].dy - padXm - padXp - 4*PAD1 - 1 - WdY - COLORPAD;
     205        *y0 = padXm + 2*PAD1 + WdY + 2;
     206        *y1 = padXm + padXp + 4*PAD1 + 1 + WdY + COLORPAD;
    135207        break;
    136208      case 3:
    137         dY = graphic[0].dy * section[0].dy - padXm - padXp - 4*PAD1 - 1 - WdY - COLORPAD;
     209        *y1 = padXm + padXp + 4*PAD1 + 1 + WdY + COLORPAD;
    138210        break;
    139211      case 2:
    140         X0 = graphic[0].dx * section[0].x  + padYm        + 2*PAD1 + ZOOM_X;
    141         dX = graphic[0].dx * section[0].dx - padYm - padYp - 3*PAD1 - ZOOM_X;
    142         dY = graphic[0].dy * section[0].dy - padXm - padXp - 2*PAD1 - COLORPAD;
     212        *x0 = padYm + 2*PAD1 + ZOOM_X;
     213        *x1 = padYm + padYp + 3*PAD1 + ZOOM_X;
     214        *y1 = padXm + padXp + 2*PAD1 + COLORPAD;
    143215        break;
    144216      case 4:
    145         dX = graphic[0].dx * section[0].dx - padYm - padYp - 3*PAD1 - ZOOM_X;
    146         dY = graphic[0].dy * section[0].dy - padXm - padXp - 2*PAD1 - COLORPAD;
     217        *x1 = padYm + padYp + 3*PAD1 + ZOOM_X;
     218        *y1 = padXm + padXp + 2*PAD1 + COLORPAD;
    147219        break;
    148220    }
    149221  }
    150222
    151   /* define locations of coordinate axes */
    152   graph[0].axis[0].fx  = X0;
    153   graph[0].axis[0].fy  = graphic->dy - Y0;
    154   graph[0].axis[0].dfx = dX;
    155   graph[0].axis[0].dfy = 0;
    156 
    157   graph[0].axis[1].fx  = X0;
    158   graph[0].axis[1].fy  = graphic->dy - Y0;
    159   graph[0].axis[1].dfx = 0;
    160   graph[0].axis[1].dfy = -dY;
    161 
    162   graph[0].axis[2].fx  = X0;
    163   graph[0].axis[2].fy  = graphic->dy - Y0 - dY;
    164   graph[0].axis[2].dfx = dX;
    165   graph[0].axis[2].dfy = 0;
    166 
    167   graph[0].axis[3].fx  = X0 + dX;
    168   graph[0].axis[3].fy  = graphic->dy - Y0;
    169   graph[0].axis[3].dfx = 0;
    170   graph[0].axis[3].dfy = -dY;
    171 
    172   /* define locations of axis labels */
    173   graph[0].label[LABELLL].x = graph[0].axis[0].fx;
    174   graph[0].label[LABELLL].y = graph[0].axis[0].fy + dXm;
    175   graph[0].label[LABELX0].x = graph[0].axis[0].fx + 0.5*graph[0].axis[0].dfx;
    176   graph[0].label[LABELX0].y = graph[0].axis[0].fy + dXm;
    177   graph[0].label[LABELLR].x = graph[0].axis[0].fx + graph[0].axis[0].dfx;
    178   graph[0].label[LABELLR].y = graph[0].axis[0].fy + dXm;
    179 
    180   graph[0].label[LABELUL].x = graph[0].axis[2].fx;
    181   graph[0].label[LABELUL].y = graph[0].axis[2].fy - dXp;
    182   graph[0].label[LABELX1].x = graph[0].axis[2].fx + 0.5*graph[0].axis[2].dfx;
    183   graph[0].label[LABELX1].y = graph[0].axis[2].fy - dXp;
    184   graph[0].label[LABELUR].x = graph[0].axis[2].fx + graph[0].axis[2].dfx;
    185   graph[0].label[LABELUR].y = graph[0].axis[2].fy - dXp;
    186 
    187   graph[0].label[LABELY0].y = graph[0].axis[1].fy + 0.5*graph[0].axis[1].dfy;
    188   graph[0].label[LABELY0].x = graph[0].axis[1].fx - dYm;
    189 
    190   graph[0].label[LABELY1].y = graph[0].axis[3].fy + 0.5*graph[0].axis[3].dfy;
    191   graph[0].label[LABELY1].x = graph[0].axis[3].fx + dYp;
    192 
    193   // fprintf (stderr, "section %s, %f,%f : %f,%f\n", section->name, X0, Y0, dX, dY);
    194 
    195   /* these are wrong and have to be adjusted to sit in the corners */
    196 
     223  return (TRUE);
    197224}
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/bDrawFrame.c

    r29539 r29815  
    22// bDrawLine is a function, not a macro like DrawLine
    33
    4 int bDrawFrame (KapaGraphWidget *graph) {
     4int bDrawFrame (bDrawBuffer *buffer, KapaGraphWidget *graph) {
    55 
    6   int i, j, Nticks, P;
    7   double fx, fy, dfx, dfy, lweight;
     6  int i, j, Nticks, P, doffset;
     7  double fx, fy, dfx, dfy, lweight, dx, dy;
    88  // Graphic graphic; is not needed
    99  TickMarkData *ticks;
     
    1414  /* each axis is drawn independently */
    1515  for (i = 0; i < 4; i++) {
    16     fx  = graph[0].axis[i].fx;
    17     fy  = graph[0].axis[i].fy;
    18     dfx = graph[0].axis[i].dfx;
    19     dfy = graph[0].axis[i].dfy;
    20     P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);
    21 
    2216    lweight = MAX (0, MIN (10, graph[0].axis[i].lweight));
    2317    color = MAX (0, MIN (15, graph[0].axis[i].color));
    2418
    25     bDrawSetStyle (color, lweight, 0);
    26     // function about sets solor and weight
     19    /* temporarily assume rectilinear axes */
     20    doffset = ((int)(lweight) % 2) ? 0.5*(lweight - 1) : 0.5*lweight;
     21    if (i == 0) { dx = doffset; dy = 0.0; }
     22    if (i == 2) { dx = doffset; dy = 0.0; }
     23    if (i == 1) { dx = 0.0; dy = doffset; }
     24    if (i == 3) { dx = 0.0; dy = doffset; }
     25
     26    fx  = graph[0].axis[i].fx - dx;
     27    fy  = graph[0].axis[i].fy - dy;
     28    dfx = graph[0].axis[i].dfx + 2*dx;
     29    dfy = graph[0].axis[i].dfy + 2*dy;
     30    P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);
     31    P *= (1 + 0.25*lweight);
     32
     33    bDrawSetStyle (buffer, color, lweight, 0);
     34    // function about sets color and weight
    2735    // bDrawRotTextInit does not exist
    2836
    2937    if (graph[0].axis[i].isaxis) {
    30       bDrawLine (fx, fy, fx+dfx, fy+dfy);
     38      bDrawLine (buffer, fx, fy, fx+dfx, fy+dfy);
    3139    }
    3240   
     
    3442      ticks = CreateAxisTicks (&graph[0].axis[i], &Nticks);
    3543      for (j = 0; j < Nticks; j++) {
    36         bDrawTick (&graph[0].axis[i], P, &ticks[j], i);
     44        bDrawTick (buffer, &graph[0].axis[i], P, &ticks[j], i);
     45
     46        // XXX DrawTick sets the style to (color, 0, 0) for the font
     47        // should the font weight stay the same?
     48        // XXX probably not needed now:
     49        // bDrawSetStyle (buffer, color, lweight, 0);
    3750      }
    3851      FREE (ticks);
     
    4255}
    4356
    44 void bDrawTick (Axis *axis, int P, TickMarkData *tick, int naxis) {
     57void bDrawTick (bDrawBuffer *buffer, Axis *axis, int P, TickMarkData *tick, int naxis) {
    4558 
    4659  double x, y, dx, dy;
     
    7588  dy = dir*size*dfx*n;
    7689 
    77   bDrawLine (x, y, x+dx, y+dy);
     90  bDrawLine (buffer, x, y, x+dx, y+dy);
    7891
    7992  if (tick->IsLabel) {
     
    94107    yt = fy + (value-min)*dfy/(max - min) + dy;
    95108
    96     PrintTick (string, value, min, max);
    97     bDrawRotText (xt, yt, string, pos, 0.0);
     109    PrintTick (string, value, min, max, tick->nsignif);
     110    bDrawRotText (buffer, xt, yt, string, pos, 0.0);
    98111  }
    99112}
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/bDrawIt.c

    r13479 r29815  
    11# include "Ximage.h"
    22
    3 bDrawBuffer *bDrawIt () {
     3bDrawBuffer *bDrawIt (png_color *palette, int Npalette, int Nbyte) {
    44
    55  int i, Nsection;
     
    1313  black = KapaColorByName ("black");
    1414
    15   buffer = bDrawBufferCreate (graphic->dx, graphic->dy);
    16   bDrawSetBuffer (buffer);
    17   bDrawSetStyle (black, 0, 0);
     15  buffer = bDrawBufferCreate (graphic->dx, graphic->dy, Nbyte, palette, Npalette);
     16  bDrawSetStyle (buffer, black, 0, 0);
    1817 
    1918  // reset the sizes for all sections
     
    2120  for (i = 0; i < Nsection; i++) {
    2221      section = GetSectionByNumber (i);
    23       bDrawGraph (section->graph);
    24       // bDrawImage (section->image);
     22      bDrawImage (buffer, section->image, graphic);
     23      bDrawGraph (buffer, section->graph);
    2524  }
    2625
     
    2827}
    2928
    30 void bDrawGraph (KapaGraphWidget *graph) {
     29void bDrawGraph (bDrawBuffer *buffer, KapaGraphWidget *graph) {
    3130  if (graph == NULL) return;
    32   bDrawFrame (graph);
    33   bDrawObjects (graph);
    34   bDrawLabels (graph);
    35   bDrawTextlines (graph);
     31  bDrawFrame (buffer, graph);
     32  bDrawObjects (buffer, graph);
     33  bDrawLabels (buffer, graph);
     34  bDrawTextlines (buffer, graph);
    3635}
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/bDrawLabels.c

    r13320 r29815  
    11# include "Ximage.h"
    22 
    3 void bDrawLabels (KapaGraphWidget *graph) {
     3void bDrawLabels (bDrawBuffer *buffer, KapaGraphWidget *graph) {
    44 
    55  int i, pos, x, y, size;
     
    2525      y = graph[0].label[i].y;
    2626      SetRotFont (graph[0].label[i].font, graph[0].label[i].size);
    27       bDrawRotText (x, y, graph[0].label[i].text, pos, angle);
     27      bDrawRotText (buffer, x, y, graph[0].label[i].text, pos, angle);
    2828    }
    2929  }
     
    3131}
    3232
    33 void bDrawTextlines (KapaGraphWidget *graph) {
     33void bDrawTextlines (bDrawBuffer *buffer, KapaGraphWidget *graph) {
    3434
    3535  int i, x, y, size;
     
    4444      y = graph[0].textline[i].y;
    4545      SetRotFont (graph[0].textline[i].font, graph[0].textline[i].size);
    46       bDrawRotText (x, y, graph[0].textline[i].text, 5, angle);
     46      bDrawRotText (buffer, x, y, graph[0].textline[i].text, 5, angle);
    4747    }
    4848  }
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/bDrawObjects.c

    r27530 r29815  
    11# include "Ximage.h"
    22
    3 # define DrawLine(X1,Y1,X2,Y2) (bDrawLine ((X1), (Y1), (X2), (Y2)))
    4 # define DrawCircle(X1,Y1,R) (bDrawCircle ((X1), (Y1), (R)))
    5 # define DrawRectangle(X,Y,dX,dY) (bDrawRectOpen ((X-0.5*dX), (Y-0.5*dY), (X+0.5*dX), (Y+0.5*dY)))
    6 # define FillRectangle(X,Y,dX,dY) (bDrawRectFill ((X-0.5*dX), (Y-0.5*dY), (X+0.5*dX), (Y+0.5*dY)))
    7 # define FillTriangle(X1,Y1,X2,Y2,X3,Y3) (bDrawTriFill ((X1), (Y1), (X2), (Y2), (X3), (Y3)))
    8 # define OpenTriangle(X1,Y1,X2,Y2,X3,Y3) (bDrawTriOpen ((X1), (Y1), (X2), (Y2), (X3), (Y3)))
     3# define DrawLine(BUF,X1,Y1,X2,Y2) (bDrawLine (BUF, (X1), (Y1), (X2), (Y2)))
     4# define DrawCircle(BUF,X1,Y1,R) (bDrawCircle (BUF, (X1), (Y1), (R)))
     5# define DrawRectangle(BUF,X,Y,dX,dY) (bDrawRectOpen (BUF, (X-0.5*dX), (Y-0.5*dY), (X+0.5*dX), (Y+0.5*dY)))
     6# define FillRectangle(BUF,X,Y,dX,dY) (bDrawRectFill (BUF, (X-0.5*dX), (Y-0.5*dY), (X+0.5*dX), (Y+0.5*dY)))
     7# define FillTriangle(BUF,X1,Y1,X2,Y2,X3,Y3) (bDrawTriFill (BUF, (X1), (Y1), (X2), (Y2), (X3), (Y3)))
     8# define OpenTriangle(BUF,X1,Y1,X2,Y2,X3,Y3) (bDrawTriOpen (BUF, (X1), (Y1), (X2), (Y2), (X3), (Y3)))
    99
    1010# define CONNECT 0
     
    1414static Graphic *graphic;
    1515
    16 int bDrawObjects (KapaGraphWidget *graph) {
     16int bDrawObjects (bDrawBuffer *buffer, KapaGraphWidget *graph) {
    1717 
    1818  int i;
     
    3030    type = graph[0].objects[i].ltype;   
    3131    color = graph[0].objects[i].color;
    32     bDrawSetStyle (color, weight, type);
     32    bDrawSetStyle (buffer, color, weight, type);
    3333
    3434    switch (graph[0].objects[i].style) {
    3535      case CONNECT:
    36         bDrawConnect (graph, &graph[0].objects[i]);
     36        bDrawConnect (buffer, graph, &graph[0].objects[i]);
    3737        break;
    3838      case HISTOGRAM:
    39         bDrawHistogram (graph, &graph[0].objects[i]);
     39        bDrawHistogram (buffer, graph, &graph[0].objects[i]);
    4040        break;
    4141      case POINTS:
    42         bDrawPoints (graph, &graph[0].objects[i]);
     42        bDrawPoints (buffer, graph, &graph[0].objects[i]);
    4343        break;
    4444    }
    4545
    4646    if (graph[0].objects[i].etype & 0x01) {
    47       bDrawYErrors (graph, &graph[0].objects[i]);
     47      bDrawYErrors (buffer, graph, &graph[0].objects[i]);
    4848    }
    4949    if (graph[0].objects[i].etype & 0x02) {
    50       bDrawXErrors (graph, &graph[0].objects[i]);
    51     }
    52   }
    53   bDrawSetStyle (black, 0, 0);
     50      bDrawXErrors (buffer, graph, &graph[0].objects[i]);
     51    }
     52  }
     53  bDrawSetStyle (buffer, black, 0, 0);
    5454  return (TRUE);
    5555}
    5656
    57 void bDrawConnect (KapaGraphWidget *graph, Gobjects *object) {
     57void bDrawConnect (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) {
    5858 
    5959  int i;
     
    9191    sx1 = x[i]*mxi + y[i]*mxj + bx;
    9292    sy1 = x[i]*myi + y[i]*myj + by;
    93     bDrawClipLine (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
     93    bDrawClipLine (buffer, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
    9494    sx0 = sx1; sy0 = sy1;
    9595  }
    9696}
    9797
    98 void bDrawClipLine (double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0) {
     98void bDrawClipLine (bDrawBuffer *buffer, double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0) {
    9999
    100100  /* skip line segement if both points are beyond box */
     
    145145    y1 = Y1;
    146146  }
    147   DrawLine (x0, y0, x1, y1);
     147  DrawLine (buffer, x0, y0, x1, y1);
    148148}
    149149
    150150/*******/
    151 void bDrawHistogram (KapaGraphWidget *graph, Gobjects *object) {
     151void bDrawHistogram (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) {
    152152
    153153  int i;
     
    192192    sy1 = MAX (MIN (sy1, Y0), Y1);
    193193    sxa = 0.5*(sx0 + sx1);
    194     DrawLine (sx0, sy0, sxa, sy0);
    195     DrawLine (sxa, sy0, sxa, sy1);
    196     DrawLine (sxa, sy1, sx1, sy1);
     194    DrawLine (buffer, sx0, sy0, sxa, sy0);
     195    DrawLine (buffer, sxa, sy0, sxa, sy1);
     196    DrawLine (buffer, sxa, sy1, sx1, sy1);
    197197    sx0 = sx1; sy0 = sy1;
    198198  }
     
    200200
    201201/*******/
    202 void bDrawPoints (KapaGraphWidget *graph, Gobjects *object) {
     202void bDrawPoints (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) {
    203203 
    204204  int i;
     
    233233            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    234234        {
    235           FillRectangle (sx, sy, 2*d*z[i], 2*d*z[i]);
     235          FillRectangle (buffer, sx, sy, 2*d*z[i], 2*d*z[i]);
    236236        }
    237237      }
     
    245245            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    246246        {
    247           DrawRectangle (sx, sy, 2*d*z[i], 2*d*z[i]);
     247          DrawRectangle (buffer, sx, sy, 2*d*z[i], 2*d*z[i]);
    248248        }
    249249      }
     
    257257            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    258258        {
    259           DrawLine (sx - d*z[i], sy, sx + d*z[i], sy);
    260           DrawLine (sx, sy - d*z[i], sx, sy + d*z[i]);
     259          DrawLine (buffer, sx - d*z[i], sy, sx + d*z[i], sy);
     260          DrawLine (buffer, sx, sy - d*z[i], sx, sy + d*z[i]);
    261261        }
    262262      }
     
    270270            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    271271        {
    272           DrawLine (sx + d*z[i], sy - d*z[i], sx - d*z[i], sy + d*z[i]);
    273           DrawLine (sx - d*z[i], sy - d*z[i], sx + d*z[i], sy + d*z[i]);
     272          DrawLine (buffer, sx + d*z[i], sy - d*z[i], sx - d*z[i], sy + d*z[i]);
     273          DrawLine (buffer, sx - d*z[i], sy - d*z[i], sx + d*z[i], sy + d*z[i]);
    274274        }
    275275      }
     
    283283            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    284284        {
    285           FillTriangle (sx - d*z[i], sy - 0.58*d*z[i], sx + d*z[i], sy - 0.58*d*z[i], sx, sy + 1.15*d*z[i]);
     285          FillTriangle (buffer, sx - d*z[i], sy - 0.58*d*z[i], sx + d*z[i], sy - 0.58*d*z[i], sx, sy + 1.15*d*z[i]);
    286286        }
    287287      }
     
    295295            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    296296        {
    297           OpenTriangle (sx - d*z[i], sy + 0.58*d*z[i], sx, sy - 1.15*d*z[i], sx + d*z[i], sy + 0.58*d*z[i]);
     297          OpenTriangle (buffer, sx - d*z[i], sy + 0.58*d*z[i], sx, sy - 1.15*d*z[i], sx + d*z[i], sy + 0.58*d*z[i]);
    298298        }
    299299      }
     
    307307            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    308308        {
    309           DrawLine (sx, sy, sx - d*z[i], sy + 0.58*d*z[i]);
    310           DrawLine (sx, sy, sx + d*z[i], sy + 0.58*d*z[i]);
    311           DrawLine (sx, sy, sx,          sy - 1.15*d*z[i]);
     309          DrawLine (buffer, sx, sy, sx - d*z[i], sy + 0.58*d*z[i]);
     310          DrawLine (buffer, sx, sy, sx + d*z[i], sy + 0.58*d*z[i]);
     311          DrawLine (buffer, sx, sy, sx,          sy - 1.15*d*z[i]);
    312312        }
    313313      }
     
    321321            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    322322        {
    323           DrawCircle (sx, sy, d*z[i]);
     323          DrawCircle (buffer, sx, sy, d*z[i]);
    324324        }
    325325      }
     
    333333            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    334334        {
    335           DrawLine (sx + 0.00*d*z[i], sy - 1.00*d*z[i], sx + 0.95*d*z[i], sy - 0.31*d*z[i]);
    336           DrawLine (sx + 0.95*d*z[i], sy - 0.31*d*z[i], sx + 0.58*d*z[i], sy + 0.81*d*z[i]);
    337           DrawLine (sx + 0.58*d*z[i], sy + 0.81*d*z[i], sx - 0.58*d*z[i], sy + 0.81*d*z[i]);
    338           DrawLine (sx - 0.58*d*z[i], sy + 0.81*d*z[i], sx - 0.95*d*z[i], sy - 0.31*d*z[i]);
    339           DrawLine (sx - 0.95*d*z[i], sy - 0.31*d*z[i], sx + 0.00*d*z[i], sy - 1.00*d*z[i]);
     335          DrawLine (buffer, sx + 0.00*d*z[i], sy - 1.00*d*z[i], sx + 0.95*d*z[i], sy - 0.31*d*z[i]);
     336          DrawLine (buffer, sx + 0.95*d*z[i], sy - 0.31*d*z[i], sx + 0.58*d*z[i], sy + 0.81*d*z[i]);
     337          DrawLine (buffer, sx + 0.58*d*z[i], sy + 0.81*d*z[i], sx - 0.58*d*z[i], sy + 0.81*d*z[i]);
     338          DrawLine (buffer, sx - 0.58*d*z[i], sy + 0.81*d*z[i], sx - 0.95*d*z[i], sy - 0.31*d*z[i]);
     339          DrawLine (buffer, sx - 0.95*d*z[i], sy - 0.31*d*z[i], sx + 0.00*d*z[i], sy - 1.00*d*z[i]);
    340340        }
    341341      }
     
    349349            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    350350        {
    351           DrawLine (sx -      d*z[i], sy,               sx - 0.50*d*z[i], sy + 0.87*d*z[i]);
    352           DrawLine (sx - 0.50*d*z[i], sy + 0.87*d*z[i], sx + 0.50*d*z[i], sy + 0.87*d*z[i]);
    353           DrawLine (sx + 0.50*d*z[i], sy + 0.87*d*z[i], sx +      d*z[i], sy);
    354 
    355           DrawLine (sx +      d*z[i], sy,               sx + 0.50*d*z[i], sy - 0.87*d*z[i]);
    356           DrawLine (sx + 0.50*d*z[i], sy - 0.87*d*z[i], sx - 0.50*d*z[i], sy - 0.87*d*z[i]);
    357           DrawLine (sx - 0.50*d*z[i], sy - 0.87*d*z[i], sx -      d*z[i], sy);
     351          DrawLine (buffer, sx -      d*z[i], sy,               sx - 0.50*d*z[i], sy + 0.87*d*z[i]);
     352          DrawLine (buffer, sx - 0.50*d*z[i], sy + 0.87*d*z[i], sx + 0.50*d*z[i], sy + 0.87*d*z[i]);
     353          DrawLine (buffer, sx + 0.50*d*z[i], sy + 0.87*d*z[i], sx +      d*z[i], sy);
     354
     355          DrawLine (buffer, sx +      d*z[i], sy,               sx + 0.50*d*z[i], sy - 0.87*d*z[i]);
     356          DrawLine (buffer, sx + 0.50*d*z[i], sy - 0.87*d*z[i], sx - 0.50*d*z[i], sy - 0.87*d*z[i]);
     357          DrawLine (buffer, sx - 0.50*d*z[i], sy - 0.87*d*z[i], sx -      d*z[i], sy);
    358358        }
    359359      }
     
    366366        sx2 = x[i+1]*mxi + y[i+1]*mxj + bx;
    367367        sy2 = x[i+1]*myi + y[i+1]*myj + by;
    368         DrawLine (sx1, sy1, sx2, sy2);
     368        DrawLine (buffer, sx1, sy1, sx2, sy2);
    369369      }
    370370    }
     
    380380            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    381381        {
    382           FillRectangle (sx, sy, 2*d, 2*d);
     382          FillRectangle (buffer, sx, sy, 2*d, 2*d);
    383383        }
    384384      }
     
    392392            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    393393        {
    394           DrawRectangle (sx, sy, 2*d, 2*d);
     394          DrawRectangle (buffer, sx, sy, 2*d, 2*d);
    395395        }
    396396      }
     
    404404            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    405405        {
    406           DrawLine (sx - d, sy, sx + d, sy);
    407           DrawLine (sx, sy - d, sx, sy + d);
     406          DrawLine (buffer, sx - d, sy, sx + d, sy);
     407          DrawLine (buffer, sx, sy - d, sx, sy + d);
    408408        }
    409409      }
     
    417417            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    418418        {
    419           DrawLine (sx + d, sy - d, sx - d, sy + d);
    420           DrawLine (sx - d, sy - d, sx + d, sy + d);
     419          DrawLine (buffer, sx + d, sy - d, sx - d, sy + d);
     420          DrawLine (buffer, sx - d, sy - d, sx + d, sy + d);
    421421        }
    422422      }
     
    430430            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    431431        {
    432           FillTriangle (sx - d, sy - 0.58*d, sx + d, sy - 0.58*d, sx, sy + 1.15*d);
     432          FillTriangle (buffer, sx - d, sy - 0.58*d, sx + d, sy - 0.58*d, sx, sy + 1.15*d);
    433433        }
    434434      }
     
    442442            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    443443        {
    444           OpenTriangle (sx - d, sy + 0.58*d, sx + d, sy + 0.58*d, sx, sy - 1.15*d);
     444          OpenTriangle (buffer, sx - d, sy + 0.58*d, sx + d, sy + 0.58*d, sx, sy - 1.15*d);
    445445        }
    446446      }
     
    454454            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    455455        {
    456           DrawLine (sx, sy, sx - d, sy - 0.58*d);
    457           DrawLine (sx, sy, sx + d, sy - 0.58*d);
    458           DrawLine (sx, sy, sx,     sy + 1.15*d);
     456          DrawLine (buffer, sx, sy, sx - d, sy - 0.58*d);
     457          DrawLine (buffer, sx, sy, sx + d, sy - 0.58*d);
     458          DrawLine (buffer, sx, sy, sx,     sy + 1.15*d);
    459459        }
    460460      }
     
    468468            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    469469        {
    470           DrawCircle (sx, sy, d);
     470          DrawCircle (buffer, sx, sy, d);
    471471        }
    472472      }
     
    480480            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    481481        {
    482           DrawLine (sx + 0.00*d, sy - 1.00*d, sx + 0.95*d, sy - 0.31*d);
    483           DrawLine (sx + 0.95*d, sy - 0.31*d, sx + 0.58*d, sy + 0.81*d);
    484           DrawLine (sx + 0.58*d, sy + 0.81*d, sx - 0.58*d, sy + 0.81*d);
    485           DrawLine (sx - 0.58*d, sy + 0.81*d, sx - 0.95*d, sy - 0.31*d);
    486           DrawLine (sx - 0.95*d, sy - 0.31*d, sx + 0.00*d, sy - 1.00*d);
     482          DrawLine (buffer, sx + 0.00*d, sy - 1.00*d, sx + 0.95*d, sy - 0.31*d);
     483          DrawLine (buffer, sx + 0.95*d, sy - 0.31*d, sx + 0.58*d, sy + 0.81*d);
     484          DrawLine (buffer, sx + 0.58*d, sy + 0.81*d, sx - 0.58*d, sy + 0.81*d);
     485          DrawLine (buffer, sx - 0.58*d, sy + 0.81*d, sx - 0.95*d, sy - 0.31*d);
     486          DrawLine (buffer, sx - 0.95*d, sy - 0.31*d, sx + 0.00*d, sy - 1.00*d);
    487487        }
    488488      }
     
    496496            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    497497        {
    498           DrawLine (sx - 1.00*d, sy + 0.00*d, sx - 0.50*d, sy + 0.87*d);
    499           DrawLine (sx - 0.50*d, sy + 0.87*d, sx + 0.50*d, sy + 0.87*d);
    500           DrawLine (sx + 0.50*d, sy + 0.87*d, sx + 1.00*d, sy + 0.00*d);
    501           DrawLine (sx + 1.00*d, sy + 0.00*d, sx + 0.50*d, sy - 0.87*d);
    502           DrawLine (sx + 0.50*d, sy - 0.87*d, sx - 0.50*d, sy - 0.87*d);
    503           DrawLine (sx - 0.50*d, sy - 0.87*d, sx - 1.00*d, sy + 0.00*d);
     498          DrawLine (buffer, sx - 1.00*d, sy + 0.00*d, sx - 0.50*d, sy + 0.87*d);
     499          DrawLine (buffer, sx - 0.50*d, sy + 0.87*d, sx + 0.50*d, sy + 0.87*d);
     500          DrawLine (buffer, sx + 0.50*d, sy + 0.87*d, sx + 1.00*d, sy + 0.00*d);
     501          DrawLine (buffer, sx + 1.00*d, sy + 0.00*d, sx + 0.50*d, sy - 0.87*d);
     502          DrawLine (buffer, sx + 0.50*d, sy - 0.87*d, sx - 0.50*d, sy - 0.87*d);
     503          DrawLine (buffer, sx - 0.50*d, sy - 0.87*d, sx - 1.00*d, sy + 0.00*d);
    504504        }
    505505      }
     
    512512        sx2 = x[i+1]*mxi + y[i+1]*mxj + bx;
    513513        sy2 = x[i+1]*myi + y[i+1]*myj + by;
    514         DrawLine (sx1, sy1, sx2, sy2);
     514        DrawLine (buffer, sx1, sy1, sx2, sy2);
    515515      }
    516516    }
     
    519519   
    520520/*******/
    521 void bDrawXErrors (KapaGraphWidget *graph, Gobjects *object) {
     521void bDrawXErrors (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) {
    522522 
    523523  int i, bar;
     
    553553         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    554554    {
    555       DrawLine (sx0, sy0, sx1, sy1);
     555      DrawLine (buffer, sx0, sy0, sx1, sy1);
    556556      if (bar) {
    557557        sx10 = sy1 - sz;
    558558        sx11 = sy1 + sz;
    559         DrawLine (sx1, sx10, sx1, sx11);
     559        DrawLine (buffer, sx1, sx10, sx1, sx11);
    560560      }
    561561    }
     
    570570         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    571571    {
    572       DrawLine (sx0, sy0, sx1, sy1);
     572      DrawLine (buffer, sx0, sy0, sx1, sy1);
    573573      if (bar) {
    574574        sx10 = sy1 - sz;
    575575        sx11 = sy1 + sz;
    576         DrawLine (sx1, sx10, sx1, sx11);
     576        DrawLine (buffer, sx1, sx10, sx1, sx11);
    577577      }
    578578    }
     
    581581   
    582582/*******/
    583 void bDrawYErrors (KapaGraphWidget *graph, Gobjects *object) {
     583void bDrawYErrors (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) {
    584584 
    585585  int i, bar;
     
    615615         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    616616    {
    617       DrawLine (sx0, sy0, sx1, sy1);
     617      DrawLine (buffer, sx0, sy0, sx1, sy1);
    618618      if (bar) {
    619619        sx10 = sx1 - sz;
    620620        sx11 = sx1 + sz;
    621         DrawLine (sx10, sy1, sx11, sy1);
     621        DrawLine (buffer, sx10, sy1, sx11, sy1);
    622622      }
    623623    }
     
    632632         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    633633    {
    634       DrawLine (sx0, sy0, sx1, sy1);
     634      DrawLine (buffer, sx0, sy0, sx1, sy1);
    635635      if (bar) {
    636636        sx10 = sx1 - sz;
    637637        sx11 = sx1 + sz;
    638         DrawLine (sx10, sy1, sx11, sy1);
     638        DrawLine (buffer, sx10, sy1, sx11, sy1);
    639639      }
    640640    }
  • branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/bDrawOverlay.c

    r25757 r29815  
    44static char name[4][16] = {"red", "green", "blue", "yellow"};
    55
    6 void bDrawOverlay (KapaImageWidget *image, int N) {
     6void bDrawOverlay (bDrawBuffer *buffer, KapaImageWidget *image, int N) {
    77
    88  int i;
     
    1414  /* translate color to bDrawColors : image[0].overlay[N].color */
    1515  color = KapaColorByName (name[N]);
    16   bDrawSetStyle (color, 0, 0);
     16  bDrawSetStyle (buffer, color, 0, 0);
    1717 
    1818  expand = 1.0;
     
    5757    switch (image[0].overlay[N].objects[i].type) {
    5858      case KII_OVERLAY_LINE:
    59         bDrawLine (X, Y, (X+dX), (Y+dY));
     59        bDrawLine (buffer, X, Y, (X+dX), (Y+dY));
    6060        break;
    6161      case KII_OVERLAY_TEXT:
    62         bDrawRotText (X, Y, image[0].overlay[N].objects[i].text, 8, 0.0);
     62        bDrawRotText (buffer, X, Y, image[0].overlay[N].objects[i].text, 8, 0.0);
    6363        break;
    6464      case KII_OVERLAY_BOX:
    6565        dx = MAX (abs(dX),2) / 2;
    6666        dy = MAX (abs(dY),2) / 2;
    67         bDrawRectOpen ((X-dx), (Y-dy), (X+dx), (Y+dy));
    68         // bDrawRectOpen ((X-dx), (Y-dy), (X), (Y));
     67        bDrawRectOpen (buffer, (X-dx), (Y-dy), (X+dx), (Y+dy));
     68        // bDrawRectOpen (buffer, (X-dx), (Y-dy), (X), (Y));
    6969        break;
    7070      case KII_OVERLAY_CIRCLE:
     
    7272        dy = MAX (abs(dY),2);
    7373        if (image[0].overlay[N].objects[i].angle == 0.0) {
    74           bDrawArc (X, Y, dx, dy, 0, 360);
     74          bDrawArc (buffer, X, Y, dx, dy, 0, 360);
    7575        } else {
    7676          // moderately-stupid rotated ellipse drawing:
     
    8888            x1 = X + pX*dx*cos(t)*cs - pX*dy*sin(t)*sn;
    8989            y1 = Y + pY*dx*cos(t)*sn + pY*dy*sin(t)*cs;
    90             bDrawLine (x0, y0, x1, y1);
     90            bDrawLine (buffer, x0, y0, x1, y1);
    9191            x0 = x1;
    9292            y0 = y1;
     
    101101 
    102102  /* translate color to bDrawColors : image[0].overlay[N].color */
    103   bDrawSetStyle (color, 0, 0);
     103  bDrawSetStyle (buffer, color, 0, 0);
    104104}
    105105
Note: See TracChangeset for help on using the changeset viewer.