Skip to content

Commit

Permalink
release 0
Browse files Browse the repository at this point in the history
  • Loading branch information
patricev committed Jan 18, 2016
1 parent 7e33607 commit 6b29ed0
Show file tree
Hide file tree
Showing 22 changed files with 3,545 additions and 1,424 deletions.
48 changes: 31 additions & 17 deletions dialogs/posttelemacpropertiesdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def __init__(self, layer1, parent=None):
#*********************************************************************************
def update(self):
"""
update dialog when selafin layer changed
update dialog when selafin layer changes
"""
if self.layer.hydraufilepath is not None:
paramtemp = self.layer.param_displayed #param_gachete deleted with clear - so save it
Expand Down Expand Up @@ -282,6 +282,9 @@ def update(self):
#*********************************************************************************

def errorMessage(self,str):
"""
Show message str in main textbrowser
"""
self.textBrowser_main.setTextColor(QColor("red"))
self.textBrowser_main.setFontWeight(QFont.Bold)
self.textBrowser_main.append(ctime() + ' - '+ str)
Expand All @@ -290,6 +293,9 @@ def errorMessage(self,str):
self.textBrowser_main.verticalScrollBar().setValue(self.textBrowser_main.verticalScrollBar().maximum())

def normalMessage(self,str):
"""
Show message error str in main textbrowser
"""
self.textBrowser_main.append(ctime() + ' - '+ str)
self.textBrowser_main.setTextColor(QColor("black"))
self.textBrowser_main.setFontWeight(QFont.Normal)
Expand All @@ -300,6 +306,9 @@ def normalMessage(self,str):
#*********************************************************************************

def loadSelafin(self):
"""
Called when clicking on load selafin button
"""
str1 = self.tr("Result file chooser")
str2 = self.tr("Telemac files")
str3 = self.tr("All files")
Expand All @@ -316,6 +325,9 @@ def loadSelafin(self):


def set_layercrs(self):
"""
Called when clicking on selafin'crs button
"""
source = self.sender()
self.crsselector.exec_()
crs = self.crsselector.selectedAuthId()
Expand All @@ -336,7 +348,7 @@ def set_layercrs(self):
#Display tools - time ***********************************************

def change_timetxt(self,intitmetireation):
"""Associated with time modification"""
"""Associated with time modification buttons"""
self.layer.changeTime(intitmetireation)
time2 = time.strftime("%j:%H:%M:%S", time.gmtime(self.layer.hydrauparser.getTimes()[intitmetireation]))

Expand All @@ -345,12 +357,12 @@ def change_timetxt(self,intitmetireation):
self.tr("time (seconds)") + " : " + str(self.layer.hydrauparser.getTimes()[intitmetireation]))

def sliderReleased(self):
"""Associated with slider behaviour"""
"""Associated with time slider behaviour"""
self.layer.draw=True
self.layer.triggerRepaint()

def sliderPressed(self):
"""Associated with slider behaviour"""
"""Associated with time slider behaviour"""
self.layer.draw=False

#*********************************************************************************
Expand All @@ -376,6 +388,7 @@ def change_param(self,int1=None):
def open_def_variables(self, lst_param):
"""
Create or edit virtual parameter, based on raw parameter of selafin file
appears when clicking on new virtual parameter
"""
source = self.sender()
if source == self.pushButton_param_add:
Expand Down Expand Up @@ -412,6 +425,7 @@ def open_def_variables(self, lst_param):
def delete_def_variables(self):
"""
Delete virtual parameter
When clicking on delete virtual parameter
"""
index = self.getTreeWidgetSelectedIndex(self.treeWidget_parameters)[1]
if self.layer.parametres[index][2]:
Expand Down Expand Up @@ -604,7 +618,7 @@ def change_cmchoosergenericlvl_vel(self):

def enablecheckbox(self,int1):
"""
Enable checkboxes for activating buttons when atoher buttons are activated
Enable checkboxes for activating buttons when another buttons are activated
"""
source = self.sender()
if source == self.checkBox_contourcrs:
Expand Down Expand Up @@ -657,7 +671,7 @@ def populatecombobox_time(self):

