Skip to content

Commit cec8dae

Browse files
committed
Freezing plot image during GUI load to avoid unecessary calls to openmc.lib.id_map.
1 parent cfc56d6 commit cec8dae

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

openmc_plotter/main_window.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def loadGui(self, use_settings_pkl=True):
6767

6868
# Create plot image
6969
self.plotIm = PlotImage(self.model, self.frame, self)
70+
self.plotIm.frozen = True
7071
self.frame.setWidget(self.plotIm)
7172

7273
# Dock
@@ -111,9 +112,11 @@ def loadGui(self, use_settings_pkl=True):
111112
self.statusBar().showMessage('')
112113

113114
# Timer allows GUI to render before plot finishes loading
114-
QtCore.QTimer.singleShot(0, self.plotIm.generatePixmap)
115+
# QtCore.QTimer.singleShot(0, self.plotIm.generatePixmap)
115116
QtCore.QTimer.singleShot(0, self.showCurrentView)
116117

118+
self.plotIm.frozen = False
119+
117120
def event(self, event):
118121
# use pinch event to update zoom
119122
if isinstance(event, QGestureEvent):

openmc_plotter/plotgui.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ def contextMenuEvent(self, event):
437437
self.menu.exec_(event.globalPos())
438438

439439
def generatePixmap(self, update=False):
440+
if self.frozen:
441+
return
442+
440443
self.model.generatePlot()
441444
if update:
442445
self.updatePixmap()

openmc_plotter/plotmodel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import copy
44
import itertools
55
import threading
6+
import traceback
67

78
from PySide2.QtWidgets import QItemDelegate, QColorDialog, QLineEdit, QMessageBox
89
from PySide2.QtCore import QAbstractTableModel, QModelIndex, Qt, QSize, QEvent
@@ -184,7 +185,6 @@ def resetColors(self):
184185

185186
def generatePlot(self):
186187
""" Spawn thread from which to generate new plot image """
187-
188188
t = threading.Thread(target=self.makePlot)
189189
t.start()
190190
t.join()

0 commit comments

Comments
 (0)