Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checkbox for reversing colormap #137

Merged
merged 1 commit into from
Apr 25, 2024
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
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 @@ -923,6 +923,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
Loading