Changeset 30606
- Timestamp:
- Feb 13, 2011, 11:15:38 AM (15 years ago)
- Location:
- trunk/Ohana/src/kapa2
- Files:
-
- 5 edited
-
include/prototypes.h (modified) (1 diff)
-
src/PSObjects.c (modified) (3 diffs)
-
src/UpdateStatusBox.c (modified) (5 diffs)
-
src/bDrawObjects.c (modified) (3 diffs)
-
src/hh_hms.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kapa2/include/prototypes.h
r29938 r30606 175 175 void DrawBitmap PROTO((Graphic *graphic, int x, int y, int dx, int dy, char *bitmap, int mode)); 176 176 void CrossHairs PROTO((Graphic *graphic, Picture *image)); 177 void hh_hms PROTO((char *line, double ra, double dec, char sep ));177 void hh_hms PROTO((char *line, double ra, double dec, char sep, int Nchar)); 178 178 179 179 int SetColormap PROTO((char *name)); -
trunk/Ohana/src/kapa2/src/PSObjects.c
r27530 r30606 164 164 float *x, *y; 165 165 double mxi, mxj, myi, myj, bxi, bxj, byi, byj, bx, by; 166 double sx0, sy0, sx1, sy1, sxa ;166 double sx0, sy0, sx1, sy1, sxa, sya, sxo, syo; 167 167 double X0, X1, Y0, Y1; 168 168 … … 189 189 for (i = 0; (i < object[0].Npts) && !(finite(x[i]) && finite(y[i])); i++); 190 190 if (i >= object[0].Npts) return; 191 192 /* first valid data point */ 193 sx0 = x[i]*mxi + y[i]*mxj + bx; 194 sy0 = x[i]*myi + y[i]*myj + by; 195 sx0 = MIN (MAX (sx0, X0), X1); 196 sy0 = MAX (MIN (sy0, Y0), Y1); 197 198 /* find the second valid datapoint */ 199 for (i++; (i < object[0].Npts) && !(finite(x[i]) && finite(y[i])); i++); 200 if (i >= object[0].Npts) return; 201 202 /* second valid data point */ 203 sx1 = x[i]*mxi + y[i]*mxj + bx; 204 sy1 = x[i]*myi + y[i]*myj + by; 205 sx1 = MIN (MAX (sx1, X0), X1); 206 sy1 = MAX (MIN (sy1, Y0), Y1); 207 208 /* connect first point to second point */ 209 sxa = sx0 - 0.5*(sx1 - sx0); 210 sya = MAX (sy0, Y0); 211 DrawLine (sx0, sy0, sxa, sy0); 212 DrawLine (sxa, sy0, sxa, sya); 213 214 /* draw segment equal distance behind first point and down to x-axis */ 215 sxa = 0.5*(sx0 + sx1); 216 DrawLine (sx0, sy0, sxa, sy0); 217 DrawLine (sxa, sy0, sxa, sy1); 218 DrawLine (sxa, sy1, sx1, sy1); 219 sx0 = sx1; 220 sy0 = sy1; 221 222 /* continue with rest of points */ 223 sxo = syo = 0; 224 for (i++; i < object[0].Npts; i++) { 225 if (!(finite(x[i]) && finite(y[i]))) continue; 226 sx1 = x[i]*mxi + y[i]*mxj + bx; 227 sy1 = x[i]*myi + y[i]*myj + by; 228 sx1 = MIN (MAX (sx1, X0), X1); 229 sy1 = MAX (MIN (sy1, Y0), Y1); 230 sxa = 0.5*(sx0 + sx1); 231 DrawLine (sx0, sy0, sxa, sy0); 232 DrawLine (sxa, sy0, sxa, sy1); 233 DrawLine (sxa, sy1, sx1, sy1); 234 sxo = sx0; syo = sy0; 235 sx0 = sx1; sy0 = sy1; 236 } 237 238 /* draw segment equal distance after last point and down to x-axis */ 239 sxa = sx1 + 0.5*(sx1 - sxo); 240 sya = MAX (sy1, Y0); 241 DrawLine (sx1, sy1, sxa, sy1); 242 DrawLine (sxa, sy1, sxa, sya); 243 244 # if (0) 191 245 sx0 = x[i]*mxi + y[i]*mxj + bx; 192 246 sy0 = x[i]*myi + y[i]*myj + by; … … 207 261 sx0 = sx1; sy0 = sy1; 208 262 } 263 # endif 209 264 } 210 265 -
trunk/Ohana/src/kapa2/src/UpdateStatusBox.c
r29539 r30606 20 20 21 21 bzero (line, 100); 22 s printf (line, "(%d x %d) @ %d ",22 snprintf (line, 100, "(%d x %d) @ %d ", 23 23 image[0].picture.dx, image[0].picture.dy, image[0].picture.expand); 24 24 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, … … 26 26 27 27 bzero (line, 100); 28 s printf (line, "%-25s", image[0].image[0].file);28 snprintf (line, 100, "%-25s", image[0].image[0].file); 29 29 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 30 30 image[0].text_x + PAD1, image[0].text_y + 5*textpad + 5*PAD1, line, strlen(line)); 31 31 32 32 bzero (line, 100); 33 s printf (line, "(%s) ", image[0].image[0].name);33 snprintf (line, 100, "(%s) ", image[0].image[0].name); 34 34 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 35 35 image[0].text_x + PAD1, image[0].text_y + 6*textpad + 6*PAD1, line, 25); … … 45 45 46 46 if (image[0].HexValue) { 47 sprintf (line, "%04x", (int) z);47 snprintf (line, 100, "%04x", (int) z); 48 48 } else { 49 sprintf (line, "%22.3f", z);49 snprintf (line, 100, "%22.3f", z); 50 50 } 51 51 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, … … 53 53 54 54 bzero (line, 100); 55 s printf (line, "%10.2f %10.2f", x, y);55 snprintf (line, 100, "%10.2f %10.2f", x, y); 56 56 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 57 57 image[0].text_x + PAD1, image[0].text_y + 2*textpad + 2*PAD1, line, strlen(line)); … … 59 59 bzero (line, 100); 60 60 if (image[0].DecimalDegrees) { 61 s printf (line, "%10.6f %10.6f", ra, dec);61 snprintf (line, 100, "%10.6f %10.6f", ra, dec); 62 62 } else { 63 hh_hms (line, ra, dec, ':' );63 hh_hms (line, ra, dec, ':', 100); 64 64 } 65 65 66 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 66 67 image[0].text_x + PAD1, image[0].text_y + 3*textpad + 3*PAD1, line, strlen(line)); -
trunk/Ohana/src/kapa2/src/bDrawObjects.c
r29938 r30606 154 154 float *x, *y; 155 155 double mxi, mxj, myi, myj, bxi, bxj, byi, byj, bx, by; 156 double sx0, sy0, sx1, sy1, sxa ;156 double sx0, sy0, sx1, sy1, sxa, sya, sxo, syo; 157 157 double X0, X1, Y0, Y1; 158 158 … … 179 179 for (i = 0; (i < object[0].Npts) && !(finite(x[i]) && finite(y[i])); i++); 180 180 if (i >= object[0].Npts) return; 181 182 /* first valid data point */ 183 sx0 = x[i]*mxi + y[i]*mxj + bx; 184 sy0 = x[i]*myi + y[i]*myj + by; 185 sx0 = MIN (MAX (sx0, X0), X1); 186 sy0 = MAX (MIN (sy0, Y0), Y1); 187 188 /* find the second valid datapoint */ 189 for (i++; (i < object[0].Npts) && !(finite(x[i]) && finite(y[i])); i++); 190 if (i >= object[0].Npts) return; 191 192 /* second valid data point */ 193 sx1 = x[i]*mxi + y[i]*mxj + bx; 194 sy1 = x[i]*myi + y[i]*myj + by; 195 sx1 = MIN (MAX (sx1, X0), X1); 196 sy1 = MAX (MIN (sy1, Y0), Y1); 197 198 /* connect first point to second point */ 199 sxa = sx0 - 0.5*(sx1 - sx0); 200 sya = MAX (sy0, Y0); 201 DrawLine (buffer, sx0, sy0, sxa, sy0); 202 DrawLine (buffer, sxa, sy0, sxa, sya); 203 204 /* draw segment equal distance behind first point and down to x-axis */ 205 sxa = 0.5*(sx0 + sx1); 206 DrawLine (buffer, sx0, sy0, sxa, sy0); 207 DrawLine (buffer, sxa, sy0, sxa, sy1); 208 DrawLine (buffer, sxa, sy1, sx1, sy1); 209 sx0 = sx1; 210 sy0 = sy1; 211 212 /* continue with rest of points */ 213 sxo = syo = 0; 214 for (i++; i < object[0].Npts; i++) { 215 if (!(finite(x[i]) && finite(y[i]))) continue; 216 sx1 = x[i]*mxi + y[i]*mxj + bx; 217 sy1 = x[i]*myi + y[i]*myj + by; 218 sx1 = MIN (MAX (sx1, X0), X1); 219 sy1 = MAX (MIN (sy1, Y0), Y1); 220 sxa = 0.5*(sx0 + sx1); 221 DrawLine (buffer, sx0, sy0, sxa, sy0); 222 DrawLine (buffer, sxa, sy0, sxa, sy1); 223 DrawLine (buffer, sxa, sy1, sx1, sy1); 224 sxo = sx0; syo = sy0; 225 sx0 = sx1; sy0 = sy1; 226 } 227 228 /* draw segment equal distance after last point and down to x-axis */ 229 sxa = sx1 + 0.5*(sx1 - sxo); 230 sya = MAX (sy1, Y0); 231 DrawLine (buffer, sx1, sy1, sxa, sy1); 232 DrawLine (buffer, sxa, sy1, sxa, sya); 233 234 # if (0) 181 235 sx0 = x[i]*mxi + y[i]*mxj + bx; 182 236 sy0 = x[i]*myi + y[i]*myj + by; … … 197 251 sx0 = sx1; sy0 = sy1; 198 252 } 253 # endif 199 254 } 200 255 -
trunk/Ohana/src/kapa2/src/hh_hms.c
r13320 r30606 1 1 # include "Ximage.h" 2 2 3 void hh_hms (char *line, double ra, double dec, char sep ) {3 void hh_hms (char *line, double ra, double dec, char sep, int Nchar) { 4 4 5 5 int h, m, flag; … … 13 13 s = 3600*(ra - h - m / 60.0); 14 14 if (flag > 0) 15 s printf (line, " %02d%c%02d%c%04.1f ", h, sep, m, sep, s);15 snprintf (line, Nchar, " %02d%c%02d%c%04.1f ", h, sep, m, sep, s); 16 16 else 17 s printf (line, "-%02d%c%02d%c%04.1f ", h, sep, m, sep, s);17 snprintf (line, Nchar, "-%02d%c%02d%c%04.1f ", h, sep, m, sep, s); 18 18 19 19 flag = SIGN(dec); … … 23 23 s = 3600*(dec - h - m / 60.0); 24 24 if (flag > 0) 25 s printf (&line[13], " %02d%c%02d%c%04.1f", h, sep, m, sep, s);25 snprintf (&line[13], Nchar, " %02d%c%02d%c%04.1f", h, sep, m, sep, s); 26 26 else 27 s printf (&line[13], "-%02d%c%02d%c%04.1f", h, sep, m, sep, s);27 snprintf (&line[13], Nchar, "-%02d%c%02d%c%04.1f", h, sep, m, sep, s); 28 28 }
Note:
See TracChangeset
for help on using the changeset viewer.
