- Timestamp:
- Apr 20, 2020, 1:23:21 PM (6 years ago)
- Location:
- trunk/Ohana/src
- Files:
-
- 1 added
- 15 edited
-
kapa2/Makefile (modified) (1 diff)
-
kapa2/include/prototypes.h (modified) (1 diff)
-
kapa2/include/structures.h (modified) (2 diffs)
-
kapa2/src/DrawFrame.c (modified) (5 diffs)
-
kapa2/src/Graphs.c (modified) (1 diff)
-
kapa2/src/LoadFrame.c (modified) (1 diff)
-
kapa2/src/PDF_Frame.c (modified) (1 diff)
-
kapa2/src/PSFrame.c (modified) (2 diffs)
-
kapa2/src/PSit.c (modified) (1 diff)
-
kapa2/src/SetGraphData.c (modified) (1 diff)
-
kapa2/src/SetGraphSize.c (modified) (4 diffs)
-
kapa2/src/TickMarks.c (added)
-
kapa2/src/bDrawFrame.c (modified) (3 diffs)
-
libdvo/include/get_graphdata.h (modified) (1 diff)
-
libkapa/src/KapaWindow.c (modified) (4 diffs)
-
opihi/cmd.data/box.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kapa2/Makefile
r41341 r41344 68 68 $(SRC)/DrawObjects.$(ARCH).o $(SRC)/DrawFrame.$(ARCH).o \ 69 69 $(SRC)/DrawTextlines.$(ARCH).o $(SRC)/DrawLabels.$(ARCH).o \ 70 $(SRC)/MemoryDump.$(ARCH).o \70 $(SRC)/MemoryDump.$(ARCH).o $(SRC)/TickMarks.$(ARCH).o \ 71 71 $(SRC)/PNGit.$(ARCH).o $(SRC)/PPMit.$(ARCH).o \ 72 72 $(SRC)/CheckPipe.$(ARCH).o $(SRC)/EventLoop.$(ARCH).o \ -
trunk/Ohana/src/kapa2/include/prototypes.h
r41341 r41344 49 49 void DrawYErrors PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects)); 50 50 void DrawTick PROTO((Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis)); 51 52 /* TickMark functions */ 51 53 void AxisTickScale PROTO((Axis *axis, double *range, double *major, double *minor, int *nsignif)); 52 54 TickMarkData *CreateAxisTicks PROTO((Axis *axis, int *nticks)); 53 int PrintTick PROTO((char *string, double value, double min, double max, int nsignif));55 int PrintTick PROTO((char *string, TickMarkData *tick, double min, double max)); 54 56 55 57 /* EventLoop */ -
trunk/Ohana/src/kapa2/include/structures.h
r41341 r41344 157 157 158 158 typedef struct { 159 char format[16]; 159 160 double min, max; 160 161 char isaxis, areticks, islabel, islog; … … 169 170 // structure to describe the ticks for an axis 170 171 typedef struct { 172 char format[16]; 171 173 double value; 172 174 int IsMajor; -
trunk/Ohana/src/kapa2/src/DrawFrame.c
r40118 r41344 58 58 } 59 59 60 int PrintTick (char *string, double value, double min, double max, int nsignif) {61 62 int Nexp = 0;63 int Nchar = 0;64 65 if (fabs(value/(max-min)) < 0.001) {66 value = 0.0;67 Nchar = sprintf (string, "%.1f", value);68 return Nchar;69 }70 71 // double lvalue = log10(fabs(value));72 // if (isfinite(lvalue)) {73 // Nexp = fabs(lvalue);74 // } else {75 // Nexp = 0;76 // }77 78 Nexp = abs(nsignif);79 80 if (Nexp > 3) {81 Nchar = sprintf (string, "%.1e", value);82 } else {83 if (nsignif < 0) {84 char format[16];85 snprintf (format, 16, "%%.%df", -1 * nsignif);86 Nchar = sprintf (string, format, value);87 } else {88 Nchar = sprintf (string, "%.1f", value);89 }90 }91 return Nchar;92 }93 94 60 void DrawTick (Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis) { 95 61 … … 118 84 dir = ((naxis == 0) || (naxis == 3)) ? -1 : +1; 119 85 120 x = fx + (value -min)*dfx/(max - min);121 y = fy + (value -min)*dfy/(max - min);86 x = fx + (value - min)*dfx/(max - min); 87 y = fy + (value - min)*dfy/(max - min); 122 88 123 89 dy = 0; … … 153 119 if (naxis == 3) { dy = 0; dx = +0.5*pad; pos = 5; } // right, center justified 154 120 155 xt = fx + (value -min)*dfx/(max - min) + dx;156 yt = fy + (value -min)*dfy/(max - min) + dy;157 158 PrintTick (string, value, min, max, tick->nsignif);121 xt = fx + (value - min)*dfx/(max - min) + dx; 122 yt = fy + (value - min)*dfy/(max - min) + dy; 123 124 PrintTick (string, tick, min, max); 159 125 DrawRotText (xt, yt, string, pos, 0.0); 160 126 } … … 254 220 if (naxis == 3) { dy = 0; dx = +0.5*pad; pos = 5; } // right, center justified 255 221 256 xt = fx + (value -min)*dfx/(max - min) + dx;257 yt = fy + (value -min)*dfy/(max - min) + dy;258 259 PrintTick (string, value, min, max, tick->nsignif);222 xt = fx + (value - min)*dfx/(max - min) + dx; 223 yt = fy + (value - min)*dfy/(max - min) + dy; 224 225 PrintTick (string, tick, min, max); 260 226 DrawRotText (xt, yt, string, pos, 0.0); 261 227 } … … 263 229 # endif 264 230 265 // do I really want this? allow an override?266 # define MIN_RANGE 1e-30267 268 void AxisTickScale (Axis *axis, double *range, double *major, double *minor, int *nsignif) {269 270 double lrange, factor, mantis, fmantis, power;271 272 *range = axis->fLabelRange*(axis[0].max - axis[0].min);273 if (fabs(*range) < MIN_RANGE) {274 *range = (*range < 0) ? -MIN_RANGE : +MIN_RANGE;275 }276 277 lrange = log10(MAX(fabs(*range), MIN_RANGE));278 double truncRange = ((int) ((lrange + 0.005) * 1000)) / 1000.0;279 lrange = truncRange;280 281 mantis = modf (lrange, &factor);282 if (mantis < 0.0) {283 mantis += 1.0;284 factor -= 1.0;285 }286 287 // how many significant digits are needed?288 289 power = MAX(pow(10.0, factor), MIN_RANGE);290 fmantis = pow(10.0, mantis);291 *major = MAX(0.5 * power, MIN_RANGE);292 *minor = MAX(0.1 * power, MIN_RANGE);293 294 if ((fmantis >= 1.0) && (fmantis < 1.999)) {295 *major = 0.5 * power;296 *nsignif = factor - 1;297 if (axis[0].areticks == 1) {298 *major = 0.25 * power;299 *nsignif = factor - 2;300 }301 if (axis[0].areticks == 3) {302 *major = 1.0 * power;303 *nsignif = factor - 1;304 }305 }306 if ((fmantis >= 1.999) && (fmantis < 3.999)) {307 *major = 1.0 * power;308 *nsignif = factor;309 if (axis[0].areticks == 1) {310 *major = 0.5 * power;311 *nsignif = factor - 1;312 }313 if (axis[0].areticks == 3) {314 *major = 2.0 * power;315 *nsignif = factor;316 }317 }318 if ((fmantis >= 3.999) && (fmantis < 5.999)) {319 *major = 1.0 * power;320 *nsignif = factor;321 if (axis[0].areticks == 1) {322 *major = 1.0 * power;323 *nsignif = factor;324 }325 if (axis[0].areticks == 3) {326 *major = 2.0 * power;327 *nsignif = factor;328 }329 }330 if ((fmantis >= 5.999) && (fmantis < 7.999)) {331 *major = 2.0 * power;332 *nsignif = factor;333 if (axis[0].areticks == 1) {334 *major = 1.0 * power;335 *nsignif = factor;336 }337 if (axis[0].areticks == 3) {338 *major = 4.0 * power;339 *nsignif = factor;340 }341 }342 if ((fmantis >= 7.999) && (fmantis < 10.000)) {343 *major = 2.5 * power;344 *nsignif = factor - 1;345 if (axis[0].areticks == 1) {346 *major = 2.0 * power;347 *nsignif = factor;348 }349 if (axis[0].areticks == 3) {350 *major = 4.0 * power;351 *nsignif = factor;352 }353 }354 *minor = *major / axis->fMinor;355 }356 357 TickMarkData *CreateAxisTicks (Axis *axis, int *nticks) {358 359 TickMarkData *ticks;360 double range, major, minor, first, value;361 int i, NTICKS, done, nsignif;362 363 *nticks = 0;364 365 if (isnan(axis->min) || isinf(axis->min)) return NULL;366 if (isnan(axis->max) || isinf(axis->max)) return NULL;367 368 // length of the axis in pixels369 // int nPixels = hypot(axis->dfx, axis->dfy);370 // double dPixels = nPixels / range; // axis pixel-scale371 372 AxisTickScale (axis, &range, &major, &minor, &nsignif);373 374 // be a little generous375 NTICKS = (int)(fabs(range / minor)) + 2;376 ALLOCATE (ticks, TickMarkData, NTICKS);377 378 // value of the first tick mark (near axis->min)379 double minValue = axis->min / minor;380 int ifirst = (int) minValue;381 382 if ((axis->min > 0.0) && (minValue - ifirst > +0.1)) {383 ifirst ++;384 }385 if ((axis->min < 0.0) && (minValue - ifirst < -0.1)) {386 ifirst --;387 }388 first = minor*ifirst;389 390 // only write the labels for the inner fRange of the axies391 double minLabelValue = 0.5*(1.0 - 1.001*axis->fLabelRange)*(axis->max - axis->min) + axis->min;392 double maxLabelValue = 0.5*(1.0 + 1.001*axis->fLabelRange)*(axis->max - axis->min) + axis->min;393 394 // loop to find the ticks395 done = FALSE;396 value = first;397 for (i = 0; !done && (i < NTICKS); i++) {398 ticks[i].IsMajor = FALSE;399 ticks[i].IsMajor |= (fabs((int)(value/major) - (value/major)) < 0.5*(minor/major));400 ticks[i].IsMajor |= (fabs((int)((value + 0.5*minor)/major) - (value/major)) < 0.5*(minor/major));401 ticks[i].IsMajor |= (fabs((int)((value - 0.5*minor)/major) - (value/major)) < 0.5*(minor/major));402 int inLabelRange = (range > 0) ? (value >= minLabelValue) && (value <= maxLabelValue) : (value <= minLabelValue) && (value >= maxLabelValue);403 ticks[i].IsLabel = inLabelRange && ticks[i].IsMajor && axis->islabel;404 ticks[i].value = value;405 ticks[i].nsignif = nsignif;406 if (range > 0)407 value += minor;408 else409 value -= minor;410 411 done |= (range > 0) && (value > axis->max + 0.1*minor);412 done |= (range < 0) && (value < axis->max - 0.1*minor);413 // fprintf (stderr, "%d : %f %f %f %f\n", done, range, value, axis->max, 0.1*minor);414 }415 416 *nticks = i;417 return (ticks);418 } -
trunk/Ohana/src/kapa2/src/Graphs.c
r39652 r41344 25 25 graph[0].axis[i].fLabelRange = 1.0; 26 26 graph[0].axis[i].fMinor = 5.0; 27 memset (graph[0].axis[i].format, 0, 16); 27 28 } 28 29 -
trunk/Ohana/src/kapa2/src/LoadFrame.c
r41341 r41344 46 46 graph[0].axis[2].fMinor = graph[0].data.fMinorXp; 47 47 graph[0].axis[3].fMinor = graph[0].data.fMinorYp; 48 49 strcpy (graph[0].axis[0].format, graph[0].data.formatXm); 50 strcpy (graph[0].axis[1].format, graph[0].data.formatYm); 51 strcpy (graph[0].axis[2].format, graph[0].data.formatXp); 52 strcpy (graph[0].axis[3].format, graph[0].data.formatYp); 48 53 49 54 for (i = 0; i < 4; i++) { -
trunk/Ohana/src/kapa2/src/PDF_Frame.c
r41341 r41344 130 130 yt = fy + (value-min)*dfy/(max - min) + dy; 131 131 132 // PrintTick write the characters into the string133 PrintTick (string, value, min, max, tick->nsignif);132 // PrintTick writes the characters into the string 133 PrintTick (string, tick, min, max); 134 134 PDFRotText (buffer, xt, yt, string, pos, 0.0); 135 135 } -
trunk/Ohana/src/kapa2/src/PSFrame.c
r40118 r41344 122 122 yt = fy + (value-min)*dfy/(max - min) + dy; 123 123 124 PrintTick (string, value, min, max, tick->nsignif);124 PrintTick (string, tick, min, max); 125 125 PSRotText (f, xt, yt, string, pos, 0.0); 126 126 } … … 198 198 yt = fy + (value-min)*dfy/(max - min) + dy; 199 199 200 PrintTick (string, value, min, max, tick->nsignif);200 PrintTick (string, tick, min, max); 201 201 PSRotText (f, xt, yt, string, pos, 0.0); 202 202 } -
trunk/Ohana/src/kapa2/src/PSit.c
r31665 r41344 1 1 # include "Ximage.h" 2 # define XOFFSET 603 # define YOFFSET 602 # define XOFFSET 0 3 # define YOFFSET 0 4 4 5 5 static char *name = "$Name: not supported by cvs2svn $"; -
trunk/Ohana/src/kapa2/src/SetGraphData.c
r38986 r41344 37 37 graph[0].axis[2].fMinor = graph[0].data.fMinorXp; 38 38 graph[0].axis[3].fMinor = graph[0].data.fMinorYp; 39 40 strcpy (graph[0].axis[0].format, graph[0].data.formatXm); 41 strcpy (graph[0].axis[1].format, graph[0].data.formatYm); 42 strcpy (graph[0].axis[2].format, graph[0].data.formatXp); 43 strcpy (graph[0].axis[3].format, graph[0].data.formatYp); 39 44 40 45 graph[0].axis[0].pad = graph[0].data.padXm; -
trunk/Ohana/src/kapa2/src/SetGraphSize.c
r38465 r41344 100 100 GetRotFont (&fontsize); 101 101 102 // labelPad (min -> no labels, max -> yes labels) 103 // XXX change these defaults 102 104 minPAD = 1.0*fontsize + 0; 103 105 maxPAD = 2.0*fontsize + 4; … … 140 142 // these depend on (a) existence of tick labels and (b) auto-offset or not. 141 143 // in the auto-offset case, offset depends on the width of the tick label strings 144 // because the y-axis labels are horizontal, the length matters 142 145 if (graph[0].axis[1].islabel && (isnan(graph[0].axis[1].labelPad) || isnan(graph[0].axis[1].pad))) { 143 146 /* check for the max size of the axis label */ … … 146 149 for (i = 0; i < Nticks; i++) { 147 150 if (!ticks[i].IsMajor) continue; 148 149 int Nchar = PrintTick (string, ticks[i].value, graph[0].axis[1].min, graph[0].axis[1].max, ticks[i].nsignif); 150 151 int Nchar = PrintTick (string, &ticks[i], graph[0].axis[1].min, graph[0].axis[1].max); 151 152 Nc = MAX (Nc, Nchar); 152 153 } … … 172 173 for (i = 0; i < Nticks; i++) { 173 174 if (!ticks[i].IsMajor) continue; 174 int Nchar = PrintTick (string, ticks[i].value, graph[0].axis[3].min, graph[0].axis[3].max, ticks[i].nsignif);175 int Nchar = PrintTick (string, &ticks[i], graph[0].axis[3].min, graph[0].axis[3].max); 175 176 Nc = MAX (Nc, Nchar); 176 177 } -
trunk/Ohana/src/kapa2/src/bDrawFrame.c
r40558 r41344 87 87 dir = ((naxis == 0) || (naxis == 3)) ? -1 : +1; 88 88 89 x = fx + (value -min)*dfx/(max - min);90 y = fy + (value -min)*dfy/(max - min);89 x = fx + (value - min)*dfx/(max - min); 90 y = fy + (value - min)*dfy/(max - min); 91 91 92 92 dx = 0; … … 121 121 if (naxis == 3) { dy = 0; dx = +pad; pos = 5; } 122 122 123 xt = fx + (value -min)*dfx/(max - min) + dx;124 yt = fy + (value -min)*dfy/(max - min) + dy;123 xt = fx + (value - min)*dfx/(max - min) + dx; 124 yt = fy + (value - min)*dfy/(max - min) + dy; 125 125 126 PrintTick (string, value, min, max, tick->nsignif);126 PrintTick (string, tick, min, max); 127 127 bDrawRotText (buffer, xt, yt, string, pos, 0.0); 128 128 } … … 190 190 yt = fy + (value-min)*dfy/(max - min) + dy; 191 191 192 PrintTick (string, value, min, max, tick->nsignif);192 PrintTick (string, tick, min, max); 193 193 bDrawRotText (buffer, xt, yt, string, pos, 0.0); 194 194 } -
trunk/Ohana/src/libdvo/include/get_graphdata.h
r40571 r41344 16 16 int flipeast, flipnorth; 17 17 char axis[8], labels[8], ticks[8]; 18 char formatXm[16], formatXp[16], formatYm[16], formatYp[16]; 18 19 } Graphdata; 19 20 -
trunk/Ohana/src/libkapa/src/KapaWindow.c
r41341 r41344 88 88 } 89 89 90 // XXX drop this function? : kapa is responsible for the graph initialization90 // called in kapa2/src/Graphs.c to init the graph 91 91 int KapaInitGraph (Graphdata *graphdata) { 92 92 … … 109 109 strcpy (graphdata[0].labels, "2222"); 110 110 111 strcpy (graphdata[0].formatXm, "auto"); 112 strcpy (graphdata[0].formatXp, "auto"); 113 strcpy (graphdata[0].formatYm, "auto"); 114 strcpy (graphdata[0].formatYp, "auto"); 115 111 116 graphdata[0].ticktextPad = NAN; 112 117 … … 182 187 data[0].fMinorYm, data[0].fMinorYp); 183 188 189 KiiSendMessage (fd, "%s %s %s %s", 190 data[0].formatXm, data[0].formatXp, 191 data[0].formatYm, data[0].formatYp); 192 184 193 KiiSendMessage (fd, "%g %g %g %g ", 185 194 data[0].coords.pc1_1, data[0].coords.pc2_2, … … 232 241 &data[0].fMinorXm, &data[0].fMinorXp, 233 242 &data[0].fMinorYm, &data[0].fMinorYp); 243 244 KiiScanMessage (fd, "%s %s %s %s", 245 data[0].formatXm, data[0].formatXp, 246 data[0].formatYm, data[0].formatYp); 234 247 235 248 KiiScanMessage (fd, "%f %f %f %f", -
trunk/Ohana/src/opihi/cmd.data/box.c
r38986 r41344 200 200 } 201 201 202 if ((N = get_argument (argc, argv, "-format"))) { 203 remove_argument (N, &argc, argv); 204 if (strlen (argv[N]) > 15) { goto usage; } 205 strcpy (graphmode.formatXm, argv[N]); 206 strcpy (graphmode.formatXp, argv[N]); 207 strcpy (graphmode.formatYm, argv[N]); 208 strcpy (graphmode.formatYp, argv[N]); 209 remove_argument (N, &argc, argv); 210 } 211 212 if ((N = get_argument (argc, argv, "-xformat"))) { 213 remove_argument (N, &argc, argv); 214 if (strlen (argv[N]) > 15) { goto usage; } 215 strcpy (graphmode.formatXm, argv[N]); 216 remove_argument (N, &argc, argv); 217 } 218 219 if ((N = get_argument (argc, argv, "-yformat"))) { 220 remove_argument (N, &argc, argv); 221 if (strlen (argv[N]) > 15) { goto usage; } 222 strcpy (graphmode.formatYm, argv[N]); 223 remove_argument (N, &argc, argv); 224 } 225 226 if ((N = get_argument (argc, argv, "+xformat"))) { 227 remove_argument (N, &argc, argv); 228 if (strlen (argv[N]) > 15) { goto usage; } 229 strcpy (graphmode.formatXp, argv[N]); 230 remove_argument (N, &argc, argv); 231 } 232 233 if ((N = get_argument (argc, argv, "+yformat"))) { 234 remove_argument (N, &argc, argv); 235 if (strlen (argv[N]) > 15) { goto usage; } 236 strcpy (graphmode.formatYm, argv[N]); 237 remove_argument (N, &argc, argv); 238 } 239 202 240 if (argc != 1) goto usage; 203 241
Note:
See TracChangeset
for help on using the changeset viewer.
