From 43cb40d11ed7086b8dc9764329705fac6ea25f84 Mon Sep 17 00:00:00 2001
From: Delaigue Olivier <olivier.delaigue@irstea.fr>
Date: Sat, 18 Apr 2020 07:29:03 +0000
Subject: [PATCH] v0.2.10.18 UPDATE: embellishment of the GR2M diagram #14
 length of segments y-position of the routing store

---
 DESCRIPTION |  4 ++--
 NEWS.md     |  2 +-
 R/Utils.R   | 15 ++++++++++-----
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index 49d5f7f..c20567d 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,8 +1,8 @@
 Package: airGRteaching
 Type: Package
 Title: Teaching Hydrological Modelling with the GR Rainfall-Runoff Models ('Shiny' Interface Included)
-Version: 0.2.10.17
-Date: 2020-04-17
+Version: 0.2.10.18
+Date: 2020-04-18
 Authors@R: c(
   person("Olivier", "Delaigue", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-7668-8468"), email = "airGR@inrae.fr"),
   person("Laurent", "Coron", role = c("aut"), comment = c(ORCID = "0000-0002-1503-6204")),
diff --git a/NEWS.md b/NEWS.md
index 60a0248..78f3ffe 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -4,7 +4,7 @@
 
 
 
-### 0.2.10.17 Release Notes (2020-04-17)
+### 0.2.10.18 Release Notes (2020-04-17)
 
 
 #### New features
diff --git a/R/Utils.R b/R/Utils.R
index 0e932fd..2e737d4 100644
--- a/R/Utils.R
+++ b/R/Utils.R
@@ -315,8 +315,11 @@ if (getRversion() >= "2.15.1") {
     text(x = xy_P[1]+50, y = y_interception+20, labels = "Interception", pos = 4, font = 1, cex = 1.4)
   }
   
+  # E vers Es et P vers Ps ou Pn
+  y_Xs <- ifelse(HydroModel == "GR2M", y_rendement+2*tmp_decal, y_interception+tmp_decal)
+  
   # P vers Pn
-  segments(x0 = xy_P[1], x1 = xy_P[1], y0 = xy_P[2], y1 = y_interception+tmp_decal)
+  segments(x0 = xy_P[1], x1 = xy_P[1], y0 = xy_P[2], y1 = y_Xs)
   
   # Pn vers Ps
   segments(x0 = xy_P[1], x1 = xy_P[1],
@@ -338,7 +341,7 @@ if (getRversion() >= "2.15.1") {
   
   # E vers En puis Es
   segments(x0 = xy_E[1], x1 = xy_E[1],
-           y0 = xy_E[2], y1 = y_interception+tmp_decal)
+           y0 = xy_E[2], y1 = y_Xs)
   segments(x0 = xy_E[1], x1 = xy_E[1],
            y0 = y_interception, y1 = y_rendement)
   
@@ -437,15 +440,16 @@ if (getRversion() >= "2.15.1") {
   # parametres
   tmp_decal   <- (y_percolation - y_entreeUH) / 2 
   
-  # Pr vers UH
+  # Pr vers UH (Pr vers reservoir de routage si GR2M)
+  k <- ifelse(HydroModel == "GR2M", 0.5, 1)
   segments(x0 = x_PnPs, x1 = x_PnPs,
-           y0 = y_percolation, y1 = y_entreeUH+tmp_decal/2)
+           y0 = y_percolation, y1 = (y_entreeUH*k) + tmp_decal/2)
   
   
   if (HydroModel == "GR2M") {
-    # Pr
     plotrix::boxed.labels(x = x_PnPs, y = y_percolation, labels = "Pr",
                           bg = col_mod_bg, border = NA, xpad = xpad, ypad = ypad)
+    
     if (OutputsModel$PR[i_pdt] != 0) {
       points(x = x_PnPs[1], y = y_entreeUH+tmp_decal,
              type = "p", pch = tri_B, col = col_P,
@@ -652,6 +656,7 @@ if (getRversion() >= "2.15.1") {
   
   # Reservoir de routage
   if (HydroModel == "GR2M") {
+    xy_min_ROUT[1] <- x_PnPs - base_res/2
     Param[3] <- 600
   }
   rect(xleft = xy_min_ROUT[1], xright = xy_min_ROUT[1]+base_res,
-- 
GitLab