From cec8dae44aeb27b2063c6c7f73331ef0ab5664b2 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Fri, 29 Apr 2022 18:49:53 -0500 Subject: [PATCH 1/4] Freezing plot image during GUI load to avoid unecessary calls to openmc.lib.id_map. --- openmc_plotter/main_window.py | 5 ++++- openmc_plotter/plotgui.py | 3 +++ openmc_plotter/plotmodel.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/openmc_plotter/main_window.py b/openmc_plotter/main_window.py index 3432a04..8c1b0f3 100755 --- a/openmc_plotter/main_window.py +++ b/openmc_plotter/main_window.py @@ -67,6 +67,7 @@ def loadGui(self, use_settings_pkl=True): # Create plot image self.plotIm = PlotImage(self.model, self.frame, self) + self.plotIm.frozen = True self.frame.setWidget(self.plotIm) # Dock @@ -111,9 +112,11 @@ def loadGui(self, use_settings_pkl=True): self.statusBar().showMessage('') # Timer allows GUI to render before plot finishes loading - QtCore.QTimer.singleShot(0, self.plotIm.generatePixmap) + # QtCore.QTimer.singleShot(0, self.plotIm.generatePixmap) QtCore.QTimer.singleShot(0, self.showCurrentView) + self.plotIm.frozen = False + def event(self, event): # use pinch event to update zoom if isinstance(event, QGestureEvent): diff --git a/openmc_plotter/plotgui.py b/openmc_plotter/plotgui.py index f0617c5..64ad02e 100644 --- a/openmc_plotter/plotgui.py +++ b/openmc_plotter/plotgui.py @@ -437,6 +437,9 @@ def contextMenuEvent(self, event): self.menu.exec_(event.globalPos()) def generatePixmap(self, update=False): + if self.frozen: + return + self.model.generatePlot() if update: self.updatePixmap() diff --git a/openmc_plotter/plotmodel.py b/openmc_plotter/plotmodel.py index adc7121..39e6618 100644 --- a/openmc_plotter/plotmodel.py +++ b/openmc_plotter/plotmodel.py @@ -3,6 +3,7 @@ import copy import itertools import threading +import traceback from PySide2.QtWidgets import QItemDelegate, QColorDialog, QLineEdit, QMessageBox from PySide2.QtCore import QAbstractTableModel, QModelIndex, Qt, QSize, QEvent @@ -184,7 +185,6 @@ def resetColors(self): def generatePlot(self): """ Spawn thread from which to generate new plot image """ - t = threading.Thread(target=self.makePlot) t.start() t.join() From 21b7e78c70244a1e7cc8c0fcf7ba331bf13536ce Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Fri, 29 Apr 2022 19:19:29 -0500 Subject: [PATCH 2/4] Removing early call to generatePixmap --- openmc_plotter/main_window.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openmc_plotter/main_window.py b/openmc_plotter/main_window.py index 8c1b0f3..eb5e0a8 100755 --- a/openmc_plotter/main_window.py +++ b/openmc_plotter/main_window.py @@ -112,7 +112,6 @@ def loadGui(self, use_settings_pkl=True): self.statusBar().showMessage('') # Timer allows GUI to render before plot finishes loading - # QtCore.QTimer.singleShot(0, self.plotIm.generatePixmap) QtCore.QTimer.singleShot(0, self.showCurrentView) self.plotIm.frozen = False From 18de91483e1ebe1981046978555b621df4a59fe8 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Fri, 29 Apr 2022 19:24:22 -0500 Subject: [PATCH 3/4] Adding frozen attr to PlotImage constructor --- openmc_plotter/plotgui.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openmc_plotter/plotgui.py b/openmc_plotter/plotgui.py index 64ad02e..15da51d 100644 --- a/openmc_plotter/plotgui.py +++ b/openmc_plotter/plotgui.py @@ -37,6 +37,8 @@ def __init__(self, model, parent, main_window): self.main_window = main_window self.parent = parent + self.frozen = False + self.rubber_band = QRubberBand(QRubberBand.Rectangle, self) self.band_origin = QtCore.QPoint() self.x_plot_origin = None @@ -439,7 +441,7 @@ def contextMenuEvent(self, event): def generatePixmap(self, update=False): if self.frozen: return - + print('Calling gen plot') self.model.generatePlot() if update: self.updatePixmap() From 392b69ca206480285a9fa36ab20355fcab78a066 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Tue, 3 May 2022 16:36:27 -0500 Subject: [PATCH 4/4] Removing print statement and extra imported module --- openmc_plotter/plotgui.py | 2 +- openmc_plotter/plotmodel.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/openmc_plotter/plotgui.py b/openmc_plotter/plotgui.py index 15da51d..1f3c7ff 100644 --- a/openmc_plotter/plotgui.py +++ b/openmc_plotter/plotgui.py @@ -441,7 +441,7 @@ def contextMenuEvent(self, event): def generatePixmap(self, update=False): if self.frozen: return - print('Calling gen plot') + self.model.generatePlot() if update: self.updatePixmap() diff --git a/openmc_plotter/plotmodel.py b/openmc_plotter/plotmodel.py index 39e6618..5d5759f 100644 --- a/openmc_plotter/plotmodel.py +++ b/openmc_plotter/plotmodel.py @@ -3,7 +3,6 @@ import copy import itertools import threading -import traceback from PySide2.QtWidgets import QItemDelegate, QColorDialog, QLineEdit, QMessageBox from PySide2.QtCore import QAbstractTableModel, QModelIndex, Qt, QSize, QEvent