From a0fa9e8f79c40d65dba66ba32674d1b86cdad2ad Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Tue, 23 Jan 2007 08:01:08 +0000
Subject: [PATCH] simplify selection colors (keep only one) and add 3 highlight
 colors

---
 Common/Context.h              |  2 +-
 Common/DefaultOptions.h       | 20 ++++++++++----------
 Common/Options.cpp            | 34 +++++++++++++++++-----------------
 Common/Options.h              |  8 ++++----
 Graphics/Geom.cpp             | 20 ++++++++++----------
 Graphics/Mesh.cpp             | 16 +++-------------
 doc/texinfo/opt_geometry.texi | 25 +++++++++++++++----------
 doc/texinfo/opt_mesh.texi     |  2 +-
 8 files changed, 61 insertions(+), 66 deletions(-)

diff --git a/Common/Context.h b/Common/Context.h
index a775c1bb1b..d47f674dad 100644
--- a/Common/Context.h
+++ b/Common/Context.h
@@ -224,7 +224,7 @@ public :
     unsigned int ambient_light[6], diffuse_light[6], specular_light[6];
     struct{
       unsigned int point, line, surface, volume;
-      unsigned int point_sel, line_sel, surface_sel, volume_sel;
+      unsigned int selection, highlight[3];
       unsigned int tangents, normals;
     } geom;
     struct{
diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h
index 28cef443db..44be2ace24 100644
--- a/Common/DefaultOptions.h
+++ b/Common/DefaultOptions.h
@@ -1418,18 +1418,18 @@ StringXColor GeometryOptions_Color[] = {
   { F|O, "Volumes" , opt_geometry_color_volumes ,
     {255, 255, 0, 255}, {255, 255, 0, 255}, {0, 0, 0, 255},
     "Normal geometry volume color" },
-  { F|O, "PointsSelect" , opt_geometry_color_points_select ,
+  { F|O, "Selection" , opt_geometry_color_selection ,
     {255, 0, 0, 255}, {255, 0, 0, 255}, {255, 0, 0, 255},
-    "Selected geometry point color" },
-  { F|O, "LinesSelect" , opt_geometry_color_lines_select ,
+    "Selected geometry color" },
+  { F|O, "HighlightZero" , opt_geometry_color_highlight0 ,
     {255, 0, 0, 255}, {255, 0, 0, 255}, {255, 0, 0, 255},
-    "Selected geometry curve color" },
-  { F|O, "SurfacesSelect" , opt_geometry_color_surfaces_select ,
-    {255, 0, 0, 255}, {255, 0, 0, 255}, {255, 0, 0, 255},
-    "Selected geometry surface color" },
-  { F|O, "VolumesSelect" , opt_geometry_color_volumes_select ,
-    {255, 0, 0, 255}, {255, 0, 0, 255}, {255, 0, 0, 255},
-    "Selected geometry volume color" },
+    "Highlight 0 color" },
+  { F|O, "HighlightOne" , opt_geometry_color_highlight1 ,
+    {255, 150, 0, 255}, {255, 150, 0, 255}, {255, 150, 0, 255},
+    "Highlight 1 color" },
+  { F|O, "HighlightTwo" , opt_geometry_color_highlight2 ,
+    {255, 255, 0, 255}, {255, 255, 0, 255}, {255, 255, 0, 255},
+    "Highlight 2 color" },
   { F|O, "Tangents" , opt_geometry_color_tangents ,
     {255, 255, 0, 255}, {255, 255, 0, 255}, {0, 0, 0, 255},
     "Tangent geometry vectors color" },
diff --git a/Common/Options.cpp b/Common/Options.cpp
index 9f00485660..62b3ba82b9 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -1,4 +1,4 @@
-// $Id: Options.cpp,v 1.330 2007-01-22 16:31:42 geuzaine Exp $
+// $Id: Options.cpp,v 1.331 2007-01-23 08:01:07 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -7105,46 +7105,46 @@ unsigned int opt_geometry_color_volumes(OPT_ARGS_COL)
   return CTX.color.geom.volume;
 }
 
-unsigned int opt_geometry_color_points_select(OPT_ARGS_COL)
+unsigned int opt_geometry_color_selection(OPT_ARGS_COL)
 {
   if(action & GMSH_SET)
-    CTX.color.geom.point_sel = val;
+    CTX.color.geom.selection = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.geom.point_sel, WID->geo_col[4]);
+  CCC(CTX.color.geom.selection, WID->geo_col[4]);
 #endif
-  return CTX.color.geom.point_sel;
+  return CTX.color.geom.selection;
 }
 
