Changeset 29815
- Timestamp:
- Nov 24, 2010, 11:54:39 AM (15 years ago)
- Location:
- branches/eam_branches/ipp-20101103/Ohana/src/kapa2
- Files:
-
- 1 added
- 19 edited
-
Makefile (modified) (1 diff)
-
include/prototypes.h (modified) (5 diffs)
-
include/structures.h (modified) (1 diff)
-
src/CheckPipe.c (modified) (2 diffs)
-
src/DefineSection.c (modified) (1 diff)
-
src/DrawFrame.c (modified) (15 diffs)
-
src/JPEGit24.c (modified) (1 diff)
-
src/PNGit.c (modified) (5 diffs)
-
src/PPMit.c (modified) (2 diffs)
-
src/PSFrame.c (modified) (3 diffs)
-
src/PSimage.c (modified) (1 diff)
-
src/PSit.c (modified) (2 diffs)
-
src/Resize.c (modified) (1 diff)
-
src/SetGraphSize.c (modified) (10 diffs)
-
src/bDrawFrame.c (modified) (6 diffs)
-
src/bDrawImage.c (added)
-
src/bDrawIt.c (modified) (4 diffs)
-
src/bDrawLabels.c (modified) (4 diffs)
-
src/bDrawObjects.c (modified) (35 diffs)
-
src/bDrawOverlay.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20101103/Ohana/src/kapa2/Makefile
r25757 r29815 42 42 $(SRC)/bDrawObjects.$(ARCH).o $(SRC)/bDrawFrame.$(ARCH).o \ 43 43 $(SRC)/bDrawLabels.$(ARCH).o $(SRC)/bDrawIt.$(ARCH).o \ 44 $(SRC)/bDrawImage.$(ARCH).o \ 44 45 $(SRC)/PNGit.$(ARCH).o $(SRC)/PPMit.$(ARCH).o \ 45 46 $(SRC)/PSit.$(ARCH).o $(SRC)/CrossHairs.$(ARCH).o \ -
branches/eam_branches/ipp-20101103/Ohana/src/kapa2/include/prototypes.h
r29783 r29815 40 40 void DrawYErrors PROTO((KapaGraphWidget *graph, Gobjects *objects)); 41 41 void DrawTick PROTO((Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis)); 42 void AxisTickScale PROTO((Axis *axis, double *major, double *minor ));42 void AxisTickScale PROTO((Axis *axis, double *major, double *minor, int *nsignif)); 43 43 TickMarkData *CreateAxisTicks PROTO((Axis *axis, int *nticks)); 44 int PrintTick PROTO((char *string, double value, double min, double max ));44 int PrintTick PROTO((char *string, double value, double min, double max, int nsignif)); 45 45 46 46 /* EventLoop */ … … 68 68 int MoveSection PROTO((int sock)); 69 69 int DefineSection PROTO((int sock)); 70 int DefineSectionByImage PROTO((int sock)); 70 71 int SetFont PROTO((int sock)); 71 72 int EraseCurrentPlot PROTO((void)); … … 127 128 128 129 /* 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)); 130 int bDrawFrame PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph)); 131 int bDrawObjects PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph)); 132 void bDrawLabels PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph)); 133 void bDrawTextlines PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph)); 134 void bDrawConnect PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object)); 135 void bDrawHistogram PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object)); 136 void bDrawPoints PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object)); 137 void bDrawXErrors PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object)); 138 void bDrawYErrors PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object)); 139 void bDrawTick PROTO((bDrawBuffer *buffer, Axis *axis, int P, TickMarkData *tick, int naxis)); 140 void bDrawClipLine PROTO((bDrawBuffer *buffer, double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0)); 141 void bDrawGraph PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph)); 142 int bDrawImage PROTO((bDrawBuffer *buffer, KapaImageWidget *image, Graphic *graphic)); 143 bDrawBuffer *bDrawIt PROTO((png_color *palette, int Npalette, int Nbyte)); 142 144 143 145 /* misc support */ … … 245 247 int GetActiveSocket (void); 246 248 void InvertButton (Graphic *graphic, Button *button); 247 void bDrawOverlay ( KapaImageWidget *image, int N);249 void bDrawOverlay (bDrawBuffer *buffer, KapaImageWidget *image, int N); 248 250 249 251 /* color cube tools */ … … 265 267 int SetColorScale3D_CC (Graphic *graphic, KapaImageWidget *image); 266 268 int SetColorCubeHistogram (void); 269 int GetGraphBoundary (Section *section, double *x0, double *y0, double *x1, double *y1, int *dXm, int *dXp, int *dYm, int *dYp); 270 int ResizeByImage (int sock); 271 -
branches/eam_branches/ipp-20101103/Ohana/src/kapa2/include/structures.h
r29539 r29815 148 148 int IsMajor; 149 149 int IsLabel; 150 int nsignif; 150 151 } TickMarkData; 151 152 -
branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/CheckPipe.c
r29783 r29815 137 137 } 138 138 139 if (!strcmp (word, "ISIZ")) { 140 status = ResizeByImage (sock); 141 KiiSendCommand (sock, 4, "DONE"); 142 FINISHED (TRUE); 143 } 144 139 145 if (!strcmp (word, "MOVE")) { 140 146 status = Relocate (sock); … … 217 223 if (!strcmp (word, "DSEC")) { 218 224 status = DefineSection (sock); 225 KiiSendCommand (sock, 4, "DONE"); 226 FINISHED (TRUE); 227 } 228 229 if (!strcmp (word, "ISEC")) { 230 status = DefineSectionByImage (sock); 219 231 KiiSendCommand (sock, 4, "DONE"); 220 232 FINISHED (TRUE); -
branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/DefineSection.c
r27790 r29815 40 40 return (TRUE); 41 41 } 42 43 // define the section, but do not create a graph or image 44 int 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 5 5 int DrawFrame (KapaGraphWidget *graph) { 6 6 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; 9 9 Graphic *graphic; 10 10 TickMarkData *ticks; … … 15 15 /* each axis is drawn independently, but ticks and labels are placed according to perpendicular distance. */ 16 16 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 23 17 lweight = MAX (0, MIN (10, graph[0].axis[i].lweight)); 24 18 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); 25 34 26 35 XSetLineAttributes (graphic->display, graphic->gc, lweight, LineSolid, CapNotLast, JoinMiter); … … 43 52 } 44 53 45 int PrintTick (char *string, double value, double min, double max ) {54 int PrintTick (char *string, double value, double min, double max, int nsignif) { 46 55 47 56 int Nexp = 0; … … 54 63 } 55 64 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 64 74 if (Nexp > 3) { 65 75 Nchar = sprintf (string, "%.1e", value); 66 76 } 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 } 68 84 } 69 85 return Nchar; … … 129 145 yt = fy + (value-min)*dfy/(max - min) + dy; 130 146 131 PrintTick (string, value, min, max );147 PrintTick (string, value, min, max, tick->nsignif); 132 148 DrawRotText (xt, yt, string, pos, 0.0); 133 149 } … … 136 152 # define MIN_RANGE 1e-10 137 153 138 void AxisTickScale (Axis *axis, double *major, double *minor ) {154 void AxisTickScale (Axis *axis, double *major, double *minor, int *nsignif) { 139 155 140 156 double range, lrange, factor, mantis, fmantis, power; … … 152 168 } 153 169 170 // how many significant digits are needed? 171 154 172 power = MAX(pow(10.0, factor), MIN_RANGE); 155 173 fmantis = pow(10.0, mantis); … … 160 178 *major = 0.5 * power; 161 179 *minor = 0.1 * power; 180 *nsignif = factor - 1; 162 181 if (axis[0].areticks == 1) { 163 182 *major = 0.25 * power; 164 183 *minor = 0.05 * power; 184 *nsignif = factor - 2; 165 185 } 166 186 } … … 168 188 *major = 1.0 * power; 169 189 *minor = 0.2 * power; 190 *nsignif = factor; 170 191 if (axis[0].areticks == 1) { 171 192 *major = 0.5 * power; 172 193 *minor = 0.1 * power; 194 *nsignif = factor - 1; 173 195 } 174 196 } … … 176 198 *major = 1.0 * power; 177 199 *minor = 0.5 * power; 200 *nsignif = factor; 178 201 if (axis[0].areticks == 1) { 179 202 *major = 1.0 * power; 180 203 *minor = 0.2 * power; 204 *nsignif = factor; 181 205 } 182 206 } … … 184 208 *major = 2.0 * power; 185 209 *minor = 0.5 * power; 210 *nsignif = factor; 186 211 if (axis[0].areticks == 1) { 187 212 *major = 1.0 * power; 188 213 *minor = 0.5 * power; 214 *nsignif = factor; 189 215 } 190 216 } … … 192 218 *major = 2.5 * power; 193 219 *minor = 0.5 * power; 220 *nsignif = factor - 1; 194 221 if (axis[0].areticks == 1) { 195 222 *major = 2.0 * power; 196 223 *minor = 0.5 * power; 224 *nsignif = factor; 197 225 } 198 226 } … … 203 231 TickMarkData *ticks; 204 232 double range, major, minor, first, value, dPixels, overshoot; 205 int i, NTICKS, nPixels, done, ifirst ;233 int i, NTICKS, nPixels, done, ifirst, nsignif; 206 234 207 235 *nticks = 0; … … 223 251 dPixels = nPixels / range; // axis pixel-scale 224 252 225 AxisTickScale (axis, &major, &minor );253 AxisTickScale (axis, &major, &minor, &nsignif); 226 254 227 255 // be a little generous … … 256 284 ticks[i].IsLabel = (ticks[i].IsMajor && axis->islabel); 257 285 ticks[i].value = value; 286 ticks[i].nsignif = nsignif; 258 287 if (range > 0) 259 288 value += minor; -
branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/JPEGit24.c
r29783 r29815 202 202 palette = KapaPNGPalette (&Npalette); 203 203 204 buffer = bDrawBufferCreate (dx, dy); 205 bDrawSetBuffer (buffer); 204 buffer = bDrawBufferCreate (dx, dy, 1, palette, Npalette); 206 205 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); 208 207 } 209 208 -
branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/PNGit.c
r29783 r29815 6 6 3) decision on output based on the existence of images or not 7 7 */ 8 9 bDrawBuffer *bDrawBufferCreate8bitRGB (int Nx, int Ny);10 int bDrawImage (bDrawBuffer *buffer, Graphic *graphic);11 8 12 9 int PNGcommand (int sock) { … … 25 22 png_structp png_ptr; 26 23 png_infop info_ptr; 27 int status, Npalette;24 int i, status, Npalette, Nsection; 28 25 bDrawBuffer *buffer = NULL; 29 26 Graphic *graphic = NULL; 30 27 png_color *palette = NULL; 28 Section *section; 31 29 32 30 graphic = GetGraphic(); … … 68 66 png_init_io (png_ptr, f); 69 67 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 70 78 /* 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) { 77 80 // 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); 78 81 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); 79 82 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); 80 86 } 81 87 … … 87 93 png_write_info (png_ptr, info_ptr); 88 94 89 if (PALETTE) { 90 buffer = bDrawIt (); 95 if (haveImage) { 96 buffer = bDrawIt (palette, Npalette, 3); 97 // bDrawImage (buffer, graphic); 91 98 } else { 92 buffer = bDrawBufferCreate8bitRGB(graphic->dx, graphic->dy); 93 bDrawImage (buffer, graphic); 99 buffer = bDrawIt (palette, Npalette, 1); 94 100 } 95 101 … … 99 105 100 106 bDrawBufferFree (buffer); 101 free (palette);102 107 fclose (f); 103 108 return (TRUE); 104 109 105 110 } 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 255132 # define WHITE_G 255133 # define WHITE_B 255134 # 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,0188 // I_start, J_start are the image pixel corresponding to i_start, j_start189 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, dy192 // I_end, J_end are the image pixel corresponding to i_end, j_end193 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 the284 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 30 30 fprintf (f, "255\n"); 31 31 32 buffer = bDrawIt ( );32 buffer = bDrawIt (palette, Npalette, 1); 33 33 34 34 ALLOCATE (line, char, 3*dx); … … 47 47 bDrawBufferFree (buffer); 48 48 return (TRUE); 49 50 49 } -
branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/PSFrame.c
r29539 r29815 4 4 int PSFrame (KapaGraphWidget *graph, FILE *f) { 5 5 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; 8 8 Graphic *graphic; 9 9 TickMarkData *ticks; … … 15 15 fprintf (f, "1 setlinewidth\n"); 16 16 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 23 17 lweight = MAX (0, MIN (10, graph[0].axis[i].lweight)); 24 18 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); 25 34 26 35 fprintf (f, "%.1f setlinewidth\n", lweight); … … 95 104 yt = fy + (value-min)*dfy/(max - min) + dy; 96 105 97 PrintTick (string, value, min, max );106 PrintTick (string, value, min, max, tick->nsignif); 98 107 PSRotText (f, xt, yt, string, pos, 0.0); 99 108 } -
branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/PSimage.c
r14913 r29815 13 13 graphic = GetGraphic(); 14 14 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); 17 20 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); 18 22 fprintf (f, "%d %d 8\n", image[0].picture.dx, image[0].picture.dy); 19 23 fprintf (f, "[1 0 0 1 0 0]\n"); -
branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/PSit.c
r13479 r29815 87 87 for (i = 0; i < Nsection; i++) { 88 88 section = GetSectionByNumber (i); 89 if (section->image) { 90 PSimage (section->image, f); 91 } 89 92 if (section->graph) { 90 93 PSFrame (section->graph, f); … … 92 95 PSLabels (section->graph, f); 93 96 PSTextlines (section->graph, f); 94 }95 if (section->image) {96 PSimage (section->image, f);97 97 } 98 98 } -
branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/Resize.c
r26891 r29815 39 39 return (TRUE); 40 40 } 41 42 // resise the window so the image in the currently active window fills its section 43 int 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 5 5 6 6 void 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 71 int GetGraphBoundary (Section *section, double *x0, double *y0, double *x1, double *y1, int *dXm, int *dXp, int *dYm, int *dYp) { 7 72 8 73 int i, Nticks; 9 74 int fontsize, Nc = 0; 10 75 int textpad, textdY, WdY; 11 int dXm, dXp, dYm, dYp;12 76 double padXm, padXp, padYm, padYp; 13 77 double minPADx, maxPADx, minPADy; 14 78 double minPAD, maxPAD; 15 double X0, Y0, dX, dY;16 79 char string[64], *fontname; 17 80 KapaGraphWidget *graph; … … 19 82 TickMarkData *ticks; 20 83 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; 22 95 graph = section->graph; 23 if (graph == NULL) return ;96 if (graph == NULL) return FALSE; 24 97 25 98 graphic = GetGraphic (); … … 40 113 // these depend on (a) existence of tick labels and (b) auto-offset or not 41 114 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; 45 118 } 46 119 if (isnan(graph[0].axis[0].pad)) { … … 53 126 // these depend on (a) existence of tick labels and (b) auto-offset or not 54 127 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; 58 131 } 59 132 if (isnan(graph[0].axis[2].pad)) { … … 73 146 if (!ticks[i].IsMajor) continue; 74 147 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); 76 149 77 150 Nc = MAX (Nc, Nchar); … … 80 153 } 81 154 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; 85 158 } 86 159 if (isnan(graph[0].axis[1].pad)) { … … 98 171 for (i = 0; i < Nticks; i++) { 99 172 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); 101 174 Nc = MAX (Nc, Nchar); 102 175 } … … 104 177 } 105 178 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; 109 182 } 110 183 if (isnan(graph[0].axis[3].pad)) { … … 115 188 116 189 /* 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; 121 194 122 195 // if we are tied to an image, make mods as needed … … 128 201 switch (section->image->location) { 129 202 case 0: 130 // no changes?131 203 break; 132 204 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; 135 207 break; 136 208 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; 138 210 break; 139 211 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; 143 215 break; 144 216 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; 147 219 break; 148 220 } 149 221 } 150 222 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); 197 224 } -
branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/bDrawFrame.c
r29539 r29815 2 2 // bDrawLine is a function, not a macro like DrawLine 3 3 4 int bDrawFrame ( KapaGraphWidget *graph) {4 int bDrawFrame (bDrawBuffer *buffer, KapaGraphWidget *graph) { 5 5 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; 8 8 // Graphic graphic; is not needed 9 9 TickMarkData *ticks; … … 14 14 /* each axis is drawn independently */ 15 15 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 22 16 lweight = MAX (0, MIN (10, graph[0].axis[i].lweight)); 23 17 color = MAX (0, MIN (15, graph[0].axis[i].color)); 24 18 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 27 35 // bDrawRotTextInit does not exist 28 36 29 37 if (graph[0].axis[i].isaxis) { 30 bDrawLine ( fx, fy, fx+dfx, fy+dfy);38 bDrawLine (buffer, fx, fy, fx+dfx, fy+dfy); 31 39 } 32 40 … … 34 42 ticks = CreateAxisTicks (&graph[0].axis[i], &Nticks); 35 43 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); 37 50 } 38 51 FREE (ticks); … … 42 55 } 43 56 44 void bDrawTick ( Axis *axis, int P, TickMarkData *tick, int naxis) {57 void bDrawTick (bDrawBuffer *buffer, Axis *axis, int P, TickMarkData *tick, int naxis) { 45 58 46 59 double x, y, dx, dy; … … 75 88 dy = dir*size*dfx*n; 76 89 77 bDrawLine ( x, y, x+dx, y+dy);90 bDrawLine (buffer, x, y, x+dx, y+dy); 78 91 79 92 if (tick->IsLabel) { … … 94 107 yt = fy + (value-min)*dfy/(max - min) + dy; 95 108 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); 98 111 } 99 112 } -
branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/bDrawIt.c
r13479 r29815 1 1 # include "Ximage.h" 2 2 3 bDrawBuffer *bDrawIt ( ) {3 bDrawBuffer *bDrawIt (png_color *palette, int Npalette, int Nbyte) { 4 4 5 5 int i, Nsection; … … 13 13 black = KapaColorByName ("black"); 14 14 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); 18 17 19 18 // reset the sizes for all sections … … 21 20 for (i = 0; i < Nsection; i++) { 22 21 section = GetSectionByNumber (i); 23 bDraw Graph (section->graph);24 // bDrawImage (section->image);22 bDrawImage (buffer, section->image, graphic); 23 bDrawGraph (buffer, section->graph); 25 24 } 26 25 … … 28 27 } 29 28 30 void bDrawGraph ( KapaGraphWidget *graph) {29 void bDrawGraph (bDrawBuffer *buffer, KapaGraphWidget *graph) { 31 30 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); 36 35 } -
branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/bDrawLabels.c
r13320 r29815 1 1 # include "Ximage.h" 2 2 3 void bDrawLabels ( KapaGraphWidget *graph) {3 void bDrawLabels (bDrawBuffer *buffer, KapaGraphWidget *graph) { 4 4 5 5 int i, pos, x, y, size; … … 25 25 y = graph[0].label[i].y; 26 26 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); 28 28 } 29 29 } … … 31 31 } 32 32 33 void bDrawTextlines ( KapaGraphWidget *graph) {33 void bDrawTextlines (bDrawBuffer *buffer, KapaGraphWidget *graph) { 34 34 35 35 int i, x, y, size; … … 44 44 y = graph[0].textline[i].y; 45 45 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); 47 47 } 48 48 } -
branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/bDrawObjects.c
r27530 r29815 1 1 # include "Ximage.h" 2 2 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))) 9 9 10 10 # define CONNECT 0 … … 14 14 static Graphic *graphic; 15 15 16 int bDrawObjects ( KapaGraphWidget *graph) {16 int bDrawObjects (bDrawBuffer *buffer, KapaGraphWidget *graph) { 17 17 18 18 int i; … … 30 30 type = graph[0].objects[i].ltype; 31 31 color = graph[0].objects[i].color; 32 bDrawSetStyle ( color, weight, type);32 bDrawSetStyle (buffer, color, weight, type); 33 33 34 34 switch (graph[0].objects[i].style) { 35 35 case CONNECT: 36 bDrawConnect ( graph, &graph[0].objects[i]);36 bDrawConnect (buffer, graph, &graph[0].objects[i]); 37 37 break; 38 38 case HISTOGRAM: 39 bDrawHistogram ( graph, &graph[0].objects[i]);39 bDrawHistogram (buffer, graph, &graph[0].objects[i]); 40 40 break; 41 41 case POINTS: 42 bDrawPoints ( graph, &graph[0].objects[i]);42 bDrawPoints (buffer, graph, &graph[0].objects[i]); 43 43 break; 44 44 } 45 45 46 46 if (graph[0].objects[i].etype & 0x01) { 47 bDrawYErrors ( graph, &graph[0].objects[i]);47 bDrawYErrors (buffer, graph, &graph[0].objects[i]); 48 48 } 49 49 if (graph[0].objects[i].etype & 0x02) { 50 bDrawXErrors ( graph, &graph[0].objects[i]);51 } 52 } 53 bDrawSetStyle (b lack, 0, 0);50 bDrawXErrors (buffer, graph, &graph[0].objects[i]); 51 } 52 } 53 bDrawSetStyle (buffer, black, 0, 0); 54 54 return (TRUE); 55 55 } 56 56 57 void bDrawConnect ( KapaGraphWidget *graph, Gobjects *object) {57 void bDrawConnect (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) { 58 58 59 59 int i; … … 91 91 sx1 = x[i]*mxi + y[i]*mxj + bx; 92 92 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); 94 94 sx0 = sx1; sy0 = sy1; 95 95 } 96 96 } 97 97 98 void bDrawClipLine ( double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0) {98 void bDrawClipLine (bDrawBuffer *buffer, double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0) { 99 99 100 100 /* skip line segement if both points are beyond box */ … … 145 145 y1 = Y1; 146 146 } 147 DrawLine ( x0, y0, x1, y1);147 DrawLine (buffer, x0, y0, x1, y1); 148 148 } 149 149 150 150 /*******/ 151 void bDrawHistogram ( KapaGraphWidget *graph, Gobjects *object) {151 void bDrawHistogram (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) { 152 152 153 153 int i; … … 192 192 sy1 = MAX (MIN (sy1, Y0), Y1); 193 193 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); 197 197 sx0 = sx1; sy0 = sy1; 198 198 } … … 200 200 201 201 /*******/ 202 void bDrawPoints ( KapaGraphWidget *graph, Gobjects *object) {202 void bDrawPoints (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) { 203 203 204 204 int i; … … 233 233 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 234 234 { 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]); 236 236 } 237 237 } … … 245 245 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 246 246 { 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]); 248 248 } 249 249 } … … 257 257 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 258 258 { 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]); 261 261 } 262 262 } … … 270 270 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 271 271 { 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]); 274 274 } 275 275 } … … 283 283 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 284 284 { 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]); 286 286 } 287 287 } … … 295 295 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 296 296 { 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]); 298 298 } 299 299 } … … 307 307 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 308 308 { 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]); 312 312 } 313 313 } … … 321 321 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 322 322 { 323 DrawCircle ( sx, sy, d*z[i]);323 DrawCircle (buffer, sx, sy, d*z[i]); 324 324 } 325 325 } … … 333 333 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 334 334 { 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]); 340 340 } 341 341 } … … 349 349 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 350 350 { 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); 358 358 } 359 359 } … … 366 366 sx2 = x[i+1]*mxi + y[i+1]*mxj + bx; 367 367 sy2 = x[i+1]*myi + y[i+1]*myj + by; 368 DrawLine ( sx1, sy1, sx2, sy2);368 DrawLine (buffer, sx1, sy1, sx2, sy2); 369 369 } 370 370 } … … 380 380 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 381 381 { 382 FillRectangle ( sx, sy, 2*d, 2*d);382 FillRectangle (buffer, sx, sy, 2*d, 2*d); 383 383 } 384 384 } … … 392 392 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 393 393 { 394 DrawRectangle ( sx, sy, 2*d, 2*d);394 DrawRectangle (buffer, sx, sy, 2*d, 2*d); 395 395 } 396 396 } … … 404 404 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 405 405 { 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); 408 408 } 409 409 } … … 417 417 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 418 418 { 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); 421 421 } 422 422 } … … 430 430 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 431 431 { 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); 433 433 } 434 434 } … … 442 442 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 443 443 { 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); 445 445 } 446 446 } … … 454 454 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 455 455 { 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); 459 459 } 460 460 } … … 468 468 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 469 469 { 470 DrawCircle ( sx, sy, d);470 DrawCircle (buffer, sx, sy, d); 471 471 } 472 472 } … … 480 480 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 481 481 { 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); 487 487 } 488 488 } … … 496 496 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 497 497 { 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); 504 504 } 505 505 } … … 512 512 sx2 = x[i+1]*mxi + y[i+1]*mxj + bx; 513 513 sy2 = x[i+1]*myi + y[i+1]*myj + by; 514 DrawLine ( sx1, sy1, sx2, sy2);514 DrawLine (buffer, sx1, sy1, sx2, sy2); 515 515 } 516 516 } … … 519 519 520 520 /*******/ 521 void bDrawXErrors ( KapaGraphWidget *graph, Gobjects *object) {521 void bDrawXErrors (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) { 522 522 523 523 int i, bar; … … 553 553 (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy))) 554 554 { 555 DrawLine ( sx0, sy0, sx1, sy1);555 DrawLine (buffer, sx0, sy0, sx1, sy1); 556 556 if (bar) { 557 557 sx10 = sy1 - sz; 558 558 sx11 = sy1 + sz; 559 DrawLine ( sx1, sx10, sx1, sx11);559 DrawLine (buffer, sx1, sx10, sx1, sx11); 560 560 } 561 561 } … … 570 570 (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy))) 571 571 { 572 DrawLine ( sx0, sy0, sx1, sy1);572 DrawLine (buffer, sx0, sy0, sx1, sy1); 573 573 if (bar) { 574 574 sx10 = sy1 - sz; 575 575 sx11 = sy1 + sz; 576 DrawLine ( sx1, sx10, sx1, sx11);576 DrawLine (buffer, sx1, sx10, sx1, sx11); 577 577 } 578 578 } … … 581 581 582 582 /*******/ 583 void bDrawYErrors ( KapaGraphWidget *graph, Gobjects *object) {583 void bDrawYErrors (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) { 584 584 585 585 int i, bar; … … 615 615 (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy))) 616 616 { 617 DrawLine ( sx0, sy0, sx1, sy1);617 DrawLine (buffer, sx0, sy0, sx1, sy1); 618 618 if (bar) { 619 619 sx10 = sx1 - sz; 620 620 sx11 = sx1 + sz; 621 DrawLine ( sx10, sy1, sx11, sy1);621 DrawLine (buffer, sx10, sy1, sx11, sy1); 622 622 } 623 623 } … … 632 632 (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy))) 633 633 { 634 DrawLine ( sx0, sy0, sx1, sy1);634 DrawLine (buffer, sx0, sy0, sx1, sy1); 635 635 if (bar) { 636 636 sx10 = sx1 - sz; 637 637 sx11 = sx1 + sz; 638 DrawLine ( sx10, sy1, sx11, sy1);638 DrawLine (buffer, sx10, sy1, sx11, sy1); 639 639 } 640 640 } -
branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/bDrawOverlay.c
r25757 r29815 4 4 static char name[4][16] = {"red", "green", "blue", "yellow"}; 5 5 6 void bDrawOverlay ( KapaImageWidget *image, int N) {6 void bDrawOverlay (bDrawBuffer *buffer, KapaImageWidget *image, int N) { 7 7 8 8 int i; … … 14 14 /* translate color to bDrawColors : image[0].overlay[N].color */ 15 15 color = KapaColorByName (name[N]); 16 bDrawSetStyle ( color, 0, 0);16 bDrawSetStyle (buffer, color, 0, 0); 17 17 18 18 expand = 1.0; … … 57 57 switch (image[0].overlay[N].objects[i].type) { 58 58 case KII_OVERLAY_LINE: 59 bDrawLine ( X, Y, (X+dX), (Y+dY));59 bDrawLine (buffer, X, Y, (X+dX), (Y+dY)); 60 60 break; 61 61 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); 63 63 break; 64 64 case KII_OVERLAY_BOX: 65 65 dx = MAX (abs(dX),2) / 2; 66 66 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)); 69 69 break; 70 70 case KII_OVERLAY_CIRCLE: … … 72 72 dy = MAX (abs(dY),2); 73 73 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); 75 75 } else { 76 76 // moderately-stupid rotated ellipse drawing: … … 88 88 x1 = X + pX*dx*cos(t)*cs - pX*dy*sin(t)*sn; 89 89 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); 91 91 x0 = x1; 92 92 y0 = y1; … … 101 101 102 102 /* translate color to bDrawColors : image[0].overlay[N].color */ 103 bDrawSetStyle ( color, 0, 0);103 bDrawSetStyle (buffer, color, 0, 0); 104 104 } 105 105
Note:
See TracChangeset
for help on using the changeset viewer.
