forked from eianlei/pydplan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pydplan_plot.py
634 lines (550 loc) · 23.5 KB
/
pydplan_plot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
#
# (c) 2018 Ian Leiman, [email protected]
# pydplan_plot
# part of PYDPLAN, a Python Dive Planner with PyQt5 GUI
# plotting tools
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPainter, QPainterPath, QLinearGradient, QBrush, QPen, QColor
from PyQt5.QtWidgets import QWidget
from pydplan_buhlmann import ModelPoint
colors = [Qt.black, Qt.gray, Qt.lightGray, Qt.darkGray,
Qt.red, Qt.darkYellow, Qt.green, Qt.darkGreen,
Qt.blue, Qt.darkBlue, Qt.cyan, Qt.darkCyan,
Qt.darkMagenta, Qt.magenta, Qt.yellow, Qt.darkRed]
class PlotBelowWidget(QWidget):
def __init__(self, plan=None):
super().__init__()
self.plan = plan
self.maxPressure = 3.0
self.initUI()
def initUI(self):
self.qp = QPainter()
self.show()
def paintEvent(self, e):
size = self.size()
self.plot_width = size.width() -50
self.plot_height = size.height() -5
self.qp.begin(self)
self.drawPP(self.qp)
self.drawPressureGrid(self.qp)
self.qp.end()
def drawPP(self,qp):
qp.drawText(5, self.plot_height+5 , 'PARTIAL PRESSURES O2, He, N2')
if not self.plan.profileSampled :
return
profile = self.plan.profileSampled
self.totalTime = self.plan.profileSampled[-1].time
self.maxPressure = self.plan.maxPPanyGas
# draw the ppo2
x1, y1 = (0, self.plot_height )
qp.setPen(QPen(Qt.darkGreen, 2, Qt.SolidLine))
for point in profile:
x = (point.time / self.totalTime) * self.plot_width
y = (1 - point.ppOxygen / self.maxPressure) * self.plot_height
qp.drawLine(x1, y1, x, y)
x1, y1 = x, y
qp.drawText(x - 20, y, 'ppO2')
# draw the ppHe
x1, y1 = (0, self.plot_height )
qp.setPen(QPen(Qt.blue, 1, Qt.SolidLine))
for point in profile:
x = (point.time / self.totalTime) * self.plot_width
y = (1 - point.ppHelium / self.maxPressure) * self.plot_height
qp.drawLine(x1, y1, x, y)
x1, y1 = x, y
qp.drawText(x - 20, y, 'ppHe')
# draw the ppN2
x1, y1 = (0, self.plot_height )
qp.setPen(QPen(Qt.darkYellow, 1, Qt.SolidLine))
for point in profile:
x = (point.time / self.totalTime) * self.plot_width
y = (1 - point.ppNitrogen / self.maxPressure) * self.plot_height
qp.drawLine(x1, y1, x, y)
x1, y1 = x, y
qp.drawText(x - 20, y-10, 'ppN2')
# draw ppo2=1.6 limit (common deco gas limit, bottom gas limit usually 1.4
y = (1.0 - 1.60 / self.maxPressure) * self.plot_height
qp.setPen(QPen(Qt.darkGreen, 1, Qt.DashLine))
qp.drawLine(0, y, self.plot_width, y)
qp.drawText(self.plot_width/2, y + 10, 'ppO2=1.6 limit')
# draw ppN2 = 3.16, END=30m, the GUE limit, note DAN limit is 3.95
y = (1.0 - 3.16 / self.maxPressure) * self.plot_height
qp.setPen(QPen(Qt.darkYellow, 1, Qt.DashLine))
qp.drawLine(0, y, self.plot_width, y)
qp.drawText(self.plot_width/2, y + 10, 'ppN2=3.16 limit (END=30m)')
def drawPressureGrid(self, qp):
qp.setPen(QPen(Qt.gray, 1, Qt.DotLine))
# pressure lines at maxPressure/6 bar intervals
for gline in range(7) :
y = (1 - (gline/6.0 )) * self.plot_height
qp.drawLine(0, y, self.plot_width, y)
ltext = '{:.1f} bar'.format(gline * self.maxPressure/6.0)
qp.drawText(self.plot_width + 5, y + 10, ltext)
# ticks at 1 meter intervals
#for dd in range(0, int(self.depthMax), 1):
# y = int((dd / self.depthMax) * self.plot_height)
# qp.drawLine(self.plot_width - 5, y, self.plot_width + 4, y)
##################################################################################
class PlotPlanWidget(QWidget):
def __init__(self, plan=None):
super().__init__()
self.plan = plan
self.profileSampled = None
self.TC = None
self.maxTC = None
self.initUI()
self.ceilingPlotX = []
self.ceilingPlotY = [[]]
# initialize the window
def initUI(self):
self.qp = QPainter()
self.show()
# set the vectorised format of profile
def setPlan(self, plan):
self.plan = plan
# when any event occurs, like resize, we also redraw the plot
def paintEvent(self, e):
#qp = QPainter()
self.qp.begin(self)
self.drawSize(self.qp)
self.drawDepth(self.qp)
self.drawDepthGrid(self.qp)
self.drawTimeGrid(self.qp)
self.drawCeilings(self.qp)
self.drawCeilingMargin(self.qp)
self.drawTanks(self.qp)
self.drawTankPressure(self.qp)
#self.drawTC(self.qp)
self.qp.end()
# redraw the depth profile plot
def drawSize(self, qp):
size = self.size()
self.plot_width = size.width() -50
self.plot_height = size.height() -20
def drawDepth(self, qp):
# Fill plot bg area
bgPath = QPainterPath()
bgPath.moveTo(self.plot_width, self.plot_height)
bgPath.lineTo(0.0, self.plot_height)
bgPath.lineTo(0.0, 0.0)
bgPath.lineTo(self.plot_width, 0.0)
bgPath.closeSubpath()
gradient = QLinearGradient(0, 0, 0, 100)
gradient.setColorAt(0.0, Qt.white)
gradient.setColorAt(1.0, Qt.white)
qp.setBrush(QBrush(gradient))
qp.drawPath(bgPath)
qp.drawText(50, 50, 'placeholder for the profile plot widget')
if not self.plan.profileSampled :
return
self.totalTime = self.plan.profileSampled[-1].time
self.depthMax = self.plan.maxDepth
# now we plot the DEPTH profile
depthPath = QPainterPath()
depthPath.moveTo(0.0, 0.0)
#point: DiveProfilePoint
for n, point in enumerate( self.plan.profileSampled):
x = (point.time / self.totalTime ) * self.plot_width
y = (point.depth / self.depthMax) * self.plot_height
depthPath.lineTo(x, y)
depthPath.lineTo(self.plot_width, 0.0)
depthPath.lineTo(0.0, 0.0)
depthPath.closeSubpath()
gradient = QLinearGradient(0, 0, 0, 100)
gradient.setColorAt(0.0, Qt.cyan)
gradient.setColorAt(1.0, Qt.blue)
qp.setBrush(QBrush(gradient))
qp.drawPath(depthPath)
# redraw the ceiling depths
def drawCeilings(self, qp):
if not self.plan.profileSampled :
return
profileSampled = self.plan.profileSampled
self.ceilingPlotX = [0 for y in range(len(profileSampled)) ]
self.ceilingPlotY = [[0 for x in range(len(profileSampled))] for y in range(ModelPoint.COMPS)]
# draw the point.ceiling_use_3m line in green
x1, y1 = (0, 0)
pen = QPen(Qt.green, 2, Qt.SolidLine)
qp.setPen(pen)
for n, point in enumerate(profileSampled):
x = (point.time / self.totalTime) * self.plot_width
self.ceilingPlotX[n] = x
y = point.modelpoint.leadCeilingStop / self.depthMax * self.plot_height
qp.drawLine(x1, y1, x, y)
x1, y1 = x, y
#at the same go we compute the ceiling plots (x,y) for individual tissue compartments
for tc in range(ModelPoint.COMPS):
if not point.modelpoint.ceilings:
yCeiling = 0.0
elif point.modelpoint.ceilings[tc] > 0.0:
yCeiling = (point.modelpoint.ceilings[tc] / self.depthMax) * self.plot_height
else:
yCeiling = 0.0
self.ceilingPlotY[tc][n] = yCeiling
# draw the running average depth
x1, y1 = (0, 0)
qp.setPen(QPen(Qt.lightGray, 1, Qt.SolidLine))
for point in profileSampled:
x = (point.time / self.totalTime) * self.plot_width
y = point.depthRunAvg / self.depthMax * self.plot_height
qp.drawLine(x1, y1, x, y)
x1, y1 = x, y
qp.drawText(x + 10, y, 'AVG')
# now draw the tissue compartment ceilings one by one
for tc in range(ModelPoint.COMPS):
color = QColor(tc*15, 255-(tc*15), tc*15)
pen = QPen(color, 1, Qt.SolidLine)
qp.setPen(pen)
x1, y1 = (0, 0)
for n in range(len(self.ceilingPlotX)):
x = self.ceilingPlotX[n]
y = self.ceilingPlotY[tc][n]
qp.drawLine(x1, y1, x, y)
x1 = x
y1 = y
# redraw the ceiling margin
def drawCeilingMargin(self, qp):
if not self.plan.profileSampled :
return
profileSampled = self.plan.profileSampled
x1, y1 = (0, 0)
x2 = 0
mError = False
status = 'ok'
zeroLevel = self.plot_height * 0.75
for point in profileSampled:
margin = point.depth - point.modelpoint.leadCeilingMeters
if margin < 0:
qp.setPen(QPen(Qt.red,2, Qt.SolidLine))
mError = True
status = 'ERROR!'
else:
qp.setPen(QPen(Qt.darkGreen, 1, Qt.SolidLine))
x = (point.time / self.totalTime) * self.plot_width
y = zeroLevel - (margin / self.depthMax * self.plot_height * 0.5)
if point.time >= self.plan.ascentBegins:
qp.drawLine(x1, y1, x, y)
else:
x2 = x
x1, y1 = x, y
qp.setPen(QPen(Qt.black, 1, Qt.DashLine))
qp.drawLine(x2, zeroLevel, self.plot_width, zeroLevel)
if mError:
qp.setPen(QPen(Qt.red, 1, Qt.DashLine))
qp.drawText(x2+20, zeroLevel-1, 'ceiling margin {}'.format(status))
# redraw the TC curves plot
def drawTC(self, qp):
if not self.TC :
return
size = self.size()
plot_width = size.width() -50
plot_height = size.height() -20
samples = len(self.TC[0])
maxPressure = max(self.maxTC) # biggest value we will plot
step = plot_width / samples
for tc in range(len(self.TC)):
color = QColor(255-(tc*15), tc*15, tc*15)
pen = QPen(color, 1, Qt.SolidLine)
qp.setPen(pen)
x1, y1 = (0, 0)
for index in range(samples):
x = index * step
y = (self.TC[tc][index] / maxPressure) * plot_height
qp.drawLine(x1, y1, x, y)
x1 = x
y1 = y
def drawDepthGrid(self, qp):
qp.setPen(Qt.darkRed)
# depth lines at 5 meter intervals
for dd in range(0, int(self.depthMax), 5):
y = int((dd / self.depthMax) * self.plot_height)
qp.drawLine(0, y, self.plot_width, y)
ltext = '{:d} m'.format(dd)
qp.drawText(self.plot_width + 5, y + 5, ltext)
# ticks at 1 meter intervals
for dd in range(0, int(self.depthMax), 1):
y = int((dd / self.depthMax) * self.plot_height)
qp.drawLine(self.plot_width - 5, y, self.plot_width + 4, y)
def drawTimeGrid(self, qp):
# time lines at 5 minute intervals
qp.setPen(Qt.darkGreen)
for tt in range(0, int(self.totalTime), 5 * 60):
x = int((tt / self.totalTime) * self.plot_width)
qp.drawLine(x, 0, x, self.plot_height)
ltext = '{:d}'.format(tt // 60)
qp.drawText(x, self.plot_height + 10, ltext)
# time ticks at 1 minute intervals
qp.setPen(Qt.darkGreen)
for tt in range(0, int(self.totalTime), 60):
x = int((tt / self.totalTime) * self.plot_width)
qp.drawLine(x, self.plot_height - 5, x, self.plot_height + 5)
pass
def drawTanks(self, qp):
for tankKey in self.plan.tankList.keys():
qp.setPen(Qt.black)
tank = self.plan.tankList[tankKey]
if tank.use == False:
continue
x1 = tank.useFromTime / self.totalTime *self.plot_width
x2 = tank.useUntilTime / self.totalTime *self.plot_width
yTxt = tank.changeDepth / self.depthMax * self.plot_height
bgPath = QPainterPath()
bgPath.moveTo(x1, self.plot_height+10)
bgPath.lineTo(x1, self.plot_height+20)
bgPath.lineTo(x2, self.plot_height+20)
bgPath.lineTo(x2, self.plot_height+10)
bgPath.closeSubpath()
gradient = QLinearGradient(0, 0, 0, 100)
gradient.setColorAt(0.0, tank.color)
gradient.setColorAt(1.0, tank.color)
qp.setBrush(QBrush(gradient))
qp.drawPath(bgPath)
text = '{} ({}/{})'.format(tank.name, tank.o2, tank.he)
text2 = '{:.0f} m {:.0f} min'.format(tank.changeDepth, tank.useFromTime/60.0)
qp.drawText(x1+3, self.plot_height+20, text)
qp.drawText(x1+3, yTxt + 10, text)
qp.drawText(x1+3, yTxt + 20, text2)
qp.setPen(QPen(Qt.black, 1, Qt.DotLine))
if x1 != 0 :
qp.drawLine(x1, self.plot_height, x1, yTxt)
qp.drawLine(x1, yTxt, self.plot_width, yTxt)
def drawTankPressure(self, qp):
# draw the tank pressure
previousTank = None
lastPressure = None
x1 = 0
y1 = (1.0 - self.plan.profileSampled[0].currentTankPressure / 300.0) * self.plot_height
for point in self.plan.profileSampled:
thisTank = point.tank
x = (point.time / self.totalTime) * self.plot_width
y = (1.0 - point.currentTankPressure / 300.0) * self.plot_height
if thisTank != previousTank:
if lastPressure :
qp.drawText(x -5,y1, '{:.0f}'.format(lastPressure))
qp.setPen(QPen(thisTank.color, 2, Qt.SolidLine))
qp.drawText(x + 2, y, '{:.0f}'.format(point.currentTankPressure))
y1 = y
qp.drawLine(x1, y1, x, y)
x1, y1 = x, y
previousTank = thisTank
lastPressure = point.currentTankPressure
qp.drawText(x + 10, y, '{:.0f}'.format(lastPressure))
##############################################################################################
class PlotTissuesWidget(QWidget):
def __init__(self, plan=None):
super().__init__()
self.plan = plan
self.initUI()
# initialize the window
def initUI(self):
self.qp = QPainter()
self.show()
def setPlan(self, plan):
self.plan = plan
# when any event occurs, like resize, we also redraw the plot
def paintEvent(self, e):
self.qp.begin(self)
self.drawSize(self.qp)
self.drawDepthGrey(self.qp)
self.drawTC(self.qp)
self.qp.end()
def drawSize(self, qp):
size = self.size()
self.plot_width = size.width() -50
self.plot_height = size.height() -20
def drawTC(self, qp):
if not self.plan.model :
return
# now draw the tissue compartment pressures one by one for N2
maxN2press = self.plan.maxTCnitrogen
zeroLevel = self.plot_height / 2.0 + 10
for tc in range(ModelPoint.COMPS):
color = colors[tc]
#color = QColor(tc*15, 15+(tc*15), 255-tc*15)
qp.setPen(QPen(color, 1, Qt.SolidLine))
x1, y1 = (0, 0)
for n, point in enumerate( self.plan.profileSampled):
x = (point.time / self.totalTime) * self.plot_width
#x = (n / len(self.plan.model)) * self.plot_width
pressure = point.modelpoint.tissues[tc].nitrogenPressure
y = zeroLevel - ( (pressure / maxN2press) * (self.plot_height /2.0))
qp.drawLine(x1, y1, x, y)
x1 = x
y1 = y
qp.setPen(QPen(Qt.black, 1, Qt.DashLine))
qp.drawText(10, 10, 'Nitrogen tissue compartment pressures')
# draw gridlines
pLine= 0.0
while pLine < maxN2press:
lineLevel = zeroLevel - (self.plot_height/2.0 * (pLine / maxN2press))
qp.drawLine(0, lineLevel, self.plot_width, lineLevel)
qp.drawText(self.plot_width + 5, lineLevel, '{:.1f}'.format(pLine))
pLine += 0.5
# draw ticks
qp.setPen(QPen(Qt.darkGray, 1, Qt.SolidLine))
dd = 0.0
while dd < maxN2press:
y = zeroLevel - (self.plot_height/2.0 * (dd / maxN2press))
qp.drawLine(self.plot_width - 5, y, self.plot_width + 4, y)
dd += 0.1
# Helium TC's next
heScale = 2.2
maxHEpress = self.plan.maxTChelium
if maxHEpress == 0:
qp.drawText(10, self.plot_height, 'NO HELIUM USED')
return # there is no helium
zeroLevel = self.plot_height
for tc in range(ModelPoint.COMPS):
color = colors[tc]
#color = QColor(255-(tc*10), tc*10, tc*10)
qp.setPen(QPen(color, 1, Qt.SolidLine))
x1, y1 = (0, 0)
for n, point in enumerate(self.plan.profileSampled):
x = (point.time / self.totalTime) * self.plot_width
#x = (n / len(self.plan.model)) * self.plot_width
pressure = point.modelpoint.tissues[tc].heliumPressure
y = zeroLevel - ( (pressure / maxHEpress) * (self.plot_height/heScale))
qp.drawLine(x1, y1, x, y)
x1 = x
y1 = y
qp.setPen(QPen(Qt.darkGreen, 1, Qt.DashLine))
qp.drawLine(0, zeroLevel, self.plot_width, zeroLevel)
qp.drawText(0, zeroLevel+10, 'Helium tissue compartment pressures')
# draw gridlines
pLine= 0.0
while pLine < maxHEpress:
lineLevel = zeroLevel - (self.plot_height/heScale * (pLine / maxHEpress))
qp.drawLine(0, lineLevel, self.plot_width, lineLevel)
qp.drawText(self.plot_width + 10, lineLevel, '{:.1f}'.format(pLine))
pLine += 0.5
# draw ticks
qp.setPen(QPen(Qt.darkGreen, 1, Qt.SolidLine))
dd = 0.0
while dd < maxHEpress:
y = zeroLevel - (self.plot_height/heScale * (dd / maxHEpress))
qp.drawLine(self.plot_width +5, y, self.plot_width + 9, y)
dd += 0.1
def drawPressureGrid(self, qp, max, zeroLevel):
qp.setPen(Qt.darkRed)
# pressure lines
for pLevel in range(max):
y = int((pLevel / self.depthMax) * self.plot_height)
qp.drawLine(0, y, self.plot_width, y)
ltext = '{:d} m'.format(pLevel)
qp.drawText(self.plot_width + 10, y + 5, ltext)
# ticks at 1 meter intervals
for dd in range(0, int(self.depthMax), 1):
y = int((dd / self.depthMax) * self.plot_height)
qp.drawLine(self.plot_width + 4, y, self.plot_width + 9, y)
def drawDepthGrey(self, qp):
if not self.plan.profileSampled :
return
self.totalTime = self.plan.profileSampled[-1].time
self.depthMax = self.plan.maxDepth
# now we plot the DEPTH profile
depthPath = QPainterPath()
depthPath.moveTo(0.0, 0.0)
for n, point in enumerate( self.plan.profileSampled):
x = (point.time / self.totalTime ) * self.plot_width
y = (point.depth / self.depthMax) * self.plot_height
depthPath.lineTo(x, y)
depthPath.lineTo(self.plot_width, 0.0)
depthPath.lineTo(0.0, 0.0)
depthPath.closeSubpath()
qp.setBrush(QColor(240,240,240))
qp.drawPath(depthPath)
class PlotPressureGraphWidget(QWidget):
def __init__(self, plan=None):
super().__init__()
self.plan = plan
self.initUI()
def initUI(self):
self.qp = QPainter()
self.show()
def setPlan(self, plan):
self.plan = plan
def paintEvent(self, e):
self.qp.begin(self)
self.drawSize(self.qp)
self.drawPG(self.qp, self.plan.PGplot)
self.drawMvalueLines(self.qp, self.plan.PGplot, self.plan.GFhigh, self.plan.GFlow)
#self.drawMV(self.qp)
self.qp.end()
def drawSize(self, qp):
size = self.size()
self.plot_width = size.width()
self.plot_height = size.height()
def drawPG(self, qp, plot ='Total'):
if not self.plan.model :
return
scaler = 5.0
offset = -1.0
qp.setPen(QPen(Qt.darkCyan, 2, Qt.DashLine))
qp.drawLine(0, self.plot_height , self.plot_width, 0)
# do x y plot on ambient vs tissue pressures
for tc in range(ModelPoint.COMPS):
color = colors[tc]
qp.setPen(QPen(color, 2, Qt.SolidLine))
qp.drawText(5, 40 + tc * 10, 'TC {}'.format(tc))
x1, y1 = (0, self.plot_height)
for n, mPoint in enumerate( self.plan.model ):
#x = (((mPoint.ambient + offset) / scaler) * self.plot_width)
x = scaleToX(mPoint.ambient, scaler, offset, self.plot_width)
if plot=='Total':
qp.drawText(5, 10 , 'Nitrogen + Helium Pressure plot')
TCpressure = mPoint.tissues[tc].nitrogenPressure \
+ mPoint.tissues[tc].heliumPressure
elif plot=='Nitrogen':
qp.drawText(5, 10 , 'Nitrogen Pressure plot')
TCpressure = mPoint.tissues[tc].nitrogenPressure
elif plot == 'Helium':
qp.drawText(5, 10 , 'Helium Pressure plot')
TCpressure = mPoint.tissues[tc].heliumPressure
else:
break
#y = self.plot_height - (((TCpressure +offset) / scaler) * self.plot_height)
y = scaleToY(TCpressure, scaler, offset, self.plot_height)
qp.drawLine(x1, y1, x, y)
x1, y1 = x, y
def drawMvalueLines(self, qp, plot ='Total', ghHigh = 1.0, gfLow = 1.0):
scaler = 5.0
offset = -1.0
qp.drawText(5, 20, 'GF high = {}, GFlow = {}'.format(ghHigh, gfLow))
for tc in range(ModelPoint.COMPS):
color = colors[tc]
qp.setPen(QPen(color, 1, Qt.SolidLine))
if plot == 'Total':
break
elif plot=='Nitrogen':
a = self.plan.modelUsed[tc].NitrogenA
b = self.plan.modelUsed[tc].NitrogenB
elif plot == 'Helium':
a = self.plan.modelUsed[tc].HeliumA
b = self.plan.modelUsed[tc].HeliumB
x1 = 0
y1 = scaleToY( 1.0/b +a , scaler, offset, self.plot_height)
x2 = scaleToX( (6.0-a) *b, scaler, offset, self.plot_width)
y2 = scaleToY( 6.0 , scaler, offset, self.plot_height)
qp.drawLine( x2, y2, x1, y1)
def drawMV(self, qp):
if not self.plan.model :
return
scaler = 5.0
#qp.setPen(QPen(Qt.darkCyan, 2, Qt.DashLine))
#qp.drawLine(0, self.plot_height , self.plot_width, 0)
# do x y plot on ambient vs tissue pressures
for tc in range(ModelPoint.COMPS):
color = colors[tc]
qp.setPen(QPen(color, 1, Qt.DotLine))
x1, y1 = (0, self.plot_height)
for n, mPoint in enumerate( self.plan.model ):
x = (((mPoint.ambient -0.5) / scaler) * self.plot_width)
mValue = mPoint.tissues[tc].mv
y = self.plot_height - (((mValue-0.5) / scaler) * self.plot_height)
qp.drawLine(x1, y1, x, y)
x1 = x
y1 = y
def scaleToX(input, scaler, offset, plot_width):
return ((input + offset) / scaler) * plot_width
def scaleToY(input, scaler, offset, plot_height):
return plot_height - (((input +offset) / scaler) * plot_height)