From 3535dcc740297cbea0aa7f164b257123c4df493c Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Wed, 11 Jan 2006 05:37:35 +0000
Subject: [PATCH] add little button to add param name for entity in vis browser
 + refresh vis browser after adding new entities

---
 Fltk/Callbacks.cpp | 30 ++++++++++++++++++++++++++++--
 Fltk/GUI.cpp       | 10 +++++++---
 2 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index 881b64cd95..db14742e1e 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.393 2006-01-08 14:09:50 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.394 2006-01-11 05:37:35 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -1449,6 +1449,7 @@ void visibility_sort_cb(CALLBACK_ARGS)
 {
   int val;
   char *str = (char*)data;
+  static char tmpstr[256];
 
   if(!strcmp(str, "type"))
     val = 1;
@@ -1458,6 +1459,8 @@ void visibility_sort_cb(CALLBACK_ARGS)
     val = 3;
   else if(!strcmp(str, "-"))
     val = -1;
+  else if(!strcmp(str, "+"))
+    val = -2;
   else
     val = 0;
 
@@ -1483,6 +1486,18 @@ void visibility_sort_cb(CALLBACK_ARGS)
       if(!state[i-1]) WID->vis_browser->select(i);
     delete [] state;
   }
+  else if(val == -2){ // create new parameter name for selection
+    for(int i = 1; i < WID->vis_browser->size(); i++){
+      if(WID->vis_browser->selected(i)){
+	Entity *e = (Entity *) WID->vis_browser->data(i);
+	sprintf(tmpstr, "%d", e->Num());
+	WID->context_geometry_input[1]->value(tmpstr);
+	break;
+      }
+    }
+    WID->context_geometry_input[0]->value("NewName");
+    WID->create_geometry_context_window(0);
+  }
   else { // sort
     SetVisibilitySort(val);
     visibility_cb(NULL, NULL);
@@ -1874,6 +1889,8 @@ void geometry_elementary_add_new_point_cb(CALLBACK_ARGS)
       break;
     }
   }
+
+  WID->reset_visibility();
   Msg(STATUS3N, "Ready");
   Msg(ONSCREEN, "");
 }
@@ -1941,6 +1958,7 @@ static void _new_multiline(int type)
     }
   }
 
+  WID->reset_visibility();
   Msg(STATUS3N, "Ready");
   Msg(ONSCREEN, "");
 }
@@ -1997,6 +2015,7 @@ void geometry_elementary_add_new_line_cb(CALLBACK_ARGS)
     }
   }
 
+  WID->reset_visibility();
   Msg(STATUS3N, "Ready");
   Msg(ONSCREEN, "");
 }
@@ -2061,6 +2080,7 @@ void geometry_elementary_add_new_circle_cb(CALLBACK_ARGS)
     }
   }
 
+  WID->reset_visibility();
   Msg(STATUS3N, "Ready");
   Msg(ONSCREEN, "");
 }
@@ -2118,6 +2138,7 @@ void geometry_elementary_add_new_ellipse_cb(CALLBACK_ARGS)
     }
   }
 
+  WID->reset_visibility();
   Msg(STATUS3N, "Ready");
   Msg(ONSCREEN, "");
 }
@@ -2258,6 +2279,8 @@ static void _new_surface_volume(int mode)
 stopall:;
   List_Delete(List1);
   List_Delete(List2);
+
+  WID->reset_visibility();
   Msg(STATUS3N, "Ready");
   Msg(ONSCREEN, "");
 }
@@ -2510,8 +2533,9 @@ static void _action_point_line_surface_volume(int action, int mode, char *what)
       break;
     }
   }
-  
   List_Delete(List1);
+
+  WID->reset_visibility();
   Msg(STATUS3N, "Ready");
   Msg(ONSCREEN, "");
 }
@@ -4254,6 +4278,7 @@ void con_geometry_define_parameter_cb(CALLBACK_ARGS)
 {
   add_param((char *)WID->context_geometry_input[0]->value(),
             (char *)WID->context_geometry_input[1]->value(), CTX.filename);
+  WID->reset_visibility();
 }
 
 void con_geometry_define_point_cb(CALLBACK_ARGS)
@@ -4265,6 +4290,7 @@ void con_geometry_define_point_cb(CALLBACK_ARGS)
 	    (char*)WID->context_geometry_input[5]->value());
   ZeroHighlight(THEM);
   CalculateMinMax(THEM->Points, NULL);
+  WID->reset_visibility();
   Draw();
 }
 
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index 7e129f4af8..0adc4aa374 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI.cpp,v 1.479 2006-01-07 20:38:29 geuzaine Exp $
+// $Id: GUI.cpp,v 1.480 2006-01-11 05:37:35 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -3800,7 +3800,7 @@ void GUI::create_visibility_window()
     {0}
   };
 
-  int width = cols[0] + cols[1] + cols[2] + cols[3] + 4 * WB;
+  int width = cols[0] + cols[1] + cols[2] + cols[3] + 6 * WB;
   int height = 18 * BH;
 
   vis_window = new Dialog_Window(width, height, "Visibility");
@@ -3833,7 +3833,7 @@ void GUI::create_visibility_window()
     Fl_Button *o1 = new Fl_Button(2 * WB, 3 * WB + 2 * BH + BH/2, cols[0], BH - BH/2, "-");
     o1->tooltip("Invert selection");
     o1->callback(visibility_sort_cb, (void *)"-");
-    
+
     Fl_Button *o2 = new Fl_Button(2 * WB + cols[0], 3 * WB + 2 * BH, cols[1], BH, "Type");
     o2->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
     o2->tooltip("Sort by type");
@@ -3848,6 +3848,10 @@ void GUI::create_visibility_window()
     o4->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
     o4->tooltip("Sort by name");
     o4->callback(visibility_sort_cb, (void *)"name");
+
+    Fl_Button *o5 = new Fl_Button(width - 4 * WB, 3 * WB + 2 * BH, 2 * WB, BH, "+");
+    o5->tooltip("Add parameter name for first selected item");
+    o5->callback(visibility_sort_cb, (void *)"+");
     
     {
       Fl_Group *o = new Fl_Group(2 * WB, 3 * WB + 3 * BH, brw, height - 7 * WB - 5 * BH);
-- 
GitLab