diff --git a/Common/ColorTable.cpp b/Common/ColorTable.cpp index 3eea7cf48f635b2e4c46cc2c0ccac4126a67196f..2eba886d7ca249474a789dfe663cfd91cbbe778b 100644 --- a/Common/ColorTable.cpp +++ b/Common/ColorTable.cpp @@ -1,4 +1,4 @@ -// $Id: ColorTable.cpp,v 1.23 2004-07-08 18:57:29 geuzaine Exp $ +// $Id: ColorTable.cpp,v 1.24 2004-12-23 22:26:34 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -34,7 +34,7 @@ extern Context_T CTX; -void ColorTable_InitParam(int number, GmshColorTable * ct) +void ColorTable_InitParam(int number, double alpha, GmshColorTable * ct) { ct->size = 255; ct->ipar[COLORTABLE_MODE] = COLORTABLE_RGB; @@ -43,35 +43,57 @@ void ColorTable_InitParam(int number, GmshColorTable * ct) ct->ipar[COLORTABLE_SWAP] = 0; ct->ipar[COLORTABLE_ROTATE] = 0; - ct->fpar[COLORTABLE_CURVE] = 0.0; - ct->fpar[COLORTABLE_BIAS] = 0.0; - ct->fpar[COLORTABLE_BETA] = 0.0; - ct->fpar[COLORTABLE_ALPHAPOW] = 1.; - ct->fpar[COLORTABLE_ALPHAVAL] = 255.; + ct->dpar[COLORTABLE_CURVE] = 0.0; + ct->dpar[COLORTABLE_BIAS] = 0.0; + ct->dpar[COLORTABLE_BETA] = 0.0; + ct->dpar[COLORTABLE_ALPHAVAL] = alpha; +} + +static double gray(double s) +{ + return s < 0. ? 0. : (s < 1. ? s : 1.); +} + +static double hot_r(double s) +{ + return s < 0. ? 0. : (s < 3./8. ? 8./3. * s : 1.); +} + +static double hot_g(double s) +{ + return s < 3./8. ? 0. : (s < 6./8. ? 8./3. * (s - 3./8.) : 1.); +} + +static double hot_b(double s) +{ + return s < 6./8. ? 0. : (s < 1. ? 8./2. * (s - 6./8.) : 1.); +} + +static double cubic(double a, double b, double c, double d, double x) +{ + return a + b * x + c * x * x + d * x * x * x; } void ColorTable_Recompute(GmshColorTable * ct) { - float curve, bias; - double gamma; + double curve, bias, s, t, gamma; int i, r, g, b, a, rotate; - float s, t; ct->ipar[COLORTABLE_CHANGED] = 1; - bias = ct->fpar[COLORTABLE_BIAS]; - curve = ct->fpar[COLORTABLE_CURVE]; + bias = ct->dpar[COLORTABLE_BIAS]; + curve = ct->dpar[COLORTABLE_CURVE]; rotate = ct->ipar[COLORTABLE_ROTATE]; for(i = 0; i < ct->size; i++) { if(ct->size > 1) { if(i + rotate < 0) - s = (float)(i + rotate + ct->size) / (float)(ct->size - 1); + s = (double)(i + rotate + ct->size) / (double)(ct->size - 1); else if(i + rotate > ct->size - 1) - s = (float)(i + rotate - ct->size) / (float)(ct->size - 1); + s = (double)(i + rotate - ct->size) / (double)(ct->size - 1); else - s = (float)(i + rotate) / (float)(ct->size - 1); + s = (double)(i + rotate) / (double)(ct->size - 1); } else s = 0.; @@ -86,8 +108,33 @@ void ColorTable_Recompute(GmshColorTable * ct) g = (int)(128.0 + 127.0 * (2 * exp(-7 * t * t) - 1)); b = (int)(128.0 + 127.0 * atan(-7.0 * t) / 1.57); break; - case 2: // samcef - if(s - bias <= 0.00) { + case 2: // matlab "jet" + { + double ii = (double)(s-bias)*128.; + if(ii < 0) ii = 0; + if(ii > 128) ii = 128; + double rr = + ii <= 46 ? 0. : + ii >= 111 ? -0.03125*(ii - 111) + 1. : + ii >= 78 ? 1. : + 0.03125*(ii - 46); + double gg = + ii <= 14 || ii >= 111 ? 0. : + ii >= 79 ? -0.03125*(ii - 111) : + ii <= 46 ? 0.03125*(ii - 14) : + 1.; + double bb = + ii >= 79 ? 0. : + ii >= 47 ? -0.03125*(ii - 79) : + ii <= 14 ? 0.03125*(ii - 14) + 1.: + 1.; + r = (int)(rr*255.); + g = (int)(gg*255.); + b = (int)(bb*255.); + } + break; + case 3: // samcef + if(s - bias <= 0.) { r = 0; g = 0; b = 255; @@ -102,7 +149,7 @@ void ColorTable_Recompute(GmshColorTable * ct) g = 255; b = 0; } - else if(s - bias <= 1.00) { + else if(s - bias <= 1.) { r = 255; g = (int)(255. - 637.5 * (s - bias - 0.6)); b = 0; @@ -113,8 +160,8 @@ void ColorTable_Recompute(GmshColorTable * ct) b = 0; } break; - case 3: // rainbow (matlab, etc.) - if(s - bias <= 0.00) { + case 4: // rainbow + if(s - bias <= 0.) { r = 0; g = 0; b = 255; @@ -138,7 +185,7 @@ void ColorTable_Recompute(GmshColorTable * ct) g = 255; b = 0; } - else if(s - bias <= 1.00) { + else if(s - bias <= 1.) { curve = (curve == -0.25) ? -0.26 : curve; r = 255; g = @@ -151,37 +198,8 @@ void ColorTable_Recompute(GmshColorTable * ct) b = 0; } break; - case 4: // darkblue-red-yellow-white -#define myfct(a,b,c,d) ((a)+ \ - (b)*(s-bias)+ \ - (c)*(s-bias)*(s-bias)+ \ - (d)*(s-bias)*(s-bias)*(s-bias)) -#define clamp(x) x = (x)<0?0:((x)>255?255:(x)) - r = (int)(255. * myfct(-0.0506169, 2.81633, -1.87033, 0.0524573)); - g = (int)(255. * myfct(0.0485868, -1.26109, 6.3074, -4.12498)); - b = (int)(255. * myfct(0.364662, 1.50814, -7.36756, 6.51847)); - clamp(r); - clamp(g); - clamp(b); -#undef myfct -#undef clamp - break; - case 5: // grayscale - if(s - bias <= 0.00) { - r = g = b = 0; - } - else if(s - bias <= 1.00) { - r = g = b = (int)(255 * (s - bias)); - } - else { - r = g = b = 255; - } - break; - case 6: // monochrome - r = g = b = 0; - break; - case 7: // rainbow modified to add black and white , from EMC2000 - if(s - bias <= 0.00) { + case 5: // emc2000 (rainbow with black and white) + if(s - bias <= 0.) { r = 0; g = 0; b = 0; @@ -214,9 +232,7 @@ void ColorTable_Recompute(GmshColorTable * ct) else if(s - bias <= 1.0) { r = 255; g = (int)((255. / 0.2) * (s - bias - 0.8)); - b = - (int)(-3187.66 * (s - bias) * (s - bias) + 7012.76 * (s - bias) - - 3570.61); + b = (int)(-3187.66 * (s - bias) * (s - bias) + 7012.76 * (s - bias) - 3570.61); } else { r = 255; @@ -224,25 +240,51 @@ void ColorTable_Recompute(GmshColorTable * ct) b = 255; } break; - case 8: // grayscale, without white - default: - if(s - bias <= 0.00) { + case 6: // darkblue->red->yellow->white + r = (int)(255. * cubic(-0.0506169, 2.81633, -1.87033, 0.0524573, s-bias)); + g = (int)(255. * cubic(0.0485868, -1.26109, 6.3074, -4.12498, s-bias)); + b = (int)(255. * cubic(0.364662, 1.50814, -7.36756, 6.51847, s-bias)); + break; + case 7: // matlab "hot" + r = (int)(255. * hot_r(s-bias)); + g = (int)(255. * hot_g(s-bias)); + b = (int)(255. * hot_b(s-bias)); + break; + case 8: // matlab "pink" + r = (int)(255. * sqrt((2.*gray(s-bias) + hot_r(s-bias))/3.)); + g = (int)(255. * sqrt((2.*gray(s-bias) + hot_g(s-bias))/3.)); + b = (int)(255. * sqrt((2.*gray(s-bias) + hot_b(s-bias))/3.)); + break; + case 9: // grayscale + if(s - bias <= 0.) { r = g = b = 0; } - else if(s - bias <= 1.00) { - r = g = b = (int)(220 * (s - bias)); + else if(s - bias <= 1.) { + r = g = b = (int)(255 * (1. - curve) * (s - bias)); } else { - r = g = b = 220; + r = g = b = (int)(255 * (1. - curve)); } break; + case 0: // all black + default: + r = g = b = 0; + break; } + + a = (int)(255. * ct->dpar[COLORTABLE_ALPHAVAL]); + + // clamp to [0,255] + r = r < 0 ? 0 : (r > 255 ? 255 : r); + g = g < 0 ? 0 : (g > 255 ? 255 : g); + b = b < 0 ? 0 : (b > 255 ? 255 : b); + a = a < 0 ? 0 : (a > 255 ? 255 : a); - if(ct->fpar[COLORTABLE_BETA]) { - if(ct->fpar[COLORTABLE_BETA] > 0.0) - gamma = 1. - ct->fpar[COLORTABLE_BETA]; + if(ct->dpar[COLORTABLE_BETA]) { + if(ct->dpar[COLORTABLE_BETA] > 0.0) + gamma = 1. - ct->dpar[COLORTABLE_BETA]; else - gamma = 1. / (1.001 + ct->fpar[COLORTABLE_BETA]); // beta is thresholded to [-1,1] + gamma = 1. / (1.001 + ct->dpar[COLORTABLE_BETA]); // beta is thresholded to [-1,1] r = (int)(255. * pow((double)r / 255., gamma)); g = (int)(255. * pow((double)g / 255., gamma)); b = (int)(255. * pow((double)b / 255., gamma)); @@ -254,9 +296,6 @@ void ColorTable_Recompute(GmshColorTable * ct) b = 255 - b; } - a = (int)(ct->fpar[COLORTABLE_ALPHAVAL] * - ct->fpar[COLORTABLE_ALPHAPOW]); - ct->table[i] = PACK_COLOR(r, g, b, a); } @@ -269,7 +308,7 @@ void ColorTable_Copy(GmshColorTable * ct) clip.size = ct->size; memcpy(clip.table, ct->table, ct->size * sizeof(unsigned int)); memcpy(clip.ipar, ct->ipar, COLORTABLE_NBMAX_PARAM * sizeof(int)); - memcpy(clip.fpar, ct->fpar, COLORTABLE_NBMAX_PARAM * sizeof(float)); + memcpy(clip.dpar, ct->dpar, COLORTABLE_NBMAX_PARAM * sizeof(double)); } void ColorTable_Paste(GmshColorTable * ct) @@ -277,7 +316,7 @@ void ColorTable_Paste(GmshColorTable * ct) ct->size = clip.size; memcpy(ct->table, clip.table, clip.size * sizeof(unsigned int)); memcpy(ct->ipar, clip.ipar, COLORTABLE_NBMAX_PARAM * sizeof(int)); - memcpy(ct->fpar, clip.fpar, COLORTABLE_NBMAX_PARAM * sizeof(float)); + memcpy(ct->dpar, clip.dpar, COLORTABLE_NBMAX_PARAM * sizeof(double)); } int ColorTable_Diff(GmshColorTable * ct1, GmshColorTable * ct2) @@ -315,7 +354,6 @@ void ColorTable_Print(GmshColorTable * ct, FILE * fp) fprintf(fp, "%s\n", tmp1); else Msg(DIRECT, tmp1); - } int ColorTable_IsAlpha(GmshColorTable * ct) @@ -329,14 +367,3 @@ int ColorTable_IsAlpha(GmshColorTable * ct) return 0; } -int ColorTable_SetAlpha(GmshColorTable * ct, double alpha) -{ - int i, r, g, b; - for(i = 0; i < ct->size; i++) { - r = UNPACK_RED(ct->table[i]); - g = UNPACK_GREEN(ct->table[i]); - b = UNPACK_BLUE(ct->table[i]); - ct->table[i] = PACK_COLOR(r, g, b, (int)(255. * alpha)); - } - return 0; -} diff --git a/Common/ColorTable.h b/Common/ColorTable.h index a544c307f10afedba98f949254bae289f358f682..1d7224fbd78a99a1021253be756bb9b14020c2b0 100644 --- a/Common/ColorTable.h +++ b/Common/ColorTable.h @@ -27,16 +27,14 @@ typedef struct{ unsigned int table[COLORTABLE_NBMAX_COLOR]; int size; // must be >= 2 int ipar[COLORTABLE_NBMAX_PARAM]; - float fpar[COLORTABLE_NBMAX_PARAM]; + double dpar[COLORTABLE_NBMAX_PARAM]; }GmshColorTable; - // COLORTABLE_MODE #define COLORTABLE_RGB 1 #define COLORTABLE_HSV 2 - // integrer parameters indices #define COLORTABLE_NUMBER 0 // predefined curve index @@ -46,21 +44,19 @@ typedef struct{ #define COLORTABLE_ROTATE 4 // rotate #define COLORTABLE_MODE 5 // mode (rgb, hsv) -// float parameters indices +// double parameters indices #define COLORTABLE_CURVE 0 // curvature #define COLORTABLE_BIAS 1 // offset -#define COLORTABLE_ALPHAPOW 2 // alpha channel power -#define COLORTABLE_ALPHAVAL 3 // alpha channel value -#define COLORTABLE_BETA 4 // beta coeff for brighten +#define COLORTABLE_ALPHAVAL 2 // alpha channel value +#define COLORTABLE_BETA 3 // beta coeff for brighten -void ColorTable_InitParam (int number, GmshColorTable * ct); -void ColorTable_Recompute (GmshColorTable * ct); +void ColorTable_InitParam(int number, double alpha, GmshColorTable *ct); +void ColorTable_Recompute(GmshColorTable *ct); void ColorTable_Copy(GmshColorTable *ct); void ColorTable_Paste(GmshColorTable *ct); void ColorTable_Print(GmshColorTable *ct, FILE *fp) ; int ColorTable_IsAlpha(GmshColorTable *ct) ; -int ColorTable_SetAlpha(GmshColorTable * ct, double alpha); -int ColorTable_Diff(GmshColorTable * ct1, GmshColorTable * ct2); +int ColorTable_Diff(GmshColorTable *ct1, GmshColorTable *ct2); #endif diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index cb705078b1283cfe9c14f8620f19da29ac34014c..35d7d5caa690e6f49fa8716f4d1ca00db9279b76 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -1005,6 +1005,8 @@ StringXNumber ViewOptions_Number[] = { { F|O, "Boundary" , opt_view_boundary , 0. , "Draw the `N minus b'-dimensional boundary of the simplex (N=simplex dimension, b=option value)" }, + { F|O, "Colormap" , opt_view_default_colormap , 1. , + "Default colormap number" }, { F, "CustomMax" , opt_view_custom_max , 0. , "User-defined maximum value to be displayed" }, { F, "CustomMin" , opt_view_custom_min , 0. , diff --git a/Common/Options.cpp b/Common/Options.cpp index 7cd3f7ff016d2963669f9b5315afac68c305c4fc..267d918e1a989d721899998a69b5e516dede0910 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.211 2004-12-22 16:43:59 geuzaine Exp $ +// $Id: Options.cpp,v 1.212 2004-12-23 22:26:34 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -42,7 +42,7 @@ extern Post_View *Post_ViewReference; void Init_Options_Safe(int num) { - ColorTable_InitParam(1, &Post_ViewReference->CT); + ColorTable_InitParam(1, 1., &Post_ViewReference->CT); ColorTable_Recompute(&Post_ViewReference->CT); // Default string options @@ -64,13 +64,13 @@ void Init_Options_Safe(int num) Set_DefaultNumberOptions(num, PrintOptions_Number); // Default color options - Set_DefaultColorOptions(num, GeneralOptions_Color, CTX.color_scheme); - Set_DefaultColorOptions(num, GeometryOptions_Color, CTX.color_scheme); - Set_DefaultColorOptions(num, MeshOptions_Color, CTX.color_scheme); - Set_DefaultColorOptions(num, SolverOptions_Color, CTX.color_scheme); - Set_DefaultColorOptions(num, PostProcessingOptions_Color, CTX.color_scheme); - Set_DefaultColorOptions(num, ViewOptions_Color, CTX.color_scheme); - Set_DefaultColorOptions(num, PrintOptions_Color, CTX.color_scheme); + Set_DefaultColorOptions(num, GeneralOptions_Color); + Set_DefaultColorOptions(num, GeometryOptions_Color); + Set_DefaultColorOptions(num, MeshOptions_Color); + Set_DefaultColorOptions(num, SolverOptions_Color); + Set_DefaultColorOptions(num, PostProcessingOptions_Color); + Set_DefaultColorOptions(num, ViewOptions_Color); + Set_DefaultColorOptions(num, PrintOptions_Color); } char *gmsh_getenv(char *var) @@ -675,16 +675,11 @@ StringXColor *Get_ColorOptionCategory(char *cat) return NULL; } -void Set_DefaultColorOptions(int num, StringXColor s[], int scheme) +void Set_DefaultColorOptions(int num, StringXColor s[]) { int i = 0; - switch (scheme) { - case 0: - while(s[i].str) { - s[i].function(num, GMSH_SET, s[i].def1); - i++; - } - break; + // Warning: this assumes that CTX.color_scheme is set... + switch (CTX.color_scheme) { case 1: while(s[i].str) { s[i].function(num, GMSH_SET, s[i].def2); @@ -697,6 +692,12 @@ void Set_DefaultColorOptions(int num, StringXColor s[], int scheme) i++; } break; + default: + while(s[i].str) { + s[i].function(num, GMSH_SET, s[i].def1); + i++; + } + break; } } @@ -727,7 +728,13 @@ void Print_ColorOptions(int num, int level, int diff, StringXColor s[], char tmp[1024]; while(s[i].str) { if(s[i].level & level) { - if(!diff || (s[i].function(num, GMSH_GET, 0) != s[i].def1)){ + unsigned int def; + switch (CTX.color_scheme) { + case 1: def = s[i].def2; break; + case 2: def = s[i].def3; break; + default: def = s[i].def1; break; + } + if(!diff || (s[i].function(num, GMSH_GET, 0) != def)){ sprintf(tmp, "%sColor.%s = {%d,%d,%d}; // %s", prefix, s[i].str, UNPACK_RED(s[i].function(num, GMSH_GET, 0)), @@ -2590,9 +2597,9 @@ double opt_general_color_scheme(OPT_ARGS_NUM) CTX.color_scheme = (int)val; if(CTX.color_scheme > 2) CTX.color_scheme = 0; - Set_DefaultColorOptions(0, GeneralOptions_Color, CTX.color_scheme); - Set_DefaultColorOptions(0, GeometryOptions_Color, CTX.color_scheme); - Set_DefaultColorOptions(0, MeshOptions_Color, CTX.color_scheme); + Set_DefaultColorOptions(0, GeneralOptions_Color); + Set_DefaultColorOptions(0, GeometryOptions_Color); + Set_DefaultColorOptions(0, MeshOptions_Color); Set_ColorOptions_GUI(0, GeneralOptions_Color); Set_ColorOptions_GUI(0, GeometryOptions_Color); Set_ColorOptions_GUI(0, MeshOptions_Color); @@ -5395,13 +5402,22 @@ double opt_view_alpha_channel(OPT_ARGS_NUM) { GET_VIEW(0.); if(action & GMSH_SET) { - if(val > 0.0 && val < 1.0){ - ColorTable_SetAlpha(&v->CT, val); - v->Changed = 1; - } - v->AlphaChannel = val; + ColorTable_InitParam(v->CT.ipar[COLORTABLE_NUMBER], val, &v->CT); + ColorTable_Recompute(&v->CT); + v->Changed = 1; + } + return v->CT.dpar[COLORTABLE_ALPHAVAL]; +} + +double opt_view_default_colormap(OPT_ARGS_NUM) +{ + GET_VIEW(0.); + if(action & GMSH_SET) { + ColorTable_InitParam((int)val, v->CT.dpar[COLORTABLE_ALPHAVAL], &v->CT); + ColorTable_Recompute(&v->CT); + v->Changed = 1; } - return v->AlphaChannel; + return v->CT.ipar[COLORTABLE_NUMBER]; } double opt_view_external_view(OPT_ARGS_NUM) diff --git a/Common/Options.h b/Common/Options.h index a5ac67c5c64688cf94edc26d8665f43d026dc198..41eb7c04266edd02eea7d1e11cfe1fd31f8e6cfe 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -484,6 +484,7 @@ double opt_view_saturate_values(OPT_ARGS_NUM); double opt_view_max_recursion_level(OPT_ARGS_NUM); double opt_view_target_error(OPT_ARGS_NUM); double opt_view_alpha_channel(OPT_ARGS_NUM); +double opt_view_default_colormap(OPT_ARGS_NUM); double opt_view_external_view(OPT_ARGS_NUM); double opt_view_gen_raise_view(OPT_ARGS_NUM); double opt_view_gen_raise_factor(OPT_ARGS_NUM); @@ -627,7 +628,7 @@ StringXColor * Get_ColorOptionCategory(char * cat); void Set_DefaultStringOptions(int num, StringXString s[]); void Set_DefaultNumberOptions(int num, StringXNumber s[]); -void Set_DefaultColorOptions(int num, StringXColor s[], int scheme); +void Set_DefaultColorOptions(int num, StringXColor s[]); void Set_StringOptions_GUI(int num, StringXString s[]); void Set_NumberOptions_GUI(int num, StringXNumber s[]); diff --git a/Common/Views.cpp b/Common/Views.cpp index 756b69093e2c1e8077103693ad022b2d04dbb497..c2c79816b9070a9dbf3e7bafafff2e3b19eb1cc3 100644 --- a/Common/Views.cpp +++ b/Common/Views.cpp @@ -1,4 +1,4 @@ -// $Id: Views.cpp,v 1.149 2004-12-13 15:57:29 geuzaine Exp $ +// $Id: Views.cpp,v 1.150 2004-12-23 22:26:34 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -621,7 +621,6 @@ void CopyViewOptions(Post_View * src, Post_View * dest) dest->Visible = src->Visible; dest->IntervalsType = src->IntervalsType; dest->SaturateValues = src->SaturateValues; - dest->AlphaChannel = src->AlphaChannel; dest->Boundary = src->Boundary; dest->NbAbscissa = src->NbAbscissa; dest->NbIso = src->NbIso; @@ -698,8 +697,16 @@ void Print_ColorTable(int num, int diff, char *prefix, FILE * file) v = *vv; } - if(diff && !ColorTable_Diff(&Post_ViewReference->CT, &v->CT)) - return; + if(diff){ + // compare the current colormap with a vanilla colormap having the + // same index number + GmshColorTable ref; + ColorTable_InitParam(v->CT.ipar[COLORTABLE_NUMBER], + v->CT.dpar[COLORTABLE_ALPHAVAL], &ref); + ColorTable_Recompute(&ref); + if(!ColorTable_Diff(&ref, &v->CT)) + return; + } sprintf(tmp, "%s = {", prefix); if(file) diff --git a/Common/Views.h b/Common/Views.h index f81d4a2c48e708b22667917048c22142f40de3d5..57932eabc2e5817a166b67732e906f37e379a686 100644 --- a/Common/Views.h +++ b/Common/Views.h @@ -82,7 +82,7 @@ class Post_View{ double Normals, Tangents; int Visible, IntervalsType, NbIso, NbAbscissa, ArrowSizeProportional; int Light, LightTwoSide, SmoothNormals; - double AngleSmoothNormals, AlphaChannel; + double AngleSmoothNormals; int SaturateValues; int ShowElement, ShowTime, ShowScale; int ScaleType, RangeType; diff --git a/Fltk/Colorbar_Window.cpp b/Fltk/Colorbar_Window.cpp index be8ea289b2a3a6548e8f5c2f41d80eb0e86155d8..9b45892b0abc00cebbfef9477adfe64fe9e2788e 100644 --- a/Fltk/Colorbar_Window.cpp +++ b/Fltk/Colorbar_Window.cpp @@ -1,4 +1,4 @@ -// $Id: Colorbar_Window.cpp,v 1.38 2004-05-22 01:24:17 geuzaine Exp $ +// $Id: Colorbar_Window.cpp,v 1.39 2004-12-23 22:26:34 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -118,7 +118,7 @@ static void HSV_to_RGB(double H, double S, double V, int Colorbar_Window::x_to_index(int x) { int index; - index = (int)(x * (float)ct->size / (float)w()); + index = (int)(x * (double)ct->size / (double)w()); if(index < 0) index = 0; else if(index >= ct->size) @@ -131,7 +131,7 @@ int Colorbar_Window::x_to_index(int x) int Colorbar_Window::index_to_x(int index) { int x; - x = (int)(index * (float)w() / (float)(ct->size - 1)); + x = (int)(index * (double)w() / (double)(ct->size - 1)); if(x >= w()) x = w() - 1; return x; @@ -142,7 +142,7 @@ int Colorbar_Window::index_to_x(int index) int Colorbar_Window::intensity_to_y(int intensity) { int y; - y = (int)(wedge_y - intensity * (float)wedge_y / 255.); + y = (int)(wedge_y - intensity * (double)wedge_y / 255.); if(y < 0) y = 0; else if(y >= wedge_y) @@ -155,7 +155,7 @@ int Colorbar_Window::intensity_to_y(int intensity) int Colorbar_Window::y_to_intensity(int y) { int intensity; - intensity = (int)((wedge_y - y) * 255. / (float)wedge_y); + intensity = (int)((wedge_y - y) * 255. / (double)wedge_y); if(intensity < 0) intensity = 0; else if(intensity > 255) @@ -287,7 +287,7 @@ void Colorbar_Window::redraw_range(int a, int b) int xx0 = 10, xx1 = 12 * font_height, yy0 = 10; if(help_flag) { i = 0; - fl_draw("1, 2, ..., 8", xx0, yy0 + (i + 1) * font_height); + fl_draw("0, 1, 2, ..., 9", xx0, yy0 + (i + 1) * font_height); fl_draw("select predefined colormap", xx1, yy0 + (i + 1) * font_height); i++; fl_draw("mouse1", xx0, yy0 + (i + 1) * font_height); @@ -317,15 +317,15 @@ void Colorbar_Window::redraw_range(int a, int b) fl_draw("up, down", xx0, yy0 + (i + 1) * font_height); fl_draw("modify color curvature", xx1, yy0 + (i + 1) * font_height); i++; - fl_draw("Ctrl+up, Ctrl+down", xx0, yy0 + (i + 1) * font_height); - fl_draw("incr. or decr. alpha channel", xx1, yy0 + (i + 1) * font_height); - i++; - fl_draw("i, Ctrl+i", xx0, yy0 + (i + 1) * font_height); - fl_draw("invert x or y range", xx1, yy0 + (i + 1) * font_height); + fl_draw("a, Ctrl+a", xx0, yy0 + (i + 1) * font_height); + fl_draw("increase or decrease alpha", xx1, yy0 + (i + 1) * font_height); i++; fl_draw("b, Ctrl+b", xx0, yy0 + (i + 1) * font_height); fl_draw("increase or decrease gamma", xx1, yy0 + (i + 1) * font_height); i++; + fl_draw("i, Ctrl+i", xx0, yy0 + (i + 1) * font_height); + fl_draw("invert x or y range", xx1, yy0 + (i + 1) * font_height); + i++; fl_draw("h", xx0, yy0 + (i + 1) * font_height); fl_draw("show this help message", xx1, yy0 + (i + 1) * font_height); i++; @@ -343,7 +343,7 @@ void Colorbar_Window::redraw_marker() { int x, y0, y1; char str[50]; - float val; + double val; make_current(); @@ -363,7 +363,7 @@ void Colorbar_Window::redraw_marker() // draw marker value fl_font(FL_HELVETICA, font_height); val = - minval + (maxval - minval) * ((float)marker_pos / (float)(ct->size - 1)); + minval + (maxval - minval) * ((double)marker_pos / (double)(ct->size - 1)); sprintf(str, "%g", val); fl_draw(str, 10, label_y); } @@ -386,7 +386,7 @@ void Colorbar_Window::draw() // Update -void Colorbar_Window::update(char *name, float min, float max, +void Colorbar_Window::update(char *name, double min, double max, GmshColorTable * table, int *changed) { label = name; @@ -422,43 +422,43 @@ int Colorbar_Window::handle(int event) case FL_SHORTCUT: case FL_KEYBOARD: if(Fl::test_shortcut('0')) { - ColorTable_InitParam(0, ct); + ColorTable_InitParam(0, 1., ct); compute = 1; } else if(Fl::test_shortcut('1')) { - ColorTable_InitParam(1, ct); + ColorTable_InitParam(1, 1., ct); compute = 1; } else if(Fl::test_shortcut('2')) { - ColorTable_InitParam(2, ct); + ColorTable_InitParam(2, 1., ct); compute = 1; } else if(Fl::test_shortcut('3')) { - ColorTable_InitParam(3, ct); + ColorTable_InitParam(3, 1., ct); compute = 1; } else if(Fl::test_shortcut('4')) { - ColorTable_InitParam(4, ct); + ColorTable_InitParam(4, 1., ct); compute = 1; } else if(Fl::test_shortcut('5')) { - ColorTable_InitParam(5, ct); + ColorTable_InitParam(5, 1., ct); compute = 1; } else if(Fl::test_shortcut('6')) { - ColorTable_InitParam(6, ct); + ColorTable_InitParam(6, 1., ct); compute = 1; } else if(Fl::test_shortcut('7')) { - ColorTable_InitParam(7, ct); + ColorTable_InitParam(7, 1., ct); compute = 1; } else if(Fl::test_shortcut('8')) { - ColorTable_InitParam(8, ct); + ColorTable_InitParam(8, 1., ct); compute = 1; } else if(Fl::test_shortcut('9')) { - ColorTable_InitParam(9, ct); + ColorTable_InitParam(9, 1., ct); compute = 1; } else if(Fl::test_shortcut('c')) { @@ -473,7 +473,7 @@ int Colorbar_Window::handle(int event) draw(); } else if(Fl::test_shortcut('r')) { - ColorTable_InitParam(ct->ipar[COLORTABLE_NUMBER], ct); + ColorTable_InitParam(ct->ipar[COLORTABLE_NUMBER], 1., ct); compute = 1; } else if(Fl::test_shortcut('m')) { @@ -492,19 +492,31 @@ int Colorbar_Window::handle(int event) compute = 1; } else if(Fl::test_shortcut('b')) { - ct->fpar[COLORTABLE_BETA] += 0.05; - if(ct->fpar[COLORTABLE_BETA] > 1.0) - ct->fpar[COLORTABLE_BETA] = 1.0; + ct->dpar[COLORTABLE_BETA] += 0.05; + if(ct->dpar[COLORTABLE_BETA] > 1.0) + ct->dpar[COLORTABLE_BETA] = 1.0; compute = 1; } else if(Fl::test_shortcut(FL_CTRL + 'b')) { - ct->fpar[COLORTABLE_BETA] -= 0.05; - if(ct->fpar[COLORTABLE_BETA] < -1.0) - ct->fpar[COLORTABLE_BETA] = -1.0; + ct->dpar[COLORTABLE_BETA] -= 0.05; + if(ct->dpar[COLORTABLE_BETA] < -1.0) + ct->dpar[COLORTABLE_BETA] = -1.0; + compute = 1; + } + else if(Fl::test_shortcut('a')) { + ct->dpar[COLORTABLE_ALPHAVAL] -= 0.05; + if(ct->dpar[COLORTABLE_ALPHAVAL] < 0.0) + ct->dpar[COLORTABLE_ALPHAVAL] = 0.0; + compute = 1; + } + else if(Fl::test_shortcut(FL_CTRL + 'a')) { + ct->dpar[COLORTABLE_ALPHAVAL] += 0.05; + if(ct->dpar[COLORTABLE_ALPHAVAL] > 1.0) + ct->dpar[COLORTABLE_ALPHAVAL] = 1.0; compute = 1; } else if(Fl::test_shortcut(FL_Left)) { - ct->fpar[COLORTABLE_BIAS] -= 0.05; + ct->dpar[COLORTABLE_BIAS] -= 0.05; compute = 1; } else if(Fl::test_shortcut(FL_CTRL + FL_Left)) { @@ -514,7 +526,7 @@ int Colorbar_Window::handle(int event) compute = 1; } else if(Fl::test_shortcut(FL_Right)) { - ct->fpar[COLORTABLE_BIAS] += 0.05; + ct->dpar[COLORTABLE_BIAS] += 0.05; compute = 1; } else if(Fl::test_shortcut(FL_CTRL + FL_Right)) { @@ -524,23 +536,11 @@ int Colorbar_Window::handle(int event) compute = 1; } else if(Fl::test_shortcut(FL_Up)) { - ct->fpar[COLORTABLE_CURVE] -= 0.05; - compute = 1; - } - else if(Fl::test_shortcut(FL_CTRL + FL_Up)) { - ct->fpar[COLORTABLE_ALPHAPOW] += 0.05; - if(ct->fpar[COLORTABLE_ALPHAPOW] > 1.0) - ct->fpar[COLORTABLE_ALPHAPOW] = 1.0; + ct->dpar[COLORTABLE_CURVE] -= 0.05; compute = 1; } else if(Fl::test_shortcut(FL_Down)) { - ct->fpar[COLORTABLE_CURVE] += 0.05; - compute = 1; - } - else if(Fl::test_shortcut(FL_CTRL + FL_Down)) { - ct->fpar[COLORTABLE_ALPHAPOW] -= 0.05; - if(ct->fpar[COLORTABLE_ALPHAPOW] < 0.0) - ct->fpar[COLORTABLE_ALPHAPOW] = 0.0; + ct->dpar[COLORTABLE_CURVE] += 0.05; compute = 1; } else { diff --git a/Fltk/Colorbar_Window.h b/Fltk/Colorbar_Window.h index 59fbb10793897eb1e3285c547101682f54ccf556..5d10a4c8c2f30347d94f92b6600709cfca14f3ec 100644 --- a/Fltk/Colorbar_Window.h +++ b/Fltk/Colorbar_Window.h @@ -38,7 +38,7 @@ class Colorbar_Window : public Fl_Window { int font_height, marker_height, wedge_height; char *label; - float minval, maxval; // min and max data values + double minval, maxval; // min and max data values int wedge_y; // top coord of color wedge int marker_y; // top coord of marker arrow int label_y; // y coord of text labels @@ -52,7 +52,7 @@ class Colorbar_Window : public Fl_Window { public: Colorbar_Window(int x,int y,int w,int h,const char *l=0); - void update(char *name, float min, float max, GmshColorTable *ct, int *changed); + void update(char *name, double min, double max, GmshColorTable *ct, int *changed); }; diff --git a/demos/isosurf.scp b/demos/isosurf.scp index 132512daa7c421da78fdc511b1a36f22cb48ab31..de906a4887c3b03461af8868c76d3cdf613f352e 100644 --- a/demos/isosurf.scp +++ b/demos/isosurf.scp @@ -15,10 +15,6 @@ EndFor Delete View[0]; Combine Views; -For i In {1:nbIso} - Delete View[0]; -EndFor - Plugin(DecomposeInSimplex).iView = 0; Plugin(DecomposeInSimplex).Run; diff --git a/doc/VERSIONS b/doc/VERSIONS index b457ec1a3a1569a37a88d8ae46953d3621e04102..e86ee1028da5b95415488d2c23d12be5110300a8 100644 --- a/doc/VERSIONS +++ b/doc/VERSIONS @@ -1,6 +1,6 @@ -$Id: VERSIONS,v 1.278 2004-12-23 03:19:58 geuzaine Exp $ +$Id: VERSIONS,v 1.279 2004-12-23 22:26:34 geuzaine Exp $ -New since 1.57: new File->Rename menu; +New since 1.57: new File->Rename menu; improved colormap handling; New in 1.57: generalized displacement maps to display arbitrary view types; the arrows representing a vector field can now also be colored