Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Freezing plot image during GUI load to avoid unecessary calls to open…
…mc.lib.id_map.
  • Loading branch information
pshriwise committed Apr 29, 2022
commit cec8dae44aeb27b2063c6c7f73331ef0ab5664b2
5 changes: 4 additions & 1 deletion openmc_plotter/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions openmc_plotter/plotgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion openmc_plotter/plotmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down