Changeset 5612
- Timestamp:
- Nov 28, 2005, 8:27:19 AM (21 years ago)
- Location:
- trunk/Ohana/src/kapa
- Files:
-
- 1 added
- 17 edited
-
Makefile (modified) (1 diff)
-
event/EventLoop.c (modified) (2 diffs)
-
event/FlushDisplay.c (modified) (1 diff)
-
event/Refresh.c (modified) (1 diff)
-
graph/ErasePlot.c (modified) (1 diff)
-
graph/LoadBox.c (modified) (2 diffs)
-
graph/LoadObject.c (modified) (1 diff)
-
graph/bDrawFrame.c (modified) (2 diffs)
-
graph/bDrawFuncs.c (modified) (4 diffs)
-
graph/bDrawObjects.c (modified) (3 diffs)
-
graph/bDrawRotFont.c (modified) (3 diffs)
-
include/bDraw.h (modified) (1 diff)
-
include/globals.h (modified) (1 diff)
-
setup/CloseDisplay.c (modified) (1 diff)
-
setup/DefineLayout.c (modified) (2 diffs)
-
setup/SetUpWindow.c (modified) (1 diff)
-
setup/Ximage.c (modified) (1 diff)
-
setup/args.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kapa/Makefile
r5610 r5612 72 72 $(SDIR)/CreateWindow.$(ARCH).o $(SDIR)/SetNormalHints.$(ARCH).o \ 73 73 $(SDIR)/DefineLayout.$(ARCH).o $(SDIR)/SetUpDisplay.$(ARCH).o \ 74 $(SDIR)/SetUpWindow.$(ARCH).o \74 $(SDIR)/SetUpWindow.$(ARCH).o $(SDIR)/args.$(ARCH).o \ 75 75 $(SDIR)/GetColor.$(ARCH).o $(SDIR)/SetWMHints.$(ARCH).o \ 76 76 $(SDIR)/LoadFont.$(ARCH).o $(SDIR)/TopWindow.$(ARCH).o \ -
trunk/Ohana/src/kapa/event/EventLoop.c
r3695 r5612 20 20 Display *display; 21 21 22 Refresh (1);22 if (USE_XWINDOW) Refresh (1); 23 23 24 24 status = TRUE; … … 27 27 if (!CheckPipe ()) return (FALSE); 28 28 29 if (!USE_XWINDOW) { 30 usleep (50000); 31 continue; 32 } 33 29 34 if (XEventsQueued (graphic.display, QueuedAfterFlush) < 1) { 30 35 usleep (50000); -
trunk/Ohana/src/kapa/event/FlushDisplay.c
r4769 r5612 10 10 int flush; 11 11 double dtime; 12 13 if (!USE_XWINDOW) return; 12 14 13 15 flush = FALSE; -
trunk/Ohana/src/kapa/event/Refresh.c
r5354 r5612 5 5 int i; 6 6 7 if (!USE_XWINDOW) return; 7 8 if (HAVE_BACKING) return; 8 9 -
trunk/Ohana/src/kapa/graph/ErasePlot.c
r2473 r5612 47 47 } 48 48 49 XClearWindow (graphic.display, graphic.window);49 if (USE_XWINDOW) XClearWindow (graphic.display, graphic.window); 50 50 Refresh (1); 51 51 -
trunk/Ohana/src/kapa/graph/LoadBox.c
r2473 r5612 64 64 } 65 65 66 DrawFrame (layout);66 if (USE_XWINDOW) DrawFrame (layout); 67 67 status = TRUE; 68 68 if (status) { … … 70 70 PositionPicture (§ion[i]); 71 71 } 72 XClearWindow (graphic.display, graphic.window);72 if (USE_XWINDOW) XClearWindow (graphic.display, graphic.window); 73 73 Refresh (1); 74 74 } else { -
trunk/Ohana/src/kapa/graph/LoadObject.c
r5386 r5612 98 98 if (DEBUG) fprintf (stderr, "loaded %d objects, using object %d\n", layout[0].objects[N].Npts, N); 99 99 100 DrawObjectN (layout, &layout[0].objects[layout[0].Nobjects-1]);100 if (USE_XWINDOW) DrawObjectN (layout, &layout[0].objects[layout[0].Nobjects-1]); 101 101 FlushDisplay (); 102 102 -
trunk/Ohana/src/kapa/graph/bDrawFrame.c
r5610 r5612 18 18 19 19 if (layout[0].axis[i].isaxis) { 20 bDrawLine (fx, fy, fx+dfx, fy+dfy , FALSE);20 bDrawLine (fx, fy, fx+dfx, fy+dfy); 21 21 } 22 22 … … 70 70 dy = dir*size*dfx*n; 71 71 72 bDrawLine (x, y, x+dx, y+dy , FALSE);72 bDrawLine (x, y, x+dx, y+dy); 73 73 74 74 if (mode == 1) { -
trunk/Ohana/src/kapa/graph/bDrawFuncs.c
r5610 r5612 71 71 } 72 72 73 // use the Bresenham line drawing technique 74 void bDrawLine (double x1, double y1, double x2, double y2, int swapcoords) { 73 void bDrawTriOpen (double x1, double y1, double x2, double y2, double x3, double y3) { 74 75 bDrawLine (x1, y1, x2, y2); 76 bDrawLine (x2, y2, x3, y3); 77 bDrawLine (x3, y3, x1, y1); 78 79 return; 80 } 81 82 void bDrawRectOpen (double x1, double y1, double x2, double y2) { 75 83 76 84 int X1, Y1, X2, Y2; 77 int X, Y, dX, dY; 85 86 if (x1 > x2) SWAP (x1, x2); 87 if (y1 > y2) SWAP (y1, y2); 88 89 X1 = MIN (MAX (ROUND (x1), 0), bBuffer[0].Nx - 1); 90 X2 = MIN (MAX (ROUND (x2), 1), bBuffer[0].Nx); 91 92 Y1 = MIN (MAX (ROUND (y1), 0), bBuffer[0].Ny - 1); 93 Y2 = MIN (MAX (ROUND (y2), 1), bBuffer[0].Ny); 94 95 bDrawLineHorizontal (X1, X2, Y1); 96 bDrawLineHorizontal (X1, X2, Y2); 97 bDrawLineVertical (X1, Y1, Y2); 98 bDrawLineVertical (X2, Y1, Y2); 99 return; 100 } 101 102 void bDrawRectFill (double x1, double y1, double x2, double y2) { 103 104 int i; 105 int X1, Y1, X2, Y2; 106 107 if (x1 > x2) SWAP (x1, x2); 108 if (y1 > y2) SWAP (y1, y2); 109 110 X1 = MIN (MAX (ROUND (x1), 0), bBuffer[0].Nx - 1); 111 X2 = MIN (MAX (ROUND (x2), 1), bBuffer[0].Nx); 112 113 Y1 = MIN (MAX (ROUND (y1), 0), bBuffer[0].Ny - 1); 114 Y2 = MIN (MAX (ROUND (y2), 0), bBuffer[0].Ny); 115 116 for (i = Y1; i < Y2; i++) { 117 bDrawLineHorizontal (X1, X2, i); 118 } 119 return; 120 } 121 122 // identify the quadrant and draw the correct line 123 void bDrawLine (double x1, double y1, double x2, double y2) { 124 125 int FlipDirect, FlipCoords; 126 int X1, Y1, X2, Y2, dX, dY; 78 127 79 128 /* rather than draw the line from float positions, we find the closest … … 88 137 dY = Y2 - Y1; 89 138 90 // fprintf (stderr, "(%f,%f) - (%f,%f)\n", x1, y1, x2, y2); 91 if (x1 > x2) { 92 // fprintf (stderr, "flip direct\n"); 93 bDrawLine (x2, y2, x1, y1, swapcoords); 94 return; 95 } 96 if (abs(dX) < abs(dY)) { 97 // fprintf (stderr, "flip coords\n"); 98 bDrawLine (y1, x1, y2, x2, TRUE); 99 return; 100 } 101 102 /* integer-only Bresenham line-draw version which is fast */ 103 { 104 int e, e2; 105 106 Y = Y1; 107 e = 0; 108 for (X = X1; X <= X2; X++) { 109 if (swapcoords) { 110 bDrawPoint (Y,X); 111 } else { 112 bDrawPoint (X,Y); 113 } 114 e += dY; 115 e2 = 2 * e; 116 if (e2 > dX) { 117 Y++; 118 e -= dX; 119 } 120 if (e2 < -dX) { 121 Y--; 122 e += dX; 123 } 124 } 125 } 126 return; 127 } 128 129 void bDrawRectOpen (int x1, int y1, int x2, int y2) { 130 131 return; 132 } 133 134 void bDrawRectFill (int x1, int y1, int x2, int y2) { 135 136 return; 137 } 138 139 void bDrawTriOpen (int x1, int y1, int x2, int y2, int x3, int y3) { 140 141 return; 142 } 143 144 void bDrawTriFill (int x1, int y1, int x2, int y2, int x3, int y3) { 145 139 FlipCoords = (abs(dX) < abs(dY)); 140 FlipDirect = FlipCoords ? (y1 > y2) : (x1 > x2); 141 142 if (!FlipDirect && !FlipCoords) bDrawLineWeight (X1, Y1, X2, Y2, FALSE); 143 if ( FlipDirect && !FlipCoords) bDrawLineWeight (X2, Y2, X1, Y1, FALSE); 144 if (!FlipDirect && FlipCoords) bDrawLineWeight (Y1, X1, Y2, X2, TRUE); 145 if ( FlipDirect && FlipCoords) bDrawLineWeight (Y2, X2, Y1, X1, TRUE); 146 147 return; 148 } 149 150 // draw a series of lines to give the line weight 151 void bDrawLineWeight (int X1, int Y1, int X2, int Y2, int swapcoords) { 152 153 int dN, dNs, dNe; 154 155 dNs = -0.5*(bWeight - 1); 156 /* 0, 0, 0, -1, -1, -2, -2 */ 157 158 dNe = +0.5*bWeight + 1; 159 /* 1, 1, 2, 2, 2, 3, 3 */ 160 161 for (dN = dNs; dN < dNe; dN++) { 162 bDrawLineBresen (X1, Y1 + dN, X2, Y2 + dN, swapcoords); 163 } 164 return; 165 } 166 167 // use the Bresenham line drawing technique 168 // integer-only Bresenham line-draw version which is fast 169 void bDrawLineBresen (int X1, int Y1, int X2, int Y2, int swapcoords) { 170 171 int X, Y, dX, dY; 172 int e, e2; 173 int N, DashOn; 174 175 dX = X2 - X1; 176 dY = Y2 - Y1; 177 178 DashOn = TRUE; 179 180 Y = Y1; 181 e = 0; 182 for (X = X1, N = 0; X <= X2; X++, N++) { 183 if (bType == 1) { DashOn = (N % 10) < 5; } 184 if (bType == 2) { DashOn = (N % 6) < 3; } 185 if (swapcoords) { 186 if (DashOn) bDrawPoint (Y,X); 187 } else { 188 if (DashOn) bDrawPoint (X,Y); 189 } 190 e += dY; 191 e2 = 2 * e; 192 if (e2 > dX) { 193 Y++; 194 e -= dX; 195 } 196 if (e2 < -dX) { 197 Y--; 198 e += dX; 199 } 200 } 201 return; 202 } 203 204 void bDrawLineHorizontal (int X1, int X2, int Y) { 205 206 int i; 207 208 for (i = X1; i < X2; i++) { 209 bBuffer[0].pixels[Y][i] = bColor; 210 } 211 return; 212 } 213 214 void bDrawLineVertical (int X, int Y1, int Y2) { 215 216 int i; 217 218 for (i = Y1; i < Y2; i++) { 219 bBuffer[0].pixels[i][X] = bColor; 220 } 221 return; 222 } 223 224 void bDrawTriFill (double x1, double y1, double x2, double y2, double x3, double y3) { 225 226 bDrawTriOpen (x1, y1, x2, y2, x3, y3); 146 227 return; 147 228 } … … 181 262 } 182 263 264 // draw a series of circles to give line weight 265 void bDrawCircle (double xc, double yc, double radius) { 266 267 int dN, dNs, dNe; 268 269 dNs = -0.5*(bWeight - 1); 270 /* 0, 0, 0, -1, -1, -2, -2 */ 271 272 dNe = +0.5*bWeight + 1; 273 /* 1, 1, 2, 2, 2, 3, 3 */ 274 275 for (dN = dNs; dN < dNe; dN++) { 276 bDrawCircle (xc, yc, radius + dN); 277 } 278 return; 279 } 280 183 281 // draw a pure circle 184 void bDrawCircle (double xc, double yc, double radius) {282 void bDrawCircleSingle (double xc, double yc, double radius) { 185 283 186 284 int Xc, Yc, Radius; … … 206 304 bDrawPoint (Xc-y, Yc+x); 207 305 bDrawPoint (Xc-y, Yc-x); 306 307 if (d < 0) { 308 // d = d + 4*x + 6; 309 d = d + 8*x + 4; 310 } else { 311 // d = d + 4*(x-y) + 10; 312 d = d + 8*(x-y) + 8; 313 y--; 314 } 315 x++; 316 } 317 } 318 319 // draw a pure circle 320 void bDrawCircleFill (double xc, double yc, double radius) { 321 322 int Xc, Yc, Radius; 323 int x, y, d; 324 325 Xc = ROUND(xc); 326 Yc = ROUND(yc); 327 Radius = ROUND(radius); 328 329 x = 0; 330 y = Radius; 331 332 // d = 3 - 2*Radius; 333 d = 5 - 4*radius; 334 335 while (x <= y) { 336 bDrawLineHorizontal (Xc-x, Xc+x, Yc+y); 337 bDrawLineHorizontal (Xc-x, Xc+x, Yc-y); 338 bDrawLineHorizontal (Xc-y, Xc+y, Yc+x); 339 bDrawLineHorizontal (Xc-y, Xc+y, Yc-x); 208 340 209 341 if (d < 0) { -
trunk/Ohana/src/kapa/graph/bDrawObjects.c
r5610 r5612 2 2 # include "bDraw.h" 3 3 4 # define DrawLine(X1,Y1,X2,Y2) (bDrawLine ((X1), (Y1), (X2), (Y2) , FALSE))4 # define DrawLine(X1,Y1,X2,Y2) (bDrawLine ((X1), (Y1), (X2), (Y2))) 5 5 # define DrawCircle(X1,Y1,R) (bDrawCircle ((X1), (Y1), (R))) 6 # define DrawRectangle(X,Y,dX,dY) (bDrawRectOpen ((X-0.5*dX), (Y-0.5*dY), ( dX), (dY)))7 # define FillRectangle(X,Y,dX,dY) (bDrawRectFill ((X-0.5*dX), (Y-0.5*dY), ( dX), (dY)))6 # define DrawRectangle(X,Y,dX,dY) (bDrawRectOpen ((X-0.5*dX), (Y-0.5*dY), (X+0.5*dX), (Y+0.5*dY))) 7 # define FillRectangle(X,Y,dX,dY) (bDrawRectFill ((X-0.5*dX), (Y-0.5*dY), (X+0.5*dX), (Y+0.5*dY))) 8 8 # define FillTriangle(X1,Y1,X2,Y2,X3,Y3) (bDrawTriFill ((X1), (Y1), (X2), (Y2), (X3), (Y3))) 9 # define OpenTriangle(X1,Y1,X2,Y2,X3,Y3) (bDrawTriOpen ((X1), (Y1), (X2), (Y2), (X3), (Y3))) 9 10 # define CONNECT 0 10 11 # define HISTOGRAM 1 … … 288 289 (sy < layout[0].axis[1].fy) && (sy > layout[0].axis[1].fy + layout[0].axis[1].dfy)) 289 290 { 290 DrawLine (sx - d*z[i], sy + 0.58*d*z[i], sx + d*z[i], sy + 0.58*d*z[i]); 291 DrawLine (sx + d*z[i], sy + 0.58*d*z[i], sx, sy - 1.15*d*z[i]); 292 DrawLine (sx, sy - 1.15*d*z[i], sx - d*z[i], sy + 0.58*d*z[i]); 291 OpenTriangle (sx - d*z[i], sy + 0.58*d*z[i], sx, sy - 1.15*d*z[i], sx + d*z[i], sy + 0.58*d*z[i]); 293 292 } 294 293 } … … 403 402 (sy < layout[0].axis[1].fy) && (sy > layout[0].axis[1].fy + layout[0].axis[1].dfy)) 404 403 { 405 DrawLine (sx - d, sy - 0.58*d, sx + d, sy - 0.58*d); 406 DrawLine (sx + d, sy - 0.58*d, sx, sy + 1.15*d); 407 DrawLine (sx, sy + 1.15*d, sx - d, sy - 0.58*d); 404 OpenTriangle (sx - d, sy + 0.58*d, sx + d, sy + 0.58*d, sx, sy - 1.15*d); 408 405 } 409 406 } -
trunk/Ohana/src/kapa/graph/bDrawRotFont.c
r5611 r5612 149 149 Y = YPROC (dx,0); 150 150 # ifdef DRAWBOXES 151 bDrawLine (x+X, y+Y, x+X1, y+Y1 , FALSE);151 bDrawLine (x+X, y+Y, x+X1, y+Y1); 152 152 Xt = X; 153 153 Yt = Y; … … 161 161 Y = YPROC (dx,dy); 162 162 # ifdef DRAWBOXES 163 bDrawLine (x+X, y+Y, x+Xt, y+Yt , FALSE);163 bDrawLine (x+X, y+Y, x+Xt, y+Yt); 164 164 Xt = X; 165 165 Yt = Y; … … 173 173 Y = YPROC (0,dy); 174 174 # ifdef DRAWBOXES 175 bDrawLine (x+X, y+Y, x+Xt, y+Yt , FALSE);175 bDrawLine (x+X, y+Y, x+Xt, y+Yt); 176 176 Xt = X; 177 177 Yt = Y; -
trunk/Ohana/src/kapa/include/bDraw.h
r5611 r5612 27 27 void bDrawPoint (int x, int y); 28 28 void bDrawPointf (float x, float y); 29 void bDrawLine (double x1, double y1, double x2, double y2, int swapcoords); 29 30 30 void bDrawArc (double Xc, double Yc, double Xr, double Yr, double Ts, double Te); 31 31 void bDrawCircle (double Xc, double Yc, double radius); 32 void bDrawCircleFill (double xc, double yc, double radius); 33 34 void bDrawLine (double x1, double y1, double x2, double y2); 35 void bDrawLineWeight (int X1, int Y1, int X2, int Y2, int swapcoords); 36 void bDrawLineBresen (int X1, int Y1, int X2, int Y2, int swapcoords); 37 void bDrawLineHorizontal (int X1, int X2, int Y); 38 void bDrawLineVertical (int X, int Y1, int Y2); 39 32 40 png_color *MakePNGPalette (int *Npalette); 33 41 bDrawColor GetColorByName (char *name); 34 42 bDrawBuffer *bDrawIt (); 35 43 36 void bDrawRectOpen ( int x1, int y1, int x2, inty2);37 void bDrawRectFill ( int x1, int y1, int x2, inty2);38 void bDrawTriOpen ( int x1, int y1, int x2, int y2, int x3, inty3);39 void bDrawTriFill ( int x1, int y1, int x2, int y2, int x3, inty3);44 void bDrawRectOpen (double x1, double y1, double x2, double y2); 45 void bDrawRectFill (double x1, double y1, double x2, double y2); 46 void bDrawTriOpen (double x1, double y1, double x2, double y2, double x3, double y3); 47 void bDrawTriFill (double x1, double y1, double x2, double y2, double x3, double y3); 40 48 int bDrawRotText (int x, int y, char *string, int pos, double angle); 41 49 int bDrawRotBitmap (int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale); 50 -
trunk/Ohana/src/kapa/include/globals.h
r2473 r5612 2 2 int HAVE_BACKING; 3 3 int DEBUG; 4 int USE_XWINDOW; 5 int MAP_WINDOW; 6 int FOREGROUND; 4 7 5 8 /* file descriptor for socket connection to mana */ -
trunk/Ohana/src/kapa/setup/CloseDisplay.c
r2473 r5612 3 3 /************** CloseDisplay *************/ 4 4 void CloseDisplay () { 5 XFreeFont (graphic.display, graphic.font); 5 6 XFreeGC (graphic.display, graphic.gc); 6 7 XDestroySubwindows (graphic.display, graphic.window); -
trunk/Ohana/src/kapa/setup/DefineLayout.c
r4769 r5612 5 5 void DefineLayout (int argc, char **argv) { 6 6 7 int i, status, N , FOREGROUND;7 int i, status, N; 8 8 struct sockaddr_un Address; 9 9 char temp[100]; 10 10 11 if ((N = get_argument (argc, argv, "-debug"))) {12 remove_argument(N, &argc, argv);13 DEBUG = TRUE;14 } else {15 DEBUG = FALSE;16 }17 18 FOREGROUND = FALSE;19 if ((N = get_argument (argc, argv, "-fg"))) {20 remove_argument(N, &argc, argv);21 FOREGROUND = TRUE;22 }23 24 11 /** initiate connection with server **/ 25 12 if (!FOREGROUND) { … … 42 29 43 30 InitRotFonts (); 44 MakeColormap (argc, argv);45 31 46 32 /** set up defaults for display region **/ -
trunk/Ohana/src/kapa/setup/SetUpWindow.c
r2473 r5612 23 23 NameWindow ("Kapa"); 24 24 25 if ((N = get_argument (*argc, argv, "-nomap"))) { 26 remove_argument(N, argc, argv); 27 } else { 28 MapWindow (graphic); 29 } 30 25 MakeColormap (*argc, argv); /* move to SetUpWindow? */ 26 27 if (MAP_WINDOW) MapWindow (graphic); 28 return; 31 29 } -
trunk/Ohana/src/kapa/setup/Ximage.c
r4769 r5612 3 3 int main (int argc, char **argv) { 4 4 5 SetUpDisplay (&argc, argv); 6 SetUpWindow (&argc, argv); 5 /* this is a lame place to put this default */ 6 graphic.x = 10; 7 graphic.y = 10; 8 graphic.dx = 512; 9 graphic.dy = 512; 7 10 8 DefineLayout (argc, argv); 11 args (&argc, argv); 12 13 if (USE_XWINDOW) SetUpDisplay (&argc, argv); /* skip if Xless */ 14 if (USE_XWINDOW) SetUpWindow (&argc, argv); /* skip if Xless */ 15 16 DefineLayout (argc, argv); 9 17 EventLoop (); 10 18 11 XFreeFont (graphic.display, graphic.font); 12 CloseDisplay (); 19 if (USE_XWINDOW) CloseDisplay (); 13 20 exit (0); 14 21 }
Note:
See TracChangeset
for help on using the changeset viewer.
