diff --git a/Common/ColorTable.cpp b/Common/ColorTable.cpp index 797d9fce5cc096a2c7a6a7b246a0f07e0b229042..3b858e1132e0008f37043a9214c0122fe6b259cf 100644 --- a/Common/ColorTable.cpp +++ b/Common/ColorTable.cpp @@ -1,21 +1,10 @@ -// $Id: ColorTable.cpp,v 1.18 2003-11-29 01:38:49 geuzaine Exp $ +// $Id: ColorTable.cpp,v 1.19 2003-12-08 19:18:13 geuzaine Exp $ // // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle // -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. +// This software is provided "as is" without express or implied warranty. +// See the file "doc/LICENSE" for the licensing terms. // -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. // // Please report all bugs and problems to "gmsh@geuz.org". // @@ -23,10 +12,10 @@ // David Colignon // -// These routines are loosely based on the colortable routines from -// the Vis5d program for visualizing five dimensional gridded data -// sets Copyright (C) 1990 - 1995 Bill Hibbard, Brian Paul, Dave -// Santek, and Andre Battaiola. +// These colortable routines were inspired by those provided in Vis5d, +// a program for visualizing five dimensional gridded data sets +// Copyright (C) 1990 - 1995 Bill Hibbard, Brian Paul, Dave Santek, +// and Andre Battaiola. #include "Gmsh.h" #include "ColorTable.h" @@ -34,28 +23,23 @@ extern Context_T CTX; -void ColorTable_InitParam(int number, GmshColorTable * ct, - int rgb_flag, int alpha_flag) +void ColorTable_InitParam(int number, GmshColorTable * ct) { + ct->size = 255; + ct->ipar[COLORTABLE_MODE] = COLORTABLE_RGB; ct->ipar[COLORTABLE_NUMBER] = number; + ct->ipar[COLORTABLE_INVERT] = 0; + ct->ipar[COLORTABLE_SWAP] = 0; + ct->ipar[COLORTABLE_ROTATE] = 0; - if(rgb_flag) { - ct->ipar[COLORTABLE_INVERT] = 0; - 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; - } - if(alpha_flag) { - ct->fpar[COLORTABLE_ALPHAPOW] = 1.; - ct->fpar[COLORTABLE_ALPHAVAL] = 255.; - } - + 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.; } -void ColorTable_Recompute(GmshColorTable * ct, int rgb_flag, int alpha_flag) +void ColorTable_Recompute(GmshColorTable * ct) { float curve, bias; double gamma; @@ -84,197 +68,183 @@ void ColorTable_Recompute(GmshColorTable * ct, int rgb_flag, int alpha_flag) if(ct->ipar[COLORTABLE_SWAP]) s = 1.0 - s; - if(rgb_flag) { - - switch (ct->ipar[COLORTABLE_NUMBER]) { - case 1: // vis5d - t = (curve + 1.4) * (s - (1. + bias) / 2.); - r = (int)(128.0 + 127.0 * atan(7.0 * t) / 1.57); - 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) { - r = 0; - g = 0; - b = 255; - } - else if(s - bias <= 0.40) { - r = 0; - g = (int)((s - bias) * 637.5); - b = (int)(255. - (s - bias) * 637.5); - } - else if(s - bias <= 0.60) { - r = (int)(1275. * (s - bias - 0.4)); - g = 255; - b = 0; - } - else if(s - bias <= 1.00) { - r = 255; - g = (int)(255. - 637.5 * (s - bias - 0.6)); - b = 0; - } - else { - r = 255; - g = 0; - b = 0; - } - break; - case 3: // rainbow (matlab, etc.) - if(s - bias <= 0.00) { - r = 0; - g = 0; - b = 255; - } - else if(s - bias <= 0.25 + curve) { - curve = (curve == -0.25) ? -0.26 : curve; - r = 0; - g = (int)((s - bias) * (255. / (0.25 + curve))); - b = 255; - } - else if(s - bias <= 0.50) { - curve = (curve == 0.25) ? 0.26 : curve; - r = 0; - g = 255; - b = - (int)(255. - (255. / (0.25 - curve)) * (s - bias - 0.25 - curve)); - } - else if(s - bias <= 0.75 - curve) { - curve = (curve == 0.25) ? 0.26 : curve; - r = (int)((s - bias - 0.5) * (255. / (0.25 - curve))); - g = 255; - b = 0; - } - else if(s - bias <= 1.00) { - curve = (curve == -0.25) ? -0.26 : curve; - r = 255; - g = - (int)(255. - (255. / (0.25 + curve)) * (s - bias - 0.75 + curve)); - b = 0; - } - else { - r = 255; - g = 0; - b = 0; - } - break; - case 4: // darkblue-red-yellow-white -#define myfct(a,b,c,d) ((a)+\ - (b)*(s-bias)+\ - (c)*(s-bias)*(s-bias)+\ + switch (ct->ipar[COLORTABLE_NUMBER]) { + case 1: // vis5d + t = (curve + 1.4) * (s - (1. + bias) / 2.); + r = (int)(128.0 + 127.0 * atan(7.0 * t) / 1.57); + 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) { + r = 0; + g = 0; + b = 255; + } + else if(s - bias <= 0.40) { + r = 0; + g = (int)((s - bias) * 637.5); + b = (int)(255. - (s - bias) * 637.5); + } + else if(s - bias <= 0.60) { + r = (int)(1275. * (s - bias - 0.4)); + g = 255; + b = 0; + } + else if(s - bias <= 1.00) { + r = 255; + g = (int)(255. - 637.5 * (s - bias - 0.6)); + b = 0; + } + else { + r = 255; + g = 0; + b = 0; + } + break; + case 3: // rainbow (matlab, etc.) + if(s - bias <= 0.00) { + r = 0; + g = 0; + b = 255; + } + else if(s - bias <= 0.25 + curve) { + curve = (curve == -0.25) ? -0.26 : curve; + r = 0; + g = (int)((s - bias) * (255. / (0.25 + curve))); + b = 255; + } + else if(s - bias <= 0.50) { + curve = (curve == 0.25) ? 0.26 : curve; + r = 0; + g = 255; + b = + (int)(255. - (255. / (0.25 - curve)) * (s - bias - 0.25 - curve)); + } + else if(s - bias <= 0.75 - curve) { + curve = (curve == 0.25) ? 0.26 : curve; + r = (int)((s - bias - 0.5) * (255. / (0.25 - curve))); + g = 255; + b = 0; + } + else if(s - bias <= 1.00) { + curve = (curve == -0.25) ? -0.26 : curve; + r = 255; + g = + (int)(255. - (255. / (0.25 + curve)) * (s - bias - 0.75 + curve)); + b = 0; + } + else { + r = 255; + g = 0; + 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); + 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) { - r = 0; - g = 0; - b = 0; - } - else if(s - bias <= 0.2) { - r = (int)(57 * (1 - 100 * ((s - bias) - 0.1) * ((s - bias) - 0.1))); - g = 0; - b = (int)((s - bias) * (255. / 0.2)); - } - else if(s - bias <= 0.3624) { - r = 0; - g = (int)((s - bias - 0.2) * (255. / 0.1624)); - b = 255; - } - else if(s - bias <= 0.50) { - r = 0; - g = 255; - b = (int)(255. - (255. / 0.1376) * (s - bias - 0.3624)); - } - else if(s - bias <= 0.6376) { - r = (int)((s - bias - 0.5) * (255. / 0.1376)); - g = 255; - b = 0; - } - else if(s - bias <= 0.8) { - r = 255; - g = (int)(255. - (255. / 0.1624) * (s - bias - 0.6376)); - b = 0; - } - 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); - } - else { - r = 255; - g = 255; - b = 255; - } - break; - case 8: // grayscale, without white - default: - if(s - bias <= 0.00) { - r = g = b = 0; - } - else if(s - bias <= 1.00) { - r = g = b = (int)(220 * (s - bias)); - } - else { - r = g = b = 220; - } - break; + break; + case 5: // grayscale + if(s - bias <= 0.00) { + r = g = b = 0; } - - if(ct->fpar[COLORTABLE_BETA]) { - if(ct->fpar[COLORTABLE_BETA] > 0.0) - gamma = 1. - ct->fpar[COLORTABLE_BETA]; - else - gamma = 1. / (1.001 + ct->fpar[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)); + else if(s - bias <= 1.00) { + r = g = b = (int)(255 * (s - bias)); } - - if(ct->ipar[COLORTABLE_INVERT]) { - r = 255 - r; - g = 255 - g; - b = 255 - b; + else { + r = g = b = 255; } - - } - else { - r = UNPACK_RED(ct->table[i]); - g = UNPACK_GREEN(ct->table[i]); - b = UNPACK_BLUE(ct->table[i]); + 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) { + r = 0; + g = 0; + b = 0; + } + else if(s - bias <= 0.2) { + r = (int)(57 * (1 - 100 * ((s - bias) - 0.1) * ((s - bias) - 0.1))); + g = 0; + b = (int)((s - bias) * (255. / 0.2)); + } + else if(s - bias <= 0.3624) { + r = 0; + g = (int)((s - bias - 0.2) * (255. / 0.1624)); + b = 255; + } + else if(s - bias <= 0.50) { + r = 0; + g = 255; + b = (int)(255. - (255. / 0.1376) * (s - bias - 0.3624)); + } + else if(s - bias <= 0.6376) { + r = (int)((s - bias - 0.5) * (255. / 0.1376)); + g = 255; + b = 0; + } + else if(s - bias <= 0.8) { + r = 255; + g = (int)(255. - (255. / 0.1624) * (s - bias - 0.6376)); + b = 0; + } + 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); + } + else { + r = 255; + g = 255; + b = 255; + } + break; + case 8: // grayscale, without white + default: + if(s - bias <= 0.00) { + r = g = b = 0; + } + else if(s - bias <= 1.00) { + r = g = b = (int)(220 * (s - bias)); + } + else { + r = g = b = 220; + } + break; } - - if(alpha_flag) { - a = (int)(ct->fpar[COLORTABLE_ALPHAVAL] * - ct->fpar[COLORTABLE_ALPHAPOW]); + + if(ct->fpar[COLORTABLE_BETA]) { + if(ct->fpar[COLORTABLE_BETA] > 0.0) + gamma = 1. - ct->fpar[COLORTABLE_BETA]; + else + gamma = 1. / (1.001 + ct->fpar[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)); } - else { - a = UNPACK_ALPHA(ct->table[i]); + + if(ct->ipar[COLORTABLE_INVERT]) { + r = 255 - r; + g = 255 - g; + b = 255 - b; } + + a = (int)(ct->fpar[COLORTABLE_ALPHAVAL] * + ct->fpar[COLORTABLE_ALPHAPOW]); ct->table[i] = PACK_COLOR(r, g, b, a); } @@ -299,7 +269,6 @@ void ColorTable_Paste(GmshColorTable * ct) memcpy(ct->fpar, clip.fpar, COLORTABLE_NBMAX_PARAM * sizeof(float)); } - void ColorTable_Print(GmshColorTable * ct, FILE * fp) { int i, r, g, b, a; diff --git a/Common/ColorTable.h b/Common/ColorTable.h index 4bcc0de4d0cd3bc789d199be05e0d208ce4329d0..e0d427c29c8c54f9c50a48b5d183cb4eaf2970d5 100644 --- a/Common/ColorTable.h +++ b/Common/ColorTable.h @@ -54,8 +54,8 @@ typedef struct{ #define COLORTABLE_ALPHAVAL 3 // alpha channel value #define COLORTABLE_BETA 4 // beta coeff for brighten -void ColorTable_InitParam (int number, GmshColorTable * ct, int rgb_flag, int alpha_flag); -void ColorTable_Recompute (GmshColorTable * ct, int rgb_flag, int alpha_flag); +void ColorTable_InitParam (int number, GmshColorTable * ct); +void ColorTable_Recompute (GmshColorTable * ct); void ColorTable_Copy(GmshColorTable *ct); void ColorTable_Paste(GmshColorTable *ct); void ColorTable_Print(GmshColorTable *ct, FILE *fp) ; diff --git a/Common/Options.cpp b/Common/Options.cpp index c9927ccc09a362130f7c3baee4c25e24501ba83e..528a3e1b8f9b467742548647309fcec0bfba1d7a 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.128 2003-12-07 05:37:00 geuzaine Exp $ +// $Id: Options.cpp,v 1.129 2003-12-08 19:18:13 geuzaine Exp $ // // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle // @@ -41,10 +41,8 @@ extern Post_View *Post_ViewReference; void Init_Options_Safe(int num) { - Post_ViewReference->CT.size = 255; - Post_ViewReference->CT.ipar[COLORTABLE_MODE] = COLORTABLE_RGB; - ColorTable_InitParam(1, &Post_ViewReference->CT, 1, 1); - ColorTable_Recompute(&Post_ViewReference->CT, 1, 1); + ColorTable_InitParam(1, &Post_ViewReference->CT); + ColorTable_Recompute(&Post_ViewReference->CT); // Default string options Set_DefaultStringOptions(num, GeneralOptions_String); diff --git a/Fltk/Colorbar_Window.cpp b/Fltk/Colorbar_Window.cpp index e48196205d0c8df3bc829c2a23ea4643fc05b1a3..a46e3e10749da45e70767541fdddc5f0bc255db2 100644 --- a/Fltk/Colorbar_Window.cpp +++ b/Fltk/Colorbar_Window.cpp @@ -1,4 +1,4 @@ -// $Id: Colorbar_Window.cpp,v 1.35 2003-10-29 15:18:30 geuzaine Exp $ +// $Id: Colorbar_Window.cpp,v 1.36 2003-12-08 19:18:13 geuzaine Exp $ // // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle // @@ -426,43 +426,43 @@ int Colorbar_Window::handle(int event) case FL_SHORTCUT: case FL_KEYBOARD: if(Fl::test_shortcut('0')) { - ColorTable_InitParam(0, ct, 1, 1); + ColorTable_InitParam(0, ct); compute = 1; } else if(Fl::test_shortcut('1')) { - ColorTable_InitParam(1, ct, 1, 1); + ColorTable_InitParam(1, ct); compute = 1; } else if(Fl::test_shortcut('2')) { - ColorTable_InitParam(2, ct, 1, 1); + ColorTable_InitParam(2, ct); compute = 1; } else if(Fl::test_shortcut('3')) { - ColorTable_InitParam(3, ct, 1, 1); + ColorTable_InitParam(3, ct); compute = 1; } else if(Fl::test_shortcut('4')) { - ColorTable_InitParam(4, ct, 1, 1); + ColorTable_InitParam(4, ct); compute = 1; } else if(Fl::test_shortcut('5')) { - ColorTable_InitParam(5, ct, 1, 1); + ColorTable_InitParam(5, ct); compute = 1; } else if(Fl::test_shortcut('6')) { - ColorTable_InitParam(6, ct, 1, 1); + ColorTable_InitParam(6, ct); compute = 1; } else if(Fl::test_shortcut('7')) { - ColorTable_InitParam(7, ct, 1, 1); + ColorTable_InitParam(7, ct); compute = 1; } else if(Fl::test_shortcut('8')) { - ColorTable_InitParam(8, ct, 1, 1); + ColorTable_InitParam(8, ct); compute = 1; } else if(Fl::test_shortcut('9')) { - ColorTable_InitParam(9, ct, 1, 1); + ColorTable_InitParam(9, ct); compute = 1; } else if(Fl::test_shortcut('c')) { @@ -477,7 +477,7 @@ int Colorbar_Window::handle(int event) draw(); } else if(Fl::test_shortcut('r')) { - ColorTable_InitParam(ct->ipar[COLORTABLE_NUMBER], ct, 1, 1); + ColorTable_InitParam(ct->ipar[COLORTABLE_NUMBER], ct); compute = 1; } else if(Fl::test_shortcut('m')) { @@ -552,7 +552,7 @@ int Colorbar_Window::handle(int event) } if(compute) { - ColorTable_Recompute(ct, 1, 1); + ColorTable_Recompute(ct); draw(); *viewchanged = 1; set_changed(); diff --git a/Makefile b/Makefile index 0b4fad24ec86cf46810e4e62da77fd7e09dcbe24..13ca28ac4f1fe73b11c703b5f6ef0b246ae09ca8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.317 2003-12-07 20:55:51 geuzaine Exp $ +# $Id: Makefile,v 1.318 2003-12-08 19:18:13 geuzaine Exp $ # # Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle # @@ -74,7 +74,7 @@ source: source-common NR Triangle/triangle.* utils/commercial tar zcvf gmsh-${GMSH_RELEASE}-source.tgz gmsh-${GMSH_RELEASE} -source-nonfree: source-common +source-commercial: source-common cd gmsh-${GMSH_RELEASE} && rm -rf CVS */CVS */*/CVS */.globalrc ${GMSH_VERSION_FILE}\ Triangle/triangle.* TODO doc/gmsh.html doc/FAQ doc/README.cvs\ utils/commercial @@ -84,7 +84,7 @@ source-nonfree: source-common cp -f utils/commercial/license.texi gmsh-${GMSH_RELEASE}/doc/texinfo/license.texi cp -f utils/commercial/copying.texi gmsh-${GMSH_RELEASE}/doc/texinfo/copying.texi utils/commercial/sanitize.sh gmsh-${GMSH_RELEASE} - tar zcvf gmsh-${GMSH_RELEASE}-source-nonfree.tgz gmsh-${GMSH_RELEASE} + tar zcvf gmsh-${GMSH_RELEASE}-source-commercial.tgz gmsh-${GMSH_RELEASE} .PHONY: parser parser: