Changeset 16011
- Timestamp:
- Jan 6, 2008, 1:41:58 PM (18 years ago)
- Location:
- trunk/Ohana/src/kapa2
- Files:
-
- 6 added
- 41 edited
-
Makefile (modified) (1 diff)
-
include/buttons.h (modified) (1 diff)
-
include/constants.h (modified) (2 diffs)
-
include/prototypes.h (modified) (5 diffs)
-
include/structures.h (modified) (6 diffs)
-
src/ButtonFunctions.c (modified) (7 diffs)
-
src/CSaveOverlay.c (modified) (1 diff)
-
src/Center.c (modified) (2 diffs)
-
src/CheckButtons.c (modified) (3 diffs)
-
src/CheckPipe.c (modified) (1 diff)
-
src/CheckVisual.c (modified) (6 diffs)
-
src/ColorCube.c (added)
-
src/ColorHistogram.c (added)
-
src/CreateZoom16.c (modified) (4 diffs)
-
src/CreateZoom24.c (modified) (4 diffs)
-
src/CreateZoom32.c (modified) (11 diffs)
-
src/CreateZoom8.c (modified) (4 diffs)
-
src/CursorOps.c (modified) (2 diffs)
-
src/DragColorbar.c (modified) (2 diffs)
-
src/Image.c (modified) (6 diffs)
-
src/InterpretKeys.c (modified) (5 diffs)
-
src/InterpretPresses.c (modified) (3 diffs)
-
src/JPEGit24.c (modified) (5 diffs)
-
src/LoadOverlay.c (modified) (1 diff)
-
src/LoadPicture.c (modified) (5 diffs)
-
src/LoadTickmarks.c (modified) (1 diff)
-
src/MakeColormap.c (modified) (1 diff)
-
src/PSPixmap.c (modified) (5 diffs)
-
src/Remap.c (modified) (1 diff)
-
src/Remap16.c (modified) (1 diff)
-
src/Remap24.c (modified) (1 diff)
-
src/Remap32.c (modified) (7 diffs)
-
src/Remap8.c (modified) (1 diff)
-
src/Reorient.c (modified) (2 diffs)
-
src/Rescale.c (added)
-
src/SetChannel.c (added)
-
src/SetColorScale.c (added)
-
src/SetColormap.c (modified) (3 diffs)
-
src/SetGraphSize.c (modified) (1 diff)
-
src/SetImageData.c (modified) (9 diffs)
-
src/SetImageSize.c (modified) (8 diffs)
-
src/SetToolbox.c (modified) (2 diffs)
-
src/SetUpGraphic.c (modified) (1 diff)
-
src/StatusBox.c (modified) (1 diff)
-
src/UpdatePointer.c (modified) (2 diffs)
-
src/UpdateStatusBox.c (modified) (2 diffs)
-
src/sort.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kapa2/Makefile
r13484 r16011 77 77 $(SRC)/bDrawOverlay.$(ARCH).o $(SRC)/ButtonFunctions.$(ARCH).o \ 78 78 $(SRC)/PSimage.$(ARCH).o $(SRC)/PSPixmap.$(ARCH).o \ 79 $(SRC)/PSOverlay.$(ARCH).o 79 $(SRC)/PSOverlay.$(ARCH).o $(SRC)/SetChannel.$(ARCH).o \ 80 $(SRC)/SetColorScale.$(ARCH).o $(SRC)/ColorCube.$(ARCH).o \ 81 $(SRC)/ColorHistogram.$(ARCH).o $(SRC)/sort.$(ARCH).o 80 82 81 83 OBJ = $(KAPA) -
trunk/Ohana/src/kapa2/include/buttons.h
r13320 r16011 47 47 0x80, 0xef, 0x03, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 48 48 0x00, 0x00, 0x00, 0x00}; 49 #define puns_width 2550 #define puns_height 2551 static char puns_bits[] = {49 #define heat_width 25 50 #define heat_height 25 51 static char heat_bits[] = { 52 52 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x07, 0xd8, 0x01, 53 53 0x00, 0x0c, 0x37, 0x00, 0xf8, 0xc9, 0x6f, 0x00, 0x0c, 0xde, 0xf0, 0x00, -
trunk/Ohana/src/kapa2/include/constants.h
r13479 r16011 9 9 | StructureNotifyMask \ 10 10 | PointerMotionMask) 11 12 # define NCHANNELS 3 13 # define NPIXELS_DYNAMIC 128 14 15 // XXX for the moment, this is set to match the values in SetColorScale3D_CC 16 # define NPIXELS_STATIC 4600 11 17 12 18 # define PAD1 3 … … 27 33 # define LABEL_MAXLEN 128 28 34 35 typedef enum { 36 KAPA_SCALE_1D, 37 KAPA_SCALE_3D_RUFF, 38 KAPA_SCALE_3D_FULL 39 } KapaColorScaleMode; 40 29 41 /* label names */ 30 # define LABELX0 0 31 # define LABELY0 1 32 # define LABELX1 2 33 # define LABELY1 3 34 # define LABELUL 4 35 # define LABELUR 5 36 # define LABELLL 6 37 # define LABELLR 7 42 typedef enum { 43 LABELX0, 44 LABELY0, 45 LABELX1, 46 LABELY1, 47 LABELUL, 48 LABELUR, 49 LABELLL, 50 LABELLR 51 } KapaLabelMode; 52 53 typedef enum { 54 KAPA_CHANNEL_RED, 55 KAPA_CHANNEL_GREEN, 56 KAPA_CHANNEL_BLUE, 57 } KapaChannels; 58 59 // use an enum to identify the 3 dimensions: 60 typedef enum { 61 CC_X, 62 CC_Y, 63 CC_Z, 64 } CCDimen; 38 65 39 66 /* EVENT_MASK consists of: -
trunk/Ohana/src/kapa2/include/prototypes.h
r14590 r16011 71 71 int GetImageCoords PROTO((int sock)); 72 72 int GetImageRange PROTO((int sock)); 73 int SetChannel (int sock); 74 int SetColormapFromPipe (int sock); 73 75 74 76 int LoadVectorData PROTO((int sock, KapaGraphWidget *graph, int N, char *type)); … … 140 142 141 143 int Center PROTO(()); 142 void Remap PROTO((Graphic *graphic, KapaImageWidget *image, Matrix *matrix)); 144 void SetColorScale PROTO((Graphic *graphic, KapaImageWidget *image)); 145 void SetColorScale1D PROTO((Graphic *graphic, KapaImageWidget *image)); 146 int SetColorScale3D PROTO((Graphic *graphic, KapaImageWidget *image)); 147 void Remap PROTO((Graphic *graphic, KapaImageWidget *image)); 143 148 void Remap8 PROTO((Graphic *graphic, KapaImageWidget *image, Matrix *matrix)); 144 149 void Remap16 PROTO((Graphic *graphic, KapaImageWidget *image, Matrix *matrix)); … … 147 152 int LoadPicture PROTO((int sock)); 148 153 149 KapaImageWidget *InitImage PROTO(()); 154 KapaImageWidget *InitImageWidget PROTO(()); 155 int InitImageChannel PROTO((KapaImageChannel *channel)); 150 156 void FreeImage PROTO((KapaImageWidget *image)); 151 157 void SetImageSize PROTO((Section *section)); … … 179 185 /* Button Functions */ 180 186 int greycolors PROTO((Graphic *graphic, KapaImageWidget *image)); 181 int punsPROTO((Graphic *graphic, KapaImageWidget *image));187 int heat PROTO((Graphic *graphic, KapaImageWidget *image)); 182 188 int rainbow PROTO((Graphic *graphic, KapaImageWidget *image)); 183 189 int Recenter PROTO((Graphic *graphic, KapaImageWidget *image)); … … 219 225 void InvertButton (Graphic *graphic, Button *button); 220 226 void bDrawOverlay (KapaImageWidget *image, int N); 227 228 /* color cube tools */ 229 CCNode *CCNodeAlloc (); 230 CCNode *CCFindChild (CCNode *node, float x, float y, float z); 231 int CCSplitNode (CCNode *node); 232 int CCSplitNodeIterate (CCNode *node, int current, int max); 233 void CCNodeFree (CCNode *node); 234 CCNode *CCFindBottom (CCNode *top, float x, float y, float z); 235 int CCNodeExtractCounts (CCNode *node, float **values, int *nvalues, int *NVALUES); 236 int CCNodeDivideLimit (CCNode *node, float minValue); 237 int CCNodeInitCounts (CCNode *node, float value); 238 239 /* 3D color histogram */ 240 void ColorHistogram (KapaImageWidget *image, CCNode *cube); 241 void CCNodeSetColorPixels (KapaImageWidget *image, CCNode *cube); 242 int CCNodeSetColorMap (CCNode *node, XColor *cmap, int Npixels, int *current); 243 244 int SetColorScale3D_CC (Graphic *graphic, KapaImageWidget *image); 245 246 void sort (float *value, int N); -
trunk/Ohana/src/kapa2/include/structures.h
r14590 r16011 2 2 /**************** Graphic carries X info around ****************/ 3 3 typedef struct { 4 Display *display; 5 int screen; 4 Display *display; // X display pointer 5 int screen; // X screen number 6 6 int depth; 7 7 Window window; 8 8 Visual *visual; 9 int visualclass; 10 int Nbits; 9 int visualclass; // is visual dynamic? (XXX change name?) 10 int Nbits; // pixel depth in bits (8, 16, 24, 32) 11 11 GC gc; 12 12 XFontStruct *font; … … 14 14 int x, y; 15 15 unsigned int dx, dy; 16 XColor cmap[256];16 XColor *cmap; 17 17 Colormap colormap; 18 unsigned long fore; 19 unsigned long back; 20 unsigned long *color; 21 unsigned long pixels[256]; 22 unsigned long overlay_color[NOVERLAYS]; 23 int Npixels; 24 int Ncolors; 18 unsigned long *color; // graph plotting colors 19 int Ncolors; 20 21 unsigned long *pixels; // image pixel colors 22 int Npixels; // number of pixels 23 24 int ColorScaleMode; // single colormap for all images?? 25 int nRed; 26 int nBlue; 27 int nGreen; 28 29 unsigned long fore; // basic foreground color 30 unsigned long back; // basic background color 31 32 unsigned long overlay_color[NOVERLAYS]; // image plotting colors 25 33 } Graphic; 26 34 … … 58 66 } TextBox; 59 67 68 /*** 3C color cube histogram tree thingy ***/ 69 typedef struct CCNode { 70 // for the moment, this structure is specific to the color-histogram analysis. if 71 // this were a void *pointer and we defined some additional apis, we could use this 72 // structure to track any 3D space 73 int count; 74 int pixel; 75 char bottom; 76 float min[3]; // min value for each of the 3 dimensions for this node 77 float mid[3]; // mid-point for each of the 3 dimensions for this node 78 float max[3]; // max value for each of the 3 dimensions for this node 79 struct CCNode *sub[2][2][2]; 80 } CCNode; 81 60 82 /**************** general structures ****************/ 61 83 typedef struct { … … 125 147 } KapaGraphWidget; 126 148 149 typedef struct { 150 // data associated with this image element 151 Matrix matrix; /* data for picture */ 152 double zero, range; /* zero, range for picture to cmap */ 153 double max, min; /* zero, range for data to z-value */ 154 double start, slope; /* zero, range for cmap to pixels */ 155 Coords coords; 156 char file[1024]; /* name of file */ 157 char name[1024]; /* name of buffer */ 158 } KapaImageChannel; 159 127 160 // a single image in the display window 128 161 typedef struct { … … 139 172 Button grey_button; 140 173 Button rainbow_button; 141 Button puns_button;174 Button heat_button; 142 175 Button overlay_button[NOVERLAYS]; 143 176 … … 149 182 int DecimalDegrees; 150 183 151 // data associated with this image element 184 double X, Y; /* image pixel at screen center */ 185 int expand; /* zoomscale */ 186 double x, y, z; /* last pointer coords */ 187 152 188 Overlay overlay[NOVERLAYS]; 153 189 Overlay tickmarks; 154 Matrix matrix; /* data for picture */ 155 double X, Y; /* image pixel at screen center */ 156 int expand; /* zoomscale */ 157 double zero, range; /* zero, range for picture to cmap */ 158 double max, min; /* zero, range for data to z-value */ 159 double start, slope; /* zero, range for cmap to pixels */ 160 double x, y, z; /* last pointer coords */ 161 Coords coords; 162 char file[1024]; /* name of file */ 163 char name[1024]; /* name of buffer */ 190 191 unsigned short *pixmap; // lookup table for image pixel value to pixel index 192 int nPixels; 193 194 KapaImageChannel *image; 195 KapaImageChannel channel[NCHANNELS]; 164 196 } KapaImageWidget; 165 197 -
trunk/Ohana/src/kapa2/src/ButtonFunctions.c
r13331 r16011 2 2 3 3 static char *GREY = "greyscale"; 4 static char * PUNS = "Puns";4 static char *HEAT = "Heat"; 5 5 static char *RAINBOW = "Rainbow"; 6 6 … … 18 18 SetColormap (name); 19 19 CreateColorbar (image, graphic); 20 Remap (graphic, image, &image[0].matrix); 20 SetColorScale (graphic, image); 21 Remap (graphic, image); 21 22 CreateZoom (image, graphic, 0, 0); 22 23 Refresh (); … … 25 26 } 26 27 27 int puns(Graphic *graphic, KapaImageWidget *image) {28 int heat (Graphic *graphic, KapaImageWidget *image) { 28 29 char *name; 29 name = PUNS;30 SetColormap ( name);30 name = HEAT; 31 SetColormap ("ruffcolor"); 31 32 CreateColorbar (image, graphic); 32 Remap (graphic, image, &image[0].matrix); 33 SetColorScale (graphic, image); 34 Remap (graphic, image); 33 35 CreateZoom (image, graphic, 0, 0); 34 36 Refresh (); … … 40 42 char *name; 41 43 name = RAINBOW; 42 SetColormap ( name);44 SetColormap ("fullcolor"); 43 45 CreateColorbar (image, graphic); 44 Remap (graphic, image, &image[0].matrix); 46 SetColorScale (graphic, image); 47 Remap (graphic, image); 45 48 CreateZoom (image, graphic, 0, 0); 46 49 Refresh (); … … 54 57 image[0].Y = 0; 55 58 56 Remap (graphic, image , &image[0].matrix);59 Remap (graphic, image); 57 60 Refresh (); 58 61 FlushDisplay (graphic[0].display); … … 64 67 65 68 image[0].expand = 1; 66 Remap (graphic, image , &image[0].matrix);69 Remap (graphic, image); 67 70 Refresh (); 68 71 FlushDisplay (graphic[0].display); … … 77 80 image[0].expand = 1; 78 81 79 Remap (graphic, image , &image[0].matrix);82 Remap (graphic, image); 80 83 Refresh (); 81 84 FlushDisplay (graphic[0].display); -
trunk/Ohana/src/kapa2/src/CSaveOverlay.c
r13479 r16011 24 24 for (i = 0; i < image[0].overlay[N].Nobjects; i++) { 25 25 if (image[0].overlay[N].objects[i].type == KII_OVERLAY_LINE) { 26 XY_to_RD (&ra, &dec, image[0].overlay[N].objects[i].x, image[0].overlay[N].objects[i].y, &image[0]. coords);26 XY_to_RD (&ra, &dec, image[0].overlay[N].objects[i].x, image[0].overlay[N].objects[i].y, &image[0].image[0].coords); 27 27 x1 = image[0].overlay[N].objects[i].x + image[0].overlay[N].objects[i].dx; 28 28 y1 = image[0].overlay[N].objects[i].y + image[0].overlay[N].objects[i].dy; 29 XY_to_RD (&ra1, &dec1, x1, y1, &image[0]. coords);29 XY_to_RD (&ra1, &dec1, x1, y1, &image[0].image[0].coords); 30 30 dra = (ra1 - ra); 31 31 ddec = (dec1 - dec); 32 32 } else { 33 XY_to_RD (&ra, &dec, image[0].overlay[N].objects[i].x, image[0].overlay[N].objects[i].y, &image[0]. coords);33 XY_to_RD (&ra, &dec, image[0].overlay[N].objects[i].x, image[0].overlay[N].objects[i].y, &image[0].image[0].coords); 34 34 x1 = image[0].overlay[N].objects[i].x; 35 35 y1 = image[0].overlay[N].objects[i].y + image[0].overlay[N].objects[i].dy; 36 XY_to_RD (&ra1, &dec1, x1, y1, &image[0]. coords);36 XY_to_RD (&ra1, &dec1, x1, y1, &image[0].image[0].coords); 37 37 ddec = fabs (dec1 - dec); 38 38 x1 = image[0].overlay[N].objects[i].x + image[0].overlay[N].objects[i].dx; 39 39 y1 = image[0].overlay[N].objects[i].y; 40 XY_to_RD (&ra1, &dec1, x1, y1, &image[0]. coords);40 XY_to_RD (&ra1, &dec1, x1, y1, &image[0].image[0].coords); 41 41 dra = cos (dec*RAD_DEG) * fabs (ra1 - ra); 42 42 } -
trunk/Ohana/src/kapa2/src/Center.c
r13479 r16011 16 16 if (image == NULL) return (TRUE); 17 17 18 image[0].X = 0.5*image[0]. matrix.Naxis[0] - X;19 image[0].Y = 0.5*image[0]. matrix.Naxis[1] - Y;18 image[0].X = 0.5*image[0].image[0].matrix.Naxis[0] - X; 19 image[0].Y = 0.5*image[0].image[0].matrix.Naxis[1] - Y; 20 20 if ((zoom != 0) && (zoom != -1)) { 21 21 image[0].expand = zoom; … … 23 23 24 24 if (USE_XWINDOW) { 25 Remap (graphic, image , &image[0].matrix);25 Remap (graphic, image); 26 26 Refresh (); 27 27 XFlush (graphic[0].display); -
trunk/Ohana/src/kapa2/src/CheckButtons.c
r13320 r16011 1 1 # include "Ximage.h" 2 # define PAD_X 103 # define PAD_Y 104 # define NPLANES 15 # define NPIXELS 2556 2 7 3 /******** Here we test the Buttons specific to this program *******/ … … 21 17 button = &image[0].rainbow_button; 22 18 23 if (InButton (event, &image[0]. puns_button))24 button = &image[0]. puns_button;19 if (InButton (event, &image[0].heat_button)) 20 button = &image[0].heat_button; 25 21 26 22 if (InButton (event, &image[0].PS_button)) … … 39 35 } 40 36 41 42 37 /* To define a button, you must: 43 38 -
trunk/Ohana/src/kapa2/src/CheckPipe.c
r14590 r16011 268 268 } 269 269 270 if (!strcmp (word, "CHAN")) { 271 status = SetChannel (sock); 272 KiiSendCommand (sock, 4, "DONE"); 273 FINISHED (status); 274 } 275 276 if (!strcmp (word, "CMAP")) { 277 status = SetColormapFromPipe (sock); 278 KiiSendCommand (sock, 4, "DONE"); 279 FINISHED (status); 280 } 281 270 282 if (!strcmp (word, "SAVE")) { 271 283 status = SaveOverlay (sock); -
trunk/Ohana/src/kapa2/src/CheckVisual.c
r13479 r16011 1 1 # include "Ximage.h" 2 # define NPIXELS 643 2 4 3 /* DirectColor doesn't seem to work, even though it is available: … … 11 10 12 11 int i, Nfound, N; 13 int col, def, dyn;12 int isColor, isDefault, isDynamic; 14 13 XVisualInfo *visual_list, visual_temp; 15 14 unsigned long planes[3]; … … 20 19 fprintf (stderr, "DirectColor: %d\n", DirectColor); 21 20 fprintf (stderr, "PseudoColor: %d\n", PseudoColor); 22 fprintf (stderr, "TrueColor: %d\n", TrueColor);23 fprintf (stderr, "GrayScale: %d\n", GrayScale);21 fprintf (stderr, "TrueColor: %d\n", TrueColor); 22 fprintf (stderr, "GrayScale: %d\n", GrayScale); 24 23 fprintf (stderr, "StaticColor: %d\n", StaticColor); 25 fprintf (stderr, "StaticGray: %d\n", StaticGray);24 fprintf (stderr, "StaticGray: %d\n", StaticGray); 26 25 } 27 26 … … 42 41 } 43 42 44 col = def = dyn = FALSE; 43 // set these based on selected visual 44 isColor = isDefault = isDynamic = FALSE; 45 46 // attempt to select the most desirable type of visual: Default as PseudoColor (XXX is it still true?) 45 47 if (DEBUG) fprintf (stderr, "default visual class is %d\n", visual_list[i].class); 46 switch (visual_list[i].class) { 47 case PseudoColor: 48 col = def = dyn = TRUE; 48 if (visual_list[i].class == PseudoColor) { 49 isColor = isDefault = isDynamic = TRUE; 49 50 graphic[0].visual = visual_list[i].visual; 50 51 graphic[0].visualclass = TRUE; 51 52 goto test_pixels; 52 break;53 default:54 break;55 53 } 56 54 57 for (i = 0; i < Nfound; i++) { 58 switch (visual_list[i].class) { 59 case PseudoColor: 60 if (DEBUG) fprintf (stderr, "selected visual class is %d\n", visual_list[i].class); 61 col = dyn = TRUE; 62 if (graphic[0].visual == visual_list[i].visual) { 63 def = TRUE; 64 } else { 65 graphic[0].visual = visual_list[i].visual; 66 } 67 graphic[0].visualclass = TRUE; 68 goto test_pixels; 69 break; 70 default: 71 break; 72 } 55 // attempt to select the most desirable type of visual: PseudoColor (XXX is it still true?) 56 for (i = 0; (i < Nfound) && (visual_list[i].class != PseudoColor); i++); 57 if (i != Nfound) { 58 isColor = isDynamic = TRUE; 59 if (DEBUG) fprintf (stderr, "selected visual class is %d\n", visual_list[i].class); 60 isDefault = (graphic[0].visual == visual_list[i].visual); 61 graphic[0].visual = visual_list[i].visual; 62 graphic[0].visualclass = TRUE; 63 goto test_pixels; 73 64 } 74 65 75 for (i = 0; i < Nfound; i++) { 76 switch (visual_list[i].class) { 77 case GrayScale: 78 if (DEBUG) fprintf (stderr, "selected visual class is %d\n", visual_list[i].class); 79 dyn = TRUE; 80 if (graphic[0].visual == visual_list[i].visual) { 81 def = TRUE; 82 } else { 83 graphic[0].visual = visual_list[i].visual; 84 } 85 graphic[0].visualclass = TRUE; 86 goto test_pixels; 87 break; 88 default: 89 break; 90 } 66 // attempt to select the most desirable type of visual: GrayScale (XXX is it still true?) 67 for (i = 0; (i < Nfound) && (visual_list[i].class != GrayScale); i++); 68 if (i != Nfound) { 69 isDynamic = TRUE; 70 if (DEBUG) fprintf (stderr, "selected visual class is %d\n", visual_list[i].class); 71 isDefault = (graphic[0].visual == visual_list[i].visual); 72 graphic[0].visual = visual_list[i].visual; 73 graphic[0].visualclass = TRUE; 74 goto test_pixels; 91 75 } 92 76 77 // attempt to select the most desirable type of visual: TrueColor (XXX is it still true?) 93 78 for (i = 0; (i < Nfound) && (visual_list[i].class != TrueColor); i++); 94 79 if (i != Nfound) { 95 col= TRUE;80 isColor = TRUE; 96 81 if (DEBUG) fprintf (stderr, "visual class is %d\n", visual_list[i].class); 97 if (graphic[0].visual == visual_list[i].visual) { 98 def = TRUE; 99 } else { 100 graphic[0].visual = visual_list[i].visual; 101 } 82 isDefault = (graphic[0].visual == visual_list[i].visual); 83 graphic[0].visual = visual_list[i].visual; 102 84 graphic[0].visualclass = FALSE; 103 85 goto test_pixels; 104 86 } 105 87 88 // attempt to select the most desirable type of visual: TrueColor (XXX is it still true?) 106 89 for (i = 0; (i < Nfound) && (visual_list[i].class != StaticColor); i++); 107 90 if (i != Nfound) { 108 91 if (DEBUG) fprintf (stderr, "visual class is %d\n", visual_list[i].class); 109 if (graphic[0].visual == visual_list[i].visual) { 110 def = TRUE; 111 } else { 112 graphic[0].visual = visual_list[i].visual; 113 } 92 isDefault = (graphic[0].visual == visual_list[i].visual); 93 graphic[0].visual = visual_list[i].visual; 114 94 graphic[0].visualclass = FALSE; 115 95 goto test_pixels; 116 96 } 117 97 98 // attempt to select the most desirable type of visual: TrueColor (XXX is it still true?) 118 99 for (i = 0; (i < Nfound) && (visual_list[i].class != StaticGray); i++); 119 100 if (i != Nfound) { 120 101 if (DEBUG) fprintf (stderr, "visual class is %d\n", visual_list[i].class); 121 if (graphic[0].visual == visual_list[i].visual) { 122 def = TRUE; 123 } else { 124 graphic[0].visual = visual_list[i].visual; 125 } 102 isDefault = (graphic[0].visual == visual_list[i].visual); 103 graphic[0].visual = visual_list[i].visual; 126 104 graphic[0].visualclass = FALSE; 127 105 goto test_pixels; … … 136 114 /* NEED TO ADD A COUPLE LINES DEFINING THE VARIOUS HARD COLORS (BLACK, WHITE, AND THE OVERLAYS) */ 137 115 116 // allow user to force a private colormap 138 117 if ((N = get_argument (*argc, argv, "-private"))) { 139 118 remove_argument(N, argc, argv); 140 def= FALSE;119 isDefault = FALSE; 141 120 } 142 121 143 if (!def) { 122 // allocate a private colormap, if needed 123 if (!isDefault) { 144 124 if (DEBUG) fprintf (stderr, "allocated private colormap\n"); 145 125 graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, AllocNone); 146 126 } 147 127 148 if (dyn) { 149 /* allocate color cells */ 150 for (graphic[0].Npixels = NPIXELS; 151 ((graphic[0].Npixels >= 16) && 152 !XAllocColorCells (graphic[0].display, graphic[0].colormap, FALSE, planes, 1, graphic[0].pixels, graphic[0].Npixels)); 153 graphic[0].Npixels -= 4) { 128 if (isDynamic) { 129 /* allocate color cells */ 130 ALLOCATE (graphic[0].pixels, unsigned long, NPIXELS_DYNAMIC); 131 ALLOCATE (graphic[0].cmap, XColor, NPIXELS_DYNAMIC); 132 for (graphic[0].Npixels = NPIXELS_DYNAMIC; graphic[0].Npixels >= 16; graphic[0].Npixels -= 4) { 154 133 if (DEBUG) fprintf (stderr, "trying %d colors\n", (int) graphic[0].Npixels); 134 if (XAllocColorCells (graphic[0].display, graphic[0].colormap, FALSE, planes, 1, graphic[0].pixels, graphic[0].Npixels)) { 135 break; 136 } 155 137 } 156 138 139 /* insufficient cells, can we make a private colormap? */ 140 if (graphic[0].Npixels < 16) { 141 if (!isDefault) { 142 fprintf (stderr, "can't allocate enough cells in private colormap\n"); 143 exit (0); 144 } 145 if (DEBUG) fprintf (stderr, "can't allocate enough cells, using private colormap\n"); 146 graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, AllocNone); 157 147 158 /* make private colormap */ 159 if (graphic[0].Npixels < 16) { 160 // fprintf (stderr, "can't allocate enough cells, using private colormap\n"); 161 graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, AllocNone); 162 for (graphic[0].Npixels = NPIXELS; 163 ((graphic[0].Npixels >= 16) && 164 !XAllocColorCells (graphic[0].display, graphic[0].colormap, FALSE, planes, 1, graphic[0].pixels, graphic[0].Npixels)); 165 graphic[0].Npixels -= 4); 148 for (graphic[0].Npixels = NPIXELS_DYNAMIC; graphic[0].Npixels >= 16; graphic[0].Npixels -= 4) { 149 if (DEBUG) fprintf (stderr, "trying %d colors\n", (int) graphic[0].Npixels); 150 if (XAllocColorCells (graphic[0].display, graphic[0].colormap, FALSE, planes, 1, graphic[0].pixels, graphic[0].Npixels)) { 151 break; 152 } 153 } 166 154 167 155 if ((N = get_argument (*argc, argv, "-colorcount"))) { 168 fprintf (stderr, "k ii can grab %d colors\n", (int)graphic[0].Npixels);156 fprintf (stderr, "kapa can grab %d colors\n", graphic[0].Npixels); 169 157 exit (0); 170 158 } … … 174 162 } 175 163 } 176 } 177 178 if (!dyn) { 179 graphic[0].Npixels = 256; 180 // fprintf (stderr, "can't use dynamic colors, color scrollbar inactive\n"); 181 // fprintf (stderr, " this can be avoided by using a dynamic visual class\n"); 182 // fprintf (stderr, " (see Kii help page for details)\n"); 164 } else { 165 // XXX allocate the unsigned long *pixels here and above 166 ALLOCATE (graphic[0].pixels, unsigned long, NPIXELS_STATIC); 167 ALLOCATE (graphic[0].cmap, XColor, NPIXELS_STATIC); 168 graphic[0].Npixels = NPIXELS_STATIC; 183 169 } 184 170 185 171 if ((N = get_argument (*argc, argv, "-colorcount"))) { 186 fprintf (stderr, "kii can grab %d colors\n", (int)graphic[0].Npixels);172 fprintf (stderr, "kii can grab %d colors\n", graphic[0].Npixels); 187 173 exit (0); 188 174 } -
trunk/Ohana/src/kapa2/src/CreateZoom16.c
r13479 r16011 31 31 dy = image[0].zoom.dy; 32 32 33 if (image[0]. matrix.size == 0) { /* create a test pattern */33 if (image[0].image[0].matrix.size == 0) { /* create a test pattern */ 34 34 REALLOCATE (image[0].zoom.data, char, 2*dy*dx); 35 35 bzero (image[0].zoom.data, image[0].zoom.dx*image[0].zoom.dy); … … 48 48 // define the color transform parameters 49 49 MaxValue = graphic[0].Npixels - 1; 50 if (image[0]. range != 0.0) {51 slope = graphic[0].Npixels / image[0]. range;52 start = graphic[0].Npixels * image[0]. zero /image[0].range;50 if (image[0].image[0].range != 0.0) { 51 slope = graphic[0].Npixels / image[0].image[0].range; 52 start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range; 53 53 } else { 54 54 slope = 1.0; 55 start = image[0]. zero;55 start = image[0].image[0].zero; 56 56 } 57 57 … … 61 61 expand_in = 1; 62 62 63 DX = image[0]. matrix.Naxis[0];64 DY = image[0]. matrix.Naxis[1];63 DX = image[0].image[0].matrix.Naxis[0]; 64 DY = image[0].image[0].matrix.Naxis[1]; 65 65 Rx = x - expand*(int)(0.5*(dx + 1)) + 1; 66 66 Ry = y - expand*(int)(0.5*(dy + 1)) + 1; … … 74 74 75 75 data = out_pix = (unsigned char *) image[0].zoom.data; 76 imdata = (float *) image[0]. matrix.buffer;76 imdata = (float *) image[0].image[0].matrix.buffer; 77 77 in_pix = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)]; 78 78 -
trunk/Ohana/src/kapa2/src/CreateZoom24.c
r13479 r16011 32 32 extra = 4 - (dx * 3) % 4; 33 33 34 if (image[0]. matrix.size == 0) { /* create a test pattern */34 if (image[0].image[0].matrix.size == 0) { /* create a test pattern */ 35 35 REALLOCATE (image[0].zoom.data, char, dy*(3*dx+extra)); 36 36 bzero (image[0].zoom.data, image[0].zoom.dx*image[0].zoom.dy); … … 52 52 // define the color transform parameters 53 53 MaxValue = graphic[0].Npixels - 1; 54 if (image[0]. range != 0.0) {55 slope = graphic[0].Npixels / image[0]. range;56 start = graphic[0].Npixels * image[0]. zero /image[0].range;54 if (image[0].image[0].range != 0.0) { 55 slope = graphic[0].Npixels / image[0].image[0].range; 56 start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range; 57 57 } else { 58 58 slope = 1.0; 59 start = image[0]. zero;59 start = image[0].image[0].zero; 60 60 } 61 61 … … 65 65 expand_in = 1; 66 66 67 DX = image[0]. matrix.Naxis[0];68 DY = image[0]. matrix.Naxis[1];67 DX = image[0].image[0].matrix.Naxis[0]; 68 DY = image[0].image[0].matrix.Naxis[1]; 69 69 Rx = x - expand*(int)(0.5*(dx + 1)) + 1; 70 70 Ry = y - expand*(int)(0.5*(dy + 1)) + 1; … … 78 78 79 79 data = out_pix = (unsigned char *) image[0].zoom.data; 80 imdata = (float *) image[0]. matrix.buffer;80 imdata = (float *) image[0].image[0].matrix.buffer; 81 81 in_pix = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)]; 82 82 -
trunk/Ohana/src/kapa2/src/CreateZoom32.c
r13479 r16011 1 1 # include "Ximage.h" 2 2 # define FRAC(a) ((a) - (int)(a)) 3 4 static float slope = 1.0;5 static float start = 0.0;6 static int MaxValue = 255;7 8 // XXX inline this if needed9 static int PixelLookup(float value) {10 int out;11 out = MIN (MAX (slope * value - start, 0), MaxValue);12 return (out);13 }14 3 15 4 void CreateZoom32 (KapaImageWidget *image, Graphic *graphic, double x, double y) { … … 22 11 int expand_in, expand_out; 23 12 unsigned int *out_pix, *out_pix2; 24 float *imdata,*in_pix, *in_pix2;25 unsigned long pixel[256], pixvalue;13 unsigned short *in_pix, *in_pix2; 14 unsigned long *pixel, pixvalue; 26 15 unsigned long back; 27 16 28 if (image[0]. matrix.size == 0) { /* create a test pattern */17 if (image[0].image[0].matrix.size == 0) { /* create a test pattern */ 29 18 REALLOCATE (image[0].zoom.data, char, 4*image[0].zoom.dx*image[0].zoom.dy); 30 19 image[0].zoom.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, … … 33 22 } 34 23 35 for (i = 0; i < 256; i++) { /* set up pixel array */ 24 ALLOCATE (pixel, unsigned long, graphic[0].Npixels); 25 26 // local array for pixel values 27 for (i = 0; i < graphic[0].Npixels; i++) { 36 28 pixel[i] = graphic[0].cmap[i].pixel; 37 29 } 38 30 back = graphic[0].back; 39 40 // define the color transform parameters41 MaxValue = graphic[0].Npixels - 1;42 if (image[0].range != 0.0) {43 slope = graphic[0].Npixels / image[0].range;44 start = graphic[0].Npixels * image[0].zero / image[0].range;45 } else {46 slope = 1.0;47 start = image[0].zero;48 }49 31 50 32 zoomscale = MAX (5, image[0].expand + 5); … … 55 37 dx = image[0].zoom.dx; 56 38 dy = image[0].zoom.dy; 57 DX = image[0].matrix.Naxis[0]; 58 DY = image[0].matrix.Naxis[1]; 39 DX = image[0].image[0].matrix.Naxis[0]; 40 DY = image[0].image[0].matrix.Naxis[1]; 41 42 /* Rx,Ry are the screen coordinates of the first image pixel */ 59 43 Rx = x - expand*(int)(0.5*(dx + 1)) + 1; 60 44 Ry = y - expand*(int)(0.5*(dy + 1)) + 1; … … 64 48 i_end = MAX (MIN ((DX-Rx) / expand, dx - expand_out + 1), 0); 65 49 j_end = MAX (MIN ((DY-Ry) / expand, dy - expand_out + 1), 0); 50 66 51 dropback = expand_out - (i_end - i_start) % expand_out; 67 52 if ((i_end - i_start) % expand_out == 0) dropback = 0; 68 53 69 54 out_pix = (unsigned int *) image[0].zoom.data; 70 imdata = (float *) image[0].matrix.buffer; 71 in_pix = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)]; 55 in_pix = &image[0].pixmap[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)]; 72 56 73 57 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 78 62 return; 79 63 } 80 64 81 65 82 66 /**** fill in bottom area ****/ 83 67 for (j = 0; j < dx*j_start; j++, out_pix++) { 84 out_pix[0]= back;68 *out_pix = back; 85 69 } 86 70 … … 88 72 89 73 /**** fill in area to the left of the picture ****/ 90 for (jj = 0; jj < expand_out; jj++) {74 for (jj = 0; (i_start > 0) && (jj < expand_out); jj++) { 91 75 out_pix2 = out_pix + jj*dx; 92 76 for (i = 0; i < i_start; i++, out_pix2++) { 93 out_pix[0]= back;77 *out_pix2 = back; 94 78 } 95 79 } … … 100 84 if (expand_out == 1) { 101 85 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) { 102 pixelN = PixelLookup(*in_pix2); 103 out_pix[0] = pixel[pixelN]; 86 *out_pix = pixel[*in_pix2]; 104 87 } 105 } 106 else { 88 } else { 107 89 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) { 108 pixelN = PixelLookup(*in_pix2); 109 pixvalue = pixel[pixelN]; 90 pixvalue = pixel[*in_pix2]; 110 91 out_pix2 = out_pix; 111 92 for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) { 112 93 for (ii = 0; ii < expand_out; ii++, out_pix2++) { 113 out_pix2[0]= pixvalue;94 *out_pix2 = pixvalue; 114 95 } 115 96 } … … 117 98 } 118 99 out_pix -= dropback; 119 120 100 121 101 /**** fill in area to the right of the picture ****/ … … 123 103 out_pix2 = out_pix + jj*dx; 124 104 for (i = i_end; i < dx; i++, out_pix2++) { 125 out_pix2[0]= back;105 *out_pix2 = back; 126 106 } 127 107 } … … 134 114 /**** fill in top area ****/ 135 115 for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned int *)image[0].zoom.data < dx*dy); j++, out_pix++) { 136 out_pix[0]= back;116 *out_pix = back; 137 117 } 138 118 139 out_pix = (unsigned int *)image[0].zoom.data;140 119 image[0].zoom.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, 141 120 image[0].zoom.data, image[0].zoom.dx, image[0].zoom.dy, 32, 0); 142 121 122 free (pixel); 143 123 } -
trunk/Ohana/src/kapa2/src/CreateZoom8.c
r14590 r16011 26 26 unsigned long back; 27 27 28 if (image[0]. matrix.size == 0) { /* create a test pattern */28 if (image[0].image[0].matrix.size == 0) { /* create a test pattern */ 29 29 REALLOCATE (image[0].zoom.data, char, image[0].zoom.dx*image[0].zoom.dy); 30 30 bzero (image[0].zoom.data, image[0].zoom.dx*image[0].zoom.dy); … … 41 41 // define the color transform parameters 42 42 MaxValue = graphic[0].Npixels - 1; 43 if (image[0]. range != 0.0) {44 slope = graphic[0].Npixels / image[0]. range;45 start = graphic[0].Npixels * image[0]. zero /image[0].range;43 if (image[0].image[0].range != 0.0) { 44 slope = graphic[0].Npixels / image[0].image[0].range; 45 start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range; 46 46 } else { 47 47 slope = 1.0; 48 start = image[0]. zero;48 start = image[0].image[0].zero; 49 49 } 50 50 … … 56 56 dx = image[0].zoom.dx; 57 57 dy = image[0].zoom.dy; 58 DX = image[0]. matrix.Naxis[0];59 DY = image[0]. matrix.Naxis[1];58 DX = image[0].image[0].matrix.Naxis[0]; 59 DY = image[0].image[0].matrix.Naxis[1]; 60 60 Rx = x - expand*(int)(0.5*(dx + 1)) + 1; 61 61 Ry = y - expand*(int)(0.5*(dy + 1)) + 1; … … 69 69 70 70 out_pix = (unsigned char *) image[0].zoom.data; 71 imdata = (float *) image[0]. matrix.buffer;71 imdata = (float *) image[0].image[0].matrix.buffer; 72 72 in_pix = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)]; 73 73 -
trunk/Ohana/src/kapa2/src/CursorOps.c
r13320 r16011 13 13 } 14 14 15 *x1 = expand*(x2 - image[0].picture.x - 0.5*image[0].picture.dx) + 0.5*image[0]. matrix.Naxis[0] - image[0].X;16 *y1 = expand*(y2 - image[0].picture.y - 0.5*image[0].picture.dy) + 0.5*image[0]. matrix.Naxis[1] - image[0].Y;15 *x1 = expand*(x2 - image[0].picture.x - 0.5*image[0].picture.dx) + 0.5*image[0].image[0].matrix.Naxis[0] - image[0].X; 16 *y1 = expand*(y2 - image[0].picture.y - 0.5*image[0].picture.dy) + 0.5*image[0].image[0].matrix.Naxis[1] - image[0].Y; 17 17 18 18 } … … 31 31 } 32 32 33 *x1 = (x2 - 0.5*image[0]. matrix.Naxis[0] + image[0].X) * expand + image[0].picture.x + 0.5*image[0].picture.dx;34 *y1 = (y2 - 0.5*image[0]. matrix.Naxis[1] + image[0].Y) * expand + image[0].picture.y + 0.5*image[0].picture.dy;33 *x1 = (x2 - 0.5*image[0].image[0].matrix.Naxis[0] + image[0].X) * expand + image[0].picture.x + 0.5*image[0].picture.dx; 34 *y1 = (y2 - 0.5*image[0].image[0].matrix.Naxis[1] + image[0].Y) * expand + image[0].picture.y + 0.5*image[0].picture.dy; 35 35 36 36 } -
trunk/Ohana/src/kapa2/src/DragColorbar.c
r13320 r16011 15 15 Y = mouse_event[0].y; 16 16 Npix = graphic[0].Npixels; 17 slope = image[0]. slope;18 start = image[0]. start;17 slope = image[0].image[0].slope; 18 start = image[0].image[0].start; 19 19 oldfrac_x = oldfrac_y = 10; 20 20 … … 63 63 case ButtonPress: 64 64 case ButtonRelease: 65 image[0]. start = start;66 image[0]. slope = slope;65 image[0].image[0].start = start; 66 image[0].image[0].slope = slope; 67 67 return; 68 68 break; -
trunk/Ohana/src/kapa2/src/Image.c
r13479 r16011 2 2 # include "buttons.h" 3 3 4 int InitImageChannel (KapaImageChannel *channel) { 5 6 /** set up a bunch of default things **/ 7 channel->zero = 0; 8 channel->range = 1; 9 channel->start = 0; 10 channel->slope = 1; 11 12 channel->coords.Npolyterms = 0; 13 channel->matrix.size = 0; /* a flag to show there is no data in the matrix */ 14 ALLOCATE (channel->matrix.buffer, char, 1); /* allocate so later free will not crash! */ 15 16 return (TRUE); 17 } 18 4 19 /* initialization for things not specific to X */ 5 KapaImageWidget *InitImage () {20 KapaImageWidget *InitImageWidget () { 6 21 7 22 int i; … … 14 29 memset (image, 0, sizeof(KapaImageWidget)); 15 30 16 /** set up a bunch of default things **/ 17 image[0].X = image[0].Y = 0; 18 image[0].expand = 1; 19 image[0].zero = 0; 20 image[0].range = 1; 21 image[0].start = 0; 22 image[0].slope = 1; 23 image[0].location = 4; 31 for (i = 0; i < NCHANNELS; i++) { 32 InitImageChannel (&image[0].channel[i]); 33 } 34 image[0].image = &image[0].channel[0]; 24 35 25 image[0].coords.Npolyterms = 0; 36 image[0].nPixels = 0; 37 ALLOCATE (image[0].pixmap, unsigned short, 1); /* allocate so later free will not crash! */ 38 39 // XXXX this has been moved to graphic, which may be wrong 40 // image[0].ColorScaleMode = KAPA_SCALE_1D; 41 26 42 for (i = 0; i < NOVERLAYS; i++) { 27 43 image[0].overlay[i].Nobjects = 0; … … 30 46 image[0].overlay[i].color = graphic[0].overlay_color[i]; 31 47 } 32 image[0].matrix.size = 0; /* a flag to show there is no data in the matrix */ 48 49 image[0].X = 0.0; 50 image[0].Y = 0.0; 51 image[0].expand = 1; 52 image[0].location = 4; 33 53 34 54 image[0].MovePointer = TRUE; 35 55 image[0].DecimalDegrees = TRUE; 36 ALLOCATE (image[0].matrix.buffer, char, 1); /* allocate so later free will not crash! */37 56 ALLOCATE (image[0].picture.data, char, 1); /* allocate so later free will not crash! */ 38 57 ALLOCATE (image[0].cmapbar.data, char, 1); /* allocate so later free will not crash! */ … … 48 67 InitButtonFunc (&image[0].rainbow_button, rainbow); 49 68 50 InitButtonSize (&image[0]. puns_button, puns_width, puns_height, puns_bits);51 InitButtonFunc (&image[0]. puns_button, puns);69 InitButtonSize (&image[0].heat_button, heat_width, heat_height, heat_bits); 70 InitButtonFunc (&image[0].heat_button, heat); 52 71 53 72 InitButtonSize (&image[0].recenter_button, recenter_width, recenter_height, recenter_bits); … … 131 150 DrawButton (graphic, &image[0].grey_button); 132 151 DrawButton (graphic, &image[0].rainbow_button); 133 DrawButton (graphic, &image[0]. puns_button);152 DrawButton (graphic, &image[0].heat_button); 134 153 DrawButton (graphic, &image[0].hms_button); 135 154 … … 152 171 free (image[0].overlay[i].objects); 153 172 } 154 free (image[0].matrix.buffer); 173 for (i = 0; i < NCHANNELS; i++) { 174 free (image[0].channel[i].matrix.buffer); 175 } 176 free (image[0].pixmap); 155 177 free (image[0].picture.data); 156 178 free (image[0].cmapbar.data); -
trunk/Ohana/src/kapa2/src/InterpretKeys.c
r14590 r16011 61 61 if (event[0].y > image[0].picture.y + image[0].picture.dy) goto skip_cursor; 62 62 Screen_to_Image (&X, &Y, (double)event[0].x, (double)event[0].y, image); 63 XY_to_RD (&R, &D, X, Y, &image[0]. coords);63 XY_to_RD (&R, &D, X, Y, &image[0].image[0].coords); 64 64 65 DX = image[0]. matrix.Naxis[0];66 DY = image[0]. matrix.Naxis[1];65 DX = image[0].image[0].matrix.Naxis[0]; 66 DY = image[0].image[0].matrix.Naxis[1]; 67 67 68 68 if (X < 0) goto off_image; … … 70 70 if (X >= DX) goto off_image; 71 71 if (Y >= DY) goto off_image; 72 imdata = (float *) image[0]. matrix.buffer;72 imdata = (float *) image[0].image[0].matrix.buffer; 73 73 Z = imdata[DX*(int)(Y) + (int)(X)]; 74 74 } … … 89 89 switch (keysym) { 90 90 91 case XK_F1: 92 image[0].image = &image[0].channel[0]; 93 Reorient (graphic, image, image[0].X, image[0].Y, 0); 94 break; 95 96 case XK_F2: 97 image[0].image = &image[0].channel[1]; 98 Reorient (graphic, image, image[0].X, image[0].Y, 0); 99 break; 100 101 case XK_F3: 102 image[0].image = &image[0].channel[2]; 103 Reorient (graphic, image, image[0].X, image[0].Y, 0); 104 break; 105 91 106 case XK_KP_Home: 92 107 case XK_Home: … … 103 118 case XK_Return: 104 119 Screen_to_Image (&X, &Y, (double)event[0].x, (double)event[0].y, image); 105 X = 0.5*image[0]. matrix.Naxis[0] - X;106 Y = 0.5*image[0]. matrix.Naxis[1] - Y;120 X = 0.5*image[0].image[0].matrix.Naxis[0] - X; 121 Y = 0.5*image[0].image[0].matrix.Naxis[1] - Y; 107 122 Reorient (graphic, image, X, Y, 0); 108 123 break; … … 132 147 break; 133 148 149 case XK_KP_Add: 150 image[0].image[0].zero += 0.1*image[0].image[0].range; 151 Reorient (graphic, image, image[0].X, image[0].Y, 0); 152 break; 153 case XK_KP_Subtract: 154 image[0].image[0].zero -= 0.1*image[0].image[0].range; 155 Reorient (graphic, image, image[0].X, image[0].Y, 0); 156 break; 157 134 158 case XK_Tab: 135 159 image[0].MovePointer = image[0].MovePointer ^ TRUE; -
trunk/Ohana/src/kapa2/src/InterpretPresses.c
r14590 r16011 36 36 Screen_to_Image (&X, &Y, (double)event[0].x, (double)event[0].y, image); 37 37 38 XY_to_RD (&R, &D, X, Y, &image[0]. coords);38 XY_to_RD (&R, &D, X, Y, &image[0].image[0].coords); 39 39 40 DX = image[0]. matrix.Naxis[0];41 DY = image[0]. matrix.Naxis[1];40 DX = image[0].image[0].matrix.Naxis[0]; 41 DY = image[0].image[0].matrix.Naxis[1]; 42 42 43 43 if (X < 0) goto off_image; … … 45 45 if (X >= DX) goto off_image; 46 46 if (Y >= DY) goto off_image; 47 imdata = (float *) image[0]. matrix.buffer;47 imdata = (float *) image[0].image[0].matrix.buffer; 48 48 Z = imdata[DX*(int)(Y) + (int)(X)]; 49 49 } … … 102 102 103 103 Screen_to_Image (&X, &Y, (double)mouse_event[0].x, (double)mouse_event[0].y, image); 104 X = 0.5*image[0]. matrix.Naxis[0] - X;105 Y = 0.5*image[0]. matrix.Naxis[1] - Y;104 X = 0.5*image[0].image[0].matrix.Naxis[0] - X; 105 Y = 0.5*image[0].image[0].matrix.Naxis[1] - Y; 106 106 107 107 switch (mouse_event[0].button) { -
trunk/Ohana/src/kapa2/src/JPEGit24.c
r14590 r16011 37 37 double expand, Rx, Ry, X, Y; 38 38 unsigned char *out_pix; 39 float *imdata,*in_pix, *in_pix_ref;40 unsigned char pixel1[256], pixel2[256], pixel3[256];39 unsigned short *in_pix, *in_pix_ref; 40 unsigned char *pixel1, *pixel2, *pixel3; 41 41 char filename[1024]; 42 42 FILE *f; … … 75 75 jpeg_start_compress (&cinfo, TRUE); 76 76 77 ALLOCATE (pixel1, unsigned char, graphic[0].Npixels); 78 ALLOCATE (pixel2, unsigned char, graphic[0].Npixels); 79 ALLOCATE (pixel3, unsigned char, graphic[0].Npixels); 80 77 81 /** cmap[i].pixel must be defined even if X is not used **/ 78 for (i = 0; i < 256; i++) { /* set up pixel array */82 for (i = 0; i < graphic[0].Npixels; i++) { /* set up pixel array */ 79 83 pixel1[i] = graphic[0].cmap[i].red >> 8; 80 84 pixel2[i] = graphic[0].cmap[i].green >> 8; 81 85 pixel3[i] = graphic[0].cmap[i].blue >> 8; 82 }83 84 // define the color transform parameters85 MaxValue = graphic[0].Npixels - 1;86 if (image[0].range != 0.0) {87 slope = graphic[0].Npixels / image[0].range;88 start = graphic[0].Npixels * image[0].zero / image[0].range;89 } else {90 slope = 1.0;91 start = image[0].zero;92 86 } 93 87 … … 108 102 dx = image[0].picture.dx; 109 103 dy = image[0].picture.dy; 110 DX = image[0]. matrix.Naxis[0];111 DY = image[0]. matrix.Naxis[1];104 DX = image[0].image[0].matrix.Naxis[0]; 105 DY = image[0].image[0].matrix.Naxis[1]; 112 106 113 107 /* X,Y are the image coordinates of the first image pixel */ … … 145 139 ALLOCATE (line_buffer, JSAMPLE, 3*dx); 146 140 147 imdata = (float *) image[0].matrix.buffer; 148 in_pix_ref = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)]; 141 in_pix_ref = &image[0].pixmap[DX*(int)MAX(Y,0) + (int)MAX(X,0)]; 149 142 150 143 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 177 170 /*** fill in the picture region ***/ 178 171 for (i = i_start; i < i_end; i+=expand_out, in_pix+=expand_in) { 179 pixelN = PixelLookup(*in_pix);180 172 for (ii = 0; ii < expand_out; ii++, out_pix+=3) { 181 out_pix[0] = pixel1[ pixelN];182 out_pix[1] = pixel2[ pixelN];183 out_pix[2] = pixel3[ pixelN];173 out_pix[0] = pixel1[*in_pix]; 174 out_pix[1] = pixel2[*in_pix]; 175 out_pix[2] = pixel3[*in_pix]; 184 176 } 185 177 } -
trunk/Ohana/src/kapa2/src/LoadOverlay.c
r15620 r16011 14 14 section = GetActiveSection(); 15 15 if (section->image == NULL) { 16 section->image = InitImage ();16 section->image = InitImageWidget (); 17 17 SetSectionSizes (section); 18 18 } -
trunk/Ohana/src/kapa2/src/LoadPicture.c
r15589 r16011 13 13 section = GetActiveSection(); 14 14 if (section->image == NULL) { 15 section->image = InitImage ();15 section->image = InitImageWidget (); 16 16 SetSectionSizes (section); 17 17 } … … 24 24 KiiScanMessage (sock, "%d %d %d %d %lf %lf", &header.Naxis[0], &header.Naxis[1]); 25 25 KiiScanMessage (sock, "%d %d %d %d %lf %lf", &header.bitpix, &header.unsign, &header.bzero, &header.bscale); 26 KiiScanMessage (sock, "%lf %lf %s %s", &image[0]. zero, &image[0].range, image[0].name,image[0].file);27 KiiScanMessage (sock, "%lf %lf %d", &image[0]. min, &image[0].max, &header.size);28 KiiScanMessage (sock, "%lf %f %f %f %f", &image[0]. coords.crval1, &image[0].coords.crpix1, &image[0].coords.cdelt1, &image[0].coords.pc1_1, &image[0].coords.pc1_2);29 KiiScanMessage (sock, "%lf %f %f %f %f", &image[0]. coords.crval2, &image[0].coords.crpix2, &image[0].coords.cdelt2, &image[0].coords.pc2_1, &image[0].coords.pc2_2);30 KiiScanMessage (sock, "%s", image[0]. coords.ctype);26 KiiScanMessage (sock, "%lf %lf %s %s", &image[0].image[0].zero, &image[0].image[0].range, image[0].image[0].name, image[0].image[0].file); 27 KiiScanMessage (sock, "%lf %lf %d", &image[0].image[0].min, &image[0].image[0].max, &header.size); 28 KiiScanMessage (sock, "%lf %f %f %f %f", &image[0].image[0].coords.crval1, &image[0].image[0].coords.crpix1, &image[0].image[0].coords.cdelt1, &image[0].image[0].coords.pc1_1, &image[0].image[0].coords.pc1_2); 29 KiiScanMessage (sock, "%lf %f %f %f %f", &image[0].image[0].coords.crval2, &image[0].image[0].coords.crpix2, &image[0].image[0].coords.cdelt2, &image[0].image[0].coords.pc2_1, &image[0].image[0].coords.pc2_2); 30 KiiScanMessage (sock, "%s", image[0].image[0].coords.ctype); 31 31 32 gfits_free_matrix (&image[0]. matrix);33 gfits_create_matrix (&header, &image[0]. matrix);32 gfits_free_matrix (&image[0].image[0].matrix); 33 gfits_create_matrix (&header, &image[0].image[0].matrix); 34 34 35 35 fcntl (sock, F_SETFL, O_NONBLOCK); 36 36 37 37 status = 1; 38 buff = image[0]. matrix.buffer;38 buff = image[0].image[0].matrix.buffer; 39 39 bytes_left = header.size; 40 image[0]. matrix.size = 0;40 image[0].image[0].matrix.size = 0; 41 41 while (bytes_left > 0) { 42 42 status = read (sock, buff, bytes_left); … … 46 46 } 47 47 if (status != -1) { /* pipe has data */ 48 image[0]. matrix.size += status;48 image[0].image[0].matrix.size += status; 49 49 bytes_left -= status; 50 50 buff = (char *)(buff + status); … … 54 54 fcntl (sock, F_SETFL, !O_NONBLOCK); 55 55 56 if (DEBUG) fprintf (stderr, "read %d bytes\n", image[0]. matrix.size);56 if (DEBUG) fprintf (stderr, "read %d bytes\n", image[0].image[0].matrix.size); 57 57 /* it it not obvious this condition should kill kii, but ... */ 58 if (image[0]. matrix.size != header.size) {59 fprintf (stderr, "error: expected %d bytes, but got only %d\n", header.size, image[0]. matrix.size);58 if (image[0].image[0].matrix.size != header.size) { 59 fprintf (stderr, "error: expected %d bytes, but got only %d\n", header.size, image[0].image[0].matrix.size); 60 60 return (FALSE); 61 61 } … … 63 63 if (!USE_XWINDOW) return (TRUE); 64 64 65 Remap (graphic, image, &image[0].matrix); 65 SetColorScale (graphic, image); 66 Remap (graphic, image); 66 67 if (DEBUG) fprintf (stderr, "remapped image\n"); 67 68 Refresh (); -
trunk/Ohana/src/kapa2/src/LoadTickmarks.c
r13479 r16011 11 11 section = GetActiveSection(); 12 12 if (section->image == NULL) { 13 section->image = InitImage ();13 section->image = InitImageWidget (); 14 14 SetSectionSizes (section); 15 15 } -
trunk/Ohana/src/kapa2/src/MakeColormap.c
r13320 r16011 1 1 # include "Ximage.h" 2 # define NPIXELS 643 2 4 3 static char default_cmap[] = "grayscale"; -
trunk/Ohana/src/kapa2/src/PSPixmap.c
r13331 r16011 13 13 /* start at the last line, print lines in decending order */ 14 14 buff = (unsigned char *)image[0].picture.data + image[0].picture.dx*(image[0].picture.dy - 1); 15 slope = image[0]. slope;16 start = image[0]. start;15 slope = image[0].image[0].slope; 16 start = image[0].image[0].start; 17 17 back = graphic[0].back; 18 18 … … 46 46 /* start at the last line, print lines in decending order */ 47 47 buff = (unsigned short *)image[0].picture.data + image[0].picture.dx*(image[0].picture.dy - 1); 48 slope = image[0]. slope;49 start = image[0]. start;48 slope = image[0].image[0].slope; 49 start = image[0].image[0].start; 50 50 back = graphic[0].back; 51 51 … … 83 83 /* start at the last line, print lines in decending order */ 84 84 buff = (unsigned char *)&image[0].picture.data[(dy - 1)*(3*dx + extra)]; 85 slope = image[0]. slope;86 start = image[0]. start;85 slope = image[0].image[0].slope; 86 start = image[0].image[0].start; 87 87 back = graphic[0].back; 88 88 … … 123 123 /* start at the last line, print lines in decending order */ 124 124 buff = (unsigned int *)image[0].picture.data + image[0].picture.dx*(image[0].picture.dy - 1); 125 slope = image[0]. slope;126 start = image[0]. start;125 slope = image[0].image[0].slope; 126 start = image[0].image[0].start; 127 127 back = graphic[0].back; 128 128 … … 143 143 return; 144 144 } 145 146 # if (0) 147 // XXX needs work! 148 void PSPixmap32_RGB (Graphic *graphic, KapaImageWidget *image, FILE *f) { 149 150 int i, k, m, val; 151 double Nchar, Npix, start, slope, frac; 152 unsigned int *buff; 153 unsigned long back; 154 unsigned char 155 156 ALLOCATE (pixelR, unsigned char, graphic[0].Npixels); 157 ALLOCATE (pixelG, unsigned char, graphic[0].Npixels); 158 ALLOCATE (pixelB, unsigned char, graphic[0].Npixels); 159 160 /** cmap[i].pixel must be defined even if X is not used **/ 161 for (i = 0; i < graphic[0].Npixels; i++) { /* set up pixel array */ 162 pixelR[i] = graphic[0].cmap[i].red >> 8; 163 pixelG[i] = graphic[0].cmap[i].green >> 8; 164 pixelB[i] = graphic[0].cmap[i].blue >> 8; 165 } 166 167 for (i = 0; i < image[0].picture.dy; i++) { 168 for (k = 0; k < image[0].picture.dx; k++, buff++) { 169 if (*buff == back) 170 val = Nchar; 171 else { 172 for (m = 0; (graphic[0].cmap[m].pixel != *buff) && (m < Npix); m++); 173 val = Nchar - frac * MIN (MAX (start + m * slope, 0), Npix); 174 } 175 fprintf (f, "%02x", val); 176 if (!((k+1) % 40)) fprintf (f, "\n"); 177 } 178 fprintf (f, "\n"); 179 buff -= 2*image[0].picture.dx; 180 } 181 return; 182 } 183 # endif -
trunk/Ohana/src/kapa2/src/Remap.c
r13320 r16011 1 1 # include "Ximage.h" 2 2 3 void Remap (Graphic *graphic, KapaImageWidget *image , Matrix *matrix) {3 void Remap (Graphic *graphic, KapaImageWidget *image) { 4 4 5 5 switch (graphic[0].Nbits) { 6 6 case 8: 7 Remap8 (graphic, image,matrix);7 Remap8 (graphic, image, &image->image->matrix); 8 8 break; 9 9 case 16: 10 Remap16 (graphic, image, matrix);10 Remap16 (graphic, image, &image->image->matrix); 11 11 break; 12 12 case 24: 13 Remap24 (graphic, image, matrix);13 Remap24 (graphic, image, &image->image->matrix); 14 14 break; 15 15 case 32: 16 Remap32 (graphic, image, matrix);16 Remap32 (graphic, image, &image->image->matrix); 17 17 break; 18 18 } -
trunk/Ohana/src/kapa2/src/Remap16.c
r13479 r16011 38 38 // define the color transform parameters 39 39 MaxValue = graphic[0].Npixels - 1; 40 if (image[0]. range != 0.0) {41 slope = graphic[0].Npixels / image[0]. range;42 start = graphic[0].Npixels * image[0]. zero /image[0].range;40 if (image[0].image[0].range != 0.0) { 41 slope = graphic[0].Npixels / image[0].image[0].range; 42 start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range; 43 43 } else { 44 44 slope = 1.0; 45 start = image[0]. zero;45 start = image[0].image[0].zero; 46 46 } 47 47 -
trunk/Ohana/src/kapa2/src/Remap24.c
r13479 r16011 40 40 // define the color transform parameters 41 41 MaxValue = graphic[0].Npixels - 1; 42 if (image[0]. range != 0.0) {43 slope = graphic[0].Npixels / image[0]. range;44 start = graphic[0].Npixels * image[0]. zero /image[0].range;42 if (image[0].image[0].range != 0.0) { 43 slope = graphic[0].Npixels / image[0].image[0].range; 44 start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range; 45 45 } else { 46 46 slope = 1.0; 47 start = image[0]. zero;47 start = image[0].image[0].zero; 48 48 } 49 49 -
trunk/Ohana/src/kapa2/src/Remap32.c
r13479 r16011 1 1 # include "Ximage.h" 2 3 static float slope = 1.0;4 static float start = 0.0;5 static int MaxValue = 255;6 7 // XXX inline this if needed8 static int PixelLookup(float value) {9 int out;10 out = MIN (MAX (slope * value - start, 0), MaxValue);11 return (out);12 }13 2 14 3 void Remap32 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) { … … 21 10 int expand_in, expand_out; 22 11 unsigned int *out_pix, *out_pix2; 23 float *imdata,*in_pix, *in_pix2;24 unsigned long pixel[256], pixvalue;12 unsigned short *in_pix, *in_pix2; 13 unsigned long *pixel, pixvalue; 25 14 unsigned long back; 26 15 16 ALLOCATE (pixel, unsigned long, graphic[0].Npixels); 17 27 18 // local array for pixel values 28 for (i = 0; i < 256; i++) {19 for (i = 0; i < graphic[0].Npixels; i++) { 29 20 pixel[i] = graphic[0].cmap[i].pixel; 30 21 } 31 22 back = graphic[0].back; 32 33 // define the color transform parameters34 MaxValue = graphic[0].Npixels - 1;35 if (image[0].range != 0.0) {36 slope = graphic[0].Npixels / image[0].range;37 start = graphic[0].Npixels * image[0].zero / image[0].range;38 } else {39 slope = 1.0;40 start = image[0].zero;41 }42 23 43 24 // set up expansions … … 61 42 DX = matrix[0].Naxis[0]; 62 43 DY = matrix[0].Naxis[1]; 44 63 45 /* X,Y are the image coordinates of the first image pixel */ 64 46 X = MAX(0.5*(DX - dx*expand) - image[0].X, 0); … … 92 74 93 75 out_pix = (unsigned int *) image[0].picture.data; 94 imdata = (float *) matrix[0].buffer; 95 in_pix = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)]; 76 in_pix = &image[0].pixmap[DX*(int)MAX(Y,0) + (int)MAX(X,0)]; 96 77 97 78 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ 98 79 99 80 /**** fill in bottom area ****/ 100 for (j = 0; j < dx*j_start; j++, out_pix++) 81 for (j = 0; j < dx*j_start; j++, out_pix++) { 101 82 *out_pix = back; 83 } 102 84 103 85 for (j = j_start; j < j_end; j+= expand_out, out_pix+=(expand_out-1)*dx, in_pix += expand_in*DX) { … … 116 98 if (expand_out == 1) { 117 99 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) { 118 pixelN = PixelLookup(*in_pix2); 119 *out_pix = pixel[pixelN]; 100 *out_pix = pixel[*in_pix2]; 120 101 } 121 } 122 else { 102 } else { 123 103 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) { 124 pixelN = PixelLookup(*in_pix2); 125 pixvalue = pixel[pixelN]; 104 pixvalue = pixel[*in_pix2]; 126 105 out_pix2 = out_pix; 127 106 for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) { … … 142 121 } 143 122 out_pix += (dx - i_end); 144 145 123 } 146 124 … … 152 130 *out_pix = back; 153 131 } 132 154 133 image[0].picture.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, 155 134 image[0].picture.data, image[0].picture.dx, image[0].picture.dy, 32, 0); 135 136 free (pixel); 156 137 } 157 -
trunk/Ohana/src/kapa2/src/Remap8.c
r13479 r16011 33 33 // define the color transform parameters 34 34 MaxValue = graphic[0].Npixels - 1; 35 if (image[0]. range != 0.0) {36 slope = graphic[0].Npixels / image[0]. range;37 start = graphic[0].Npixels * image[0]. zero /image[0].range;35 if (image[0].image[0].range != 0.0) { 36 slope = graphic[0].Npixels / image[0].image[0].range; 37 start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range; 38 38 } else { 39 39 slope = 1.0; 40 start = image[0]. zero;40 start = image[0].image[0].zero; 41 41 } 42 42 -
trunk/Ohana/src/kapa2/src/Reorient.c
r13320 r16011 4 4 5 5 if (image[0].expand == 0) image[0].expand = 1; 6 7 if ((image[0].X == X) && (image[0].Y == Y) && (mode == 0)) { 8 Refresh (); 9 XFlush (graphic[0].display); 10 return; 11 } 6 12 7 13 switch (mode) { … … 38 44 } 39 45 40 Remap (graphic, image , &image[0].matrix);46 Remap (graphic, image); 41 47 Refresh (); 42 48 -
trunk/Ohana/src/kapa2/src/SetColormap.c
r13320 r16011 1 1 # include "Ximage.h" 2 2 3 /*** this function uses only private colormaps. it should try the standard colormap 4 first to get better control over the smooth greyscales ***/ 3 # define SETVALUE(VAR,VALUE,MINVAL,MAXVAL) { \ 4 float tmp = (VALUE); \ 5 if (tmp < MINVAL) { \ 6 VAR = MINVAL; \ 7 } else if (tmp > MAXVAL) { \ 8 VAR = MAXVAL; \ 9 } else { \ 10 VAR = tmp; \ 11 } } 5 12 6 13 int SetColormap (char *name) { 7 14 8 int i; 15 int i, red, blue, green; 16 float scale, blueRef, redRef, greenRef; 9 17 Graphic *graphic; 10 18 11 19 graphic = GetGraphic(); 12 20 21 // the "fullcolor" colormap is uniquely defined for each image; 22 // defer to the 'SetColorScale' step 23 if (!strcasecmp (name, "fullcolor")) { 24 graphic[0].ColorScaleMode = KAPA_SCALE_3D_FULL; 25 return TRUE; 26 } 27 28 // very simple color model: evenly spaced cube 29 if (!strcasecmp (name, "ruffcolor")) { 30 graphic[0].nRed = pow (graphic[0].Npixels, 0.333); 31 graphic[0].nBlue = pow (graphic[0].Npixels, 0.333); 32 graphic[0].nGreen = graphic[0].Npixels / (graphic[0].nRed * graphic[0].nBlue); 33 34 // red,green,blue are values in range 0x0000 to 0xffff 35 float redScale = 0xffff / (graphic[0].nRed - 1); 36 float blueScale = 0xffff / (graphic[0].nBlue - 1); 37 float greenScale = 0xffff / (graphic[0].nGreen - 1); 38 39 i = 0; 40 for (red = 0; red < graphic[0].nRed; red++) { 41 for (blue = 0; blue < graphic[0].nBlue; blue++) { 42 for (green = 0; green < graphic[0].nGreen; green++, i++) { 43 SETVALUE (graphic[0].cmap[i].red, red*redScale, 0, 0xffff); 44 SETVALUE (graphic[0].cmap[i].blue, blue*blueScale, 0, 0xffff); 45 SETVALUE (graphic[0].cmap[i].green, green*greenScale, 0, 0xffff); 46 graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue; 47 } 48 } 49 } 50 51 // all other modes are 1D: set the flag: 52 graphic[0].ColorScaleMode = KAPA_SCALE_3D_RUFF; 53 goto store_colors; 54 } 55 56 // all other modes are 1D: set the flag: 57 graphic[0].ColorScaleMode = KAPA_SCALE_1D; 58 59 // red,green,blue are values in range 0x0000 to 0xffff 60 scale = 0xffff / (graphic[0].Npixels - 1); 61 13 62 /* greyscale */ 14 if ((!strc mp (name, "grayscale")) || (!strcmp (name, "greyscale"))) {63 if ((!strcasecmp (name, "grayscale")) || (!strcasecmp (name, "greyscale"))) { 15 64 for (i = 0; i < graphic[0].Npixels; i++) { 16 graphic[0].cmap[i].red = 256*(255 - 255*i/graphic[0].Npixels); 17 graphic[0].cmap[i].green = 256*(255 - 255*i/graphic[0].Npixels); 18 graphic[0].cmap[i].blue = 256*(255 - 255*i/graphic[0].Npixels); 65 SETVALUE (graphic[0].cmap[i].red, 0xffff - i*scale, 0, 0xffff); 66 SETVALUE (graphic[0].cmap[i].green, 0xffff - i*scale, 0, 0xffff); 67 SETVALUE (graphic[0].cmap[i].blue, 0xffff - i*scale, 0, 0xffff); 68 graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue; 69 } 70 goto store_colors; 71 } 72 /* -grayscale */ 73 if ((!strcasecmp (name, "-grayscale")) || (!strcasecmp (name, "-greyscale"))) { 74 for (i = 0; i < graphic[0].Npixels; i++) { 75 SETVALUE (graphic[0].cmap[i].red, i*scale, 0, 0xffff); 76 SETVALUE (graphic[0].cmap[i].green, i*scale, 0, 0xffff); 77 SETVALUE (graphic[0].cmap[i].blue, i*scale, 0, 0xffff); 19 78 graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue; 20 79 } … … 22 81 } 23 82 /* heat */ 24 if (!strcmp (name, "Puns")) { 83 if (!strcasecmp (name, "Heat")) { 84 greenRef = 0.25*graphic[0].Npixels*scale*2.0; 85 blueRef = 0.50*graphic[0].Npixels*scale*2.0; 25 86 for (i = 0; i < (int)(0.25*graphic[0].Npixels); i++) { 87 SETVALUE (graphic[0].cmap[i].red, 2*i*scale, 0, 0xffff); 26 88 graphic[0].cmap[i].green = 0; 27 graphic[0].cmap[i].blue = 0; 28 graphic[0].cmap[i].red = MIN (256*255, 256*255*2*i/(1.0*graphic[0].Npixels)); 89 graphic[0].cmap[i].blue = 0; 29 90 graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue; 30 91 } 31 for (i = (int)(0.25*graphic[0].Npixels); i < (int)(0.50*graphic[0].Npixels); i++) {32 graphic[0].cmap[i].red = MIN (256*255, 256*255*2*i/(1.0*graphic[0].Npixels));33 graphic[0].cmap[i].green = MIN (256*255, 256*255*2*(i/(1.0*graphic[0].Npixels) - 0.25));92 for (i = 0.25*graphic[0].Npixels; i < 0.50*graphic[0].Npixels; i++) { 93 SETVALUE (graphic[0].cmap[i].red, 2*i*scale, 0, 0xffff); 94 SETVALUE (graphic[0].cmap[i].green, 2*i*scale - greenRef, 0, 0xffff); 34 95 graphic[0].cmap[i].blue = 0; 35 96 graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue; 36 97 } 37 98 for (i = (int)(0.50*graphic[0].Npixels); i < (int)(0.75*graphic[0].Npixels); i++) { 38 graphic[0].cmap[i].red = 256*255;39 graphic[0].cmap[i].green = MIN (256*255, 256*255*2*(i/(1.0*graphic[0].Npixels) - 0.25));40 graphic[0].cmap[i].blue = MIN (256*255, 256*255*2*(i/(1.0*graphic[0].Npixels) - 0.50));99 graphic[0].cmap[i].red = 0xffff; 100 SETVALUE (graphic[0].cmap[i].green, 2*i*scale - greenRef, 0, 0xffff); 101 SETVALUE (graphic[0].cmap[i].blue, 2*i*scale - blueRef, 0, 0xffff); 41 102 graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue; 42 103 } 43 104 for (i = (int)(0.75*graphic[0].Npixels); i < graphic[0].Npixels; i++) { 44 graphic[0].cmap[i].red = 256*255; 45 graphic[0].cmap[i].green = 256*255; 46 graphic[0].cmap[i].blue = MIN (256*255, 256*255*2*(i/(1.0*graphic[0].Npixels) - 0.50)); 47 graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue; 48 } 49 goto store_colors; 50 } 51 /* -grayscale */ 52 if ((!strcmp (name, "-grayscale")) || (!strcmp (name, "-greyscale"))) { 53 for (i = 0; i < graphic[0].Npixels; i++) { 54 graphic[0].cmap[i].red = 256*(255*i/graphic[0].Npixels); 55 graphic[0].cmap[i].green = 256*(255*i/graphic[0].Npixels); 56 graphic[0].cmap[i].blue = 256*(255*i/graphic[0].Npixels); 105 graphic[0].cmap[i].red = 0xffff; 106 graphic[0].cmap[i].green = 0xffff; 107 SETVALUE (graphic[0].cmap[i].blue, 2*i*scale - blueRef, 0, 0xffff); 57 108 graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue; 58 109 } … … 60 111 } 61 112 /* rainbow */ 62 if (!strcmp (name, "Rainbow")) { 113 if (!strcasecmp (name, "Rainbow")) { 114 redRef = 0.25*graphic[0].Npixels*scale*4.0; 115 greenRef = 0.50*graphic[0].Npixels*scale*4.0; 116 blueRef = 0.50*graphic[0].Npixels*scale*4.0; 63 117 for (i = 0; i < (int)(0.25*graphic[0].Npixels); i++) { 64 graphic[0].cmap[i].red = 0;118 graphic[0].cmap[i].red = 0; 65 119 graphic[0].cmap[i].green = 0; 66 graphic[0].cmap[i].blue = 256*(255*4*(i/(1.0*graphic[0].Npixels)));120 SETVALUE (graphic[0].cmap[i].blue, 4*i*scale, 0, 0xffff); 67 121 graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue; 68 122 } 69 123 for (i = (int)(0.25*graphic[0].Npixels); i < (int)(0.50*graphic[0].Npixels); i++) { 70 graphic[0].cmap[i].red = 256*(255*4*((i/(1.0*graphic[0].Npixels)) - 0.25));124 SETVALUE (graphic[0].cmap[i].red, 4*i*scale - redRef, 0, 0xffff); 71 125 graphic[0].cmap[i].green = 0; 72 graphic[0].cmap[i].blue = 256*(255*4*(0.50 - (i/(1.0*graphic[0].Npixels))));126 SETVALUE (graphic[0].cmap[i].blue, blueRef - 4*i*scale, 0, 0xffff); 73 127 graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue; 74 128 } 75 129 for (i = (int)(0.50*graphic[0].Npixels); i < (int)(0.75*graphic[0].Npixels); i++) { 76 graphic[0].cmap[i].red = 256*255;77 graphic[0].cmap[i].green = 256*(255*4*((i/(1.0*graphic[0].Npixels)) - 0.50));130 graphic[0].cmap[i].red = 0xffff; 131 SETVALUE (graphic[0].cmap[i].green, 4*i*scale - greenRef, 0, 0xffff); 78 132 graphic[0].cmap[i].blue = 0; 79 133 graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue; 80 134 } 135 blueRef = 0.75*graphic[0].Npixels*scale*4.0; 81 136 for (i = (int)(0.75*graphic[0].Npixels); i < graphic[0].Npixels; i++) { 82 graphic[0].cmap[i].red = 256*255;83 graphic[0].cmap[i].green = 256*255;84 graphic[0].cmap[i].blue = 256*(255*4*((i/(1.0*graphic[0].Npixels)) - 0.75));137 graphic[0].cmap[i].red = 0xffff; 138 graphic[0].cmap[i].green = 0xffff; 139 SETVALUE (graphic[0].cmap[i].blue, 4*i*scale - blueRef, 0, 0xffff); 85 140 graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue; 86 141 } -
trunk/Ohana/src/kapa2/src/SetGraphSize.c
r13479 r16011 41 41 // if we are tied to an image, make mods as needed 42 42 if (section->image) { 43 textpad = graphic[0].font[0].ascent;43 textpad = USE_XWINDOW ? graphic[0].font[0].ascent : 10; 44 44 textdY = 6*textpad + 7*PAD1; 45 45 WdY = MAX (ZOOM_Y, textdY + 2*BUTTON_HEIGHT + PAD1); -
trunk/Ohana/src/kapa2/src/SetImageData.c
r14590 r16011 11 11 section = GetActiveSection(); 12 12 if (section->image == NULL) { 13 section->image = InitImage ();13 section->image = InitImageWidget (); 14 14 SetSectionSizes (section); 15 15 } … … 18 18 // get image data from client 19 19 KiiScanMessage (sock, "%lf %lf %s", 20 &image[0]. zero,21 &image[0]. range,22 image[0]. name,23 image[0]. file);20 &image[0].image[0].zero, 21 &image[0].image[0].range, 22 image[0].image[0].name, 23 image[0].image[0].file); 24 24 25 25 // XXX when we go to 32bit, this should remap the image … … 37 37 section = GetActiveSection(); 38 38 if (section->image == NULL) { 39 section->image = InitImage ();39 section->image = InitImageWidget (); 40 40 SetSectionSizes (section); 41 41 } … … 43 43 44 44 KiiSendMessage (sock, "%g %g %s %s", 45 image[0]. zero,46 image[0]. range,47 image[0]. name,48 image[0]. file);45 image[0].image[0].zero, 46 image[0].image[0].range, 47 image[0].image[0].name, 48 image[0].image[0].file); 49 49 50 50 return (TRUE); … … 61 61 section = GetActiveSection(); 62 62 if (section->image == NULL) { 63 section->image = InitImage ();63 section->image = InitImageWidget (); 64 64 SetSectionSizes (section); 65 65 } … … 67 67 68 68 KiiScanMessage (sock, "%f %f %f %f", 69 &image[0]. coords.pc1_1, &image[0].coords.pc2_2,70 &image[0]. coords.pc1_2, &image[0].coords.pc2_1);69 &image[0].image[0].coords.pc1_1, &image[0].image[0].coords.pc2_2, 70 &image[0].image[0].coords.pc1_2, &image[0].image[0].coords.pc2_1); 71 71 72 KiiScanMessage (sock, "%s", image[0]. coords.ctype);72 KiiScanMessage (sock, "%s", image[0].image[0].coords.ctype); 73 73 74 74 KiiScanMessage (sock, "%lf %lf %f %f %f %f", 75 &image[0]. coords.crval1,76 &image[0]. coords.crval2,77 &image[0]. coords.crpix1,78 &image[0]. coords.crpix2,79 &image[0]. coords.cdelt1,80 &image[0]. coords.cdelt2);75 &image[0].image[0].coords.crval1, 76 &image[0].image[0].coords.crval2, 77 &image[0].image[0].coords.crpix1, 78 &image[0].image[0].coords.crpix2, 79 &image[0].image[0].coords.cdelt1, 80 &image[0].image[0].coords.cdelt2); 81 81 82 82 return (TRUE); … … 90 90 section = GetActiveSection(); 91 91 if (section->image == NULL) { 92 section->image = InitImage ();92 section->image = InitImageWidget (); 93 93 SetSectionSizes (section); 94 94 } … … 96 96 97 97 KiiSendMessage (sock, "%g %g %g %g", 98 image[0]. coords.pc1_1,image[0].coords.pc2_2,99 image[0]. coords.pc1_2,image[0].coords.pc2_1);98 image[0].image[0].coords.pc1_1, image[0].image[0].coords.pc2_2, 99 image[0].image[0].coords.pc1_2, image[0].image[0].coords.pc2_1); 100 100 101 KiiSendMessage (sock, "%s", image[0]. coords.ctype);101 KiiSendMessage (sock, "%s", image[0].image[0].coords.ctype); 102 102 103 103 KiiSendMessage (sock, "%g %g %g %g %g %g", 104 image[0]. coords.crval1,105 image[0]. coords.crval2,106 image[0]. coords.crpix1,107 image[0]. coords.crpix2,108 image[0]. coords.cdelt1,109 image[0]. coords.cdelt2);104 image[0].image[0].coords.crval1, 105 image[0].image[0].coords.crval2, 106 image[0].image[0].coords.crpix1, 107 image[0].image[0].coords.crpix2, 108 image[0].image[0].coords.cdelt1, 109 image[0].image[0].coords.cdelt2); 110 110 111 111 return (TRUE); … … 120 120 section = GetActiveSection(); 121 121 if (section->image == NULL) { 122 section->image = InitImage ();122 section->image = InitImageWidget (); 123 123 SetSectionSizes (section); 124 124 } -
trunk/Ohana/src/kapa2/src/SetImageSize.c
r14590 r16011 40 40 } 41 41 if (USE_XWINDOW) CreatePicture (image, graphic); 42 Remap (graphic, image , &image[0].matrix);42 Remap (graphic, image); 43 43 return; 44 44 45 45 case 1: 46 textpad = graphic[0].font[0].ascent;46 textpad = USE_XWINDOW ? graphic[0].font[0].ascent : 10; 47 47 textdY = 6*textpad + 7*PAD1; 48 48 WdY = MAX (ZOOM_Y, textdY + 2*BUTTON_HEIGHT + PAD1); … … 104 104 image[0].rainbow_button.y = image[0].PS_button.y; 105 105 106 image[0]. puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;107 image[0]. puns_button.y = image[0].PS_button.y;108 109 image[0].recenter_button.x = image[0]. puns_button.x + image[0].puns_button.dx + PAD1;106 image[0].heat_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1; 107 image[0].heat_button.y = image[0].PS_button.y; 108 109 image[0].recenter_button.x = image[0].heat_button.x + image[0].heat_button.dx + PAD1; 110 110 image[0].recenter_button.y = image[0].PS_button.y; 111 111 break; 112 112 113 113 case 3: 114 textpad = graphic[0].font[0].ascent;114 textpad = USE_XWINDOW ? graphic[0].font[0].ascent : 10; 115 115 textdY = 6*textpad + 7*PAD1; 116 116 WdY = MAX (ZOOM_Y, textdY + 2*BUTTON_HEIGHT + PAD1); … … 172 172 image[0].rainbow_button.y = image[0].PS_button.y; 173 173 174 image[0]. puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;175 image[0]. puns_button.y = image[0].PS_button.y;176 177 image[0].recenter_button.x = image[0]. puns_button.x + image[0].puns_button.dx + PAD1;174 image[0].heat_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1; 175 image[0].heat_button.y = image[0].PS_button.y; 176 177 image[0].recenter_button.x = image[0].heat_button.x + image[0].heat_button.dx + PAD1; 178 178 image[0].recenter_button.y = image[0].PS_button.y; 179 179 break; … … 206 206 207 207 /** everything below is tied in x-dir to the zoom box **/ 208 textpad = graphic[0].font[0].ascent;208 textpad = USE_XWINDOW ? graphic[0].font[0].ascent : 10; 209 209 image[0].text_x = image[0].zoom.x; 210 210 image[0].text_y = image[0].zoom.y + image[0].zoom.dy + PAD1; … … 238 238 image[0].rainbow_button.y = image[0].PS_button.y; 239 239 240 image[0]. puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;241 image[0]. puns_button.y = image[0].PS_button.y;242 243 image[0].recenter_button.x = image[0]. puns_button.x + image[0].puns_button.dx + PAD1;240 image[0].heat_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1; 241 image[0].heat_button.y = image[0].PS_button.y; 242 243 image[0].recenter_button.x = image[0].heat_button.x + image[0].heat_button.dx + PAD1; 244 244 image[0].recenter_button.y = image[0].PS_button.y; 245 245 break; … … 272 272 273 273 /** everything below is tied in x-dir to the zoom box **/ 274 textpad = graphic[0].font[0].ascent;274 textpad = USE_XWINDOW ? graphic[0].font[0].ascent : 10; 275 275 image[0].text_x = image[0].zoom.x; 276 276 image[0].text_y = image[0].zoom.y + image[0].zoom.dy + PAD1; … … 304 304 image[0].rainbow_button.y = image[0].PS_button.y; 305 305 306 image[0]. puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;307 image[0]. puns_button.y = image[0].PS_button.y;308 309 image[0].recenter_button.x = image[0]. puns_button.x + image[0].puns_button.dx + PAD1;306 image[0].heat_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1; 307 image[0].heat_button.y = image[0].PS_button.y; 308 309 image[0].recenter_button.x = image[0].heat_button.x + image[0].heat_button.dx + PAD1; 310 310 image[0].recenter_button.y = image[0].PS_button.y; 311 311 break; … … 321 321 CreateZoom (image, graphic, 0, 0); 322 322 } 323 Remap (graphic, image , &image[0].matrix);323 Remap (graphic, image); 324 324 325 325 return; -
trunk/Ohana/src/kapa2/src/SetToolbox.c
r13479 r16011 17 17 section = GetActiveSection(); 18 18 if (section->image == NULL) { 19 section->image = InitImage ();19 section->image = InitImageWidget (); 20 20 } 21 21 section->image->location = location; … … 24 24 if (!USE_XWINDOW) return; 25 25 26 Remap (graphic, section->image , §ion->image->matrix);26 Remap (graphic, section->image); 27 27 if (DEBUG) fprintf (stderr, "remapped image\n"); 28 28 Refresh (); -
trunk/Ohana/src/kapa2/src/SetUpGraphic.c
r13320 r16011 17 17 graphic->dy = 512; 18 18 19 if (!USE_XWINDOW) return; 19 if (!USE_XWINDOW) { 20 ALLOCATE (graphic[0].pixels, unsigned long, NPIXELS_STATIC); 21 ALLOCATE (graphic[0].cmap, XColor, NPIXELS_STATIC); 22 graphic[0].Npixels = NPIXELS_STATIC; 23 return; 24 } 20 25 21 26 name = CheckDisplayName (argc, argv); -
trunk/Ohana/src/kapa2/src/StatusBox.c
r13320 r16011 6 6 7 7 if (image[0].MovePointer) { 8 x = 0.5*image[0]. matrix.Naxis[0];9 y = 0.5*image[0]. matrix.Naxis[1];8 x = 0.5*image[0].image[0].matrix.Naxis[0]; 9 y = 0.5*image[0].image[0].matrix.Naxis[1]; 10 10 z = -1; 11 11 image[0].x = x; -
trunk/Ohana/src/kapa2/src/UpdatePointer.c
r13479 r16011 19 19 if (image[0].MovePointer && InPicture ((XButtonEvent *)event, &image[0].picture)) { 20 20 21 data = (float *) image[0]. matrix.buffer;21 data = (float *) image[0].image[0].matrix.buffer; 22 22 Screen_to_Image (&x, &y, (double)event[0].x, (double)event[0].y, image); 23 23 24 24 z = -1; 25 25 if (x < 0) goto skip; 26 if (x >= image[0]. matrix.Naxis[0]) goto skip;26 if (x >= image[0].image[0].matrix.Naxis[0]) goto skip; 27 27 if (y < 0) goto skip; 28 if (y >= image[0]. matrix.Naxis[1]) goto skip;29 z = data[(int)(y)*image[0]. matrix.Naxis[0] + (int)(x)];28 if (y >= image[0].image[0].matrix.Naxis[1]) goto skip; 29 z = data[(int)(y)*image[0].image[0].matrix.Naxis[0] + (int)(x)]; 30 30 31 31 skip: … … 47 47 48 48 if (InPicture ((XButtonEvent *)event, &image[0].cmapbar)) { 49 z = image[0]. zero +image[0].range * (event[0].x - image[0].cmapbar.x) / image[0].cmapbar.dx;49 z = image[0].image[0].zero + image[0].image[0].range * (event[0].x - image[0].cmapbar.x) / image[0].cmapbar.dx; 50 50 textpad = graphic[0].font[0].ascent; 51 51 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back); -
trunk/Ohana/src/kapa2/src/UpdateStatusBox.c
r14498 r16011 7 7 char line[100]; 8 8 9 XY_to_RD (&ra, &dec, x, y, &image[0]. coords);9 XY_to_RD (&ra, &dec, x, y, &image[0].image[0].coords); 10 10 11 11 textpad = graphic[0].font[0].ascent; … … 26 26 27 27 bzero (line, 100); 28 sprintf (line, "%-25s", image[0]. file);28 sprintf (line, "%-25s", image[0].image[0].file); 29 29 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 30 30 image[0].text_x + PAD1, image[0].text_y + 5*textpad + 5*PAD1, line, strlen(line)); 31 31 32 32 bzero (line, 100); 33 sprintf (line, "(%s) ", image[0]. name);33 sprintf (line, "(%s) ", image[0].image[0].name); 34 34 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 35 35 image[0].text_x + PAD1, image[0].text_y + 6*textpad + 6*PAD1, line, 25);
Note:
See TracChangeset
for help on using the changeset viewer.
