Changeset 25757 for trunk/Ohana/src/kapa2
- Timestamp:
- Oct 2, 2009, 3:15:42 PM (17 years ago)
- Location:
- trunk/Ohana/src/kapa2
- Files:
-
- 5 deleted
- 29 edited
- 3 copied
-
Makefile (modified) (2 diffs)
-
include/constants.h (modified) (1 diff)
-
include/prototypes.h (modified) (2 diffs)
-
include/structures.h (modified) (2 diffs)
-
src/ButtonFunctions.c (modified) (3 diffs)
-
src/Center.c (modified) (1 diff)
-
src/CheckPipe.c (modified) (1 diff)
-
src/CheckVisual.c (modified) (12 diffs)
-
src/CheckVisual.test.c (copied) (copied from branches/eam_branches/20090715/Ohana/src/kapa2/src/CheckVisual.test.c )
-
src/CreateZoom16.c (deleted)
-
src/CreateZoom24.c (deleted)
-
src/CreateZoom32.c (deleted)
-
src/CreateZoom8.c (deleted)
-
src/CursorOps.c (modified) (9 diffs)
-
src/DragColorbar.c (modified) (5 diffs)
-
src/Image.c (modified) (3 diffs)
-
src/InterpretKeys.c (modified) (7 diffs)
-
src/JPEGit24.c (modified) (2 diffs)
-
src/LoadPicture.c (modified) (3 diffs)
-
src/MakeColormap.c (modified) (1 diff)
-
src/PSOverlay.c (modified) (1 diff)
-
src/PaintOverlay.c (modified) (2 diffs)
-
src/Relocate.c (copied) (copied from branches/eam_branches/20090715/Ohana/src/kapa2/src/Relocate.c )
-
src/Remap16.c (modified) (7 diffs)
-
src/Remap24.c (modified) (6 diffs)
-
src/Remap32.c (modified) (8 diffs)
-
src/Remap8.c (modified) (6 diffs)
-
src/Reorient.c (modified) (3 diffs)
-
src/SetColorScale.c (modified) (1 diff)
-
src/SetColormap.c (modified) (1 diff)
-
src/SetUpGraphic.c (modified) (1 diff)
-
src/StatusBox.c (modified) (1 diff)
-
src/UpdatePointer.c (modified) (2 diffs)
-
src/UpdateStatusBox.c (modified) (1 diff)
-
src/bDrawOverlay.c (modified) (1 diff)
-
src/sort.c (deleted)
-
test/overlay.sh (copied) (copied from branches/eam_branches/20090715/Ohana/src/kapa2/test/overlay.sh )
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kapa2/Makefile
r16270 r25757 48 48 $(SRC)/Layout.$(ARCH).o $(SRC)/Sections.$(ARCH).o \ 49 49 $(SRC)/Graphs.$(ARCH).o $(SRC)/SetGraphSize.$(ARCH).o \ 50 $(SRC)/Resize.$(ARCH).o $(SRC)/ ErasePlots.$(ARCH).o\51 $(SRC)/Erase Image.$(ARCH).o $(SRC)/SetToolbox.$(ARCH).o \50 $(SRC)/Resize.$(ARCH).o $(SRC)/Relocate.$(ARCH).o \ 51 $(SRC)/ErasePlots.$(ARCH).o $(SRC)/EraseImage.$(ARCH).o \ 52 52 $(SRC)/EraseCurrentPlot.$(ARCH).o $(SRC)/EraseSections.$(ARCH).o \ 53 $(SRC)/SetToolbox.$(ARCH).o \ 53 54 $(SRC)/SetSection.$(ARCH).o $(SRC)/DefineSection.$(ARCH).o \ 54 55 $(SRC)/SetLimits.$(ARCH).o $(SRC)/SetFont.$(ARCH).o \ … … 79 80 $(SRC)/ColorHistogram.$(ARCH).o $(SRC)/CreateWide.$(ARCH).o 80 81 81 #$(SRC)/CreateZoom8.$(ARCH).o $(SRC)/CreateZoom16.$(ARCH).o \82 #$(SRC)/CreateZoom24.$(ARCH).o $(SRC)/CreateZoom32.$(ARCH).o \83 84 82 OBJ = $(KAPA) 85 83 -
trunk/Ohana/src/kapa2/include/constants.h
r16011 r25757 11 11 12 12 # define NCHANNELS 3 13 # define NPIXELS_DYNAMIC 12813 # define NPIXELS_DYNAMIC 4600 14 14 15 15 // XXX for the moment, this is set to match the values in SetColorScale3D_CC -
trunk/Ohana/src/kapa2/include/prototypes.h
r21153 r25757 55 55 int LoadTextlines PROTO((int sock)); 56 56 int Resize PROTO((int sock)); 57 int Relocate PROTO((int sock)); 57 58 int GetLimits PROTO((int sock)); 58 59 int SetLimits PROTO((int sock)); … … 178 179 void Image_to_Picture PROTO((double *x1, double *y1, double x2, double y2, Picture *picture)); 179 180 void Image_to_Screen PROTO((double *x1, double *y1, double x2, double y2, Picture *picture)); 180 void Picture_Lower PROTO((int *i_start, int *j_start, Matrix *matrix, Picture *picture));181 void Picture_Upper PROTO((int *i_end, int *j_end, Matrix *matrix, Picture *picture));181 void Picture_Lower PROTO((int *i_start, int *j_start, int *I_start, int *J_start, Matrix *matrix, Picture *picture)); 182 void Picture_Upper PROTO((int *i_end, int *j_end, int i_start, int j_start, Matrix *matrix, Picture *picture)); 182 183 183 184 void DragColorbar PROTO((Graphic *graphic, KapaImageWidget *image, XButtonEvent *mouse_event)); -
trunk/Ohana/src/kapa2/include/structures.h
r21153 r25757 21 21 Window window; 22 22 Visual *visual; 23 int visualclass; // is visual dynamic? (XXX change name?)23 int dynamicColors; // is visual dynamic? 24 24 int Nbits; // pixel depth in bits (8, 16, 24, 32) 25 25 GC gc; … … 94 94 int DX, DY; // size of displayed picture (must be updated with new images...) 95 95 int expand; // zoomscale 96 double X , Y; // center of image in picture96 double Xc, Yc; // center of image in picture 97 97 char flipx, flipy; // parity (0 = +; 1 = -) 98 98 XImage *pix; -
trunk/Ohana/src/kapa2/src/ButtonFunctions.c
r21153 r25757 44 44 int Recenter (Graphic *graphic, KapaImageWidget *image) { 45 45 46 image[0].picture.X = 0.5*image[0].image[0].matrix.Naxis[0];47 image[0].picture.Y = 0.5*image[0].image[0].matrix.Naxis[1];46 image[0].picture.Xc = 0.5*image[0].image[0].matrix.Naxis[0]; 47 image[0].picture.Yc = 0.5*image[0].image[0].matrix.Naxis[1]; 48 48 49 49 Remap (graphic, image); … … 56 56 57 57 image[0].picture.expand = 1; 58 image[0].zoom.expand = 5; 58 59 Remap (graphic, image); 59 60 Refresh (); … … 64 65 int RecenterRescale (Graphic *graphic, KapaImageWidget *image) { 65 66 66 image[0].picture.X = 0.5*image[0].image[0].matrix.Naxis[0];67 image[0].picture.Y = 0.5*image[0].image[0].matrix.Naxis[1];67 image[0].picture.Xc = 0.5*image[0].image[0].matrix.Naxis[0]; 68 image[0].picture.Yc = 0.5*image[0].image[0].matrix.Naxis[1]; 68 69 image[0].picture.expand = 1; 70 image[0].zoom.expand = 5; 69 71 70 72 Remap (graphic, image); -
trunk/Ohana/src/kapa2/src/Center.c
r21060 r25757 16 16 if (image == NULL) return (TRUE); 17 17 18 image[0].picture.X = X; 19 image[0].picture.Y = Y; 18 // enforce integer center here? 19 image[0].picture.Xc = X; 20 image[0].picture.Yc = Y; 20 21 if ((zoom != 0) && (zoom != -1)) { 21 22 image[0].picture.expand = zoom; 23 image[0].zoom.expand = MIN(image[0].zoom.dx / 5.5, MAX(5, 2*zoom)); 22 24 } 23 25 -
trunk/Ohana/src/kapa2/src/CheckPipe.c
r21060 r25757 131 131 } 132 132 133 if (!strcmp (word, "MOVE")) { 134 status = Relocate (sock); 135 KiiSendCommand (sock, 4, "DONE"); 136 FINISHED (status); 137 } 138 133 139 if (!strcmp (word, "GLIM")) { 134 140 GetLimits (sock); -
trunk/Ohana/src/kapa2/src/CheckVisual.c
r21153 r25757 10 10 11 11 int i, Nfound, N; 12 int isColor, isDefault , isDynamic;12 int isColor, isDefault; 13 13 XVisualInfo *visual_list, visual_temp; 14 14 unsigned long planes[3]; … … 34 34 } 35 35 36 // skip the default and the PseudoColor visuals, go for TrueColor first37 # if (0)38 /* check default visual first */39 for (i = 0; (i < Nfound) && (graphic[0].visual != visual_list[i].visual); i++);40 if (i == Nfound) {41 fprintf (stderr, "default visual not found??\n");42 exit (0);43 }44 # endif45 46 36 // set these based on selected visual 47 isColor = isDefault = isDynamic = FALSE; 48 49 # if (0) 50 // attempt to select the most desirable type of visual: Default as PseudoColor (XXX is it still true?) 51 if (DEBUG) fprintf (stderr, "default visual class is %d\n", visual_list[i].class); 52 if (visual_list[i].class == PseudoColor) { 53 isColor = isDefault = isDynamic = TRUE; 54 graphic[0].visual = visual_list[i].visual; 55 graphic[0].visualclass = TRUE; 56 goto test_pixels; 57 } 58 # endif 59 60 // attempt to select the most desirable type of visual: TrueColor (XXX is it still true?) 37 isColor = isDefault = FALSE; 38 39 // attempt to select the most desirable type of visual: TrueColor 61 40 for (i = 0; (i < Nfound) && (visual_list[i].class != TrueColor); i++); 62 41 if (i != Nfound) { … … 65 44 isDefault = (graphic[0].visual == visual_list[i].visual); 66 45 graphic[0].visual = visual_list[i].visual; 67 graphic[0].visualclass = FALSE; 46 graphic[0].dynamicColors = FALSE; 47 if (DEBUG) fprintf (stderr, "got TrueColor visual\n"); 48 goto test_pixels; 49 } 50 51 // attempt to select the most desirable type of visual: DirectColor 52 for (i = 0; (i < Nfound) && (visual_list[i].class != DirectColor); i++); 53 if (i != Nfound) { 54 isColor = TRUE; 55 if (DEBUG) fprintf (stderr, "visual class is %d\n", visual_list[i].class); 56 isDefault = (graphic[0].visual == visual_list[i].visual); 57 graphic[0].visual = visual_list[i].visual; 58 graphic[0].dynamicColors = TRUE; 59 if (DEBUG) fprintf (stderr, "got DirectColor visual\n"); 68 60 goto test_pixels; 69 61 } … … 72 64 for (i = 0; (i < Nfound) && (visual_list[i].class != PseudoColor); i++); 73 65 if (i != Nfound) { 74 isColor = isDynamic =TRUE;66 isColor = TRUE; 75 67 if (DEBUG) fprintf (stderr, "selected visual class is %d\n", visual_list[i].class); 76 68 isDefault = (graphic[0].visual == visual_list[i].visual); 77 69 graphic[0].visual = visual_list[i].visual; 78 graphic[0].visualclass = TRUE; 70 graphic[0].dynamicColors = TRUE; 71 if (DEBUG) fprintf (stderr, "got PseudoColor visual\n"); 79 72 goto test_pixels; 80 73 } … … 83 76 for (i = 0; (i < Nfound) && (visual_list[i].class != GrayScale); i++); 84 77 if (i != Nfound) { 85 isDynamic = TRUE;86 78 if (DEBUG) fprintf (stderr, "selected visual class is %d\n", visual_list[i].class); 87 79 isDefault = (graphic[0].visual == visual_list[i].visual); 88 80 graphic[0].visual = visual_list[i].visual; 89 graphic[0].visualclass = TRUE; 81 graphic[0].dynamicColors = TRUE; 82 if (DEBUG) fprintf (stderr, "got GrayScale visual\n"); 90 83 goto test_pixels; 91 84 } … … 97 90 isDefault = (graphic[0].visual == visual_list[i].visual); 98 91 graphic[0].visual = visual_list[i].visual; 99 graphic[0].visualclass = FALSE; 92 graphic[0].dynamicColors = FALSE; 93 if (DEBUG) fprintf (stderr, "got StaticColor visual\n"); 100 94 goto test_pixels; 101 95 } … … 107 101 isDefault = (graphic[0].visual == visual_list[i].visual); 108 102 graphic[0].visual = visual_list[i].visual; 109 graphic[0].visualclass = FALSE; 103 graphic[0].dynamicColors = FALSE; 104 if (DEBUG) fprintf (stderr, "got StaticGray visual\n"); 110 105 goto test_pixels; 111 106 } … … 115 110 /* need to make a colormap if 116 111 1) the selected visual is not the default 112 XXX not sure if I need to / am allowed to alloc a colormap if I've grabbed the default. 117 113 2) there are not enough colors available */ 118 114 … … 125 121 } 126 122 127 // allocate a private colormap, if needed 123 // dynamic visual classes can accept AllocAll and can use XAllocColorCells while AllocNone must use XAllocColor 124 // int allocMode = graphic[0].dynamicColors ? AllocAll : AllocNone; 125 int allocMode = AllocNone; 126 127 // allocate a private colormap, if desired or needed 128 128 if (!isDefault) { 129 129 if (DEBUG) fprintf (stderr, "allocated private colormap\n"); 130 graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, AllocNone);131 } 132 133 if ( isDynamic) {130 graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, allocMode); 131 } 132 133 if (graphic[0].dynamicColors) { 134 134 Npixels = NPIXELS_DYNAMIC; 135 135 if ((N = get_argument (*argc, argv, "-ncolors"))) { … … 144 144 for (graphic[0].Npixels = Npixels; graphic[0].Npixels >= 16; graphic[0].Npixels -= 4) { 145 145 if (DEBUG) fprintf (stderr, "trying %d colors\n", (int) graphic[0].Npixels); 146 if (XAllocColorCells (graphic[0].display, graphic[0].colormap, FALSE, planes, 1, graphic[0].pixels, graphic[0].Npixels)) {146 if (XAllocColorCells (graphic[0].display, graphic[0].colormap, FALSE, planes, 0, graphic[0].pixels, graphic[0].Npixels)) { 147 147 break; 148 } 149 for (i = 0; i < graphic[0].Npixels; i++) { 150 graphic[0].cmap[i].pixel = graphic[0].pixels[i]; 148 151 } 149 152 } … … 152 155 if (graphic[0].Npixels < 16) { 153 156 if (!isDefault) { 157 // We've already tried to allocate a colormap above... 154 158 fprintf (stderr, "can't allocate enough cells in private colormap\n"); 155 159 exit (0); 156 160 } 157 161 if (DEBUG) fprintf (stderr, "can't allocate enough cells, using private colormap\n"); 158 graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, AllocNone);162 graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, allocMode); 159 163 160 164 for (graphic[0].Npixels = NPIXELS_DYNAMIC; graphic[0].Npixels >= 16; graphic[0].Npixels -= 4) { … … 163 167 break; 164 168 } 165 } 166 169 for (i = 0; i < graphic[0].Npixels; i++) { 170 graphic[0].cmap[i].pixel = graphic[0].pixels[i]; 171 } 172 } 167 173 if ((N = get_argument (*argc, argv, "-colorcount"))) { 168 174 fprintf (stderr, "kapa can grab %d colors\n", graphic[0].Npixels); -
trunk/Ohana/src/kapa2/src/CursorOps.c
r16270 r25757 2 2 3 3 // input coordinates are relative to the picture bounding box 4 // XXX pre-calculate fexpand, Xc, Yc when expand is set? 4 5 void Picture_to_Image (double *x1, double *y1, double x2, double y2, Picture *picture) { 5 6 … … 14 15 15 16 // pixel coordinates in picture frame 16 dx = expand*(x2 - 0.5*picture[0].dx); 17 dy = expand*(y2 - 0.5*picture[0].dy); 17 dx = expand*(x2 - (int)(0.5*picture[0].dx)); 18 dy = expand*(y2 - (int)(0.5*picture[0].dy)); 19 20 // set the true center (image and screen pixel boundaries must be aligned) 21 // Xc = (int)(picture[0].Xc / expand) * expand; 22 // Yc = (int)(picture[0].Yc / expand) * expand; 18 23 19 24 // picture[0].X,Y is the image coordinate in the center of the picture 20 *x1 = picture[0].flipx ? picture[0].X - dx : picture[0].X+ dx;21 *y1 = picture[0].flipy ? picture[0].Y - dy : picture[0].Y+ dy;25 *x1 = picture[0].flipx ? picture[0].Xc - dx : picture[0].Xc + dx; 26 *y1 = picture[0].flipy ? picture[0].Yc - dy : picture[0].Yc + dy; 22 27 } 23 28 … … 46 51 } 47 52 53 // set the true center (image and screen pixel boundaries must be aligned) 54 // Xc = ((int)(picture[0].Xc * expand)) / expand; 55 // Yc = ((int)(picture[0].Yc * expand)) / expand; 56 48 57 // pixel coordinates in picture frame 49 dx = picture[0].flipx ? picture[0].X - x2 : x2 - picture[0].X;50 dy = picture[0].flipy ? picture[0].Y - y2 : y2 - picture[0].Y;58 dx = picture[0].flipx ? picture[0].Xc - x2 : x2 - picture[0].Xc; 59 dy = picture[0].flipy ? picture[0].Yc - y2 : y2 - picture[0].Yc; 51 60 52 *x1 = expand*dx + 0.5*picture[0].dx;53 *y1 = expand*dy + 0.5*picture[0].dy;61 *x1 = expand*dx + (int)(0.5*picture[0].dx); 62 *y1 = expand*dy + (int)(0.5*picture[0].dy); 54 63 } 55 64 … … 66 75 67 76 // input coordinates are relative to the picture bounding box 68 void Picture_Lower (int *i_start, int *j_start, Matrix *matrix, Picture *picture) {77 void Picture_Lower (int *i_start, int *j_start, int *I_start, int *J_start, Matrix *matrix, Picture *picture) { 69 78 70 79 double Ix, Iy, Sx, Sy; … … 72 81 // Ix, Iy are the image coordinates of the specified screen pixel 73 82 Picture_to_Image (&Ix, &Iy, 0.0, 0.0, picture); 74 75 // Ix, Iy are now limited to valid image coordinates76 Ix = MIN (MAX (Ix, 0), matrix[0].Naxis[0]);77 Iy = MIN (MAX (Iy, 0), matrix[0].Naxis[1]);78 83 79 84 // round up (down) to nearest pixel boundary … … 84 89 Iy = picture[0].flipy ? (int)(Iy) : (int)(Iy) + 1; 85 90 } 91 92 // Ix, Iy are now limited to valid image coordinates 93 Ix = MIN (MAX (Ix, 0), matrix[0].Naxis[0]); 94 Iy = MIN (MAX (Iy, 0), matrix[0].Naxis[1]); 95 96 // I_start, J_start are the first displayed image pixel 97 *I_start = Ix; 98 *J_start = Iy; 86 99 87 100 // Sx, Sy are the screen coordinates of the Ix,Iy pixel … … 94 107 95 108 // input coordinates are relative to the picture bounding box 96 void Picture_Upper (int *i_end, int *j_end, Matrix *matrix, Picture *picture) {109 void Picture_Upper (int *i_end, int *j_end, int i_start, int j_start, Matrix *matrix, Picture *picture) { 97 110 111 int nExtra; 98 112 double Ix, Iy, Sx, Sy; 99 113 … … 101 115 Picture_to_Image (&Ix, &Iy, picture[0].dx, picture[0].dy, picture); 102 116 117 // round down (up) to nearest pixel boundary 118 if (Ix > (int)(Ix)) { 119 Ix = picture[0].flipx ? (int)(Ix) + 1: (int)(Ix); 120 } 121 if (Iy > (int)(Iy)) { 122 Iy = picture[0].flipy ? (int)(Iy) + 1: (int)(Iy); 123 } 124 103 125 // Ix, Iy are now limited to valid image coordinates 104 126 Ix = MIN (MAX (Ix, 0), matrix[0].Naxis[0]); 105 127 Iy = MIN (MAX (Iy, 0), matrix[0].Naxis[1]); 106 128 107 // round down (up) to nearest pixel boundary 108 if (Ix > (int)(Ix)) { 109 Ix = picture[0].flipx ? (int)(Ix) + 1 : (int)(Ix); 110 } 111 if (Iy > (int)(Iy)) { 112 Iy = picture[0].flipy ? (int)(Iy) + 1: (int)(Iy); 113 } 129 // I_end, J_end are the last displayed image pixel 130 // *I_end = Ix; 131 // *J_end = Iy; 114 132 115 133 // Sx, Sy are the screen coordinates of the Ix,Iy pixel … … 119 137 *i_end = MIN (MAX (Sx, 0), picture[0].dx); 120 138 *j_end = MIN (MAX (Sy, 0), picture[0].dy); 139 140 // round off error can leave us with a small number of extra pixels here. 141 if (picture[0].expand > 1) { 142 nExtra = (*i_end - i_start) % picture[0].expand; 143 *i_end -= nExtra; 144 nExtra = (*j_end - j_start) % picture[0].expand; 145 *j_end -= nExtra; 146 } 121 147 } -
trunk/Ohana/src/kapa2/src/DragColorbar.c
r16011 r25757 10 10 int xstatus, Npix, center; 11 11 12 if (!graphic[0]. visualclass) return;12 if (!graphic[0].dynamicColors) return; 13 13 14 14 X = mouse_event[0].x; … … 79 79 XColor cmap[256]; 80 80 81 if (!graphic[0]. visualclass) return;81 if (!graphic[0].dynamicColors) return; 82 82 83 83 for (i = 0; i < graphic[0].Npixels; i++) { … … 88 88 cmap[i].blue = graphic[0].cmap[0].blue; 89 89 cmap[i].green = graphic[0].cmap[0].green; 90 cmap[i].flags = DoRed | DoGreen | DoBlue; 90 91 } 91 92 else { … … 94 95 cmap[i].blue = graphic[0].cmap[graphic[0].Npixels-1].blue; 95 96 cmap[i].green = graphic[0].cmap[graphic[0].Npixels-1].green; 97 cmap[i].flags = DoRed | DoGreen | DoBlue; 96 98 } 97 99 else { … … 99 101 cmap[i].blue = graphic[0].cmap[j].blue; 100 102 cmap[i].green = graphic[0].cmap[j].green; 103 cmap[i].flags = DoRed | DoGreen | DoBlue; 101 104 } 102 105 } -
trunk/Ohana/src/kapa2/src/Image.c
r21153 r25757 48 48 49 49 // set the center and expansion for the pictures: 50 image[0].picture.X = 0.0;51 image[0].picture.Y = 0.0;50 image[0].picture.Xc = 0.0; 51 image[0].picture.Yc = 0.0; 52 52 image[0].picture.expand = 1; 53 53 image[0].picture.flipx = FALSE; 54 54 image[0].picture.flipy = FALSE; 55 55 56 image[0].zoom.X = 0.0;57 image[0].zoom.Y = 0.0;58 image[0].zoom.expand = +5;56 image[0].zoom.Xc = 0.0; 57 image[0].zoom.Yc = 0.0; 58 image[0].zoom.expand = 5; 59 59 image[0].zoom.flipx = FALSE; 60 60 image[0].zoom.flipy = FALSE; 61 61 62 image[0].wide.X = 0.0;63 image[0].wide.Y = 0.0;62 image[0].wide.Xc = 0.0; 63 image[0].wide.Yc = 0.0; 64 64 image[0].wide.expand = -5; 65 65 image[0].wide.flipx = FALSE; … … 144 144 image[0].picture.dx+1, image[0].picture.dy+1); 145 145 146 XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc, 147 image[0].picture.pix, 0, 0, 148 image[0].picture.x + 1, image[0].picture.y + 1, 149 image[0].picture.dx, image[0].picture.dy); 146 if (image[0].picture.pix) { 147 XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc, 148 image[0].picture.pix, 0, 0, 149 image[0].picture.x + 1, image[0].picture.y + 1, 150 image[0].picture.dx, image[0].picture.dy); 151 } 150 152 151 153 for (i = 0; i < NOVERLAYS; i++) { … … 156 158 157 159 if (image[0].location) { 158 XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc, 159 image[0].cmapbar.pix, 0, 0, 160 image[0].cmapbar.x, image[0].cmapbar.y, 161 image[0].cmapbar.dx, image[0].cmapbar.dy); 162 163 XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc, 164 image[0].wide.pix, 0, 0, 165 image[0].wide.x, image[0].wide.y, 166 image[0].wide.dx, image[0].wide.dy); 160 if (image[0].cmapbar.pix) { 161 XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc, 162 image[0].cmapbar.pix, 0, 0, 163 image[0].cmapbar.x, image[0].cmapbar.y, 164 image[0].cmapbar.dx, image[0].cmapbar.dy); 165 } 166 if (image[0].wide.pix) { 167 XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc, 168 image[0].wide.pix, 0, 0, 169 image[0].wide.x, image[0].wide.y, 170 image[0].wide.dx, image[0].wide.dy); 171 } 167 172 168 173 CrossHairs (graphic, &image[0].zoom); -
trunk/Ohana/src/kapa2/src/InterpretKeys.c
r18411 r25757 93 93 SetColorScale (graphic, image); 94 94 Remap (graphic, image); 95 Reorient (graphic, image, image[0].picture.X , image[0].picture.Y, 0);95 Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0); 96 96 break; 97 97 … … 100 100 SetColorScale (graphic, image); 101 101 Remap (graphic, image); 102 Reorient (graphic, image, image[0].picture.X , image[0].picture.Y, 0);102 Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0); 103 103 break; 104 104 … … 107 107 SetColorScale (graphic, image); 108 108 Remap (graphic, image); 109 Reorient (graphic, image, image[0].picture.X , image[0].picture.Y, 0);109 Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0); 110 110 break; 111 111 … … 113 113 case XK_Home: 114 114 image[0].picture.expand = 1; 115 Reorient (graphic, image, image[0].picture.X, image[0].picture.Y, 0); 115 image[0].zoom.expand = 5; 116 Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0); 116 117 break; 117 118 case XK_KP_End: 118 119 case XK_End: 119 120 image[0].picture.expand = 1; 121 image[0].zoom.expand = 5; 120 122 Reorient (graphic, image, 0.5*image[0].image[0].matrix.Naxis[0], 0.5*image[0].image[0].matrix.Naxis[1], 0); 121 123 break; … … 128 130 case XK_Prior: 129 131 case XK_KP_Prior: 130 Reorient (graphic, image, image[0].picture.X , image[0].picture.Y, +1);132 Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, +1); 131 133 break; 132 134 case XK_Next: 133 135 case XK_KP_Next: 134 Reorient (graphic, image, image[0].picture.X , image[0].picture.Y, -1);136 Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, -1); 135 137 break; 136 138 case XK_Up: 137 139 case XK_KP_Up: 138 Reorient (graphic, image, image[0].picture.X , image[0].picture.Y+ offset, 0);140 Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc + offset, 0); 139 141 break; 140 142 case XK_Down: 141 143 case XK_KP_Down: 142 Reorient (graphic, image, image[0].picture.X , image[0].picture.Y- offset, 0);144 Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc - offset, 0); 143 145 break; 144 146 case XK_Left: 145 147 case XK_KP_Left: 146 Reorient (graphic, image, image[0].picture.X + offset, image[0].picture.Y, 0);148 Reorient (graphic, image, image[0].picture.Xc + offset, image[0].picture.Yc, 0); 147 149 break; 148 150 case XK_Right: 149 151 case XK_KP_Right: 150 Reorient (graphic, image, image[0].picture.X - offset, image[0].picture.Y, 0);152 Reorient (graphic, image, image[0].picture.Xc - offset, image[0].picture.Yc, 0); 151 153 break; 152 154 … … 160 162 SetColorScale (graphic, image); 161 163 Remap (graphic, image); 162 Reorient (graphic, image, image[0].picture.X , image[0].picture.Y, 0);164 Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0); 163 165 break; 164 166 case XK_KP_Subtract: … … 171 173 SetColorScale (graphic, image); 172 174 Remap (graphic, image); 173 Reorient (graphic, image, image[0].picture.X , image[0].picture.Y, 0);175 Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0); 174 176 break; 175 177 -
trunk/Ohana/src/kapa2/src/JPEGit24.c
r19833 r25757 22 22 int ii, i, j; 23 23 int i_start, i_end, j_start, j_end; 24 int I_start, J_start; 24 25 int dropback; /* this is a bit of a kludge... */ 25 26 int dx, dy, DX, DY, inDX, inDY; … … 95 96 DY = image[0].image[0].matrix.Naxis[1]; 96 97 97 // x, yare the closest lit screen pixel to 0,098 Picture_Lower (&i_start, &j_start, &image[0].image[0].matrix, &image[0].picture);99 100 // x, y are the closest lit screen pixel to dx, dy 101 Picture_Upper (&i_end, &j_end, &image[0].image[0].matrix, &image[0].picture);102 103 if (i_end < i_start) MY_SWAP_INT (i_start, i_end);104 if (j_end < j_start) MY_SWAP_INT (j_start, j_end); 105 106 // Ix,Iy are the first displayed image pixel107 Picture_to_Image (&Ix, &Iy, i_start, j_start, &image[0].picture); 108 Ix = MIN (MAX (0, Ix), DX - 1);109 Iy = MIN (MAX (0, Iy), DY - 1);98 // i_start, j_start are the closest lit screen pixel to 0,0 99 // I_start, J_start are the image pixel corresponding to i_start, j_start 100 Picture_Lower (&i_start, &j_start, &I_start, &J_start, &image[0].image[0].matrix, &image[0].picture); 101 102 // i_end, j_end are the closest lit screen pixel to dx, dy 103 // I_end, J_end are the image pixel corresponding to i_end, j_end 104 Picture_Upper (&i_end, &j_end, i_start, j_start, &image[0].image[0].matrix, &image[0].picture); 105 106 assert (i_start <= i_end); 107 assert (j_start <= j_end); 108 109 Ix = image[0].picture.flipx ? I_start - 1 : I_start; 110 Iy = image[0].picture.flipy ? J_start - 1 : J_start; 110 111 111 112 inDX = image[0].picture.flipx ? -1 : +1; -
trunk/Ohana/src/kapa2/src/LoadPicture.c
r21060 r25757 25 25 Yoffset = 0.0; 26 26 if (image[0].image[0].matrix.size) { 27 Xoffset = image[0].picture.X - 0.5*image[0].image[0].matrix.Naxis[0]; 28 Yoffset = image[0].picture.Y - 0.5*image[0].image[0].matrix.Naxis[1]; 27 // XXX enforce int center here? 28 Xoffset = image[0].picture.Xc - 0.5*image[0].image[0].matrix.Naxis[0]; 29 Yoffset = image[0].picture.Yc - 0.5*image[0].image[0].matrix.Naxis[1]; 29 30 } 30 31 … … 49 50 50 51 // reference point for image is the center pixel 51 image[0].picture.X = 0.5*header.Naxis[0] + Xoffset;52 image[0].picture.Y = 0.5*header.Naxis[1] + Yoffset;52 image[0].picture.Xc = 0.5*header.Naxis[0] + Xoffset; 53 image[0].picture.Yc = 0.5*header.Naxis[1] + Yoffset; 53 54 54 55 // choose expand for wide to guarantee we fit: … … 59 60 image[0].wide.expand = 1.0 / wx; 60 61 } 61 image[0].wide.X = 0.5*header.Naxis[0];62 image[0].wide.Y = 0.5*header.Naxis[1];62 image[0].wide.Xc = 0.5*header.Naxis[0]; 63 image[0].wide.Yc = 0.5*header.Naxis[1]; 63 64 64 65 fcntl (sock, F_SETFL, O_NONBLOCK); -
trunk/Ohana/src/kapa2/src/MakeColormap.c
r16011 r25757 2 2 3 3 static char default_cmap[] = "grayscale"; 4 // static char default_cmap[] = "heat"; 4 5 5 6 void MakeColormap (int argc, char **argv) { -
trunk/Ohana/src/kapa2/src/PSOverlay.c
r19835 r25757 80 80 double sn = sin(angle); 81 81 x0 = X + pX*dX*cs; 82 y0 = Y +pY*dX*sn;82 y0 = Y - pY*dX*sn; 83 83 // XXX dt should be based on the size of the ellipse... 84 84 // 0.10 -> 60 segments on the ellipse 85 85 # define DT 0.1 86 86 for (t = DT; t < 2*M_PI + DT; t+=DT) { 87 x1 = X + pX*dX*cos(t)*cs -pX*dY*sin(t)*sn;88 y1 = Y +pY*dX*cos(t)*sn + pY*dY*sin(t)*cs;87 x1 = X + pX*dX*cos(t)*cs + pX*dY*sin(t)*sn; 88 y1 = Y - pY*dX*cos(t)*sn + pY*dY*sin(t)*cs; 89 89 fprintf (f, " %6.1f %6.1f %6.1f %6.1f L\n", x0 + extra, y0 + extra, x1 + extra, y1 + extra); 90 90 x0 = x1; -
trunk/Ohana/src/kapa2/src/PaintOverlay.c
r20936 r25757 9 9 10 10 XSetForeground (graphic[0].display, graphic[0].gc, image[0].overlay[N].color); 11 XSetLineAttributes (graphic->display, graphic->gc, 2, LineSolid, CapNotLast, JoinMiter);11 XSetLineAttributes (graphic->display, graphic->gc, 1, LineSolid, CapNotLast, JoinMiter); 12 12 13 13 expand = 1.0; … … 72 72 double sn = sin(angle); 73 73 x0 = X + pX*dx*cs; 74 y0 = Y -pY*dx*sn;74 y0 = Y + pY*dx*sn; 75 75 // XXX dt should be based on the size of the ellipse... 76 76 // 0.10 -> 60 segments on the ellipse 77 77 # define DT 0.1 78 78 for (t = DT; t < 2*M_PI + DT; t+=DT) { 79 x1 = X + pX*dx*cos(t)*cs +pX*dy*sin(t)*sn;80 y1 = Y -pY*dx*cos(t)*sn + pY*dy*sin(t)*cs;79 x1 = X + pX*dx*cos(t)*cs - pX*dy*sin(t)*sn; 80 y1 = Y + pY*dx*cos(t)*sn + pY*dy*sin(t)*cs; 81 81 XDrawLine (graphic[0].display, graphic[0].window, graphic[0].gc, x0, y0, x1, y1); 82 82 x0 = x1; -
trunk/Ohana/src/kapa2/src/Remap16.c
r18324 r25757 1 1 # include "Ximage.h" 2 # define OUT_TYPE unsigned short 2 3 3 4 # define MY_SWAP_BYTE(W) { \ … … 10 11 int i, j, ii, jj; 11 12 int i_start, i_end, j_start, j_end; 12 int dropback; 13 int I_start, J_start; 14 int dropback, inDX, inDY; 13 15 int dx, dy, DX, DY; 14 16 double expand, Ix, Iy; 15 17 int expand_in, expand_out; 16 unsigned short*out_pix, *out_pix2, *data;18 OUT_TYPE *out_pix, *out_pix2, *data; 17 19 unsigned short *in_pix, *in_pix2; 18 unsigned short*pixel, pixvalue;19 unsigned shortback;20 OUT_TYPE *pixel, pixvalue; 21 OUT_TYPE back; 20 22 int swap_client, swap_server, swap_bytes; 21 23 22 ALLOCATE (pixel, unsigned short, graphic[0].Npixels); 24 // just skip if there is no data 25 if (matrix[0].Naxes == 0) return; 26 if (matrix[0].Naxis[0] == 0) return; 27 if (matrix[0].Naxis[1] == 0) return; 28 29 ALLOCATE (pixel, OUT_TYPE, graphic[0].Npixels); 23 30 24 31 # ifdef BYTE_SWAP … … 38 45 back = 0xffff & graphic[0].back; 39 46 if (swap_bytes) MY_SWAP_BYTE (back); 40 // XXX not certain this is the correct solution...41 47 42 48 // set up expansions … … 60 66 DY = matrix[0].Naxis[1]; 61 67 62 // x, y are the closest lit screen pixel to 0,0 63 Picture_Lower (&i_start, &j_start, matrix, picture); 68 // i_start, j_start are the closest lit screen pixel to 0,0 69 // I_start, J_start are the image pixel corresponding to i_start, j_start 70 Picture_Lower (&i_start, &j_start, &I_start, &J_start, matrix, picture); 64 71 65 // x, y are the closest lit screen pixel to dx, dy 66 Picture_Upper (&i_end, &j_end, matrix, picture); 72 // i_end, j_end are the closest lit screen pixel to dx, dy 73 // I_end, J_end are the image pixel corresponding to i_end, j_end 74 Picture_Upper (&i_end, &j_end, i_start, j_start, matrix, picture); 67 75 68 // Ix,Iy are the first displayed image pixel 69 Picture_to_Image (&Ix, &Iy, i_start, j_start, picture); 76 assert (i_start <= i_end); 77 assert (j_start <= j_end); 78 79 Ix = picture[0].flipx ? I_start - 1 : I_start; 80 Iy = picture[0].flipy ? J_start - 1 : J_start; 81 82 inDX = picture[0].flipx ? -1 : +1; 83 inDY = picture[0].flipy ? -1 : +1; 70 84 71 85 dropback = expand_out - (i_end - i_start) % expand_out; 72 86 if ((i_end - i_start) % expand_out == 0) dropback = 0; 73 87 74 data = out_pix = (unsigned short*) picture[0].data;88 out_pix = data = (OUT_TYPE *) picture[0].data; 75 89 in_pix = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)]; 76 90 … … 82 96 } 83 97 84 for (j = j_start; j < j_end; j+= expand_out, in_pix += expand_in*DX) {98 for (j = j_start; j < j_end; j+= expand_out, in_pix += inDY*expand_in*DX) { 85 99 out_pix = &data[j*dx]; 86 100 … … 97 111 in_pix2 = in_pix; 98 112 if (expand_out == 1) { 99 for (i = i_start; i < i_end; i++, in_pix2 +=expand_in, out_pix++) {113 for (i = i_start; i < i_end; i++, in_pix2 += inDX*expand_in, out_pix++) { 100 114 *out_pix = pixel[*in_pix2]; 101 115 } 102 116 } else { 103 for (i = i_start; i < i_end; i+= expand_out, in_pix2 ++, out_pix+= expand_out) {117 for (i = i_start; i < i_end; i+= expand_out, in_pix2 += inDX, out_pix+= expand_out) { 104 118 pixvalue = pixel[*in_pix2]; 105 119 out_pix2 = out_pix; … … 124 138 /**** fill in top area ****/ 125 139 out_pix = &data[j_end*dx]; 126 for (j = 0; j < (dy - j_end); j++) {140 for (j = 0; j < dy - j_end; j++) { 127 141 for (i = 0; i < dx; i++, out_pix++) { 128 142 *out_pix = back; -
trunk/Ohana/src/kapa2/src/Remap24.c
r18324 r25757 5 5 int i, j, ii, jj; 6 6 int i_start, i_end, j_start, j_end; 7 int dropback, extra; 7 int I_start, J_start; 8 int dropback, extra, inDX, inDY; 8 9 int dx, dy, DX, DY; 9 10 double expand, Ix, Iy; … … 53 54 extra = 4 - (dx * 3) % 4; 54 55 55 // x, y are the closest lit screen pixel to 0,0 56 Picture_Lower (&i_start, &j_start, matrix, picture); 56 // i_start, j_start are the closest lit screen pixel to 0,0 57 // I_start, J_start are the image pixel corresponding to i_start, j_start 58 Picture_Lower (&i_start, &j_start, &I_start, &J_start, matrix, picture); 57 59 58 // x, y are the closest lit screen pixel to dx, dy 59 Picture_Upper (&i_end, &j_end, matrix, picture); 60 // i_end, j_end are the closest lit screen pixel to dx, dy 61 // I_end, J_end are the image pixel corresponding to i_end, j_end 62 Picture_Upper (&i_end, &j_end, i_start, j_start, matrix, picture); 60 63 61 // Ix,Iy are the first displayed image pixel 62 Picture_to_Image (&Ix, &Iy, i_start, j_start, picture); 64 assert (i_start <= i_end); 65 assert (j_start <= j_end); 66 67 Ix = picture[0].flipx ? I_start - 1 : I_start; 68 Iy = picture[0].flipy ? J_start - 1 : J_start; 69 70 inDX = picture[0].flipx ? -1 : +1; 71 inDY = picture[0].flipy ? -1 : +1; 63 72 64 73 dropback = expand_out - (i_end - i_start) % expand_out; … … 80 89 } 81 90 82 for (j = j_start; j < j_end; j+= expand_out, in_pix += expand_in*DX) {91 for (j = j_start; j < j_end; j+= expand_out, in_pix += inDY*expand_in*DX) { 83 92 out_pix = &data[j*(3*dx+extra)]; 84 93 … … 97 106 in_pix2 = in_pix; 98 107 if (expand_out == 1) { 99 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix+=3) {108 for (i = i_start; i < i_end; i++, in_pix2+= inDX*expand_in, out_pix+=3) { 100 109 out_pix[0] = pixel1[*in_pix2]; 101 110 out_pix[1] = pixel2[*in_pix2]; … … 103 112 } 104 113 } else { 105 for (i = i_start; i < i_end; i+= expand_out, in_pix2 ++, out_pix+= 3*expand_out) {114 for (i = i_start; i < i_end; i+= expand_out, in_pix2 += inDX, out_pix+= 3*expand_out) { 106 115 pixvalue1 = pixel1[*in_pix2]; 107 116 pixvalue2 = pixel2[*in_pix2]; … … 121 130 /**** fill in area to the right of the picture ****/ 122 131 for (jj = 0; (jj < expand_out) && (j + jj < dy); jj++) { 123 // for (jj = 0; jj < expand_out; jj++) {124 132 out_pix2 = out_pix + jj*(3*dx+extra); 125 133 for (i = i_end; i < dx; i++, out_pix2+=3) { -
trunk/Ohana/src/kapa2/src/Remap32.c
r18324 r25757 1 1 # include "Ximage.h" 2 # define OUT_TYPE unsigned int 2 3 3 4 # define MY_SWAP_INT(A,B) { int tmp; tmp = A; A = B; B = tmp; } 4 5 5 # define MY_SWAP_WORD(W) { \6 char tmp, *X;\7 X = (char *) &W;\8 tmp = X[0]; X[0] = X[3]; X[3] = tmp;\9 tmp = X[1]; X[1] = X[2]; X[2] = tmp; }6 # define MY_SWAP_WORD(W) { \ 7 char tmp, *X; \ 8 X = (char *) &W; \ 9 tmp = X[0]; X[0] = X[3]; X[3] = tmp; \ 10 tmp = X[1]; X[1] = X[2]; X[2] = tmp; } 10 11 11 12 void Remap32 (Graphic *graphic, KapaImageWidget *image, Picture *picture, Matrix *matrix) { … … 13 14 int i, j, ii, jj; 14 15 int i_start, i_end, j_start, j_end; 16 int I_start, J_start; 15 17 int dropback, inDX, inDY; 16 18 int dx, dy, DX, DY; 17 19 double expand, Ix, Iy; 18 20 int expand_in, expand_out; 19 unsigned int *out_pix, *out_pix2;21 OUT_TYPE *out_pix, *out_pix2, *data; 20 22 unsigned short *in_pix, *in_pix2; 21 unsigned long*pixel, pixvalue;22 unsigned longback;23 OUT_TYPE *pixel, pixvalue; 24 OUT_TYPE back; 23 25 int swap_client, swap_server, swap_bytes; 24 26 25 ALLOCATE (pixel, unsigned long, graphic[0].Npixels); 27 // just skip if there is no data 28 if (matrix[0].Naxes == 0) return; 29 if (matrix[0].Naxis[0] == 0) return; 30 if (matrix[0].Naxis[1] == 0) return; 31 32 ALLOCATE (pixel, OUT_TYPE, graphic[0].Npixels); 26 33 27 34 # ifdef BYTE_SWAP … … 43 50 44 51 // set up expansions 45 assert ((picture[0].expand >= 1) || (picture[0].expand <= - 1));52 assert ((picture[0].expand >= 1) || (picture[0].expand <= -2)); 46 53 expand = expand_in = expand_out = 1.0; 47 54 if (picture[0].expand > 0) { … … 62 69 DY = matrix[0].Naxis[1]; 63 70 64 // x, y are the closest lit screen pixel to 0,0 65 Picture_Lower (&i_start, &j_start, matrix, picture); 71 // i_start, j_start are the closest lit screen pixel to 0,0 72 // I_start, J_start are the image pixel corresponding to i_start, j_start 73 Picture_Lower (&i_start, &j_start, &I_start, &J_start, matrix, picture); 66 74 67 // x, y are the closest lit screen pixel to dx, dy 68 Picture_Upper (&i_end, &j_end, matrix, picture); 75 // i_end, j_end are the closest lit screen pixel to dx, dy 76 // I_end, J_end are the image pixel corresponding to i_end, j_end 77 Picture_Upper (&i_end, &j_end, i_start, j_start, matrix, picture); 69 78 70 if (i_end < i_start) MY_SWAP_INT (i_start,i_end);71 if (j_end < j_start) MY_SWAP_INT (j_start,j_end);79 assert (i_start <= i_end); 80 assert (j_start <= j_end); 72 81 73 // Ix,Iy are the first displayed image pixel 74 Picture_to_Image (&Ix, &Iy, i_start, j_start, picture); 75 Ix = MIN (MAX (0, Ix), DX - 1); 76 Iy = MIN (MAX (0, Iy), DY - 1); 77 // XXX not completely consistent with the i_start, i_end range... 78 79 // we need to offset because i_start points to the bottom edge of Ix 80 // if (picture[0].flipx) Ix -= 1.0; 81 // if (picture[0].flipy) Iy -= 1.0; 82 Ix = picture[0].flipx ? I_start - 1 : I_start; 83 Iy = picture[0].flipy ? J_start - 1 : J_start; 82 84 83 85 inDX = picture[0].flipx ? -1 : +1; … … 87 89 if ((i_end - i_start) % expand_out == 0) dropback = 0; 88 90 89 out_pix = (unsigned int*) picture[0].data;91 out_pix = data = (OUT_TYPE *) picture[0].data; 90 92 in_pix = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)]; 91 93 … … 97 99 } 98 100 99 for (j = j_start; j < j_end; j+= expand_out, out_pix+=(expand_out-1)*dx, in_pix += inDY*expand_in*DX) { 101 for (j = j_start; j < j_end; j+= expand_out, in_pix += inDY*expand_in*DX) { 102 out_pix = &data[j*dx]; 100 103 101 104 /**** fill in area to the left of the picture ****/ … … 126 129 } 127 130 out_pix -= dropback; 128 129 // assert (in_pix2 - image[0].pixmap <= DX*DY);130 // assert (in_pix2 - image[0].pixmap >= 0);131 // assert (in_pix - image[0].pixmap <= DX*DY);132 // assert (in_pix - image[0].pixmap >= 0);133 131 134 132 /**** fill in area to the right of the picture ****/ … … 139 137 } 140 138 } 141 out_pix += (dx - i_end);142 // assert (out_pix - (unsigned int *)picture[0].data <= dx*dy);143 // assert (out_pix - (unsigned int *)picture[0].data >= 0);144 139 } 145 146 if ((j_end - j_start) % expand_out > 0)147 out_pix -= expand_out - (j_end - j_start) % expand_out;148 149 // assert (out_pix - (unsigned int *)picture[0].data <= dx*dy);150 // assert (out_pix - (unsigned int *)picture[0].data >= 0);151 140 152 141 /**** fill in top area ****/ 153 for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned int *)picture[0].data < dx*dy); j++, out_pix++) { 154 *out_pix = back; 142 out_pix = &data[j_end*dx]; 143 for (j = 0; j < dy - j_end; j++) { 144 for (i = 0; i < dx; i++, out_pix ++) { 145 *out_pix = back; 146 } 155 147 } 156 148 157 149 picture[0].pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, 158 picture[0].data, picture[0].dx, picture[0].dy, 32, 0);150 picture[0].data, picture[0].dx, picture[0].dy, 32, 0); 159 151 160 152 free (pixel); -
trunk/Ohana/src/kapa2/src/Remap8.c
r18324 r25757 1 1 # include "Ximage.h" 2 # define OUT_TYPE unsigned char 2 3 3 4 void Remap8 (Graphic *graphic, KapaImageWidget *image, Picture *picture, Matrix *matrix) { … … 5 6 int i, j, ii, jj; 6 7 int i_start, i_end, j_start, j_end; 7 int dropback; 8 int I_start, J_start; 9 int dropback, inDX, inDY; 8 10 int dx, dy, DX, DY; 9 11 double expand, Ix, Iy; 10 12 int expand_in, expand_out; 11 unsigned char *out_pix, *out_pix2;12 unsigned short *in_pix, *in_pix2;13 unsigned char*pixel, pixvalue;14 unsigned charback;13 OUT_TYPE *out_pix, *out_pix2, *data; 14 unsigned short *in_pix, *in_pix2; 15 OUT_TYPE *pixel, pixvalue; 16 OUT_TYPE back; 15 17 16 ALLOCATE (pixel, unsigned char, graphic[0].Npixels); 18 // just skip if there is no data 19 if (matrix[0].Naxes == 0) return; 20 if (matrix[0].Naxis[0] == 0) return; 21 if (matrix[0].Naxis[1] == 0) return; 22 23 ALLOCATE (pixel, OUT_TYPE, graphic[0].Npixels); 17 24 18 25 // local array for pixel values … … 44 51 DY = matrix[0].Naxis[1]; 45 52 46 // x, y are the closest lit screen pixel to 0,0 47 Picture_Lower (&i_start, &j_start, matrix, picture); 53 // i_start, j_start are the closest lit screen pixel to 0,0 54 // I_start, J_start are the image pixel corresponding to i_start, j_start 55 Picture_Lower (&i_start, &j_start, &I_start, &J_start, matrix, picture); 48 56 49 // x, y are the closest lit screen pixel to dx, dy 50 Picture_Upper (&i_end, &j_end, matrix, picture); 57 // i_end, j_end are the closest lit screen pixel to dx, dy 58 // I_end, J_end are the image pixel corresponding to i_end, j_end 59 Picture_Upper (&i_end, &j_end, i_start, j_start, matrix, picture); 51 60 52 // Ix,Iy are the first displayed image pixel 53 Picture_to_Image (&Ix, &Iy, i_start, j_start, picture); 61 assert (i_start <= i_end); 62 assert (j_start <= j_end); 63 64 Ix = picture[0].flipx ? I_start - 1 : I_start; 65 Iy = picture[0].flipy ? J_start - 1 : J_start; 66 67 inDX = picture[0].flipx ? -1 : +1; 68 inDY = picture[0].flipy ? -1 : +1; 54 69 55 70 dropback = expand_out - (i_end - i_start) % expand_out; 56 71 if ((i_end - i_start) % expand_out == 0) dropback = 0; 57 72 58 out_pix = (unsigned char*) picture[0].data;73 out_pix = data = (OUT_TYPE *) picture[0].data; 59 74 in_pix = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)]; 60 75 … … 66 81 } 67 82 68 for (j = j_start; j < j_end; j+= expand_out, out_pix+=(expand_out-1)*dx, in_pix += expand_in*DX) { 83 for (j = j_start; j < j_end; j+= expand_out, in_pix += inDY*expand_in*DX) { 84 out_pix = &data[j*dx]; 69 85 70 86 /**** fill in area to the left of the picture ****/ … … 80 96 in_pix2 = in_pix; 81 97 if (expand_out == 1) { 82 for (i = i_start; i < i_end; i++, in_pix2 +=expand_in, out_pix++) {98 for (i = i_start; i < i_end; i++, in_pix2 += inDX*expand_in, out_pix++) { 83 99 *out_pix = pixel[*in_pix2]; 84 100 } 85 101 } else { 86 for (i = i_start; i < i_end; i+= expand_out, in_pix2 ++, out_pix+= expand_out) {102 for (i = i_start; i < i_end; i+= expand_out, in_pix2 += inDX, out_pix+= expand_out) { 87 103 pixvalue = pixel[*in_pix2]; 88 104 out_pix2 = out_pix; 89 for (jj = 0; (jj < expand_out) & (j + jj < dy); jj++, out_pix2+=(dx-expand_out)) {105 for (jj = 0; (jj < expand_out) && (j + jj < dy); jj++, out_pix2+=(dx-expand_out)) { 90 106 for (ii = 0; ii < expand_out; ii++, out_pix2++) { 91 107 *out_pix2 = pixvalue; … … 103 119 } 104 120 } 105 out_pix += (dx - i_end);106 107 121 } 108 122 109 if ((j_end - j_start) % expand_out > 0)110 out_pix -= expand_out - (j_end - j_start) % expand_out;111 112 123 /**** fill in top area ****/ 113 for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned char *)picture[0].data < dx*dy); j++, out_pix++) { 114 *out_pix = back; 124 out_pix = &data[j_end*dx]; 125 for (j = 0; j < dy - j_end; j++) { 126 for (i = 0; i < dx; i++, out_pix++) { 127 *out_pix = back; 128 } 115 129 } 116 130 picture[0].pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, -
trunk/Ohana/src/kapa2/src/Reorient.c
r16228 r25757 7 7 picture = &image[0].picture; 8 8 9 if (picture[0].expand == 0) picture[0].expand = 1; 9 if (picture[0].expand == 0) { 10 picture[0].expand = 1; 11 image[0].zoom.expand = 5; 12 } 10 13 11 if ((picture[0].X == X) && (picture[0].Y== Y) && (mode == 0)) {14 if ((picture[0].Xc == X) && (picture[0].Yc == Y) && (mode == 0)) { 12 15 Refresh (); 13 16 XFlush (graphic[0].display); … … 17 20 switch (mode) { 18 21 case 0: 19 if ((picture[0].X != X) || (picture[0].Y!= Y)) {20 picture[0].X = X;21 picture[0].Y = Y;22 if ((picture[0].Xc != X) || (picture[0].Yc != Y)) { 23 picture[0].Xc = X; 24 picture[0].Yc = Y; 22 25 } 23 26 break; … … 25 28 picture[0].expand--; 26 29 if ((picture[0].expand == 0) || (picture[0].expand == -1)) picture[0].expand = -2; 27 picture[0].X = X;28 picture[0].Y = Y;30 picture[0].Xc = X; 31 picture[0].Yc = Y; 29 32 break; 30 33 case +1: 31 34 picture[0].expand++; 32 35 if ((picture[0].expand == 0) || (picture[0].expand == -1)) picture[0].expand = 1; 33 picture[0].X = X;34 picture[0].Y = Y;36 picture[0].Xc = X; 37 picture[0].Yc = Y; 35 38 break; 36 39 } 40 image[0].zoom.expand = MIN(image[0].zoom.dx / 5.5, MAX(5, 2*picture[0].expand)); 37 41 38 42 Remap (graphic, image); -
trunk/Ohana/src/kapa2/src/SetColorScale.c
r16061 r25757 218 218 // store the colors 219 219 if (USE_XWINDOW) { 220 if (graphic[0]. visualclass) {220 if (graphic[0].dynamicColors) { 221 221 XStoreColors(graphic[0].display, graphic[0].colormap, graphic[0].cmap, Npixels); 222 222 } else { -
trunk/Ohana/src/kapa2/src/SetColormap.c
r16039 r25757 146 146 store_colors: 147 147 if (!USE_XWINDOW) return (TRUE); 148 if (graphic[0].visualclass) { 149 XStoreColors(graphic[0].display, graphic[0].colormap, graphic[0].cmap, graphic[0].Npixels); 148 if (graphic[0].dynamicColors) { 149 if (!XStoreColors(graphic[0].display, graphic[0].colormap, graphic[0].cmap, graphic[0].Npixels)) { 150 fprintf (stderr, "error storing colors\n"); 151 } 150 152 } else { 151 153 for (i = 0; i < graphic[0].Npixels; i++) { 152 if ( XAllocColor (graphic[0].display, graphic[0].colormap, &graphic[0].cmap[i]) == 0) {154 if (!XAllocColor (graphic[0].display, graphic[0].colormap, &graphic[0].cmap[i])) { 153 155 fprintf (stderr, "error on %d\n", i); 154 156 } -
trunk/Ohana/src/kapa2/src/SetUpGraphic.c
r21153 r25757 60 60 graphic->color = KapaX11colors (graphic->display, graphic->colormap, graphic->fore, &Ncolors); 61 61 if (MAP_WINDOW) MapWindow (graphic); 62 62 63 return; 63 64 } -
trunk/Ohana/src/kapa2/src/StatusBox.c
r16256 r25757 11 11 y = 0.5*image[0].image[0].matrix.Naxis[1]; 12 12 // z = -1; 13 image[0].zoom.X = x;14 image[0].zoom.Y = y;13 image[0].zoom.Xc = x; 14 image[0].zoom.Yc = y; 15 15 // image[0].z = z; 16 16 } else { 17 x = image[0].zoom.X ;18 y = image[0].zoom.Y ;17 x = image[0].zoom.Xc; 18 y = image[0].zoom.Yc; 19 19 // z = image[0].z; 20 20 } -
trunk/Ohana/src/kapa2/src/UpdatePointer.c
r16256 r25757 29 29 30 30 skip: 31 image[0].zoom.X = x;32 image[0].zoom.Y = y;31 image[0].zoom.Xc = x; 32 image[0].zoom.Yc = y; 33 33 34 34 UpdateStatusBox (graphic, image, x, y, z, 0); … … 36 36 37 37 CreateZoom (graphic, image); 38 XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc, 39 image[0].zoom.pix, 0, 0, 40 image[0].zoom.x, image[0].zoom.y, 41 image[0].zoom.dx, image[0].zoom.dy); 38 if (image[0].zoom.pix) { 39 XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc, 40 image[0].zoom.pix, 0, 0, 41 image[0].zoom.x, image[0].zoom.y, 42 image[0].zoom.dx, image[0].zoom.dy); 43 } 42 44 CrossHairs (graphic, &image[0].zoom); 43 45 XFlush (graphic[0].display); -
trunk/Ohana/src/kapa2/src/UpdateStatusBox.c
r16255 r25757 48 48 49 49 bzero (line, 100); 50 sprintf (line, "%10. 1f %10.1f", x, y);50 sprintf (line, "%10.2f %10.2f", x, y); 51 51 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 52 52 image[0].text_x + PAD1, image[0].text_y + 2*textpad + 2*PAD1, line, strlen(line)); -
trunk/Ohana/src/kapa2/src/bDrawOverlay.c
r19838 r25757 81 81 double sn = sin(angle); 82 82 x0 = X + pX*dx*cs; 83 y0 = Y -pY*dx*sn;83 y0 = Y + pY*dx*sn; 84 84 // XXX dt should be based on the size of the ellipse... 85 85 // 0.10 -> 60 segments on the ellipse 86 86 # define DT 0.1 87 87 for (t = DT; t < 2*M_PI + DT; t+=DT) { 88 x1 = X + pX*dx*cos(t)*cs +pX*dy*sin(t)*sn;89 y1 = Y -pY*dx*cos(t)*sn + pY*dy*sin(t)*cs;88 x1 = X + pX*dx*cos(t)*cs - pX*dy*sin(t)*sn; 89 y1 = Y + pY*dx*cos(t)*sn + pY*dy*sin(t)*cs; 90 90 bDrawLine (x0, y0, x1, y1); 91 91 x0 = x1;
Note:
See TracChangeset
for help on using the changeset viewer.
