Changeset 27790
- Timestamp:
- Apr 28, 2010, 10:27:33 AM (16 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 2 deleted
- 36 edited
- 5 copied
-
. (modified) (1 prop)
-
src/addstar/src/find_matches_closest_refstars.c (modified) (1 diff)
-
src/kapa2/doc/mark.issues.txt (modified) (2 diffs)
-
src/kapa2/doc/notes.txt (copied) (copied from branches/eam_branches/Ohana.20100407/src/kapa2/doc/notes.txt )
-
src/kapa2/include/prototypes.h (modified) (7 diffs)
-
src/kapa2/include/structures.h (modified) (2 diffs)
-
src/kapa2/src/CheckPipe.c (modified) (1 diff)
-
src/kapa2/src/DefineSection.c (modified) (3 diffs)
-
src/kapa2/src/DrawFrame.c (modified) (4 diffs)
-
src/kapa2/src/DrawLabels.c (modified) (1 diff)
-
src/kapa2/src/EraseSections.c (modified) (1 diff)
-
src/kapa2/src/Graphs.c (modified) (2 diffs)
-
src/kapa2/src/Layout.c (modified) (1 diff)
-
src/kapa2/src/LoadFrame.c (modified) (6 diffs)
-
src/kapa2/src/PSFrame.c (modified) (4 diffs)
-
src/kapa2/src/Refresh.c (modified) (2 diffs)
-
src/kapa2/src/Sections.c (modified) (4 diffs)
-
src/kapa2/src/SetGraphData.c (modified) (2 diffs)
-
src/kapa2/src/SetGraphSize.c (modified) (5 diffs)
-
src/kapa2/src/bDrawFrame.c (modified) (6 diffs)
-
src/libkapa/include/kapa.h (modified) (3 diffs)
-
src/libkapa/src/KapaWindow.c (modified) (9 diffs)
-
src/opihi/cmd.basic/opihi.c (modified) (2 diffs)
-
src/opihi/cmd.data/box.c (modified) (6 diffs)
-
src/opihi/cmd.data/section.c (modified) (4 diffs)
-
src/opihi/include/shell.h (modified) (1 diff)
-
src/opihi/lib.data/open_graph.c (deleted)
-
src/opihi/lib.data/open_image.c (deleted)
-
src/opihi/lib.shell/command.c (modified) (5 diffs)
-
src/relastro (modified) (1 prop)
-
src/relphot/src/StarOps.c (modified) (1 diff)
-
src/uniphot/Makefile (modified) (4 diffs)
-
src/uniphot/include/uniphot.h (modified) (3 diffs)
-
src/uniphot/src/ConfigInit.c (modified) (4 diffs)
-
src/uniphot/src/Shutdown.c (modified) (1 diff)
-
src/uniphot/src/args.c (modified) (2 diffs)
-
src/uniphot/src/initialize.c (modified) (2 diffs)
-
src/uniphot/src/load_images.c (modified) (2 diffs)
-
src/uniphot/src/load_zpt_table.c (copied) (copied from branches/eam_branches/Ohana.20100407/src/uniphot/src/load_zpt_table.c )
-
src/uniphot/src/match_zpts_to_images.c (copied) (copied from branches/eam_branches/Ohana.20100407/src/uniphot/src/match_zpts_to_images.c )
-
src/uniphot/src/setphot.c (copied) (copied from branches/eam_branches/Ohana.20100407/src/uniphot/src/setphot.c )
-
src/uniphot/src/uniphot.c (modified) (2 diffs)
-
src/uniphot/src/update_catalog_setphot.c (copied) (copied from branches/eam_branches/Ohana.20100407/src/uniphot/src/update_catalog_setphot.c )
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana
-
Property svn:mergeinfo
set to
/branches/eam_branches/Ohana.20100407 merged eligible
-
Property svn:mergeinfo
set to
-
trunk/Ohana/src/addstar/src/find_matches_closest_refstars.c
r27582 r27790 159 159 /** in replace mode, search for entry and replace values M, dM, R, D */ 160 160 // XXX this fails for unsorted catalogs, right? 161 if (options.replace && replace_match (&catalog[0].average[n], catalog[0].measure, stars[N])) continue; 161 if (options.replace && replace_match (&catalog[0].average[n], catalog[0].measure, stars[N])) { 162 i++; 163 continue; 164 } 162 165 163 166 /* make sure there is space for next entry */ -
trunk/Ohana/src/kapa2/doc/mark.issues.txt
r25918 r27790 1 2 * option to set window margin 3 * option to add section outer box 4 * option to set limits based on associated image (and change dynamically...) 5 o need consistency of graph defaults : axis, tick, labels should come from kapa 6 o clear should erase current plot 7 1 8 -> The "plot" command needs to be fixed so that boundaries of contours do 2 9 not cause it to draw excessive amounts of lines connecting unrelated 3 10 contours. A specific "contour line type" would be useful. 4 5 -> DVO is not consistently placing the x/y axis labels, especially in 6 user-defined sections of the plot window. 11 (-pt 100?) 7 12 8 13 -> DVO does not plot the end-points of histograms properly (e.g., the … … 13 18 relay output to the file in the same order. Also, until DVO is closed, the 14 19 output does not appear in the file. 20 (fixed both issues) 15 21 22 -> DVO is not consistently placing the x/y axis labels, especially in 23 user-defined sections of the plot window. 24 (fixed) 25 * box -labelpad -labelpad[x,y] +labelpad[x,y] - 26 27 28 --- 29 30 31 1)You wanted me to remind you to update ~ipp-svn; this was so I could have 32 the latest version of DVO on-hand 33 34 2)The plotting of axis labels remains inconsistent; depending on section 35 dimensions and the presence/absence of tick-marks, labels will change 36 their distance from their corresponding axis. This results in labels 37 falling off the screen or overlapping with other plot sections 38 39 3)Plot section locations in the plot window shift if labels/tick-marks are 40 present or absent 41 42 4)It would be useful to have an option for the box or section command that 43 causes the background to be opaque. This will allow plots to have insets. 44 45 5)It would be useful to have a rectangle plotting command in order to 46 shade out regions on plots 47 48 6)The limits command combined with box will sometimes produce tick-marks 49 with only the zero-point labeled, making the axes difficult to interpret 50 51 7)Text is printed to a file at different times when using either the echo 52 or fprintf commands alongside the output command. Sometimes output is 53 printed to the file immediately, while other times it is printed only when 54 the file is closed for output. 55 56 8)The use of ^C as an interrupt does not always work when a macro is doing 57 for loops. 58 59 9)It would be useful for DVO to echo which line of a macro contains an 60 error, or at which line it was forced to stop. This would help debugging a 61 lot. 62 63 10)The cgrid could use an option to print RA/DEC tick-mark labels so that 64 image plots would be more informative -
trunk/Ohana/src/kapa2/include/prototypes.h
r27530 r27790 26 26 27 27 /* X drawing utilities */ 28 voidDrawFrame PROTO((KapaGraphWidget *graph));28 int DrawFrame PROTO((KapaGraphWidget *graph)); 29 29 int DrawObjects PROTO((KapaGraphWidget *graph)); 30 30 void DrawLabels PROTO((KapaGraphWidget *graph)); … … 39 39 void DrawXErrors PROTO((KapaGraphWidget *graph, Gobjects *objects)); 40 40 void DrawYErrors PROTO((KapaGraphWidget *graph, Gobjects *objects)); 41 void DrawTick PROTO(( int fx, int fy, int dfx, int dfy, int P, double min, double max, double value, int IsLabel, int IsMajor, int naxis));41 void DrawTick PROTO((Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis)); 42 42 void AxisTickScale PROTO((Axis *axis, double *major, double *minor)); 43 TickMarkData *CreateAxisTicks PROTO((Axis *axis, int *nticks)); 43 44 44 45 /* EventLoop */ … … 47 48 int Reconfig PROTO((XEvent *event)); 48 49 void Refresh PROTO((void)); 50 void DrawSectionBG PROTO((Graphic *graphic, Section *section)); 49 51 50 52 /* CheckPipe */ … … 61 63 int SetSection PROTO((int sock)); 62 64 int ListSection PROTO((int sock)); 65 int SetSectionBG PROTO((int sock)); 63 66 int MoveSection PROTO((int sock)); 64 67 int DefineSection PROTO((int sock)); … … 84 87 void FreeSection PROTO((Section *section)); 85 88 void FreeSections PROTO((void)); 86 Section *AddSection PROTO((char *name, float x, float y, float dx, float dy ));89 Section *AddSection PROTO((char *name, float x, float y, float dx, float dy, int bg)); 87 90 int DelSection PROTO((char *name)); 88 91 int GetSectionByName PROTO((char *name)); … … 112 115 void PSXErrors PROTO((KapaGraphWidget *graph, Gobjects *objects, FILE *f)); 113 116 void PSYErrors PROTO((KapaGraphWidget *graph, Gobjects *objects, FILE *f)); 114 void PSTick PROTO(( FILE *f, double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int IsLabel, int IsMajor, int naxis));117 void PSTick PROTO((Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis, FILE *f)); 115 118 void ClipLinePS PROTO((double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0, FILE *f)); 116 119 int PSimage PROTO((KapaImageWidget *image, FILE *f)); … … 131 134 void bDrawXErrors PROTO((KapaGraphWidget *graph, Gobjects *object)); 132 135 void bDrawYErrors PROTO((KapaGraphWidget *graph, Gobjects *object)); 133 void bDrawTick PROTO(( double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int IsLabel, int IsMajor, int naxis));136 void bDrawTick PROTO((Axis *axis, int P, TickMarkData *tick, int naxis)); 134 137 void bDrawClipLine PROTO((double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0)); 135 138 bDrawBuffer *bDrawIt PROTO((void)); -
trunk/Ohana/src/kapa2/include/structures.h
r25757 r27790 137 137 double min, max; 138 138 char isaxis, areticks, islabel, islog; 139 double pad, labelPad, ticktextPad; 139 140 double fx, dfx, fy, dfy; /* axis location on graphic */ 140 141 double lweight; 141 142 int color; 142 143 } Axis; 144 145 // structure to describe the ticks for an axis 146 typedef struct { 147 double value; 148 int IsMajor; 149 int IsLabel; 150 } TickMarkData; 143 151 144 152 // a single graph in the display window … … 210 218 float x, y; 211 219 float dx, dy; 220 int bg; 212 221 char *name; 213 222 } Section; -
trunk/Ohana/src/kapa2/src/CheckPipe.c
r25757 r27790 221 221 } 222 222 223 if (!strcmp (word, "BSEC")) { 224 status = SetSectionBG (sock); 225 KiiSendCommand (sock, 4, "DONE"); 226 FINISHED (TRUE); 227 } 228 223 229 if (!strcmp (word, "FONT")) { 224 230 status = SetFont (sock); -
trunk/Ohana/src/kapa2/src/DefineSection.c
r21153 r27790 4 4 int DefineSection (int sock) { 5 5 6 int N, MoveSection ;6 int N, MoveSection, bg; 7 7 char name[128]; 8 8 double x, y, dx, dy; 9 9 Section *section; 10 10 11 KiiScanMessage (sock, "%s %lf %lf %lf %lf ", name, &x, &y, &dx, &dy);11 KiiScanMessage (sock, "%s %lf %lf %lf %lf %d", name, &x, &y, &dx, &dy, &bg); 12 12 13 13 MoveSection = FALSE; … … 15 15 N = GetSectionByName (name); 16 16 if (N < 0) { 17 section = AddSection (name, x, y, dx, dy );17 section = AddSection (name, x, y, dx, dy, bg); 18 18 MoveSection = TRUE; 19 19 } else { … … 30 30 section[0].dx = dx; 31 31 section[0].dy = dy; 32 section[0].bg = bg; 32 33 } 33 34 -
trunk/Ohana/src/kapa2/src/DrawFrame.c
r27603 r27790 1 1 # include "Ximage.h" 2 # define MIN_RANGE 1e-103 2 # define DrawLine(X,Y,DX,DY) (XDrawLine (graphic->display, graphic->window, graphic->gc, (int)(X), (int)(Y), (int)(X+DX), (int)(Y+DY))) 4 3 5 static Graphic *graphic; 6 7 void DrawFrame (KapaGraphWidget *graph) { 8 9 int i, fx, fy, dfx, dfy, P, IsLabel, IsMajor; 10 double range, major, minor, first, next, lweight; 4 int DrawFrame (KapaGraphWidget *graph) { 5 6 int i, j, Nticks, P; 7 double fx, fy, dfx, dfy, lweight; 8 Graphic *graphic; 9 TickMarkData *ticks; 10 int color; 11 11 12 12 graphic = GetGraphic(); 13 13 14 /* each axis is drawn independently, but ticks and labels are placed according to 15 perpendicular distance. */ 14 /* each axis is drawn independently, but ticks and labels are placed according to perpendicular distance. */ 16 15 for (i = 0; i < 4; i++) { 17 fx = graph[0].axis[i].fx;18 fy = graph[0].axis[i].fy;16 fx = graph[0].axis[i].fx; 17 fy = graph[0].axis[i].fy; 19 18 dfx = graph[0].axis[i].dfx; 20 19 dfy = graph[0].axis[i].dfy; 21 P = hypot ( (double)graph[0].axis[(i+1)%2].dfx, (double)graph[0].axis[(i+1)%2].dfy);20 P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy); 22 21 23 22 lweight = MAX (0, MIN (10, graph[0].axis[i].lweight)); 23 color = MAX (0, MIN (15, graph[0].axis[i].color)); 24 24 25 XSetLineAttributes (graphic->display, graphic->gc, lweight, LineSolid, CapNotLast, JoinMiter); 25 26 graph[0].axis[i].color = MAX (0, MIN (15, graph[0].axis[i].color)); 27 28 XSetForeground (graphic->display, graphic->gc, graphic->color[graph[0].axis[i].color]); 29 DrawRotTextInit (graphic->display, graphic->window, graphic->gc, graphic->color[graph[0].axis[i].color], graphic->back); 30 31 // fprintf (stderr, "axis: %d, color: %d, %ld, weight: %f\n", i, graph[0].axis[i].color, graphic->color[graph[0].axis[i].color], lweight); 26 XSetForeground (graphic->display, graphic->gc, graphic->color[color]); 27 DrawRotTextInit (graphic->display, graphic->window, graphic->gc, graphic->color[color], graphic->back); 32 28 33 29 if (graph[0].axis[i].isaxis) { 34 30 DrawLine (fx, fy, dfx, dfy); 35 // fprintf (stderr, "%d : %d %d - %d %d\n", i, fx, fy, dfx, dfy);36 // if (i == 0) {37 // int j;38 // for (j = fx; j < fx + dfx; j+= 10) {39 // DrawLine (j, fy-10, 0, 20);40 // }41 // }42 31 } 43 32 44 33 if (graph[0].axis[i].areticks) { 45 if (isnan(graph[0].axis[i].min) || isinf(graph[0].axis[i].min)) continue; 46 if (isnan(graph[0].axis[i].max) || isinf(graph[0].axis[i].max)) continue; 47 48 range = graph[0].axis[i].max - graph[0].axis[i].min; 49 if (fabs(range) < MIN_RANGE) continue; 50 51 if (fabs(range) < MIN_RANGE) { 52 range = (range < 0) ? -MIN_RANGE : +MIN_RANGE; 34 ticks = CreateAxisTicks (&graph[0].axis[i], &Nticks); 35 for (j = 0; j < Nticks; j++) { 36 DrawTick (graphic, &graph[0].axis[i], P, &ticks[j], i); 53 37 } 54 55 AxisTickScale (&graph[0].axis[i], &major, &minor); 56 57 first = minor*((int)(graph[0].axis[i].min/minor)); 58 if ((range > 0) && (first < graph[0].axis[i].min)) { 59 first += minor; 60 } 61 if ((range < 0) && (first > graph[0].axis[i].min)) { 62 first -= minor; 63 } 64 for (next = first; ((range > 0) && (next <= graph[0].axis[i].max)) || ((range < 0) && (next >= graph[0].axis[i].max));) { 65 IsMajor = FALSE; 66 IsMajor |= (fabs((int)(next/major) - (next/major)) < 0.5*(minor/major)); 67 IsMajor |= (fabs((int)((next + 0.5*minor)/major) - (next/major)) < 0.5*(minor/major)); 68 IsMajor |= (fabs ((int)((next - 0.5*minor)/major) - (next/major)) < 0.5*(minor/major)); 69 IsLabel = (IsMajor && graph[0].axis[i].islabel); 70 DrawTick (fx, fy, dfx, dfy, P, graph[0].axis[i].min, graph[0].axis[i].max, next, IsLabel, IsMajor, i); 71 if (range > 0) 72 next += minor; 73 else 74 next -= minor; 75 } 38 FREE (ticks); 76 39 } 77 40 } 78 } 79 80 void DrawTick (int fx, int fy, int dfx, int dfy, 81 int P, double min, double max, 82 double value, int IsLabel, int IsMajor, int naxis) { 83 84 int x, y, dx, dy,pos, dir, fontsize;85 double size, n ;41 return (TRUE); 42 } 43 44 void DrawTick (Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis) { 45 46 double x, y, dx, dy; 47 int pos, dir, fontsize; 48 double size, n, pad; 86 49 char string[64], *fontname; 87 50 88 if (IsMajor) { 51 double fx = axis->fx; 52 double fy = axis->fy; 53 double dfx = axis->dfx; 54 double dfy = axis->dfy; 55 56 double min = axis->min; 57 double max = axis->max; 58 59 double value = tick->value; 60 61 pos = size = 0; 62 63 if (tick->IsMajor) { 89 64 size = MAX (0.02, 7.0 / P); 90 65 } else { … … 92 67 } 93 68 94 n = P / sqrt ((double)(dfx*dfx + dfy*dfy));69 n = P / hypot(dfx, dfy); 95 70 x = fx + (value-min)*dfx/(max - min); 96 71 y = fy + (value-min)*dfy/(max - min); 97 72 98 dir = +1; 99 if ((naxis == 0) || (naxis == 1)) dir *= -1; 73 if ((naxis == 0) || (naxis == 2)) { 74 x = MAX(x, fx); 75 } 76 // y = MAX(y, fy); 77 // } 78 79 dir = ((naxis == 0) || (naxis == 1)) ? -1 : +1; 100 80 dx = dir*size*dfy*n; 101 81 dy = dir*size*dfx*n; … … 103 83 DrawLine (x, y, dx, dy); 104 84 105 # ifdef IN_AND_OUT_TICKS 106 # define GAP 0.03 107 # else 108 # define GAP 0.01 109 # endif 110 111 if (IsLabel) { 85 if (tick->IsLabel) { 86 int xt, yt; 87 112 88 fontname = GetRotFont (&fontsize); 113 pos = 0; 89 90 pad = isfinite(axis->ticktextPad) ? axis->ticktextPad*fontsize : fontsize + 4.0; 91 // pad = isfinite(axis->ticktextPad) ? axis->ticktextPad*fontsize : 0.8*fontsize + 1.0; 114 92 115 93 /* temporarily assume rectilinear axes */ 116 if (naxis == 0) { dx = 0; dy = -dir*(0.8*fontsize + 1); pos = 1; }117 if (naxis == 2) { dx = 0; dy = - dir*(0.8*fontsize + 1); pos = 7; }118 119 if (naxis == 1) { dy = 0; dx = - (0.8*fontsize + 1); pos = 3; }120 if (naxis == 3) { dy = 0; dx = + (0.8*fontsize + 1); pos = 5; }121 122 x = fx + (value-min)*dfx/(max - min) + dx;123 y = fy + (value-min)*dfy/(max - min) + dy;94 if (naxis == 0) { dx = 0; dy = +1.0*pad; pos = 7; } 95 if (naxis == 2) { dx = 0; dy = -1.0*pad; pos = 1; } 96 97 if (naxis == 1) { dy = 0; dx = -0.5*pad; pos = 3; } 98 if (naxis == 3) { dy = 0; dx = +0.5*pad; pos = 5; } 99 100 xt = fx + (value-min)*dfx/(max - min) + dx; 101 yt = fy + (value-min)*dfy/(max - min) + dy; 124 102 if (fabs(value/(max-min)) < 0.001) { value = 0.0; } 125 103 sprintf (string, "%4g", value); 126 DrawRotText (x , y, string, pos, 0.0);127 } 128 129 } 130 104 DrawRotText (xt, yt, string, pos, 0.0); 105 } 106 } 107 108 # define MIN_RANGE 1e-10 131 109 132 110 void AxisTickScale (Axis *axis, double *major, double *minor) { … … 192 170 } 193 171 } 172 173 TickMarkData *CreateAxisTicks (Axis *axis, int *nticks) { 174 175 TickMarkData *ticks; 176 double range, major, minor, first, value, dPixels, overshoot; 177 int i, NTICKS, nPixels, done, ifirst; 178 179 *nticks = 0; 180 181 if (isnan(axis->min) || isinf(axis->min)) return NULL; 182 if (isnan(axis->max) || isinf(axis->max)) return NULL; 183 184 range = axis->max - axis->min; 185 186 // not sure why I skip out here instead of using the MIN_RANGE value 187 if (fabs(range) < MIN_RANGE) return NULL; 188 189 if (fabs(range) < MIN_RANGE) { 190 range = (range < 0) ? -MIN_RANGE : +MIN_RANGE; 191 } 192 193 // length of the axis in pixels 194 nPixels = hypot(axis->dfx, axis->dfy); 195 dPixels = nPixels / range; // axis pixel-scale 196 197 AxisTickScale (axis, &major, &minor); 198 199 // be a little generous 200 NTICKS = (int)(fabs(range / minor)) + 2; 201 ALLOCATE (ticks, TickMarkData, NTICKS); 202 203 // value of the tick mark 204 ifirst = (axis->min < 0.0) ? (axis->min/minor - 0.05) : (axis->min/minor + 0.05); 205 first = minor*ifirst; 206 207 // allow undershoot by 1 pixel 208 overshoot = (axis->min - first) * dPixels; 209 // if (overshoot > 0.5) { 210 // if (range > 0) { 211 // first += minor; 212 // } else { 213 // first -= minor; 214 // } 215 // } 216 217 // loop to find the ticks 218 done = FALSE; 219 value = first; 220 for (i = 0; !done && (i < NTICKS); i++) { 221 ticks[i].IsMajor = FALSE; 222 ticks[i].IsMajor |= (fabs((int)(value/major) - (value/major)) < 0.5*(minor/major)); 223 ticks[i].IsMajor |= (fabs((int)((value + 0.5*minor)/major) - (value/major)) < 0.5*(minor/major)); 224 ticks[i].IsMajor |= (fabs((int)((value - 0.5*minor)/major) - (value/major)) < 0.5*(minor/major)); 225 ticks[i].IsLabel = (ticks[i].IsMajor && axis->islabel); 226 ticks[i].value = value; 227 if (range > 0) 228 value += minor; 229 else 230 value -= minor; 231 232 done |= (range > 0) && (value > axis->max); 233 done |= (range < 0) && (value < axis->max); 234 } 235 236 *nticks = i; 237 return (ticks); 238 } -
trunk/Ohana/src/kapa2/src/DrawLabels.c
r17466 r27790 34 34 switch (i) { 35 35 case 0: pos = 7; break; 36 case 2: pos = 1; break; 36 37 case 1: pos = 1; angle = -90; break; 37 case 2: pos = 1; break;38 38 case 3: pos = 1; angle = 90; break; 39 39 case 4: pos = 2; break; -
trunk/Ohana/src/kapa2/src/EraseSections.c
r21153 r27790 8 8 9 9 FreeSections (); 10 AddSection ("default", 0.0, 0.0, 1.0, 1.0 );10 AddSection ("default", 0.0, 0.0, 1.0, 1.0, -1); 11 11 12 12 if (USE_XWINDOW) XClearWindow (graphic->display, graphic->window); -
trunk/Ohana/src/kapa2/src/Graphs.c
r27530 r27790 18 18 graph[0].axis[i].lweight = 0.0; 19 19 graph[0].axis[i].color = 0; 20 graph[0].axis[i].ticktextPad = NAN; 21 graph[0].axis[i].labelPad = NAN; 22 graph[0].axis[i].pad = NAN; 20 23 } 24 graph[0].data.ticktextPad = NAN; 25 26 graph[0].data.labelPadXm = NAN; 27 graph[0].data.labelPadXp = NAN; 28 graph[0].data.labelPadYm = NAN; 29 graph[0].data.labelPadYp = NAN; 30 31 graph[0].data.padXm = NAN; 32 graph[0].data.padXp = NAN; 33 graph[0].data.padYm = NAN; 34 graph[0].data.padYp = NAN; 35 21 36 for (i = 0; i < 8; i++) { 22 37 strcpy (graph[0].label[i].text, ""); … … 37 52 graph[0].data.size = 1.0; // point size of 1.0 38 53 39 graph[0].data.flipeast = 1; // +East = -X by default 40 graph[0].data.flipnorth = 0; // +North = +Y by default 54 graph[0].data.flipeast = TRUE; // +East = -X by default 55 graph[0].data.flipnorth = FALSE; // +North = +Y by default 56 57 graph[0].data.coords.pc1_1 = graph[0].data.coords.pc2_2 = 1.0; 58 graph[0].data.coords.pc1_2 = graph[0].data.coords.pc2_1 = 0.0; 59 graph[0].data.coords.crval1 = 0.0; 60 graph[0].data.coords.crval2 = 0.0; 61 graph[0].data.coords.crpix1 = 0.0; 62 graph[0].data.coords.crpix2 = 0.0; 63 graph[0].data.coords.cdelt1 = graph[0].data.coords.cdelt2 = 1.0; 64 strcpy (graph[0].data.coords.ctype, "RA---LIN"); 65 strcpy (graph[0].data.axis, "2222"); 66 strcpy (graph[0].data.ticks, "2222"); 67 strcpy (graph[0].data.labels, "2222"); 41 68 42 69 graph[0].Nobjects = 0; -
trunk/Ohana/src/kapa2/src/Layout.c
r14737 r27790 43 43 44 44 /* create basic section, empty of image or graph */ 45 section = AddSection ("default", 0.0, 0.0, 1.0, 1.0 );45 section = AddSection ("default", 0.0, 0.0, 1.0, 1.0, -1); 46 46 } -
trunk/Ohana/src/kapa2/src/LoadFrame.c
r21153 r27790 3 3 int LoadFrame (int sock) { 4 4 5 int i, color; 6 char Axis[16], Labels[16], Ticks[16]; 7 double lweight; 5 int i; 8 6 Section *section; 9 7 KapaGraphWidget *graph; … … 16 14 graph = section->graph; 17 15 18 KiiScanMessage (sock, "%lf %lf %lf %lf", 19 &graph[0].axis[0].min, &graph[0].axis[0].max, 20 &graph[0].axis[1].min, &graph[0].axis[1].max); 16 KapaScanGraphData (sock, &graph[0].data); 21 17 22 18 graph[0].axis[3].min = graph[0].axis[1].min; … … 25 21 graph[0].axis[2].max = graph[0].axis[0].max; 26 22 27 KiiScanMessage (sock, "%lf %d", &lweight, &color);28 color = MAX (0, MIN (15,color));23 // XXX this is fragile 24 graph[0].data.color = MAX (0, MIN (15, graph[0].data.color)); 29 25 30 KiiScanMessage (sock, "%s %s %s", Axis, Labels, Ticks); 26 graph[0].axis[0].pad = graph[0].data.padXm; 27 graph[0].axis[1].pad = graph[0].data.padYm; 28 graph[0].axis[2].pad = graph[0].data.padXp; 29 graph[0].axis[3].pad = graph[0].data.padYp; 30 31 graph[0].axis[0].labelPad = graph[0].data.labelPadXm; 32 graph[0].axis[1].labelPad = graph[0].data.labelPadYm; 33 graph[0].axis[2].labelPad = graph[0].data.labelPadXp; 34 graph[0].axis[3].labelPad = graph[0].data.labelPadYp; 31 35 32 36 for (i = 0; i < 4; i++) { 33 graph[0].axis[i].lweight = lweight;34 graph[0].axis[i].color = color;37 graph[0].axis[i].lweight = graph[0].data.lweight; 38 graph[0].axis[i].color = graph[0].data.color; 35 39 36 switch (Axis[i]) { 40 graph[0].axis[i].ticktextPad = graph[0].data.ticktextPad; 41 42 switch (graph[0].data.axis[i]) { 37 43 case '0': 38 44 graph[0].axis[i].isaxis = FALSE; … … 45 51 break; 46 52 } 47 switch ( Ticks[i]) {53 switch (graph[0].data.ticks[i]) { 48 54 case '0': 49 55 graph[0].axis[i].areticks = FALSE; … … 56 62 break; 57 63 } 58 switch ( Labels[i]) {64 switch (graph[0].data.labels[i]) { 59 65 case '0': 60 66 graph[0].axis[i].islabel = FALSE; … … 70 76 71 77 SetSectionSizes (section); 72 if (USE_XWINDOW) DrawFrame (graph); 73 FlushDisplay (); 78 Refresh(); 79 // if (USE_XWINDOW) DrawFrame (graph); 80 // FlushDisplay (); 74 81 75 82 /* XXX why did I do this??? */ -
trunk/Ohana/src/kapa2/src/PSFrame.c
r19834 r27790 4 4 int PSFrame (KapaGraphWidget *graph, FILE *f) { 5 5 6 int i, P, IsLabel, IsMajor, fontsize; 7 double fx, fy, dfx, dfy, range, major, minor, first, next; 8 char *fontname; 6 int i, Nticks, P; 7 double fx, fy, dfx, dfy, lweight; 9 8 Graphic *graphic; 10 float weight;9 TickMarkData *ticks; 11 10 bDrawColor color; 12 11 … … 14 13 15 14 /* each axis is drawn independently */ 16 fontname = GetRotFont (&fontsize);17 15 fprintf (f, "1 setlinewidth\n"); 18 16 for (i = 0; i < 4; i++) { 19 fx = graph[0].axis[i].fx;20 fy = graphic->dy - graph[0].axis[i].fy;17 fx = graph[0].axis[i].fx; 18 fy = graphic->dy - graph[0].axis[i].fy; 21 19 dfx = graph[0].axis[i].dfx; 22 20 dfy = -graph[0].axis[i].dfy; 23 P = hypot ( (double)graph[0].axis[(i+1)%2].dfx, (double)graph[0].axis[(i+1)%2].dfy);21 P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy); 24 22 25 weight = MAX (0, MIN (10, graph[0].axis[i].lweight));23 lweight = MAX (0, MIN (10, graph[0].axis[i].lweight)); 26 24 color = MAX (0, MIN (15, graph[0].axis[i].color)); 27 fprintf (f, "%.1f setlinewidth\n", weight); 25 26 fprintf (f, "%.1f setlinewidth\n", lweight); 28 27 fprintf (f, "%s setrgbcolor\n", KapaColorRGBString(color)); 28 // no need to init rot font 29 29 30 if (graph[0].axis[i].isaxis) { DrawLine (fx, fy, dfx, dfy); } 30 if (graph[0].axis[i].isaxis) { 31 DrawLine (fx, fy, dfx, dfy); 32 } 31 33 32 34 if (graph[0].axis[i].areticks) { 33 if (isnan(graph[0].axis[i].min) || isinf(graph[0].axis[i].min)) continue; 34 if (isnan(graph[0].axis[i].max) || isinf(graph[0].axis[i].max)) continue; 35 36 range = graph[0].axis[i].max - graph[0].axis[i].min; 37 AxisTickScale (&graph[0].axis[i], &major, &minor); 38 39 first = minor*((int)(graph[0].axis[i].min/minor)); 40 if ((range > 0) && (first < graph[0].axis[i].min)) { 41 first += minor; 35 ticks = CreateAxisTicks (&graph[0].axis[i], &Nticks); 36 for (i = 0; i < Nticks; i++) { 37 PSTick (graphic, &graph[0].axis[i], P, &ticks[i], i, f); 42 38 } 43 if ((range < 0) && (first > graph[0].axis[i].min)) { 44 first -= minor; 45 } 46 for (next = first; ((range > 0) && (next <= graph[0].axis[i].max)) || ((range < 0) && (next >= graph[0].axis[i].max));) { 47 IsMajor = FALSE; 48 IsMajor |= (fabs((int)(next/major) - (next/major)) < 0.5*(minor/major)); 49 IsMajor |= (fabs ((int)((next + 0.5*minor)/major) - (next/major)) < 0.5*(minor/major)); 50 IsMajor |= (fabs ((int)((next - 0.5*minor)/major) - (next/major)) < 0.5*(minor/major)); 51 IsLabel = (IsMajor && graph[0].axis[i].islabel); 52 PSTick (f, fx, fy, dfx, dfy, P, graph[0].axis[i].min, graph[0].axis[i].max, next, IsLabel, IsMajor, i); 53 if (range > 0) 54 next += minor; 55 else 56 next -= minor; 57 } 58 } 39 FREE (ticks); 40 } 59 41 } 60 42 return (TRUE); 61 43 } 62 44 63 void PSTick ( FILE *f, double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int IsLabel, int IsMajor, int naxis) {45 void PSTick (Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis, FILE *f) { 64 46 47 double x, y, dx, dy; 65 48 int pos, dir, fontsize; 66 double size, n, x, y, dx, dy;49 double size, n, pad; 67 50 char string[64], *fontname; 51 52 double fx = axis->fx; 53 double fy = graphic->dy - axis->fy; 54 double dfx = axis->dfx; 55 double dfy = -axis->dfy; 56 57 double min = axis->min; 58 double max = axis->max; 59 60 double value = tick->value; 68 61 69 62 pos = size = 0; 70 63 71 if ( IsMajor) {64 if (tick->IsMajor) { 72 65 size = MAX (0.02, 7.0 / P); 73 66 } else { … … 75 68 } 76 69 77 n = P / sqrt ((double)(dfx*dfx + dfy*dfy));70 n = P / hypot(dfx, dfy); 78 71 x = fx + (value-min)*dfx/(max - min); 79 72 y = fy + (value-min)*dfy/(max - min); 80 73 81 dir = -1; 82 if ((naxis == 0) || (naxis == 1)) dir *= -1; 74 dir = ((naxis == 0) || (naxis == 1)) ? -1 : +1; 83 75 dx = dir*size*dfy*n; 84 76 dy = dir*size*dfx*n; … … 86 78 DrawLine (x, y, dx, dy); 87 79 88 if (IsLabel) { 80 if (tick->IsLabel) { 81 int xt, yt; 82 89 83 fontname = GetRotFont (&fontsize); 90 84 85 pad = isfinite(axis->ticktextPad) ? axis->ticktextPad*fontsize : 0.8*fontsize + 1.0; 86 91 87 /* temporarily assume rectilinear axes */ 92 if (naxis == 0) { dx = 0; dy = -dir*(0.8*fontsize + 1); pos = 1; }93 if (naxis == 2) { dx = 0; dy = - dir*(0.8*fontsize + 1); pos = 7; }88 if (naxis == 0) { dx = 0; dy = +pad; pos = 1; } 89 if (naxis == 2) { dx = 0; dy = -pad; pos = 7; } 94 90 95 if (naxis == 1) { dy = 0; dx = - (0.8*fontsize + 1); pos = 3; }96 if (naxis == 3) { dy = 0; dx = + (0.8*fontsize + 1); pos = 5; }91 if (naxis == 1) { dy = 0; dx = -pad; pos = 3; } 92 if (naxis == 3) { dy = 0; dx = +pad; pos = 5; } 97 93 98 x = fx + (value-min)*dfx/(max - min) + dx;99 y = fy + (value-min)*dfy/(max - min) + dy;100 if (fabs(value) < 1e-14) { value = 0.0; }101 sprintf (string, "% g", value);102 PSRotText (f, (int)x, (int)y, string, pos, 0.0);94 xt = fx + (value-min)*dfx/(max - min) + dx; 95 yt = fy + (value-min)*dfy/(max - min) + dy; 96 if (fabs(value) < 0.001) { value = 0.0; } 97 sprintf (string, "%4g", value); 98 PSRotText (f, xt, yt, string, pos, 0.0); 103 99 } 104 100 } -
trunk/Ohana/src/kapa2/src/Refresh.c
r21153 r27790 21 21 for (i = 0; i < Nsection; i++) { 22 22 section = GetSectionByNumber (i); 23 DrawSectionBG (graphic, section); 23 24 DrawImage (section->image); 24 25 DrawGraph (section->graph); … … 28 29 } 29 30 31 void DrawSectionBG (Graphic *graphic, Section *section) { 32 33 int Ncolors; 34 int X0, Y0, dX, dY; 35 36 if (section->bg == -1) return; 37 38 Ncolors = KapaColormapSize(); 39 40 if (section->bg < 0) return; 41 if (section->bg >= Ncolors) return; 42 43 XSetForeground (graphic->display, graphic->gc, graphic->color[section->bg]); 44 45 dY = graphic[0].dy * section[0].dy; 46 dX = graphic[0].dx * section[0].dx; 47 Y0 = graphic[0].dy - graphic[0].dy * section[0].y - dY; 48 X0 = graphic[0].dx * section[0].x; 49 // fprintf (stderr, "section: (%s) %d %d - %d %d\n", section[0].name, X0, Y0, dX, dY); 50 51 XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, X0, Y0, dX, dY); 52 return; 53 } -
trunk/Ohana/src/kapa2/src/Sections.c
r21153 r27790 16 16 section[0].dx = 0; 17 17 section[0].dy = 0; 18 section[0].bg = -1; 18 19 19 20 section[0].name = NULL; … … 42 43 } 43 44 44 Section *AddSection (char *name, float x, float y, float dx, float dy ) {45 Section *AddSection (char *name, float x, float y, float dx, float dy, int bg) { 45 46 46 47 int N; … … 61 62 sections[N][0].dx = dx; 62 63 sections[N][0].dy = dy; 64 sections[N][0].bg = bg; 63 65 ActiveSection = N; 64 66 return (sections[N]); … … 155 157 } 156 158 159 int SetSectionBG (int sock) { 160 161 int N, background; 162 char name[128]; 163 164 KiiScanMessage (sock, "%s %d", name, &background); 165 166 N = GetSectionByName (name); 167 if (N < 0) { 168 fprintf (stderr, "section %s not found\n", name); 169 return (TRUE); 170 } 171 172 sections[N][0].bg = background; 173 174 return (TRUE); 175 } 176 157 177 // return TRUE even for nonsense cases to avoid quitting kapa 158 178 int MoveSection (int sock) { -
trunk/Ohana/src/kapa2/src/SetGraphData.c
r21153 r27790 18 18 graph = section->graph; 19 19 20 // get graph data from client 21 KiiScanMessage (sock, "%d %d %d %d %d %d %lf %lf", 22 &graph[0].data.style, 23 &graph[0].data.ptype, 24 &graph[0].data.ltype, 25 &graph[0].data.etype, 26 &graph[0].data.ebar, 27 &graph[0].data.color, 28 &graph[0].data.lweight, 29 &graph[0].data.size); 20 KapaScanGraphData (sock, &graph[0].data); 30 21 31 KiiScanMessage (sock, "%lf %lf %lf %lf", 32 &graph[0].data.xmin, 33 &graph[0].data.xmax, 34 &graph[0].data.ymin, 35 &graph[0].data.ymax); 22 for (i = 0; i < 4; i++) { 23 graph[0].axis[i].ticktextPad = graph[0].data.ticktextPad; 24 } 25 graph[0].axis[0].labelPad = graph[0].data.labelPadXm; 26 graph[0].axis[1].labelPad = graph[0].data.labelPadYm; 27 graph[0].axis[2].labelPad = graph[0].data.labelPadXp; 28 graph[0].axis[3].labelPad = graph[0].data.labelPadYp; 36 29 37 KiiScanMessage (sock, "%f %f %f %f", 38 &graph[0].data.coords.pc1_1, &graph[0].data.coords.pc2_2, 39 &graph[0].data.coords.pc1_2, &graph[0].data.coords.pc2_1); 40 41 KiiScanMessage (sock, "%d %d %s", 42 &graph[0].data.flipeast, &graph[0].data.flipnorth, 43 graph[0].data.coords.ctype); 44 45 KiiScanMessage (sock, "%lf %lf %f %f %f %f", 46 &graph[0].data.coords.crval1, 47 &graph[0].data.coords.crval2, 48 &graph[0].data.coords.crpix1, 49 &graph[0].data.coords.crpix2, 50 &graph[0].data.coords.cdelt1, 51 &graph[0].data.coords.cdelt2); 52 53 30 graph[0].axis[0].pad = graph[0].data.padXm; 31 graph[0].axis[1].pad = graph[0].data.padYm; 32 graph[0].axis[2].pad = graph[0].data.padXp; 33 graph[0].axis[3].pad = graph[0].data.padYp; 54 34 55 35 xmin = graph[0].data.xmin; … … 90 70 graph = section->graph; 91 71 92 KiiSendMessage (sock, "%8d %d %d %d %d %d %f %f", 93 graph[0].data.style, 94 graph[0].data.ptype, graph[0].data.ltype, 95 graph[0].data.etype, graph[0].data.ebar, graph[0].data.color, 96 graph[0].data.lweight, graph[0].data.size); 97 98 KiiSendMessage (sock, "%g %g %g %g", 99 graph[0].data.xmin, graph[0].data.xmax, 100 graph[0].data.ymin, graph[0].data.ymax); 101 102 KiiSendMessage (sock, "%g %g %g %g", 103 graph[0].data.coords.pc1_1, graph[0].data.coords.pc2_2, 104 graph[0].data.coords.pc1_2, graph[0].data.coords.pc2_1); 105 106 KiiSendMessage (sock, "%d %d %s", 107 graph[0].data.flipeast, graph[0].data.flipnorth, 108 graph[0].data.coords.ctype); 109 110 KiiSendMessage (sock, "%g %g %g %g %g %g", 111 graph[0].data.coords.crval1, 112 graph[0].data.coords.crval2, 113 graph[0].data.coords.crpix1, 114 graph[0].data.coords.crpix2, 115 graph[0].data.coords.cdelt1, 116 graph[0].data.coords.cdelt2); 72 KapaSendGraphData (sock, &graph[0].data); 117 73 118 74 return (TRUE); -
trunk/Ohana/src/kapa2/src/SetGraphSize.c
r16011 r27790 6 6 void SetGraphSize (Section *section) { 7 7 8 int fontsize, bump, Nc; 8 int i, Nticks; 9 int fontsize, Nc; 9 10 int textpad, textdY, WdY; 10 double PADx, PADy, Dx, Dy; 11 double PXm, PXp, PYm, PYp; 11 int dXm, dXp, dYm, dYp; 12 double padXm, padXp, padYm, padYp; 13 double minPADx, maxPADx, minPADy; 14 double minPAD, maxPAD; 12 15 double X0, Y0, dX, dY; 13 16 char string[64], *fontname; 14 17 KapaGraphWidget *graph; 15 18 Graphic *graphic; 19 TickMarkData *ticks; 16 20 17 21 if (section == NULL) return; … … 22 26 fontname = GetRotFont (&fontsize); 23 27 24 PADx = MAX (graphic->dx / 20.0, fontsize); 25 PADy = MAX (graphic->dy / 20.0, fontsize); 26 Dx = graphic->dx - 2*PADx; 27 Dy = graphic->dy - 2*PADy; 28 minPAD = 1.0*fontsize + 0; 29 maxPAD = 2.0*fontsize + 4; 28 30 29 /* each graph has a padding PXm, PXp, PYm, PYp */ 30 PXm = (graph[0].axis[1].islabel) ? 4*fontsize : 0; 31 PXp = (graph[0].axis[3].islabel) ? 4*fontsize : 0; 32 PYm = (graph[0].axis[0].islabel) ? 4*fontsize : 0; 33 PYp = (graph[0].axis[2].islabel) ? 4*fontsize : 0; 34 31 minPADx = 1.5*fontsize; 32 maxPADx = 2.5*fontsize + 4.0; 33 34 minPADy = 1.5*fontsize; 35 36 // dXm : offset to label from lower x-axis, dYp : offset to label from right y-axis, etc 37 // padXm : padding below x-axis, padYp : padding to right of y-axis, etc 38 39 // offset from lower x-axis to labels and tick values 40 // these depend on (a) existence of tick labels and (b) auto-offset or not 41 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; 45 } 46 if (isnan(graph[0].axis[0].pad)) { 47 padXm = graph[0].axis[0].islabel ? maxPADx : minPADx; 48 } else { 49 padXm = graph[0].axis[0].pad * fontsize; 50 } 51 52 // offset from upper x-axis to labels and tick values 53 // these depend on (a) existence of tick labels and (b) auto-offset or not 54 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; 58 } 59 if (isnan(graph[0].axis[2].pad)) { 60 padXp = graph[0].axis[2].islabel ? maxPADx : minPADx; 61 } else { 62 padXp = graph[0].axis[2].pad * fontsize; 63 } 64 65 // offset from left y-axis to labels and tick values 66 // these depend on (a) existence of tick labels and (b) auto-offset or not. 67 // in the auto-offset case, offset depends on the width of the tick label strings 68 if (graph[0].axis[1].islabel && (isnan(graph[0].axis[1].labelPad) || isnan(graph[0].axis[1].pad))) { 69 /* check for the max size of the axis label */ 70 Nc = 0; 71 ticks = CreateAxisTicks (&graph[0].axis[1], &Nticks); 72 for (i = 0; i < Nticks; i++) { 73 if (!ticks[i].IsMajor) continue; 74 sprintf (string, "%g", ticks[i].value); 75 Nc = MAX (Nc, strlen (string)); 76 } 77 FREE(ticks); 78 } 79 if (isnan(graph[0].axis[1].labelPad)) { 80 dYm = (graph[0].axis[1].islabel) ? (0.7*(Nc + 1.5)*fontsize) : minPAD; 81 } else { 82 dYm = graph[0].axis[1].labelPad * fontsize; 83 } 84 if (isnan(graph[0].axis[1].pad)) { 85 padYm = graph[0].axis[1].islabel ? (0.7*(Nc + 2.5)*fontsize) : minPADy; 86 } else { 87 padYm = graph[0].axis[1].pad * fontsize; 88 } 89 90 // offset from right y-axis to labels and tick values 91 // these depend on (a) existence of tick labels and (b) auto-offset or not. 92 // in the auto-offset case, offset depends on the width of the tick label strings 93 if (graph[0].axis[3].islabel && (isnan(graph[0].axis[3].labelPad) || isnan(graph[0].axis[3].pad))) { 94 Nc = 0; 95 ticks = CreateAxisTicks (&graph[0].axis[3], &Nticks); 96 for (i = 0; i < Nticks; i++) { 97 if (!ticks[i].IsMajor) continue; 98 sprintf (string, "%g", ticks[i].value); 99 Nc = MAX (Nc, strlen (string)); 100 } 101 FREE(ticks); 102 } 103 if (isnan(graph[0].axis[3].labelPad)) { 104 dYp = (graph[0].axis[3].islabel) ? (0.7*(Nc + 1.5)*fontsize) : minPAD; 105 } else { 106 dYp = graph[0].axis[3].labelPad * fontsize; 107 } 108 if (isnan(graph[0].axis[3].pad)) { 109 padYp = graph[0].axis[3].islabel ? (0.7*(Nc + 2.5)*fontsize) : minPADy; 110 } else { 111 padYp = graph[0].axis[3].pad * fontsize; 112 } 113 35 114 /* basic size of the graph in Xwindow coordinates */ 36 X0 = PADx + PXm + (Dx * section[0].x);37 Y0 = PADy + PYm + (Dy * section[0].y);38 dX = (Dx * section[0].dx) - PXp - PXm;39 dY = (Dy * section[0].dy) - PYp - PYm;115 X0 = graphic[0].dx * section[0].x + padYm; 116 Y0 = graphic[0].dy * section[0].y + padXm; 117 dX = graphic[0].dx * section[0].dx - padYm - padYp; 118 dY = graphic[0].dy * section[0].dy - padXm - padXp; 40 119 41 120 // if we are tied to an image, make mods as needed … … 47 126 switch (section->image->location) { 48 127 case 1: 49 Y0 = graphic[0].dy * section[0].y + 2*PAD1 + WdY + 2; // tied to image in Y128 Y0 = graphic[0].dy * section[0].y + 2*PAD1 + WdY + 2; // tied to image in Y 50 129 dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD + 1; 51 130 break; 52 131 case 3: 53 dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD - PADy - PYm;132 dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD - padYm - padYp; 54 133 break; 55 134 case 2: … … 58 137 break; 59 138 case 4: 60 dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X - PADx - PXm;139 dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X - padXm - padXp; 61 140 break; 62 141 } … … 84 163 graph[0].axis[3].dfy = -dY; 85 164 86 PADx = 0.8*fontsize + 2; 87 PADy = 3.0*fontsize + 4; 165 /* define locations of axis labels */ 166 graph[0].label[LABELLL].x = graph[0].axis[0].fx; 167 graph[0].label[LABELLL].y = graph[0].axis[0].fy + dXm; 168 graph[0].label[LABELX0].x = graph[0].axis[0].fx + 0.5*graph[0].axis[0].dfx; 169 graph[0].label[LABELX0].y = graph[0].axis[0].fy + dXm; 170 graph[0].label[LABELLR].x = graph[0].axis[0].fx + graph[0].axis[0].dfx; 171 graph[0].label[LABELLR].y = graph[0].axis[0].fy + dXm; 88 172 89 /* define locations of axis labels */ 90 graph[0].label[LABELX0].x = graph[0].axis[0].fx + 0.5*graph[0].axis[0].dfx; 91 bump = (graph[0].axis[0].islabel) ? PADy : PADx; 92 graph[0].label[LABELX0].y = graph[0].axis[0].fy + bump; 93 173 graph[0].label[LABELUL].x = graph[0].axis[2].fx; 174 graph[0].label[LABELUL].y = graph[0].axis[2].fy - dXp; 94 175 graph[0].label[LABELX1].x = graph[0].axis[2].fx + 0.5*graph[0].axis[2].dfx; 95 bump = (graph[0].axis[2].islabel) ? PADy : PADx; 96 graph[0].label[LABELX1].y = graph[0].axis[2].fy - bump; 97 98 /* check for the max size of the axis label */ 99 sprintf (string, "%4g", graph[0].axis[1].min); 100 Nc = strlen (string); 101 sprintf (string, "%4g", graph[0].axis[1].max); 102 Nc = MAX (Nc, strlen (string)); 176 graph[0].label[LABELX1].y = graph[0].axis[2].fy - dXp; 177 graph[0].label[LABELUR].x = graph[0].axis[2].fx + graph[0].axis[2].dfx; 178 graph[0].label[LABELUR].y = graph[0].axis[2].fy - dXp; 103 179 104 180 graph[0].label[LABELY0].y = graph[0].axis[1].fy + 0.5*graph[0].axis[1].dfy; 105 bump = (graph[0].axis[1].islabel) ? (0.8*Nc*fontsize + 1) : PADx; 106 graph[0].label[LABELY0].x = graph[0].axis[1].fx - bump; 107 108 sprintf (string, "%4g", graph[0].axis[3].min); 109 Nc = strlen (string); 110 sprintf (string, "%4g", graph[0].axis[3].max); 111 Nc = MAX (Nc, strlen (string)); 181 graph[0].label[LABELY0].x = graph[0].axis[1].fx - dYm; 112 182 113 183 graph[0].label[LABELY1].y = graph[0].axis[3].fy + 0.5*graph[0].axis[3].dfy; 114 bump = (graph[0].axis[3].islabel) ? (0.8*Nc*fontsize + 1) : PADx; 115 graph[0].label[LABELY1].x = graph[0].axis[3].fx + bump; 184 graph[0].label[LABELY1].x = graph[0].axis[3].fx + dYp; 116 185 186 // fprintf (stderr, "section %s, %f,%f : %f,%f\n", section->name, X0, Y0, dX, dY); 187 117 188 /* these are wrong and have to be adjusted to sit in the corners */ 118 189 119 graph[0].label[LABELUL].x = graph[0].axis[2].fx - PADx;120 graph[0].label[LABELUL].y = graph[0].axis[2].fy - PADx;121 graph[0].label[LABELUR].x = graph[0].axis[2].fx + graph[0].axis[2].dfx + PADx;122 graph[0].label[LABELUR].y = graph[0].axis[2].fy - PADx;123 graph[0].label[LABELLL].x = graph[0].axis[0].fx - PADx;124 graph[0].label[LABELLL].y = graph[0].axis[0].fy + PADx;125 graph[0].label[LABELLR].x = graph[0].axis[0].fx + graph[0].axis[0].dfx + PADx;126 graph[0].label[LABELLR].y = graph[0].axis[0].fy + PADx;127 128 190 } -
trunk/Ohana/src/kapa2/src/bDrawFrame.c
r19837 r27790 1 1 # include "Ximage.h" 2 // bDrawLine is a function, not a macro like DrawLine 2 3 3 4 int bDrawFrame (KapaGraphWidget *graph) { 4 5 5 int i, P, IsLabel, IsMajor, fontsize;6 double fx, fy, dfx, dfy, range, major, minor, first, next;7 char *fontname;8 int weight;6 int i, Nticks, P; 7 double fx, fy, dfx, dfy, lweight; 8 // Graphic graphic; is not needed 9 TickMarkData *ticks; 9 10 bDrawColor color; 10 11 12 // don't need graphic, unlink DrawFrame 13 11 14 /* each axis is drawn independently */ 12 fontname = GetRotFont (&fontsize);13 15 for (i = 0; i < 4; i++) { 14 16 fx = graph[0].axis[i].fx; … … 16 18 dfx = graph[0].axis[i].dfx; 17 19 dfy = graph[0].axis[i].dfy; 18 P = hypot ( (double)graph[0].axis[(i+1)%2].dfx, (double)graph[0].axis[(i+1)%2].dfy);20 P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy); 19 21 20 weight = MAX (0, MIN (10, graph[0].axis[i].lweight));22 lweight = MAX (0, MIN (10, graph[0].axis[i].lweight)); 21 23 color = MAX (0, MIN (15, graph[0].axis[i].color)); 22 bDrawSetStyle (color, weight, 0); 24 25 bDrawSetStyle (color, lweight, 0); 26 // function about sets solor and weight 27 // bDrawRotTextInit does not exist 23 28 24 29 if (graph[0].axis[i].isaxis) { … … 27 32 28 33 if (graph[0].axis[i].areticks) { 29 if (isnan(graph[0].axis[i].min) || isinf(graph[0].axis[i].min)) continue; 30 if (isnan(graph[0].axis[i].max) || isinf(graph[0].axis[i].max)) continue; 31 32 range = graph[0].axis[i].max - graph[0].axis[i].min; 33 34 AxisTickScale (&graph[0].axis[i], &major, &minor); 35 36 first = minor*((int)(graph[0].axis[i].min/minor)); 37 if ((range > 0) && (first < graph[0].axis[i].min)) { 38 first += minor; 34 ticks = CreateAxisTicks (&graph[0].axis[i], &Nticks); 35 for (i = 0; i < Nticks; i++) { 36 bDrawTick (&graph[0].axis[i], P, &ticks[i], i); 39 37 } 40 if ((range < 0) && (first > graph[0].axis[i].min)) { 41 first -= minor; 42 } 43 for (next = first; ((range > 0) && (next <= graph[0].axis[i].max)) || ((range < 0) && (next >= graph[0].axis[i].max));) { 44 IsMajor = FALSE; 45 IsMajor |= (fabs((int)(next/major) - (next/major)) < 0.5*(minor/major)); 46 IsMajor |= (fabs ((int)((next + 0.5*minor)/major) - (next/major)) < 0.5*(minor/major)); 47 IsMajor |= (fabs ((int)((next - 0.5*minor)/major) - (next/major)) < 0.5*(minor/major)); 48 IsLabel = (IsMajor && graph[0].axis[i].islabel); 49 bDrawTick (fx, fy, dfx, dfy, P, graph[0].axis[i].min, graph[0].axis[i].max, next, IsLabel, IsMajor, i); 50 if (range > 0) 51 next += minor; 52 else 53 next -= minor; 54 } 38 FREE (ticks); 55 39 } 56 40 } … … 58 42 } 59 43 60 void bDrawTick ( double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int IsLabel, int IsMajor, int naxis) {44 void bDrawTick (Axis *axis, int P, TickMarkData *tick, int naxis) { 61 45 46 double x, y, dx, dy; 62 47 int pos, dir, fontsize; 63 double size, n, x, y, dx, dy;48 double size, n, pad; 64 49 char string[64], *fontname; 50 51 double fx = axis->fx; 52 double fy = axis->fy; 53 double dfx = axis->dfx; 54 double dfy = axis->dfy; 55 56 double min = axis->min; 57 double max = axis->max; 58 59 double value = tick->value; 65 60 66 61 pos = size = 0; 67 62 68 if ( IsMajor) {63 if (tick->IsMajor) { 69 64 size = MAX (0.02, 7.0 / P); 70 65 } else { … … 72 67 } 73 68 74 n = P / sqrt ((double)(dfx*dfx + dfy*dfy));69 n = P / hypot(dfx, dfy); 75 70 x = fx + (value-min)*dfx/(max - min); 76 71 y = fy + (value-min)*dfy/(max - min); 77 72 78 dir = +1; 79 if ((naxis == 0) || (naxis == 1)) dir *= -1; 73 dir = ((naxis == 0) || (naxis == 1)) ? -1 : +1; 80 74 dx = dir*size*dfy*n; 81 75 dy = dir*size*dfx*n; … … 83 77 bDrawLine (x, y, x+dx, y+dy); 84 78 85 if (IsLabel) { 79 if (tick->IsLabel) { 80 int xt, yt; 81 86 82 fontname = GetRotFont (&fontsize); 87 83 84 pad = isfinite(axis->ticktextPad) ? axis->ticktextPad*fontsize : 0.8*fontsize + 1.0; 85 88 86 /* temporarily assume rectilinear axes */ 89 if (naxis == 0) { dx = 0; dy = -dir*(0.8*fontsize + 1); pos = 1; }90 if (naxis == 2) { dx = 0; dy = - dir*(0.8*fontsize + 1); pos = 7; }87 if (naxis == 0) { dx = 0; dy = +pad; pos = 1; } 88 if (naxis == 2) { dx = 0; dy = -pad; pos = 7; } 91 89 92 if (naxis == 1) { dy = 0; dx = - (0.8*fontsize + 1); pos = 3; }93 if (naxis == 3) { dy = 0; dx = + (0.8*fontsize + 1); pos = 5; }90 if (naxis == 1) { dy = 0; dx = -pad; pos = 3; } 91 if (naxis == 3) { dy = 0; dx = +pad; pos = 5; } 94 92 95 x = fx + (value-min)*dfx/(max - min) + dx;96 y = fy + (value-min)*dfy/(max - min) + dy;97 if (fabs(value) < 1e-14) { value = 0.0; }98 sprintf (string, "% g", value);99 bDrawRotText ( (int)x, (int)y, string, pos, 0.0);93 xt = fx + (value-min)*dfx/(max - min) + dx; 94 yt = fy + (value-min)*dfy/(max - min) + dy; 95 if (fabs(value) < 0.001) { value = 0.0; } 96 sprintf (string, "%4g", value); 97 bDrawRotText (xt, yt, string, pos, 0.0); 100 98 } 101 99 } -
trunk/Ohana/src/libkapa/include/kapa.h
r27435 r27790 72 72 float dx; 73 73 float dy; 74 int bg; 74 75 } KapaSection; 75 76 … … 78 79 int style, ptype, ltype, etype, ebar, color; 79 80 double lweight, size; 81 double ticktextPad; 82 double labelPadXm, labelPadYm, labelPadXp, labelPadYp; 83 double padXm, padXp, padYm, padYp; 80 84 Coords coords; 81 85 int flipeast, flipnorth; … … 173 177 int KapaSelectSection (int fd, char *name); 174 178 int KapaGetSection (int fd, char *name); 179 int KapaSectionBG (int fd, char *name, int bg); 175 180 int KapaMoveSection (int fd, char *name, char *direction); 176 181 int KapaSetGraphData (int fd, Graphdata *graphmode); 177 182 int KapaGetGraphData (int fd, Graphdata *graphmode); 183 int KapaScanGraphData (int fd, Graphdata *graphmode); 184 int KapaSendGraphData (int fd, Graphdata *graphmode); 178 185 int KapaSetImageData (int fd, KapaImageData *graphmode); 179 186 int KapaGetImageData (int fd, KapaImageData *graphmode); -
trunk/Ohana/src/libkapa/src/KapaWindow.c
r27588 r27790 38 38 39 39 KiiSendCommand (fd, 4, "DBOX"); 40 KiiSendMessage (fd, "%12.6g %12.6g %12.6g %12.6g", 41 graphdata[0].xmin, graphdata[0].xmax, graphdata[0].ymin, graphdata[0].ymax); 42 43 KiiSendMessage (fd, "%lf %d", graphdata[0].lweight, graphdata[0].color); 44 45 KiiSendMessage (fd, "%s %s %s", graphdata[0].axis, graphdata[0].labels, graphdata[0].ticks); 40 41 KapaSendGraphData (fd, graphdata); 42 46 43 KiiWaitAnswer (fd, "DONE"); 47 44 return (TRUE); … … 84 81 } 85 82 83 // XXX drop this function? : kapa is responsible for the graph initialization 86 84 int KapaInitGraph (Graphdata *graphdata) { 87 85 … … 103 101 graphdata[0].flipeast = TRUE; 104 102 graphdata[0].flipnorth = FALSE; 103 105 104 strcpy (graphdata[0].axis, "2222"); 106 105 strcpy (graphdata[0].ticks, "2222"); 107 106 strcpy (graphdata[0].labels, "2222"); 107 108 graphdata[0].ticktextPad = NAN; 109 110 graphdata[0].labelPadXm = NAN; 111 graphdata[0].labelPadXp = NAN; 112 graphdata[0].labelPadYm = NAN; 113 graphdata[0].labelPadYp = NAN; 114 115 graphdata[0].padXm = NAN; 116 graphdata[0].padXp = NAN; 117 graphdata[0].padYm = NAN; 118 graphdata[0].padYp = NAN; 108 119 109 120 return (TRUE); … … 128 139 } 129 140 130 int KapaSetGraphData (int fd, Graphdata *data) { 131 132 /* tell kapa to look for the incoming image */ 133 KiiSendCommand (fd, 4, "SSTY"); 134 141 int KapaSendGraphData (int fd, Graphdata *data) { 142 135 143 /* send kapa the plot details */ 144 KiiSendMessage (fd, "%g %g %g %g", 145 data[0].xmin, data[0].xmax, 146 data[0].ymin, data[0].ymax); 147 136 148 KiiSendMessage (fd, "%8d %d %d %d %d %d %f %f", 137 149 data[0].style, … … 140 152 data[0].lweight, data[0].size); 141 153 154 KiiSendMessage (fd, "%g %g %g %g %g", 155 data[0].ticktextPad, 156 data[0].padXm, data[0].padXp, 157 data[0].padYm, data[0].padYp); 158 142 159 KiiSendMessage (fd, "%g %g %g %g", 143 data[0]. xmin, data[0].xmax,144 data[0]. ymin, data[0].ymax);160 data[0].labelPadXm, data[0].labelPadXp, 161 data[0].labelPadYm, data[0].labelPadYp); 145 162 146 163 KiiSendMessage (fd, "%g %g %g %g", … … 160 177 data[0].coords.cdelt2); 161 178 162 KiiWaitAnswer (fd, "DONE"); 163 return (TRUE); 164 } 165 166 int KapaGetGraphData (int fd, Graphdata *data) { 167 168 /* tell kapa to look for the incoming image */ 169 KiiSendCommand (fd, 4, "GSTY"); 170 179 KiiSendMessage (fd, "%s %s %s", data[0].axis, data[0].ticks, data[0].labels); 180 181 return (TRUE); 182 } 183 184 int KapaScanGraphData (int fd, Graphdata *data) { 185 171 186 /* send kapa the plot details */ 187 KiiScanMessage (fd, "%lf %lf %lf %lf", 188 &data[0].xmin, &data[0].xmax, 189 &data[0].ymin, &data[0].ymax); 190 172 191 KiiScanMessage (fd, "%d %d %d %d %d %d %lf %lf", 173 192 &data[0].style, … … 176 195 &data[0].lweight, &data[0].size); 177 196 197 KiiScanMessage (fd, "%lf %lf %lf %lf %lf", 198 &data[0].ticktextPad, 199 &data[0].padXm, &data[0].padXp, 200 &data[0].padYm, &data[0].padYp); 201 178 202 KiiScanMessage (fd, "%lf %lf %lf %lf", 179 &data[0]. xmin, &data[0].xmax,180 &data[0]. ymin, &data[0].ymax);203 &data[0].labelPadXm, &data[0].labelPadXp, 204 &data[0].labelPadYm, &data[0].labelPadYp); 181 205 182 206 KiiScanMessage (fd, "%f %f %f %f", … … 196 220 &data[0].coords.cdelt2); 197 221 222 KiiScanMessage (fd, "%s %s %s", data[0].axis, data[0].ticks, data[0].labels); 223 198 224 // XXX at some point, we need to add polynomials and 2-level mosaic 199 225 // astrometry here. 200 226 201 227 data[0].coords.Npolyterms = 0; 228 229 return (TRUE); 230 } 231 232 int KapaSetGraphData (int fd, Graphdata *data) { 233 234 /* tell kapa to look for the incoming image */ 235 KiiSendCommand (fd, 4, "SSTY"); 236 237 KapaSendGraphData (fd, data); 238 239 KiiWaitAnswer (fd, "DONE"); 240 return (TRUE); 241 } 242 243 int KapaGetGraphData (int fd, Graphdata *data) { 244 245 /* tell kapa to look for the incoming image */ 246 KiiSendCommand (fd, 4, "GSTY"); 247 248 KapaScanGraphData (fd, data); 202 249 203 250 KiiWaitAnswer (fd, "DONE"); … … 312 359 313 360 KiiSendCommand (fd, 4, "DSEC"); 314 KiiSendMessage (fd, "%s %6.3f %6.3f %6.3f %6.3f ",361 KiiSendMessage (fd, "%s %6.3f %6.3f %6.3f %6.3f %3d", 315 362 section[0].name, 316 363 section[0].x, 317 364 section[0].y, 318 365 section[0].dx, 319 section[0].dy); 366 section[0].dy, 367 section[0].bg); 368 KiiWaitAnswer (fd, "DONE"); 369 return (TRUE); 370 } 371 372 int KapaSectionBG (int fd, char *name, int bg) { 373 374 KiiSendCommand (fd, 4, "BSEC"); 375 KiiSendMessage (fd, "%s %3d", name, bg); 320 376 KiiWaitAnswer (fd, "DONE"); 321 377 return (TRUE); -
trunk/Ohana/src/opihi/cmd.basic/opihi.c
r27255 r27790 3 3 int opihi_setmode (int argc, char **argv) { 4 4 5 intvalue;5 OpihiVerboseMode value; 6 6 7 7 if (argc < 2) { 8 gprint (GP_ERR, "USAGE: opihi (verbose) [on/off ]\n");8 gprint (GP_ERR, "USAGE: opihi (verbose) [on/off/error]\n"); 9 9 return (FALSE); 10 10 } … … 13 13 if (argc == 2) { 14 14 value = get_verbose_shell(); 15 if (value) { 16 gprint (GP_ERR, "opihi verbose mode: on\n"); 17 } else { 18 gprint (GP_ERR, "opihi verbose mode: off\n"); 19 } 15 switch (value) { 16 case OPIHI_VERBOSE_OFF: 17 gprint (GP_ERR, "opihi verbose mode: off\n"); 18 break; 19 case OPIHI_VERBOSE_ON: 20 gprint (GP_ERR, "opihi verbose mode: on\n"); 21 break; 22 case OPIHI_VERBOSE_ERROR: 23 gprint (GP_ERR, "opihi verbose mode: error\n"); 24 break; 25 default: 26 fprintf (stderr, "impossible condition\n"); 27 abort(); 28 } 20 29 return (TRUE); 21 30 } 22 31 if (!strcasecmp(argv[2], "on")) { 23 set_verbose_shell ( TRUE);32 set_verbose_shell (OPIHI_VERBOSE_ON); 24 33 return (TRUE); 25 34 } 26 35 if (!strcasecmp(argv[2], "off")) { 27 set_verbose_shell (FALSE); 36 set_verbose_shell (OPIHI_VERBOSE_OFF); 37 return (TRUE); 38 } 39 if (!strcasecmp(argv[2], "error")) { 40 set_verbose_shell (OPIHI_VERBOSE_ERROR); 28 41 return (TRUE); 29 42 } -
trunk/Ohana/src/opihi/cmd.data/box.c
r19839 r27790 25 25 } 26 26 27 graphmode.lweight = 1;27 // graphmode.lweight = 1; 28 28 if ((N = get_argument (argc, argv, "-lw"))) { 29 29 remove_argument (N, &argc, argv); … … 32 32 } 33 33 34 graphmode.color = KapaColorByName ("black");34 // graphmode.color = KapaColorByName ("black"); 35 35 if ((N = get_argument (argc, argv, "-c"))) { 36 36 remove_argument (N, &argc, argv); … … 40 40 } 41 41 42 strcpy (graphmode.ticks, "2222"); 42 // XXX need to get the current values from kapa 43 // strcpy (graphmode.ticks, "2222"); 43 44 if ((N = get_argument (argc, argv, "-ticks"))) { 44 45 remove_argument (N, &argc, argv); … … 51 52 } 52 53 53 strcpy (graphmode.labels, "2222");54 // strcpy (graphmode.labels, "2222"); 54 55 if ((N = get_argument (argc, argv, "-labels"))) { 55 56 remove_argument (N, &argc, argv); … … 62 63 } 63 64 64 strcpy (graphmode.axis, "2222");65 // strcpy (graphmode.axis, "2222"); 65 66 if ((N = get_argument (argc, argv, "-axis"))) { 66 67 remove_argument (N, &argc, argv); … … 71 72 if ((graphmode.axis[i] != '0') && (graphmode.axis[i] != '1') && (graphmode.axis[i] != '2')) { goto usage; } 72 73 } 74 } 75 76 if ((N = get_argument (argc, argv, "-tickpad"))) { 77 remove_argument (N, &argc, argv); 78 graphmode.ticktextPad = atof(argv[N]); 79 remove_argument (N, &argc, argv); 80 } 81 82 if ((N = get_argument (argc, argv, "-labelpadx"))) { 83 remove_argument (N, &argc, argv); 84 graphmode.labelPadXm = atof(argv[N]); 85 remove_argument (N, &argc, argv); 86 } 87 88 if ((N = get_argument (argc, argv, "-labelpady"))) { 89 remove_argument (N, &argc, argv); 90 graphmode.labelPadYm = atof(argv[N]); 91 remove_argument (N, &argc, argv); 92 } 93 94 if ((N = get_argument (argc, argv, "+labelpadx"))) { 95 remove_argument (N, &argc, argv); 96 graphmode.labelPadXp = atof(argv[N]); 97 remove_argument (N, &argc, argv); 98 } 99 100 if ((N = get_argument (argc, argv, "+labelpady"))) { 101 remove_argument (N, &argc, argv); 102 graphmode.labelPadYp = atof(argv[N]); 103 remove_argument (N, &argc, argv); 104 } 105 106 if ((N = get_argument (argc, argv, "-labelpad"))) { 107 remove_argument (N, &argc, argv); 108 graphmode.labelPadXm = atof(argv[N]); 109 graphmode.labelPadXp = atof(argv[N]); 110 graphmode.labelPadYm = atof(argv[N]); 111 graphmode.labelPadYp = atof(argv[N]); 112 remove_argument (N, &argc, argv); 113 } 114 115 if ((N = get_argument (argc, argv, "-pad"))) { 116 remove_argument (N, &argc, argv); 117 graphmode.padXm = atof(argv[N]); 118 graphmode.padXp = atof(argv[N]); 119 graphmode.padYm = atof(argv[N]); 120 graphmode.padYp = atof(argv[N]); 121 remove_argument (N, &argc, argv); 122 } 123 if ((N = get_argument (argc, argv, "-xpad"))) { 124 remove_argument (N, &argc, argv); 125 graphmode.padXm = atof(argv[N]); 126 remove_argument (N, &argc, argv); 127 } 128 if ((N = get_argument (argc, argv, "+xpad"))) { 129 remove_argument (N, &argc, argv); 130 graphmode.padXp = atof(argv[N]); 131 remove_argument (N, &argc, argv); 132 } 133 if ((N = get_argument (argc, argv, "-ypad"))) { 134 remove_argument (N, &argc, argv); 135 graphmode.padYm = atof(argv[N]); 136 remove_argument (N, &argc, argv); 137 } 138 if ((N = get_argument (argc, argv, "+ypad"))) { 139 remove_argument (N, &argc, argv); 140 graphmode.padYp = atof(argv[N]); 141 remove_argument (N, &argc, argv); 73 142 } 74 143 -
trunk/Ohana/src/opihi/cmd.data/section.c
r27491 r27790 1 1 # include "data.h" 2 2 3 enum {NONE, LIST, UP, DOWN, TOP, BOTTOM, TOOL };3 enum {NONE, LIST, UP, DOWN, TOP, BOTTOM, TOOL, BG}; 4 4 5 5 int section (int argc, char **argv) { 6 6 7 int N, action, kapa ;7 int N, action, kapa, background; 8 8 Graphdata graphmode; 9 9 KapaSection section; … … 37 37 location = argv[N]; 38 38 remove_argument (N, &argc, argv); 39 } 40 41 background = -1; // invisible 42 if ((N = get_argument (argc, argv, "-bg"))) { 43 remove_argument (N, &argc, argv); 44 if (!strcasecmp (argv[N], "NONE")) { 45 background = -1; 46 } else { 47 background = KapaColorByName(argv[N]); 48 } 49 remove_argument (N, &argc, argv); 50 action = BG; 39 51 } 40 52 … … 82 94 break; 83 95 96 case BG: 97 KapaSectionBG (kapa, argv[1], background); 98 break; 99 84 100 case TOOL: 85 101 if (!strcmp(location, "-x")) { … … 121 137 section.dx = atof (argv[4]); 122 138 section.dy = atof (argv[5]); 139 section.bg = background; 123 140 KapaSetSection (kapa, §ion); 124 141 return (TRUE); -
trunk/Ohana/src/opihi/include/shell.h
r27435 r27790 15 15 typedef enum {GP_FILE, GP_BUFF} gpMode; 16 16 typedef enum {GP_LOG, GP_ERR} gpDest; 17 typedef enum {OPIHI_VERBOSE_OFF, OPIHI_VERBOSE_ON, OPIHI_VERBOSE_ERROR} OpihiVerboseMode; 17 18 18 19 typedef int CommandF (int argc, char **argv); -
trunk/Ohana/src/opihi/lib.shell/command.c
r27255 r27790 2 2 # define DEBUG 0 3 3 4 static int VERBOSE_SHELL = FALSE;4 static int VERBOSE_SHELL = OPIHI_VERBOSE_OFF; 5 5 6 6 int command (char *line, char **outline, int VERBOSE) { … … 10 10 Command *cmd; 11 11 12 rawline = NULL;13 //rawline = strcreate (line);12 // rawline = NULL; 13 rawline = strcreate (line); 14 14 15 15 /* force a space between ! and first word: !ls becomes ! ls */ … … 24 24 /* expand anything of the form fred[N] */ 25 25 line = expand_vectors (line); /* line is freed here, new one allocated */ 26 27 // print the line with the variables and vectors expanded, but before evaluating 28 // any in-line math expression 29 if (VERBOSE_SHELL == OPIHI_VERBOSE_ON) gprint (GP_ERR, "opihi: %s\n", line); 30 26 31 /* solve math expresions, assign variable, if needed */ 27 32 line = parse (line); /* line is freed here, new one allocated */ … … 31 36 *outline = line; 32 37 33 if (VERBOSE_SHELL) gprint (GP_ERR, "opihi: %s\n", line);34 35 38 argv = parse_commands (line, &argc); 36 39 if (argc == 0) { … … 60 63 msg = get_variable_ptr ("ERRORMSG"); 61 64 if (msg != (char *) NULL) gprint (GP_ERR, "%s\n", msg); 62 if (VERBOSE_SHELL ) gprint (GP_ERR, "error on line: %s\n", rawline);65 if (VERBOSE_SHELL != OPIHI_VERBOSE_OFF) gprint (GP_ERR, "error on line: %s\n", rawline); 63 66 } 64 67 -
trunk/Ohana/src/relastro
- Property svn:mergeinfo changed (with no actual effect on merging)
-
trunk/Ohana/src/relphot/src/StarOps.c
r27586 r27790 225 225 } 226 226 227 // XXX make it optional to apply Mcal (do I need an extra field for advisory Mcal?) 227 228 list[N] = Msys - catalog[i].measure[m].Mcal; 228 229 dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR); -
trunk/Ohana/src/uniphot/Makefile
r12842 r27790 1 default: uniphot 1 default: uniphot setphot 2 2 help: 3 @echo "make options: uniphot (default)"3 @echo "make options: uniphot setphot default help install default (uniphot setphot)" 4 4 5 5 include ../../Makefile.System … … 18 18 19 19 uniphot: $(BIN)/uniphot.$(ARCH) 20 install: $(DESTBIN)/uniphot 20 setphot: $(BIN)/setphot.$(ARCH) 21 install: $(DESTBIN)/uniphot $(DESTBIN)/setphot 21 22 22 23 UNIPHOT = \ … … 24 25 $(SRC)/initialize.$(ARCH).o \ 25 26 $(SRC)/ConfigInit.$(ARCH).o \ 26 $(SRC)/args.$(ARCH).o \27 $(SRC)/args.$(ARCH).o \ 27 28 $(SRC)/liststats.$(ARCH).o \ 28 29 $(SRC)/load_images.$(ARCH).o \ … … 39 40 $(UNIPHOT): $(INC)/uniphot.h 40 41 $(BIN)/uniphot.$(ARCH): $(UNIPHOT) 42 43 SETPHOT = \ 44 $(SRC)/setphot.$(ARCH).o \ 45 $(SRC)/initialize.$(ARCH).o \ 46 $(SRC)/ConfigInit.$(ARCH).o \ 47 $(SRC)/args.$(ARCH).o \ 48 $(SRC)/liststats.$(ARCH).o \ 49 $(SRC)/load_zpt_table.$(ARCH).o \ 50 $(SRC)/load_images.$(ARCH).o \ 51 $(SRC)/match_zpts_to_images.$(ARCH).o \ 52 $(SRC)/update_catalog_setphot.$(ARCH).o \ 53 $(SRC)/SetSignals.$(ARCH).o \ 54 $(SRC)/Shutdown.$(ARCH).o 55 56 $(SETPHOT): $(INC)/uniphot.h 57 $(BIN)/setphot.$(ARCH): $(SETPHOT) -
trunk/Ohana/src/uniphot/include/uniphot.h
r27435 r27790 39 39 } Group; 40 40 41 typedef struct { 42 float zpt; 43 e_time time; 44 int found; 45 } ZptTable; 46 41 47 /* global variables set in parameter file */ 42 48 char ImageCat[256]; … … 44 50 char CATMODE[16]; /* raw, mef, split, mysql */ 45 51 char CATFORMAT[16]; /* internal, elixir, loneos, panstarrs */ 52 char SKY_TABLE[256]; 53 int SKY_DEPTH; /** XXX EAM : depth of catalog tables, fix usage */ 54 char GSCFILE[256]; 46 55 char STATMODE[64]; 47 56 int VERBOSE; … … 66 75 67 76 /***** prototypes ****/ 68 void ConfigInit PROTO((int *argc, char **argv)); 69 void DonePlotting PROTO((Graphdata *graphmode, int N)); 70 void JpegPlot PROTO((Graphdata *graphmode, int N, char *filename)); 71 void PSPlot PROTO((Graphdata *graphmode, int N, char *filename)); 72 void PlotLabel PROTO((char *string, int N)); 73 void PlotVector PROTO((int Npts, double *vect, int mode, int N)); 74 void PrepPlotting PROTO((int Npts, Graphdata *graphmode, int N)); 75 void XDead PROTO((void)); 76 int args PROTO((int argc, char **argv)); 77 void dumpresult PROTO((void)); 78 Group *find_image_sgroups PROTO((FITS_DB *db, ImageLink **imlink, int *Nsgroup)); 79 Group *find_image_tgroups PROTO((FITS_DB *db, ImageLink **imlink, int *Ntgroup)); 80 void fit_sgroup PROTO((Group *sgroup, int Nsgroup)); 81 void fit_tgroup PROTO((Group *tgroup, int Ntgroup)); 82 int gcatalog PROTO((Catalog *catalog)); 83 void initialize PROTO((int argc, char **argv)); 84 void initstats PROTO((char *mode)); 85 int liststats PROTO((double *value, double *dvalue, int N, StatType *stats)); 86 int load_images PROTO((FITS_DB *db)); 87 int main PROTO((int argc, char **argv)); 88 int open_graph PROTO((int N)); 89 void sort PROTO((unsigned int *X, int N)); 90 void sortB PROTO((double *X, double *Y, int N)); 91 void sortD PROTO((double *X, double *Y, double *Z, int N)); 92 void update_dvo_catalog PROTO((Catalog *catalog, Group *sgroup, int warn)); 93 void wcatalog PROTO((Catalog *catalog)); 94 void wimages PROTO((Image *image, int Nimage)); 95 void check_permissions PROTO((char *basefile)); 96 void lock_image_db PROTO((FITS_DB *db, char *filename)); 97 void unlock_image_db PROTO((FITS_DB *db)); 98 void create_image_db PROTO((FITS_DB *db)); 99 void set_db PROTO((FITS_DB *in)); 100 int Shutdown PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) ); 101 void TrapSignal PROTO((int sig)); 102 void SetProtect PROTO((int mode)); 103 int SetSignals PROTO((void)); 104 int subset_images PROTO((FITS_DB *db)); 105 void update PROTO((FITS_DB *db, Group *sgroup, int Nsgroup)); 106 void sort_time PROTO((unsigned int *value, int N)); 77 void ConfigInit PROTO((int *argc, char **argv)); 78 void DonePlotting PROTO((Graphdata *graphmode, int N)); 79 void JpegPlot PROTO((Graphdata *graphmode, int N, char *filename)); 80 void PSPlot PROTO((Graphdata *graphmode, int N, char *filename)); 81 void PlotLabel PROTO((char *string, int N)); 82 void PlotVector PROTO((int Npts, double *vect, int mode, int N)); 83 void PrepPlotting PROTO((int Npts, Graphdata *graphmode, int N)); 84 void XDead PROTO((void)); 85 int args_uniphot PROTO((int argc, char **argv)); 86 int args_setphot PROTO((int argc, char **argv)); 87 void dumpresult PROTO((void)); 88 Group *find_image_sgroups PROTO((FITS_DB *db, ImageLink **imlink, int *Nsgroup)); 89 Group *find_image_tgroups PROTO((FITS_DB *db, ImageLink **imlink, int *Ntgroup)); 90 void fit_sgroup PROTO((Group *sgroup, int Nsgroup)); 91 void fit_tgroup PROTO((Group *tgroup, int Ntgroup)); 92 int gcatalog PROTO((Catalog *catalog)); 93 void initialize_uniphot PROTO((int argc, char **argv)); 94 void initialize_setphot PROTO((int argc, char **argv)); 95 void initstats PROTO((char *mode)); 96 int liststats PROTO((double *value, double *dvalue, int N, StatType *stats)); 97 int load_images_uniphot PROTO((FITS_DB *db)); 98 int main PROTO((int argc, char **argv)); 99 int open_graph PROTO((int N)); 100 void sort PROTO((unsigned int *X, int N)); 101 void sortB PROTO((double *X, double *Y, int N)); 102 void sortD PROTO((double *X, double *Y, double *Z, int N)); 103 void update_dvo_catalog PROTO((Catalog *catalog, Group *sgroup, int warn)); 104 void wcatalog PROTO((Catalog *catalog)); 105 void wimages PROTO((Image *image, int Nimage)); 106 void check_permissions PROTO((char *basefile)); 107 void lock_image_db PROTO((FITS_DB *db, char *filename)); 108 void unlock_image_db PROTO((FITS_DB *db)); 109 void create_image_db PROTO((FITS_DB *db)); 110 void set_db PROTO((FITS_DB *in)); 111 int Shutdown PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) ); 112 void TrapSignal PROTO((int sig)); 113 void SetProtect PROTO((int mode)); 114 int SetSignals PROTO((void)); 115 int subset_images PROTO((FITS_DB *db)); 116 void update PROTO((FITS_DB *db, Group *sgroup, int Nsgroup)); 117 void sort_time PROTO((unsigned int *value, int N)); 118 119 // setphot-specific prototypes 120 ZptTable *load_zpt_table PROTO((char *filename, int *nzpts)); 121 Image *load_images_setphot PROTO((FITS_DB *db, off_t *Nimage)); 122 int match_zpts_to_images PROTO((Image *image, off_t Nimage, ZptTable *zpts, int Nzpts)); 123 int update_setphot PROTO((Image *image, off_t Nimage)); 124 void update_catalog_setphot PROTO((Catalog *catalog, Image *image, off_t *index, off_t Nimage)); -
trunk/Ohana/src/uniphot/src/ConfigInit.c
r25757 r27790 1 1 # include "uniphot.h" 2 3 void GetConfig (char *config, char *field, char *format, int N, void *ptr); 2 4 3 5 void ConfigInit (int *argc, char **argv) { … … 18 20 if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file); 19 21 20 ScanConfig (config, "CATDIR", "%s", 0, CATDIR);22 GetConfig (config, "CATDIR", "%s", 0, CATDIR); 21 23 ScanConfig (config, "CATMODE", "%s", 0, CATMODE); 22 24 ScanConfig (config, "CATFORMAT", "%s", 0, CATFORMAT); … … 24 26 25 27 sprintf (ImageCat, "%s/Images.dat", CATDIR); 28 29 GetConfig (config, "GSCFILE", "%s", 0, GSCFILE); 30 if (!ScanConfig (config, "SKY_DEPTH", "%d", 0, &SKY_DEPTH)) { 31 SKY_DEPTH = 2; 32 } 33 if (!ScanConfig (config, "SKY_TABLE", "%s", 0, SKY_TABLE)) { 34 SKY_TABLE[0] = 0; 35 } 26 36 27 37 ScanConfig (config, "ZERO_PT", "%lf", 0, &ZERO_POINT); … … 42 52 43 53 } 54 55 void GetConfig (char *config, char *field, char *format, int N, void *ptr) { 56 57 char *status; 58 59 status = ScanConfig (config, field, format, N, ptr); 60 if (status == NULL) { 61 fprintf (stderr, "error in config, cannot find %s\n", field); 62 exit (1); 63 } 64 return; 65 } -
trunk/Ohana/src/uniphot/src/Shutdown.c
r7080 r27790 23 23 SetProtect (TRUE); 24 24 gfits_db_close (db); 25 fprintf (stderr, "ERROR: addstarhalted\n");25 fprintf (stderr, "ERROR: halted\n"); 26 26 exit (1); 27 27 } -
trunk/Ohana/src/uniphot/src/args.c
r14590 r27790 1 1 # include "uniphot.h" 2 2 3 int args (int argc, char **argv) {3 int args_uniphot (int argc, char **argv) { 4 4 5 5 int N; … … 72 72 } 73 73 74 int args_setphot (int argc, char **argv) { 75 76 int N; 77 78 VERBOSE = FALSE; 79 if ((N = get_argument (argc, argv, "-v"))) { 80 VERBOSE = TRUE; 81 remove_argument (N, &argc, argv); 82 } 83 84 UPDATE = FALSE; 85 if ((N = get_argument (argc, argv, "-update"))) { 86 remove_argument (N, &argc, argv); 87 UPDATE = TRUE; 88 } 89 90 if (argc != 2) { 91 fprintf (stderr, "ERROR: USAGE: setphot (zptfile) [options]\n"); 92 exit (2); 93 } 94 95 return (TRUE); 96 } 97 -
trunk/Ohana/src/uniphot/src/initialize.c
r2492 r27790 1 1 # include "uniphot.h" 2 2 3 void initialize (int argc, char **argv) {3 void initialize_uniphot (int argc, char **argv) { 4 4 5 5 /* are these set correctly? */ 6 6 ConfigInit (&argc, argv); 7 args (argc, argv);7 args_uniphot (argc, argv); 8 8 9 9 if ((photcode = GetPhotcodebyName (argv[1])) == NULL) { … … 21 21 } 22 22 23 void initialize_setphot (int argc, char **argv) { 24 25 /* are these set correctly? */ 26 ConfigInit (&argc, argv); 27 args_setphot (argc, argv); 28 } 29 -
trunk/Ohana/src/uniphot/src/load_images.c
r6238 r27790 1 1 # include "uniphot.h" 2 2 3 int load_images (FITS_DB *db) {3 int load_images_uniphot (FITS_DB *db) { 4 4 5 5 if (VERBOSE) fprintf (stderr, "finding images\n"); … … 10 10 return (TRUE); 11 11 } 12 13 Image *load_images_setphot (FITS_DB *db, off_t *Nimage) { 14 15 Image *image; 16 17 if (VERBOSE) fprintf (stderr, "finding images\n"); 18 19 /* read entire db table */ 20 if (!dvo_image_load (db, VERBOSE, FALSE)) Shutdown ("can't read image catalog %s", db[0].filename); 21 22 /* use a vtable to keep the images to be calibrated */ 23 image = gfits_table_get_Image (&db[0].ftable, Nimage, &db[0].swapped); 24 25 fprintf (stderr, "loaded %lld images\n", (long long) *Nimage); 26 27 return (image); 28 } -
trunk/Ohana/src/uniphot/src/uniphot.c
r6238 r27790 9 9 10 10 /* get configuration info, args, lockfile */ 11 initialize (argc, argv);11 initialize_uniphot (argc, argv); 12 12 13 13 set_db (&db); … … 18 18 19 19 /* load images */ 20 load_images (&db);20 load_images_uniphot (&db); 21 21 22 22 /* filter image list by selection */
Note:
See TracChangeset
for help on using the changeset viewer.