-unsigned int opt_geometry_color_lines_select(OPT_ARGS_COL)
+unsigned int opt_geometry_color_highlight0(OPT_ARGS_COL)
 {
   if(action & GMSH_SET){
-    CTX.color.geom.line_sel = val;
+    CTX.color.geom.highlight[0] = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.geom.line_sel, WID->geo_col[5]);
+  CCC(CTX.color.geom.highlight[0], WID->geo_col[5]);
 #endif
-  return CTX.color.geom.line_sel;
+  return CTX.color.geom.highlight[0];
 }
 
-unsigned int opt_geometry_color_surfaces_select(OPT_ARGS_COL)
+unsigned int opt_geometry_color_highlight1(OPT_ARGS_COL)
 {
   if(action & GMSH_SET){
-    CTX.color.geom.surface_sel = val;
+    CTX.color.geom.highlight[1] = val;
   }
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.geom.surface_sel, WID->geo_col[6]);
+  CCC(CTX.color.geom.highlight[1], WID->geo_col[6]);
 #endif
-  return CTX.color.geom.surface_sel;
+  return CTX.color.geom.highlight[1];
 }
 
-unsigned int opt_geometry_color_volumes_select(OPT_ARGS_COL)
+unsigned int opt_geometry_color_highlight2(OPT_ARGS_COL)
 {
   if(action & GMSH_SET)
-    CTX.color.geom.volume_sel = val;
+    CTX.color.geom.highlight[2] = val;
 #if defined(HAVE_FLTK)
-  CCC(CTX.color.geom.volume_sel, WID->geo_col[7]);
+  CCC(CTX.color.geom.highlight[2], WID->geo_col[7]);
 #endif
-  return CTX.color.geom.volume_sel;
+  return CTX.color.geom.highlight[2];
 }
 
 unsigned int opt_geometry_color_tangents(OPT_ARGS_COL)
diff --git a/Common/Options.h b/Common/Options.h
index adeed0ef82..751ec42d12 100644
--- a/Common/Options.h
+++ b/Common/Options.h
@@ -649,10 +649,10 @@ unsigned int opt_geometry_color_points(OPT_ARGS_COL);
 unsigned int opt_geometry_color_lines(OPT_ARGS_COL);
 unsigned int opt_geometry_color_surfaces(OPT_ARGS_COL);
 unsigned int opt_geometry_color_volumes(OPT_ARGS_COL);
-unsigned int opt_geometry_color_points_select(OPT_ARGS_COL);
-unsigned int opt_geometry_color_lines_select(OPT_ARGS_COL);
-unsigned int opt_geometry_color_surfaces_select(OPT_ARGS_COL);
-unsigned int opt_geometry_color_volumes_select(OPT_ARGS_COL);
+unsigned int opt_geometry_color_selection(OPT_ARGS_COL);
+unsigned int opt_geometry_color_highlight0(OPT_ARGS_COL);
+unsigned int opt_geometry_color_highlight1(OPT_ARGS_COL);
+unsigned int opt_geometry_color_highlight2(OPT_ARGS_COL);
 unsigned int opt_geometry_color_tangents(OPT_ARGS_COL);
 unsigned int opt_geometry_color_normals(OPT_ARGS_COL);
 unsigned int opt_mesh_color_points(OPT_ARGS_COL); 
