81
81
QColorDialog, QFrame, QCheckBox,QStatusBar, QProgressDialog, # @Reimport
82
82
QStyleFactory, QTableWidget, QTableWidgetItem, QMenu, QDoubleSpinBox,QButtonGroup) # @Reimport
83
83
from PyQt5.QtGui import (QImageReader, QWindow, # @Reimport
84
- QKeySequence,QStandardItem,QImage,QPixmap,QColor,QPalette,QDesktopServices,QIcon, # @Reimport
84
+ QKeySequence,QStandardItem, #QImage,
85
+ QPixmap,QColor,QPalette,QDesktopServices,QIcon, # @Reimport
85
86
QRegExpValidator,QDoubleValidator, QIntValidator,QPainter, QFont,QBrush, QRadialGradient,QCursor,QTextDocument) # @Reimport
86
87
from PyQt5.QtPrintSupport import (QPrinter,QPrintDialog) # @Reimport
87
88
from PyQt5.QtCore import (QLibraryInfo, QTranslator, QLocale, QFileInfo, PYQT_VERSION_STR, pyqtSignal, # @Reimport
@@ -1858,11 +1859,10 @@ def doUpdate(self):
1858
1859
self.resetlines() # get rid of HUD, projection, cross lines and AUC line
1859
1860
self.resetdeltalines() # just in case
1860
1861
1861
- # ask the canvas to kindly draw it self some time in the future
1862
- # when Qt thinks it is convenient
1862
+
1863
1863
try:
1864
1864
self.fig.canvas.draw() # the triggered _draw_event(self,evt) function resets the self.in_draw_event if done
1865
- #self.fig.canvas.draw_idle()
1865
+ #self.fig.canvas.draw_idle() # ask the canvas to kindly draw it self some time in the future when Qt thinks it is convenient
1866
1866
# make sure that the GUI framework has a chance to run its event loop
1867
1867
# and clear any GUI events. This needs to be in a try/except block
1868
1868
# because the default implemenation of this method is to raise
@@ -2428,7 +2428,6 @@ def updategraphics(self):
2428
2428
self.markCharge() # we do not reset the autoChargeIdx to avoid another trigger
2429
2429
self.autoChargeIdx = 0
2430
2430
2431
-
2432
2431
##### updated canvas
2433
2432
try:
2434
2433
if not self.block_update:
@@ -2496,8 +2495,9 @@ def updategraphics(self):
2496
2495
aw.qmc.playbackevent()
2497
2496
if aw.qmc.backgroundPlaybackDROP:
2498
2497
aw.qmc.playbackdrop()
2499
- except Exception:
2500
- pass
2498
+ except Exception as e:
2499
+ _, _, exc_tb = sys.exc_info()
2500
+ aw.qmc.adderror((QApplication.translate("Error Message","Exception:",None) + " updategraphics() {0}").format(str(e)),exc_tb.tb_lineno)
2501
2501
2502
2502
#####
2503
2503
if aw.qmc.patheffects:
@@ -2593,17 +2593,18 @@ def toggleHUD(self):
2593
2593
2594
2594
#ON
2595
2595
else:
2596
+ self.redraw(False,False)
2596
2597
#load
2597
2598
img = self.grab()
2598
2599
aw.HUD.setPixmap(img)
2599
-
2600
2600
self.HUDflag = True
2601
2601
aw.button_18.setStyleSheet("QPushButton { background-color: #60ffed }")
2602
2602
aw.stack.setCurrentIndex(1)
2603
2603
aw.sendmessage(QApplication.translate("Message","HUD ON", None))
2604
2604
2605
2605
def refreshHUD(self):
2606
2606
aw.stack.setCurrentIndex(0)
2607
+ self.redraw(False,False)
2607
2608
img = self.grab()
2608
2609
aw.HUD.setPixmap(img)
2609
2610
aw.stack.setCurrentIndex(1)
@@ -10437,12 +10438,12 @@ def sample(self):
10437
10438
if aw.qmc.smooth_curves_on_recording:
10438
10439
aw.qmc.l_temp1.set_data(aw.qmc.ctimex1, aw.qmc.stemp1)
10439
10440
else:
10440
- aw.qmc.l_temp1.set_data(aw.qmc.ctimex1, aw.qmc.temp1 )
10441
+ aw.qmc.l_temp1.set_data(aw.qmc.ctimex1, aw.qmc.ctemp1 )
10441
10442
if aw.qmc.BTcurve:
10442
10443
if aw.qmc.smooth_curves_on_recording:
10443
10444
aw.qmc.l_temp2.set_data(aw.qmc.ctimex2, aw.qmc.stemp2)
10444
10445
else:
10445
- aw.qmc.l_temp2.set_data(aw.qmc.ctimex2, aw.qmc.temp2 )
10446
+ aw.qmc.l_temp2.set_data(aw.qmc.ctimex2, aw.qmc.ctemp2 )
10446
10447
10447
10448
10448
10449
@@ -24988,7 +24989,7 @@ def showHUDmetrics(self):
24988
24989
if self.qmc.hudresizeflag:
24989
24990
self.qmc.refreshHUD()
24990
24991
self.qmc.hudresizeflag = False
24991
- elif len(self.qmc.temp2) > 1: #Need this because viewProjections use rate of change (two values needed)
24992
+ if len(self.qmc.temp2) > 1: #Need this because viewProjections use rate of change (two values needed)
24992
24993
ETreachTime,BTreachTime,ET2reachTime,BT2reachTime = self.qmc.getTargetTime()
24993
24994
if ETreachTime > 0 and ETreachTime < 2000:
24994
24995
text1 = u(QApplication.translate("Label","{0} to reach ET {1}", None).format(self.qmc.stringfromseconds(int(ETreachTime)),str(self.qmc.ETtarget) + self.qmc.mode))
@@ -25049,23 +25050,16 @@ def showHUDmetrics(self):
25049
25050
MVV = int(round(MV))
25050
25051
pidstring = "ET pid = %i "%MVV
25051
25052
##### end of ET pid
25052
- # QImage.Format_RGB32, QImage.Format_ARGB32
25053
+ # # QImage.Format_RGB32, QImage.Format_ARGB32
25053
25054
# w = self.qmc.size().width()*self.devicePixelRatio()
25054
25055
# h = self.qmc.size().height()*self.devicePixelRatio()
25055
25056
# qImage = QImage(self.qmc.fig.canvas.buffer_rgba(), w, h, QImage.Format_ARGB32_Premultiplied).rgbSwapped()
25056
25057
# if hasattr(qImage, 'setDevicePixelRatio'):
25057
- # qImage.setDevicePixelRatio(self.qmc.fig.canvas._dpi_ratio)
25058
-
25059
- buf = self.qmc.fig.canvas.buffer_rgba()
25060
- buf = bytearray(buf).copy()
25061
- w = self.qmc.fig.canvas.size().width()*self.qmc.fig.canvas._dpi_ratio
25062
- h = self.qmc.fig.canvas.size().height()*self.qmc.fig.canvas._dpi_ratio
25063
- qImage = QImage(buf,w, h, QImage.Format_ARGB32_Premultiplied)
25064
- if hasattr(qImage, 'setDevicePixelRatio'):
25065
- qImage.setDevicePixelRatio(self.qmc.fig.canvas._dpi_ratio)
25066
- qImage = qImage.rgbSwapped()
25067
-
25068
- img = QPixmap.fromImage(qImage)
25058
+ # qImage.setDevicePixelRatio(self.qmc.fig.canvas._dpi_ratio)
25059
+ # img = QPixmap.fromImage(qImage)
25060
+
25061
+ img = self.qmc.grab()
25062
+
25069
25063
Wwidth = self.qmc.size().width()
25070
25064
Wheight = self.qmc.size().height()
25071
25065
#Draw begins
@@ -25090,51 +25084,49 @@ def showHUDmetrics(self):
25090
25084
25091
25085
def showHUDthermal(self):
25092
25086
if self.qmc.hudresizeflag:
25093
- #turn off
25094
- self.qmc.toggleHUD()
25095
- #turn back ON to adquire new size
25096
- self.qmc.toggleHUD()
25087
+ self.qmc.refreshHUD()
25097
25088
self.qmc.hudresizeflag = False
25098
- img = self.qmc.grab()
25099
- p = QPainter(img)
25100
- Wwidth= self.qmc.size().width()
25101
- Wheight = self.qmc.size().height()
25102
- p.setOpacity(1)
25103
- p.setPen(QColor(96,255,237)) #color the rectangle the same as HUD button
25104
- p.drawRect(10,10, Wwidth - 20, Wheight - 20)
25105
- if self.qmc.mode == "F" and self.qmc.temp1:
25106
- ETradius = int(self.qmc.temp1[-1]/3)
25107
- BTradius = int(self.qmc.temp2[-1]/3)
25108
- elif self.qmc.mode == "C" and self.qmc.temp1:
25109
- ETradius = int(self.qmc.fromCtoF(self.qmc.temp1[-1]/3))
25110
- BTradius = int(self.qmc.fromCtoF(self.qmc.temp2[-1]/3))
25111
- else:
25112
- ETradius = 50
25113
- BTradius = 50
25114
- Tradius = 300
25115
- p.setOpacity(0.5)
25116
- g = QRadialGradient(Wwidth/2, Wheight/2, ETradius)
25117
- beanbright = 100 - ETradius
25118
- if beanbright < 0: beanbright = 0
25119
- g.setColorAt(0.0, QColor(240,255,beanbright)) #bean center
25120
- g.setColorAt(.5, Qt.yellow)
25121
- g.setColorAt(.8, Qt.red)
25122
- g.setColorAt(1.,QColor("lightgrey"))
25123
- p.setBrush(QBrush(g))
25124
- #draw thermal circle
25125
- p.setPen(0)
25126
- p.drawEllipse(Wwidth/2 -Tradius/2 , Wheight/2 - Tradius/2 , Tradius,Tradius)
25127
- #draw ET circle
25128
- p.setBrush(0)
25129
- p.setPen(QColor("black"))
25130
- p.drawEllipse(Wwidth/2 -ETradius/2 , Wheight/2 - ETradius/2 , ETradius,ETradius)
25131
- #draw BT circle
25132
- p.drawEllipse(Wwidth/2 -BTradius/2 , Wheight/2 - BTradius/2 , BTradius,BTradius)
25133
- delta = QApplication.translate("Label","ET - BT = {0}{1}", None).format("%.1f"%(self.qmc.temp1[-1] - self.qmc.temp2[-1]),self.qmc.mode)
25134
- p.setFont(QFont('Utopia', 14, -1))
25135
- p.drawText(QPoint(Wwidth/2,Wheight/2),u(delta))
25136
- p.end()
25137
- self.HUD.setPixmap(img)
25089
+ if len(self.qmc.temp2) > 0:
25090
+ img = self.qmc.grab()
25091
+ p = QPainter(img)
25092
+ Wwidth= self.qmc.size().width()
25093
+ Wheight = self.qmc.size().height()
25094
+ p.setOpacity(1)
25095
+ p.setPen(QColor(96,255,237)) #color the rectangle the same as HUD button
25096
+ p.drawRect(10,10, Wwidth - 20, Wheight - 20)
25097
+ if self.qmc.mode == "F" and self.qmc.temp1:
25098
+ ETradius = int(self.qmc.temp1[-1]/3)
25099
+ BTradius = int(self.qmc.temp2[-1]/3)
25100
+ elif self.qmc.mode == "C" and self.qmc.temp1:
25101
+ ETradius = int(self.qmc.fromCtoF(self.qmc.temp1[-1]/3))
25102
+ BTradius = int(self.qmc.fromCtoF(self.qmc.temp2[-1]/3))
25103
+ else:
25104
+ ETradius = 50
25105
+ BTradius = 50
25106
+ Tradius = 300
25107
+ p.setOpacity(0.5)
25108
+ g = QRadialGradient(Wwidth/2, Wheight/2, ETradius)
25109
+ beanbright = 100 - ETradius
25110
+ if beanbright < 0: beanbright = 0
25111
+ g.setColorAt(0.0, QColor(240,255,beanbright)) #bean center
25112
+ g.setColorAt(.5, Qt.yellow)
25113
+ g.setColorAt(.8, Qt.red)
25114
+ g.setColorAt(1.,QColor("lightgrey"))
25115
+ p.setBrush(QBrush(g))
25116
+ #draw thermal circle
25117
+ p.setPen(0)
25118
+ p.drawEllipse(Wwidth/2 -Tradius/2 , Wheight/2 - Tradius/2 , Tradius,Tradius)
25119
+ #draw ET circle
25120
+ p.setBrush(0)
25121
+ p.setPen(QColor("black"))
25122
+ p.drawEllipse(Wwidth/2 -ETradius/2 , Wheight/2 - ETradius/2 , ETradius,ETradius)
25123
+ #draw BT circle
25124
+ p.drawEllipse(Wwidth/2 -BTradius/2 , Wheight/2 - BTradius/2 , BTradius,BTradius)
25125
+ delta = QApplication.translate("Label","ET - BT = {0}{1}", None).format("%.1f"%(self.qmc.temp1[-1] - self.qmc.temp2[-1]),self.qmc.mode)
25126
+ p.setFont(QFont('Utopia', 14, -1))
25127
+ p.drawText(QPoint(Wwidth/2,Wheight/2),u(delta))
25128
+ p.end()
25129
+ self.HUD.setPixmap(img)
25138
25130
25139
25131
#used by WheelGraphDlg()
25140
25132
#wrap values in unicode(.) if and only if those are of type string
0 commit comments