From 6b4e5fba9bf3f265811665fc1391f5fcc97b755e Mon Sep 17 00:00:00 2001 From: "J.A. de Jong" Date: Wed, 3 Oct 2018 17:02:13 +0200 Subject: [PATCH] Figure size can be changed using GUI, added immature possibility for plot presets. Figures now have right font. PlotOptions becomes dataclass. Show sensitivity values in measurement info box. --- lasp/CMakeLists.txt | 3 ++- lasp/plot/bar.py | 17 ++++++++++------- lasp/tools/report_tools.py | 1 - 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lasp/CMakeLists.txt b/lasp/CMakeLists.txt index 8ce373e..16d8afc 100644 --- a/lasp/CMakeLists.txt +++ b/lasp/CMakeLists.txt @@ -21,7 +21,8 @@ include_directories( # ) set(ui_files ui_apsrtsettings ui_mainwindow ui_figure ui_about -ui_apswidget ui_revtimewidget ui_slmwidget ui_daqwidget ui_apssettings) +ui_apswidget ui_revtimewidget ui_slmwidget ui_daqwidget ui_apssettings +ui_figuredialog) foreach(fn ${ui_files}) add_custom_command( OUTPUT "${fn}.py" diff --git a/lasp/plot/bar.py b/lasp/plot/bar.py index a440e7f..a06643d 100644 --- a/lasp/plot/bar.py +++ b/lasp/plot/bar.py @@ -14,7 +14,6 @@ from PySide.QtGui import ( QGraphicsTextItem, QPainter, QImage, QPrinter ) -# from PySide.QtOpenGL import from PySide.QtCore import Qt, QRectF, QLineF, QSize, QRect, QPointF, QSizeF import numpy as np import os @@ -37,6 +36,10 @@ DEFAULT_COLORS = [ASCEEColors.blue, ASCEEColors.green, Qt.red, Qt.cyan, Qt.darkYellow, Qt.darkMagenta] +def graphicsTextItem(label): + item = QGraphicsTextItem(label) + item.setFont(Branding.figureFont()) + return item class BarScene(QGraphicsScene): """ @@ -112,7 +115,7 @@ class BarScene(QGraphicsScene): range_ = ylim[1]-ylim[0] ytickval = i/(nyticks-1)*range_ + ylim[0] yticklabel = f'{ytickval:.0f}' - txt = QGraphicsTextItem(yticklabel) + txt =graphicsTextItem(yticklabel) txtwidth = txt.boundingRect().width() txtmaxwidth = max(txtmaxwidth, txtwidth) txt.setPos(leftoffset-10-txtwidth, @@ -138,7 +141,7 @@ class BarScene(QGraphicsScene): xticklabels = [] for n in range(N): xticklabel = f'{xvals[n]}' - txt = QGraphicsTextItem(xticklabel) + txt = graphicsTextItem(xticklabel) txtxpos = self.getBarGroupMidPos(n)-12 txt.setPos(txtxpos, self.ysize-bottomoffset+xticklabeloffset) @@ -148,7 +151,7 @@ class BarScene(QGraphicsScene): # Set xlabel if xlabel is not None: - xlabel = QGraphicsTextItem(xlabel) + xlabel = graphicsTextItem(xlabel) width = xlabel.boundingRect().width() txtxpos = xsize/2-width/2 txtypos = ysize - xlabelbottomoffset @@ -157,7 +160,7 @@ class BarScene(QGraphicsScene): # # Set ylabel if ylabel is not None: - ylabel = QGraphicsTextItem(ylabel) + ylabel = graphicsTextItem(ylabel) ylabel.setPos(ylabelleftoffset, (ysize-topoffset-bottomoffset)/2+topoffset) ylabel.rotate(-90) @@ -165,7 +168,7 @@ class BarScene(QGraphicsScene): # Set title if title is not None: - title = QGraphicsTextItem(title) + title = graphicsTextItem(title) width = xlabel.boundingRect().width() txtxpos = self.xsize/2-width/2 txtypos = (1-.998)*self.ysize @@ -200,7 +203,7 @@ class BarScene(QGraphicsScene): legrect = self.createRect(*pos, Lxlegrect, Lylegrect) legrect.setBrush(QBrush(color)) - legtxt = QGraphicsTextItem(leglabel) + legtxt = graphicsTextItem(leglabel) maxlegtxtwidth = max(maxlegtxtwidth, legtxt.boundingRect().width()) diff --git a/lasp/tools/report_tools.py b/lasp/tools/report_tools.py index 3e2776f..2e2bf10 100644 --- a/lasp/tools/report_tools.py +++ b/lasp/tools/report_tools.py @@ -19,7 +19,6 @@ import numpy as np import sys - def close(): import matplotlib.pyplot as plt plt.close('all')