From c46c59e11354fa0a5697ecb5822a3f40008da476 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sat, 4 May 2019 17:34:56 +0200
Subject: [PATCH] don't allow setting boundary layer field as background field

---
 Fltk/fieldWindow.cpp | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/Fltk/fieldWindow.cpp b/Fltk/fieldWindow.cpp
index c1473b3480..e9808238ff 100644
--- a/Fltk/fieldWindow.cpp
+++ b/Fltk/fieldWindow.cpp
@@ -169,9 +169,6 @@ fieldWindow::fieldWindow(int deltaFontSize) : _deltaFontSize(deltaFontSize)
 
   background_btn = new Fl_Round_Button(x, y + h - BH - WB, w - BB - WB, BH,
                                        "Set as background field");
-  background_btn->tooltip(
-    "Only a single field can be set as background field.\n"
-    "To combine multiple fields use the Min or Max fields.");
   options_tab->end();
 
   Fl_Group *help_tab = new Fl_Group(x, y, w, h, "Help");
@@ -354,8 +351,19 @@ void fieldWindow::loadFieldOptions()
     (*input)->clear_changed();
     input++;
   }
-  background_btn->value(GModel::current()->getFields()->getBackgroundField() ==
-                        f->id);
+  if(dynamic_cast<BoundaryLayerField*>(f)){
+    background_btn->value(0);
+    background_btn->deactivate();
+    background_btn->tooltip("Boundary layer fields cannot be assigned in the "
+                            "graphical user interface: edit the file directly.");
+  }
+  else{
+    background_btn->value(GModel::current()->getFields()->getBackgroundField() ==
+                          f->id);
+    background_btn->activate();
+    background_btn->tooltip("Only a single field can be set as background field.\n"
+                            "To combine multiple fields use the Min or Max fields.");
+  }
 }
 
 void fieldWindow::editField(Field *f)
-- 
GitLab