From bc71e3c38a422e2a518e6e314b8fcb36910681e6 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Thu, 15 Oct 2009 19:49:08 +0000
Subject: [PATCH] gui for component map

---
 Common/Options.cpp    |  6 ++++
 Fltk/optionWindow.cpp | 83 ++++++++++++++++++++++++++++++++++++++++---
 Geo/GFaceCompound.cpp |  8 -----
 Mesh/meshGFace.cpp    | 16 ++-------
 4 files changed, 87 insertions(+), 26 deletions(-)

diff --git a/Common/Options.cpp b/Common/Options.cpp
index ada3c62186..ef30e3681e 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -8184,6 +8184,12 @@ static double ovcm(OPT_ARGS_NUM, int nn)
     opt->componentMap[nn] = (int)val;
     if(view) view->setChanged(true);
   }
+#if defined(HAVE_FLTK)
+  if(_gui_action_valid(action, num)){
+    FlGui::instance()->options->view.value[70 + nn]->value
+      (opt->componentMap[nn]);
+  }
+#endif
   return opt->componentMap[nn];
 #else
   return 0.;
diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp
index 2cd4752123..07566753ce 100644
--- a/Fltk/optionWindow.cpp
+++ b/Fltk/optionWindow.cpp
@@ -644,6 +644,15 @@ static void view_options_ok_cb(Fl_Widget *w, void *data)
   double axes_ymax = opt_view_axes_ymax(current, GMSH_GET, 0);
   double axes_zmax = opt_view_axes_zmax(current, GMSH_GET, 0);
   double gen_raise_factor = opt_view_gen_raise_factor(current, GMSH_GET, 0);
+  double component_map0 = opt_view_component_map0(current, GMSH_GET, 0);
+  double component_map1 = opt_view_component_map1(current, GMSH_GET, 0);
+  double component_map2 = opt_view_component_map2(current, GMSH_GET, 0);
+  double component_map3 = opt_view_component_map3(current, GMSH_GET, 0);
+  double component_map4 = opt_view_component_map4(current, GMSH_GET, 0);
+  double component_map5 = opt_view_component_map5(current, GMSH_GET, 0);
+  double component_map6 = opt_view_component_map6(current, GMSH_GET, 0);
+  double component_map7 = opt_view_component_map7(current, GMSH_GET, 0);
+  double component_map8 = opt_view_component_map8(current, GMSH_GET, 0);
 
   std::string name = opt_view_name(current, GMSH_GET, "");
   std::string format = opt_view_format(current, GMSH_GET, "");
@@ -1029,6 +1038,50 @@ static void view_options_ok_cb(Fl_Widget *w, void *data)
       if(force || (val != axes_tics2))
         opt_view_axes_tics2(i, GMSH_SET, val);
 
+      val = o->view.value[70]->value();
+      if(force || (val != component_map0))
+        opt_view_component_map0(i, GMSH_SET, val);
+
+      val = o->view.value[70]->value();
+      if(force || (val != component_map0))
+        opt_view_component_map0(i, GMSH_SET, val);
+
+      val = o->view.value[70]->value();
+      if(force || (val != component_map0))
+        opt_view_component_map0(i, GMSH_SET, val);
+
+      val = o->view.value[71]->value();
+      if(force || (val != component_map1))
+        opt_view_component_map1(i, GMSH_SET, val);
+
+      val = o->view.value[72]->value();
+      if(force || (val != component_map2))
+        opt_view_component_map2(i, GMSH_SET, val);
+
+      val = o->view.value[73]->value();
+      if(force || (val != component_map3))
+        opt_view_component_map3(i, GMSH_SET, val);
+
+      val = o->view.value[74]->value();
+      if(force || (val != component_map4))
+        opt_view_component_map4(i, GMSH_SET, val);
+
+      val = o->view.value[75]->value();
+      if(force || (val != component_map5))
+        opt_view_component_map5(i, GMSH_SET, val);
+
+      val = o->view.value[76]->value();
+      if(force || (val != component_map6))
+        opt_view_component_map6(i, GMSH_SET, val);
+
+      val = o->view.value[77]->value();
+      if(force || (val != component_map7))
+        opt_view_component_map7(i, GMSH_SET, val);
+
+      val = o->view.value[78]->value();
+      if(force || (val != component_map8))
+        opt_view_component_map8(i, GMSH_SET, val);
+
       // view_inputs
 
       std::string str;
