From 86f7f334833ca7413b81ce143815a6f71fb04ec7 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Mon, 6 Jun 2011 07:09:31 +0000
Subject: [PATCH] make num_sub_edge options available in gui

---
 Common/Context.cpp    |  2 +-
 Common/Options.cpp    | 28 ++++++++++++++++++++++++----
 Fltk/menuWindow.cpp   |  2 +-
 Fltk/optionWindow.cpp | 25 ++++++++++++++++++++++---
 4 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/Common/Context.cpp b/Common/Context.cpp
index 1284cc7b6e..1c4fcba668 100644
--- a/Common/Context.cpp
+++ b/Common/Context.cpp
@@ -77,7 +77,7 @@ CTX::CTX()
   mesh.volumesEdges = mesh.volumesFaces = mesh.surfacesEdges = mesh.surfacesFaces = 0;
   mesh.volumesFaces = mesh.surfacesEdges = mesh.surfacesFaces = 0;
   mesh.smoothInternalEdges = mesh.smoothNormals = mesh.reverseAllNormals = 0;
-  mesh.explode = mesh.angleSmoothNormals = 0;
+  mesh.explode = mesh.numSubEdges = mesh.angleSmoothNormals = 0;
   mesh.colorCarousel = 0;
   color.mesh.tangents = color.mesh.tetrahedron = color.mesh.triangle = 0;
   color.mesh.prism = color.mesh.pyramid = color.mesh.hexahedron = 0;
diff --git a/Common/Options.cpp b/Common/Options.cpp
index ebbd347991..ea727f097b 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -4775,8 +4775,17 @@ double opt_geometry_old_newreg(OPT_ARGS_NUM)
 
 double opt_geometry_num_sub_edges(OPT_ARGS_NUM)
 {
-  if(action & GMSH_SET)
+  if(action & GMSH_SET){
     CTX::instance()->geom.numSubEdges = (int)val;
+    if(CTX::instance()->geom.numSubEdges < 1)
+      CTX::instance()->geom.numSubEdges = 1;
+  }
+#if defined(HAVE_FLTK)
+  if(FlGui::available() && (action & GMSH_GUI)) {
+    FlGui::instance()->options->geo.value[19]->value
+      (CTX::instance()->geom.numSubEdges);
+  }
+#endif
   return CTX::instance()->geom.numSubEdges;
 }
 
@@ -4892,6 +4901,7 @@ double opt_mesh_optimize_netgen(OPT_ARGS_NUM)
 #endif
   return CTX::instance()->mesh.optimizeNetgen;
 }
