Skip to content

Commit e93a120

Browse files
authored
Add checkbox for reversing colormap (#137)
1 parent 3c3e04c commit e93a120

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

openmc_plotter/docks.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,11 @@ def __init__(self, model, main_window, field, colormaps=None):
776776
cmap_connector = partial(main_window.editTallyDataColormap)
777777
self.colormapBox.currentTextChanged[str].connect(cmap_connector)
778778

779+
# Color map reverse
780+
self.reverseCmapBox = QCheckBox()
781+
reverse_connector = partial(main_window.toggleReverseCmap)
782+
self.reverseCmapBox.stateChanged.connect(reverse_connector)
783+
779784
# Data indicator line check box
780785
self.dataIndicatorCheckBox = QCheckBox()
781786
data_indicator_connector = partial(
@@ -831,6 +836,7 @@ def __init__(self, model, main_window, field, colormaps=None):
831836
self.layout.addRow("Visible:", self.visibilityBox)
832837
self.layout.addRow("Alpha: ", self.alphaBox)
833838
self.layout.addRow("Colormap: ", self.colormapBox)
839+
self.layout.addRow("Reverse colormap: ", self.reverseCmapBox)
834840
self.layout.addRow("Data Indicator: ", self.dataIndicatorCheckBox)
835841
self.layout.addRow("Custom Min/Max: ", self.userMinMaxBox)
836842
self.layout.addRow("Min: ", self.minBox)

openmc_plotter/main_window.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,10 @@ def editTallyDataColormap(self, cmap, apply=False):
10041004
if apply:
10051005
self.applyChanges()
10061006

1007+
def toggleReverseCmap(self, state):
1008+
av = self.model.activeView
1009+
av.tallyDataReverseCmap = bool(state)
1010+
10071011
def updateTallyMinMax(self):
10081012
self.tallyDock.updateMinMax()
10091013

openmc_plotter/plotgui.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,21 +587,25 @@ def updatePixmap(self):
587587

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

590+
cmap = cv.tallyDataColormap
591+
if cv.tallyDataReverseCmap:
592+
cmap += '_r'
593+
590594
if cv.tallyContours:
591595
# parse the levels line
592596
levels = self.parseContoursLine(cv.tallyContourLevels)
593597
self.tally_image = self.ax.contour(image_data,
594598
origin='image',
595599
levels=levels,
596600
alpha=cv.tallyDataAlpha,
597-
cmap=cv.tallyDataColormap,
601+
cmap=cmap,
598602
norm=norm,
599603
extent=extents)
600604

601605
else:
602606
self.tally_image = self.ax.imshow(image_data,
603607
alpha=cv.tallyDataAlpha,
604-
cmap=cv.tallyDataColormap,
608+
cmap=cmap,
605609
norm=norm,
606610
extent=extents)
607611
# add colorbar

openmc_plotter/plotmodel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ def __init__(self):
921921

922922
# Tally Viz Settings
923923
self.tallyDataColormap = 'Spectral'
924+
self.tallyDataReverseCmap = False
924925
self.tallyDataVisible = True
925926
self.tallyDataAlpha = 1.0
926927
self.tallyDataIndicator = False

0 commit comments

Comments
 (0)