Changeset 24800
- Timestamp:
- Jul 15, 2009, 10:01:33 AM (17 years ago)
- Location:
- branches/eam_branches/20090715/Ohana/src/kapa2
- Files:
-
- 7 edited
-
include/constants.h (modified) (1 diff)
-
include/structures.h (modified) (1 diff)
-
src/CheckVisual.c (modified) (12 diffs)
-
src/DragColorbar.c (modified) (5 diffs)
-
src/MakeColormap.c (modified) (1 diff)
-
src/SetColorScale.c (modified) (1 diff)
-
src/SetColormap.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090715/Ohana/src/kapa2/include/constants.h
r16011 r24800 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 -
branches/eam_branches/20090715/Ohana/src/kapa2/include/structures.h
r21153 r24800 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; -
branches/eam_branches/20090715/Ohana/src/kapa2/src/CheckVisual.c
r21153 r24800 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: DirectColor 40 for (i = 0; (i < Nfound) && (visual_list[i].class != DirectColor); i++); 41 if (i != Nfound) { 42 isColor = TRUE; 43 if (DEBUG) fprintf (stderr, "visual class is %d\n", visual_list[i].class); 44 isDefault = (graphic[0].visual == visual_list[i].visual); 45 graphic[0].visual = visual_list[i].visual; 46 graphic[0].dynamicColors = TRUE; 47 if (DEBUG) fprintf (stderr, "got DirectColor visual\n"); 48 goto test_pixels; 49 } 50 51 // attempt to select the most desirable type of visual: TrueColor 61 52 for (i = 0; (i < Nfound) && (visual_list[i].class != TrueColor); i++); 62 53 if (i != Nfound) { … … 65 56 isDefault = (graphic[0].visual == visual_list[i].visual); 66 57 graphic[0].visual = visual_list[i].visual; 67 graphic[0].visualclass = FALSE; 58 graphic[0].dynamicColors = FALSE; 59 if (DEBUG) fprintf (stderr, "got TrueColor 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); -
branches/eam_branches/20090715/Ohana/src/kapa2/src/DragColorbar.c
r16011 r24800 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 } -
branches/eam_branches/20090715/Ohana/src/kapa2/src/MakeColormap.c
r16011 r24800 1 1 # include "Ximage.h" 2 2 3 static char default_cmap[] = "grayscale"; 3 // static char default_cmap[] = "grayscale"; 4 static char default_cmap[] = "heat"; 4 5 5 6 void MakeColormap (int argc, char **argv) { -
branches/eam_branches/20090715/Ohana/src/kapa2/src/SetColorScale.c
r16061 r24800 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 { -
branches/eam_branches/20090715/Ohana/src/kapa2/src/SetColormap.c
r16039 r24800 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 }
Note:
See TracChangeset
for help on using the changeset viewer.
