diff --git a/Common/Options.cpp b/Common/Options.cpp index beedd4596372ed74e31684727db7e82bc8313232..4c637ed4433ecf3e2a073bf84c654737fa26619c 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.258 2005-09-22 15:20:38 remacle Exp $ +// $Id: Options.cpp,v 1.259 2005-10-09 17:45:37 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -6778,8 +6778,10 @@ unsigned int opt_geometry_color_points_select(OPT_ARGS_COL) unsigned int opt_geometry_color_lines_select(OPT_ARGS_COL) { - if(action & GMSH_SET) + if(action & GMSH_SET){ + if(CTX.color.geom.line_sel != val) CTX.mesh.changed = 1; CTX.color.geom.line_sel = val; + } #if defined(HAVE_FLTK) CCC(CTX.color.geom.line_sel, WID->geo_col[5]); #endif @@ -6788,8 +6790,10 @@ unsigned int opt_geometry_color_lines_select(OPT_ARGS_COL) unsigned int opt_geometry_color_surfaces_select(OPT_ARGS_COL) { - if(action & GMSH_SET) + if(action & GMSH_SET){ + if(CTX.color.geom.surface_sel != val) CTX.mesh.changed = 1; CTX.color.geom.surface_sel = val; + } #if defined(HAVE_FLTK) CCC(CTX.color.geom.surface_sel, WID->geo_col[6]); #endif diff --git a/Common/VertexArray.cpp b/Common/VertexArray.cpp index 79338e74b27544dfcabc2b5e597baf84cc930b13..064903560804021623bcc66b60b1b79644deec21 100644 --- a/Common/VertexArray.cpp +++ b/Common/VertexArray.cpp @@ -1,4 +1,4 @@ -// $Id: VertexArray.cpp,v 1.7 2005-10-09 15:58:40 geuzaine Exp $ +// $Id: VertexArray.cpp,v 1.8 2005-10-09 17:45:37 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -81,20 +81,6 @@ void VertexArray::add(float x, float y, float z, unsigned int col) List_Add(colors, &a); } -void VertexArray::global_change_color(unsigned int col) -{ - unsigned char r = UNPACK_RED(col); - unsigned char g = UNPACK_GREEN(col); - unsigned char b = UNPACK_BLUE(col); - unsigned char a = UNPACK_ALPHA(col); - for(int i = 0; i < List_Nbr(colors); i+= 4){ - List_Write(colors, i, &r); - List_Write(colors, i, &g); - List_Write(colors, i, &b); - List_Write(colors, i, &a); - } -} - static double theeye[3]; int compareTriEye(const void *a, const void *b) diff --git a/Common/VertexArray.h b/Common/VertexArray.h index a77b7193b50fe37324c7b4c7bd159b5d66820160..2d31f67ed3b4643caecbd96382c9bffd70f8e310 100644 --- a/Common/VertexArray.h +++ b/Common/VertexArray.h @@ -32,7 +32,6 @@ class VertexArray{ float n0, float n1, float n2, unsigned int col); void add(float x, float y, float z, unsigned int col); void sort(double eye[3]); - void global_change_color(unsigned int col); }; #endif diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index b09f98fe2888781d56048a0d48dd515c079e82d7..62b43469f807eb3692021b1ce679087232191a14 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.370 2005-09-22 15:20:38 remacle Exp $ +// $Id: Callbacks.cpp,v 1.371 2005-10-09 17:45:37 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -96,6 +96,7 @@ int SelectContour(int type, int num, List_T * List) break; } + Draw(); return k; } @@ -833,119 +834,114 @@ void options_restore_defaults_cb(CALLBACK_ARGS) void wizard_update_edges_cb(CALLBACK_ARGS) { - extern void BDS_To_Mesh(Mesh *m); - if (THEM && THEM->bds && WID) - { - const double angle = WID->swiz_value[0]->value() * M_PI / 180; - const int nb = (int) WID->swiz_value[3]->value(); - THEM->bds->classify (angle, nb); - BDS_To_Mesh (THEM); - Draw(); - } + extern void BDS_To_Mesh(Mesh *m); + if (THEM && THEM->bds && WID){ + const double angle = WID->swiz_value[0]->value() * M_PI / 180; + const int nb = (int) WID->swiz_value[3]->value(); + THEM->bds->classify (angle, nb); + BDS_To_Mesh (THEM); + Draw(); + } } void wizard_update_more_edges_cb(CALLBACK_ARGS) { - Vertex *v; - Curve *c; - Surface *s; - int n,p[100]; - extern void BDS_To_Mesh(Mesh *m); - if (THEM && THEM->bds && WID) - { - const double angle = WID->swiz_value[2]->value() * M_PI / 180; - const int nb_t = (int)(WID->swiz_value[3]->value() * M_PI / 180); + Vertex *v; + Curve *c; + Surface *s; + int n,p[100]; + extern void BDS_To_Mesh(Mesh *m); + + if (THEM && THEM->bds && WID) { + const double angle = WID->swiz_value[2]->value() * M_PI / 180; + const int nb_t = (int)(WID->swiz_value[3]->value() * M_PI / 180); + THEM->bds->classify (angle,nb_t); + BDS_To_Mesh (THEM); + Draw(); + n=0; + while(1) { + Msg(STATUS3N, "Adding new Model Edges"); + if(n == 0) + Msg(ONSCREEN, "Select Model Edges\n" + "[Press 'q' to abort or 'e' end]"); + if(n == 1) + Msg(ONSCREEN, "Select Model Edge\n" + "[Press 'u' to undo last selection, 'q' to abort, 'e' end]"); + char ib = SelectEntity(ENT_LINE, &v, &c, &s); + printf("ib = %c\n",ib); + if(ib == 'l') { + p[n++] = c->Num; + printf("line %d has been selected\n",c->Num); + } + if(ib == 'u') { + if(n > 0){ + ZeroHighlightEntityNum(p[n-1], 0, 0); + Draw(); + n--; + } + } + if(ib == 'q') { + ZeroHighlight(THEM); + Draw(); + Msg(ONSCREEN, ""); + Msg(STATUS3N, "Ready"); + const double angle = WID->swiz_value[0]->value() * M_PI / 180; THEM->bds->classify (angle,nb_t); BDS_To_Mesh (THEM); Draw(); - n=0; - while(1) { - Msg(STATUS3N, "Adding new Model Edges"); - if(n == 0) - Msg(ONSCREEN, "Select Model Edges\n" - "[Press 'q' to abort or 'e' end]"); - if(n == 1) - Msg(ONSCREEN, "Select Model Edge\n" - "[Press 'u' to undo last selection, 'q' to abort, 'e' end]"); - char ib = SelectEntity(ENT_LINE, &v, &c, &s); - printf("ib = %c\n",ib); - if(ib == 'l') { - p[n++] = c->Num; - printf("line %d has been selected\n",c->Num); - } - if(ib == 'u') { - if(n > 0){ - ZeroHighlightEntityNum(p[n-1], 0, 0); - Draw(); // inefficient, but hard to do otherwise - n--; - } - } - if(ib == 'q') { - ZeroHighlight(THEM); - Msg(ONSCREEN, ""); - Draw(); - Msg(STATUS3N, "Ready"); - const double angle = WID->swiz_value[0]->value() * M_PI / 180; - THEM->bds->classify (angle,nb_t); - BDS_To_Mesh (THEM); - Draw(); - break; - } - if(ib == 'e') { - for (int i=0;i<n;i++) - { - BDS_GeomEntity *g = THEM->bds->get_geom(p[i],1); - std::list<BDS_Edge*>::iterator it = g->e.begin(); - std::list<BDS_Edge*>::iterator ite = g->e.end(); - while (it!=ite){ - BDS_Edge *e = (*it); - e->status = 1; - ++it; - } - } - - ZeroHighlight(THEM); - Draw(); - n = 0; - } + break; + } + if(ib == 'e') { + for (int i=0;i<n;i++) { + BDS_GeomEntity *g = THEM->bds->get_geom(p[i],1); + std::list<BDS_Edge*>::iterator it = g->e.begin(); + std::list<BDS_Edge*>::iterator ite = g->e.end(); + while (it!=ite){ + BDS_Edge *e = (*it); + e->status = 1; + ++it; + } } + + ZeroHighlight(THEM); + Draw(); + n = 0; + } } + } } void wizard_update_tolerance_cb(CALLBACK_ARGS) { - extern void BDS_To_Mesh(Mesh *m); - - if (THEM && THEM->bds && WID) - { - const double tol = WID->swiz_value[1]->value(); - if (THEM->bds)delete THEM->bds; - THEM->bds = new BDS_Mesh; - printf("reading file %s\n",WID->surfmesh_filename.c_str()); - THEM->bds->read_stl ( WID->surfmesh_filename.c_str(), tol ); - BDS_To_Mesh (THEM); - SetBoundingBox(); - char a[25]; - sprintf(a,"%d",THEM->bds->points.size()); - WID->swiz_output[0]->value(a); - Draw(); - } + extern void BDS_To_Mesh(Mesh *m); + + if (THEM && THEM->bds && WID) { + const double tol = WID->swiz_value[1]->value(); + if (THEM->bds)delete THEM->bds; + THEM->bds = new BDS_Mesh; + printf("reading file %s\n",WID->surfmesh_filename.c_str()); + THEM->bds->read_stl ( WID->surfmesh_filename.c_str(), tol ); + BDS_To_Mesh (THEM); + SetBoundingBox(); + char a[25]; + sprintf(a,"%d",THEM->bds->points.size()); + WID->swiz_output[0]->value(a); + Draw(); + } } void wizard_update_next_cb(CALLBACK_ARGS) { - if (WID) - { - WID->swiz_wiz->next(); - } + if (WID) { + WID->swiz_wiz->next(); + } } void wizard_update_prev_cb(CALLBACK_ARGS) { - if (WID) - { - WID->swiz_wiz->prev(); - } + if (WID) { + WID->swiz_wiz->prev(); + } } void options_ok_cb(CALLBACK_ARGS) @@ -1947,7 +1943,7 @@ static void _new_multiline(int type) if(ib == 'u') { if(n > 0){ ZeroHighlightEntityNum(p[n-1], 0, 0); - Draw(); // inefficient, but hard to do otherwise + Draw(); n--; } } @@ -1994,7 +1990,7 @@ void geometry_elementary_add_new_line_cb(CALLBACK_ARGS) if(ib == 'u') { if(n > 0){ ZeroHighlightEntityNum(p[n-1], 0, 0); - Draw(); // inefficient, but hard to do otherwise + Draw(); n--; } } @@ -2055,7 +2051,7 @@ void geometry_elementary_add_new_circle_cb(CALLBACK_ARGS) if(ib == 'u') { if(n > 0){ ZeroHighlightEntityNum(p[n-1], 0, 0); - Draw(); // inefficient, but hard to do otherwise + Draw(); n--; } } @@ -2065,7 +2061,7 @@ void geometry_elementary_add_new_circle_cb(CALLBACK_ARGS) break; } if(n == 3) { - add_circ(p[0], p[1], p[2], CTX.filename); /* begin, center, end */ + add_circ(p[0], p[1], p[2], CTX.filename); // begin, center, end ZeroHighlight(THEM); Draw(); n = 0; @@ -2109,7 +2105,7 @@ void geometry_elementary_add_new_ellipse_cb(CALLBACK_ARGS) if(ib == 'u') { if(n > 0){ ZeroHighlightEntityNum(p[n-1], 0, 0); - Draw(); // inefficient, but hard to do otherwise + Draw(); n--; } } @@ -2710,7 +2706,7 @@ static void _add_physical(char *what) ZeroHighlightEntityNum((type == ENT_POINT) ? num : 0, (type == ENT_LINE) ? num : 0, (type == ENT_SURFACE) ? num : 0); - Draw(); // inefficient, but hard to do otherwise + Draw(); List_Pop(List1); } } @@ -2880,7 +2876,7 @@ void mesh_define_length_cb(CALLBACK_ARGS) if(ib == 'u') { if(n > 0){ ZeroHighlightEntityNum(p[n-1], 0, 0); - Draw(); // inefficient, but hard to do otherwise + Draw(); n--; } } @@ -2927,7 +2923,7 @@ void mesh_define_recombine_cb(CALLBACK_ARGS) if(ib == 'u') { if(n > 0){ ZeroHighlightEntityNum(0, 0, p[n-1]); - Draw(); // inefficient, but hard to do otherwise + Draw(); n--; } } @@ -3000,7 +2996,7 @@ static void _add_transfinite_elliptic(int type, int dim) if(dim == 1) { if(n > 0){ ZeroHighlightEntityNum(0, p[n-1], 0); - Draw(); // inefficient, but hard to do otherwise + Draw(); n--; } } @@ -3032,7 +3028,7 @@ static void _add_transfinite_elliptic(int type, int dim) if(ib == 'u') { if(n > ((dim == 2) ? 1 : 0)){ ZeroHighlightEntityNum(p[n-1], 0, 0); - Draw(); // inefficient, but hard to do otherwise + Draw(); n--; } } diff --git a/Fltk/Opengl.cpp b/Fltk/Opengl.cpp index 188da306ce3e52b00d99a4490a25ae9ca688af37..e1a75d7ef79eab7420d3e87877cdf40a92c0ac4a 100644 --- a/Fltk/Opengl.cpp +++ b/Fltk/Opengl.cpp @@ -1,4 +1,4 @@ -// $Id: Opengl.cpp,v 1.53 2005-10-09 15:58:41 geuzaine Exp $ +// $Id: Opengl.cpp,v 1.54 2005-10-09 17:45:37 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -244,6 +244,7 @@ char SelectEntity(int type, Vertex ** v, Curve ** c, Surface ** s) Process_SelectionBuffer(Fl::event_x(), Fl::event_y(), &numhits, hits); if(Filter_SelectionBuffer(WID->selection, numhits, hits, v, c, s, &M)){ HighlightEntity(*v, *c, *s, 1); + Draw(); WID->selection = ENT_NONE; return 'l'; } diff --git a/Graphics/Geom.cpp b/Graphics/Geom.cpp index 4e77769268905706b5e33aa7882444082a1d87ca..ddad24f67feedcd584a406e0cc7540a4106a1df2 100644 --- a/Graphics/Geom.cpp +++ b/Graphics/Geom.cpp @@ -1,4 +1,4 @@ -// $Id: Geom.cpp,v 1.91 2005-10-09 15:58:41 geuzaine Exp $ +// $Id: Geom.cpp,v 1.92 2005-10-09 17:45:37 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -123,7 +123,7 @@ void Draw_Curve(void *a, void *b) glPushName(c->Num); } - if(c->ipar[3]) { + if(c->ipar[3] > 0) { glLineWidth(CTX.geom.line_sel_width); gl2psLineWidth(CTX.geom.line_sel_width * CTX.print.eps_line_width_factor); glColor4ubv((GLubyte *) & CTX.color.geom.line_sel); @@ -170,7 +170,7 @@ void Draw_Curve(void *a, void *b) x[1] = e->p2->X; y[1] = e->p2->Y; z[1] = e->p2->Z; - Draw_Cylinder(c->ipar[3] ? CTX.geom.line_sel_width : CTX.geom.line_width, + Draw_Cylinder(c->ipar[3] > 0 ? CTX.geom.line_sel_width : CTX.geom.line_width, x, y, z, CTX.geom.light); } ++it; @@ -190,7 +190,7 @@ void Draw_Curve(void *a, void *b) x[1] = dv.Pos.X; y[1] = dv.Pos.Y; z[1] = dv.Pos.Z; - Draw_Cylinder(c->ipar[3] ? CTX.geom.line_sel_width : CTX.geom.line_width, + Draw_Cylinder(c->ipar[3] > 0 ? CTX.geom.line_sel_width : CTX.geom.line_width, x, y, z, CTX.geom.light); } if(CTX.geom.line_type == 2) { @@ -622,7 +622,7 @@ void Draw_Surface(void *a, void *b) glPushName(s->Num); } - if(s->ipar[4]) { + if(s->ipar[4] > 0) { glLineWidth(CTX.geom.line_sel_width / 2.); gl2psLineWidth(CTX.geom.line_sel_width / 2. * CTX.print.eps_line_width_factor); @@ -682,16 +682,19 @@ void HighlightEntity(Vertex * v, Curve * c, Surface * s, int permanent) Curve *cc; char Message[256], temp[256]; - if(permanent){ - // we want to draw incrementally (in-between to "Draw()" calls!): - // we need to make sure that the opengl context is set correctly - SetOpenglContext(); - } + // Note: in Gmsh < 1.61, we used to draw permanent highlights (the + // "red" selected lines, etc.) using incrmental drawing, i.e., by + // drawing "over" the current picture in-between Draw() calls. This + // was fine for simple overlays on points and lines (that we could + // draw with a slightly larger width so that they would cover the + // old ones), but it does not work well when drawing surfaces, + // post-pro views, etc. And since real cross-platform overlays are + // unmanageable, the best solution is actually to redraw the whole + // scene. This is the approach we follow now. if(v) { if(permanent){ v->Frozen = 1; - Draw_Geo_Point(&v,NULL); } else{ Msg(STATUS1N, "Point %d {%.5g,%.5g,%.5g} (%.5g)", v->Num, v->Pos.X, @@ -700,10 +703,7 @@ void HighlightEntity(Vertex * v, Curve * c, Surface * s, int permanent) } else if(c) { if(permanent){ - c->ipar[3] = 1; - Draw_Curve(&c,NULL); - CTX.mesh.changed = 1; // a bit brutal, but the simplest solution - Draw_Mesh_Curve(&c,NULL); + c->ipar[3] = 2; } else{ if(c->beg && c->end) @@ -714,10 +714,7 @@ void HighlightEntity(Vertex * v, Curve * c, Surface * s, int permanent) } else if(s) { if(permanent){ - s->ipar[4] = 1; - Draw_Surface(&s,NULL); - CTX.mesh.changed = 1; // a bit brutal, but the simplest solution - Draw_Mesh_Surface(&s,NULL); + s->ipar[4] = 2; } else{ int nbg = List_Nbr(s->Generatrices); @@ -755,6 +752,7 @@ void HighlightEntity(Vertex * v, Curve * c, Surface * s, int permanent) if(!permanent) Msg(STATUS1N, " "); } + } void HighlightEntityNum(int v, int c, int s, int permanent) @@ -785,21 +783,13 @@ void ZeroHighlightPoint(void *a, void *b) void ZeroHighlightCurve(void *a, void *b) { Curve *c = *(Curve **) a; - c->ipar[3] = 0; - // the curve colors might have changed (and in complicated ways, - // e.g., if we color by partition, so we cannot use the - // global_change_color trick) - CTX.mesh.changed = 1; + c->ipar[3] = -2; } void ZeroHighlightSurface(void *a, void *b) { Surface *s = *(Surface **) a; - s->ipar[4] = 0; - // the surface colors might have changed (and in complicated ways, - // e.g., if we color by partition, so we cannot use the - // global_change_color trick) - CTX.mesh.changed = 1; + s->ipar[4] = -2; } void ZeroHighlight(Mesh * m) diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp index f9b3035d1d75a0cc6a2f47fa921a9768526b707d..205c8ee3b7608e3a28ab2dd6bde5aa087530258b 100644 --- a/Graphics/Mesh.cpp +++ b/Graphics/Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: Mesh.cpp,v 1.138 2005-10-09 15:58:41 geuzaine Exp $ +// $Id: Mesh.cpp,v 1.139 2005-10-09 17:45:37 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -425,7 +425,10 @@ void Draw_Mesh_Surface(void *a, void *b) } if(CTX.mesh.vertex_arrays){ - if(CTX.mesh.changed){ + if(CTX.mesh.changed || s->ipar[4] == 2 || s->ipar[4] == -2){ + if(s->ipar[4] == 2) s->ipar[4] = 1; + if(s->ipar[4] == -2) s->ipar[4] = -1; + Msg(DEBUG, "regenerate surface mesh vertex arrays"); thePhysical = getFirstPhysical(MSH_PHYSICAL_SURFACE, s->Num); // triangles @@ -514,7 +517,10 @@ void Draw_Mesh_Curve(void *a, void *b) theColor = c->Color; if(CTX.mesh.vertex_arrays){ - if(CTX.mesh.changed){ + if(CTX.mesh.changed || c->ipar[3] == 2 || c->ipar[3] == -2){ + if(c->ipar[3] == 2) c->ipar[3] = 1; + if(c->ipar[3] == -2) c->ipar[3] = -1; + Msg(DEBUG, "regenerate curve mesh vertex array"); thePhysical = getFirstPhysical(MSH_PHYSICAL_LINE, c->Num); if(c->LinVertexArray) delete c->LinVertexArray; @@ -644,7 +650,7 @@ void Draw_Mesh_Line(void *a, void *b) } unsigned int col; - if(theCurve && theCurve->ipar[3]) + if(theCurve && theCurve->ipar[3] > 0) col = CTX.color.geom.line_sel; else if(theColor.type) col = theColor.mesh; @@ -922,7 +928,7 @@ void Draw_Mesh_Triangle(void *a, void *b) return; unsigned int col; - if(theSurface && theSurface->ipar[4]) + if(theSurface && theSurface->ipar[4] > 0) col = CTX.color.geom.surface_sel; else if(theColor.type) col = theColor.mesh; @@ -1102,7 +1108,7 @@ void Draw_Mesh_Quadrangle(void *a, void *b) return; unsigned int col; - if(theSurface && theSurface->ipar[4]) + if(theSurface && theSurface->ipar[4] > 0) col = CTX.color.geom.surface_sel; else if(theColor.type) col = theColor.mesh; diff --git a/TODO b/TODO index 5836d23c43408033310ecc1f1ec4851bbdf10fab..8a60e5e31efd874a6e9cdf51b049aa48a3e2e7fb 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -$Id: TODO,v 1.101 2005-10-09 15:58:40 geuzaine Exp $ +$Id: TODO,v 1.102 2005-10-09 17:45:37 geuzaine Exp $ ******************************************************************** @@ -7,14 +7,6 @@ remove entities from a selection by clicking on them ******************************************************************** -We should fine-grain CTX.mesh.changed so that we can keep track of -changes surface by surface, volume by volume, etc. This would speed up -mesh selection quite a bit on large models (since we would only have -to regenerate the vertex array for the surface/volume that has -changed, and not everything) - -******************************************************************** - On Windows without Cygwin: - rewrite solver interface (GmshServer and GmshClient) - Functions in parser don't seem to work