Calculettes pour l'hydraulique
form_calcul_section.class.php
Aller à la documentation de ce fichier.
1 <?php
2 include_spip('hyd_inc/form_section.abstract.class');
3 
5 
6  // Définition du nombre de colonnes du formulaire
7  protected $nb_col = 4;
8 
9  function __construct() {
10  $this->saisies['c_hyd'] = array(
11  'caract_hydraulique',
12  array(
13  'rQ' =>array('debit', 1.2, 'op'),
14  'rY' =>array('tirant_eau', 0.8, 'op')
15  ),
16  'var'
17  );
18  $this->saisies['param_calcul'] = array(
19  'param_calcul',
20  array(
21  'rPrec' => array('precision',0.001,'fop')
22  ),
23  'fix'
24  );
25  $this->saisies['val_a_cal'] = array(
26  'donnee_calc',
27  array(
28  'val_a_cal' => array('choix_donnee_calc','form_calcul_section_valacal','s')
29  ),
30  'fix'
31  );
32  parent::__construct();
33  }
34 
35  /***************************************************************************
36  * Méthode à appeler par la procédure charger du formulaire CVT
37  * @param bFix true = Formulaire sans choix fvc
38  ***************************************************************************/
39  public function charger($bFix = false) {
40  $valeurs = parent::charger($bFix);
41  $valeurs = array_merge($valeurs,
42  array(
43  'choix_section' => 'FT',
44  'val_a_cal' => 'Hs',
45  'choix_champs_select' => $this->champs_select_calc
46  )
47  );
48  return $valeurs;
49  }
50 
51  protected function calculer() {
52  $this->creer_section_param();
53 
54  // On transforme les champs du tableau des données du formulaire en variables
55  extract($this->data, EXTR_OVERWRITE|EXTR_REFS);
56 
57  if(isset($ValVar) && $ValVar != ''){
58  // Pointage de la variable qui varie sur le bon attribut
59  if($ValVar == 'rY' or in_array($ValVar, $this->get_champs_section($choix_section))){
60  $this->oSn->{$ValVar} = &$i;
61  }
62  else{
63  $this->oP->{$ValVar} = &$i;
64  }
65  // Définition de la variable à calculer
66  $tVarCal = array($val_a_cal);
67  $this->data['ValCal'] = $val_a_cal;
68  }
69  else {
70  $tVarCal = array('Hs', 'Hsc', 'B', 'P', 'S', 'R', 'V', 'Fr', 'Yc', 'Yn', 'Yf', 'Yt', 'Yco', 'J', 'I-J', 'Imp', 'Tau0');
71  }
72 
73  $tRes = array(); // Tableau des résultats (ordonnées)
74  $tAbs = array(); // Tableau des abscisses
75  if(self::DBG) spip_log($tVarCal,'hydraulic',_LOG_DEBUG);
76  if(self::DBG) spip_log("min=$min max=$max pas=$pas",'hydraulic',_LOG_DEBUG);
77  $bF = true;
78  for($i = $min; $i <= $max; $i+= $pas){
79  $this->oSn->Reset(true);
80  $tAbs[] = $i;
81  foreach($tVarCal as $sCalc){
82  $rY = $this->oSn->rY;
83  if(self::DBG) spip_log("i=$i Y=$rY Calc=$sCalc",'hydraulic',_LOG_DEBUG);
84  if(!in_array($sCalc,array('Yn', 'Yc', 'Hsc'))){
85  $tRes[] = $this->oSn->Calc($sCalc);
86  }
87  else{
88  $tRes[] = $this->oSn->CalcGeo($sCalc);
89  }
90  $this->oSn->rY = $rY;
91  }
92  if(self::DBG & $bF) spip_log("i=$i Y=$rY",'hydraulic',_LOG_DEBUG);
93  $bF = false;
94  }
95  return array('abs'=>$tAbs,'res'=>$tRes,'tVarCal'=>$tVarCal);
96  }
97 
98 
99  /** ************************************************************************
100  * Affichage des tableaux et graphiques des résultats des calculs
101  * @return Chaîne de caractère avec le code HTML à afficher
102  ***************************************************************************/
103  protected function afficher_result() {
104  if(isset($this->data['ValVar']) && $this->data['ValVar'] != ''){
105  // Une donnée varie : affichage du graphique et des tableaux de base
106  return parent::afficher_result();
107  }
108  else{
109  // Toutes les données sont fixes affichage du tableau et du schéma de la section
110  $tRes = $this->result['res'];
111  // Tableaux des résultats des calculs
112  $tC =array();
113  $c = 0;
114  foreach($this->result['tVarCal'] as $champ){
115  $tC[$c][] = _T('hydraulic:'.$this->champs_select_calc[$champ]);
116  $tC[$c][] = format_nombre($tRes[$c], $this->data['iPrec']);
117  $c++;
118  }
119  $echo = '<div style="display:inline-block;">';
120  $echo .= $this->get_result_table($tC);
121  $echo .= '</div>';
122 
123  // Schéma de la section
124  $lib_datas = array();
125  $par = 0;
126  foreach($this->result['tVarCal'] as $champ){
127  if(substr($this->champs_select_calc[$champ], 0, 6) == 'tirant' || $champ == 'Hs' || $champ == 'Hsc'){
128  $lib_datas[$champ] = $tRes[$par];
129  }
130  $par++;
131  }
132 
133  $lib_datas['rYB'] = $this->oP->rYB;
134  include_spip('hyd_inc/dessinSection.class');
135  $dessinSection = new dessinSection(250, 400, 100, $this->oSn, $lib_datas);
136  $echo.= $dessinSection->GetDessinSection();
137  return $echo;
138  }
139  }
140 
141  protected function get_champs_libelles() {
142  $lib = parent::get_champs_libelles();
143  foreach($this->champs_select_calc as $cle=>$champ) {
144  $lib[$cle] = _T('hydraulic:'.$champ);
145  }
146  return $lib;
147  }
148 }
149 ?>
Classe pour l&#39;affichage du dessin des sections.
afficher_result()
Affichage des tableaux et graphiques des résultats des calculs
get_champs_section($choix_section)
format_nombre($nombre, $dec)
Definition: cache.php:55
get_result_table($tContent, $tEntetes=false)