Skip to content

Commit 9ae7a76

Browse files
committed
compare active and current views before updating current view to check if mapping needs to be called again
1 parent ebe5460 commit 9ae7a76

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

openmc_plotter/plotmodel.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ def hash_file(filename):
7171
chunk = file.read(32768)
7272
h.update(chunk)
7373
return h.hexdigest()
74+
75+
7476
class PlotModel():
7577
""" Geometry and plot settings for OpenMC Plot Explorer model
7678
@@ -272,15 +274,17 @@ def makePlot(self):
272274
Creates corresponding .xml files from user-chosen settings.
273275
Runs OpenMC in plot mode to generate new plot image.
274276
"""
277+
# update/call maps under 2 circumstances
278+
# 1. this is the intial plot (ids_map/properties are None)
279+
# 2. The active (desired) view differs from the current view parameters
280+
if (self.currentView.view_params != self.activeView.view_params) or \
281+
(self.ids_map is None) or (self.properties is None):
282+
# get ids from the active (desired) view
283+
self.ids_map = openmc.lib.id_map(self.activeView.view_params)
284+
self.properties = openmc.lib.property_map(self.activeView.view_params)
285+
286+
# update current view
275287
cv = self.currentView = copy.deepcopy(self.activeView)
276-
pv = self.previousViews[-1]
277-
278-
if (self.properties is None) or (self.ids_map is None) or \
279-
(cv.view_params != pv.view_params):
280-
# we are at the first view and need to populate OR
281-
# view has changed and need to populate
282-
self.ids_map = openmc.lib.id_map(cv.view_params)
283-
self.properties = openmc.lib.property_map(cv.view_params)
284288

285289
# set model ids based on domain
286290
if cv.colorby == 'cell':

0 commit comments

Comments
 (0)