Changeset 40731
- Timestamp:
- May 14, 2019, 2:41:45 PM (7 years ago)
- Location:
- branches/eam_branches/ohana.20190329/src/kapa2
- Files:
-
- 12 edited
-
include/prototypes.h (modified) (2 diffs)
-
include/structures.h (modified) (1 diff)
-
src/CheckPipe.c (modified) (1 diff)
-
src/Image.c (modified) (3 diffs)
-
src/LoadFrame.c (modified) (1 diff)
-
src/LoadObject.c (modified) (1 diff)
-
src/PNGit.c (modified) (2 diffs)
-
src/Refresh.c (modified) (1 diff)
-
src/SetUpGraphic.c (modified) (2 diffs)
-
src/bDrawImage.c (modified) (3 diffs)
-
src/bDrawIt.c (modified) (1 diff)
-
src/bDrawObjects.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20190329/src/kapa2/include/prototypes.h
r40165 r40731 85 85 int SetColormapFromPipe PROTO((int sock)); 86 86 int SetNanColorFromPipe PROTO((int sock)); 87 int SetSmoothSigma PROTO((int sock)); 87 88 88 89 int LoadVectorData PROTO((int sock, KapaGraphWidget *graph, int N, char *type)); … … 179 180 void InitButtonFunc PROTO((Button *button, int (*function)(Graphic *graphic, KapaImageWidget *image))); 180 181 void DrawImage PROTO((KapaImageWidget *image)); 182 void DrawImageTool PROTO((KapaImageWidget *image)); 181 183 void DrawButton PROTO((Graphic *graphic, Button *button)); 182 184 void DrawBitmap PROTO((Graphic *graphic, int x, int y, int dx, int dy, unsigned char *bitmap, int mode)); -
branches/eam_branches/ohana.20190329/src/kapa2/include/structures.h
r40570 r40731 48 48 unsigned long back; // basic background color 49 49 50 float smooth_sigma; // anti-aliasing smoothing scale 51 50 52 unsigned long overlay_color[NOVERLAYS]; // image plotting colors 51 53 } Graphic; -
branches/eam_branches/ohana.20190329/src/kapa2/src/CheckPipe.c
r38465 r40731 352 352 } 353 353 354 if (!strcmp (word, "SIGM")) { 355 SetSmoothSigma (sock); 356 KiiSendCommand (sock, 4, "DONE"); 357 FINISHED (TRUE); 358 } 359 354 360 fprintf (stderr, "unknown signal %s\n", word); 355 361 KiiSendCommand (sock, 4, "DONE"); -
branches/eam_branches/ohana.20190329/src/kapa2/src/Image.c
r39457 r40731 148 148 void DrawImage (KapaImageWidget *image) { 149 149 150 Graphic *graphic; 151 152 if (image == NULL) return; 153 154 graphic = GetGraphic (); 155 156 if (image[0].picture.pix) { 157 XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc, 158 image[0].picture.pix, 0, 0, 159 image[0].picture.x + 1, image[0].picture.y + 1, 160 image[0].picture.dx, image[0].picture.dy); 161 } 162 } 163 164 // add the zoom, pan, crosshairs, status box, buttons 165 void DrawImageTool (KapaImageWidget *image) { 166 150 167 int i; 151 168 Graphic *graphic; … … 160 177 image[0].picture.dx+1, image[0].picture.dy+1); 161 178 162 if (image[0].picture.pix) {163 XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc,164 image[0].picture.pix, 0, 0,165 image[0].picture.x + 1, image[0].picture.y + 1,166 image[0].picture.dx, image[0].picture.dy);167 }168 169 for (i = 0; i < NOVERLAYS; i++) {170 if (image[0].overlay[i].active) {171 PaintOverlay (graphic, image, i);172 }173 }174 175 179 if (image[0].location) { 176 180 if (image[0].cmapbar.pix) { … … 211 215 StatusBox (graphic, image); 212 216 } 213 214 FlushDisplay ();215 217 } 216 218 -
branches/eam_branches/ohana.20190329/src/kapa2/src/LoadFrame.c
r38986 r40731 93 93 SetSectionSizes (section); 94 94 Refresh(); 95 // if (USE_XWINDOW) DrawFrame (graph);96 // FlushDisplay ();97 98 /* XXX why did I do this??? */99 # if (0)100 status = TRUE;101 if (status) {102 for (i = 0; i < Nsection; i++) {103 PositionPicture (§ion[i]);104 }105 if (USE_XWINDOW) XClearWindow (graphic.display, graphic.window);106 Refresh ();107 } else {108 FlushDisplay ();109 }110 # endif111 95 112 96 return (TRUE); -
branches/eam_branches/ohana.20190329/src/kapa2/src/LoadObject.c
r40570 r40731 103 103 104 104 if (USE_XWINDOW) { 105 Graphic *graphic = GetGraphic(); 106 DrawObjectN (graphic, graph, &graph[0].objects[graph[0].Nobjects-1]); 107 } 108 FlushDisplay (); 105 if (0) { 106 // use this if we are not using buffered plotting 107 Graphic *graphic = GetGraphic(); 108 DrawObjectN (graphic, graph, &graph[0].objects[graph[0].Nobjects-1]); 109 FlushDisplay (); 110 } else { 111 Refresh (); 112 } 113 } 109 114 110 115 return (TRUE); -
branches/eam_branches/ohana.20190329/src/kapa2/src/PNGit.c
r39457 r40731 98 98 png_write_info (png_ptr, info_ptr); 99 99 100 if (graphic->smooth_sigma == 0.0) { 101 fprintf (stderr, "making PNG without antialias smoothing\n"); 102 fprintf (stderr, "use 'antialias (value)' to set smoothing scale (0.4 - 0.7 recommended)\n"); 103 } 104 100 105 if (haveImage) { 101 106 buffer = bDrawIt (palette, Npalette, 3); … … 109 114 110 115 bDrawBufferFree (buffer); 116 free (palette); 117 111 118 fclose (f); 112 119 return (TRUE); -
branches/eam_branches/ohana.20190329/src/kapa2/src/Refresh.c
r36833 r40731 1 1 # include "Ximage.h" 2 2 3 void bDrawXimage (bDrawBuffer *buffer); 4 void Refresh_Buffered (void); 5 void Refresh_Unbuffered (void); 6 3 7 void Refresh (void) { 8 Refresh_Buffered(); 9 } 10 11 void Refresh_Buffered (void) { 12 13 int Npalette; 14 Graphic *graphic; 15 16 if (!USE_XWINDOW) return; 17 // if (HAVE_BACKING) return; 18 19 graphic = GetGraphic(); 20 21 // limit the png window to the min needed to contain the active graphic regions 22 SectionMinBoundary (graphic); 23 24 // is the palette reasonable in modern context? 25 png_color *palette = KapaPNGPalette (&Npalette); 26 27 bDrawBuffer *buffer = bDrawIt (palette, Npalette, 3); 28 29 /* XClearWindow (graphic.display, graphic.window); */ 30 XSetForeground (graphic->display, graphic->gc, graphic->back); 31 XFillRectangle (graphic->display, graphic->window, graphic->gc, 0, 0, graphic->dx, graphic->dy); 32 XSetForeground (graphic->display, graphic->gc, graphic->fore); 33 34 // copy buffer to Xwindow as image? 35 bDrawXimage (buffer); 36 37 // draw image tool for all sections 38 int Nsection = GetNumberOfSections (); 39 for (int i = 0; i < Nsection; i++) { 40 Section *section = GetSectionByNumber (i); 41 DrawImageTool (section->image); 42 } 43 FlushDisplay (); 44 } 45 46 void Refresh_Unbuffered (void) { 4 47 5 48 int i, Nsection; -
branches/eam_branches/ohana.20190329/src/kapa2/src/SetUpGraphic.c
r39532 r40731 51 51 CheckColors (graphic, argc, argv); 52 52 53 graphic->smooth_sigma = 0.0; 53 54 54 55 icon.width = icon_width; … … 84 85 } 85 86 87 int SetSmoothSigma (int sock) { 88 89 float sigma; 90 KiiScanMessage (sock, "%f", &sigma); 91 92 if (isfinite(sigma)) { 93 if ((sigma < 10.0) && (sigma >= 0.0)) { 94 graphic->smooth_sigma = sigma; 95 } 96 } 97 return TRUE; 98 } -
branches/eam_branches/ohana.20190329/src/kapa2/src/bDrawImage.c
r34088 r40731 1 1 # include "Ximage.h" 2 3 // XXX for the moment, this function does NOT set the mask bits. 4 // since we lay graphics on top of images, this is OK for now 2 5 3 6 # define WHITE_R 255 … … 54 57 55 58 // the created buffer is supposed to contain the output windows 59 if (Xs < 0) { 60 fprintf (stderr, "image display boundaries out of range of window (invalid condition) : fix Kapa\n"); 61 abort(); 62 } 56 63 if (buffer[0].Nx < Xs + dx) { 57 fprintf (stderr, "invalid condition\n"); 64 fprintf (stderr, "image display boundaries out of range of window (invalid condition) : fix Kapa\n"); 65 abort(); 66 } 67 if (Ys < 0) { 68 fprintf (stderr, "image display boundaries out of range of window (invalid condition) : fix Kapa\n"); 58 69 abort(); 59 70 } 60 71 if (buffer[0].Ny < Ys + dy) { 61 fprintf (stderr, "i nvalid condition\n");72 fprintf (stderr, "image display boundaries out of range of window (invalid condition) : fix Kapa\n"); 62 73 abort(); 63 74 } … … 153 164 154 165 return (TRUE); 166 } 167 168 void bDrawXimage (bDrawBuffer *buffer) { 169 170 Graphic *graphic = GetGraphic (); 171 172 ALLOCATE_PTR (data, char, 4*buffer->Nx*buffer->Ny); 173 174 for (int iy = 0; iy < buffer->Ny; iy++) { 175 for (int ix = 0; ix < buffer->Nx; ix++) { 176 data[4*(iy*buffer->Nx + ix) + 0] = buffer->pixels[iy][3*ix + 2]; 177 data[4*(iy*buffer->Nx + ix) + 1] = buffer->pixels[iy][3*ix + 1]; 178 data[4*(iy*buffer->Nx + ix) + 2] = buffer->pixels[iy][3*ix + 0]; 179 data[4*(iy*buffer->Nx + ix) + 3] = 0; 180 } 181 } 182 183 XImage *pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, 184 data, buffer->Nx, buffer->Ny, 32, 0); 185 186 XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc, pix, 0, 0, 1, 1, buffer->Nx, buffer->Ny); 155 187 } 156 188 -
branches/eam_branches/ohana.20190329/src/kapa2/src/bDrawIt.c
r40558 r40731 3 3 bDrawBuffer *bDrawIt (png_color *palette, int Npalette, int Nbyte) { 4 4 5 int i, j, Nsection; 6 bDrawBuffer *buffer; 7 bDrawColor black; 8 Graphic *graphic; 9 Section *section; 5 Graphic *graphic = GetGraphic(); 6 bDrawColor black = KapaColorByName ("black"); 10 7 11 graphic = GetGraphic(); 8 // get the number of sections 9 int Nsection = GetNumberOfSections (); 12 10 13 black = KapaColorByName ("black"); 11 // in order to allow the anti-aliasing to affect the text & graphs but not the images 12 // I need to generate the images in one buffer and the graphs in a second buffer 13 // then merge the two buffers. 14 14 15 // if we want to trim, we'll need to carry about the start in graphic coords and 16 // the dx,dy size. 17 buffer = bDrawBufferCreate (graphic->dxwin, graphic->dywin, Nbyte, palette, Npalette); 18 bDrawSetStyle (buffer, black, 0, 0, 1.0); 15 // base will hold the images 16 bDrawBuffer *base = bDrawBufferCreate (graphic->dxwin, graphic->dywin, Nbyte, palette, Npalette); 17 bDrawSetStyle (base, black, 0, 0, 1.0); 19 18 20 // reset the sizes for all sections 21 Nsection = GetNumberOfSections (); 22 for (i = 0; i < Nsection; i++) { 23 section = GetSectionByNumber (i); 24 bDrawImage (buffer, section->image, graphic); 25 for (j = 0; section->image && (j < NOVERLAYS); j++) { 26 if (section->image->overlay[j].active) bDrawOverlay (buffer, section->image, j); 27 } 28 bDrawGraph (buffer, section->graph); 19 for (int i = 0; i < Nsection; i++) { 20 Section *section = GetSectionByNumber (i); 21 bDrawImage (base, section->image, graphic); 29 22 } 30 23 31 return (buffer); 24 // graph will hold the graphic overlay 25 bDrawBuffer *graph = bDrawBufferCreate (graphic->dxwin, graphic->dywin, Nbyte, palette, Npalette); 26 bDrawSetStyle (graph, black, 0, 0, 1.0); 27 28 for (int i = 0; i < Nsection; i++) { 29 Section *section = GetSectionByNumber (i); 30 for (int j = 0; section->image && (j < NOVERLAYS); j++) { 31 if (section->image->overlay[j].active) bDrawOverlay (graph, section->image, j); 32 } 33 bDrawGraph (graph, section->graph); 34 } 35 36 // apply anti-aliasing only to the graph 37 if (graphic->smooth_sigma > 0.0) { 38 bDrawSmooth (graph, graphic->smooth_sigma); 39 } 40 41 // place graph on base 42 bDrawMerge (base, graph); 43 bDrawBufferFree (graph); 44 45 return (base); 32 46 } 33 47 -
branches/eam_branches/ohana.20190329/src/kapa2/src/bDrawObjects.c
r40570 r40731 9 9 # define OpenTriangle(BUF,X1,Y1,X2,Y2,X3,Y3) (bDrawTriOpen (BUF, (X1), (Y1), (X2), (Y2), (X3), (Y3))) 10 10 11 // I should not have a local static variable for this: 12 // I should just pass the graphic structure to the called functions below 11 13 static Graphic *graphic; 12 14
Note:
See TracChangeset
for help on using the changeset viewer.