+
 double opt_mesh_remove_4_triangles(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
@@ -4908,7 +4918,7 @@ double opt_mesh_remove_4_triangles(OPT_ARGS_NUM)
 double opt_mesh_refine_steps(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
-    CTX::instance()->mesh.refineSteps =(int) val;
+    CTX::instance()->mesh.refineSteps = (int)val;
   return CTX::instance()->mesh.refineSteps;
 }
 
@@ -4927,8 +4937,18 @@ double opt_mesh_normals(OPT_ARGS_NUM)
 
 double opt_mesh_num_sub_edges(OPT_ARGS_NUM)
 {
-  if(action & GMSH_SET)
-    CTX::instance()->mesh.numSubEdges =(int) val;
+  if(action & GMSH_SET){
+    if(CTX::instance()->mesh.numSubEdges != val) 
+      CTX::instance()->mesh.changed |= (ENT_LINE | ENT_SURFACE | ENT_VOLUME);
+    CTX::instance()->mesh.numSubEdges = (int)val;
+    if(CTX::instance()->mesh.numSubEdges < 1)
+      CTX::instance()->mesh.numSubEdges = 1;
+  }
+#if defined(HAVE_FLTK)
+  if(FlGui::available() && (action & GMSH_GUI))
+    FlGui::instance()->options->mesh.value[14]->value
+      (CTX::instance()->mesh.numSubEdges);
+#endif
   return CTX::instance()->mesh.numSubEdges;
 }
 
diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp
index d2f64cc629..d2636d04bc 100644
--- a/Fltk/menuWindow.cpp
+++ b/Fltk/menuWindow.cpp
@@ -111,7 +111,7 @@ static const char *input_formats =
   "STL Surface Mesh" TT "*.stl" NN
   "VTK Mesh" TT "*.vtk" NN
   "VRML Surface Mesh" TT "*.{wrl,vrml}" NN
-  "PLY2 Surface Mesh" TT "*.{ply2}" NN
+  "PLY2 Surface Mesh" TT "*.ply2" NN
   "BMP" TT "*.bmp" NN
 #if defined(HAVE_LIBJPEG)
   "JPEG" TT "*.{jpg,jpeg}" NN
diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp
index 2cedcb5e5c..55da5d110a 100644
--- a/Fltk/optionWindow.cpp
+++ b/Fltk/optionWindow.cpp
@@ -403,6 +403,7 @@ static void geometry_options_ok_cb(Fl_Widget *w, void *data)
   opt_geometry_offset0(0, GMSH_SET, o->geo.value[10]->value());
   opt_geometry_offset1(0, GMSH_SET, o->geo.value[14]->value());
   opt_geometry_offset2(0, GMSH_SET, o->geo.value[18]->value());
+  opt_geometry_num_sub_edges(0, GMSH_SET, o->geo.value[19]->value());
 
   opt_geometry_point_type(0, GMSH_SET, o->geo.choice[0]->value());
   opt_geometry_line_type(0, GMSH_SET, o->geo.choice[1]->value());
@@ -466,6 +467,7 @@ static void mesh_options_ok_cb(Fl_Widget *w, void *data)
   opt_mesh_normals(0, GMSH_SET, o->mesh.value[8]->value());
   opt_mesh_explode(0, GMSH_SET, o->mesh.value[9]->value());
   opt_mesh_tangents(0, GMSH_SET, o->mesh.value[13]->value());
+  opt_mesh_num_sub_edges(0, GMSH_SET, o->mesh.value[14]->value());
   opt_mesh_point_size(0, GMSH_SET, o->mesh.value[10]->value());
   opt_mesh_line_width(0, GMSH_SET, o->mesh.value[11]->value());
   opt_mesh_label_sampling(0, GMSH_SET, o->mesh.value[12]->value());
@@ -1974,8 +1976,16 @@ optionWindow::optionWindow(int deltaFontSize)
       geo.choice[1]->align(FL_ALIGN_RIGHT);     
       geo.choice[1]->callback(geometry_options_ok_cb);
 
+      geo.value[19] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Line subdivisions");
+      geo.value[19]->minimum(1);
+      geo.value[19]->maximum(50);
+      geo.value[19]->step(1);
+      geo.value[19]->align(FL_ALIGN_RIGHT);
+      geo.value[19]->callback(geometry_options_ok_cb);
+
       geo.value[4] = new Fl_Value_Input
-        (L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Line width");
+        (L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Line width");
       geo.value[4]->minimum(0.1);
       geo.value[4]->maximum(50);
       geo.value[4]->step(0.1);
@@ -1983,7 +1993,7 @@ optionWindow::optionWindow(int deltaFontSize)
       geo.value[4]->callback(geometry_options_ok_cb);
 
       geo.value[6] = new Fl_Value_Input
-        (L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Selected line width");
+        (L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Selected line width");
       geo.value[6]->minimum(0.1);
       geo.value[6]->maximum(50);
       geo.value[6]->step(0.1);
@@ -1991,7 +2001,7 @@ optionWindow::optionWindow(int deltaFontSize)
       geo.value[6]->callback(geometry_options_ok_cb);
 
       geo.choice[2] = new Fl_Choice
-        (L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Surface display");
+        (L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Surface display");
       geo.choice[2]->menu(menu_surface_display);
       geo.choice[2]->align(FL_ALIGN_RIGHT);     
       geo.choice[2]->callback(geometry_options_ok_cb);
@@ -2409,6 +2419,15 @@ optionWindow::optionWindow(int deltaFontSize)
       mesh.value[11]->align(FL_ALIGN_RIGHT);
       mesh.value[11]->callback(mesh_options_ok_cb);
 
+      mesh.value[14] = new Fl_Value_Input
+        (L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "High-order element subdivisions");
+      mesh.value[14]->minimum(1);
+      mesh.value[14]->maximum(10);
+      mesh.value[14]->step(1);
+      mesh.value[14]->align(FL_ALIGN_RIGHT);
+      mesh.value[14]->when(FL_WHEN_RELEASE);
+      mesh.value[14]->callback(mesh_options_ok_cb);
+
       o->end();
     }
     {
-- 
GitLab