##// END OF EJS Templates
Miguel Valdez -
r577:bea3bacb993a
parent child
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -0,0 +1,7
1 # ~/.bash_logout: executed by bash(1) when login shell exits.
2
3 # when leaving the console clear the screen to increase privacy
4
5 if [ "$SHLVL" = 1 ]; then
6 [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
7 fi
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,29
1 #!/usr/bin/env python
2 import os, sys
3 from PyQt4 import QtCore, QtGui
4 from PyQt4.QtGui import QApplication
5
6 from schainpy.gui.viewcontroller.initwindow import InitWindow
7 from schainpy.gui.viewcontroller.basicwindow import BasicWindow
8 from schainpy.gui.viewcontroller.workspace import Workspace
9
10 def main():
11
12 app = QtGui.QApplication(sys.argv)
13
14 Welcome=InitWindow()
15
16 if not Welcome.exec_():
17 sys.exit(-1)
18
19 WorkPathspace=Workspace()
20 if not WorkPathspace.exec_():
21 sys.exit(-1)
22
23 MainGUI=BasicWindow()
24 MainGUI.setWorkSpaceGUI(WorkPathspace.dirComBox.currentText())
25 MainGUI.show()
26 sys.exit(app.exec_())
27
28 if __name__ == "__main__":
29 main() No newline at end of file
@@ -0,0 +1,29
1 #!/usr/bin/env python
2 import os, sys
3 from PyQt4 import QtCore, QtGui
4 from PyQt4.QtGui import QApplication
5
6 from schainpy.gui.viewcontroller.initwindow import InitWindow
7 from schainpy.gui.viewcontroller.basicwindow import BasicWindow
8 from schainpy.gui.viewcontroller.workspace import Workspace
9
10 def main():
11
12 app = QtGui.QApplication(sys.argv)
13
14 Welcome=InitWindow()
15
16 if not Welcome.exec_():
17 sys.exit(-1)
18
19 WorkPathspace=Workspace()
20 if not WorkPathspace.exec_():
21 sys.exit(-1)
22
23 MainGUI=BasicWindow()
24 MainGUI.setWorkSpaceGUI(WorkPathspace.dirComBox.currentText())
25 MainGUI.show()
26 sys.exit(app.exec_())
27
28 if __name__ == "__main__":
29 main() No newline at end of file
@@ -0,0 +1,97
1 import threading
2 import Queue
3 import pickle
4 import numpy, os, sys
5
6 from schainpy.controller import Project
7 from command import *
8
9 class ControllerThread(threading.Thread):
10 def __init__(self, filename, data_q):
11 super(ControllerThread, self).__init__()
12 self.filename = filename
13 self.data_q = data_q
14 self.control = {'stop':False,'pause':False}
15
16 def stop(self):
17 self.control['stop'] = True
18
19 def pause(self):
20 self.control['pause'] = not(self.control['pause'])
21
22 def run(self):
23 self.control['stop'] = False
24 self.control['pause'] = False
25 self.controllerObj = Project(self.control, self.data_q)
26 self.controllerObj.readXml(self.filename)
27 self.controllerObj.createObjects()
28 self.controllerObj.connectObjects()
29 self.controllerObj.run()
30
31 class CommCtrlProcessThread(threading.Thread):
32 """ Implements the threading.Thread interface (start, join, etc.) and
33 can be controlled via the cmd_q Queue attribute. Replies are placed in
34 the reply_q Queue attribute.
35 """
36 def __init__(self, cmd_q=Queue.Queue(), reply_q=Queue.Queue()):
37 super(CommCtrlProcessThread, self).__init__()
38 self.cmd_q = cmd_q
39 self.reply_q = reply_q
40
41 # self.print_q = Queue.Queue()
42 self.data_q = Queue.Queue()
43
44 self.alive = threading.Event()
45 self.alive.set()
46 self.socket = None
47
48 self.socketIO = None
49 self.mySocket = None
50
51
52 self.handlers = {
53 ProcessCommand.PROCESS: self._handle_ioPROCESSTHREAD,
54 ProcessCommand.MESSAGE: self._handle_ioMESSAGE,
55 ProcessCommand.DATA: self._handle_ioDATA,
56 ProcessCommand.STOP: self._handle_ioSTOP,
57 ProcessCommand.PAUSE: self._handle_ioPAUSE
58 }
59
60 def run(self):
61 while self.alive.isSet():
62 try:
63 cmd = self.cmd_q.get(True, 0.1)
64 self.handlers[cmd.type](cmd)
65 except Queue.Empty as e:
66 continue
67
68
69 def _handle_ioPROCESSTHREAD(self, cmd):
70 filename = cmd.data
71 self.controllerObj = ControllerThread(filename=filename, data_q=self.data_q)
72 self.controllerObj.start()
73
74 def _handle_ioPAUSE(self, cmd):
75 self.controllerObj.pause()
76
77 def _handle_ioSTOP(self, cmd):
78 self.controllerObj.stop()
79
80 def _handle_ioDATA(self, cmd):
81 self.reply_q.put(self._success_reply_data(data=cmd.data))
82
83 def _handle_ioMESSAGE(self, cmd):
84 self.reply_q.put(self._success_reply_message(data=cmd.data))
85
86 def _success_reply_data(self, data=None):
87 return ClientReply(ClientReply.DATA, data)
88
89 def _success_reply_message(self, data=None):
90 return ClientReply(ClientReply.MESSAGE, data)
91
92 def join(self, timeout=None):
93 self.alive.clear()
94 threading.Thread.join(self, timeout)
95
96
97 No newline at end of file
@@ -0,0 +1,50
1 class ProcessCommand(object):
2 """ A command to the client thread.
3 Each command type has its associated data:
4
5 DATA: Data Radar Object
6 MESSAGE: Data String
7 STOP: Event to Stop the process thread
8 PAUSE: Event to Pause the process thread
9 """
10 PROCESS, DATA, MESSAGE, STOP, PAUSE = range(5)
11
12 def __init__(self, type, data=None):
13 self.type = type
14 self.data = data
15
16
17 class ClientCommand(object):
18 """ A command to the client thread.
19 Each command type has its associated data:
20
21 CONNECT: (host, port) tuple
22 SEND: Data string
23 RECEIVE: None
24 CLOSE: None
25 PROCESS: to processing
26 SEND: send a data
27 SENDXML: send xml file
28 """
29 CONNECT, SEND, SENDXML, RECEIVE, CLOSE, PROCESS = range(6)
30
31 def __init__(self, type, data=None):
32 self.type = type
33 self.data = data
34
35
36 class ClientReply(object):
37 """ A reply from the client thread.
38 Each reply type has its associated data:
39
40 ERROR: The error string
41 MESSAGE: Data String
42 DATA: Data
43 SUCCESS: Depends on the command - for RECEIVE it's the received
44 data string, for others None.
45 """
46 ERROR, SUCCESS, MESSAGE, DATA= range(4)
47
48 def __init__(self, type, data=None):
49 self.type = type
50 self.data = data
@@ -0,0 +1,21
1 # -*- coding: utf-8 -*-
2
3 """
4 Module implementing Ftp.
5 """
6
7 from PyQt4.QtGui import QMainWindow
8 from PyQt4.QtCore import pyqtSignature
9
10 from schainpy.gui.viewer.ftp import Ui_Ftp
11
12 class Ftp(QMainWindow, Ui_MainWindow):
13 """
14 Class documentation goes here.
15 """
16 def __init__(self, parent = None):
17 """
18 Constructor
19 """
20 QMainWindow.__init__(self, parent)
21 self.setupUi(self)
1 NO CONTENT: new file 100644
@@ -0,0 +1,298
1 import os.path
2 import ftplib
3
4
5 class Ftp():
6 """
7 Ftp is a public class used to define custom File Transfer Protocol from "ftplib" python module
8
9 Non-standard Python modules used: None
10
11 Written by "Daniel Suarez":mailto:daniel.suarez@jro.igp.gob.pe Oct. 26, 2010
12 """
13
14 def __init__(self,host = None, username=None, passw=None, remotefolder=None):
15 """
16 This method is used to setting parameters for FTP and establishing connection to remote host
17
18 Inputs:
19 host - remote host IP Address
20
21 username - remote host Username
22
23 passw - remote host Passw
24
25 remotefolder - remote host current working directory
26
27 Return: void
28
29 Affects:
30 self.status - in Error Case or Connection Failed this parameter is set to 1 else 0
31
32 self.folderList - sub-folder list of remote folder
33
34 self.fileList - file list of remote folder
35
36
37 """
38
39 if ((host == None) and (username==None) and (passw==None) and (remotefolder==None)):
40 host, username, passw, remotefolder = self.parmsByDefault()
41
42 self.host = host
43 self.username = username
44 self.passw = passw
45 self.remotefolder = remotefolder
46 self.file = None
47 self.ftp = None
48 self.status = 0
49
50 try:
51 self.ftp = ftplib.FTP(self.host)
52 self.ftp.login(self.username,self.passw)
53 self.ftp.cwd(self.remotefolder)
54 # print 'Connect to FTP Server: Successfully'
55
56 except ftplib.all_errors:
57 print 'Error FTP Service'
58 self.status = 1
59 return
60
61
62
63 self.dirList = []
64
65 try:
66 self.dirList = self.ftp.nlst()
67
68 except ftplib.error_perm, resp:
69 if str(resp) == "550 No files found":
70 print "no files in this directory"
71 self.status = 1
72 return
73
74 except ftplib.all_errors:
75 print 'Error Displaying Dir-Files'
76 self.status = 1
77 return
78
79 self.fileList = []
80 self.folderList = []
81 #only for test
82 for f in self.dirList:
83 name, ext = os.path.splitext(f)
84 if ext != '':
85 self.fileList.append(f)
86 # print 'filename: %s - size: %d'%(f,self.ftp.size(f))
87
88 def parmsByDefault(self):
89 host = 'jro-app.igp.gob.pe'
90 username = 'wmaster'
91 passw = 'mst2010vhf'
92 remotefolder = '/home/wmaster/graficos'
93
94 # host = 'jro.igp.gob.pe'
95 # username = 'operaciones'
96 # passw = 'mst2010vhf'
97 # remotefolder = '/users/databases/on-line'
98
99 return host, username, passw, remotefolder
100
101
102 def mkd(self,dirname):
103 """
104 mkd is used to make directory in remote host
105
106 Input:
107 dirname - directory name
108
109 Return:
110 1 in error case else 0
111 """
112 try:
113 self.ftp.mkd(dirname)
114 except:
115 print 'Error creating remote folder:%s'%dirname
116 return 1
117
118 return 0
119
120
121 def delete(self,filename):
122 """
123 delete is used to delete file in current working directory of remote host
124
125 Input:
126 filename - filename to delete in remote folder
127
128 Return:
129 1 in error case else 0
130 """
131
132 try:
133 self.ftp.delete(filename)
134 except:
135 print 'Error deleting remote file:%s'%filename
136 return 1
137
138 return 0
139
140 def download(self,filename,localfolder):
141 """
142 download is used to downloading file from remote folder into local folder
143
144 Inputs:
145 filename - filename to donwload
146
147 localfolder - directory local to store filename
148
149 Returns:
150 self.status - 1 in error case else 0
151 """
152
153 self.status = 0
154
155
156 if not(filename in self.fileList):
157 print 'filename:%s not exists'%filename
158 self.status = 1
159 return self.status
160
161 newfilename = os.path.join(localfolder,filename)
162
163 self.file = open(newfilename, 'wb')
164
165 try:
166 print 'Download: ' + filename
167 self.ftp.retrbinary('RETR ' + filename, self.__handleDownload)
168 print 'Download Complete'
169 except ftplib.all_errors:
170 print 'Error Downloading ' + filename
171 self.status = 1
172 return self.status
173
174 self.file.close()
175
176 return self.status
177
178
179 def __handleDownload(self,block):
180 """
181 __handleDownload is used to handle writing file
182 """
183 self.file.write(block)
184
185
186 def upload(self,filename,remotefolder=None):
187 """
188 upload is used to uploading local file to remote directory
189
190 Inputs:
191 filename - full path name of local file to store in remote directory
192
193 remotefolder - remote directory
194
195 Returns:
196 self.status - 1 in error case else 0
197 """
198
199 if remotefolder == None:
200 remotefolder = self.remotefolder
201
202 self.status = 0
203
204 try:
205 self.ftp.cwd(remotefolder)
206
207 self.file = open(filename, 'rb')
208
209 (head, tail) = os.path.split(filename)
210
211 command = "STOR " + tail
212
213 print 'Uploading: ' + tail
214 self.ftp.storbinary(command, self.file)
215 print 'Upload Completed'
216
217 except ftplib.all_errors:
218 print 'Error Uploading ' + tail
219 self.status = 1
220 return self.status
221
222 self.file.close()
223
224 #back to initial directory in __init__()
225 self.ftp.cwd(self.remotefolder)
226
227 return self.status
228
229
230 def dir(self,remotefolder):
231 """
232 dir is used to change working directory of remote host and get folder and file list
233
234 Input:
235 remotefolder - current working directory
236
237 Affects:
238 self.fileList - file list of working directory
239
240 Return:
241 infoList - list with filenames and size of file in bytes
242
243 self.folderList - folder list
244 """
245
246 self.remotefolder = remotefolder
247 print 'Change to ' + self.remotefolder
248 try:
249 self.ftp.cwd(remotefolder)
250 except ftplib.all_errors:
251 print 'Error Change to ' + self.remotefolder
252 infoList = None
253 self.folderList = None
254 return infoList,self.folderList
255
256 self.dirList = []
257
258 try:
259 self.dirList = self.ftp.nlst()
260
261 except ftplib.error_perm, resp:
262 if str(resp) == "550 No files found":
263 print "no files in this directory"
264 infoList = None
265 self.folderList = None
266 return infoList,self.folderList
267 except ftplib.all_errors:
268 print 'Error Displaying Dir-Files'
269 infoList = None
270 self.folderList = None
271 return infoList,self.folderList
272
273 infoList = []
274 self.fileList = []
275 self.folderList = []
276 for f in self.dirList:
277 name,ext = os.path.splitext(f)
278 if ext != '':
279 self.fileList.append(f)
280 value = (f,self.ftp.size(f))
281 infoList.append(value)
282
283 if ext == '':
284 self.folderList.append(f)
285
286 return infoList,self.folderList
287
288
289 def close(self):
290 """
291 close is used to close and end FTP connection
292
293 Inputs: None
294
295 Return: void
296
297 """
298 self.ftp.close() No newline at end of file
This diff has been collapsed as it changes many lines, (538 lines changed) Show them Hide them
@@ -0,0 +1,538
1 import os
2 import numpy
3 import time, datetime
4 import mpldriver_gui
5 from customftp import *
6 import Queue
7 import threading
8
9 class FTP_Thread (threading.Thread):
10 def __init__(self):
11 threading.Thread.__init__(self)
12 self.exitFlag = 0
13 self.queueLock = threading.Lock()
14 self.workQueue = Queue.Queue()
15
16 def run(self):
17 self.send_data()
18
19 def fin(self):
20 self.exitFlag = 1
21
22 def put_data(self, data):
23 # Fill the queue
24 self.queueLock.acquire()
25 self.workQueue.put(data)
26 self.queueLock.release()
27
28 def send_data(self):
29 while not self.exitFlag:
30 if self.workQueue.qsize():
31
32 data = self.workQueue.get(True)
33
34 try:
35 ftpObj = Ftp(host=data['server'],
36 username=data['username'],
37 passw=data['password'],
38 remotefolder=data['folder'])
39
40 ftpObj.upload(data['figfilename'])
41 ftpObj.close()
42 except:
43 print ValueError, 'Error FTP'
44 print "don't worry still running the program"
45
46
47 class Figure():
48
49 __driver = mpldriver_gui
50 __isConfigThread = False
51 fig = None
52
53 id = None
54 wintitle = None
55 width = None
56 height = None
57 nplots = None
58 timerange = None
59
60 axesObjList = []
61
62 WIDTH = None
63 HEIGHT = None
64 PREFIX = 'fig'
65
66 FTP_WEI = None #(WW)
67 EXP_CODE = None #(EXP)
68 SUB_EXP_CODE = None #(SS)
69 PLOT_CODE = None #(TT)
70 PLOT_POS = None #(NN)
71
72
73
74 def __init__(self):
75
76 raise ValueError, "This method is not implemented"
77
78 def getSubplots(self):
79
80 raise ValueError, "Abstract method: This method should be defined"
81
82 def getAxesObjList(self):
83
84 return self.axesObjList
85
86 def getScreenDim(self, widthplot, heightplot):
87
88 nrow, ncol = self.getSubplots()
89 widthscreen = widthplot*ncol
90 heightscreen = heightplot*nrow
91
92 return widthscreen, heightscreen
93
94 def getFilename(self, name, ext='.png'):
95 path = '%s%03d' %(self.PREFIX, self.id)
96 filename = '%s_%s%s' %(self.PREFIX, name, ext)
97 return os.path.join(path, filename)
98
99 def createFigure(self, id, wintitle, widthplot=None, heightplot=None):
100
101 if widthplot == None:
102 widthplot = self.WIDTH
103
104 if heightplot == None:
105 heightplot = self.HEIGHT
106
107 self.id = id
108
109 self.wintitle = wintitle
110
111 self.widthscreen, self.heightscreen = self.getScreenDim(widthplot, heightplot)
112
113 self.fig = self.__driver.createFigure(id=self.id,
114 wintitle=self.wintitle,
115 width=self.widthscreen,
116 height=self.heightscreen)
117
118 self.axesObjList = []
119
120 return self.fig
121
122 def clearAxes(self):
123 self.axesObjList = []
124
125 def addAxes(self, *args):
126 axesObj = Axes(self.fig, *args)
127 self.axesObjList.append(axesObj)
128
129 def saveFigure(self, figpath, figfile, *args):
130
131 filename = os.path.join(figpath, figfile)
132
133 fullpath = os.path.split(filename)[0]
134
135 if not os.path.exists(fullpath):
136 subpath = os.path.split(fullpath)[0]
137
138 if not os.path.exists(subpath):
139 os.mkdir(subpath)
140
141 os.mkdir(fullpath)
142
143 self.__driver.saveFigure(self.fig, filename, *args)
144
145 def getTimeLim(self, x, xmin, xmax):
146
147 if self.timerange != None:
148 txmin = x[0] - x[0]%self.timerange
149 else:
150 txmin = numpy.min(x)
151
152 thisdatetime = datetime.datetime.utcfromtimestamp(txmin)
153 thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0))
154
155 ####################################################
156 #If the x is out of xrange
157 if xmax < (thisdatetime - thisdate).seconds/(60*60.):
158 xmin = None
159 xmax = None
160
161 if xmin == None:
162 td = thisdatetime - thisdate
163 xmin = td.seconds/(60*60.)
164
165 if xmax == None:
166 xmax = xmin + self.timerange/(60*60.)
167
168 mindt = thisdate + datetime.timedelta(hours=xmin) - datetime.timedelta(seconds=time.timezone)
169 tmin = time.mktime(mindt.timetuple())
170
171 maxdt = thisdate + datetime.timedelta(hours=xmax) - datetime.timedelta(seconds=time.timezone)
172 tmax = time.mktime(maxdt.timetuple())
173
174 self.timerange = tmax - tmin
175
176 return tmin, tmax
177
178 def sendByFTP(self, figfilename, server, folder, username, password):
179 ftpObj = Ftp(host=server, username=username, passw=password, remotefolder=folder)
180 ftpObj.upload(figfilename)
181 ftpObj.close()
182
183 def sendByFTP_Thread(self, figfilename, server, folder, username, password):
184 data = {'figfilename':figfilename,'server':server,'folder':folder,'username':username,'password':password}
185
186 if not(self.__isConfigThread):
187
188 self.thread = FTP_Thread()
189 self.thread.start()
190 self.__isConfigThread = True
191
192 self.thread.put_data(data)
193
194
195 def getNameToFtp(self, thisDatetime, FTP_WEI, EXP_CODE, SUB_EXP_CODE, PLOT_CODE, PLOT_POS):
196 YEAR_STR = '%4.4d'%thisDatetime.timetuple().tm_year
197 DOY_STR = '%3.3d'%thisDatetime.timetuple().tm_yday
198 FTP_WEI = '%2.2d'%FTP_WEI
199 EXP_CODE = '%3.3d'%EXP_CODE
200 SUB_EXP_CODE = '%2.2d'%SUB_EXP_CODE
201 PLOT_CODE = '%2.2d'%PLOT_CODE
202 PLOT_POS = '%2.2d'%PLOT_POS
203 name = YEAR_STR + DOY_STR + FTP_WEI + EXP_CODE + SUB_EXP_CODE + PLOT_CODE + PLOT_POS
204 return name
205
206 def draw(self):
207 self.__driver.draw(self.fig)
208
209 axesList = property(getAxesObjList)
210
211 class Axes:
212
213 __driver = mpldriver_gui
214 fig = None
215 ax = None
216 plot = None
217 __missing = 1E30
218 __firsttime = None
219
220 __showprofile = False
221
222 xmin = None
223 xmax = None
224 ymin = None
225 ymax = None
226 zmin = None
227 zmax = None
228
229 x_buffer = None
230 z_buffer = None
231
232 decimationx = None
233 decimationy = None
234
235 __MAXNUMX = 1000.
236 __MAXNUMY = 500.
237
238 def __init__(self, *args):
239
240 """
241
242 Input:
243 *args : Los parametros necesarios son
244 fig, nrow, ncol, xpos, ypos, colspan, rowspan
245 """
246
247 ax = self.__driver.createAxes(*args)
248 self.fig = args[0]
249 self.ax = ax
250 self.plot = None
251
252 self.__firsttime = True
253 self.idlineList = []
254
255 self.x_buffer = numpy.array([])
256 self.z_buffer = numpy.array([])
257
258 def pcolor(self, x, y, z,
259 xmin=None, xmax=None,
260 ymin=None, ymax=None,
261 zmin=None, zmax=None,
262 xlabel='', ylabel='',
263 title='', rti = False, colormap='jet',
264 **kwargs):
265
266 """
267 Input:
268 x :
269 y :
270 x :
271 xmin :
272 xmax :
273 ymin :
274 ymax :
275 zmin :
276 zmax :
277 xlabel :
278 ylabel :
279 title :
280 **kwargs : Los parametros aceptados son
281 ticksize=9,
282 cblabel=''
283 rti = True or False
284 """
285
286 if self.__firsttime:
287
288 if xmin == None: xmin = numpy.nanmin(x)
289 if xmax == None: xmax = numpy.nanmax(x)
290 if ymin == None: ymin = numpy.nanmin(y)
291 if ymax == None: ymax = numpy.nanmax(y)
292 if zmin == None: zmin = numpy.nanmin(z)
293 if zmax == None: zmax = numpy.nanmax(z)
294
295
296 self.plot = self.__driver.createPcolor(self.ax, x, y, z,
297 xmin, xmax,
298 ymin, ymax,
299 zmin, zmax,
300 xlabel=xlabel,
301 ylabel=ylabel,
302 title=title,
303 colormap=colormap,
304 **kwargs)
305
306 if self.xmin == None: self.xmin = xmin
307 if self.xmax == None: self.xmax = xmax
308 if self.ymin == None: self.ymin = ymin
309 if self.ymax == None: self.ymax = ymax
310 if self.zmin == None: self.zmin = zmin
311 if self.zmax == None: self.zmax = zmax
312
313 self.__firsttime = False
314 return
315
316 if rti:
317 self.__driver.addpcolor(self.ax, x, y, z, self.zmin, self.zmax,
318 xlabel=xlabel,
319 ylabel=ylabel,
320 title=title,
321 colormap=colormap)
322 return
323
324 self.__driver.pcolor(self.plot, z,
325 xlabel=xlabel,
326 ylabel=ylabel,
327 title=title)
328
329
330 def pline(self, x, y,
331 xmin=None, xmax=None,
332 ymin=None, ymax=None,
333 xlabel='', ylabel='',
334 title='',
335 **kwargs):
336
337 """
338
339 Input:
340 x :
341 y :
342 xmin :
343 xmax :
344 ymin :
345 ymax :
346 xlabel :
347 ylabel :
348 title :
349 **kwargs : Los parametros aceptados son
350
351 ticksize
352 ytick_visible
353 """
354
355 if self.__firsttime:
356
357 if xmin == None: xmin = numpy.nanmin(x)
358 if xmax == None: xmax = numpy.nanmax(x)
359 if ymin == None: ymin = numpy.nanmin(y)
360 if ymax == None: ymax = numpy.nanmax(y)
361
362 self.plot = self.__driver.createPline(self.ax, x, y,
363 xmin, xmax,
364 ymin, ymax,
365 xlabel=xlabel,
366 ylabel=ylabel,
367 title=title,
368 **kwargs)
369
370 self.idlineList.append(0)
371 self.__firsttime = False
372 return
373
374 self.__driver.pline(self.plot, x, y, xlabel=xlabel,
375 ylabel=ylabel,
376 title=title)
377
378 def pmultiline(self, x, y,
379 xmin=None, xmax=None,
380 ymin=None, ymax=None,
381 xlabel='', ylabel='',
382 title='',
383 **kwargs):
384
385 if self.__firsttime:
386
387 if xmin == None: xmin = numpy.nanmin(x)
388 if xmax == None: xmax = numpy.nanmax(x)
389 if ymin == None: ymin = numpy.nanmin(y)
390 if ymax == None: ymax = numpy.nanmax(y)
391
392 self.plot = self.__driver.createPmultiline(self.ax, x, y,
393 xmin, xmax,
394 ymin, ymax,
395 xlabel=xlabel,
396 ylabel=ylabel,
397 title=title,
398 **kwargs)
399 self.__firsttime = False
400 return
401
402 self.__driver.pmultiline(self.plot, x, y, xlabel=xlabel,
403 ylabel=ylabel,
404 title=title)
405
406 def pmultilineyaxis(self, x, y,
407 xmin=None, xmax=None,
408 ymin=None, ymax=None,
409 xlabel='', ylabel='',
410 title='',
411 **kwargs):
412
413 if self.__firsttime:
414
415 if xmin == None: xmin = numpy.nanmin(x)
416 if xmax == None: xmax = numpy.nanmax(x)
417 if ymin == None: ymin = numpy.nanmin(y)
418 if ymax == None: ymax = numpy.nanmax(y)
419
420 self.plot = self.__driver.createPmultilineYAxis(self.ax, x, y,
421 xmin, xmax,
422 ymin, ymax,
423 xlabel=xlabel,
424 ylabel=ylabel,
425 title=title,
426 **kwargs)
427 if self.xmin == None: self.xmin = xmin
428 if self.xmax == None: self.xmax = xmax
429 if self.ymin == None: self.ymin = ymin
430 if self.ymax == None: self.ymax = ymax
431
432 self.__firsttime = False
433 return
434
435 self.__driver.pmultilineyaxis(self.plot, x, y, xlabel=xlabel,
436 ylabel=ylabel,
437 title=title)
438
439 def addpline(self, x, y, idline, **kwargs):
440 lines = self.ax.lines
441
442 if idline in self.idlineList:
443 self.__driver.set_linedata(self.ax, x, y, idline)
444
445 if idline not in(self.idlineList):
446 self.__driver.addpline(self.ax, x, y, **kwargs)
447 self.idlineList.append(idline)
448
449 return
450
451 def pcolorbuffer(self, x, y, z,
452 xmin=None, xmax=None,
453 ymin=None, ymax=None,
454 zmin=None, zmax=None,
455 xlabel='', ylabel='',
456 title='', rti = True, colormap='jet',
457 maxNumX = None, maxNumY = None,
458 **kwargs):
459
460 if maxNumX == None:
461 maxNumX = self.__MAXNUMX
462
463 if maxNumY == None:
464 maxNumY = self.__MAXNUMY
465
466 if self.__firsttime:
467 self.z_buffer = z
468 self.x_buffer = numpy.hstack((self.x_buffer, x))
469
470 if xmin == None: xmin = numpy.nanmin(x)
471 if xmax == None: xmax = numpy.nanmax(x)
472 if ymin == None: ymin = numpy.nanmin(y)
473 if ymax == None: ymax = numpy.nanmax(y)
474 if zmin == None: zmin = numpy.nanmin(z)
475 if zmax == None: zmax = numpy.nanmax(z)
476
477
478 self.plot = self.__driver.createPcolor(self.ax, self.x_buffer, y, z,
479 xmin, xmax,
480 ymin, ymax,
481 zmin, zmax,
482 xlabel=xlabel,
483 ylabel=ylabel,
484 title=title,
485 colormap=colormap,
486 **kwargs)
487
488 if self.xmin == None: self.xmin = xmin
489 if self.xmax == None: self.xmax = xmax
490 if self.ymin == None: self.ymin = ymin
491 if self.ymax == None: self.ymax = ymax
492 if self.zmin == None: self.zmin = zmin
493 if self.zmax == None: self.zmax = zmax
494
495 self.__firsttime = False
496 return
497
498 self.x_buffer = numpy.hstack((self.x_buffer, x[-1]))
499 self.z_buffer = numpy.hstack((self.z_buffer, z))
500
501 if self.decimationx == None:
502 deltax = float(self.xmax - self.xmin)/maxNumX
503 deltay = float(self.ymax - self.ymin)/maxNumY
504
505 resolutionx = self.x_buffer[2]-self.x_buffer[0]
506 resolutiony = y[1]-y[0]
507
508 self.decimationx = numpy.ceil(deltax / resolutionx)
509 self.decimationy = numpy.ceil(deltay / resolutiony)
510
511 z_buffer = self.z_buffer.reshape(-1,len(y))
512
513 x_buffer = self.x_buffer[::self.decimationx]
514 y_buffer = y[::self.decimationy]
515 z_buffer = z_buffer[::self.decimationx, ::self.decimationy]
516 #===================================================
517
518 x_buffer, y_buffer, z_buffer = self.__fillGaps(x_buffer, y_buffer, z_buffer)
519
520 self.__driver.addpcolorbuffer(self.ax, x_buffer, y_buffer, z_buffer, self.zmin, self.zmax,
521 xlabel=xlabel,
522 ylabel=ylabel,
523 title=title,
524 colormap=colormap)
525 def __fillGaps(self, x_buffer, y_buffer, z_buffer):
526
527 deltas = x_buffer[1:] - x_buffer[0:-1]
528 x_median = numpy.median(deltas)
529
530 index = numpy.where(deltas >= 2*x_median)
531
532 if len(index[0]) != 0:
533 z_buffer[index[0],::] = self.__missing
534 z_buffer = numpy.ma.masked_inside(z_buffer,0.99*self.__missing,1.01*self.__missing)
535
536 return x_buffer, y_buffer, z_buffer
537
538 No newline at end of file
@@ -0,0 +1,326
1 import numpy
2 import datetime
3 import sys
4
5 from matplotlib.figure import Figure
6 from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
7
8 from mpl_toolkits.axes_grid1 import make_axes_locatable
9 from matplotlib.ticker import *
10 import matplotlib.gridspec as gridspec
11 import matplotlib.cm as cm
12 import matplotlib.colorbar
13
14 def createFigure(id, wintitle, width, height, facecolor="w"):
15 figsize = (width,height)
16 fig = Figure(figsize=figsize, facecolor=facecolor)
17
18 return fig
19
20 def createAxes(fig, nrow, ncol, x, y, ratio):
21 width_ratios = []
22 for i in range(ncol):
23 if i%2==0:
24 width_ratios.append(ratio)
25 else:
26 width_ratios.append(1)
27
28 gs = gridspec.GridSpec(nrow, ncol, width_ratios=width_ratios)
29 ax = fig.add_subplot(gs[x,y])
30
31 return ax
32
33 def saveFigure(fig, filename):
34 fig.savefig(filename)
35
36
37 def printLabels(ax, xlabel, ylabel, title):
38
39 ax.set_xlabel(xlabel, size=11)
40 ax.set_ylabel(ylabel, size=11)
41 ax.set_title(title, size=12)
42
43 def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax,
44 xlabel='', ylabel='', title='', ticksize = 9,
45 colormap='jet',cblabel='', cbsize="5%",
46 XAxisAsTime=False):
47
48 divider = make_axes_locatable(ax)
49 ax_cb = divider.new_horizontal(size=cbsize, pad=0.05)
50 fig = ax.get_figure()
51 fig.add_axes(ax_cb)
52
53 ax.set_xlim([xmin,xmax])
54 ax.set_ylim([ymin,ymax])
55
56 printLabels(ax, xlabel, ylabel, title)
57
58 imesh = ax.pcolormesh(x,y,z.T, vmin=zmin, vmax=zmax, cmap=cm.get_cmap(colormap))
59 cb = fig.colorbar(imesh, cax=ax_cb)
60 cb.set_label(cblabel)
61
62 for tick in ax.yaxis.get_major_ticks():
63 tick.label.set_fontsize(ticksize)
64
65 for tick in ax.xaxis.get_major_ticks():
66 tick.label.set_fontsize(ticksize)
67
68 for tick in cb.ax.get_yticklabels():
69 tick.set_fontsize(ticksize)
70
71 ax_cb.yaxis.tick_right()
72
73 if '0.' in matplotlib.__version__[0:2]:
74 print "The matplotlib version has to be updated to 1.1 or newer"
75 return imesh
76
77 if '1.0.' in matplotlib.__version__[0:4]:
78 print "The matplotlib version has to be updated to 1.1 or newer"
79 return imesh
80
81 fig.tight_layout()
82
83 if XAxisAsTime:
84
85 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
86 ax.xaxis.set_major_formatter(FuncFormatter(func))
87 ax.xaxis.set_major_locator(LinearLocator(7))
88
89 return imesh
90
91 def pcolor(imesh, z, xlabel='', ylabel='', title=''):
92
93 z = z.T
94
95 ax = imesh.get_axes()
96
97 printLabels(ax, xlabel, ylabel, title)
98
99 imesh.set_array(z.ravel())
100
101 def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
102
103 printLabels(ax, xlabel, ylabel, title)
104
105 ax.collections.remove(ax.collections[0])
106
107 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
108
109
110 def draw(fig):
111
112 if type(fig) == 'int':
113 raise ValueError, "This parameter should be of tpye matplotlib figure"
114
115 fig.canvas.draw()
116
117
118 def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='',
119 ticksize=9, xtick_visible=True, ytick_visible=True,
120 nxticks=4, nyticks=10,
121 grid=None):
122
123 """
124
125 Input:
126 grid : None, 'both', 'x', 'y'
127 """
128 fig = ax.get_figure()
129 ax.set_xlim([xmin,xmax])
130 ax.set_ylim([ymin,ymax])
131
132 printLabels(ax, xlabel, ylabel, title)
133
134 ######################################################
135 if (xmax-xmin)<=1:
136 xtickspos = numpy.linspace(xmin,xmax,nxticks)
137 xtickspos = numpy.array([float("%.1f"%i) for i in xtickspos])
138 ax.set_xticks(xtickspos)
139 else:
140 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
141 # xtickspos = numpy.arange(nxticks)*float(xmax-xmin)/float(nxticks) + int(xmin)
142 ax.set_xticks(xtickspos)
143
144 for tick in ax.get_xticklabels():
145 tick.set_visible(xtick_visible)
146
147 for tick in ax.xaxis.get_major_ticks():
148 tick.label.set_fontsize(ticksize)
149
150 ######################################################
151 for tick in ax.get_yticklabels():
152 tick.set_visible(ytick_visible)
153
154 for tick in ax.yaxis.get_major_ticks():
155 tick.label.set_fontsize(ticksize)
156
157 ax.plot(x, y)
158 iplot = ax.lines[-1]
159
160 ######################################################
161 if '0.' in matplotlib.__version__[0:2]:
162 print "The matplotlib version has to be updated to 1.1 or newer"
163 return iplot
164
165 if '1.0.' in matplotlib.__version__[0:4]:
166 print "The matplotlib version has to be updated to 1.1 or newer"
167 return iplot
168
169 if grid != None:
170 ax.grid(b=True, which='major', axis=grid)
171 fig.tight_layout()
172 return iplot
173
174 def set_linedata(ax, x, y, idline):
175
176 ax.lines[idline].set_data(x,y)
177
178 def pline(iplot, x, y, xlabel='', ylabel='', title=''):
179
180 ax = iplot.get_axes()
181
182 printLabels(ax, xlabel, ylabel, title)
183
184 set_linedata(ax, x, y, idline=0)
185
186 def addpline(ax, x, y, color, linestyle, lw):
187
188 ax.plot(x,y,color=color,linestyle=linestyle,lw=lw)
189
190 def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
191 ticksize=9, xtick_visible=True, ytick_visible=True,
192 nxticks=4, nyticks=10,
193 grid=None):
194
195 """
196
197 Input:
198 grid : None, 'both', 'x', 'y'
199 """
200
201 # matplotlib.pyplot.ioff()
202 fig = ax.get_figure()
203
204 lines = ax.plot(x.T, y)
205 leg = ax.legend(lines, legendlabels, loc='upper right')
206 leg.get_frame().set_alpha(0.5)
207 ax.set_xlim([xmin,xmax])
208 ax.set_ylim([ymin,ymax])
209 printLabels(ax, xlabel, ylabel, title)
210
211 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
212 ax.set_xticks(xtickspos)
213
214 for tick in ax.get_xticklabels():
215 tick.set_visible(xtick_visible)
216
217 for tick in ax.xaxis.get_major_ticks():
218 tick.label.set_fontsize(ticksize)
219
220 for tick in ax.get_yticklabels():
221 tick.set_visible(ytick_visible)
222
223 for tick in ax.yaxis.get_major_ticks():
224 tick.label.set_fontsize(ticksize)
225
226 iplot = ax.lines[-1]
227
228 if '0.' in matplotlib.__version__[0:2]:
229 print "The matplotlib version has to be updated to 1.1 or newer"
230 return iplot
231
232 if '1.0.' in matplotlib.__version__[0:4]:
233 print "The matplotlib version has to be updated to 1.1 or newer"
234 return iplot
235
236 if grid != None:
237 ax.grid(b=True, which='major', axis=grid)
238
239 # matplotlib.pyplot.tight_layout()
240 #
241 # matplotlib.pyplot.ion()
242
243 fig.tight_layout()
244
245 return iplot
246
247
248 def pmultiline(iplot, x, y, xlabel='', ylabel='', title=''):
249
250 ax = iplot.get_axes()
251
252 printLabels(ax, xlabel, ylabel, title)
253
254 for i in range(len(ax.lines)):
255 line = ax.lines[i]
256 line.set_data(x[i,:],y)
257
258 def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
259 ticksize=9, xtick_visible=True, ytick_visible=True,
260 nxticks=4, nyticks=10, marker='.', markersize=10, linestyle="None",
261 grid=None, XAxisAsTime=False):
262
263
264 # matplotlib.pyplot.ioff()
265 fig = ax.get_figure()
266
267 lines = ax.plot(x, y.T, linestyle='None', marker='.', markersize=markersize)
268 leg = ax.legend(lines, legendlabels, loc='upper left', bbox_to_anchor=(1.01, 1.00), numpoints=1, handlelength=1.5, \
269 handletextpad=0.5, borderpad=0.5, labelspacing=0.5, borderaxespad=0.)
270
271 for label in leg.get_texts(): label.set_fontsize(9)
272
273 ax.set_xlim([xmin,xmax])
274 ax.set_ylim([ymin,ymax])
275 printLabels(ax, xlabel, ylabel, title)
276
277 # xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
278 # ax.set_xticks(xtickspos)
279
280 for tick in ax.get_xticklabels():
281 tick.set_visible(xtick_visible)
282
283 for tick in ax.xaxis.get_major_ticks():
284 tick.label.set_fontsize(ticksize)
285
286 for tick in ax.get_yticklabels():
287 tick.set_visible(ytick_visible)
288
289 for tick in ax.yaxis.get_major_ticks():
290 tick.label.set_fontsize(ticksize)
291
292 iplot = ax.lines[-1]
293
294 if '0.' in matplotlib.__version__[0:2]:
295 print "The matplotlib version has to be updated to 1.1 or newer"
296 return iplot
297
298 if '1.0.' in matplotlib.__version__[0:4]:
299 print "The matplotlib version has to be updated to 1.1 or newer"
300 return iplot
301
302 if grid != None:
303 ax.grid(b=True, which='major', axis=grid)
304
305 # matplotlib.pyplot.tight_layout()
306
307 if XAxisAsTime:
308
309 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
310 ax.xaxis.set_major_formatter(FuncFormatter(func))
311 ax.xaxis.set_major_locator(LinearLocator(7))
312
313 fig.tight_layout()
314 # matplotlib.pyplot.ion()
315
316 return iplot
317
318 def pmultilineyaxis(iplot, x, y, xlabel='', ylabel='', title=''):
319
320 ax = iplot.get_axes()
321
322 printLabels(ax, xlabel, ylabel, title)
323
324 for i in range(len(ax.lines)):
325 line = ax.lines[i]
326 line.set_data(x,y[i,:]) No newline at end of file
@@ -0,0 +1,139
1 # -*- coding: utf-8 -*-
2
3 # Form implementation generated from reading ui file '/home/alex/ui/ftpConfig4.ui'
4 #
5 # Created: Tue Aug 20 08:24:35 2013
6 # by: PyQt4 UI code generator 4.10
7 #
8 # WARNING! All changes made in this file will be lost!
9
10 from PyQt4 import QtCore, QtGui
11
12 try:
13 _fromUtf8 = QtCore.QString.fromUtf8
14 except AttributeError:
15 def _fromUtf8(s):
16 return s
17
18 try:
19 _encoding = QtGui.QApplication.UnicodeUTF8
20 def _translate(context, text, disambig):
21 return QtGui.QApplication.translate(context, text, disambig, _encoding)
22 except AttributeError:
23 def _translate(context, text, disambig):
24 return QtGui.QApplication.translate(context, text, disambig)
25
26 class Ui_Ftp(object):
27 def setupUi(self, MainWindow):
28 MainWindow.setObjectName(_fromUtf8("MainWindow"))
29 MainWindow.resize(374, 399)
30 MainWindow.setMinimumSize(QtCore.QSize(374, 399))
31 MainWindow.setMaximumSize(QtCore.QSize(374, 399))
32 self.centralWidget = QtGui.QWidget(MainWindow)
33 self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
34 self.label = QtGui.QLabel(self.centralWidget)
35 self.label.setGeometry(QtCore.QRect(9, 38, 47, 17))
36 self.label.setObjectName(_fromUtf8("label"))
37 self.label_2 = QtGui.QLabel(self.centralWidget)
38 self.label_2.setGeometry(QtCore.QRect(9, 133, 77, 17))
39 self.label_2.setObjectName(_fromUtf8("label_2"))
40 self.label_3 = QtGui.QLabel(self.centralWidget)
41 self.label_3.setGeometry(QtCore.QRect(9, 166, 68, 17))
42 self.label_3.setObjectName(_fromUtf8("label_3"))
43 self.label_4 = QtGui.QLabel(self.centralWidget)
44 self.label_4.setGeometry(QtCore.QRect(9, 9, 101, 17))
45 font = QtGui.QFont()
46 font.setBold(True)
47 font.setWeight(75)
48 self.label_4.setFont(font)
49 self.label_4.setObjectName(_fromUtf8("label_4"))
50 self.label_5 = QtGui.QLabel(self.centralWidget)
51 self.label_5.setGeometry(QtCore.QRect(9, 104, 87, 17))
52 font = QtGui.QFont()
53 font.setBold(True)
54 font.setWeight(75)
55 self.label_5.setFont(font)
56 self.label_5.setObjectName(_fromUtf8("label_5"))
57 self.label_6 = QtGui.QLabel(self.centralWidget)
58 self.label_6.setGeometry(QtCore.QRect(9, 71, 47, 17))
59 self.label_6.setObjectName(_fromUtf8("label_6"))
60 self.serverFTP = QtGui.QLineEdit(self.centralWidget)
61 self.serverFTP.setGeometry(QtCore.QRect(130, 40, 231, 27))
62 self.serverFTP.setObjectName(_fromUtf8("serverFTP"))
63 self.folderFTP = QtGui.QLineEdit(self.centralWidget)
64 self.folderFTP.setGeometry(QtCore.QRect(130, 70, 231, 27))
65 self.folderFTP.setObjectName(_fromUtf8("folderFTP"))
66 self.usernameFTP = QtGui.QLineEdit(self.centralWidget)
67 self.usernameFTP.setGeometry(QtCore.QRect(130, 130, 231, 27))
68 self.usernameFTP.setObjectName(_fromUtf8("usernameFTP"))
69 self.passwordFTP = QtGui.QLineEdit(self.centralWidget)
70 self.passwordFTP.setGeometry(QtCore.QRect(130, 160, 231, 27))
71 self.passwordFTP.setObjectName(_fromUtf8("passwordFTP"))
72 self.ftpCancelButton = QtGui.QPushButton(self.centralWidget)
73 self.ftpCancelButton.setGeometry(QtCore.QRect(130, 360, 111, 27))
74 self.ftpCancelButton.setObjectName(_fromUtf8("ftpCancelButton"))
75 self.ftpOkButton = QtGui.QPushButton(self.centralWidget)
76 self.ftpOkButton.setGeometry(QtCore.QRect(250, 360, 111, 27))
77 self.ftpOkButton.setObjectName(_fromUtf8("ftpOkButton"))
78 self.label_7 = QtGui.QLabel(self.centralWidget)
79 self.label_7.setGeometry(QtCore.QRect(10, 200, 66, 17))
80 font = QtGui.QFont()
81 font.setBold(True)
82 font.setWeight(75)
83 self.label_7.setFont(font)
84 self.label_7.setObjectName(_fromUtf8("label_7"))
85 self.label_8 = QtGui.QLabel(self.centralWidget)
86 self.label_8.setGeometry(QtCore.QRect(10, 230, 81, 17))
87 self.label_8.setObjectName(_fromUtf8("label_8"))
88 self.label_9 = QtGui.QLabel(self.centralWidget)
89 self.label_9.setGeometry(QtCore.QRect(10, 260, 81, 17))
90 self.label_9.setObjectName(_fromUtf8("label_9"))
91 self.label_10 = QtGui.QLabel(self.centralWidget)
92 self.label_10.setGeometry(QtCore.QRect(10, 290, 81, 17))
93 self.label_10.setObjectName(_fromUtf8("label_10"))
94 self.label_11 = QtGui.QLabel(self.centralWidget)
95 self.label_11.setGeometry(QtCore.QRect(10, 320, 81, 17))
96 self.label_11.setObjectName(_fromUtf8("label_11"))
97 self.weightFTP = QtGui.QLineEdit(self.centralWidget)
98 self.weightFTP.setGeometry(QtCore.QRect(130, 230, 231, 27))
99 self.weightFTP.setObjectName(_fromUtf8("weightFTP"))
100 self.expcodeFTP = QtGui.QLineEdit(self.centralWidget)
101 self.expcodeFTP.setGeometry(QtCore.QRect(130, 260, 231, 27))
102 self.expcodeFTP.setObjectName(_fromUtf8("expcodeFTP"))
103 self.subexpFTP = QtGui.QLineEdit(self.centralWidget)
104 self.subexpFTP.setGeometry(QtCore.QRect(130, 290, 231, 27))
105 self.subexpFTP.setObjectName(_fromUtf8("subexpFTP"))
106 self.plotposFTP = QtGui.QLineEdit(self.centralWidget)
107 self.plotposFTP.setGeometry(QtCore.QRect(130, 320, 231, 27))
108 self.plotposFTP.setObjectName(_fromUtf8("plotposFTP"))
109 MainWindow.setCentralWidget(self.centralWidget)
110
111 self.retranslateUi(MainWindow)
112 QtCore.QMetaObject.connectSlotsByName(MainWindow)
113
114 def retranslateUi(self, MainWindow):
115 MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
116 self.label.setText(_translate("MainWindow", "Server:", None))
117 self.label_2.setText(_translate("MainWindow", "User Name:", None))
118 self.label_3.setText(_translate("MainWindow", "Password:", None))
119 self.label_4.setText(_translate("MainWindow", "Server Details", None))
120 self.label_5.setText(_translate("MainWindow", "User Details", None))
121 self.label_6.setText(_translate("MainWindow", "Folder:", None))
122 self.ftpCancelButton.setText(_translate("MainWindow", "Cancel", None))
123 self.ftpOkButton.setText(_translate("MainWindow", "Ok", None))
124 self.label_7.setText(_translate("MainWindow", "Others", None))
125 self.label_8.setText(_translate("MainWindow", "Ftp_wei:", None))
126 self.label_9.setText(_translate("MainWindow", "Exp_code:", None))
127 self.label_10.setText(_translate("MainWindow", "Sub_exp:", None))
128 self.label_11.setText(_translate("MainWindow", "Plot_pos:", None))
129
130
131 if __name__ == "__main__":
132 import sys
133 app = QtGui.QApplication(sys.argv)
134 MainWindow = QtGui.QMainWindow()
135 ui = Ui_Ftp()
136 ui.setupUi(MainWindow)
137 MainWindow.show()
138 sys.exit(app.exec_())
139
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
@@ -139,6 +139,12 class ParameterConf():
139 139 self.name = name
140 140 self.value = str(value)
141 141 self.format = str.lower(format)
142
143 def update(self, name, value, format='str'):
144
145 self.name = name
146 self.value = str(value)
147 self.format = format
142 148
143 149 def makeXml(self, opElement):
144 150
@@ -194,6 +200,34 class OperationConf():
194 200
195 201 return self.parmConfObjList
196 202
203 def getParameterObj(self, parameterName):
204
205 for parmConfObj in self.parmConfObjList:
206
207 if parmConfObj.name != parameterName:
208 continue
209
210 return parmConfObj
211
212 return None
213
214 def getParameterObjfromValue(self,parameterValue):
215 for parmConfObj in self.parmConfObjList:
216
217 if parmConfObj.getValue() != parameterValue:
218 continue
219
220 return parmConfObj.getValue()
221
222 return None
223
224 def getParameterValue(self, parameterName):
225
226 parameterObj = self.getParameterObj(parameterName)
227 value = parameterObj.getValue()
228
229 return value
230
197 231 def setup(self, id, name, priority, type):
198 232
199 233 self.id = id
@@ -202,6 +236,13 class OperationConf():
202 236 self.priority = priority
203 237
204 238 self.parmConfObjList = []
239
240 def removeParameters(self):
241
242 for obj in self.parmConfObjList:
243 del obj
244
245 self.parmConfObjList = []
205 246
206 247 def addParameter(self, name, value, format='str'):
207 248
@@ -214,6 +255,13 class OperationConf():
214 255
215 256 return parmConfObj
216 257
258 def changeParameter(self, name, value, format='str'):
259
260 parmConfObj = self.getParameterObj(name)
261 parmConfObj.update(name, value, format)
262
263 return parmConfObj
264
217 265 def makeXml(self, upElement):
218 266
219 267 opElement = SubElement(upElement, self.ELEMENTNAME)
@@ -282,6 +330,7 class ProcUnitConf():
282 330 name = None
283 331 datatype = None
284 332 inputId = None
333 parentId = None
285 334
286 335 opConfObjList = []
287 336
@@ -326,21 +375,49 class ProcUnitConf():
326 375
327 376 return self.opConfObjList
328 377
378 def getOperationObj(self, name=None):
379
380 for opConfObj in self.opConfObjList:
381
382 if opConfObj.name != name:
383 continue
384
385 return opConfObj
386
387 return None
388
389 def getOpObjfromParamValue(self,value=None):
390
391 for opConfObj in self.opConfObjList:
392 if opConfObj.getParameterObjfromValue(parameterValue=value) != value:
393 continue
394 return opConfObj
395 return None
396
329 397 def getProcUnitObj(self):
330 398
331 399 return self.procUnitObj
332 400
333 def setup(self, id, name, datatype, inputId):
401 def setup(self, id, name, datatype, inputId, parentId=None):
334 402
335 403 self.id = id
336 404 self.name = name
337 405 self.datatype = datatype
338 406 self.inputId = inputId
407 self.parentId = parentId
339 408
340 409 self.opConfObjList = []
341 410
342 411 self.addOperation(name='run', optype='self')
343 412
413 def removeOperations(self):
414
415 for obj in self.opConfObjList:
416 del obj
417
418 self.opConfObjList = []
419 self.addOperation(name='run')
420
344 421 def addParameter(self, **kwargs):
345 422
346 423 opObj = self.opConfObjList[0]
@@ -426,6 +503,9 class ProcUnitConf():
426 503
427 504 kwargs = {}
428 505 for parmConfObj in opConfObj.getParameterObjList():
506 if opConfObj.name == 'run' and parmConfObj.name == 'datatype':
507 continue
508
429 509 kwargs[parmConfObj.name] = parmConfObj.getValue()
430 510
431 511 #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id)
@@ -439,8 +519,15 class ProcUnitConf():
439 519
440 520 def close(self):
441 521
442 self.procUnitObj.close()
522 for opConfObj in self.opConfObjList:
523 if opConfObj.type == 'self':
524 continue
525
526 opObj = self.procUnitObj.getOperationObj(opConfObj.id)
527 opObj.close()
443 528
529 self.procUnitObj.close()
530
444 531 return
445 532
446 533 class ReadUnitConf(ProcUnitConf):
@@ -467,7 +554,7 class ReadUnitConf(ProcUnitConf):
467 554
468 555 return self.ELEMENTNAME
469 556
470 def setup(self, id, name, datatype, path="", startDate="", endDate="", startTime="", endTime="", **kwargs):
557 def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", endTime="", parentId=None, **kwargs):
471 558
472 559 self.id = id
473 560 self.name = name
@@ -480,11 +567,23 class ReadUnitConf(ProcUnitConf):
480 567 self.endTime = endTime
481 568
482 569 self.addRunOperation(**kwargs)
483
570
571 def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, **kwargs):
572
573 self.datatype = datatype
574 self.path = path
575 self.startDate = startDate
576 self.endDate = endDate
577 self.startTime = startTime
578 self.endTime = endTime
579
580 self.updateRunOperation(**kwargs)
581
484 582 def addRunOperation(self, **kwargs):
485 583
486 584 opObj = self.addOperation(name = 'run', optype = 'self')
487 585
586 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
488 587 opObj.addParameter(name='path' , value=self.path, format='str')
489 588 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
490 589 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
@@ -496,6 +595,22 class ReadUnitConf(ProcUnitConf):
496 595
497 596 return opObj
498 597
598 def updateRunOperation(self, **kwargs):
599
600 opObj = self.getOperationObj(name = 'run')
601 opObj.removeParameters()
602
603 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
604 opObj.addParameter(name='path' , value=self.path, format='str')
605 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
606 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
607 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
608 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
609
610 for key, value in kwargs.items():
611 opObj.addParameter(name=key, value=value, format=type(value).__name__)
612
613 return opObj
499 614
500 615 class Project():
501 616
@@ -507,15 +622,24 class Project():
507 622
508 623 ELEMENTNAME = 'Project'
509 624
510 def __init__(self):
625 def __init__(self, control=None, dataq=None):
511 626
512 627 self.id = None
513 628 self.name = None
514 629 self.description = None
515
516 # self.readUnitConfObjList = []
630
517 631 self.procUnitConfObjDict = {}
518 632
633 #global data_q
634 #data_q = dataq
635
636 if control==None:
637 control = {}
638 control['stop'] = False
639 control['pause'] = False
640
641 self.control = control
642
519 643 def __getNewId(self):
520 644
521 645 id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1
@@ -525,13 +649,22 class Project():
525 649 def getElementName(self):
526 650
527 651 return self.ELEMENTNAME
652
653 def getId(self):
654
655 return self.id
528 656
529 657 def setup(self, id, name, description):
530 658
531 659 self.id = id
532 660 self.name = name
533 661 self.description = description
534
662
663 def update(self, name, description):
664
665 self.name = name
666 self.description = description
667
535 668 def addReadUnit(self, datatype=None, name=None, **kwargs):
536 669
537 670 #Compatible with old signal chain version
@@ -550,7 +683,7 class Project():
550 683 id = self.__getNewId()
551 684
552 685 readUnitConfObj = ReadUnitConf()
553 readUnitConfObj.setup(id, name, datatype, **kwargs)
686 readUnitConfObj.setup(id, name, datatype, parentId=self.id, **kwargs)
554 687
555 688 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
556 689
@@ -574,12 +707,30 class Project():
574 707 id = self.__getNewId()
575 708
576 709 procUnitConfObj = ProcUnitConf()
577 procUnitConfObj.setup(id, name, datatype, inputId)
710 procUnitConfObj.setup(id, name, datatype, inputId, parentId=self.id)
578 711
579 712 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
580 713
581 714 return procUnitConfObj
582 715
716 def getReadUnitId(self):
717
718 readUnitConfObj = self.getReadUnitObj()
719
720 return readUnitConfObj.id
721
722 def getReadUnitObj(self):
723
724 for obj in self.procUnitConfObjDict.values():
725 if obj.getElementName() == "ReadUnit":
726 return obj
727
728 return None
729
730 def getProcUnitObj(self, id):
731
732 return self.procUnitConfObjDict[id]
733
583 734 def makeXml(self):
584 735
585 736 projectElement = Element('Project')
@@ -705,10 +856,28 class Project():
705 856 print "Every process unit have finished"
706 857 break
707 858
859 if self.control['pause']:
860 print "Pause..."
861
862 while True:
863 time.sleep(0.1)
864
865 if not self.control['pause']:
866 break
867
868 if self.control['stop']:
869 break
870
871 if self.control['stop']:
872 print "Stopping process"
873 break
874
708 875 #Closing every process
709 876 for procKey in keyList:
710 877 procUnitConfObj = self.procUnitConfObjDict[procKey]
711 878 procUnitConfObj.close()
879
880 print "Process stopped"
712 881
713 882 def start(self, filename):
714 883
@@ -1,1 +0,0
1 from figure import * No newline at end of file
@@ -1,5 +1,4
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-'
1
3 2 import sys
4 3 from PyQt4 import QtCore, QtGui
5 4 from PyQt4.QtGui import QApplication
@@ -1,1 +0,0
1 from viewcontroller import * No newline at end of file
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
@@ -9,7 +9,7 from PyQt4.QtCore import pyqtSignature
9 9 from PyQt4 import QtCore
10 10 from PyQt4 import QtGui
11 11
12 from viewer.ui_initwindow import Ui_InitWindow
12 from schainpy.gui.viewer.ui_initwindow import Ui_InitWindow
13 13
14 14 class InitWindow(QDialog, Ui_InitWindow):
15 15 """
@@ -22,7 +22,7 class InitWindow(QDialog, Ui_InitWindow):
22 22 QDialog.__init__(self, parent)
23 23 self.setupUi(self)
24 24 self.setWindowTitle("ROJ-Signal Chain")
25 self.setWindowIcon(QtGui.QIcon("figure/adn.jpg"))
25 self.setWindowIcon(QtGui.QIcon("schainpy/gui/figure/adn.jpg"))
26 26
27 27 @pyqtSignature("")
28 28 def on_ExitBtn_clicked(self):
@@ -11,12 +11,11 from PyQt4 import QtGui
11 11 from timeconversions import Doy2Date
12 12 from modelProperties import treeModel
13 13
14 from viewer.ui_unitprocess import Ui_UnitProcess
15 from viewer.ui_window import Ui_window
16 from viewer.ui_mainwindow import Ui_MainWindow
14 from schainpy.gui.viewer.ui_unitprocess import Ui_UnitProcess
15 from schainpy.gui.viewer.ui_window import Ui_window
16 from schainpy.gui.viewer.ui_mainwindow import Ui_MainWindow
17 17
18
19 from controller import Project,ReadUnitConf,ProcUnitConf,OperationConf,ParameterConf
18 from schainpy.controller import Project,ReadUnitConf,ProcUnitConf,OperationConf,ParameterConf
20 19 import os
21 20
22 21
This diff has been collapsed as it changes many lines, (578 lines changed) Show them Hide them
@@ -1,277 +1,303
1 from PyQt4 import QtCore
2
3 HORIZONTAL_HEADERS = ("Property","Value " )
4
5 HORIZONTAL = ("RAMA :",)
6
7 class treeModel(QtCore.QAbstractItemModel):
8 '''
9 a model to display a few names, ordered by encabezado
10 '''
11 name=None
12 directorio=None
13 workspace=None
14 remode=None
15 dataformat=None
16 date=None
17 initTime=None
18 endTime=None
19 timezone=None
20 Summary=None
21
22 description=None
23
24 def __init__(self ,parent=None):
25 super(treeModel, self).__init__(parent)
26 self.people = []
27
28
29 def properties_projecto(self,description):
30 self.caracteristica="Project_Properties"
31 self.principal ="Name"
32 self.description =description
33 exam_project=person_class(self.caracteristica,self.principal,self.description)
34 return exam_project
35
36
37
38 def arbol(self):
39 for caracteristica,principal, descripcion in (("Properties","Name",self.name),
40 ("Properties","Data Path",self.directorio),
41 ("Properties","Workspace",self.workspace),
42 ("Parameters", "Read Mode ",self.remode),
43 ("Parameters", "DataType ",self.dataformat),
44 ("Parameters", "Date ",self.date),
45 ("Parameters", "Init Time ",self.initTime),
46 ("Parameters", "Final Time ",self.endTime),
47 ("Parameters", " Time zone ",self.timezone),
48 ("Parameters", "Profiles ","1"),
49 ("Description", "Summary ", self.Summary),
50 ):
51 person = person_class(caracteristica, principal, descripcion)
52 self.people.append(person)
53 def addProjectproperties(self,person):
54 self.people.append(person)
55
56
57 #def veamos(self):
58 # self.update= MainWindow(self)
59 # self.update.dataProyectTxt.text()
60 # return self.update.dataProyectTxt.text()
61
62 def showtree(self):
63 self.rootItem = TreeItem(None, "ALL", None)
64 self.parents = {0 : self.rootItem}
65 self.setupModelData()
66
67 def setParams(self,name,directorio,workspace,remode,dataformat,date,initTime,endTime,timezone,Summary):
68 self.name=name
69 self.workspace=workspace
70 self.directorio= directorio
71 self.remode=remode
72 self.dataformat=dataformat
73 self.date=date
74 self.initTime=initTime
75 self.endTime=endTime
76 self.timezone=timezone
77 self.Summary=Summary
78
79
80 for caracteristica,principal, descripcion in (("Properties","Name",self.name),
81 ("Properties","Data Path",self.directorio),
82 ("Properties","Workspace",self.workspace),
83 ("Parameters", "Read Mode ",self.remode),
84 ("Parameters", "DataType ",self.dataformat),
85 ("Parameters", "Date ",self.date),
86 ("Parameters", "Init Time ",self.initTime),
87 ("Parameters", "Final Time ",self.endTime),
88 ("Parameters", " Time zone ",self.timezone),
89 ("Parameters", "Profiles ","1"),
90 ("Description", "Summary ", self.Summary),
91 ):
92 person = person_class(caracteristica, principal, descripcion)
93 self.people.append(person)
94 self.rootItem = TreeItem(None, "ALL", None)
95 self.parents = {0 : self.rootItem}
96 self.setupModelData()
97
98
99 def columnCount(self, parent=None):
100 if parent and parent.isValid():
101 return parent.internalPointer().columnCount()
102 else:
103 return len(HORIZONTAL_HEADERS)
104
105 def data(self, index, role):
106 if not index.isValid():
107 return QtCore.QVariant()
108
109 item = index.internalPointer()
110 if role == QtCore.Qt.DisplayRole:
111 return item.data(index.column())
112 if role == QtCore.Qt.UserRole:
113 if item:
114 return item.person
115
116 return QtCore.QVariant()
117
118 def headerData(self, column, orientation, role):
119 if (orientation == QtCore.Qt.Horizontal and
120 role == QtCore.Qt.DisplayRole):
121 try:
122 return QtCore.QVariant(HORIZONTAL_HEADERS[column])
123 except IndexError:
124 pass
125
126 return QtCore.QVariant()
127
128 def index(self, row, column, parent):
129 if not self.hasIndex(row, column, parent):
130 return QtCore.QModelIndex()
131
132 if not parent.isValid():
133 parentItem = self.rootItem
134 else:
135 parentItem = parent.internalPointer()
136
137 childItem = parentItem.child(row)
138 if childItem:
139 return self.createIndex(row, column, childItem)
140 else:
141 return QtCore.QModelIndex()
142
143 def parent(self, index):
144 if not index.isValid():
145 return QtCore.QModelIndex()
146
147 childItem = index.internalPointer()
148 if not childItem:
149 return QtCore.QModelIndex()
150
151 parentItem = childItem.parent()
152
153 if parentItem == self.rootItem:
154 return QtCore.QModelIndex()
155
156 return self.createIndex(parentItem.row(), 0, parentItem)
157
158 def rowCount(self, parent=QtCore.QModelIndex()):
159 if parent.column() > 0:
160 return 0
161 if not parent.isValid():
162 p_Item = self.rootItem
163 else:
164 p_Item = parent.internalPointer()
165 return p_Item.childCount()
166
167 def setupModelData(self):
168 for person in self.people:
169 if person.descripcion:
170 encabezado = person.caracteristica
171
172
173 if not self.parents.has_key(encabezado):
174 newparent = TreeItem(None, encabezado, self.rootItem)
175 self.rootItem.appendChild(newparent)
176
177 self.parents[encabezado] = newparent
178
179 parentItem = self.parents[encabezado]
180 newItem = TreeItem(person, "", parentItem)
181 parentItem.appendChild(newItem)
182
183 def searchModel(self, person):
184 '''
185 get the modelIndex for a given appointment
186 '''
187 def searchNode(node):
188 '''
189 a function called recursively, looking at all nodes beneath node
190 '''
191 for child in node.childItems:
192 if person == child.person:
193 index = self.createIndex(child.row(), 0, child)
194 return index
195
196 if child.childCount() > 0:
197 result = searchNode(child)
198 if result:
199 return result
200
201 retarg = searchNode(self.parents[0])
202 #print retarg
203 return retarg
204
205 def find_GivenName(self, principal):
206 app = None
207 for person in self.people:
208 if person.principal == principal:
209 app = person
210 break
211 if app != None:
212 index = self.searchModel(app)
213 return (True, index)
214 return (False, None)
215
216
217
218
219
220
221
222 class person_class(object):
223 '''
224 a trivial custom data object
225 '''
226 def __init__(self, caracteristica, principal, descripcion):
227 self.caracteristica = caracteristica
228 self.principal = principal
229 self.descripcion = descripcion
230
231 def __repr__(self):
232 return "PERSON - %s %s"% (self.principal, self.caracteristica)
233
234 class TreeItem(object):
235 '''
236 a python object used to return row/column data, and keep note of
237 it's parents and/or children
238 '''
239 def __init__(self, person, header, parentItem):
240 self.person = person
241 self.parentItem = parentItem
242 self.header = header
243 self.childItems = []
244
245 def appendChild(self, item):
246 self.childItems.append(item)
247
248 def child(self, row):
249 return self.childItems[row]
250
251 def childCount(self):
252 return len(self.childItems)
253
254 def columnCount(self):
255 return 2
256
257 def data(self, column):
258 if self.person == None:
259 if column == 0:
260 return QtCore.QVariant(self.header)
261 if column == 1:
262 return QtCore.QVariant("")
263 else:
264 if column == 0:
265 return QtCore.QVariant(self.person.principal)
266 if column == 1:
267 return QtCore.QVariant(self.person.descripcion)
268 return QtCore.QVariant()
269
270 def parent(self):
271 return self.parentItem
272
273 def row(self):
274 if self.parentItem:
275 return self.parentItem.childItems.index(self)
276 return 0
1 # -*- coding: utf-8 -*-
2 from PyQt4 import QtCore
3 import itertools
4
5 HORIZONTAL_HEADERS = ("Property","Value " )
6
7 HORIZONTAL = ("RAMA :",)
8
9 class treeModel(QtCore.QAbstractItemModel):
10 '''
11 a model to display a few names, ordered by encabezado
12
13 '''
14 def __init__(self ,parent=None):
15 super(treeModel, self).__init__(parent)
16 self.people = []
17 self.initProjectProperties()
18 self.initPUVoltageProperties()
19 self.initPUSpectraProperties()
20 self.initPUSpectraHeisProperties()
21
22 def initProjectProperties(self):
23
24 name=None
25 directorio=None
26 workspace=None
27 remode=None
28 dataformat=None
29 startDate=None
30 endDate=None
31 startTime=None
32 endTime=None
33 delay=None
34 set= None
35 walk=None
36 timezone=None
37 Summary=None
38 description=None
39
40 def initPUVoltageProperties(self):
41 type=None
42 channel=None
43 heights=None
44 filter=None
45 profile=None
46 code=None
47 mode=None
48 coherentintegration=None
49
50 def initPUSpectraProperties(self):
51 type =None
52 nFFTpoints =None
53 ippFactor = None
54 pairsList =None
55 channel =None
56 heights =None
57 incoherentintegration =None
58 removeDC = None
59 removeInterference =None
60 getNoise = None
61 operationSpecPlot=None
62 operationCrossSpecPlot = None
63 operationRTIPlot = None
64 operationCohermap = None
65 operationPowProfilePlot = None
66
67 def initPUSpectraHeisProperties(self):
68 type =None
69 incoherentintegration =None
70 operationSpecHeisPlot=None
71 operationRTIHeisPlot = None
72
73 def initProjectView(self):
74 """
75 Reemplazo del método showtree
76 """
77 HORIZONTAL_HEADERS = ("Property","Value " )
78 HORIZONTAL = ("RAMA :",)
79 self.rootItem = TreeItem(None, "ALL", None)
80 self.parents = {0 : self.rootItem}
81 self.setupModelData()
82
83 def initPUVoltageView(self):
84 HORIZONTAL_HEADERS = ("Operation"," Parameter Value " )
85 HORIZONTAL = ("RAMA :",)
86 self.rootItem = TreeItem(None, "ALL", None)
87 self.parents = {0 : self.rootItem}
88 self.setupModelData()
89
90 def showProjectParms(self,caracteristicaList,principalList,descripcionList):
91 """
92 set2Obje
93 """
94 for caracteristica,principal, descripcion in itertools.izip(caracteristicaList,principalList,descripcionList):
95 person = person_class(caracteristica, principal, descripcion)
96 self.people.append(person)
97 self.rootItem = TreeItem(None, "ALL", None)
98 self.parents = {0 : self.rootItem}
99 self.setupModelData()
100
101 def showPUVoltageParms(self,caracteristicaList,principalList,descripcionList):
102
103 for caracteristica,principal, descripcion in itertools.izip(caracteristicaList,principalList,descripcionList):
104 person = person_class(caracteristica, principal, descripcion)
105 self.people.append(person)
106 self.rootItem = TreeItem(None, "ALL", None)
107 self.parents = {0 : self.rootItem}
108 self.setupModelData()
109
110
111 def showPUSpectraParms(self,caracteristicaList,principalList,descripcionList):
112
113 for caracteristica,principal, descripcion in itertools.izip(caracteristicaList,principalList,descripcionList):
114 person = person_class(caracteristica, principal, descripcion)
115 self.people.append(person)
116 self.rootItem = TreeItem(None, "ALL", None)
117 self.parents = {0 : self.rootItem}
118 self.setupModelData()
119
120 def showPUSpectraHeisParms(self,caracteristicaList,principalList,descripcionList):
121
122 for caracteristica,principal, descripcion in itertools.izip(caracteristicaList,principalList,descripcionList):
123 person = person_class(caracteristica, principal, descripcion)
124 self.people.append(person)
125 self.rootItem = TreeItem(None, "ALL", None)
126 self.parents = {0 : self.rootItem}
127 self.setupModelData()
128
129
130 def columnCount(self, parent=None):
131 if parent and parent.isValid():
132 return parent.internalPointer().columnCount()
133 else:
134 return len(HORIZONTAL_HEADERS)
135
136 def data(self, index, role):
137 if not index.isValid():
138 return QtCore.QVariant()
139
140 item = index.internalPointer()
141 if role == QtCore.Qt.DisplayRole:
142 return item.data(index.column())
143 if role == QtCore.Qt.UserRole:
144 if item:
145 return item.person
146
147 return QtCore.QVariant()
148
149 def headerData(self, column, orientation, role):
150 if (orientation == QtCore.Qt.Horizontal and
151 role == QtCore.Qt.DisplayRole):
152 try:
153 return QtCore.QVariant(HORIZONTAL_HEADERS[column])
154 except IndexError:
155 pass
156
157 return QtCore.QVariant()
158
159 def index(self, row, column, parent):
160 if not self.hasIndex(row, column, parent):
161 return QtCore.QModelIndex()
162
163 if not parent.isValid():
164 parentItem = self.rootItem
165 else:
166 parentItem = parent.internalPointer()
167
168 childItem = parentItem.child(row)
169 if childItem:
170 return self.createIndex(row, column, childItem)
171 else:
172 return QtCore.QModelIndex()
173
174 def parent(self, index):
175 if not index.isValid():
176 return QtCore.QModelIndex()
177
178 childItem = index.internalPointer()
179 if not childItem:
180 return QtCore.QModelIndex()
181
182 parentItem = childItem.parent()
183
184 if parentItem == self.rootItem:
185 return QtCore.QModelIndex()
186
187 return self.createIndex(parentItem.row(), 0, parentItem)
188
189 def rowCount(self, parent=QtCore.QModelIndex()):
190 if parent.column() > 0:
191 return 0
192 if not parent.isValid():
193 p_Item = self.rootItem
194 else:
195 p_Item = parent.internalPointer()
196 return p_Item.childCount()
197
198 def setupModelData(self):
199 for person in self.people:
200 if person.descripcion:
201 encabezado = person.caracteristica
202
203
204 if not self.parents.has_key(encabezado):
205 newparent = TreeItem(None, encabezado, self.rootItem)
206 self.rootItem.appendChild(newparent)
207
208 self.parents[encabezado] = newparent
209
210 parentItem = self.parents[encabezado]
211 newItem = TreeItem(person, "", parentItem)
212 parentItem.appendChild(newItem)
213
214 def searchModel(self, person):
215 '''
216 get the modelIndex for a given appointment
217 '''
218 def searchNode(node):
219 '''
220 a function called recursively, looking at all nodes beneath node
221 '''
222 for child in node.childItems:
223 if person == child.person:
224 index = self.createIndex(child.row(), 0, child)
225 return index
226
227 if child.childCount() > 0:
228 result = searchNode(child)
229 if result:
230 return result
231
232 retarg = searchNode(self.parents[0])
233 #print retarg
234 return retarg
235
236 def find_GivenName(self, principal):
237 app = None
238 for person in self.people:
239 if person.principal == principal:
240 app = person
241 break
242 if app != None:
243 index = self.searchModel(app)
244 return (True, index)
245 return (False, None)
246
247
248 class person_class(object):
249 '''
250 a trivial custom data object
251 '''
252 def __init__(self, caracteristica, principal, descripcion):
253 self.caracteristica = caracteristica
254 self.principal = principal
255 self.descripcion = descripcion
256
257 def __repr__(self):
258 return "PERSON - %s %s"% (self.principal, self.caracteristica)
259
260 class TreeItem(object):
261 '''
262 a python object used to return row/column data, and keep note of
263 it's parents and/or children
264 '''
265 def __init__(self, person, header, parentItem):
266 self.person = person
267 self.parentItem = parentItem
268 self.header = header
269 self.childItems = []
270
271 def appendChild(self, item):
272 self.childItems.append(item)
273
274 def child(self, row):
275 return self.childItems[row]
276
277 def childCount(self):
278 return len(self.childItems)
279
280 def columnCount(self):
281 return 2
282
283 def data(self, column):
284 if self.person == None:
285 if column == 0:
286 return QtCore.QVariant(self.header)
287 if column == 1:
288 return QtCore.QVariant("")
289 else:
290 if column == 0:
291 return QtCore.QVariant(self.person.principal)
292 if column == 1:
293 return QtCore.QVariant(self.person.descripcion)
294 return QtCore.QVariant()
295
296 def parent(self):
297 return self.parentItem
298
299 def row(self):
300 if self.parentItem:
301 return self.parentItem.childItems.index(self)
302 return 0
277 303 No newline at end of file
@@ -1,10 +1,7
1 1 import os, sys
2 2 import getopt
3 path = os.path.split(os.getcwd())[0]
4 #path="C://Users//alex//workspace//gui_14_03_13"
5 sys.path.append(path)
6 3
7 from controller import *
4 from schainpy.controller import Project
8 5
9 6 class scProcessController():
10 7 def __init__(self):
@@ -7,7 +7,7 Module implementing MainWindow.
7 7 from PyQt4.QtGui import QMainWindow
8 8 from PyQt4.QtCore import pyqtSignature
9 9
10 from viewer.ui_unitprocess import Ui_UnitProcess
10 from schainpy.gui.viewer.ui_unitprocess import Ui_UnitProcess
11 11
12 12 class UnitProcess(QMainWindow, Ui_UnitProcess):
13 13 """
@@ -10,13 +10,13 from PyQt4 import QtCore
10 10 from PyQt4 import QtGui
11 11 from timeconversions import Doy2Date
12 12 from modelProperties import treeModel
13 from viewer.ui_unitprocess import Ui_UnitProcess
14 from viewer.ui_window import Ui_window
15 from viewer.ui_mainwindow import Ui_MainWindow
16 from viewer.ui_workspace import Ui_Workspace
17 from viewer.ui_initwindow import Ui_InitWindow
13 from schainpy.gui.viewer.ui_unitprocess import Ui_UnitProcess
14 from schainpy.gui.viewer.ui_window import Ui_window
15 from schainpy.gui.viewer.ui_mainwindow import Ui_MainWindow
16 from schainpy.gui.viewer.ui_workspace import Ui_Workspace
17 from schainpy.gui.viewer.ui_initwindow import Ui_InitWindow
18 18
19 from controller import Project,ReadUnitConf,ProcUnitConf,OperationConf,ParameterConf
19 from schainpy.controller import Project,ReadUnitConf,ProcUnitConf,OperationConf,ParameterConf
20 20 import os
21 21
22 22 HORIZONTAL_HEADERS = ("ITEM :"," DATOS : " )
@@ -1,11 +1,13
1 1 # -*- coding: utf-8 -*-
2 2 import os
3 from os.path import expanduser
4
3 5 from PyQt4.QtGui import QDialog
4 6 from PyQt4.QtCore import pyqtSignature
5 7 from PyQt4.QtCore import pyqtSignal
6 8 from PyQt4 import QtGui, QtCore
7 from viewer.ui_workspace import Ui_Workspace
8 from os.path import expanduser
9
10 from schainpy.gui.viewer.ui_workspace import Ui_Workspace
9 11
10 12 class Workspace(QDialog, Ui_Workspace):
11 13 """
@@ -20,7 +22,7 class Workspace(QDialog, Ui_Workspace):
20 22 self.dirList=[]
21 23 self.setupUi(self)
22 24 self.setWindowTitle("ROJ-Signal Chain")
23 self.setWindowIcon(QtGui.QIcon("figure/adn.jpg"))
25 self.setWindowIcon(QtGui.QIcon("schainpy/gui/figure/adn.jpg"))
24 26 #*####### DIRECTORIO DE TRABAJO #########*#
25 27 #self.dirCmbBox.setItemText(0, QtGui.QApplication.translate("MainWindow", "C:\WorkSpaceGui", None, QtGui.QApplication.UnicodeUTF8))
26 28 home=expanduser("~")
@@ -1,4 +1,5
1 1 import ui_initwindow
2 2 import ui_workspace
3 3 import ui_mainwindow
4 import ui_window No newline at end of file
4 import ui_window
5 import ui_ftp No newline at end of file
@@ -42,7 +42,7 class Ui_InitWindow(object):
42 42 self.verticalLayout_4.addWidget(self.line_2)
43 43 self.label_4 = QtGui.QLabel(Dialog)
44 44 self.label_4.setText(_fromUtf8(""))
45 self.label_4.setPixmap(QtGui.QPixmap(_fromUtf8("figure/w.jpg")))
45 self.label_4.setPixmap(QtGui.QPixmap(_fromUtf8("schainpy/gui/figure/w.jpg")))
46 46 self.label_4.setScaledContents(True)
47 47 self.label_4.setObjectName(_fromUtf8("label_4"))
48 48 self.verticalLayout_4.addWidget(self.label_4)
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
General Comments 0
You need to be logged in to leave comments. Login now