From a7a9cc1f56e552fe60f0b6f730d0c75a01b3a68e Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Tue, 2 Mar 2010 16:51:30 +0000
Subject: [PATCH] gui entry for compounds

---
 Fltk/menuWindow.cpp        | 22 +++++++++++++++++++++-
 Fltk/menuWindow.h          |  1 +
 Geo/GeoStringInterface.cpp |  8 ++++++++
 Geo/GeoStringInterface.h   |  1 +
 4 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp
index 59f1a55175..73b2afa38f 100644
--- a/Fltk/menuWindow.cpp
+++ b/Fltk/menuWindow.cpp
@@ -1344,7 +1344,9 @@ static void action_point_line_surface_volume(int action, int mode, const char *w
         case 9:
           add_recosurf(List1, GModel::current()->getFileName());
           break;
-
+        case 10:
+          add_compound(what, List1, GModel::current()->getFileName());
+          break;
         default:
           Msg::Error("Unknown action on selected entities");
           break;
@@ -1987,6 +1989,16 @@ static void mesh_define_embedded_cb(Fl_Widget *w, void *data)
   add_transfinite_embedded(2, true);
 }
 
+static void mesh_define_compound_cb(Fl_Widget *w, void *data)
+{
+  FlGui::instance()->menu->setContext(menu_mesh_define_compound, 0);
+}
+
+static void mesh_define_compound_entity_cb(Fl_Widget *w, void *data)
+{
+  action_point_line_surface_volume(10, 0, (const char *)data);
+}
+
 static void view_toggle_cb(Fl_Widget *w, void *data)
 {
   int num = (int)(long)data;
@@ -2542,6 +2554,7 @@ contextItem menu_mesh[] = {
     {"Embedded points", (Fl_Callback *)mesh_define_embedded_cb, (void*)"point" } ,
     {"Recombine",   (Fl_Callback *)mesh_define_recombine_cb  } ,
     {"Transfinite", (Fl_Callback *)mesh_define_transfinite_cb  } , 
+    {"Compound", (Fl_Callback *)mesh_define_compound_cb  } , 
     {""} 
   };  
     contextItem menu_mesh_define_transfinite[] = {
@@ -2551,6 +2564,13 @@ contextItem menu_mesh[] = {
       {"Volume",  (Fl_Callback *)mesh_define_transfinite_volume_cb} , 
       {""} 
     };  
+    contextItem menu_mesh_define_compound[] = {
+      {"1Mesh>Define>Compound"} ,
+      {"Line",    (Fl_Callback *)mesh_define_compound_entity_cb, (void*)"Line"} ,
+      {"Surface", (Fl_Callback *)mesh_define_compound_entity_cb, (void*)"Surface"} ,
+      {"Volume",  (Fl_Callback *)mesh_define_compound_entity_cb, (void*)"Volume"} , 
+      {""} 
+    };  
   contextItem menu_mesh_delete[] = {
     {"1Mesh>Edit>Delete"} ,
     {"Elements", (Fl_Callback *)mesh_delete_parts_cb, (void*)"elements"} ,
diff --git a/Fltk/menuWindow.h b/Fltk/menuWindow.h
index ee45e68cc5..9f5f626bf1 100644
--- a/Fltk/menuWindow.h
+++ b/Fltk/menuWindow.h
@@ -50,6 +50,7 @@ extern    contextItem menu_mesh_edit[];
 extern        contextItem menu_mesh_delete[]; 
 extern    contextItem menu_mesh_define[]; 
 extern        contextItem menu_mesh_define_transfinite[];
+extern        contextItem menu_mesh_define_compound[];
 extern    contextItem menu_mesh_degree[];
 extern contextItem menu_solver[]; 
 extern contextItem menu_post[]; 
diff --git a/Geo/GeoStringInterface.cpp b/Geo/GeoStringInterface.cpp
index 12ea0ce0f5..763290101a 100644
--- a/Geo/GeoStringInterface.cpp
+++ b/Geo/GeoStringInterface.cpp
@@ -311,6 +311,14 @@ void add_physical(std::string type, List_T *list, std::string fileName)
   add_infile(sstream.str(), fileName);
 }
 
+void add_compound(std::string type, List_T *list, std::string fileName)
+{
+  std::ostringstream sstream;
+  sstream << "Compound " << type << "(" << NEWREG() << ") = {" 
+          << list2string(list) << "};";
+  add_infile(sstream.str(), fileName);
+}
+
 void translate(int add, List_T *list, std::string fileName, std::string what,
                std::string tx, std::string ty, std::string tz)
 {
diff --git a/Geo/GeoStringInterface.h b/Geo/GeoStringInterface.h
index 25b99adb29..aba6d57346 100644
--- a/Geo/GeoStringInterface.h
+++ b/Geo/GeoStringInterface.h
@@ -36,6 +36,7 @@ void add_surf(std::string type, List_T *list, std::string fileName);
 void add_surfloop(List_T *list, std::string fileName, int *numvol);
 void add_vol(List_T *list, std::string fileName);
 void add_physical(std::string type, List_T *list, std::string fileName);
+void add_compound(std::string type, List_T *list, std::string fileName);
 void translate(int add, List_T *list, std::string fileName, std::string what,
                std::string tx, std::string ty, std::string tz);
 void rotate(int add, List_T *list, std::string fileName, std::string what, 
-- 
GitLab