Changeset 60821 in spip-zone
- Timestamp:
- Apr 30, 2012, 1:29:38 PM (9 years ago)
- Location:
- _plugins_/hydraulic/trunk
- Files:
-
- 20 edited
- 7 copied
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/hydraulic/trunk
-
Property
svn:ignore
set to
test
-
Property
svn:ignore
set to
-
_plugins_/hydraulic/trunk/formulaires/calcul_normale_critique.html
r59892 r60821 1 1 [<div class='hyd_formulaire_erreur '><span>(#ENV*{message_erreur})</span></div>] 2 2 <script language="javascript" type="text/javascript" src="#CHEMIN{js/hyd_fonctions.js}"></script> 3 <script> 3 <script language="javascript" type="text/javascript" src="#CHEMIN{js/jquery.svg.js}"></script> 4 <script language="javascript" type="text/javascript" src="#CHEMIN{js/jquery.drawinglibrary.js}"></script> 5 6 <script> 7 function elementsParClasse(classe, tagName){ 8 var divs = document.getElementsByTagName(tagName); 9 var resultats = new Array(); 10 for(var i=0; i<divs.length; i++){ 11 if(divs[i].className == classe){ 12 resultats.push(divs[i]); 13 } 14 } 15 return resultats; 16 } 17 18 var globSelectSection = 'FT'; 19 20 function setVarGlob(){ 21 globSelectSection = getSelectValue('choix_section'); 22 } 23 24 function resetAffichageChamps(nom){ 25 setVarGlob(); 26 if(nom){ 27 var cacher = elementsParClasse('champs_var_'+nom, 'tr'); 28 for(var i in cacher){ 29 cacher[i].style.display='none'; 30 } 31 } 32 else{ 33 var tab = new Array(); 34 <BOUCLE_remplissageTab1(POUR){tableau #ENV{mes_saisies}}> 35 #SET{field1, #CLE} 36 <BOUCLE_remplissageTab2(POUR){tableau (#VALEUR|table_valeur{1})}> 37 <BOUCLE_afficheSiSection(CONDITION){si #GET{field1}|substr{0,1}|== {'F'}}> 38 tab.push('#GET{field1}_[(#CLE)]'); 39 </BOUCLE_afficheSiSection> 40 </BOUCLE_remplissageTab2> 41 </BOUCLE_remplissageTab1> 42 43 for(var i in tab){ 44 if(document.getElementById('varier_val_'+tab[i]).checked){ 45 document.getElementById('val_a_cal_field_nc').style.display='none'; 46 document.getElementById('val_a_cal_nc').style.display='none'; 47 } 48 49 document.getElementById('val_fixe_'+tab[i]).checked=true; 50 document.getElementById('caract_'+tab[i]).disabled=false; 51 var cacher = elementsParClasse('champs_var_'+tab[i], 'tr'); 52 for(var i in cacher){ 53 cacher[i].style.display='none'; 54 } 55 } 56 57 } 58 } 4 59 5 60 //Permet d'afficher ou cacher les champs correspondant à une section. 6 61 function afficher_cacher() { 7 var section = getSelectValue('choix_section_nc'); 62 resetAffichageChamps(); 63 var section = getSelectValue('choix_section'); 8 64 var f = document.getElementById("form_normale_critique"); 9 65 if(f) { … … 21 77 22 78 function gestion_radios(nom, valeur){ 23 var tabPartiel = ['rug', 'pente', 'coteEau', 'debit']; 79 setVarGlob(); 80 var tabPartiel = new Array(); 81 <BOUCLE_remplissageTabPartiel1(POUR){tableau #ENV{mes_saisies}}> 82 #SET{field2, #CLE} 83 #SET{test, #VALEUR|table_valeur{1}} 84 85 <BOUCLE_conditionSection(CONDITION){si #CLE|substr{0,1}|== {'F'}}> 86 if(globSelectSection == '#CLE'){ 87 88 <BOUCLE_remplissageTabPartiel2(POUR){tableau #GET{test}}> 89 tabPartiel.push('#GET{field2}_[(#CLE)]'); 90 </BOUCLE_remplissageTabPartiel2> 91 } 92 </BOUCLE_conditionSection> 93 <BOUCLE_remplissageTabPartiel3(POUR){tableau (#VALEUR|table_valeur{1})}> 94 tabPartiel.push('#GET{field2}_[(#CLE)]'); 95 </BOUCLE_remplissageTabPartiel3> 96 <//B_conditionSection> 97 </BOUCLE_remplissageTabPartiel1> 24 98 25 99 for(var i in tabPartiel){ 26 100 if(tabPartiel[i] == nom){ 27 101 delete(tabPartiel[i]); 28 } 29 } 30 102 } 103 } 104 31 105 if(valeur.substr(0,3) == 'var'){ 32 106 for(var cle in tabPartiel){ … … 35 109 document.getElementById('caract_'+tabPartiel[cle]).disabled=false; 36 110 document.getElementById('caract_'+nom).disabled=true; 37 var cacher = document.getElementsByClassName('champs_var_'+tabPartiel[cle]); 38 for(var i in cacher){ 39 cacher[i].style.display='none'; 40 } 111 resetAffichageChamps(tabPartiel[cle]); 41 112 } 42 113 } … … 44 115 document.getElementById('val_a_cal_nc').style.display='table-row'; 45 116 document.getElementById('caract_'+nom).disabled=true; 46 var afficher = document.getElementsByClassName('champs_var_'+nom);47 48 117 var afficher = elementsParClasse('champs_var_'+nom, 'tr'); 118 for(var i in afficher){ 119 afficher[i].style.display='table-row'; 49 120 } 50 121 } … … 63 134 64 135 document.getElementById('caract_'+nom).disabled=false; 65 var cacher = document.getElementsByClassName('champs_var_'+nom); 66 for(var i in cacher){ 67 cacher[i].style.display='none'; 68 } 69 } 136 resetAffichageChamps(nom); 137 } 138 70 139 } 71 140 </script> … … 82 151 <:hydraulic:choix_section:> : 83 152 </td> 84 153 85 154 <td colspan="3" width="70%"> 86 <select name="ncTypeSection" id="choix_section_nc" onChange="afficher_cacher();"> 87 <option value="FT" [(#ENV{ncTypeSection}|=={'FT'}|?{'selected',''})]><:hydraulic:section_trap:></option> 88 <option value="FR" [(#ENV{ncTypeSection}|=={'FR'}|?{'selected',''})]><:hydraulic:section_rect:></option> 89 <option value="FC" [(#ENV{ncTypeSection}|=={'FC'}|?{'selected',''})]><:hydraulic:section_circ:></option> 90 <option value="FP" [(#ENV{ncTypeSection}|=={'FP'}|?{'selected',''})]><:hydraulic:section_puiss:></option> 155 <select name="ncTypeSection" id="choix_section" onChange="afficher_cacher();"> 156 <BOUCLE_selectOptions(POUR){tableau #ENV{mes_saisies}}> 157 #SET{test, #VALEUR|table_valeur{0}|decoupeIdSection} 158 <BOUCLE_choixSection(CONDITION){si #CLE|substr{0,1}|== {'F'}}> 159 <option value="#CLE" [(#ENV{ncTypeSection}|=={#CLE}|?{'selected',''})]>#GET{test}</option> 160 </BOUCLE_choixSection> 161 </BOUCLE_selectOptions> 91 162 </select> 92 163 93 164 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{[(#VALEUR|table_valeur{0})]})</div>] 94 </td> 165 </td> 166 </tr> 167 168 <BOUCLE_fieldChamps(POUR){tableau #ENV{mes_saisies}}> 169 #SET{id_fieldset, #CLE} 170 171 <tr id="#GET{id_fieldset}_field" style="display:[(#CLE|match{^([(#ENV{ncTypeSection})]|Cr)$}|?{'table-row','none'})];"> 172 <td colspan="4"><div class="hyd_formulaire_chapitre">[(#VALEUR|table_valeur{0}|traduction_hydraulic)]</div></td> 173 </tr> 174 175 <BOUCLE_affichageParamCal(CONDITION){si #GET{id_fieldset}|!== {'Cr'}}> 176 <tr id="#GET{id_fieldset}_optionCal_nc" style="display:[(#CLE|match{^([(#ENV{ncTypeSection})]|Cr)$}|?{'table-row','none'})];"> 177 <td colspan="2"></td> 178 <td align="center"><:hydraulic:varier_val:></td> 179 <td align="center"><:hydraulic:fixer_val:></td> 180 </tr> 181 </BOUCLE_affichageParamCal> 182 183 184 <BOUCLE_champsLib(POUR){tableau (#VALEUR|table_valeur{1})}> 185 #SET{clefield, #GET{id_fieldset}|concat{_, #CLE}} 186 187 <tr id="#GET{clefield}" style="display:[(#GET{id_fieldset}|match{^([(#ENV{ncTypeSection})]|Cr)$}|?{'table-row','none'})];"> 188 <td align="right"> 189 [(#VALEUR|table_valeur{0}|traduction_hydraulic)] : 190 </td> 191 192 <td> 193 <input id="caract_#GET{clefield}" type="text" value="[(#ENV{#GET{clefield}})]" maxlength="30" name="#GET{clefield}" [(#ENV{choix_champs_#GET{clefield}}|=={varier_val_#GET{clefield}}|?{'disabled="true"',''})]/> 194 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{#GET{clefield}})</div>] 195 </td> 196 197 <BOUCLE_val_var_existe(CONDITION){si #ENV{choix_champs_#GET{clefield}}|== {varier_val_#GET{clefield}}}> 198 #SET{val_var, #CLE} 199 </BOUCLE_val_var_existe> 200 201 <td align="center"> 202 <input type="radio" id="varier_val_#GET{clefield}" name="choix_champs_#GET{clefield}" value="varier_val_#GET{clefield}" onclick="gestion_radios('#GET{clefield}', 'varier_val_#GET{clefield}')" [(#ENV{choix_champs_#GET{clefield}}|=={varier_val_#GET{clefield}}|?{'checked',''})]/> 203 </td> 204 205 <td align="center"> 206 <input type="radio" id="val_fixe_#GET{clefield}" name="choix_champs_#GET{clefield}" value="val_fixe_#GET{clefield}" onclick="gestion_radios('#GET{clefield}', 'val_fixe_#GET{clefield}')" [(#ENV{choix_champs_#GET{clefield}}|=={val_fixe_#GET{clefield}}|?{'checked',''})]/> 207 </td> 208 </tr> 209 210 <tr class="champs_var_#GET{clefield}" style="display:[(#ENV{choix_champs_#GET{clefield}}|=={varier_val_#GET{clefield}}|?{'table-row','none'})];"> 211 <td colspan="2" align="right"><:hydraulic:val_min:> : </td> 212 <td colspan="2"> 213 <input name="val_min_#GET{clefield}" type="text" value="[(#ENV{val_min_#GET{clefield}})]"/> 214 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{val_min_#GET{clefield}})</div>] 215 </td> 216 </tr> 95 217 96 </tr> 97 98 <BOUCLE_fieldChamps(POUR){tableau #ENV{mes_saisies}}> 99 100 #SET{id_fieldset, #CLE} 101 102 <tr id="#GET{id_fieldset}_field_nc" style="display:[(#CLE|match{^([(#ENV{ncTypeSection})]|Caract)$}|?{'table-row','none'})];"> 103 <td colspan="4"><div class="hyd_formulaire_chapitre">[(#VALEUR|table_valeur{0}|traduction_libelle)]</div></td> 104 </tr> 105 106 [(#GET{id_fieldset}|=={'Caract'}|?{ 107 <tr> 108 <td colspan="2"></td> 109 <td align="center"><:hydraulic:varier_val:></td> 110 <td align="center"><:hydraulic:fixer_val:></td> 111 </tr> 112 })] 113 114 <BOUCLE_champsLib(POUR){tableau (#VALEUR|table_valeur{1})}> 115 116 <tr id="#GET{id_fieldset}_[(#CLE)]_nc" style="display:[(#GET{id_fieldset}|match{^([(#ENV{ncTypeSection})]|Caract)$}|?{'table-row','none'})];"> 117 <td align="right"> 118 [(#VALEUR|table_valeur{0}|traduction_libelle)] : 119 </td> 120 121 <td> 122 <input id="caract_#CLE" type="text" value="[(#ENV{#GET{id_fieldset}_[(#CLE)]_nc})]" maxlength="30" name="#GET{id_fieldset}_[(#CLE)]_nc" [(#ENV{choix_champs_#CLE}|=={varier_val_#CLE}|?{'disabled="true"',''})]/> 123 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{#GET{id_fieldset}_[(#CLE)]_nc})</div>] 124 </td> 125 126 <BOUCLE_caract(CONDITION){si #GET{id_fieldset}|== {'Caract'}}> 127 128 <BOUCLE_val_var_existe(CONDITION){si #ENV{choix_champs_#CLE}|== {varier_val_#CLE}}> 129 #SET{val_var, #CLE} 130 </BOUCLE_val_var_existe> 131 132 <td align="center"> 133 <input type="radio" id="varier_val_#CLE" name="choix_champs_#CLE" value="varier_val_#CLE" onclick="gestion_radios('#CLE', 'varier_val_#CLE')" [(#ENV{choix_champs_#CLE}|=={varier_val_#CLE}|?{'checked',''})]/> 134 </td> 135 136 <td align="center"> 137 <input type="radio" id="val_fixe_#CLE" name="choix_champs_#CLE" value="val_fixe_#CLE" onclick="gestion_radios('#CLE', 'val_fixe_#CLE')" [(#ENV{choix_champs_#CLE}|=={val_fixe_#CLE}|?{'checked',''})]/> 138 </td> 139 </tr> 140 141 <tr class="champs_var_#CLE" style="display:[(#ENV{choix_champs_#CLE}|=={varier_val_#CLE}|?{'table-row','none'})];"> 142 <td colspan="2" align="right"><:hydraulic:val_min:> : </td> 143 <td colspan="2"> 144 <input name="val_min_#CLE" type="text" value="#ENV{val_min_#CLE}"/> 145 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{val_min_#CLE})</div>] 146 </td> 147 </tr> 148 149 <tr class="champs_var_#CLE" style="display:[(#ENV{choix_champs_#CLE}|=={varier_val_#CLE}|?{'table-row','none'})];"> 150 <td colspan="2" align="right"><:hydraulic:val_max:> :</td> 151 <td colspan="2"> 152 <input name="val_max_#CLE" type="text" value="#ENV{val_max_#CLE}"/> 153 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{val_max_#CLE})</div>] 154 </td> 155 </tr> 156 157 <tr class="champs_var_#CLE" style="display:[(#ENV{choix_champs_#CLE}|=={varier_val_#CLE}|?{'table-row','none'})];"> 158 <td colspan="2" align="right"><:hydraulic:pas_var:> :</td> 159 <td colspan="2"> 160 <input name="pas_var_#CLE" type="text" value="#ENV{pas_var_#CLE}"/> 161 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{pas_var_#CLE})</div>] 162 </td> 163 </tr> 164 165 </BOUCLE_caract> 166 167 </tr> 168 169 </BOUCLE_champsLib> 170 171 </BOUCLE_fieldChamps> 218 <tr class="champs_var_#GET{clefield}" style="display:[(#ENV{choix_champs_#GET{clefield}}|=={varier_val_#GET{clefield}}|?{'table-row','none'})];"> 219 <td colspan="2" align="right"><:hydraulic:val_max:> : </td> 220 <td colspan="2"> 221 <input name="val_max_#GET{clefield}" type="text" value="[(#ENV{val_max_#GET{clefield}})]"/> 222 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{val_max_#GET{clefield}})</div>] 223 </td> 224 </tr> 225 226 <tr class="champs_var_#GET{clefield}" style="display:[(#ENV{choix_champs_#GET{clefield}}|=={varier_val_#GET{clefield}}|?{'table-row','none'})];"> 227 <td colspan="2" align="right"><:hydraulic:pas_var:> : </td> 228 <td colspan="2"> 229 <input name="pas_var_#GET{clefield}" type="text" value="[(#ENV{pas_var_#GET{clefield}})]"/> 230 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{pas_var_#GET{clefield}})</div>] 231 </td> 232 </tr> 233 234 </BOUCLE_champsLib> 235 </BOUCLE_fieldChamps> 236 237 172 238 <tr id="param_calc_normale_critique"> 173 239 <td colspan="5"><div class="hyd_formulaire_chapitre"><:hydraulic:param_calcul:></div></td> … … 176 242 <tr id="precision_normale_critique"> 177 243 <td align="right"> 178 <:hydraulic:precision _lechapt_calmon:> :244 <:hydraulic:precision:> : 179 245 </td> 180 246 <td> 181 <input id="champs_ prec_nc" type="text" value="#ENV{prec_nc}" maxlength="30" name="prec_nc"/>182 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{ prec_nc})</div>]247 <input id="champs_Param_calc_rPrec" type="text" value="#ENV{Param_calc_rPrec}" maxlength="30" name="Param_calc_rPrec"/> 248 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{Param_calc_rPrec})</div>] 183 249 </td> 184 250 </tr> … … 192 258 <:hydraulic:choix_donnee_calc:> : 193 259 </td> 194 260 195 261 <td colspan="3"> 196 <select name="val_a_cal_nc"> 197 <option value="1" [(#ENV{val_a_cal_nc}|=={'1'}|?{'selected',''})]><:hydraulic:charge_spe:></option> 198 <option value="2" [(#ENV{val_a_cal_nc}|=={'2'}|?{'selected',''})]><:hydraulic:charge_critique:></option> 199 <option value="3" [(#ENV{val_a_cal_nc}|=={'3'}|?{'selected',''})]><:hydraulic:larg_miroir:></option> 200 <option value="4" [(#ENV{val_a_cal_nc}|=={'4'}|?{'selected',''})]><:hydraulic:perim_mouille:></option> 201 <option value="5" [(#ENV{val_a_cal_nc}|=={'5'}|?{'selected',''})]><:hydraulic:surf_mouille:></option> 202 <option value="6" [(#ENV{val_a_cal_nc}|=={'6'}|?{'selected',''})]><:hydraulic:rayon_hyd:></option> 203 <option value="7" [(#ENV{val_a_cal_nc}|=={'7'}|?{'selected',''})]><:hydraulic:vit_moy:></option> 204 <option value="8" [(#ENV{val_a_cal_nc}|=={'8'}|?{'selected',''})]><:hydraulic:froud:></option> 205 <option value="9" [(#ENV{val_a_cal_nc}|=={'9'}|?{'selected',''})]><:hydraulic:tirant_eau_crit:></option> 206 <option value="10" [(#ENV{val_a_cal_nc}|=={'10'}|?{'selected',''})]><:hydraulic:tirant_eau_norm:></option> 207 <option value="11" [(#ENV{val_a_cal_nc}|=={'11'}|?{'selected',''})]><:hydraulic:tirant_eau_fluv:></option> 208 <option value="12" [(#ENV{val_a_cal_nc}|=={'12'}|?{'selected',''})]><:hydraulic:tirant_eau_torr:></option> 209 <option value="13" [(#ENV{val_a_cal_nc}|=={'13'}|?{'selected',''})]><:hydraulic:tirant_eau_conj:></option> 210 <option value="14" [(#ENV{val_a_cal_nc}|=={'14'}|?{'selected',''})]><:hydraulic:perte_charge:></option> 211 <option value="15" [(#ENV{val_a_cal_nc}|=={'15'}|?{'selected',''})]><:hydraulic:var_lin:></option> 212 <option value="16" [(#ENV{val_a_cal_nc}|=={'16'}|?{'selected',''})]><:hydraulic:impulsion:></option> 213 <option value="17" [(#ENV{val_a_cal_nc}|=={'17'}|?{'selected',''})]><:hydraulic:force_tract:></option> 262 <select name="val_a_cal_nc" id="valeur_a_cal_nc"> 263 <BOUCLE_champs_select_cal(POUR){tableau #ENV{choix_champs_select}}> 264 <option value="#CLE" [(#ENV{val_a_cal_nc}|=={#CLE}|?{'selected',''})]>[(#VALEUR|traduction_hydraulic)]</option> 265 </BOUCLE_champs_select_cal> 214 266 </select> 215 267 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{[(#VALEUR|table_valeur{0})]})</div>] 216 </td> 217 268 </td> 269 218 270 </tr> 219 271 … … 228 280 </form> 229 281 230 [<div class='hydraulic_resultat' >(#ENV*{message_ok})</div>]282 [<div class='hydraulic_resultat' id="resultat_nc">(#ENV*{message_ok})</div>] -
_plugins_/hydraulic/trunk/formulaires/calcul_normale_critique.php
r59892 r60821 1 1 <?php 2 /** 3 * @file formulaires/calcul_normale_critique.php 4 * Formulaire CVT pour les calculs des paramètres hydrauliques d'une section 5 */ 6 7 /* Copyright 2012 Médéric Dulondel 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 22 * MA 02110-1301, USA. 23 */ 24 25 2 26 /* 3 * formulaires/calcul_normale_critique.php 4 * 5 * 6 * 7 * Copyright 2012 David Dorchies <dorch@dorch.fr> 8 * 9 * 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * 13 * it under the terms of the GNU General Public License as published by 14 * 15 * the Free Software Foundation; either version 2 of the License, or 16 * 17 * (at your option) any later version. 18 * 19 * 20 * 21 * This program is distributed in the hope that it will be useful, 22 * 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 * 25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 * 27 * GNU General Public License for more details. 28 * 29 * 30 * 31 * You should have received a copy of the GNU General Public License 32 * 33 * along with this program; if not, write to the Free Software 34 * 35 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 36 * 37 * MA 02110-1301, USA. 38 * 27 * Découpe le champ $champ en plusieurs morceaux séparés par '_' 28 * Ce découpage s'effectue à partir du $deb underscore et est de longueur $lg 29 * Par exemple : 30 * $test = 'petit_test_de_decoupage' 31 * id_decoupe($test, 1, 2) renvoit 'test_de' 39 32 */ 40 41 function id_decoupe($champs,$nb){ 42 $decoup = explode('_', $champs, 3); 43 return $decoup[$nb]; 44 } 45 33 function id_decoupe($champ,$deb, $lg){ 34 $decoup = explode('_', $champ); 35 $val = ''; 36 $selectElmt = array_slice($decoup, $deb, $lg); 37 $val = join("_", $selectElmt); 38 39 return $val; 40 } 41 42 include_spip('hyd_inc/section'); 43 44 /* 45 * Contient tous les champs relatifs au formulaire. 46 * Les champs communs sont localisés ici: hyd_inc/section.php 47 */ 46 48 function mes_saisies_normale_critique(){ 47 $fieldset_champs_nc = array( 48 49 'FT' => array( 50 'def_section_trap', 51 array( 52 'rLarg' =>array('largeur_fond',2.5), 53 'rFruit' =>array('fruit', 0.56) 54 ) 55 ), 56 57 'FR' => array( 58 'def_section_rect', 59 array( 60 'rLarg' =>array('largeur_fond',2.5) 61 ) 62 ), 63 64 'FC' => array( 65 'def_section_circ', 66 array( 67 'circ1' =>array('champ_circulaire1',3), 68 'circ2' =>array('champ_circulaire2', 0.6) 69 ) 70 ), 71 72 'FP' => array( 73 'def_section_puis', 74 array( 75 'puiss1' =>array('champs_puissance1',10), 76 'puiss2' =>array('champs_puissance2', 0.7) 77 ) 78 ), 79 80 'Caract' => array( 81 'caract_globale', 82 array( 83 'rug' =>array('rugosite_nc',50), 84 'pente' =>array('pente_nc', 50), 85 'coteEau' =>array('cote_eau_nc', 0.005), 86 'debit' =>array('debit_nc', 1.2) 87 ) 88 ) 89 ); 90 49 50 $fieldset_champs_nc = caract_communes(); 51 52 $fieldset_champs_nc['Cr'] = array( 53 'caract_globale', 54 array( 55 'rKs' =>array('rugosite_nc',50), 56 'rIf' =>array('pente_fond', 0.001), 57 'rQ' =>array('debit', 1.2), 58 'rYB' =>array('h_berge', 1), 59 'rY' =>array('tirant_eau', 1) 60 ) 61 ); 62 63 91 64 return $fieldset_champs_nc; 92 65 } 93 66 67 function champs_select_calculer(){ 68 $champs_select_calc = array( 69 'Hs' => 'charge_spe', 70 'Hsc' => 'charge_critique', 71 'B' => 'larg_miroir', 72 'P' => 'perim_mouille', 73 'S' => 'surf_mouille', 74 'R' => 'rayon_hyd', 75 'V' => 'vit_moy', 76 'Fr' => 'froud', 77 'Yc' => 'tirant_eau_crit', 78 'Yn' => 'tirant_eau_norm', 79 'Yf' => 'tirant_eau_fluv', 80 'Yt' => 'tirant_eau_torr', 81 'Yco' => 'tirant_eau_conj', 82 'J' => 'perte_charge', 83 'I-J' => 'var_lin', 84 'Imp' => 'impulsion', 85 'Tau0' => 'force_tract' 86 ); 87 88 return $champs_select_calc; 89 } 90 94 91 function champs_obligatoires_nc() { 95 96 92 93 $tSaisie = mes_saisies_normale_critique(); 97 94 $tChOblig = array(); 98 95 $sTypeSection = _request('ncTypeSection'); 96 // Cette variable va contenir le nom de la variable qui varie s'il y en a une. 99 97 $ValVar = ''; 100 $tChOblig[] = 'prec_nc'; 98 101 99 foreach($tSaisie as $IdFS=>$FieldSet) { 102 if((substr($IdFS,0,1) != 'F') || ($IdFS == $sTypeSection)){ 103 foreach($FieldSet[1] as $Cle=>$Champ) { 104 if(substr(_request('choix_champs_'.$Cle), 0, 3) == 'var'){ 105 $ValVar = $IdFS.'_'.$Cle.'_nc'; 106 } 107 if((!isset($Champ[2])) || (isset($Champ[2]) && $Champ[2])) { 108 $tChOblig[] = $IdFS.'_'.$Cle.'_nc'; 109 } 110 } 111 } 112 } 113 114 if($ValVar != ''){ 115 foreach($tChOblig as $cle=>$valeur){ 116 if($valeur == $ValVar){ 117 unset($tChOblig[$cle]); 118 $tChOblig = array_values($tChOblig); 119 $tChOblig [] = 'val_min_'.id_decoupe($valeur, 1); 120 $tChOblig [] = 'val_max_'.id_decoupe($valeur, 1); 121 $tChOblig [] = 'pas_var_'.id_decoupe($valeur, 1); 122 } 123 } 124 } 125 126 return $tChOblig; 127 } 128 129 function formulaires_calcul_normale_critique_charger_dist() { 130 // On charge les saisies et les champs qui nécessitent un accès par les fonctions 131 $tSaisie_nc = mes_saisies_normale_critique(); 132 133 $valeurs = array( 134 'ncTypeSection' => 'FT', 135 'mes_saisies' => $tSaisie_nc, 136 'val_a_cal_nc' => 1, 137 'prec_nc' => 0.001 138 ); 100 // Si ce n'est pas une section ou alors celle selectionnée... 101 if((substr($IdFS,0,1) != 'F') || ($IdFS == $sTypeSection)){ 102 foreach($FieldSet[1] as $Cle=>$Champ) { 103 //... alors on enresgistre les champs 104 if(substr(_request('choix_champs_'.$IdFS.'_'.$Cle), 0, 3) == 'var'){ 105 $ValVar = $IdFS.'_'.$Cle; 106 } 107 if((!isset($Champ[2])) || (isset($Champ[2]) && $Champ[2])) { 108 $tChOblig[] = $IdFS.'_'.$Cle; 109 } 110 } 111 } 112 } 113 114 if($ValVar != ''){ 115 foreach($tChOblig as $cle=>$valeur){ 116 if($valeur == $ValVar){ 117 unset($tChOblig[$cle]); 118 $tChOblig = array_values($tChOblig); 119 $tChOblig [] = 'val_min_'.$valeur; 120 $tChOblig [] = 'val_max_'.$valeur; 121 $tChOblig [] = 'pas_var_'.$valeur; 122 } 123 } 124 } 125 126 //On ajoute rPrec_nc car il ne fait pas partie des saisies de sections. 127 $tChOblig[] = 'Param_calc_rPrec'; 128 129 return $tChOblig; 130 } 131 132 function formulaires_calcul_normale_critique_charger_dist() { 133 // On charge les saisies et les champs qui nécessitent un accès par les fonctions 134 $tSaisie_nc = mes_saisies_normale_critique(); 135 $champs_select = champs_select_calculer(); 136 137 $valeurs = array( 138 'ncTypeSection' => 'FT', 139 'mes_saisies' => $tSaisie_nc, 140 'val_a_cal_nc' => 'Hs', 141 'Param_calc_rPrec' => 0.001, 142 'choix_champs_select' => $champs_select 143 ); 144 145 foreach($tSaisie_nc as $CleFD=>$FieldSet) { 146 foreach($FieldSet[1] as $Cle=>$Champ) { 147 $valeurs[$CleFD.'_'.$Cle] = $Champ[1]; 148 $valeurs['choix_champs_'.$CleFD.'_'.$Cle] = 'val_fixe_'.$CleFD.'_'.$Cle; 149 if($Cle == 'rIf'){ 150 $valeurs['val_min_'.$CleFD.'_'.$Cle] = 0.001; 151 $valeurs['val_max_'.$CleFD.'_'.$Cle] = 0.005; 152 $valeurs['pas_var_'.$CleFD.'_'.$Cle] = 0.001; 153 } 154 else { 155 $valeurs['val_min_'.$CleFD.'_'.$Cle] = 1; 156 $valeurs['val_max_'.$CleFD.'_'.$Cle] = 2; 157 $valeurs['pas_var_'.$CleFD.'_'.$Cle] = 0.1; 158 } 159 } 160 } 139 161 140 foreach($tSaisie_nc as $CleFD=>$FieldSet) {141 foreach($FieldSet[1] as $Cle=>$Champ) {142 $valeurs[$CleFD.'_'.$Cle.'_nc'] = $Champ[1];143 if($CleFD == 'Caract'){144 $valeurs['choix_champs_'.$Cle] = 'val_fixe_'.$Cle;145 $valeurs['val_min_'.$Cle] = 1;146 $valeurs['val_max_'.$Cle] = 2;147 $valeurs['pas_var_'.$Cle] = 0.1;148 }149 }150 }151 152 162 return $valeurs; 153 163 } 154 164 155 function formulaires_calcul_normale_critique_verifier_dist(){ 165 function formulaires_calcul_normale_critique_verifier_dist(){ 156 166 $erreurs = array(); 157 167 $datas = array(); … … 159 169 // Vérifier que les champs obligatoires sont bien là : 160 170 foreach($tChOblig as $obligatoire) { 161 if (_request($obligatoire) == NULL) { 162 $erreurs[$obligatoire] = _T('hydraulic:champ_obligatoire'); 163 } 164 else if(_request($obligatoire) == 0){ 165 $erreurs[$obligatoire] = _T('hydraulic:valeur_positive'); 166 } 171 if (_request($obligatoire) == NULL) { 172 $erreurs[$obligatoire] = _T('hydraulic:champ_obligatoire'); 173 } 167 174 else { 168 175 $datas[$obligatoire] = _request($obligatoire); … … 170 177 } 171 178 172 173 foreach($datas as $champ=>$data) 174 if ($data < 0) $erreurs[$champ] = _T('hydraulic:valeur_positive_nulle');175 } 176 179 // Gestion des valeurs négatives 180 foreach($datas as $champ=>$data){ 181 if($data < 0 && !strstr($champ, 'Cr_rIf')) $erreurs[$champ] = _T('hydraulic:valeur_positive_nulle'); 182 } 183 177 184 if (count($erreurs)) { 178 185 $erreurs['message_erreur'] = _T('hydraulic:saisie_erreur'); … … 183 190 184 191 185 function formulaires_normale_critique_traiter_dist(){ 186 187 /*************************************************************************** 192 function formulaires_calcul_normale_critique_traiter_dist(){ 193 global $spip_lang; 194 include_spip('hyd_inc/cache'); 195 include_spip('hyd_inc/log.class'); 196 include_spip('hyd_inc/graph.class'); 197 include_spip('hyd_inc/section.class'); 198 include_spip('hyd_inc/dessinSection.class'); 199 200 $datas = array(); 201 $echo = ''; 202 $tChUtil = champs_obligatoires_nc(); 203 $ncTypeSection = _request('ncTypeSection'); 204 $tVarCal = array(); 205 $VarVar = ''; 206 $result = array(); 207 $champs_select_nc = champs_select_calculer(); 208 209 foreach($tChUtil as $champ) { 210 if (_request($champ)){ 211 $datas[$champ] = _request($champ); 212 } 213 214 if(id_decoupe($champ, 0, 2) == 'pas_var'){ 215 $VarVar = id_decoupe($champ, 2, 2); 216 } 217 $datas[$champ] = str_replace(',','.',$datas[$champ]); // Bug #574*/ 218 } 219 220 // On ajoute la langue en cours pour différencier le fichier de cache par langue 221 $datas['sLang'] = $spip_lang; 222 223 // Nom du fichier en cache pour calcul déjà fait 224 $CacheFileName=md5(serialize($datas)); 225 226 // Initialisation de la classe chargée d'afficher le journal de calcul 227 $oLog = new cLog(); 228 229 //Transformation des variables contenues dans $datas 230 foreach($datas as $champ=>$data) { 231 ${$champ}=$data; 232 } 233 234 /*************************************************************************** 188 235 * Calcul normale critique 189 236 ***************************************************************************/ 190 191 192 /*************************************************************************** 237 $oParam= new cParam($Cr_rKs, $Cr_rQ, $Cr_rIf, $Param_calc_rPrec, $Cr_rYB); 238 switch($ncTypeSection) { 239 case 'FT': 240 include_spip('hyd_inc/sectionTrapez.class'); 241 $oSection=new cSnTrapez($oLog,$oParam,$FT_rLargeurFond,$FT_rFruit); 242 break; 243 244 case 'FR': 245 include_spip('hyd_inc/sectionRectang.class'); 246 $oSection=new cSnRectang($oLog,$oParam,$FR_rLarg); 247 break; 248 249 case 'FC': 250 include_spip('hyd_inc/sectionCirc.class'); 251 $oSection=new cSnCirc($oLog,$oParam,$FC_rD); 252 break; 253 254 case 'FP': 255 include_spip('hyd_inc/sectionPuiss.class'); 256 $oSection=new cSnPuiss($oLog,$oParam,$FP_rCoef,$FP_rLargBerge); 257 break; 258 259 default: 260 include_spip('hyd_inc/sectionTrapez.class'); 261 $oSection=new cSnTrapez($oLog,$oParam,$FT_rLargeurfond,$FT_rFruit); 262 263 } 264 $oSection->rY = $Cr_rY; 265 266 $min = 0; 267 $max = 0; 268 $pas = 1; 269 $i = 0; 270 271 $tChampsSect = mes_saisies_normale_critique(); 272 $champsSection = array(); 273 274 foreach($tChampsSect as $IdFS=>$FieldSet){ 275 if(substr($IdFS, 0, 1) == 'F'){ 276 foreach($FieldSet[1] as $Cle=>$Champ) { 277 $champsSection[] = $IdFS.'_'.$Cle; 278 } 279 } 280 } 281 282 if($VarVar != ''){ 283 $tVarCal[] = _request('val_a_cal_nc'); 284 $min = _request('val_min_'.$VarVar); 285 $max = _request('val_max_'.$VarVar); 286 $pas = _request('pas_var_'.$VarVar); 287 $valACalculer = id_decoupe($VarVar, 1, 1); 288 if($valACalculer == 'rY' or in_array($VarVar, $champsSection)){ 289 $oSection->{$valACalculer} = &$i; 290 } 291 else{ 292 $oParam->{$valACalculer} = &$i; 293 } 294 } 295 else { 296 $tVarCal = array('Hs', 'Hsc', 'B', 'P', 'S', 'R', 'V', 'Fr', 'Yc', 'Yn', 'Yf', 'Yt', 'Yco', 'J', 'I-J', 'Imp', 'Tau0'); 297 } 298 299 $max += $pas/2; 300 301 $bNoCache = false; // true pour débugage 302 if(!$bNoCache && is_file(HYD_CACHE_DIRECTORY.$CacheFileName)) { 303 // On récupère toutes les données dans un cache déjà créé 304 $result = ReadCacheFile($CacheFileName); 305 } 306 else{ 307 for($i = $min; $i <= $max; $i+= $pas){ 308 $oSection->Reset(true); 309 foreach($tVarCal as $sCalc){ 310 $rY = $oSection->rY; 311 if(!in_array($sCalc,array('Yn', 'Yc', 'Hsc'))){ 312 $result[] = $oSection->Calc($sCalc); 313 } 314 else{ 315 $result[] = $oSection->CalcGeo($sCalc); 316 } 317 $oSection->rY = $rY; 318 } 319 } 320 //Enregistrement des données dans fichier cache 321 WriteCacheFile($CacheFileName,$result); 322 } 323 /*************************************************************************** 324 * Une valeur varie 325 ****************************************************************************/ 326 if($VarVar != ''){ 327 328 /*************************************************************************** 193 329 * Affichage du tableau de données 194 330 ****************************************************************************/ 195 331 332 $tabClass = array(); 333 foreach($tChampsSect as $cleFD=>$champsFD){ 334 foreach($champsFD[1] as $cle=>$valeur){ 335 if(substr($cleFD, 0, 1) != 'F' || $cleFD == _request('ncTypeSection')){ 336 if(substr(_request('choix_champs_'.$cleFD.'_'.$cle), 0, 3) == 'var'){ 337 $tabClass['var'] = $valeur[0]; 338 } 339 else if(substr(_request('choix_champs_'.$cleFD.'_'.$cle), 0, 3) != 'var' && _request($cleFD.'_'.$cle)){ 340 $tabClass['val'.$i] = $valeur[0]; 341 $i++; 342 } 343 } 344 } 345 } 346 347 $var_a_cal = ''; 348 foreach($champs_select_nc as $cle=>$valeur){ 349 if($cle == _request('val_a_cal_nc')){ 350 $var_a_cal = _T('hydraulic:'.$valeur); 351 } 352 } 353 354 $echo.='<table class="spip"> 355 <thead> 356 <tr class="row_first">'; 357 358 foreach($tabClass as $cle=>$valeur){ 359 if(substr($cle, 0, 3) == 'val'){ 360 $echo.= '<th scope="col" rowspan="2" style="text-align:center;">'._T('hydraulic:'.$tabClass[$cle]).'</th>'; 361 } 362 } 363 364 $echo.= ' <th style="text-align:center;" scope="col" rowspan="2">('._T('hydraulic:abscisse').')<br/>'._T('hydraulic:'.$tabClass['var']).'</th> 365 <th style="text-align:center;" scope="col" rowspan="2">('._T('hydraulic:ordonnee').')<br/>'.$var_a_cal.'</th> 366 </tr> 367 </thead> 368 <tbody>'; 369 370 $i=0; 371 $tabAbs = array(); 372 373 $ValeurVarie = $min; 374 375 foreach($result as $indice){ 376 $i++; 377 $echo.= '<tr class="align_right '; 378 $echo.=($i%2==0)?'row_even':'row_odd'; 379 $echo.='">'; 380 381 foreach($datas as $cle=>$valeur){ 382 if((substr($cle, 0, 1) == 'F' || substr($cle, 0, 2) == 'Cr') && $valeur != 0){ 383 $echo.= '<td>'; 384 $echo.= format_nombre($valeur, $oSection->oP->iPrec).'</td>'; 385 } 386 } 387 388 $echo.= '<td>'.format_nombre($ValeurVarie, $oSection->oP->iPrec).'</td><td>'.format_nombre($indice, $oSection->oP->iPrec).'</td>'; 389 $echo.= '</tr>'; 390 $tabAbs[] = $ValeurVarie; 391 $ValeurVarie+= $pas; 392 } 393 394 $echo.= '</tbody> 395 </table>'; 396 397 /*************************************************************************** 398 * Affichage du graphique 399 ****************************************************************************/ 400 if(is_infinite($result[0])){ 401 unset($result[0]); 402 $result = array_values($result); 403 unset($tabAbs[0]); 404 $tabAbs = array_values($tabAbs); 405 } 406 407 $oGraph = new cGraph(); 408 // Ligne Courbe normale critique 409 if(isset($result)) { 410 $oGraph->AddSerie( 411 $var_a_cal, 412 $tabAbs, 413 $result, 414 '#00a3cd', 415 'lineWidth:3, showMarker:true, markerOptions:{style:\'filledCircle\', size:8}'); 416 } 417 // Récupération du graphique 418 $echo .= $oGraph->GetGraph('ligne_normale_critique',400,600); 419 $echo .= _T('hydraulic:'.$tabClass['var']); 420 421 } 422 196 423 /*************************************************************************** 424 * Aucune valeur ne varie 425 ****************************************************************************/ 426 else{ 427 428 /*************************************************************************** 429 * Affichage du tableau de données 430 ****************************************************************************/ 431 $lib_data = array(); 432 $test = champs_select_calculer(); 433 $par = 0; 434 435 foreach($tVarCal as $champ){ 436 $lib_data[$champ][] = $result[$par]; 437 $lib_data[$champ][] = $test[$champ]; 438 $par++; 439 } 440 441 $idCla = 0; 442 443 $echo.='<table class="spip" id="tableau_nc" style="display: inline-block;"> 444 <tbody>'; 445 446 foreach($lib_data as $cal=>$datas){ 447 $idCla++; 448 $echo.= '<tr class="align_right '; 449 $echo.=($idCla%2==0)?'row_even':'row_odd'; 450 $echo.='">'; 451 $echo.= '<td class="varACal">'; 452 $echo.= $cal.': '._T('hydraulic:'.$datas[1]).'</td>'; 453 $echo.= '<td>'.format_nombre($datas[0], $oSection->oP->iPrec).'</td>'; 454 $echo.= '</tr>'; 455 456 } 457 $echo.= '</tbody> 458 </table>'; 459 460 461 /*************************************************************************** 197 462 * Affichage du graphique 198 463 ****************************************************************************/ 199 464 200 465 $lib_datas = array(); 466 $par = 0; 467 468 foreach($tVarCal as $champ){ 469 if(substr($test[$champ], 0, 6) == 'tirant' || $champ == 'Hs' || $champ == 'Hsc'){ 470 $lib_datas[$champ] = $result[$par]; 471 } 472 $par++; 473 } 474 475 $lib_datas['rYB'] = $oSection->oP->rYB; 476 $dessinSection = new dessinSection(250, 200, $ncTypeSection, $oSection, $lib_datas); 477 $echo.= $dessinSection->GetDessinSection(); 478 } 479 480 $res['message_ok'] = $echo; 481 return $res; 201 482 } 202 483 ?> -
_plugins_/hydraulic/trunk/formulaires/courbe_remous.html
r59892 r60821 5 5 //Permet d'afficher ou cacher les champs correspondant à une section. 6 6 function afficher_cacher() { 7 var section = getSelectValue('choix_section_cr'); 8 var f = document.getElementById("form_courbe_remous"); 9 if(f) { 10 var champs = f.getElementsByTagName("tr"); 11 // On parcourt tous les <tr> du formulaire 12 for(var i=0, n=champs.length; i<n; i++) { 13 // Si le champ appartient à la section choisis , alors on l'affiche. 14 if((champs[i].getAttribute("id") != null) &&((champs[i].getAttribute("id")).substr(0,2) == section)){ 15 document.getElementById((champs[i].getAttribute("id"))).style.display='table-row'; 16 } 17 // Sinon si il appartient aux autres sections, alors on le masque 18 else if((champs[i].getAttribute("id") != null) &&((champs[i].getAttribute("id")).substr(0,1) == 'F')) { 19 document.getElementById((champs[i].getAttribute("id"))).style.display='none'; 20 } 7 21 8 var section = getSelectValue('choix_section'); 9 var f = document.getElementById("form_courbe_remous"); 10 if(f) { 11 var champs = f.getElementsByTagName("tr"); 12 for(var i=0, n=champs.length; i<n; i++) { 13 14 15 if((champs[i].getAttribute("id") != null) &&((champs[i].getAttribute("id")).substr(0,2) == section)){ 16 document.getElementById((champs[i].getAttribute("id"))).style.display='table-row'; 17 18 } 19 else if((champs[i].getAttribute("id") != null) &&((champs[i].getAttribute("id")).substr(0,1) == 'F')) { 20 document.getElementById((champs[i].getAttribute("id"))).style.display='none'; 21 22 } 23 24 } 25 } 26 22 } 23 } 27 24 } 28 25 </script> … … 32 29 <table class="hyd_formulaire"> 33 30 <tbody> 34 <tr id="type_section_field ">31 <tr id="type_section_field_cr"> 35 32 <td colspan="2"><div class="hyd_formulaire_chapitre"><:hydraulic:type_section:></div></td> 36 33 </tr> 37 34 38 <tr id="type_section_choix ">35 <tr id="type_section_choix_cr"> 39 36 <td align="right"> 40 37 <:hydraulic:choix_section:> : 41 38 </td> 42 39 40 <!-- On génére les options du select, correspondant aux types de section --> 43 41 <td> 44 <select name=" lTypeSection" id="choix_section" onChange="afficher_cacher();">42 <select name="crTypeSection" id="choix_section_cr" onChange="afficher_cacher();"> 45 43 <BOUCLE_selectOptions(POUR){tableau #ENV{mes_saisies}}> 46 44 #SET{test, #VALEUR|table_valeur{0}|decoupeIdSection} 47 45 <BOUCLE_choixSection(CONDITION){si #CLE|substr{0,1}|== {'F'}}> 48 <option value="#CLE" [(#ENV{ lTypeSection}|=={#CLE}|?{'selected',''})]>#GET{test}</option>46 <option value="#CLE" [(#ENV{crTypeSection}|=={#CLE}|?{'selected',''})]>#GET{test}</option> 49 47 </BOUCLE_choixSection> 50 48 </BOUCLE_selectOptions> … … 60 58 #SET{id_fieldset, #CLE} 61 59 62 <tr id="#GET{id_fieldset}_field" style="display:[(#CLE|match{^([(#ENV{lTypeSection})]|Caract_bief|Cond_lim|Param_calc)$}|?{'table-row','none'})];"> 60 <!-- Fieldset des champs--> 61 <tr id="#GET{id_fieldset}_field" style="display:[(#CLE|match{^([(#ENV{crTypeSection})]|Caract_bief|Cond_lim|Param_calc)$}|?{'table-row','none'})];"> 63 62 <td colspan="2"><div class="hyd_formulaire_chapitre">[(#VALEUR|table_valeur{0}|traduction_hydraulic)]</div></td> 64 63 </tr> 65 64 66 65 <BOUCLE_champsLib(POUR){tableau (#VALEUR|table_valeur{1})}> 67 68 <tr id="#GET{id_fieldset}_#CLE" style="display:[(#GET{id_fieldset}|match{^([(#ENV{lTypeSection})]|Caract_bief|Cond_lim|Param_calc)$}|?{'table-row','none'})];"> 66 67 <!-- Tous les champs d'un seul fieldset --> 68 <tr id="#GET{id_fieldset}_[(#CLE)]" style="display:[(#GET{id_fieldset}|match{^([(#ENV{crTypeSection})]|Caract_bief|Cond_lim|Param_calc)$}|?{'table-row','none'})];"> 69 69 <td align="right" width="65%"> 70 70 [(#VALEUR|table_valeur{0}|traduction_hydraulic)] : … … 72 72 73 73 <td width="35%"> 74 <input type="text" value="[(#ENV{#GET{id_fieldset}_ #CLE})]" maxlength="30" name="#GET{id_fieldset}_#CLE">75 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{#GET{id_fieldset}_ #CLE})</div>]74 <input type="text" value="[(#ENV{#GET{id_fieldset}_[(#CLE)]})]" maxlength="30" name="#GET{id_fieldset}_[(#CLE)]"> 75 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{#GET{id_fieldset}_[(#CLE)]_cr})</div>] 76 76 </td> 77 77 -
_plugins_/hydraulic/trunk/formulaires/courbe_remous.php
r59892 r60821 1 1 <?php 2 /* 3 * formulaires/courbe_remous.php 2 /** 3 * @file formulaires/courbe_remous.php 4 * Fonctions du formulaire CVT pour les courbes de remous 5 */ 6 7 /* Copyright 2009-2012 Dorch <dorch@dorch.fr>, Médéric Dulondel 4 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 5 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 6 18 * 7 * Copyright 2012 David Dorchies <dorch@dorch.fr> 8 * 9 * 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * 13 * it under the terms of the GNU General Public License as published by 14 * 15 * the Free Software Foundation; either version 2 of the License, or 16 * 17 * (at your option) any later version. 18 * 19 * 20 * 21 * This program is distributed in the hope that it will be useful, 22 * 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 * 25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 * 27 * GNU General Public License for more details. 28 * 29 * 30 * 31 * You should have received a copy of the GNU General Public License 32 * 33 * along with this program; if not, write to the Free Software 34 * 35 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 36 * 37 * MA 02110-1301, USA. 38 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 22 * MA 02110-1301, USA. 39 23 */ 40 24 41 25 include_spip('hyd_inc/section'); 42 26 27 /* Tableau des champs à afficher dans le formulaire. 28 * On travaille avec les libelles non traduits pour pouvoir gérer 29 * le multilinguisme. 30 */ 43 31 function mes_saisies_section() { 44 32 33 // On récupère les champs communs à tous les formulaires à savoir les champs de section. 45 34 $fieldset_champs = caract_communes(); 46 35 47 36 $fieldset_champs['Caract_bief'] = array( 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 ); 73 37 'caract_bief', 38 array( 39 'rKs' =>array('coef_strickler',50), 40 'rLong' =>array('longueur_bief', 50), 41 'rIf' =>array('pente_fond', 0.005), 42 'rYBerge'=>array('h_berge',1) 43 ) 44 ); 45 46 $fieldset_champs['Cond_lim'] = array( 47 'condition_limite', 48 array( 49 'rQ' =>array('debit_amont', 2), 50 'rYaval' =>array('h_aval_imposee', 0.6), 51 'rYamont'=>array('h_amont_imposee', 0.15) 52 ) 53 ); 54 55 $fieldset_champs['Param_calc'] = array( 56 'param_calcul', 57 array( 58 'rDx' =>array('pas_discret', 5), 59 'rPrec' =>array('precision_calc', 0.001) 60 ) 61 ); 62 74 63 return $fieldset_champs; 75 64 76 65 } 77 66 67 // Définition des champs obligatoires pour le formulaire. 78 68 function champs_obligatoires() { 79 69 80 70 $tSaisie = mes_saisies_section(); 71 $sTypeSection = _request('crTypeSection'); 81 72 $tChOblig = array(); 82 $sTypeSection = _request('lTypeSection');83 73 84 74 foreach($tSaisie as $IdFS=>$FieldSet) { 75 // Si ce n'est pas une section ou la section définie... 85 76 if((substr($IdFS,0,1) != 'F') || ($IdFS == $sTypeSection)){ 77 // ... alors on parcourt notre deuxième tableau en ajoutant les champs nécessaires. 86 78 foreach($FieldSet[1] as $Cle=>$Champ) { 87 79 if((!isset($Champ[2])) || (isset($Champ[2]) && $Champ[2])) { … … 98 90 $tSaisie_section = mes_saisies_section(); 99 91 $valeurs = array( 100 ' lTypeSection' => 'FT',92 'crTypeSection' => 'FT', 101 93 'mes_saisies' => $tSaisie_section 102 94 ); 103 95 96 // On charge tous les champs avec leur valeur 104 97 foreach($tSaisie_section as $CleFD=>$FieldSet) { 105 98 foreach($FieldSet[1] as $Cle=>$Champ) { 106 99 $valeurs[$CleFD.'_'.$Cle] = $Champ[1]; 107 100 } 108 101 } … … 112 105 113 106 function formulaires_courbe_remous_verifier_dist(){ 114 115 116 107 $erreurs = array(); 117 108 $datas = array(); 118 119 109 $tChOblig= champs_obligatoires(); 120 // verifierque les champs obligatoires sont bien là :110 // On vérifie que les champs obligatoires sont bien là : 121 111 foreach($tChOblig as $obligatoire) { 122 112 if (!_request($obligatoire)) { … … 127 117 } 128 118 119 // Gestion des valeurs négatives 129 120 foreach($datas as $champ=>$data) { 130 121 if ($data < 0) $erreurs[$champ] = _T('hydraulic:valeur_positive'); … … 150 141 $tSaisie = mes_saisies_section(); 151 142 $tChUtil = array(); 152 $lTypeSection = _request('lTypeSection'); 153 143 $crTypeSection = _request('crTypeSection'); 144 145 // On récupère tous les champs utiles, à savoir les champs fixes, et les champs appartenant à la section choisie 154 146 foreach($tSaisie as $IdFS=>$FieldSet) { 155 if((substr($IdFS,0,1) != 'F') || ($IdFS == $ lTypeSection)){147 if((substr($IdFS,0,1) != 'F') || ($IdFS == $crTypeSection)){ 156 148 foreach($FieldSet[1] as $Cle=>$Champ) { 157 149 $tChUtil[] = $IdFS.'_'.$Cle; 158 150 } 159 151 } 160 152 } 161 153 162 //On récupère les données154 //On récupère tous les champs utiles dans le tableau datas 163 155 foreach($tChUtil as $champ) { 164 156 if (_request($champ)){ … … 192 184 193 185 // Enregistrement des paramètres dans les classes qui vont bien 194 $oParam= new cParam($Cond_lim_rYaval,$Caract_bief_rKs,$Cond_lim_rQ,$Caract_bief_rLong,$Caract_bief_rIf,$Param_calc_rDx,$Param_calc_rPrec,$Caract_bief_rYBerge); 195 196 switch($lTypeSection) { 186 $oParam= new cParam($Caract_bief_rKs,$Cond_lim_rQ,$Caract_bief_rIf,$Param_calc_rPrec,$Caract_bief_rYBerge,$Cond_lim_rYaval,$Param_calc_rDx,$Caract_bief_rLong); 187 188 // Création d'un objet de type Section selon la section choisie. 189 switch($crTypeSection) { 197 190 case 'FT': 198 191 include_spip('hyd_inc/sectionTrapez.class'); 199 $oSection=new cSnTrapez($oLog,$oParam,$FT_rLarg ,$FT_rFruit);192 $oSection=new cSnTrapez($oLog,$oParam,$FT_rLargeurFond,$FT_rFruit); 200 193 break; 201 194 … … 207 200 case 'FC': 208 201 include_spip('hyd_inc/sectionCirc.class'); 209 $oSection=new cSnCirc($oLog,$oParam,$FC_rD iam);202 $oSection=new cSnCirc($oLog,$oParam,$FC_rD); 210 203 break; 211 204 212 205 case 'FP': 213 echo 'puissance'; 206 include_spip('hyd_inc/sectionPuiss.class'); 207 $oSection=new cSnPuiss($oLog,$oParam,$FP_rCoef,$FP_rLargBerge); 208 break; 214 209 215 210 default: 216 include_spip('hyd_inc/sectionTrapez.class .php');217 $oSection=new cSnTrapeze($oLog,$oParam,$FT_rLarg ,$FT_rFruit);211 include_spip('hyd_inc/sectionTrapez.class'); 212 $oSection=new cSnTrapeze($oLog,$oParam,$FT_rLargeurFond,$FT_rFruit); 218 213 } 219 214 … … 221 216 * Calcul de la ligne d'eau 222 217 ****************************************************************************/ 223 $bNoCache = false; // true pour débugage218 $bNoCache = true; // true pour débugage 224 219 if(!$bNoCache && is_file(HYD_CACHE_DIRECTORY.$CacheFileName)) { 225 220 // On récupère toutes les données dans un cache déjà créé … … 351 346 $echo.='"><td>'.format_nombre($rX,$oParam->iPrec).'</td>'; 352 347 if(isset($tr['X1']) && !(($cle = array_search($rX,$tr['X1'])) === false)) { 348 // On formalise les résultats, avec le nombre de chiffres aprés la virgule adéquat 353 349 $echo .= '<td>'.format_nombre($tr['Y1'][$cle],$oParam->iPrec).'</td>'; 354 350 $echo .= '<td>'.format_nombre($oSection->Calc('Fr', $tr['Y1'][$cle]),$oParam->iPrec).'</td>'; -
_plugins_/hydraulic/trunk/formulaires/lechapt_calmon.html
r59892 r60821 2 2 <script language="javascript" type="text/javascript" src="#CHEMIN{js/hyd_fonctions.js}"></script> 3 3 <script> 4 5 var glob = [];6 // Variables globales contenant le choix fait pour chaque ligne7 <BOUCLE_sans_coeff(POUR){tableau #ENV{tableau_caract}}>8 glob['#CLE'] = '#ENV{choix_champs_#CLE}';9 </BOUCLE_sans_coeff>10 11 // Mise a jour des variables globales12 function setVarGlob(){13 <BOUCLE_sans_coeff2(POUR){tableau #ENV{tableau_caract}}>14 glob['#CLE'] = getRadioValue('choix_champs_#CLE');15 </BOUCLE_sans_coeff2>16 }17 18 4 // Permet de switcher les valeur de L, M et N en fonction du matériau choisie 19 5 function change_valeur() { … … 30 16 document.getElementById('champs_M').value=materiau[(choix_mat*3)+1]; 31 17 document.getElementById('champs_N').value=materiau[(choix_mat*3)+2]; 32 } 18 } 19 20 function elementsParClasse(classe, tagName){ 21 var divs = document.getElementsByTagName(tagName); 22 var resultats = new Array(); 23 for(var i=0; i<divs.length; i++){ 24 if(divs[i].className == classe){ 25 resultats.push(divs[i]); 26 } 27 } 28 return resultats; 29 } 30 31 var glob = []; 32 33 // Variables globales contenant le choix fait pour chaque ligne 34 <BOUCLE_sans_coeff(POUR){tableau #ENV{tableau_caract}}> 35 glob['#CLE'] = '#ENV{choix_champs_#CLE}'; 36 </BOUCLE_sans_coeff> 37 38 // Mise a jour des variables globales 39 function setVarGlob(){ 40 <BOUCLE_sans_coeff2(POUR){tableau #ENV{tableau_caract}}> 41 glob['#CLE'] = getRadioValue('choix_champs_#CLE'); 42 </BOUCLE_sans_coeff2> 43 } 33 44 34 45 // Gére le comportement des boutons radios 35 46 function gestion_radios(nom,valeur){ 36 47 48 // Ce tableau contiendra tous les indices , ainsi que leur valeur, excepté celle qui a été cliqué 37 49 var tabPartiel = { 38 50 <BOUCLE_sans_coeff3(POUR){tableau #ENV{tableau_caract}}> … … 44 56 45 57 // Tableau des indices 46 47 58 var tabIndice = [ 48 59 <BOUCLE_sans_coeff4(POUR){tableau #ENV{tableau_caract}}> … … 51 62 ]; 52 63 53 // Si on appuis sur un bouton de type "calcul_val"54 64 if(valeur.substr(0,3) == 'cal'){ 55 65 /* … … 72 82 else if(valeur.substr(0,3) == 'var' || valeur.substr(0,3)=='val'){ 73 83 for(var cle in tabPartiel){ 84 var test = 0; 74 85 if(document.getElementById('varier_val_'+cle).checked && (glob[nom] != "calcul_val_"+nom)){ 75 document.getElementById('val_fixe_'+cle).checked=true; 86 if(document.getElementById('varier_val_'+nom).checked){ 87 document.getElementById('val_fixe_'+cle).checked=true; 88 } 76 89 setVarGlob(); 77 90 } 78 91 else if(document.getElementById('varier_val_'+cle).checked && (glob[nom] == "calcul_val_"+nom) && valeur.substr(0,3) == 'var'){ 79 80 92 document.getElementById('calcul_val_'+cle).checked=true; 81 93 document.getElementById('caract_'+cle).disabled=true; … … 83 95 setVarGlob(); 84 96 } 85 } 97 } 86 98 87 99 // Compte le nombre de calcul_val checké … … 111 123 document.getElementById('caract_'+nom).disabled=false; 112 124 document.getElementById('caract_'+indice).disabled=true; 113 var cacher = document.getElementsByClassName('champs_var_'+indice);125 var cacher = elementsParClasse('champs_var_'+indice, 'tr'); 114 126 for(var i in cacher){ 115 127 cacher[i].style.display='none'; … … 128 140 } 129 141 130 var afficher = document.getElementsByClassName('champs_var_'+nom);142 var afficher = elementsParClasse('champs_var_'+nom, 'tr'); 131 143 for(var i in afficher){ 132 144 afficher[i].style.display='table-row'; … … 134 146 135 147 for(var cle in tabPartiel){ 136 var cacher = document.getElementsByClassName('champs_var_'+cle);148 var cacher = elementsParClasse('champs_var_'+cle, 'tr'); 137 149 for(var i in cacher){ 138 150 cacher[i].style.display='none'; … … 157 169 } 158 170 } 159 var cacher = document.getElementsByClassName('champs_var_'+nom);171 var cacher = elementsParClasse('champs_var_'+nom, 'tr'); 160 172 for(var i in cacher){ 161 173 cacher[i].style.display='none'; … … 198 210 199 211 #SET{tableau_coeff,#ARRAY{1,L,2,M,3,N}} 200 201 212 <BOUCLE_coeff(POUR) {tableau #GET{tableau_coeff}}> 202 213 <tr id="materiau_coeff_#VALEUR"> … … 224 235 </tr> 225 236 226 227 <BOUCLE_caract(POUR) {tableau #ENV{tableau_caract}}> 228 229 <tr id="type_materiau_caract_#VALEUR"> 230 <td align="right"> 231 #VALEUR : 232 </td> 233 234 <td> 235 <input id="caract_#CLE" type="text" value="[(#ENV{choix_champs}|=={#CLE}|?{'',#ENV{#CLE}})]" maxlength="30" name="#CLE" [(#ENV{choix_champs_#CLE}|match{^((calcul_val_#CLE)|(varier_val_#CLE))$}|?{'disabled="true"',''})]/> 236 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{#CLE})</div>] 237 </td> 238 239 <td align="center"> 240 <input type="radio" id="calcul_val_#CLE" name="choix_champs_#CLE" value="calcul_val_#CLE" onclick="gestion_radios('#CLE', 'calcul_val_#CLE')" [(#ENV{choix_champs_#CLE}|=={calcul_val_#CLE}?{'checked',''})]/> 241 </td> 242 243 <td align="center"> 244 <input type="radio" id="varier_val_#CLE" name="choix_champs_#CLE" value="varier_val_#CLE" onclick="gestion_radios('#CLE', 'varier_val_#CLE')" [(#ENV{choix_champs_#CLE}|=={varier_val_#CLE}?{'checked',''})]/> 245 </td> 246 247 <td align="center"> 248 <input type="radio" id="val_fixe_#CLE" name="choix_champs_#CLE" value="val_fixe_#CLE" onclick="gestion_radios('#CLE', 'val_fixe_#CLE')" [(#ENV{choix_champs_#CLE}|=={val_fixe_#CLE}?{'checked',''})]/> 249 </td> 250 </tr> 251 252 253 <tr class="champs_var_#CLE" style="display:[(#ENV{choix_champs_#CLE}|=={varier_val_#CLE}|?{'table-row','none'})];"> 254 <td colspan="3" align="right"><:hydraulic:val_min:> : </td> 255 <td colspan="2"> 256 <input name="val_min_#CLE" type="text" value="#ENV{val_min_#CLE}"/> 257 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{val_min_#CLE})</div>] 258 </td> 259 </tr> 260 261 <tr class="champs_var_#CLE" style="display:[(#ENV{choix_champs_#CLE}|=={varier_val_#CLE}|?{'table-row','none'})];"> 262 <td colspan="3" align="right"><:hydraulic:val_max:> :</td> 263 <td colspan="2"> 264 <input name="val_max_#CLE" type="text" value="#ENV{val_max_#CLE}"/> 265 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{val_max_#CLE})</div>] 266 </td> 267 </tr> 268 269 <tr class="champs_var_#CLE" style="display:[(#ENV{choix_champs_#CLE}|=={varier_val_#CLE}|?{'table-row','none'})];"> 270 <td colspan="3" align="right"><:hydraulic:pas_var:> :</td> 271 <td colspan="2"> 272 <input name="pas_var_#CLE" type="text" value="#ENV{pas_var_#CLE}"/> 273 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{pas_var_#CLE})</div>] 274 </td> 275 </tr> 237 <!-- On génère les champs du formulaire en suivant le tableau caract --> 238 <BOUCLE_caract(POUR) {tableau #ENV{tableau_caract}}> 239 240 <tr id="type_materiau_caract_#VALEUR"> 241 <td align="right"> 242 #VALEUR : 243 </td> 244 245 <td> 246 <input id="caract_#CLE" type="text" value="[(#ENV{choix_champs}|=={#CLE}|?{'',#ENV{#CLE}})]" maxlength="30" name="#CLE" [(#ENV{choix_champs_#CLE}|match{^((calcul_val_#CLE)|(varier_val_#CLE))$}|?{'disabled="true"',''})]/> 247 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{#CLE})</div>] 248 </td> 249 250 <!-- Les 3 boutons radios pour le choix de la variable à calculer, varier, ou fixer --> 251 <td align="center"> 252 <input type="radio" id="calcul_val_#CLE" name="choix_champs_#CLE" value="calcul_val_#CLE" onclick="gestion_radios('#CLE', 'calcul_val_#CLE')" [(#ENV{choix_champs_#CLE}|=={calcul_val_#CLE}?{'checked',''})]/> 253 </td> 254 255 <td align="center"> 256 <input type="radio" id="varier_val_#CLE" name="choix_champs_#CLE" value="varier_val_#CLE" onclick="gestion_radios('#CLE', 'varier_val_#CLE')" [(#ENV{choix_champs_#CLE}|=={varier_val_#CLE}?{'checked',''})]/> 257 </td> 258 259 <td align="center"> 260 <input type="radio" id="val_fixe_#CLE" name="choix_champs_#CLE" value="val_fixe_#CLE" onclick="gestion_radios('#CLE', 'val_fixe_#CLE')" [(#ENV{choix_champs_#CLE}|=={val_fixe_#CLE}?{'checked',''})]/> 261 </td> 262 </tr> 263 264 <!-- Champs pour les variations de calcul. Par défaut non visible. --> 265 <tr class="champs_var_#CLE" style="display:[(#ENV{choix_champs_#CLE}|=={varier_val_#CLE}|?{'table-row','none'})];"> 266 <td colspan="3" align="right"><:hydraulic:val_min:> : </td> 267 <td colspan="2"> 268 <input name="val_min_#CLE" type="text" value="#ENV{val_min_#CLE}"/> 269 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{val_min_#CLE})</div>] 270 </td> 271 </tr> 272 273 <tr class="champs_var_#CLE" style="display:[(#ENV{choix_champs_#CLE}|=={varier_val_#CLE}|?{'table-row','none'})];"> 274 <td colspan="3" align="right"><:hydraulic:val_max:> :</td> 275 <td colspan="2"> 276 <input name="val_max_#CLE" type="text" value="#ENV{val_max_#CLE}"/> 277 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{val_max_#CLE})</div>] 278 </td> 279 </tr> 280 281 <tr class="champs_var_#CLE" style="display:[(#ENV{choix_champs_#CLE}|=={varier_val_#CLE}|?{'table-row','none'})];"> 282 <td colspan="3" align="right"><:hydraulic:pas_var:> :</td> 283 <td colspan="2"> 284 <input name="pas_var_#CLE" type="text" value="#ENV{pas_var_#CLE}"/> 285 [<div class='hyd_erreur'>(#ENV**{erreurs}|table_valeur{pas_var_#CLE})</div>] 286 </td> 287 </tr> 276 288 277 </BOUCLE_caract> 278 289 </BOUCLE_caract> 290 291 <!-- Fieldset + champs sur la précision du calcul.--> 279 292 <tr id="param_calc_lechapt_calmon"> 280 293 <td colspan="5"><div class="hyd_formulaire_chapitre"><:hydraulic:param_calcul:></div></td> … … 283 296 <tr id="precision_lechapt_calmon"> 284 297 <td align="right"> 285 <:hydraulic:precision _lechapt_calmon:> :298 <:hydraulic:precision:> : 286 299 </td> 287 300 <td> … … 301 314 </form> 302 315 303 [<div class='hydraulic_resultat' >(#ENV*{message_ok})</div>]316 [<div class='hydraulic_resultat' id="resultat_lechapt_calmon">(#ENV*{message_ok})</div>] -
_plugins_/hydraulic/trunk/formulaires/lechapt_calmon.php
r59892 r60821 46 46 function mes_champs_sans_coeff_materiau(){ 47 47 $mes_champs_sans_coeff = array( 48 49 50 51 52 48 'Q' => _T('hydraulic:param_Q'), 49 'D' => _T('hydraulic:param_D'), 50 'J' => _T('hydraulic:param_J'), 51 'Lg' => _T('hydraulic:param_Lg') 52 ); 53 53 54 54 return $mes_champs_sans_coeff; … … 401 401 } 402 402 403 $echo.= ' <th style="text-align:center;" scope="col" rowspan="2"> (Abscisse)<br/>'.$tabClass['var'].'</th>404 <th style="text-align:center;" scope="col" rowspan="2"> (Ordonnée)<br/>'.$tabClass['cal'].'</th>403 $echo.= ' <th style="text-align:center;" scope="col" rowspan="2">'._T('hydraulic:abscisse').'<br/>'.$tabClass['var'].'</th> 404 <th style="text-align:center;" scope="col" rowspan="2">'._T('hydraulic:ordonnee').'<br/>'.$tabClass['cal'].'</th> 405 405 </tr> 406 406 </thead> … … 465 465 // Récupération du graphique 466 466 $echo .= $oGraph->GetGraph('ligne_lechapt_calmon',400,600); 467 $echo .= $tabClass['var']; 467 468 } 468 469 $res['message_ok'] = $echo; -
_plugins_/hydraulic/trunk/hyd_inc/graph.class.php
r56971 r60821 85 85 $Xmin = min($tX); 86 86 $Xmax = max($tX); 87 88 if($Xmin == $Xmax){ 89 $Xmin = $Xmin * 0.9; 90 $Xmax = $Xmax * 1.1; 91 } 92 93 if($xMin == 0 && $Xmax == 0){ 94 $Xmin = -1; 95 $Xmax = 1; 96 } 97 87 98 $r1 = ($Xmax - $Xmin) / floatval($Tmax); 88 99 $r2 = floor($r1 * pow(10,(-floor(log10($r1))))*10)/10; 100 89 101 if($r2 > 5) { 90 102 $XTick = 10; … … 102 114 $XTick = 1; 103 115 } 116 104 117 // Ecart entre chaque graduation 105 118 $XTick = $XTick * pow(10, floor(log10($r1))); … … 257 270 $ret = sprintf("\nvar tSerie%s=[];",$this->num); 258 271 foreach($this->tXY as $rX=>$rY) { 259 $ret .= sprintf("\ntSerie%s.push([%s, %s]);", $this->num, $rX, ($rY + $rCoteFond));272 $ret .= sprintf("\ntSerie%s.push([%s, %s]);", $this->num, $rX, $rY); 260 273 } 261 274 return $ret."\n"; -
_plugins_/hydraulic/trunk/hyd_inc/newton.class.php
r59892 r60821 1 1 <?php 2 /* 3 def deriv(f , c, dx = 0.0001): 4 """5 deriv(f,c,dx) --> float 2 /** 3 * @file inc_hyd/newton.class.php 4 * Classe abstraite de résolution d'une équation par la méthode de Newton 5 */ 6 6 7 Returns f'(c), computed as a symmetric difference quotient. Make dx smaller for more precise results. 8 """ 9 10 return (f(c+dx) - f(c - dx))/ (2*dx) 7 /* Copyright 2009-2012 David Dorchies <dorch@dorch.fr> 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 22 * MA 02110-1301, USA. 23 */ 11 24 12 25 13 def fuzzyequals(a,b,tol=0.0001):14 """15 fuzzyequals(a,b,tol) --> Bool16 17 Returns True if a is within tol of b.18 """19 return abs(a-b) < tol20 21 22 def Newton(f, c):23 24 """25 Newton(f,c) --> float26 27 Returns the x closest to c such that f(x) = 0.28 """29 30 if fuzzyequals(f(c),0,tol):31 return c32 33 else:34 # catch recursion limit errors, division by zero errors35 try:36 # x_n+1 = x_n - f(x_n)/f'(x_n)37 return newton(f, c - f(c)/deriv(f,c,tol), tol)38 except:39 # We've either hit a horizontal tangent or else40 # haven't been able to find one within the recursion depth.41 return None42 */43 26 abstract class acNewton { 44 27 protected $rTol; 45 28 protected $rDx; 46 29 private $iCpt=0; 47 private $iCptMax= 100;30 private $iCptMax=50; 48 31 private $rRelax=1; /// Coefficient de relaxation 49 32 private $rFnPrec=0; /// Mémorisation du Fn précédent pour détecter le changement de signe 50 33 private $iOscil=0; /// Nombre de changement de signe de Delta 51 34 private $oLog; 35 36 37 /** 38 * Constructeur de la classe 39 * @param $oSn Section sur laquelle on fait le calcul 40 * @param $oP Paramètres supplémentaires (Débit, précision...) 41 */ 42 function __construct(cParam $oP) { 43 $this->rTol=$oP->rPrec; 44 $this->rDx=$oP->rPrec/10; 45 } 46 52 47 53 48 /** … … 64 59 */ 65 60 protected function CalcDer($x) { 66 spip_log('Newton:CalcDer $rX='.$x,'hydraulic');61 //~ spip_log('Newton:CalcDer $rX='.$x,'hydraulic'); 67 62 return ($this->CalcFn($x+$this->rDx)-$this->CalcFn($x-$this->rDx))/(2*$this->rDx); 68 63 } … … 85 80 $this->iCpt++; 86 81 $rFn=$this->CalcFn($rX); 87 // echo('</br>Newton '.$this->iCpt.' Relax='.$this->rRelax.'- f('.$rX.') = '.$rFn);82 //~ echo('</br>Newton '.$this->iCpt.' Relax='.$this->rRelax.'- f('.$rX.') = '.$rFn); 88 83 if($this->FuzzyEqual($rFn) || $this->iCpt >= $this->iCptMax) { 89 84 return $rX; … … 91 86 else { 92 87 $rDer=$this->CalcDer($rX); 93 // echo(' - f\' = '.$rDer);88 //~ echo(' - f\' = '.$rDer); 94 89 if($rDer!=0) { 95 90 /* … … 108 103 // On est dans le cas d'une oscillation autour de la solution 109 104 // On réduit le coefficient de relaxation 110 //~ echo '</br> ****** Delta='.$Delta.' DeltaPrec='.$this->rDelta;111 105 $this->rRelax *= 0.5; 112 106 } … … 139 133 * @return true si oui, false sinon 140 134 */ public function HasConverged() { 141 142 143 144 145 146 147 135 if($this->iCpt >= $this->iCptMax) { 136 return false; 137 } 138 else { 139 return true; 140 } 141 } 148 142 } 149 143 -
_plugins_/hydraulic/trunk/hyd_inc/section.class.php
r59892 r60821 1 1 <?php 2 2 /** 3 * @file class.section.php3 * @file section.class.php 4 4 * Gestion des calculs au niveau des Sections 5 5 */ … … 40 40 public $iPrec; /// Précision en nombre de décimales 41 41 42 function __construct($r YCL,$rKs, $rQ, $rLong, $rIf, $rDx, $rPrec, $rYB) {42 function __construct($rKs, $rQ, $rIf, $rPrec, $rYB, $rYCL = 0, $rDx = 0, $rLong = 0) { 43 43 $this->rYCL=(real) $rYCL; 44 44 $this->rKs=(real) $rKs; … … 64 64 //~ public $rJ; /// Perte de charge 65 65 //~ public $rFr; /// Froude 66 p rotected$rY=0; /// Tirant d'eau66 public $rY=0; /// Tirant d'eau 67 67 public $rHautCritique; /// Tirant d'eau critique 68 68 public $rHautNormale; /// Tirant d'eau normal 69 p rotected$oP; /// Paramètres du système canal (classe oParam)69 public $oP; /// Paramètres du système canal (classe oParam) 70 70 protected $oLog; /// Pour l'affichage du journal de calcul 71 71 public $rLargeurBerge; /// largeur au débordement … … 81 81 * - J : la perte de charge 82 82 * - Fr : le nombre de Froude 83 * - dS : la dérivée de S par rapport Y84 83 * - dP : la dérivée de P par rapport Y 85 84 * - dR : la dérivée de R par rapport Y … … 89 88 protected $arCalcGeo = array(); /// Données ne dépendant pas de la cote de l'eau 90 89 90 private $rY_old ; /// Mémorisation du tirant d'eau pour calcul intermédiaire 91 private $arCalc_old = array(); /// Mémorisation des données hydrauliques pour calcul intermédiaire 92 91 93 /** 92 94 * Construction de la classe. … … 94 96 */ 95 97 public function __construct(&$oLog,&$oP) { 96 $this->oP = &$oP; 97 $this->CalcGeo('B'); 98 //spip_log($this,'hydraulic'); 98 $this->oP = &$oP; 99 $this->oLog = &$oLog; 100 $this->CalcGeo('B'); 101 spip_log($this,'hydraulic'); 99 102 } 100 103 … … 110 113 111 114 /** 115 * Mémorise les données hydraulique en cours ou les restitue 116 * @param bMem true pour mémorisation, false pour restitution 117 */ 118 public function Swap($bMem) { 119 if($bMem) { 120 $this->rY_old = $this->rY; 121 $this->arCalc_old = $this->arCalc; 122 } 123 else { 124 $this->rY = $this->rY_old; 125 $this->arCalc = $this->arCalc_old; 126 $this->arCalc_old = array(); 127 } 128 } 129 130 131 /** 112 132 * Calcul des données à la section 113 133 * @param $sDonnee Clé de la donnée à calculer (voir $this->$arCalc) … … 117 137 public function Calc($sDonnee, $rY = false) { 118 138 if($rY!==false && $rY!=$this->rY) { 119 //spip_log('Calc('.$sDonnee.') rY='.$rY,'hydraulic');139 spip_log('Calc('.$sDonnee.') rY='.$rY,'hydraulic'); 120 140 $this->rY = $rY; 121 141 // On efface toutes les données dépendantes de Y pour forcer le calcul … … 144 164 $this->arCalc[$sDonnee] = $this->CalcFr(); 145 165 break; 146 case 'dS' : // dS/dY147 $this->arCalc[$sDonnee] = $this->CalcSder();148 break;149 166 case 'dP' : // dP/dY 150 167 $this->arCalc[$sDonnee] = $this->CalcPder(); … … 174 191 $this->arCalc[$sDonnee] = $this->CalcTau0(); 175 192 break; 176 case ' Yg' : // Distance du centre de gravité de la section à la surface libre177 $this->arCalc[$sDonnee] = $this->Calc Yg();193 case 'SYg' : // Distance du centre de gravité de la section à la surface libre 194 $this->arCalc[$sDonnee] = $this->CalcSYg(); 178 195 break; 179 196 case 'Imp' : // Impulsion hydraulique … … 186 203 $this->arCalc[$sDonnee] = $this->CalcAlphaDer(); 187 204 break; 205 case 'I-J' : // Variation linéaire de l'énergie spécifique (I-J) en m/m 206 $this->arCalc[$sDonnee] = $this->oP->rIf-$this->Calc('J'); 207 break; 188 208 } 189 209 } 190 //spip_log('Calc('.$sDonnee.')='.$this->arCalc[$sDonnee],'hydraulic');210 spip_log('Calc('.$sDonnee.')='.$this->arCalc[$sDonnee],'hydraulic'); 191 211 return $this->arCalc[$sDonnee]; 192 212 } … … 199 219 */ 200 220 public function CalcGeo($sDonnee) { 201 if($sDonnee != 'B' && !isset($this->arCalcGeo['B'])) {202 // Si la largeur aux berges n'a pas encore été calculée, on commence par ça203 $this->CalcGeo('B');204 }221 if($sDonnee != 'B' && !isset($this->arCalcGeo['B'])) { 222 // Si la largeur aux berges n'a pas encore été calculée, on commence par ça 223 $this->CalcGeo('B'); 224 } 205 225 if(!isset($this->arCalcGeo[$sDonnee])) { 206 226 // La donnée a besoin d'être calculée 207 //spip_log('CalcGeo('.$sDonnee.') rY='.$this->oP->rYB,'hydraulic'); 208 $this->Reset(false); 209 $this->rY = $this->oP->rYB; 227 spip_log('CalcGeo('.$sDonnee.') rY='.$this->oP->rYB,'hydraulic'); 228 $this->Swap(true); // On mémorise les données hydrauliques en cours 229 $this->Reset(false); 230 $this->rY = $this->oP->rYB; 210 231 switch($sDonnee) { 211 case 'B' : // Largeur aux berges212 $this->arCalcGeo[$sDonnee] = $this->CalcB();213 if($this->arCalcGeo[$sDonnee] < $this->oP->rYB / 100) {214 // Section fermée215 $this->bSnFermee = true;216 // On propose une fente de Preissmann égale à 1/100 de la hauteur des berges217 $this->arCalcGeo[$sDonnee] = $this->oP->rYB / 100;218 }219 $this->rLargeurBerge = $this->arCalcGeo[$sDonnee];220 break; 221 case 'S' : // Surface mouillée 232 case 'B' : // Largeur aux berges 233 $this->arCalcGeo[$sDonnee] = $this->CalcB(); 234 if($this->arCalcGeo[$sDonnee] < $this->oP->rYB / 100) { 235 // Section fermée 236 $this->bSnFermee = true; 237 // On propose une fente de Preissmann égale à 1/100 de la hauteur des berges 238 $this->arCalcGeo[$sDonnee] = $this->oP->rYB / 100; 239 } 240 $this->rLargeurBerge = $this->arCalcGeo[$sDonnee]; 241 break; 242 case 'S' : // Surface mouillée au niveau des berges 222 243 $this->arCalcGeo[$sDonnee] = $this->CalcS(); 223 244 break; 224 case 'P' : // Périmètre mouillé 245 case 'P' : // Périmètre mouillé au niveau des berges 225 246 $this->arCalcGeo[$sDonnee] = $this->CalcP(); 226 247 break; … … 231 252 $this->arCalcGeo[$sDonnee] = $this->CalcYn(); 232 253 break; 254 case 'Hsc' : // Charge spécifique critique 255 $this->arCalcGeo[$sDonnee] = $this->CalcHsc(); 233 256 } 234 257 } 235 //spip_log('CalcGeo('.$sDonnee.')='.$this->arCalcGeo[$sDonnee],'hydraulic'); 258 $this->Swap(false); // On restitue les données hydrauliques en cours 259 spip_log('CalcGeo('.$sDonnee.')='.$this->arCalcGeo[$sDonnee],'hydraulic'); 236 260 return $this->arCalcGeo[$sDonnee]; 237 261 } … … 245 269 } 246 270 247 /**248 * Calcul de dérivée de la surface hydraulique par rapport au tirant d'eau.249 * @return dS250 */251 protected function CalcSder() {252 return $this->rLargeurBerge;253 }254 271 255 272 /** … … 287 304 protected function CalcRder() { 288 305 if($this->Calc('P')!=0) { 289 return ($this->Calc(' dS')*$this->Calc('P')-$this->Calc('S')*$this->Calc('dP'))/pow($this->Calc('P'),2);306 return ($this->Calc('B')*$this->Calc('P')-$this->Calc('S')*$this->Calc('dP'))/pow($this->Calc('P'),2); 290 307 } 291 308 else { … … 314 331 */ 315 332 private function CalcJ() { 316 return pow($this->oP->rQ/$this->Calc('S')/$this->oP->rKs,2)/pow($this->Calc('R'),4/3); 333 if($this->Calc('R')!=0) { 334 return pow($this->Calc('V')/$this->oP->rKs,2)/pow($this->Calc('R'),4/3); 335 } 336 else { 337 return INF; 338 } 317 339 } 318 340 … … 322 344 */ 323 345 private function CalcFr() { 324 return $this->oP->rQ/$this->Calc('S')*sqrt($this->Calc('B')/$this->Calc('S')/$this->oP->rG); 346 if($this->Calc('S')!=0) { 347 return $this->oP->rQ/$this->Calc('S')*sqrt($this->Calc('B')/$this->Calc('S')/$this->oP->rG); 348 } 349 else { 350 return INF; 351 } 325 352 } 326 353 … … 339 366 */ 340 367 private function CalcV() { 341 return $this->oP->rQ/$this->Calc('S'); 368 if($this->Calc('S')!=0) { 369 return $this->oP->rQ/$this->Calc('S'); 370 } 371 else { 372 return INF; 373 } 342 374 } 343 375 … … 350 382 } 351 383 384 385 /** 386 * Calcul de la charge spécifique critique. 387 * @return Charge spécifique critique 388 */ 389 private function CalcHsc() { 390 $this->Swap(true); // On mémorise les données hydrauliques en cours 391 // On calcule la charge avec la hauteur critique 392 $rHsc = $this->Calc('Hs',$this->CalcGeo('Yc')); 393 // On restitue les données initiales 394 $this->Swap(false); 395 return $rHsc; 396 } 397 398 352 399 /** 353 400 * Calcul du tirant d'eau critique. … … 356 403 private function CalcYc() { 357 404 $oHautCritique = new cHautCritique($this, $this->oP); 358 if(!$this->rHautCritique = $oHautCritique->Newton($this->oP->r Prec) or !$oHautCritique->HasConverged()) {359 $this->oLog (_T('hydraulic:h_critique').' : '._T('hydraulic:newton_non_convergence'));405 if(!$this->rHautCritique = $oHautCritique->Newton($this->oP->rYB) or !$oHautCritique->HasConverged()) { 406 $this->oLog->Add(_T('hydraulic:h_critique').' : '._T('hydraulic:newton_non_convergence')); 360 407 } 361 408 return $this->rHautCritique; … … 369 416 $oHautNormale= new cHautNormale($this, $this->oP); 370 417 if(!$this->rHautNormale = $oHautNormale->Newton($this->CalcGeo('Yc')) or !$oHautNormale->HasConverged()) { 371 $this->oLog(_T('hydraulic:h_normale').' : '._T('hydraulic:newton_non_convergence'));372 }418 $this->oLog->Add(_T('hydraulic:h_normale').' : '._T('hydraulic:newton_non_convergence')); 419 } 373 420 return $this->rHautNormale; 374 421 } … … 379 426 */ 380 427 private function CalcYf() { 381 if($this->rY > $this->Calc ('Yc')) {428 if($this->rY > $this->CalcGeo('Yc')) { 382 429 return $this->rY; 383 430 } 384 431 else { 385 $oHautCorrespondante= new cHautCorrespondante($this, $ oP);386 return $oHautCorrespondante->Newton($this->Calc('Yc') );432 $oHautCorrespondante= new cHautCorrespondante($this, $this->oP); 433 return $oHautCorrespondante->Newton($this->Calc('Yc')*2); 387 434 } 388 435 } … … 393 440 */ 394 441 private function CalcYt() { 395 if($this->rY < $this->Calc ('Yc')) {442 if($this->rY < $this->CalcGeo('Yc')) { 396 443 return $this->rY; 397 444 } 398 445 else { 399 $oHautCorrespondante= new cHautCorrespondante($this, $ oP);400 return $oHautCorrespondante->Newton($this->Calc ('Yc'));446 $oHautCorrespondante= new cHautCorrespondante($this, $this->oP); 447 return $oHautCorrespondante->Newton($this->CalcGeo('Yc')/2); 401 448 } 402 449 } … … 407 454 */ 408 455 private function CalcYco() { 409 return (sqrt(1 + 8 * pow($this->Calc('Fr'),2)) - 1) / 2;456 return $this->rY*(sqrt(1 + 8 * pow($this->Calc('Fr'),2)) - 1) / 2; 410 457 } 411 458 … … 415 462 */ 416 463 private function CalcTau0() { 417 return 1000 * $ oP->rG * $this->Calc('R') * $oP->rIf;464 return 1000 * $this->oP->rG * $this->Calc('R') * $this->oP->rIf; 418 465 } 419 466 … … 422 469 * @return Distance du centre de gravité de la section à la surface libre 423 470 */ 424 protected function Calc Yg($rY) {471 protected function CalcSYg($rY) { 425 472 return $rY / 2; 426 473 } … … 430 477 */ 431 478 protected function CalcImp() { 432 return 1000 * ($ oP->rQ * $this->Calc('V') + $oP->rG * $this->Calc('S') * $this->Calc('Yg'));479 return 1000 * ($this->oP->rQ * $this->Calc('V') + $this->oP->rG * $this->Calc('SYg')); 433 480 } 434 481 … … 465 512 */ 466 513 function __construct($oSn,cParam $oP) { 467 $this->oSn = $oSn;514 $this->oSn = clone $oSn; 468 515 $this->oP = $oP; 469 $this->rTol=$oP->rPrec; 470 $this->rDx=$oP->rPrec/10; 516 parent::__construct($oP); 471 517 } 472 518 … … 477 523 protected function CalcFn($rX) { 478 524 // Calcul de la fonction 479 $rFn = (pow($this->oP->rQ,2)/pow($this->oSn->Calc('S',$rX),2)*($this->oSn->Calc('B',$rX)/$this->oSn->Calc('S',$rX)/$this->oP->rG)-1); 480 spip_log('cHautCritique:CalcFn('.$rX.')='.$rFn,'hydraulic'); 525 if($this->oSn->Calc('S',$rX)!=0) { 526 $rFn = (pow($this->oP->rQ,2)/pow($this->oSn->Calc('S',$rX),2)*($this->oSn->Calc('B',$rX)/$this->oSn->Calc('S',$rX)/$this->oP->rG)-1); 527 } 528 else { 529 $rFn = INF; 530 } 531 //spip_log('cHautCritique:CalcFn('.$rX.')='.$rFn,'hydraulic'); 481 532 return $rFn; 482 533 } … … 487 538 */ 488 539 protected function CalcDer($rX) { 489 // L'initialisation à partir de $rX a été faite lors de l'appel à CalcFn 490 $rDer = ($this->oSn->Calc('dB')*$this->oSn->Calc('S')-3*$this->oSn->Calc('B')*$this->oSn->Calc('dS')); 491 $rDer = pow($this->oP->rQ,2)/$this->oP->rG * $rDer / pow($this->oSn->Calc('S'),4); 492 spip_log('cHautCritique:CalcDer('.$rX.')='.$rDer,'hydraulic'); 540 if($this->oSn->Calc('S')!=0) { 541 // L'initialisation à partir de $rX a été faite lors de l'appel à CalcFn 542 $rDer = ($this->oSn->Calc('dB')*$this->oSn->Calc('S')-3*$this->oSn->Calc('B')*$this->oSn->Calc('B')); 543 $rDer = pow($this->oP->rQ,2)/$this->oP->rG * $rDer / pow($this->oSn->Calc('S'),4); 544 } 545 else { 546 $rDer = INF; 547 } 548 549 //spip_log('cHautCritique:CalcDer('.$rX.')='.$rDer,'hydraulic'); 493 550 return $rDer; 494 551 } … … 510 567 */ 511 568 function __construct($oSn, cParam $oP) { 512 $this->oSn= $oSn;569 $this->oSn= clone $oSn; 513 570 $this->rQ=$oP->rQ; 514 571 $this->rKs=$oP->rKs; 515 572 $this->rIf=$oP->rIf; 516 573 $this->rG=$oP->rG; 517 $this->rTol=$oP->rPrec; 518 $this->rDx=$oP->rPrec/10; 574 parent::__construct($oP); 519 575 } 520 576 … … 526 582 // Calcul de la fonction 527 583 $rFn = ($this->rQ-$this->rKs*pow($this->oSn->Calc('R',$rX),2/3)*$this->oSn->Calc('S',$rX)*sqrt($this->rIf)); 528 spip_log('cHautNormale:CalcFn('.$rX.')='.$rFn,'hydraulic');584 //spip_log('cHautNormale:CalcFn('.$rX.')='.$rFn,'hydraulic'); 529 585 return $rFn; 530 586 } … … 537 593 // L'initialisation a été faite lors de l'appel à CalcFn 538 594 $rDer = 2/3*$this->oSn->Calc('dR')*pow($this->oSn->Calc('R'),-1/3)*$this->oSn->Calc('S'); 539 $rDer += pow($this->oSn->Calc('R'),2/3)*$this->oSn->Calc(' dS');595 $rDer += pow($this->oSn->Calc('R'),2/3)*$this->oSn->Calc('B'); 540 596 $rDer *= -$this->rKs * sqrt($this->rIf); 541 spip_log('cHautNormale:CalcDer('.$rX.')='.$rDer,'hydraulic');597 //spip_log('cHautNormale:CalcDer('.$rX.')='.$rDer,'hydraulic'); 542 598 return $rDer; 543 599 } … … 560 616 */ 561 617 function __construct(acSection $oSn, cParam $oP) { 618 parent::__construct($oP); 562 619 $this->rY = $oSn->rY; 563 $this->rV2 = pow($oSn->Calc('V'),2); 564 $this->oSnCal = clone $oSn; 565 $this->rQ = $oP->rQ; 566 $this->rG = $oP->rG; 620 $this->rS2 = pow($oSn->Calc('S'),-2); 621 $this->oSn = clone $oSn; 622 $this->rQ2G = pow($oP->rQ,2)/(2*$oP->rG); 567 623 } 568 624 … … 572 628 */ 573 629 protected function CalcFn($rX) { 630 574 631 // Calcul de la fonction 575 $rFn = $this->rY - $rX + ($this->r V2+pow($this->oSnCal->Calc('V',$rX),2))/(2*$this->rG);632 $rFn = $this->rY - $rX + ($this->rS2-pow($this->oSn->Calc('S',$rX),-2))*$this->rQ2G; 576 633 spip_log('cHautCorrespondante:CalcFn('.$rX.')='.$rFn,'hydraulic'); 577 634 return $rFn; … … 584 641 protected function CalcDer($rX) { 585 642 // L'initialisation a été faite lors de l'appel à CalcFn 586 $rDer = - $this->rQ/ $this->rG * $this->oSnCal->Calc('dS') / pow($this->oSnCal->Calc('S'),3); 643 if($this->oSn->Calc('S')!=0) { 644 $rDer = -1 + 2 * $this->rQ2G * $this->oSn->Calc('B') / pow($this->oSn->Calc('S'),3); 645 } 646 else { 647 $rDer = INF; 648 } 587 649 spip_log('cHautCorrespondante:CalcDer('.$rX.')='.$rDer,'hydraulic'); 588 650 return $rDer; -
_plugins_/hydraulic/trunk/hyd_inc/section.php
r59892 r60821 1 <?php 1 <?php 2 /** 3 * @file inc_hyd/section.php 4 * Listes des champs concernant les sections paramétrées 5 */ 6 7 /* Copyright 2012 David Dorchies <dorch@dorch.fr>, Médéric Dulondel 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 22 * MA 02110-1301, USA. 23 */ 24 25 /* 26 * Caractéristiques des différents types de section. 27 */ 2 28 function caract_communes() { 3 29 4 30 $caract_com = array( 31 'FT' => array( 32 'def_section_trap', 33 array( 34 'rLargeurFond' =>array('largeur_fond',2.5), 35 'rFruit' =>array('fruit', 0.56) 36 ) 37 ), 5 38 6 'FT' => array( 7 'def_section_trap', 8 array( 9 'rLarg' =>array('largeur_fond',2.5), 10 'rFruit' =>array('fruit', 0.56, false) 11 ) 12 ), 39 'FR' => array( 40 'def_section_rect', 41 array( 42 'rLarg' =>array('largeur_fond',2.5), 43 ) 44 ), 13 45 14 'FR'=> array(15 'def_section_rect',16 17 'rLarg' =>array('largeur_fond',2.5),18 19 46 'FC' => array( 47 'def_section_circ', 48 array( 49 'rD' =>array('diametre',2) 50 ) 51 ), 20 52 21 'FC' => array( 22 'def_section_circ', 23 array( 24 'rDiam' =>array('diametre',2) 25 ) 26 ) 27 ); 53 'FP' => array( 54 'def_section_parab', 55 array( 56 'rCoef' =>array('coef',0.5), 57 'rLargBerge' =>array('largeur_berge', 4) 58 ) 59 ) 60 ); 28 61 29 /*'FP' => array( 30 'def_section_puis', 31 array( 32 'puiss1' =>array('champs_puissance1',10), 33 'puiss2' =>array('champs_puissance2', 0.7) 34 ) 35 ),*/ 36 37 return $caract_com; 62 return $caract_com; 38 63 } 39 64 -
_plugins_/hydraulic/trunk/hyd_inc/sectionCirc.class.php
r59892 r60821 5 5 */ 6 6 7 /* Copyright 20 09-2012 Dorch <dorch@dorch.fr>7 /* Copyright 2012 Dorch <dorch@dorch.fr> 8 8 * 9 9 * This program is free software; you can redistribute it and/or modify … … 30 30 */ 31 31 class cSnCirc extends acSection { 32 p rotected$rD; /// Diamètre du cercle32 public $rD; /// Diamètre du cercle 33 33 private $rAlpha; /// Angle de la surface libre par rapport au fond 34 34 … … 44 44 */ 45 45 protected function CalcAlpha() { 46 47 48 49 50 51 46 if($this->rY > $this->oP->rYB) { 47 $rY = $this->oP->rYB; 48 } 49 else { 50 $rY = $this->rY; 51 } 52 52 if($rY <= 0) { 53 53 return 0; … … 85 85 */ 86 86 protected function CalcB() { 87 88 89 90 91 92 87 if($this->rY > $this->oP->rYB) { 88 return parent::CalcB(); 89 } 90 else { 91 return $this->rD * sin($this->Calc('Alpha')); 92 } 93 93 } 94 94 … … 98 98 */ 99 99 protected function CalcP() { 100 101 102 103 104 105 106 100 if($this->rY > $this->oP->rYB and !$this->bSnFermee) { 101 // On n'ajoute pas le périmètre dans le cas d'une fente de Preissmann 102 return $this->CalcGeo('P') + parent::CalcP($this->rY-$this->oP->rYB); 103 } 104 else { 105 return $this->rD * $this->Calc('Alpha'); 106 } 107 107 } 108 108 … … 112 112 */ 113 113 protected function CalcS() { 114 115 116 117 118 119 114 if($this->rY > $this->oP->rYB) { 115 return $this->CalcGeo('S') + parent::CalcS($this->rY-$this->oP->rYB); 116 } 117 else { 118 return pow($this->rD,2) / 4 * ($this->Calc('Alpha') - sin($this->Calc('Alpha')) * cos($this->Calc('Alpha'))); 119 } 120 120 } 121 121 … … 125 125 */ 126 126 protected function CalcSder() { 127 128 129 130 131 132 127 if($this->rY > $this->oP->rYB) { 128 return parent::CalcSder(); 129 } 130 else { 131 return pow($this->rD,2) / 4 * $this->Calc('dAlpha') * (1 - cos(2 * $this->Calc('Alpha'))); 132 } 133 133 } 134 134 … … 138 138 */ 139 139 protected function CalcPder() { 140 141 142 143 144 145 140 if($this->rY > $this->oP->rYB && !$this->bSnFermee) { 141 return parent::CalcPder(); 142 } 143 else { 144 return $this->rD * $this->Calc('dAlpha'); 145 } 146 146 } 147 147 … … 151 151 */ 152 152 protected function CalcBder() { 153 154 155 156 157 158 153 if($this->rY > $this->oP->rYB) { 154 return parent::CalcBder(); 155 } 156 else { 157 return $this->rD * $this->Calc('dAlpha') * cos($this->Calc('Alpha')); 158 } 159 159 } 160 160 … … 163 163 * @return Distance du centre de gravité de la section à la surface libre 164 164 */ 165 protected function Calc Yg() {165 protected function CalcSYg() { 166 166 $SYg = sin($this->Calc('Alpha'))-pow(sin($this->Calc('Alpha')),3) / 3 - $this->Calc('Alpha') * cos($this->Calc('Alpha')); 167 167 $SYg = pow($this->rD,3) / 8 * $SYg; 168 return $SYg / $this->Calc('S');168 return $SYg; 169 169 } 170 170 -
_plugins_/hydraulic/trunk/hyd_inc/sectionRectang.class.php
r59892 r60821 5 5 */ 6 6 7 /* Copyright 20 09-2012 Dorch <dorch@dorch.fr>7 /* Copyright 2012 Dorch <dorch@dorch.fr> 8 8 * 9 9 * This program is free software; you can redistribute it and/or modify … … 32 32 33 33 function __construct(&$oLog,&$oP,$rLargeurFond) { 34 34 $this->rLargeurBerge = $rLargeurFond; 35 35 parent::__construct($oLog,$oP); 36 36 } … … 48 48 * @return Distance du centre de gravité de la section à la surface libre 49 49 */ 50 protected function Calc Yg() {51 return parent::Calc Yg($this->rY);50 protected function CalcSYg() { 51 return parent::CalcSYg($this->rY); 52 52 } 53 53 -
_plugins_/hydraulic/trunk/hyd_inc/sectionTrapez.class.php
r59892 r60821 41 41 42 42 protected function CalcB($bBerge=false) { 43 44 45 46 47 48 43 if(!$bBerge && $this->rY > $this->oP->rYB) { 44 return $this->rLargeurBerge; 45 } 46 else { 47 return $this->rLargeurFond+2*$this->rFruit*$this->rY; 48 } 49 49 } 50 50 51 51 protected function CalcP() { 52 52 if($this->rY > $this->oP->rYB) { 53 54 55 56 57 53 return $this->CalcGeo('P') + parent::CalcP($this->rY-$this->oP->rYB); 54 } 55 else { 56 return $this->rLargeurFond+2*sqrt(1+pow($this->rFruit,2))*$this->rY; 57 } 58 58 } 59 59 60 60 protected function CalcS() { 61 62 63 64 65 66 61 if($this->rY > $this->oP->rYB) { 62 return $this->CalcGeo('S') + parent::CalcS($this->rY-$this->oP->rYB); 63 } 64 else { 65 return $this->rY*($this->rLargeurFond+$this->rFruit*$this->rY); 66 } 67 67 } 68 68 … … 72 72 */ 73 73 protected function CalcSder() { 74 75 76 77 78 79 74 if($this->rY > $this->oP->rYB) { 75 return parent::CalcSder(); 76 } 77 else { 78 return $this->rLargeurFond + 2*$this->rFruit*$this->rY; 79 } 80 80 } 81 81 … … 85 85 */ 86 86 protected function CalcPder() { 87 88 89 90 91 92 87 if($this->rY > $this->oP->rYB) { 88 return parent::CalcPder(); 89 } 90 else { 91 return 2*sqrt(1+$this->rFruit*$this->rFruit); 92 } 93 93 } 94 94 … … 98 98 */ 99 99 protected function CalcBder() { 100 101 102 103 104 105 100 if($this->rY > $this->oP->rYB) { 101 return parent::CalcBder(); 102 } 103 else { 104 return 2*$this->rLargeurFond*$this->rFruit; 105 } 106 106 } 107 107 … … 110 110 * @return Distance du centre de gravité de la section à la surface libre 111 111 */ 112 protected function CalcYg() { 113 return ($this->rLargeurFond / 2 + $this->rFruit * $this->rY / 3) * pow($this->rY,2) / $this->Calc('S'); 112 protected function CalcSYg() { 113 if($this->Calc('S') != 0){ 114 return ($this->rLargeurFond / 2 + $this->rFruit * $this->rY / 3) * pow($this->rY,2) / $this->Calc('S'); 115 } 116 else{ 117 return INF; 118 } 114 119 } 115 120 -
_plugins_/hydraulic/trunk/hydraulic.css.html
r59892 r60821 4 4 5 5 .hyd_log { 6 border: 1px solid black;7 margin: 1.8em 1.15em;8 padding: 0.65em;9 display: block;10 background-color: #fdffdd;11 width: 100%;12 border-radius: 10px;6 border: 1px solid black; 7 margin: 1.8em 1.15em; 8 padding: 0.65em; 9 display: block; 10 background-color: #fdffdd; 11 width: 100%; 12 border-radius: 10px; 13 13 } 14 14 … … 90 90 } 91 91 92 #jqplot_ligne_lechapt_calmon, #jqplot_courbe_remous {92 #jqplot_ligne_lechapt_calmon, #jqplot_courbe_remous, #jqplot_ligne_normale_critique{ 93 93 margin: 0 auto; 94 94 } … … 97 97 text-align: right; 98 98 } 99 100 tr.align_left td { 101 text-align: left; 102 } 103 104 tr.align_right td.varACal { 105 text-align: left; 106 } 107 108 .varACal { 109 background: #919191; 110 color: white; 111 font-weight: bold; 112 } 113 114 #dessinSection{ 115 display: inline-block; 116 margin: 0 0 0 125px; 117 } 118 119 #tableau_nc { 120 margin: 0 auto; 121 } 122 123 #resultat_nc, #resultat_lechapt_calmon { 124 text-align: center; 125 } -
_plugins_/hydraulic/trunk/hydraulic_fonctions.php
r59892 r60821 1 1 <?php 2 2 3 // Renvoit la traduction du paramètre à traiter 3 4 function traduction_hydraulic($param_a_traiter) 4 5 { … … 6 7 } 7 8 9 // Découpe l'id de la section passé en paramètre et retourne la traduction adéquat 8 10 function decoupeIdSection($param_a_decoup){ 9 11 -
_plugins_/hydraulic/trunk/js/hyd_fonctions.js
r59103 r60821 15 15 return choix; 16 16 } 17 -
_plugins_/hydraulic/trunk/lang/hydraulic_en.php
r59892 r60821 17 17 'calcul_fluvial' => "Downstream boundary condition >= Critical elevation : calculation of subcritical part from downstream", 18 18 'calcul_torrentiel'=> "Uptream boundary condition <= Critical elevation : calculation of supercritical part from upstream", 19 'champ_obligatoire'=> 'This field is required',19 'champ_obligatoire'=> "This field is required", 20 20 'choix_materiau' => "Choice of material", 21 'caract _lechapt_calmon'=> "Characteristics",21 'caract' => "Characteristics", 22 22 'calculer_lechapt_calmon' => "Calculation with Lechapt and Calmon formula", 23 23 'calcul_val' => "Value to calculate", 24 24 'choix_section' => "Choice of section", 25 'caract_globale' => "Overall characteristics", 26 'charge_spe' => "", 27 'choix_donnee_calc' => "", 28 'charge_critique' => "", 29 'cote_eau' => "", 25 30 // D 26 31 'debit_amont' => "Upstream flow (m3/s)", … … 28 33 'def_section_rect'=> "Definition of rectangular section", 29 34 'def_section_circ'=> "Definition of circular section", 30 'def_section_puis'=> "Definition of power section", 31 'diametre' => "Diameter (m)", 35 'def_section_parab'=> "Definition of parabolic section", 36 'diametre' => "Diameter (m)", 37 'donnee_calc' => "", 38 'debit' => "", 32 39 // F 33 40 'fond' => "Bottom", … … 35 42 'fixer_val' => "Fixed parameter", 36 43 'fonte_beton_corrosive' =>"Unlined cast iron - Coarse concrete (corrosive water)", 37 44 'fonte_beton_ncorrosive' => "Cast steel or uncoated - Concrete coarse (somewhat corrosive water)", 38 45 'fonte_revt_ciment' => "Cast steel or cement coating", 39 46 'fonte_revt_bitume' => "Cast iron or steel coating bitumen - Concrete centrifuged", 40 47 'fonte_revt_centrifuge' => "Cast iron or steel coating centrifuged", 48 'froud' => "", 49 'force_tract' => "", 41 50 // H 42 51 'h_amont_imposee' => "Water level imposed at the upstream (m)", … … 45 54 'h_critique' => "Critical elevation", 46 55 'h_normale' => "Normal elevation", 56 //I 57 'impulsion' => "", 47 58 // L 48 59 'largeur_fond' => "Width at bottom (m)", … … 52 63 'log_titre' => "Calculation's log", 53 64 'longueur_bief' => "Length of reach (m)", 65 'larg_miroir' => "", 54 66 //N 55 67 'newton_non_convergence' => "Non-convergence of the calculation (Newton's method)", 68 // O 69 'ordonnee' => "Ordinate", 56 70 // P 57 71 'param_calcul' => "Calculation parameters", … … 61 75 'pente_fond' => "Bottom slope (m/m)", 62 76 'precision_calc' => "Accuracy of calculation and display of dimensions (m)", 63 'pas_calcul_depuis_aval' => 'Downstream boundary condition < Critical elevation : no possible calculation from downstream',64 'pas_calcul_depuis_amont' => 'Upstream boundary condition < Critical elevation : no possible calculation from upstream',65 'pas_var' => "With a variation step of",77 'pas_calcul_depuis_aval' => "Downstream boundary condition < Critical elevation : no possible calculation from downstream", 78 'pas_calcul_depuis_amont' => "Upstream boundary condition < Critical elevation : no possible calculation from upstream", 79 'pas_var' => "With a variation step of", 66 80 'pvc' => "PVC - Polyethylene", 67 81 'param_Q' => "Q: Flow (m³ / s)", … … 69 83 'param_J' => "J: Head drop (m)", 70 84 'param_Lg' => "Lg: Pipe length (m)", 71 'param_calc_lechapt_calmon' => "Calculation parameters", 72 'precision_lechapt_calmon' => "Display accuracy (m)", 85 'precision' => "Display accuracy (m)", 86 'perim_mouille' => "", 87 'perte_charge' => "", 88 //R 89 'rayon_hyd' => "", 90 'rugosite_nc' => "", 73 91 //S 74 'saisie_erreur' => 'Your entry contains errors!',92 'saisie_erreur' => "Your entry contains errors!", 75 93 'section_trap' => "Trapezoidal Section", 76 94 'section_rect' => "Rectangular Section", 77 95 'section_circ' => "Circular Section", 78 'section_puiss' => "Power Section", 96 'section_parab' => "Parabolic Section", 97 'surf_mouille' => "", 79 98 //T 80 'tirant_eau' => 'Draft (m)',99 'tirant_eau' => "Draft (m)", 81 100 'type_materiau' => "Type of material", 82 101 'tuyau_lisse1' => "Hydraulically smooth pipe - 0.05 ≤ D ≤ 0.2 ", 83 'tuyau_lisse2' => "Hydraulically smooth pipe - 0.25 102 'tuyau_lisse2' => "Hydraulically smooth pipe - 0.25 ≤ D ≤ 1 ", 84 103 'type_section' => "Type of section", 104 'tirant_eau_crit' => "", 105 'tirant_eau_norm' => "", 106 'tirant_eau_fluv' => "", 107 'tirant_eau_torr' => "", 108 'tirant_eau_conj' => "", 85 109 //V 86 110 'valeur_positive' => "This value must be strictly positive", 87 'val_min' => "From minimum value", 88 'val_max' => "To maximum value", 89 'varier_val' => "Parameter to vary " 111 'valeur_positive_nulle' => "", 112 'val_min' => "From minimum value", 113 'val_max' => "To maximum value", 114 'varier_val' => "Parameter to vary ", 115 'vit_moy' => "", 116 'var_lin' => "", 117 90 118 ); 91 119 -
_plugins_/hydraulic/trunk/lang/hydraulic_fr.php
r59892 r60821 6 6 'arret_calcul' => "Arrêt du calcul : Hauteur critique atteinte à l'abscisse", 7 7 'acier_lamine' => "Acier laminé - Béton lisse", 8 // 8 //B 9 9 'berge' => "Berge", 10 10 // C … … 19 19 'champ_obligatoire'=> "Ce champ est obligatoire", 20 20 'choix_materiau' => "Choix du matériau", 21 'caract _lechapt_calmon'=> "Caractéristiques",21 'caract' => "Caractéristiques", 22 22 'calculer_lechapt_calmon' => "Calcul avec la formule de Lechapt et Calmon", 23 23 'calcul_val' => "Paramètre à calculer", … … 27 27 'choix_donnee_calc' => "Choix de la donnée à calculer", 28 28 'charge_critique' => "La charge critique (m)", 29 'larg_miroir' => "La largeur au miroir (m)", 29 'cote_eau' => "Côte de l'eau (m)", 30 'coef' => "Coefficient", 30 31 // D 31 'debit_amont' => "Débit amont (m 3/s)",32 'debit_amont' => "Débit amont (m³/s)", 32 33 'def_section_trap'=> "Définition de la section trapézoïdale", 33 34 'def_section_rect'=> "Définition de la section rectangulaire", 34 35 'def_section_circ'=> "Définition de la section circulaire", 35 'def_section_puis'=> "Définition de la section puissance", 36 'diametre' => "Diamètre (m)", 37 'donnee_calc' => "Donnée à calculer", 36 'def_section_parab'=> "Définition de la section parabolique", 37 'diametre' => "Diamètre (m)", 38 'donnee_calc' => "Donnée à calculer", 39 'debit' => "Débit (m³/s)", 38 40 // F 39 41 'fond' => "Fond", … … 62 64 'log_titre' => "Journal des calculs", 63 65 'longueur_bief' => "Longueur du bief (m)", 66 'larg_miroir' => "La largeur au miroir (m)", 64 67 //N 65 68 'newton_non_convergence' => "Non convergence du calcul (Méthode de Newton)", 69 // O 70 'ordonnee' => "Ordonnée", 66 71 // P 67 72 'param_calcul' => "Paramètres de calcul", … … 79 84 'param_J' => "J: Perte de charge (m)", 80 85 'param_Lg' => "Lg: Longueur du tuyau (m)", 81 'precision _lechapt_calmon' => "Précision de calcul(m)",86 'precision' => "Précision de calcul(m)", 82 87 'perim_mouille' => "Le périmètre mouillé (m)", 83 88 'perte_charge' => "La perte de charge (m/m)", 89 84 90 //R 85 91 'rayon_hyd' => "Le rayon hydraulique (m)", 92 'rugosite_nc' => "Rugosité (SI)", 86 93 //S 87 94 'saisie_erreur' => "Votre saisie contient des erreurs !", … … 89 96 'section_rect' => "Section Rectangulaire", 90 97 'section_circ' => "Section Circulaire", 91 'section_p uiss' => "Section Puissance",98 'section_parab' => "Section Parabolique", 92 99 'surf_mouille' => "La surface mouillée (m²)", 93 100 //T -
_plugins_/hydraulic/trunk/plugin.xml
r59892 r60821 5 5 <auteur>David Dorchies, Médéric Dulondel</auteur> 6 6 <licence>GNU/GLP</licence> 7 <version>0. 4.1</version>7 <version>0.5.1</version> 8 8 <necessite id="lib:dist" src="https://bitbucket.org/cleonello/jqplot/downloads/jquery.jqplot.1.0.0b2_r1012.zip" /> 9 9 <slogan> … … 17 17 18 18 Les formulaires de calcul disponibles sont : 19 -*<formulaire|courbe_remous> : Calcul d'une courbe de remous dans un canal à section paramétrée à surface libre 20 -*<formulaire|lechapt_calmon> : Calculs pour une conduite circulaire en charge avec la formule de Lechapt et Calmon 19 -* <formulaire|courbe_remous> : Calcul d'une courbe de remous dans un canal à section paramétrée à surface libre 20 -* <formulaire|lechapt_calmon> : Calculs pour une conduite circulaire en charge avec la formule de Lechapt et Calmon 21 -* <formulaire|calcul_normale_critique> : Calcul des paramètres hydrauliques d'une section paramétrée 21 22 [en]Calculator for performing calculations in hydraulic adapted to canals and rivers. The plugin comes 22 23 as forms to be inserted into articles, sections or skeletons. … … 25 26 -* <formulaire|courbe_remous> : Calculation of a backwater curve in a parametrized section channel with free surface 26 27 -* <formulaire|lechapt_calmon> : Calculations on hydraulic head for a circular pipe with Lechapt and Calmon formula 28 -* <formulaire|calcul_normale_critique> : Calculation of hydraulic parameters in a parametrized section 27 29 </multi> 28 30 </description>
Note: See TracChangeset
for help on using the changeset viewer.