From c90103fe527ca1c35e1d8a4e5c2efb2a96d5d649 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 18 Jan 2013 17:04:15 +0000
Subject: [PATCH] restore top third for 2m

---
 Common/DefaultOptions.h  | 2 +-
 Common/Options.cpp       | 2 +-
 Fltk/optionWindow.cpp    | 1 +
 Graphics/drawGraph2d.cpp | 9 ++++++---
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h
index ad610ceb49..a4b6e47fb3 100644
--- a/Common/DefaultOptions.h
+++ b/Common/DefaultOptions.h
@@ -1184,7 +1184,7 @@ StringXNumber ViewOptions_Number[] = {
   { F|O, "AutoPosition" , opt_view_auto_position , 1. ,
     "Position the scale or 2D plot automatically (0: manual, 1: automatic, 2: top left, "
     "3: top right, 4: bottom left, 5: bottom right, 6: top, 7: bottom, 8: left, 9: right, "
-    "10: full)" },
+    "10: full, 11: top third)" },
   { F|O, "Axes" , opt_view_axes , 0 ,
     "Axes (0=none, 1=simple axes, 2=box, 3=full grid, 4=open grid, 5=ruler)" },
   { F|O, "AxesMikado" , opt_view_axes_mikado , 0. ,
diff --git a/Common/Options.cpp b/Common/Options.cpp
index c3eff4c33a..7422799eae 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -6761,7 +6761,7 @@ double opt_view_auto_position(OPT_ARGS_NUM)
   GET_VIEWo(0.);
   if(action & GMSH_SET) {
     opt->autoPosition = (int)val;
-    if(opt->autoPosition < 0 || opt->autoPosition > 10)
+    if(opt->autoPosition < 0 || opt->autoPosition > 11)
       opt->autoPosition = 0;
   }
 #if defined(HAVE_FLTK)
diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp
index 0b2efc055e..916448db5a 100644
--- a/Fltk/optionWindow.cpp
+++ b/Fltk/optionWindow.cpp
@@ -107,6 +107,7 @@ static Fl_Menu_Item menu_position[] = {
   {"Left",         0, 0, 0},
   {"Right",        0, 0, 0},
   {"Full",         0, 0, 0},
+  {"Top third",    0, 0, 0},
   {0}
 };
 
diff --git a/Graphics/drawGraph2d.cpp b/Graphics/drawGraph2d.cpp
index b6579b81ce..c8c6440068 100644
--- a/Graphics/drawGraph2d.cpp
+++ b/Graphics/drawGraph2d.cpp
@@ -556,7 +556,7 @@ void drawContext::drawGraph2d()
   //  |       my+4*ysep                         |
   //  +-----------------------------------------+
 
-  int overlay[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+  int overlay[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
   double winw = viewport[2] - viewport[0];
   double winh = viewport[3] - viewport[1];
   for(unsigned int i = 0; i < graphs.size(); i++){
@@ -584,9 +584,10 @@ void drawContext::drawGraph2d()
         drawGraph(this, p, x, viewport[3] - y, w, h, tic);
       }
     }
-    else if(opt->autoPosition >= 2 && opt->autoPosition <= 10){
+    else if(opt->autoPosition >= 2 && opt->autoPosition <= 11){
       // top left (2), top right (3), bottom left (4), bottom right (5), top
-      // half (6), bottom half (7), left half (8), right half (9), full (10)
+      // half (6), bottom half (7), left half (8), right half (9), full (10),
+      // top third (11)
       int a = opt->autoPosition;
       double w, h;
       if(a <= 5 || a == 8 || a == 9)
@@ -595,6 +596,8 @@ void drawContext::drawGraph2d()
         w = winw - 2 * mx - 2 * xsep;
       if(a <= 5 || a == 6 || a == 7)
         h = (winh - 3 * my - 12 * ysep) / 2.;
+      else if(a == 11)
+        h = (winh - 3 * my - 12 * ysep) / 3.;
       else
         h = winh - 2 * my - 7 * ysep;
       if(a == 3 || a == 5 || a == 9) x += (w + mx + 2 * xsep);
-- 
GitLab