diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 07016438a7d16301a139023039a7fa00ac27233b..843f7400df55cbdbcf69f8c714f4d4a2f44aa399 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -818,7 +818,7 @@ StringXNumber GeometryOptions_Number[] = { { F|O, "LineSelectWidth" , opt_geometry_line_sel_width , 2. , "Display width of selected lines (in pixels)" }, { F|O, "LineType" , opt_geometry_line_type , 0. , - "Display lines as solid color segments (0) or 3D cylinders (1)" }, + "Display lines as solid color segments (0), 3D cylinders (1) or tapered cylinders (2)" }, { F|O, "LineWidth" , opt_geometry_line_width , 2. , "Display width of lines (in pixels)" }, @@ -845,7 +845,7 @@ StringXNumber GeometryOptions_Number[] = { { F|O, "PointSize" , opt_geometry_point_size , 4. , "Display size of points (in pixels)" }, { F|O, "PointType" , opt_geometry_point_type , 0. , - "Display points as solid color dots (0) or 3D spheres (1)" }, + "Display points as solid color dots (0), 3D spheres (1) or growing spheres (2)" }, { F|O, "ScalingFactor" , opt_geometry_scaling_factor , 1.0 , "Global geometry scaling factor" }, diff --git a/Common/Options.cpp b/Common/Options.cpp index 350456004c6495358aa89d150b73b661494fea81..fc0d535f5a9f4848c8fef9202bb167b6854e3648 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.349 2007-08-17 17:51:26 geuzaine Exp $ +// $Id: Options.cpp,v 1.350 2007-08-28 08:38:47 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -6712,10 +6712,11 @@ double opt_view_point_type(OPT_ARGS_NUM) GET_VIEW(0.); if(action & GMSH_SET) { v->PointType = (int)val; + if(v->PointType < 0 || v->PointType > 2) v->PointType = 0; } #if defined(HAVE_FLTK) if(_gui_action_valid(action, num)) { - WID->view_choice[5]->value(v->PointType ? 1 : 0); + WID->view_choice[5]->value(v->PointType); } #endif return v->PointType; @@ -6726,11 +6727,12 @@ double opt_view_line_type(OPT_ARGS_NUM) GET_VIEW(0.); if(action & GMSH_SET) { v->LineType = (int)val; + if(v->LineType < 0 || v->LineType > 2) v->LineType = 0; v->Changed = 1; } #if defined(HAVE_FLTK) if(_gui_action_valid(action, num)) { - WID->view_choice[6]->value(v->LineType ? 1 : 0); + WID->view_choice[6]->value(v->LineType); } #endif return v->LineType; diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 46e3fbbe26a048039ca4c2c5757bdd162c1deb41..ba4e9dabb44596f8a3e08352773835c29e8bfd1c 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.632 2007-08-24 08:38:24 remacle Exp $ +// $Id: GUI.cpp,v 1.633 2007-08-28 08:38:47 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -343,32 +343,39 @@ static Fl_Menu_Item menu_point_display[] = { {0} }; +static Fl_Menu_Item menu_point_display_post[] = { + {"Color dot", 0, 0, 0}, + {"3D sphere", 0, 0, 0}, + {"Growing sphere", 0, 0, 0}, + {0} +}; + static Fl_Menu_Item menu_line_display[] = { {"Color segment", 0, 0, 0}, {"3D cylinder", 0, 0, 0}, {0} }; -static Fl_Menu_Item menu_line_display_postpro[] = { - {"Color segment", 0, 0, 0}, - {"3D cylinder", 0, 0, 0}, - {"Taper cylinder", 0, 0, 0}, +static Fl_Menu_Item menu_line_display_post[] = { + {"Color segment", 0, 0, 0}, + {"3D cylinder", 0, 0, 0}, + {"Tapered cylinder", 0, 0, 0}, {0} }; static Fl_Menu_Item menu_surface_display[] = { {"Wireframe", 0, 0, 0}, - {"Solid", 0, 0, 0}, + {"Solid", 0, 0, 0}, {0} }; static Fl_Menu_Item menu_axes_mode[] = { - {"None", 0, 0, 0}, + {"None", 0, 0, 0}, {"Simple axes", 0, 0, 0}, - {"Box", 0, 0, 0}, - {"Full grid", 0, 0, 0}, - {"Open grid", 0, 0, 0}, - {"Ruler", 0, 0, 0}, + {"Box", 0, 0, 0}, + {"Full grid", 0, 0, 0}, + {"Open grid", 0, 0, 0}, + {"Ruler", 0, 0, 0}, {0} }; @@ -3230,7 +3237,7 @@ void GUI::create_option_window() view_value[12]->callback(view_options_ok_cb); view_choice[5] = new Fl_Choice(L + 2 * WB, 2 * WB + 2 * BH, IW, BH, "Point display"); - view_choice[5]->menu(menu_point_display); + view_choice[5]->menu(menu_point_display_post); view_choice[5]->align(FL_ALIGN_RIGHT); view_choice[5]->callback(view_options_ok_cb); @@ -3242,7 +3249,7 @@ void GUI::create_option_window() view_value[61]->callback(view_options_ok_cb); view_choice[6] = new Fl_Choice(L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Line display"); - view_choice[6]->menu(menu_line_display_postpro); + view_choice[6]->menu(menu_line_display_post); view_choice[6]->align(FL_ALIGN_RIGHT); view_choice[6]->callback(view_options_ok_cb); diff --git a/Graphics/Post.cpp b/Graphics/Post.cpp index 74b2620d62376f00844b14cf57ec0d1d4f8221a9..41a681087060001c61c9f7aeb80f99a1770eedfa 100644 --- a/Graphics/Post.cpp +++ b/Graphics/Post.cpp @@ -1,4 +1,4 @@ -// $Id: Post.cpp,v 1.122 2007-08-28 07:03:42 geuzaine Exp $ +// $Id: Post.cpp,v 1.123 2007-08-28 08:38:47 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -71,6 +71,20 @@ double normValue(int numComp, double val[9]) return 0.; } +SVector3 getPointNormal(PView *p, double v) +{ + PViewOptions *opt = p->getOptions(); + SVector3 n(0., 0., 0.); + if(opt->PointType > 0){ + // if we draw spheres, we'll use the normalized value (between 0 + // and 1) stored in the first component of the normals to + // change the radius of the sphere + double d = opt->TmpMax - opt->TmpMin; + n[0] = (v - opt->TmpMin) / (d ? d : 1.); + } + return n; +} + void getLineNormal(PView *p, double x[2], double y[2], double z[2], double *v, SVector3 n[2], bool computeNormal) { @@ -243,7 +257,8 @@ void addOutlinePoint(PView *p, double xyz[NMAX][3], unsigned int color, bool pre=false, int i0=0) { if(pre) return; - p->va_points->add(&xyz[i0][0], &xyz[i0][1], &xyz[i0][2], 0, &color, 0, true); + SVector3 n = getPointNormal(p, 1.); + p->va_points->add(&xyz[i0][0], &xyz[i0][1], &xyz[i0][2], &n, &color, 0, true); } void addScalarPoint(PView *p, double xyz[NMAX][3], double val[NMAX][9], @@ -255,7 +270,8 @@ void addScalarPoint(PView *p, double xyz[NMAX][3], double val[NMAX][9], double vmin = opt->TmpMin, vmax = opt->TmpMax; if(opt->SaturateValues) saturate(1, val, vmin, vmax, i0); unsigned int col = opt->getColor(val[i0][0], vmin, vmax); - p->va_points->add(&xyz[i0][0], &xyz[i0][1], &xyz[i0][2], 0, &col, 0, unique); + SVector3 n = getPointNormal(p, val[i0][0]); + p->va_points->add(&xyz[i0][0], &xyz[i0][1], &xyz[i0][2], &n, &col, 0, unique); } void addOutlineLine(PView *p, double xyz[NMAX][3], unsigned int color, @@ -346,7 +362,8 @@ void addScalarLine(PView *p, double xyz[NMAX][3], double val[NMAX][9], int nb = IsoLine(x, y, z, v, iso, x2, y2, z2); if(nb == 1){ unsigned int color = opt->getColor(k, opt->NbIso); - p->va_points->add(x2, y2, z2, 0, &color, 0, unique); + SVector3 n = getPointNormal(p, iso); + p->va_points->add(x2, y2, z2, &n, &color, 0, unique); } if(vmin == vmax) break; } @@ -916,7 +933,12 @@ void drawArrays(PView *p, VertexArray *va, GLint type, bool useNormalArray) for(int i = 0; i < va->getNumVertices(); i++){ float *p = va->getVertexArray(3 * i); glColor4ubv((GLubyte *)va->getColorArray(4 * i)); - Draw_Sphere(opt->PointSize, p[0], p[1], p[2], opt->Light); + double f = 1.; + if(opt->PointType == 2){ + char *n = va->getNormalArray(3 * i); + f = char2float(*n); + } + Draw_Sphere(opt->PointSize * f, p[0], p[1], p[2], opt->Light); } } else if(type == GL_LINES && opt->LineType > 0){ @@ -925,14 +947,14 @@ void drawArrays(PView *p, VertexArray *va, GLint type, bool useNormalArray) float *p1 = va->getVertexArray(3 * (i + 1)); double x[2] = {p0[0], p1[0]}, y[2] = {p0[1], p1[1]}, z[2] = {p0[2], p1[2]}; glColor4ubv((GLubyte *)va->getColorArray(4 * i)); - if(opt->LineType == 1) - Draw_Cylinder(opt->LineWidth, x, y, z, opt->Light); - else{ + if(opt->LineType == 2){ char *n0 = va->getNormalArray(3 * i); char *n1 = va->getNormalArray(3 * (i + 1)); double v0 = char2float(*n0), v1 = char2float(*n1); Draw_TapCylinder(opt->LineWidth, v0, v1, 0., 1., x, y, z, opt->Light); } + else + Draw_Cylinder(opt->LineWidth, x, y, z, opt->Light); } } else{ diff --git a/Post/PViewOptions.cpp b/Post/PViewOptions.cpp index 9096242231b29bdbad1aa299673e3a29e03af32e..d2d04a06ceb8c89c25ead2d63c928f9f7e5b1e62 100644 --- a/Post/PViewOptions.cpp +++ b/Post/PViewOptions.cpp @@ -1,4 +1,4 @@ -// $Id: PViewOptions.cpp,v 1.8 2007-08-28 07:03:42 geuzaine Exp $ +// $Id: PViewOptions.cpp,v 1.9 2007-08-28 08:38:47 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -79,10 +79,10 @@ PViewOptions::PViewOptions() DrawStrings = DrawPoints = DrawLines = DrawTriangles = DrawQuadrangles = DrawTetrahedra = DrawHexahedra = DrawPrisms = DrawPyramids = DrawScalars = DrawVectors = DrawTensors = 1; - Boundary = 0; + Boundary = 1; PointType = LineType = 2; PointSize = 3; - LineWidth = 3; + LineWidth = 2; UseStipple = 0; ExternalViewIndex = ViewIndexForGenRaise = -1; UseGenRaise = 0;