def OnGrapheXY(self,evt): """permet de fair eune graphe xy de la vairable representee et des donnees""" dicData=self.model.getBase('Data'); groupe, nom, obj = self.visu.getCurrentVisu();#print groupe,nom nom = nom.split('_')[-1] # recupere les coords des forages et data mesures lZone=self.model.Aquifere.getZoneList('Forages') nF = len(lZone);mesu=[];lxy=[] # nb forages dans interface if (len(dicData['cols'])!=0)and(nom in dicData['cols']): iC=dicData['cols'].index(nom);n=0 for z in lZone: nomF=z.getNom() if nomF in dicData['lignes']: n += 1;iR = dicData['lignes'].index(nomF) mesu.append(dicData['data'][iR,iC]) lxy.append(z.getXy()[0]); else : self.OnMessage("pas de donnees");return # recupere les donnees simulees (vue actuelle) calc = []; if len(obj)>=2: # objet de type contour for xy in lxy: i,j=self.getIndexPt(xy,obj) # coord du forage ds grille calc.append(obj[2][i,j]) # obj contient x,y,z self.plt=MyDialogs.plotxy(self.model.gui,-1);self.plt.Show(True) self.plt.draw(mesu,calc,nom,"Comparaison", "mesure", "calcul",'+')
def OnValeurZ(self, evt): #changer la valeur, faire apparaitre le dialogue z = self.currentZone if z == None: return val = z.getVal() if type(val) == type([5, 6]): val = 'liste' nom = z.getNom() info = z.getInfo() l0 = [(nom, val)] typz = 'B.Condition' if self.currentVar in ['Potentiel', 'Transport', 'PHT3D']: typz = info[3] if typz == 'Constant': typz = 'B.Condition' # pb with old versions l0.append(('Type', [typz, ['Initial', 'B.Condition', 'Transient']])) dialg = MyDialogs.MyGenericCtrl(self, "modifier zone", l0) if dialg.ShowModal() == wx.ID_OK: lst2 = dialg.GetValues() if lst2[0][1] != 'liste': val = lst2[0][1] z.setVal(val) self.visu.modifValZone(self.currentVar, self.izone, val) self.valZ.SetLabel("Val : " + str(val)) # changer la valeur pour la zone selectionnee if self.currentVar in ['Potentiel', 'Transport', 'PHT3D']: z.setInfo(3, lst2[1][1][0]) self.aquifere.createZoneTransient() dialg.Destroy()
def OnPasteZone(self, evt): var = self.currentVar mil = self.currentMil info = [var, self.aquifere.getNbzone(var), [mil]] units = self.aquifere.getUnits(var) l0 = [('nom', 'z'), ('Valeur (' + units + ')', 0.0)] if len(self.copyXy) > 0: xy = self.copyXy shapeZone = self.copyShape dialg = MyDialogs.MyGenericCtrl(self, "coller", l0) if dialg.ShowModal() == wx.ID_OK: lst2 = dialg.GetValues() nameZone = lst2[0][1] valueZone = lst2[1][1] self.valZ.SetLabel("Val : " + str(valueZone)) self.model.Aquifere.addZone(var, nameZone, valueZone, shapeZone, info, xy) self.visu.addZone(mil, nameZone, valueZone, shapeZone, info, xy) self.aquifere.createZoneTransient() self.visu.redraw() dialg.Destroy() # mise a jour du choix des zones pour la variable courante self.gui.modifBox.updateChoice2OnChange(var, mil) else: self.OnMessage("pas de zone copiee")
def OnChangeContour(self, groupe, nom): """ modifie la valeur et les couleurs des contours : valeur[0] : min [1] : max, [2] nb contours, [3] decimales, [4] : 'lin' log' ou 'fix', si [4]:fix, alors [0] est la serie des valeurs de contours """ valeur = self.getGlist(groupe, nom, 'valeur') col = self.getGlist(groupe, nom, 'col') dlgContour = MyDialogs.MyDialogContour(self, "Contours", valeur, col) if dlgContour.ShowModal() == wx.ID_OK: val = dlgContour.GetStrings() log = dlgContour.log.GetValue() # creer le vecteur de couleurs c = dlgContour.coul col = [(c[0].Red(), c[0].Green(), c[0].Blue()), (c[1].Red(), c[1].Green(), c[1].Blue()), (c[2].Red(), c[2].Green(), c[2].Blue())] else: return valeur = val[:5] valeur[4] = 'lin' if len(val[-1]) > 5: valeur[0] = eval(val[-1]) valeur[4] = 'fix' elif log: valeur[4] = 'log' self.setGlist(groupe, nom, 'valeur', valeur) #nb le Glist de RT3d est le mm que Reaction self.setGlist(groupe, nom, 'col', col) nom2 = nom if groupe == '6.rt3d': nom2 = 'rt' + nom elif groupe == '7.pht3d': nom2 = 'pht' + nom elif groupe == '8.reactionIsot': nom2 = nom + 'Isot' self.parent.Visu.changeContour(valeur=valeur, typC=nom2, col=col) self.parent.Visu.drawContour(nom2, True)
def onObservation(self): group=self.visu.curGroupe if group not in ['Ecoulement','Transport','PHT3D']: return typ=self.curTypO[0] # B or P t=self.curItemps; if group=='PHT3D': lesp=self.getNames('PHT3D_Especes_L'); elif group=='Ecoulement': lesp=['Charge','Flux'] else : lesp=['Transport'] lst0=zip(lesp,[False]*len(lesp)) #dialog to choose species to graph if len(lesp)>1: dlg = MyDialogs.MyGenericCtrl(self,'species',lst0) if dlg.ShowModal() == wx.ID_OK: lst1=dlg.GetValues();lesp=[] for i in range(len(lst1)): if lst1[i][1]:lesp.append(lst1[i][0]) else :return # dialog for type of graph, for flow tis dialog is useless lst0=['Valeur','Valeur ponderee','Flux']; if group!='Ecoulement': dlg = MyDialogs.MyGenericCtrl(self,'type',[('Choisir :',['Valeur',lst0])]) if dlg.ShowModal() == wx.ID_OK: #dialog to choose type of graph val=dlg.GetValues()[0][1][0]; typ+=str(lst0.index(val)); else :return dist,val,lab=self.model.onPtObs(typ,t,group,self.curZoneO,lesp) plt = MyDialogs.plotxy(self.gui,-1);plt.Show(True) znam=self.curZoneO if typ[0]=='X': plt.draw(dist,val,lab[1:],znam,lab[0],"val",typ='+'); else : plt.draw(dist,val,lab[1:],znam,lab[0],"val"); plt.Raise()
def OnInterpol(self, evt): lstDialg = self.model.getParm('Aquifere', 'Interpol') dialg = MyDialogs.MyGenericCtrl(self, 'Interpoler', lstDialg) retour = dialg.ShowModal() if retour == wx.ID_OK: lst2 = dialg.GetValues() self.model.setParm('Aquifere', 'Interpol', lst2) dialg.Destroy()
def OnPht3dOpt(self,evt): """allow to set some pht3d parameters""" lst = self.model.getParm('PHT3D','options') dlg = MyDialogs.MyGenericCtrl(self.gui,'Pht3d options',lst) retour = dlg.ShowModal(); if retour == wx.ID_OK: lst2 = dlg.GetValues(); self.model.setParm('PHT3D','options',lst2) dlg.Destroy()
def OnModflowOpt(self,evt): """allow to set some modflow parameters""" lst = self.model.getParm('Ecoulement','options') dlg = MyDialogs.MyGenericCtrl(self.gui,'Modflow options',lst) retour = dlg.ShowModal(); if retour == wx.ID_OK: lst2 = dlg.GetValues();self.model.setParm('Ecoulement','options',lst2) dlg.Destroy()
def polyVdialog(self): dlg = MyDialogs.MyGenericCtrl(self, "Point", [('Valeur', 0.)]) retour = dlg.ShowModal() if retour == wx.ID_OK: values = dlg.GetValues() self.tempZoneVal.append(float(values[0][1])) return True else: return False
def OnMt3dmsOpt(self,evt): """allow to set some mt3dms parameters""" lst = self.model.getParm('Transport','options');print lst dlg = MyDialogs.MyGenericCtrl(self.gui,'Mt3dms options',lst) retour = dlg.ShowModal(); if retour == wx.ID_OK: lst2 = dlg.GetValues() dlg.Destroy() if lst2[0][1][0]=='multiple': if type(lst[1][1])==type((5,6)): lstin=lst[1][1]*1 else : lstin=['all '+str(lst[1][1])] dlg=MyDialogs.MyListDialog(self.gui,'multiple diffusion',lstin) retour = dlg.ShowModal(); if retour == wx.ID_OK: lstout=dlg.GetStrings() lst2[1]=('Diffusion coeff (m2/s)',tuple(lstout)) print lst2 self.model.setParm('Transport','options',lst2) dlg.Destroy()
def OnVisuOpt(self,evt): """permet de fixer un certain nombre d'options du programme""" lst = self.model.getParm('visuOpt','') dialg = MyDialogs.MyGenericCtrl(self.gui,'options',lst) retour = dialg.ShowModal() if retour == wx.ID_OK: lst2 = dialg.GetValues(); self.model.setParm('visuOpt','',lst2) self.model.visu.redraw() dialg.Destroy()
def OnCalcOpt(self,evt): """permet de fixer un certain nombre d'options du programme""" lst = self.model.getParm('calcOpt','') dialg = MyDialogs.MyGenericCtrl(self.gui,'options',lst) retour = dialg.ShowModal() if retour == wx.ID_OK: lst2 = dialg.GetValues(); self.model.setParm('calcOpt','',lst2) bool=(lst2[1][1][0]=='oui') # DUAL PORO self.gui.parametresGui.setDualPoro(bool) dialg.Destroy()
def OnChange(self, evt): """ change les caracteristiques d'un affichage""" item = self.FindWindowById(evt.GetId()) n = item.GetName() #getName ou getLabelText [groupe, nom, tag] = n.split('_') item2 = self.FindWindowByName(groupe + '_' + nom + '_L') if item2 != None: nom = item2.GetStringSelection() col = self.model.getGlistParm(groupe, nom, 'col') valeur = self.model.getGlistParm(groupe, nom, 'valeur') if nom in self.change.keys(): # cas autres que contours if col == None: col = self.change[nom][0][1] if valeur == None and len(self.change[nom]) > 1: valeur = self.change[nom][1][1] lst0 = self.change[nom] lst0[0][1] = col if nom in ['Vitesse', 'Particules']: lst0[1][1] = valeur dlg = MyDialogs.MyGenericCtrl(self, nom, lst0) if dlg.ShowModal() == wx.ID_OK: lst1 = zip(*dlg.GetValues())[1] col = lst1[0] if len(lst1) > 1: valeur = lst1[1] else: return else: # cas contour dlgContour = MyDialogs.MyDialogContour(self.gui, "Contours", valeur, col) if dlgContour.ShowModal() == wx.ID_OK: valeur = dlgContour.GetStrings() # creer le vecteur de couleurs c = dlgContour.coul col = [(c[0].Red(), c[0].Green(), c[0].Blue()), (c[1].Red(), c[1].Green(), c[1].Blue()), (c[2].Red(), c[2].Green(), c[2].Blue()), int(c[3])] else: return self.model.setGlistParm(groupe, nom, 'valeur', valeur) self.model.setGlistParm(groupe, nom, 'col', col) self.onTickBox(groupe, nom, tag, True) self.visu.changeObject(groupe, nom, valeur, col)
def OnZoneMil(self, evt): """ dialogue pour modifier les milieux que recouvre une zone""" if self.currentZone == None: return mil = self.currentZone.getInfo()[2] dialg = MyDialogs.MyGenericCtrl(self, "couches zone", [('couche Haut', mil[0]), ('couche Bas', mil[-1])]) if dialg.ShowModal() == wx.ID_OK: mil = dialg.GetValues() millist = range(mil[0][1], mil[1][1] + 1) self.currentZone.setInfo(2, millist) self.visu.modifLayZone(self.currentVar, self.izone, millist) dialg.Destroy()
def onObservation(self): group = self.visu.curGroupe if group not in ['Ecoulement', 'Transport', 'PHT3D']: return typ = self.curTypO[0] # B or P t = self.curItemps if group == 'PHT3D': lesp = self.getNames('PHT3D_Especes_L') elif group == 'Ecoulement': lesp = ['Charge', 'Flux'] else: lesp = ['Transport'] lst0 = zip(lesp, [False] * len(lesp)) #dialog to choose species to graph if len(lesp) > 1: dlg = MyDialogs.MyGenericCtrl(self, 'species', lst0) if dlg.ShowModal() == wx.ID_OK: lst1 = dlg.GetValues() lesp = [] for i in range(len(lst1)): if lst1[i][1]: lesp.append(lst1[i][0]) else: return # dialog for type of graph, for flow tis dialog is useless lst0 = ['Valeur', 'Valeur ponderee', 'Flux'] if group != 'Ecoulement': dlg = MyDialogs.MyGenericCtrl(self, 'type', [('Choisir :', ['Valeur', lst0])]) if dlg.ShowModal() == wx.ID_OK: #dialog to choose type of graph val = dlg.GetValues()[0][1][0] typ += str(lst0.index(val)) else: return dist, val, lab = self.model.onPtObs(typ, t, group, self.curZoneO, lesp) plt = MyDialogs.plotxy(self.gui, -1) plt.Show(True) znam = self.curZoneO if typ[0] == 'X': plt.draw(dist, val, lab[1:], znam, lab[0], "val", typ='+') else: plt.draw(dist, val, lab[1:], znam, lab[0], "val") plt.Raise()
def BaDialog(self, evt): head = 'insert python commands below' dialg = MyDialogs.MyTextDialog(self.gui, 'Batch program', head, self.lastBatch) retour = dialg.ShowModal() if retour == wx.ID_OK: txt = dialg.GetText() #dialg.GetTextAsList() self.lastBatch = txt txt1 = txt.replace('model', 'self.gui.model') exec(txt1) ## for t in lst: ## self.lastBatch+=t+'\n' ## t1=t.replace('model','self.gui.model') ## exec(t1) else: return dialg.Destroy()
def OnHisto(self, evt): """dialogue pour rentrer un historique sur une zone""" z = self.currentZone if z == None: return li0 = [] if z.getForme() != 4 and type(z.getVal()) == type([5, 6]): li0 = z.getVal() # ne pas prendre polyV dialg = MyDialogs.MyListDialog(self, self.traduit('Historique Zone'), li0) retour = dialg.ShowModal() if retour == wx.ID_OK: li1 = dialg.GetStrings() z.setVal(li1) self.aquifere.createZoneTransient() else: return dialg.Destroy() self.visu.modifValZone(self.currentVar, self.izone, li1)
def OnZoneCreate(self, typeZone, xy, listeVal): """ la zone a ete dessinnee dans la visu, on retourne les coordonnees ici on ouvre le dialogue pour les infos sur la zone et on modifie le modele """ var = self.gui.parametresGui.getCurrentVar() units = self.aquifere.getUnits(var) nom_val = 'Valeur (' + units + ')' v0 = 0. maxmil = len(self.milist) if var == 'PHT3D': dlist = [('Nom', 'z'), ('Type', ['B.Condition', ['Initial', 'B.Condition', 'Transient']]), ('Solution nb', 1), ('Phase nb', 0), ('Exchange nb', 0), ('Surface nb', 0)] elif var in ['Potentiel', 'Transport']: dlist = [('Nom', 'z'), ('Type', ['B.Condition', ['Initial', 'B.Condition', 'Transient']]), (nom_val, v0)] elif var == 'Observation': dlist = [('Nom', 'z')] else: dlist = [('Nom', 'z'), (nom_val, v0)] if self.aquifere.getDim() == '3D': dlist.extend([('Milieu Haut', 0), ('Milieu Bas', 0)]) dlgZoneInfo = MyDialogs.MyGenericCtrl(self, "Infos sur les zones", dlist) retour = dlgZoneInfo.ShowModal() if retour == wx.ID_OK: listVal = dlgZoneInfo.GetValues() nameZone = listVal[0][1] typz = 'B.Condition' if typeZone == 4: # cas polyV if var in ['Potentiel', 'Transport']: listeVal.append(float(listVal[2][1])) else: listeVal.append(float(listVal[1][1])) valueZone = listeVal * 1 elif var in ['Potentiel', 'Transport']: valueZone = float(listVal[2][1]) if listVal[1][1][0] in ['Initial', 'Transient']: typz = 'Initial' elif var == 'PHT3D': a = str(listVal[2][1]) + str(listVal[3][1]) + str( listVal[4][1]) + str(listVal[5][1]) valueZone = int(a) # 1210 : solu 1, min 2, exchan 1 surf 0 if listVal[1][1][0] in ['Initial', 'Transient']: typz = 'Initial' # if inital put a negative value elif var == 'Observation': valueZone = 0 else: valueZone = float(listVal[1][1]) if self.aquifere.getDim() == '3D': mil = range(listVal[-2][1], listVal[-1][1] + 1) else: mil = [0] # traiter nb milieu et zone source (index zon cree pour chaque layer) info = [var, self.aquifere.getNbzone(var), mil, typz] # ajout de la (des) zone au model et du texte a la visu self.model.Aquifere.addZone(var, nameZone, valueZone, typeZone, info, xy) self.visu.addZone(mil, nameZone, valueZone, typeZone, info, xy) self.visu.redraw() # mise a jour du choix des zones pour la variable courante self.gui.modifBox.updateChoice2OnChange(var, mil) if var == 'Observation': zlist = self.aquifere.getZoneList(var) znames = [z.getNom() for z in zlist] self.gui.afficheTree.setNames('Observation_Zone_L', znames) flag = True else: self.visu.deconnecte() self.visu.redraw() flag = False dlgZoneInfo.Destroy() self.model.doAction('Top', 'zoneEnd') return flag
def OnButton(self,evt): item = self.FindWindowById(evt.GetId());n = item.GetName(); #getName ou getLabelText [groupe,nom]=n.split('_'); if groupe=='Modele': groupe='Aquifere' #car toute donnes dans aqui retour = self.gui.control.valide(groupe,nom) if retour =='Stop' : return aqui=self.model.Aquifere ### AQUIFERE if nom=='GriVar': dic1=self.model.getParm(groupe,nom) dialg = MyDialogs.MyGriVarDialog(self,self.traduit(str(nom)),dic1) retour = dialg.ShowModal() if retour == wx.ID_OK: dic2 = dialg.GetValues(); self.model.setParm(groupe,nom,dic2) dialg.Destroy() elif nom=='zList': # liste des z de couches li1=self.model.getParm(groupe,nom) dialg = MyDialogs.MyListDialog(self,self.traduit(str(nom)),li1) retour = dialg.ShowModal() if retour == wx.ID_OK: li2 = dialg.GetValues() self.model.setParm(groupe,nom,li2) dialg.Destroy() elif nom=='Variable': s=str(item.GetStringSelection()) if s=='Tr_Source': s='Transport' if s=='PH_Source': s='PHT3D' self.currentVar = self.tradinverse(s); self.setVbase(groupe,item) # met vbase actuel sur bouton elif nom=='Milieux': self.currentMil=int(item.GetStringSelection()) #self.setVbase(groupe,item) elif nom=='ValBase': if self.currentVar==None: return mil = self.currentMil v = aqui.getVbase(self.currentVar,mil) u = ' ('+aqui.getUnits(self.currentVar)+')' if self.currentVar=='Mur' or (self.currentVar=='Toit' and int(mil)==0): dialg = MyDialogs.MyGenericCtrl(self,nom+u,[(self.currentVar,v)]) if dialg.ShowModal() == wx.ID_OK: lst2 = dialg.GetValues() if lst2 != None: v = lst2[0][1] aqui.setVbase(self.currentVar,v,[mil]) elif self.currentVar=='Toit' and int(mil)>0: return else : lst=[(self.currentVar,v)] if aqui.getDim()=='3D': lst.extend([('Milieu Haut',0),('Milieu Bas',0)]) dialg = MyDialogs.MyGenericCtrl(self,nom+u,lst) if dialg.ShowModal() == wx.ID_OK: lst2 = dialg.GetValues() if lst2 != None: v = lst2[0][1];llist=[self.currentMil] if aqui.getDim()=='3D': llist= range(lst2[1][1],lst2[2][1]+1) #range of media aqui.setVbase(self.currentVar,v,[int(l)for l in llist]) dialg.Destroy() but=self.FindWindowByName(groupe+'_ValBase') but.SetLabel(str(v)) #self.vbase.SetLabel(str(v)) elif nom=='Carte' : dlg = wx.FileDialog(self,self.traduit("Choisir une carte"),"","","*.png",wx.OPEN) retour = dlg.ShowModal() if retour == wx.ID_OK: path = dlg.GetPath() self.model.setMap(path) else : return dlg.Destroy() ### ECOULEMENT elif nom=='Particule': pName = self.model.getProjectName(); if pName=='': # pas de projet self.OnMessage('creez ou sauvez votre projet') return self.visu.startParticules(); self.startP = True; self.model.doAction('Top','zoneStart') ### Transport elif nom in ['Import','Write']: pass elif nom=='Chemistry': dic = self.model.getParm(groupe,nom) dialg = MyDialogs.MyNoteBook(self,"Chemistry",dic) retour = dialg.ShowModal() if retour == wx.ID_OK: dic2 = dialg.GetValues() if dic2 != None: self.model.setParm(groupe,nom,dic2) dialg.Destroy() elif nom=='PH_Source': nomv ='PHT3D';self.currentVar=nomv; self.visu.changeAxesOri('Z',self.currentMil) self.visu.showVar(nomv,self.currentMil) elif nom=='Immobile': dic = self.model.getParm(groupe,nom) dialg = MyDialogs.MyNoteBook(self,"Chemistry Immobile",dic) retour = dialg.ShowModal() if retour == wx.ID_OK: dic2 = dialg.GetValues() if dic2 != None: self.model.setParm(groupe,nom,dic2) dialg.Destroy() ### Observation elif nom=='ZoneO': nomv ='Observation';self.currentVar=nomv; self.visu.changeAxesOri('Z',self.currentMil) self.visu.showVar(nomv,self.currentMil) zlist=aqui.getZoneList(nomv);znames=[z.getNom() for z in zlist] self.gui.afficheTree.setNames('Observation_Zone_L',znames) ### GENERIQUES elif nom[:3]=='Run': pass else : lstDialg = self.model.getParm(groupe,nom) if lstDialg==None: return u = self.unitsForDialog(nom) dialg = MyDialogs.MyGenericCtrl(self,str(nom)+u,lstDialg) retour = dialg.ShowModal() if retour == wx.ID_OK: lst2 = dialg.GetValues() if lst2 != None: self.model.setParm(groupe,nom,lst2) dialg.Destroy() self.model.doAction(groupe,nom)