diff --git a/Graphics/Geom.cpp b/Graphics/Geom.cpp
index f6749ae192..f61fe21001 100644
--- a/Graphics/Geom.cpp
+++ b/Graphics/Geom.cpp
@@ -1,4 +1,4 @@
-// $Id: Geom.cpp,v 1.128 2007-01-22 16:31:43 geuzaine Exp $
+// $Id: Geom.cpp,v 1.129 2007-01-23 08:01:08 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -44,7 +44,7 @@ class drawGVertex {
     if(v->getSelection()) {
       glPointSize(CTX.geom.point_sel_size);
       gl2psPointSize(CTX.geom.point_sel_size * CTX.print.eps_point_size_factor);
-      glColor4ubv((GLubyte *) & CTX.color.geom.point_sel);
+      glColor4ubv((GLubyte *) & CTX.color.geom.selection);
     }
     else {
       glPointSize(CTX.geom.point_size);
@@ -55,9 +55,9 @@ class drawGVertex {
     if(CTX.geom.highlight_orphans){
       std::list<GEdge*> edges = v->edges();
       if(edges.size() == 0)
-	glColor3d(1., 0., 0.);
+	glColor4ubv((GLubyte *) & CTX.color.geom.highlight[0]);
       else if(edges.size() == 1)
-	glColor3d(1., 0.6, 0.);
+	glColor4ubv((GLubyte *) & CTX.color.geom.highlight[1]);
     }
 
     if(CTX.geom.points) {
@@ -109,7 +109,7 @@ class drawGEdge {
     if(e->getSelection()) {
       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);
+      glColor4ubv((GLubyte *) & CTX.color.geom.selection);
     }
     else {
       glLineWidth(CTX.geom.line_width);
@@ -120,9 +120,9 @@ class drawGEdge {
     if(CTX.geom.highlight_orphans){
       std::list<GFace*> faces = e->faces();
       if(faces.size() == 0)
-	glColor3d(1., 0., 0.);
+	glColor4ubv((GLubyte *) & CTX.color.geom.highlight[0]);
       else if(faces.size() == 1)
-	glColor3d(1., 0.6, 0.);
+	glColor4ubv((GLubyte *) & CTX.color.geom.highlight[1]);
     }
 
     Range<double> t_bounds = e->parBounds(0);
@@ -252,7 +252,7 @@ class drawGFace {
     glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
     //glEnable(GL_LIGHTING);
     //glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
-    glColor4ubv((GLubyte *) & CTX.color.geom.surface_sel);
+    glColor4ubv((GLubyte *) & CTX.color.geom.selection);
     glBegin(GL_QUADS);
     for(int i = 1; i < N; i++){
       for(int j = 1; j < N; j++){
@@ -395,7 +395,7 @@ public :
       glLineWidth(CTX.geom.line_sel_width / 2.);
       gl2psLineWidth(CTX.geom.line_sel_width / 2. *
 		     CTX.print.eps_line_width_factor);
-      glColor4ubv((GLubyte *) & CTX.color.geom.surface_sel);
+      glColor4ubv((GLubyte *) & CTX.color.geom.selection);
     }
     else {
       glLineWidth(CTX.geom.line_width / 2.);
@@ -431,7 +431,7 @@ class drawGRegion {
     }
     
     if(r->getSelection())
-      glColor4ubv((GLubyte *) & CTX.color.geom.volume_sel);
+      glColor4ubv((GLubyte *) & CTX.color.geom.selection);
     else
       glColor4ubv((GLubyte *) & CTX.color.geom.volume);
     
diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp
index 91c846d8ab..4d2596beb4 100644
--- a/Graphics/Mesh.cpp
+++ b/Graphics/Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: Mesh.cpp,v 1.192 2007-01-22 16:31:43 geuzaine Exp $
+// $Id: Mesh.cpp,v 1.193 2007-01-23 08:01:08 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -36,12 +36,7 @@ extern Context_T CTX;
 static unsigned int getColorByEntity(GEntity *e)
 {
   if(e->getSelection()){ // selection
-    switch(e->dim()){
-    case 0: return CTX.color.geom.point_sel;
-    case 1: return CTX.color.geom.line_sel;
-    case 2: return CTX.color.geom.surface_sel;
-    default: return CTX.color.geom.volume_sel;
-    }
+    return CTX.color.geom.selection;
   }
   else if(e->useColor()){ // forced from a script
     return e->getColor();
@@ -62,12 +57,7 @@ static unsigned int getColorByEntity(GEntity *e)
 static unsigned int getColorByElement(MElement *ele)
 {
   if(ele->getVisibility() > 1){ // selection
-    switch(ele->getDim()){
-    case 0: return CTX.color.geom.point_sel;
-    case 1: return CTX.color.geom.line_sel;
-    case 2: return CTX.color.geom.surface_sel;
-    default: return CTX.color.geom.volume_sel;
-    }
+    return CTX.color.geom.selection;
   }
   else if(CTX.mesh.color_carousel == 0){ // by element type
     switch(ele->getNumEdges()){
diff --git a/doc/texinfo/opt_geometry.texi b/doc/texinfo/opt_geometry.texi
index 79b8cc95c4..58a295f5db 100644
--- a/doc/texinfo/opt_geometry.texi
+++ b/doc/texinfo/opt_geometry.texi
@@ -19,6 +19,11 @@ Number of control points for splines created during extrusion@*
 Default value: @code{5}@*
 Saved in: @code{General.OptionsFileName}
 
+@item Geometry.HighlightOrphans
+Highlight orphan entities (lines connected to a single surface, etc.)?@*
+Default value: @code{0}@*
+Saved in: @code{General.OptionsFileName}
+
 @item Geometry.Light
 Enable lighting for the geometry@*
 Default value: @code{1}@*
@@ -174,24 +179,24 @@ Normal geometry volume color@*
 Default value: @code{@{255,255,0@}}@*
 Saved in: @code{General.OptionsFileName}
 
-@item Geometry.Color.PointsSelect
-Selected geometry point color@*
+@item Geometry.Color.Selection
+Selected geometry color@*
 Default value: @code{@{255,0,0@}}@*
 Saved in: @code{General.OptionsFileName}
 
-@item Geometry.Color.LinesSelect
-Selected geometry curve color@*
+@item Geometry.Color.HighlightZero
+Highlight 0 color@*
 Default value: @code{@{255,0,0@}}@*
 Saved in: @code{General.OptionsFileName}
 
-@item Geometry.Color.SurfacesSelect
-Selected geometry surface color@*
-Default value: @code{@{255,0,0@}}@*
+@item Geometry.Color.HighlightOne
+Highlight 1 color@*
+Default value: @code{@{255,150,0@}}@*
 Saved in: @code{General.OptionsFileName}
 
-@item Geometry.Color.VolumesSelect
-Selected geometry volume color@*
-Default value: @code{@{255,0,0@}}@*
+@item Geometry.Color.HighlightTwo
+Highlight 2 color@*
+Default value: @code{@{255,255,0@}}@*
 Saved in: @code{General.OptionsFileName}
 
 @item Geometry.Color.Tangents
diff --git a/doc/texinfo/opt_mesh.texi b/doc/texinfo/opt_mesh.texi
index 86097cc7cc..a7cf88c753 100644
--- a/doc/texinfo/opt_mesh.texi
+++ b/doc/texinfo/opt_mesh.texi
@@ -15,7 +15,7 @@ Default value: @code{1}@*
 Saved in: @code{General.OptionsFileName}
 
 @item Mesh.Algorithm3D
-3D mesh algorithm (1=delaunay, 4=netgen)@*
+3D mesh algorithm (1=delaunay, 4=netgen, 5=tetgen)@*
 Default value: @code{4}@*
 Saved in: @code{General.OptionsFileName}
 
-- 
GitLab