def populatecombobox_param(self):
"""
Populate parameters combobox on dialog update
Populate parameters comboboxes on dialog update
"""
self.comboBox_parametreschooser.clear()
for i in range(len(self.layer.parametres)):
Expand Down Expand Up @@ -761,8 +775,6 @@ def mapToolChooser(self,int=None):
itemname = self.treewidgettoolsindextab[indextabtemp.index(position)][2]
else:
itemname = None



if (len(self.treeWidget_utils.selectedItems())>0
and itemname == 'Values'
Expand Down Expand Up @@ -862,16 +874,17 @@ def initCompare(self):
str1 = self.tr("Selafin file chooser")
str2 = self.tr("Telemac files")
str3 = self.tr("All files")
self.reset_dialog()
fname = self.qfiledlg.getOpenFileName(None,str1,self.loaddirectory, str2 + " (*.res *.geo *.init *.slf);;" + str3 + " (*)")
#Things
self.lineEdit_5.setText(fname)
hydrauparser = PostTelemacSelafinParser()
hydrauparser.loadHydrauFile(fname)
self.writeSelafinCaracteristics(self.textEdit_3,hydrauparser)
#Launch thread
self.checkBox_6.setEnabled(False)
self.postutils.compareselafin()
if fname:
self.reset_dialog()
self.lineEdit_5.setText(fname)
hydrauparser = PostTelemacSelafinParser()
hydrauparser.loadHydrauFile(fname)
self.writeSelafinCaracteristics(self.textEdit_3,hydrauparser)
#Launch thread
self.checkBox_6.setEnabled(False)
self.postutils.compareselafin()

def reset_dialog(self):
#self.textEdit_2.clear()
Expand Down Expand Up @@ -955,7 +968,8 @@ def eventFilter(self,target,event):


def getTreeWidgetSelectedIndex(self,widget):

"""
"""
getSelected = widget.selectedItems()
if getSelected:
baseNode = getSelected[0]
Expand Down
Binary file added icons/tools/Files_Copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/tools/Information_48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/tools/Line_Graph_48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/tools/Line_Graph_48x48_flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/tools/Line_Graph_48x48_spatial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/tools/Line_Graph_48x48_time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/tools/Video_48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/tools/Wizard_48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/tools/layer_add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/tools/layer_add_mesh.bmp
Binary file not shown.
Binary file added icons/tools/layer_add_points.bmp
Binary file not shown.
Binary file added icons/tools/layer_shaded_relief_add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/tools/map_add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 11 additions & 14 deletions libs/post_telemac_pluginlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
from numpy import *
import numpy as np
#import scipy
from scipy.spatial import cKDTree
#from scipy.spatial import cKDTree
#import matplotlib
from matplotlib import tri
#from matplotlib import tri
from matplotlib import colors
#import PyQT
from PyQt4.QtCore import *
Expand Down Expand Up @@ -105,9 +105,9 @@ def __init__(self,nom1 = None):
self.canvas = iface.mapCanvas()
self.propertiesdialog = PostTelemacPropertiesDialog(self)
#matplotlib things and others
self.triangulation = None #matplotlib triangulation of the mesh
#self.triangulation = None #matplotlib triangulation of the mesh
self.triinterp = None #triinterp for plotting tools
self.trifind = None
#self.trifind = None
#viewer parameters
self.selafinqimage = Selafin2QImage(self,self.instancecount)
self.affichagevitesse = False
Expand Down Expand Up @@ -155,7 +155,7 @@ def draw(self, rendererContext):
"""
implementation of method from QgsPluginLayer to draw on he mapcanvas
return True if successful
image 2 is used to display mesh (make the render faster)
image 2 is used to display only mesh (make the render faster)
"""
if self.hydrauparser !=None and self.hydrauparser.hydraufile !=None :
bool1,image1,image2 = self.selafinqimage.getimage(self,rendererContext)
Expand Down Expand Up @@ -243,7 +243,7 @@ def initSelafinParameters(self):
Called load_selafin by when changing selafin file
Set selafin variables
"""
self.initTriangul()
#self.initTriangul()
self.parametres = []
#load parametres in self.parametres
for i,name in enumerate(self.hydrauparser.getVarnames()):
Expand Down Expand Up @@ -275,12 +275,9 @@ def clearParameters(self):
self.lvl_contour = None
self.time_displayed = None
self.alpha_displayed = 100.0


"""
def initTriangul(self,ct=None):
"""
Called set_selafin by when changing selafin file
set matplotlib's triangulation variables
"""
if ct:
pass
if self.hydrauparser.hydraufile:
Expand All @@ -293,7 +290,7 @@ def initTriangul(self,ct=None):
print 'bug with trifinder ' + str(e)
print 'regenerate selafin file please'
#TODO : disable utils dependant trifind (valeurs,?)

"""


#****************************************************************************************************
Expand All @@ -309,7 +306,7 @@ def updateSelafinValues(self, onlyparamtimeunchanged = -1 ):
"""
self.updatevalue.emit(onlyparamtimeunchanged)

updatevalue = pyqtSignal(int,bool)
updatevalue = pyqtSignal(int)

def updateSelafinValues1(self, onlyparamtimeunchanged = -1):
"""
Expand Down Expand Up @@ -579,7 +576,7 @@ def identify(self,qgspointfromcanvas,multiparam = False):
return (True,d)

def initTriinterpolator(self):
self.triinterp = [tri.LinearTriInterpolator(self.triangulation, self.values[i]) for i in range(len(self.parametres))]
self.triinterp = [tri.LinearTriInterpolator(self.hydrauparser.triangulation, self.values[i]) for i in range(len(self.parametres))]

#****************************************************************************************************
#************Method for saving/loading project with selafinlayer file***********************************
Expand Down
74 changes: 71 additions & 3 deletions libs/posttelemac_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __init__(self,layer):
self.graphflowdatac = []
self.skdtree = None #Object that enables nearest point query
self.compareprocess = None
self.initclassgraphtemp = InitGraphTemp()
#self.xformutil = None #for vector crs transformation


Expand Down Expand Up @@ -316,7 +317,8 @@ def launchThread(self,geom):
if self.graphtodo ==0:
if not self.selafinlayer.propertiesdialog.checkBox.isChecked() and self.rubberband :
self.rubberband.reset(QGis.Point)
self.initclass=InitGraphTemp()
#self.initclass=InitGraphTemp()
self.initclass = self.initclassgraphtemp
elif self.graphtodo ==1:
self.initclass=InitComputeFlow()
self.initclass.status.connect(self.selafinlayer.propertiesdialog.textBrowser_2.append)
Expand All @@ -325,7 +327,7 @@ def launchThread(self,geom):
self.initclass.finished1.connect(self.workerFinished)

if self.graphtodo ==0:
self.initclass.start(geom,self.selafinlayer)
self.initclass.start(self.selafinlayer, geom)
self.graphtempactive = True
self.selafinlayer.propertiesdialog.pushButton_limni.setEnabled(False)
elif self.graphtodo ==1:
Expand Down Expand Up @@ -469,6 +471,7 @@ def compare1(self,int1):
self.selafinlayer.updatevalue.connect(self.compareprocess.updateSelafinValue)
except Exception, e:
pass
self.initclassgraphtemp.compare = True
self.selafinlayer.triinterp = None
#desactive non matching parameters
for i in range(len(self.selafinlayer.parametres)):
Expand All @@ -485,6 +488,7 @@ def compare1(self,int1):
self.selafinlayer.updatevalue.connect(self.selafinlayer.updateSelafinValues1)
except Exception, e:
pass
self.initclassgraphtemp.compare = False
self.selafinlayer.triinterp = None
self.selafinlayer.forcerefresh = True
self.reinitCorrespondingParameters()
Expand Down Expand Up @@ -527,7 +531,8 @@ def calculMaxRes(self):
def chargerSelafin(self, path):
if path and self.selafinlayer.propertiesdialog.checkBox_8.isChecked():
slf = QgsPluginLayerRegistry.instance().pluginLayerType('selafin_viewer').createLayer()
slf.setCrs(iface.mapCanvas().mapSettings().destinationCrs())
#slf.setRealCrs(iface.mapCanvas().mapSettings().destinationCrs())
slf.setRealCrs(self.selafinlayer.crs())
slf.load_selafin(path)
QgsMapLayerRegistry.instance().addMapLayer(slf)

Expand Down Expand Up @@ -732,6 +737,8 @@ def tr(self, message):
"""Used for translation"""
return QCoreApplication.translate('PostTelemacUtils', message, None, QApplication.UnicodeUTF8)

""

def getNearest(self,pointfromcanvas):
"""
Get the nearest point in selafin mesh
Expand All @@ -746,3 +753,64 @@ def getNearest(self,pointfromcanvas):
self.skdtree = cKDTree(self.arraymesh,leafsize=100)
numfinal = self.skdtree.query(point1,k=1)[1][0]
return numfinal



class ThreadLaucnher(QtCore.QObject):

def __init__(self):
QtCore.QObject.__init__(self)
self.thread = None
self.worker = None
self.processtype = 0
#self.selafin = selafin
#self.graphtemp = graphTemp(selafin)
self.compare = False
self.method = None

def start(self, selafin, method,
qgspoints ):

#Launch worker
self.thread = QtCore.QThread()
self.worker = graphTemp(selafin, qgspoints,self.compare)
#self.graphtemp.points = qgspoints
#self.worker = self.graphtemp

self.worker.moveToThread(self.thread)
self.thread.started.connect(self.worker.createGraphTemp)
self.worker.status.connect(self.writeOutput)
self.worker.error.connect(self.raiseError)
self.worker.emitpoint.connect(self.emitPoint)
self.worker.finished.connect(self.workerFinished)
self.worker.finished.connect(self.worker.deleteLater)
self.thread.finished.connect(self.thread.deleteLater)
self.worker.finished.connect(self.thread.quit)
self.thread.start()



def raiseError(self,str):
if self.processtype ==0:
self.status.emit(str)
elif self.processtype in [1,2,3]:
raise GeoAlgorithmExecutionException(str)
elif self.processtype == 4:
print str
sys.exit(0)

def writeOutput(self,str1):
self.status.emit(str(str1))

def workerFinished(self,list1,list2):
self.finished1.emit(list1,list2)

def emitPoint(self,x,y):
self.emitpoint.emit(x,y)



status = QtCore.pyqtSignal(str)
error = QtCore.pyqtSignal(str)
finished1 = QtCore.pyqtSignal(list,list)
emitpoint = QtCore.pyqtSignal(float,float)
6 changes: 3 additions & 3 deletions libs/posttelemac_util_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def computeFlowMain(self):
if METHOD == 0 :
if not self.selafinlayer.networkxgraph:
G=nx.Graph()
G.add_edges_from([(edge[0],edge[1]) for edge in self.selafinlayer.triangulation.edges])
G.add_edges_from([(edge[0],edge[1]) for edge in self.selafinlayer.hydrauparser.triangulation.edges])
self.selafinlayer.networkxgraph = G
else:
G = self.selafinlayer.networkxgraph
Expand All @@ -81,10 +81,10 @@ def computeFlowMain(self):
flow = None
for points in range(len(linetemp)-1):
try:
triangle = self.selafinlayer.trifind.__call__(linetemp[points][0],linetemp[points][1])
triangle = self.selafinlayer.hydrauparser.trifind.__call__(linetemp[points][0],linetemp[points][1])
if triangle != -1:
enumpointdebut = self.getNearestPointEdge(linetemp[points][0],linetemp[points][1],triangle)
triangle = self.selafinlayer.trifind.__call__(linetemp[points + 1][0],linetemp[points + 1][1])
triangle = self.selafinlayer.hydrauparser.trifind.__call__(linetemp[points + 1][0],linetemp[points + 1][1])
if triangle != -1:
enumpointfin = self.getNearestPointEdge(linetemp[points + 1][0],linetemp[points + 1][1],triangle)

Expand Down
Loading

0 comments on commit 6b29ed0

Please sign in to comment.