From 9d4f38b4c5de279cfd14a349dab13e323de4afc4 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sat, 18 Sep 2004 20:25:26 +0000
Subject: [PATCH] - removed the sort view list stuff: it's a bad idea since we
 re-sort the list in many places when we search/replace through it

- add a simple "set visibility->all on/off" switch
---
 Common/Views.cpp   | 32 ++++++--------------------------
 Common/Views.h     |  1 -
 Fltk/Callbacks.cpp | 13 +++++--------
 Fltk/Callbacks.h   |  3 +--
 Fltk/GUI.cpp       | 10 +++++-----
 doc/VERSIONS       |  6 +++---
 6 files changed, 20 insertions(+), 45 deletions(-)

diff --git a/Common/Views.cpp b/Common/Views.cpp
index ac70ad434b..80b54b4ed8 100644
--- a/Common/Views.cpp
+++ b/Common/Views.cpp
@@ -1,4 +1,4 @@
-// $Id: Views.cpp,v 1.133 2004-09-18 15:39:17 geuzaine Exp $
+// $Id: Views.cpp,v 1.134 2004-09-18 20:25:25 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -69,8 +69,12 @@ Post_View *BeginView(int allocate)
   if(!CTX.post.list)
     CTX.post.list = List_Create(100, 100, sizeof(Post_View));
 
+  // Important notes:
+  // - each view *must* have a unique number
+  // - the view list is assumned to be sorted with increasing nums
+
   if(!CTX.post.force_num) {
-    vv.Num = ++UniqueNum;       // each view _must_ have a unique number
+    vv.Num = ++UniqueNum;
     List_Add(CTX.post.list, &vv);
   }
   else {
@@ -594,30 +598,6 @@ void FreeView(Post_View * v)
 
 }
 
-void SortViews(int how)
-{
-  // how==0: by name
-  // how==1: by visibility
-
-  if(!List_Nbr(CTX.post.list)) 
-    return;
-
-  if(how == 0)
-    List_Sort(CTX.post.list, fcmpPostViewName);
-  else
-    List_Sort(CTX.post.list, fcmpPostViewVisibility);
-
-  // recalculate the indices
-  for(int i = 0; i < List_Nbr(CTX.post.list); i++){
-    Post_View *v = (Post_View *) List_Pointer(CTX.post.list, i);
-    v->Index = i;
-  }
-
-#if defined(HAVE_FLTK)
-  UpdateViewsInGUI();
-#endif
-}
-
 void CopyViewOptions(Post_View * src, Post_View * dest)
 {
   dest->Type = src->Type;
diff --git a/Common/Views.h b/Common/Views.h
index f911be9dee..95aa9b175b 100644
--- a/Common/Views.h
+++ b/Common/Views.h
@@ -160,7 +160,6 @@ void ReadView(FILE *file, char *filename);
 void WriteView(Post_View *v, char *filename, int binary, int append);
 void CopyViewOptions(Post_View *src, Post_View *dest);
 void CombineViews(int time, int how, int remove);
-void SortViews(int how);
 
 int BGMWithView (Post_View *ErrView);
 double ErrorInView(Post_View * ErrView, int *n);
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index 2d9829e375..30a03e5532 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.273 2004-09-18 15:39:17 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.274 2004-09-18 20:25:25 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -3212,14 +3212,11 @@ void view_combine_time_by_name_cb(CALLBACK_ARGS)
   Draw();
 }
 
-void view_sort_by_name_cb(CALLBACK_ARGS)
+void view_all_visible_cb(CALLBACK_ARGS)
 {
-  SortViews(0);
-}
-
-void view_sort_by_visibility_cb(CALLBACK_ARGS)
-{
-  SortViews(1);
+  for(int i = 0; i < List_Nbr(CTX.post.list); i ++)
+    opt_view_visible(i, GMSH_SET | GMSH_GUI, (long int)data ? 1 : 0);
+  Draw();
 }
 
 void view_applybgmesh_cb(CALLBACK_ARGS)
diff --git a/Fltk/Callbacks.h b/Fltk/Callbacks.h
index 3ad19d8d85..c6d7f43ee1 100644
--- a/Fltk/Callbacks.h
+++ b/Fltk/Callbacks.h
@@ -118,8 +118,7 @@ void view_combine_space_by_name_cb(CALLBACK_ARGS) ;
 void view_combine_time_all_cb(CALLBACK_ARGS) ;
 void view_combine_time_visible_cb(CALLBACK_ARGS) ;
 void view_combine_time_by_name_cb(CALLBACK_ARGS) ;
-void view_sort_by_name_cb(CALLBACK_ARGS) ;
-void view_sort_by_visibility_cb(CALLBACK_ARGS) ;
+void view_all_visible_cb(CALLBACK_ARGS) ;
 void view_applybgmesh_cb(CALLBACK_ARGS) ;
 void view_options_cb(CALLBACK_ARGS) ;
 void view_plugin_cb(CALLBACK_ARGS) ;
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index d03a97722d..d4826fb338 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI.cpp,v 1.347 2004-09-18 15:39:18 geuzaine Exp $
+// $Id: GUI.cpp,v 1.348 2004-09-18 20:25:26 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -1074,10 +1074,10 @@ void GUI::set_context(Context_Item * menu_asked, int flag)
 		  (Fl_Callback *) view_combine_time_visible_cb, (void *)nb, 0);
 	p[j]->add("Combine/Time steps/By view name", 0, 
 		 (Fl_Callback *) view_combine_time_by_name_cb, (void *)nb, 0);
-	p[j]->add("Sort/By name", 0, 
-		 (Fl_Callback *) view_sort_by_name_cb, (void *)nb, 0);
-	p[j]->add("Sort/By visibility", 0, 
-		 (Fl_Callback *) view_sort_by_visibility_cb, (void *)nb, 0);
+	p[j]->add("Set visibility/All on", 0, 
+		  (Fl_Callback *) view_all_visible_cb, (void *)1, 0);
+	p[j]->add("Set visibility/All off", 0, 
+		  (Fl_Callback *) view_all_visible_cb, (void *)0, 0);
 	p[j]->add("Save as/ASCII view...", 0, 
 		  (Fl_Callback *) view_save_ascii_cb, (void *)nb, 0);
 	p[j]->add("Save as/Binary view...", 0, 
diff --git a/doc/VERSIONS b/doc/VERSIONS
index d0d1e18b18..5bffa683d4 100644
--- a/doc/VERSIONS
+++ b/doc/VERSIONS
@@ -1,11 +1,11 @@
-$Id: VERSIONS,v 1.246 2004-09-18 15:39:18 geuzaine Exp $
+$Id: VERSIONS,v 1.247 2004-09-18 20:25:26 geuzaine Exp $
 
 New since 1.55: new post-processing option to draw a scalar view
 raised by a displacement view without using Plugin(DisplacementRaise)
 (makes drawing arbitrary scalar fields on deformed meshes much
 easier); better post-processing menu (arbitrary number of
-views+scrollable+show view number); improved view->combine and added
-view->sort; small bug fixes.
+views+scrollable+show view number); improved view->combine; small bug
+fixes.
 
 New in 1.55: added background mesh support for Triangle; meshes can
 now be displayed using "smoothed" normals (like post-processing
-- 
GitLab