From ca578da267e35a03042dd835ddb5c91db303d934 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Mon, 31 Aug 2009 07:36:50 +0000
Subject: [PATCH] use old parser physical labels in tree too

---
 Fltk/visibilityWindow.cpp | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/Fltk/visibilityWindow.cpp b/Fltk/visibilityWindow.cpp
index 1d05f0d169..c9fc52055a 100644
--- a/Fltk/visibilityWindow.cpp
+++ b/Fltk/visibilityWindow.cpp
@@ -496,12 +496,14 @@ static void _add_region(GRegion *gr, Fl_Tree *tree, std::string path)
 }
 
 static void _add_physical_group(int dim, int num, std::vector<GEntity*> &ge,
+				std::map<int, std::string> &oldLabels, 
                                 Fl_Tree *tree, std::string path)
 {
   if(ge.empty()) return;
-  std::string name;
-  if(ge[0]->model()->getPhysicalName(dim, num).size())
-    name += std::string(" <<") + ge[0]->model()->getPhysicalName(dim, num) + ">>";
+  std::string name = ge[0]->model()->getPhysicalName(dim, num);
+  if(name.empty() && oldLabels.count(num)) name = oldLabels[num];
+  if(name.size()) name = std::string(" <<") + name + ">>";
+
   Fl_Tree_Item *n;
   std::ostringstream group;
   group << path;
@@ -591,10 +593,17 @@ static void _rebuild_tree_browser(bool force)
 
     std::map<int, std::vector<GEntity*> > groups[4];
     m->getPhysicalGroups(groups);
+    std::map<int, std::string> oldLabels;
+#if !defined(HAVE_NO_PARSER)
+    for(std::map<std::string, std::vector<double> >::iterator it = gmsh_yysymbols.begin();
+        it != gmsh_yysymbols.end(); ++it)
+      for(unsigned int i = 0; i < it->second.size(); i++)
+        oldLabels[(int)it->second[i]] = it->first;
+#endif
     for(int i = 3; i >= 0; i--)
       for(std::map<int, std::vector<GEntity*> >::iterator it = groups[i].begin();
           it != groups[i].end(); it++)
-        _add_physical_group(i, it->first, it->second,
+        _add_physical_group(i, it->first, it->second, oldLabels,
                             FlGui::instance()->visibility->tree, physical);
   }
 
-- 
GitLab