@@ -2744,18 +2797,29 @@ optionWindow::optionWindow(int deltaFontSize)
       view.menu[0]->callback(view_options_ok_cb);
 
       static Fl_Menu_Item menu_force_field_type[] = {
-        {"None", 0, 0, 0},
-        {"Scalar", 0, 0, 0},
-        {"Vector", 0, 0, 0},
-        {"Tensor", 0, 0, 0},
+        {"Original Field", 0, 0, 0},
+        {"Force Scalar", 0, 0, 0},
+        {"Force Vector", 0, 0, 0},
+        {"Force Tensor", 0, 0, 0},
         {0}
       };
       view.choice[14] = new Fl_Choice
-        (L + 2 * WB, 2 * WB + 10 * BH, IW, BH, "Forced field type");
+        (L + 2 * WB, 2 * WB + 10 * BH, IW, BH);
       view.choice[14]->menu(menu_force_field_type);
       view.choice[14]->align(FL_ALIGN_RIGHT);
       view.choice[14]->callback(view_options_ok_cb);
 
+      for(int i = 0; i < 9; i++){
+        int W = width - 5 * WB - IW;
+        int w = W / 9;
+        view.value[70 + i] = new Fl_Value_Input
+          (L + 3 * WB + IW + i * w, 2 * WB + 10 * BH, w, BH);
+        view.value[70 + i]->minimum(0);
+        view.value[70 + i]->maximum(9);
+        view.value[70 + i]->step(1);
+        view.value[70 + i]->callback(view_options_ok_cb);
+      }
+
       o->end();
     }
     {
@@ -3276,6 +3340,15 @@ void optionWindow::updateViewGroup(int index)
   opt_view_timestep(index, GMSH_GUI, 0);
   opt_view_show_time(index, GMSH_GUI, 0);
   opt_view_force_num_components(index, GMSH_GUI, 0);
+  opt_view_component_map0(index, GMSH_GUI, 0);
+  opt_view_component_map1(index, GMSH_GUI, 0);
+  opt_view_component_map2(index, GMSH_GUI, 0);
+  opt_view_component_map3(index, GMSH_GUI, 0);
+  opt_view_component_map4(index, GMSH_GUI, 0);
+  opt_view_component_map5(index, GMSH_GUI, 0);
+  opt_view_component_map6(index, GMSH_GUI, 0);
+  opt_view_component_map7(index, GMSH_GUI, 0);
+  opt_view_component_map8(index, GMSH_GUI, 0);
 
   opt_view_point_size(index, GMSH_GUI, 0);
   opt_view_point_type(index, GMSH_GUI, 0);
diff --git a/Geo/GFaceCompound.cpp b/Geo/GFaceCompound.cpp
index 843236bfdc..7f75d2627f 100644
--- a/Geo/GFaceCompound.cpp
+++ b/Geo/GFaceCompound.cpp
@@ -29,14 +29,6 @@
 #include "Context.h"
 #include "discreteFace.h"
 
-// #if !defined(HAVE_NO_MESH)
-// #include "meshGFace.h"
-// #include "meshGFaceOptimize.h"
-// #include "meshGEdge.h"
-// #include "meshPartitionOptions.h"
-// #include "meshPartition.h"
-// #endif
-
 static void fixEdgeToValue(GEdge *ed, double value, dofManager<double, double> &myAssembler)
 {
   myAssembler.fixVertex(ed->getBeginVertex()->mesh_vertices[0], 0, 1, value);
diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp
index dd5b46863d..fe926b5df1 100644
--- a/Mesh/meshGFace.cpp
+++ b/Mesh/meshGFace.cpp
@@ -1309,17 +1309,15 @@ void meshGFace::operator() (GFace *gf)
 
 void partitionAndRemesh(GFaceCompound *gf)
 {
-
-#if !defined(HAVE_NO_MESH) && (defined(HAVE_CHACO) || defined(HAVE_METIS))
-
+#if defined(HAVE_CHACO) || defined(HAVE_METIS)
   //Partition the mesh and createTopology for new faces
   //-----------------------------------------------------
   int N = gf->nbSplit;
   meshPartitionOptions options;
-  options =  CTX::instance()->partitionOptions;
+  options = CTX::instance()->partitionOptions;
   options.num_partitions = N;
   options.partitioner = 2; //METIS
-  options.algorithm =  1 ;
+  options.algorithm = 1;
   int ier = PartitionMesh(gf->model(), options);
   int numv = gf->model()->maxVertexNum() + 1;
   int nume = gf->model()->maxEdgeNum() + 1;
@@ -1413,13 +1411,7 @@ void partitionAndRemesh(GFaceCompound *gf)
 
     printf("*** Mesh of surface %d done by assembly remeshed faces\n", gf->tag());
     gf->meshStatistics.status = GFace::DONE; 
-
-
-
-#else
-  return;
 #endif
-
 }
 
 
@@ -1499,5 +1491,3 @@ void orientMeshGFace::operator()(GFace *gf)
     }
   }
 }
-
-
-- 
GitLab