Skip to content

Commit

Permalink
Add checkbox for reversing colormap (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulromano authored Apr 25, 2024
1 parent 3c3e04c commit e93a120
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions openmc_plotter/docks.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,11 @@ def __init__(self, model, main_window, field, colormaps=None):
cmap_connector = partial(main_window.editTallyDataColormap)
self.colormapBox.currentTextChanged[str].connect(cmap_connector)

# Color map reverse
self.reverseCmapBox = QCheckBox()
reverse_connector = partial(main_window.toggleReverseCmap)
self.reverseCmapBox.stateChanged.connect(reverse_connector)

# Data indicator line check box
self.dataIndicatorCheckBox = QCheckBox()
data_indicator_connector = partial(
Expand Down Expand Up @@ -831,6 +836,7 @@ def __init__(self, model, main_window, field, colormaps=None):
self.layout.addRow("Visible:", self.visibilityBox)
self.layout.addRow("Alpha: ", self.alphaBox)
self.layout.addRow("Colormap: ", self.colormapBox)
self.layout.addRow("Reverse colormap: ", self.reverseCmapBox)
self.layout.addRow("Data Indicator: ", self.dataIndicatorCheckBox)
self.layout.addRow("Custom Min/Max: ", self.userMinMaxBox)
self.layout.addRow("Min: ", self.minBox)
Expand Down
4 changes: 4 additions & 0 deletions openmc_plotter/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,10 @@ def editTallyDataColormap(self, cmap, apply=False):
if apply:
self.applyChanges()

def toggleReverseCmap(self, state):
av = self.model.activeView
av.tallyDataReverseCmap = bool(state)

def updateTallyMinMax(self):
self.tallyDock.updateMinMax()

Expand Down
8 changes: 6 additions & 2 deletions openmc_plotter/plotgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,21 +587,25 @@ def updatePixmap(self):

norm = SymLogNorm(1E-30) if cv.tallyDataLogScale else None

cmap = cv.tallyDataColormap
if cv.tallyDataReverseCmap:
cmap += '_r'

if cv.tallyContours:
# parse the levels line
levels = self.parseContoursLine(cv.tallyContourLevels)
self.tally_image = self.ax.contour(image_data,
origin='image',
levels=levels,
alpha=cv.tallyDataAlpha,
cmap=cv.tallyDataColormap,
cmap=cmap,
norm=norm,
extent=extents)

else:
self.tally_image = self.ax.imshow(image_data,
alpha=cv.tallyDataAlpha,
cmap=cv.tallyDataColormap,
cmap=cmap,
norm=norm,
extent=extents)
# add colorbar
Expand Down
1 change: 1 addition & 0 deletions openmc_plotter/plotmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ def __init__(self):

# Tally Viz Settings
self.tallyDataColormap = 'Spectral'
self.tallyDataReverseCmap = False
self.tallyDataVisible = True
self.tallyDataAlpha = 1.0
self.tallyDataIndicator = False
Expand Down

0 comments on commit e93a120

Please sign in to comment.