From a5a723cc939d67dc5738ee2173544ab09677890b Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sun, 20 Oct 2013 07:10:21 +0000
Subject: [PATCH] Min/Max button now computes min/max for all the selected
 views

---
 Fltk/optionWindow.cpp | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp
index 48bc840a2c..2ed3661b6b 100644
--- a/Fltk/optionWindow.cpp
+++ b/Fltk/optionWindow.cpp
@@ -665,21 +665,28 @@ static void view_options_ok_cb(Fl_Widget *w, void *data)
   o->activate((const char*)data);
 
   if(data){
-    const char *str = (const char*)data;
-    if(!strcmp(str, "range_min") || !strcmp(str, "range_max")){
-      int vindex = o->view.index;
-      if(vindex >= 0 && vindex < (int)PView::list.size()){
-        // compute min/max taking current visibility status into account
-        int step = (int)opt_view_timestep(vindex, GMSH_GET, 0);
-        PViewData *data = PView::list[vindex]->getData(true);
-        PViewOptions *opt = PView::list[vindex]->getOptions();
-        if(!strcmp(str, "range_min"))
-          o->view.value[31]->value(data->getMin(step, true, opt->forceNumComponents,
-                                                opt->componentMap));
-        else if(!strcmp(str, "range_max"))
-          o->view.value[32]->value(data->getMax(step, true, opt->forceNumComponents,
-                                                opt->componentMap));
+    std::string str((const char*)data);
+    if(str == "range_min" || str == "range_max"){
+      double vmin = 1e200;
+      double vmax = -1e200;
+      for(int i = 0; i < (int)PView::list.size(); i++) {
+        if(i == current || FlGui::instance()->options->browser->selected(i + 6)) {
+          // compute min/max taking current visibility status into account
+          int step = (int)opt_view_timestep(i, GMSH_GET, 0);
+          PViewData *data = PView::list[i]->getData(true);
+          PViewOptions *opt = PView::list[i]->getOptions();
+          if(str == "range_min")
+            vmin = std::min(vmin, data->getMin(step, true, opt->forceNumComponents,
+                                               opt->componentMap));
+          else if(str == "range_max")
+            vmax = std::max(vmax, data->getMax(step, true, opt->forceNumComponents,
+                                               opt->componentMap));
+        }
       }
+      if(str == "range_min")
+        o->view.value[31]->value(vmin);
+      else if(str == "range_max")
+        o->view.value[32]->value(vmax);
     }
   }
 
-- 
GitLab