Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 8 additions & 4 deletions openmc_plotter/docks.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ def _createOptionsBox(self):
self.main_window.editPlotVisibility)

# Outlines
self.outlinesBox = QCheckBox(self)
self.outlinesBox.stateChanged.connect(self.main_window.toggleOutlines)
self.outlinesCellBox = QCheckBox(self)
self.outlinesCellBox.stateChanged.connect(self.main_window.toggleOutlinesCell)
self.outlinesMatBox = QCheckBox(self)
self.outlinesMatBox.stateChanged.connect(self.main_window.toggleOutlinesMat)

# Basis
self.basisBox = QComboBox(self)
Expand All @@ -247,7 +249,8 @@ def _createOptionsBox(self):
self.opLayout.addRow('Universe Level:', self.universeLevelBox)
self.opLayout.addRow('Plot alpha:', self.domainAlphaBox)
self.opLayout.addRow('Visible:', self.visibilityBox)
self.opLayout.addRow('Outlines:', self.outlinesBox)
self.opLayout.addRow('Cell Outlines:', self.outlinesCellBox)
self.opLayout.addRow('Material Outlines:', self.outlinesMatBox)
self.opLayout.addRow(self.colorOptionsButton)
self.opLayout.setLabelAlignment(QtCore.Qt.AlignLeft)
self.opLayout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
Expand Down Expand Up @@ -331,7 +334,8 @@ def updatePlotVisibility(self):
self.visibilityBox.setChecked(self.model.activeView.domainVisible)

def updateOutlines(self):
self.outlinesBox.setChecked(self.model.activeView.outlines)
self.outlinesCellBox.setChecked(self.model.activeView.outlinesCell)
self.outlinesMatBox.setChecked(self.model.activeView.outlinesMat)

def updateBasis(self):
self.basisBox.setCurrentText(self.model.activeView.basis)
Expand Down
20 changes: 16 additions & 4 deletions openmc_plotter/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def createMenuBar(self):
self.outlineAct.setToolTip('Display Cell/Material Boundaries')
self.outlineAct.setStatusTip('Toggle display of domain '
'outlines when enabled')
outline_connector = partial(self.toggleOutlines, apply=True)
outline_connector = partial(self.toggleOutlinesCell, apply=True)
self.outlineAct.toggled.connect(outline_connector)
self.editMenu.addAction(self.outlineAct)

Expand Down Expand Up @@ -444,7 +444,7 @@ def updateEditMenu(self):

self.maskingAction.setChecked(self.model.currentView.masking)
self.highlightingAct.setChecked(self.model.currentView.highlighting)
self.outlineAct.setChecked(self.model.currentView.outlines)
self.outlineAct.setChecked(self.model.currentView.outlinesCell)
self.overlapAct.setChecked(self.model.currentView.color_overlaps)

num_previous_views = len(self.model.previousViews)
Expand Down Expand Up @@ -549,6 +549,11 @@ def loadViewFile(self, filename):

if saved['version'] == self.model.version:
self.model.activeView = saved['current']
# Handle backward compatibility for outline attributes
if not hasattr(self.model.activeView, 'outlinesCell'):
self.model.activeView.outlinesCell = False
if not hasattr(self.model.activeView, 'outlinesMat'):
self.model.activeView.outlinesMat = False
self.dock.updateDock()
self.colorDialog.updateDialogValues()
self.applyChanges()
Expand Down Expand Up @@ -877,8 +882,15 @@ def editPlotAlpha(self, value):
def editPlotVisibility(self, value):
self.model.activeView.domainVisible = bool(value)

def toggleOutlines(self, value, apply=False):
self.model.activeView.outlines = bool(value)
def toggleOutlinesCell(self, value, apply=False):
self.model.activeView.outlinesCell = bool(value)
self.dock.updateOutlines()

if apply:
self.applyChanges()

def toggleOutlinesMat(self, value, apply=False):
self.model.activeView.outlinesMat = bool(value)
self.dock.updateOutlines()

if apply:
Expand Down
29 changes: 20 additions & 9 deletions openmc_plotter/plotgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,17 +705,28 @@ def plotSourceSites(self):
def add_outlines(self):
cv = self.model.currentView
# draw outlines as isocontours
if cv.outlines:
if cv.outlinesCell or cv.outlinesMat:
# set data extents for automatic reporting of pointer location
data_bounds = self.current_view_data_bounds()
levels = np.unique(self.model.ids)
self.contours = self.ax.contour(self.model.ids,
origin='upper',
colors='k',
linestyles='solid',
levels=levels,
extent=data_bounds,
algorithm='serial')
if cv.outlinesCell:
levels = np.unique(self.model.cell_ids)
self.ax.contour(self.model.cell_ids,
origin='upper',
colors='k',
linestyles='solid',
levels=levels,
extent=data_bounds,
algorithm='serial')
if cv.outlinesMat:
levels = np.unique(self.model.mat_ids)
self.ax.contour(self.model.mat_ids,
origin='upper',
colors='k',
linestyles='solid',
levels=levels,
extent=data_bounds,
algorithm='serial')


@staticmethod
def parseContoursLine(line):
Expand Down
18 changes: 15 additions & 3 deletions openmc_plotter/plotmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,10 @@ class PlotViewIndependent:
Alpha value of the geometry plot
plotVisibile : bool
Controls visibility of geometry
outlines: bool
Controls visibility of geometry outlines
outlinesCell : bool
Controls visibility of cell outlines
outlinesMat : bool
Controls visibility of material outlines
tallyDataColormap : str
Name of the colormap used for tally data
tallyDataVisible : bool
Expand Down Expand Up @@ -962,7 +964,8 @@ def __init__(self):
self.overlap_color = (255, 0, 0)
self.domainAlpha = 1.0
self.domainVisible = True
self.outlines = False
self.outlinesCell = False
self.outlinesMat = False
self.colormaps = {'temperature': 'Oranges', 'density': 'Greys'}
# set defaults for color dialog
self.data_minmax = {prop: (0.0, 0.0) for prop in _MODEL_PROPERTIES}
Expand All @@ -988,6 +991,15 @@ def __init__(self):
self.tallyContours = False
self.tallyContourLevels = ""

def __setstate__(self, state):
"""Handle backward compatibility when unpickling old views"""
self.__dict__.update(state)
# Add missing attributes from older versions
if not hasattr(self, 'outlinesCell'):
self.outlinesCell = False
if not hasattr(self, 'outlinesMat'):
self.outlinesMat = False

def getDataLimits(self):
return self.data_minmax

Expand Down