Changeset 29410
- Timestamp:
- Oct 14, 2010, 2:07:33 PM (16 years ago)
- Location:
- branches/eam_branches/ipp-20100823/Ohana/src/kapa2
- Files:
-
- 17 edited
-
doc/notes.txt (modified) (1 diff)
-
include/prototypes.h (modified) (1 diff)
-
include/structures.h (modified) (1 diff)
-
src/DrawFrame.c (modified) (2 diffs)
-
src/DrawObjects.c (modified) (4 diffs)
-
src/EraseCurrentPlot.c (modified) (1 diff)
-
src/EraseImage.c (modified) (1 diff)
-
src/Graphs.c (modified) (3 diffs)
-
src/LoadFrame.c (modified) (1 diff)
-
src/LoadLabels.c (modified) (1 diff)
-
src/LoadObject.c (modified) (1 diff)
-
src/LoadTextlines.c (modified) (1 diff)
-
src/PNGit.c (modified) (2 diffs)
-
src/PSFrame.c (modified) (1 diff)
-
src/SetGraphSize.c (modified) (4 diffs)
-
src/SetImageSize.c (modified) (11 diffs)
-
src/bDrawFrame.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/doc/notes.txt
r27790 r29410 1 2 2010.10.14 3 4 * dX,dY = window size, Xs, Ys = corner of image 5 6 * PAD1 = 3 (gap between elements) 7 * PAD2 = 5 (alternate gap) 8 * COLORPAD = 10 (thickness of colorbar) 9 * WdY = MAX (ZOOM_Y, textdY + 2*BUTTON_HEIGHT + PAD1) : height of zoom box or text box + buttons 1 10 2 11 2010.04.14 -
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/include/prototypes.h
r29214 r29410 42 42 void AxisTickScale PROTO((Axis *axis, double *major, double *minor)); 43 43 TickMarkData *CreateAxisTicks PROTO((Axis *axis, int *nticks)); 44 int PrintTick PROTO((char *string, double value, double min, double max)); 44 45 45 46 /* EventLoop */ -
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/include/structures.h
r29214 r29410 161 161 Label *textline; /* placed text labels */ 162 162 int Ntextline; 163 int haveGraph; // is there anything in the plot window? 163 164 } KapaGraphWidget; 164 165 -
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/DrawFrame.c
r29013 r29410 43 43 } 44 44 45 int PrintTick (char *string, double value, double min, double max) { 46 47 int Nexp = 0; 48 int Nchar = 0; 49 50 if (fabs(value/(max-min)) < 0.001) { 51 value = 0.0; 52 Nchar = sprintf (string, "%.1f", value); 53 return Nchar; 54 } 55 56 double lvalue = log10(fabs(value)); 57 58 if (isfinite(lvalue)) { 59 Nexp = fabs(lvalue); 60 } else { 61 Nexp = 0; 62 } 63 64 if (Nexp > 3) { 65 Nchar = sprintf (string, "%.1e", value); 66 } else { 67 Nchar = sprintf (string, "%.1f", value); 68 } 69 return Nchar; 70 } 71 45 72 void DrawTick (Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis) { 46 73 … … 101 128 xt = fx + (value-min)*dfx/(max - min) + dx; 102 129 yt = fy + (value-min)*dfy/(max - min) + dy; 103 if (fabs(value/(max-min)) < 0.001) { value = 0.0; } 104 sprintf (string, "%4g", value);130 131 PrintTick (string, value, min, max); 105 132 DrawRotText (xt, yt, string, pos, 0.0); 106 133 } -
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/DrawObjects.c
r27530 r29410 517 517 } 518 518 if (object[0].ptype == 100) { /* connect a pair of points */ 519 520 double X0 = graph[0].axis[0].fx; 521 double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx; 522 double Y0 = graph[0].axis[1].fy; 523 double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy; 524 519 525 for (i = 0; i + 1 < object[0].Npts; i+=2) { 520 526 if (!(finite(x[i]) && finite(y[i]))) continue; … … 524 530 sx2 = x[i+1]*mxi + y[i+1]*mxj + bx; 525 531 sy2 = x[i+1]*myi + y[i+1]*myj + by; 526 DrawLine (sx1, sy1, sx2, sy2);532 ClipLine (sx1, sy1, sx2, sy2, X0, Y0, X1, Y1); 527 533 } 528 534 } … … 674 680 } 675 681 if (object[0].ptype == 100) { 682 double X0 = graph[0].axis[0].fx; 683 double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx; 684 double Y0 = graph[0].axis[1].fy; 685 double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy; 686 676 687 for (i = 0; i + 1 < object[0].Npts; i+=2) { 677 688 if (!(finite(x[i]) && finite(y[i]))) continue; … … 680 691 sx2 = x[i+1]*mxi + y[i+1]*mxj + bx; 681 692 sy2 = x[i+1]*myi + y[i+1]*myj + by; 682 DrawLine (sx1, sy1, sx2, sy2);693 ClipLine (sx1, sy1, sx2, sy2, X0, Y0, X1, Y1); 683 694 } 684 695 } -
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/EraseCurrentPlot.c
r21153 r29410 15 15 16 16 if (USE_XWINDOW) XClearWindow (graphic->display, graphic->window); 17 18 SetSectionSizes (section); 17 19 Refresh (); 18 20 -
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/EraseImage.c
r14590 r29410 15 15 section->image = NULL; 16 16 17 if (USE_XWINDOW) Refresh (); 17 if (USE_XWINDOW) XClearWindow (graphic->display, graphic->window); 18 19 SetSectionSizes (section); 20 Refresh (); 18 21 return (TRUE); 19 22 } -
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/Graphs.c
r27790 r29410 8 8 9 9 ALLOCATE (graph, KapaGraphWidget, 1); 10 11 graph[0].haveGraph = FALSE; 10 12 11 13 /* set up axis positions */ … … 82 84 void DrawGraph (KapaGraphWidget *graph) { 83 85 if (graph == NULL) return; 86 if (!graph[0].haveGraph) return; 87 84 88 DrawFrame (graph); 85 89 DrawObjects (graph); … … 94 98 95 99 if (graph == NULL) return; 100 graph[0].haveGraph = FALSE; 96 101 97 102 /* free data objects, then re-alloc those needed */ -
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/LoadFrame.c
r27790 r29410 15 15 16 16 KapaScanGraphData (sock, &graph[0].data); 17 18 // even if we have no actual elements, once we define a frame, we have a graph 19 graph[0].haveGraph = TRUE; 17 20 18 21 graph[0].axis[3].min = graph[0].axis[1].min; -
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/LoadLabels.c
r17466 r29410 14 14 } 15 15 graph = section->graph; 16 16 graph[0].haveGraph = TRUE; 17 17 18 KiiScanMessage (sock, "%d", &mode); 18 19 label = KiiRecvData (sock); -
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/LoadObject.c
r27486 r29410 15 15 } 16 16 graph = section->graph; 17 graph[0].haveGraph = TRUE; 17 18 18 19 N = graph[0].Nobjects; -
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/LoadTextlines.c
r19830 r29410 11 11 section = GetActiveSection(); 12 12 graph = section->graph; 13 if (section->graph == NULL) {13 if (section->graph == NULL) { 14 14 section->graph = InitGraph (); 15 15 SetSectionSizes (section); 16 16 graph = section->graph; 17 17 } 18 graph[0].haveGraph = TRUE; 18 19 19 20 graph[0].Ntextline = MAX (graph[0].Ntextline, 0); -
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/PNGit.c
r27600 r29410 15 15 png_structp png_ptr; 16 16 png_infop info_ptr; 17 int Npalette;17 int status, Npalette; 18 18 char filename[1024]; 19 19 bDrawBuffer *buffer = NULL; … … 47 47 } 48 48 49 if (setjmp (png_ptr[0].jmpbuf)) { 49 #ifdef png_jmpbuf 50 status = setjmp(png_jmpbuf(png_ptr)); 51 # else 52 status = setjmp (png_ptr[0].jmpbuf); 53 # endif 54 55 if (status) { 50 56 fprintf (stderr, "can't get png return\n"); 51 57 png_destroy_write_struct (&png_ptr, &info_ptr); -
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/PSFrame.c
r28347 r29410 94 94 xt = fx + (value-min)*dfx/(max - min) + dx; 95 95 yt = fy + (value-min)*dfy/(max - min) + dy; 96 if (fabs(value) < 0.001) { value = 0.0; } 97 sprintf (string, "%4g", value);96 97 PrintTick (string, value, min, max); 98 98 PSRotText (f, xt, yt, string, pos, 0.0); 99 99 } -
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/SetGraphSize.c
r27902 r29410 72 72 for (i = 0; i < Nticks; i++) { 73 73 if (!ticks[i].IsMajor) continue; 74 sprintf (string, "%g", ticks[i].value); 75 Nc = MAX (Nc, strlen (string)); 74 75 int Nchar = PrintTick (string, ticks[i].value, graph[0].axis[1].min, graph[0].axis[1].max); 76 77 Nc = MAX (Nc, Nchar); 76 78 } 77 79 FREE(ticks); … … 96 98 for (i = 0; i < Nticks; i++) { 97 99 if (!ticks[i].IsMajor) continue; 98 sprintf (string, "%g", ticks[i].value);99 Nc = MAX (Nc, strlen (string));100 int Nchar = PrintTick (string, ticks[i].value, graph[0].axis[3].min, graph[0].axis[3].max); 101 Nc = MAX (Nc, Nchar); 100 102 } 101 103 FREE(ticks); … … 112 114 } 113 115 114 /* basic size of the graph in Xwindow coordinates */116 /* basic size of the graph in Xwindow coordinates, but measured from lower-left corner */ 115 117 X0 = graphic[0].dx * section[0].x + padYm; 116 118 Y0 = graphic[0].dy * section[0].y + padXm; … … 125 127 126 128 switch (section->image->location) { 129 case 0: 130 // no changes? 131 break; 127 132 case 1: 128 Y0 = graphic[0].dy * section[0].y + 2*PAD1 + WdY + 2; // tied to image in Y129 dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD + 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; 130 135 break; 131 136 case 3: 132 dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD - padYm - padYp;137 dY = graphic[0].dy * section[0].dy - padXm - padXp - 4*PAD1 - 1 - WdY - COLORPAD; 133 138 break; 134 139 case 2: 135 X0 = graphic[0].dx * section[0].x + 2*PAD1 + ZOOM_X; 136 dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X; 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; 137 143 break; 138 144 case 4: 139 dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X - padXm - padXp; 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; 140 147 break; 141 148 } -
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/SetImageSize.c
r29214 r29410 1 # include "Ximage.h"1 # include "Ximage.h" 2 2 3 3 /* Set the dimensions of the specific image based on the current window size. The image … … 9 9 int Xs, Ys, dX, dY; 10 10 int textpad, textdY, WdY; 11 int haveGraph; 11 12 KapaImageWidget *image; 12 13 KapaGraphWidget *graph; … … 17 18 if (image == NULL) return; 18 19 graph = section->graph; 20 haveGraph = graph && graph->haveGraph; 19 21 20 22 graphic = GetGraphic (); … … 33 35 34 36 case 0: // no zoom / status / wide 35 if ( section->graph) {37 if (haveGraph) { 36 38 image[0].picture.x = graph[0].axis[0].fx; 37 39 image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy; 38 image[0].picture.dx = MAX( graph[0].axis[0].dfx +1, 1);40 image[0].picture.dx = MAX(fabs(graph[0].axis[0].dfx) - 1, 1); 39 41 image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1); 40 42 } else { 41 43 image[0].picture.x = Xs + PAD1; 42 44 image[0].picture.y = Ys + PAD1; 43 image[0].picture.dx = dX - 2*PAD1 ;44 image[0].picture.dy = dY - 2*PAD1 ;45 image[0].picture.dx = dX - 2*PAD1 - 1; 46 image[0].picture.dy = dY - 2*PAD1 - 1; 45 47 } 46 48 if (USE_XWINDOW) CreatePicture (image, graphic); … … 48 50 return; 49 51 50 case 1: // zoom / status / wide on bottom 51 52 if ( section->graph) {53 image[0].picture.x = graph[0].axis[0].fx;54 image[0].picture.y = Ys + 2*PAD1 + COLORPAD;55 image[0].picture.dx = graph[0].axis[0].dfx;56 image[0].picture.dy = dY - 5*PAD1 - WdY - COLORPAD;57 } else { 58 image[0].picture.x = Xs + PAD1;59 image[0].picture.y = Ys + 2*PAD1 + COLORPAD;60 image[0].picture.dx = dX - 2*PAD1;61 image[0].picture.dy = dY - 5*PAD1 - WdY - COLORPAD;52 case 1: // zoom / status / wide on bottom (-x) 53 54 if (haveGraph) { 55 image[0].picture.x = graph[0].axis[0].fx; 56 image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy; 57 image[0].picture.dx = MAX(fabs(graph[0].axis[0].dfx) - 1, 1); 58 image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1); 59 } else { 60 image[0].picture.x = Xs + PAD1; 61 image[0].picture.y = Ys + 2*PAD1 + COLORPAD; 62 image[0].picture.dx = dX - 2*PAD1 - 1; 63 image[0].picture.dy = dY - 4*PAD1 - 1 - WdY - COLORPAD; 62 64 } 63 65 … … 72 74 image[0].zoom.dy = ZOOM_Y; 73 75 image[0].zoom.x = Xs + PAD1; 74 image[0].zoom.y = image[0].picture.y + image[0].picture.dy + PAD1;76 image[0].zoom.y = Ys + dY - PAD1 - WdY; 75 77 76 78 /** everything below is tied in x-dir to the zoom box **/ … … 130 132 break; 131 133 132 case 3: // zoom / status / wide on top 133 134 if ( section->graph) {134 case 3: // zoom / status / wide on top (+x) 135 136 if (haveGraph) { 135 137 image[0].picture.x = graph[0].axis[0].fx; 136 138 image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy; 137 image[0].picture.dx = MAX( graph[0].axis[0].dfx, 1);139 image[0].picture.dx = MAX(fabs(graph[0].axis[0].dfx) - 1, 1); 138 140 image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1); 139 141 } else { 140 image[0].picture.dx = dX - 2*PAD1;141 image[0].picture.dy = dY - 5*PAD1 - WdY - COLORPAD;142 142 image[0].picture.x = Xs + PAD1; 143 image[0].picture.y = Ys + 4*PAD1 + COLORPAD + WdY; 143 image[0].picture.y = Ys + 3*PAD1 + COLORPAD + WdY; 144 image[0].picture.dx = dX - 2*PAD1 - 1; 145 image[0].picture.dy = dY - 4*PAD1 - 1 - WdY - COLORPAD; 144 146 } 145 147 … … 212 214 break; 213 215 214 case 2: // zoom / status / wide on left 215 216 if ( section->graph) {217 image[0].picture.x = Xs + 2*PAD1 + ZOOM_X;216 case 2: // zoom / status / wide on left (-y) 217 218 if (haveGraph) { 219 image[0].picture.x = graph[0].axis[0].fx; 218 220 image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy; 219 image[0].picture.dx = dX - 3*PAD1 - ZOOM_X;221 image[0].picture.dx = MAX(fabs(graph[0].axis[0].dfx) - 1, 1); 220 222 image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1); 221 223 } else { 222 image[0].picture.dx = dX - 3*PAD1 - ZOOM_X;223 image[0].picture.dy = dY - 3*PAD1 - COLORPAD;224 224 image[0].picture.x = Xs + 2*PAD1 + ZOOM_X; 225 225 image[0].picture.y = Ys + 2*PAD1 + COLORPAD; 226 image[0].picture.dx = dX - 3*PAD1 - 1 - ZOOM_X; 227 image[0].picture.dy = dY - 3*PAD1 - 1 - COLORPAD; 226 228 } 227 229 … … 236 238 image[0].zoom.dy = ZOOM_Y; 237 239 image[0].zoom.x = Xs + PAD1; 238 image[0].zoom.y = image[0].picture.y;240 image[0].zoom.y = Ys + 2*PAD1 + COLORPAD; 239 241 240 242 /** everything below is tied in x-dir to the zoom box **/ … … 294 296 break; 295 297 296 case 4: // zoom / status / wide on right 297 298 if ( section->graph) {298 case 4: // zoom / status / wide on right (+y) 299 300 if (haveGraph) { 299 301 image[0].picture.x = graph[0].axis[0].fx; 300 302 image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy; 301 image[0].picture.dx = dX - 3*PAD1 - ZOOM_X - graph[0].axis[0].fx;303 image[0].picture.dx = MAX(fabs(graph[0].axis[0].dfx) - 1, 1); 302 304 image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1); 303 305 } else { 304 image[0].picture.dx = dX - 3*PAD1 - ZOOM_X;305 image[0].picture.dy = dY - 3*PAD1 - COLORPAD;306 306 image[0].picture.x = Xs + PAD1; 307 307 image[0].picture.y = Ys + 2*PAD1 + COLORPAD; 308 image[0].picture.dx = dX - 3*PAD1 - 1 - ZOOM_X; 309 image[0].picture.dy = dY - 3*PAD1 - 1 - COLORPAD; 308 310 } 309 311 … … 317 319 image[0].zoom.dx = ZOOM_X; 318 320 image[0].zoom.dy = ZOOM_Y; 319 image[0].zoom.x = image[0].picture.x + image[0].picture.dx +PAD1;320 image[0].zoom.y = image[0].picture.y;321 image[0].zoom.x = Xs + dX - ZOOM_X - PAD1; 322 image[0].zoom.y = Ys + 2*PAD1 + COLORPAD; 321 323 322 324 /** everything below is tied in x-dir to the zoom box **/ -
branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/bDrawFrame.c
r28347 r29410 93 93 xt = fx + (value-min)*dfx/(max - min) + dx; 94 94 yt = fy + (value-min)*dfy/(max - min) + dy; 95 if (fabs(value) < 0.001) { value = 0.0; } 96 sprintf (string, "%4g", value);95 96 PrintTick (string, value, min, max); 97 97 bDrawRotText (xt, yt, string, pos, 0.0); 98 98 }
Note:
See TracChangeset
for help on using the changeset viewer.
