Skip to content

Commit b14a924

Browse files
committed
Improved undefined region workflow
1 parent 16f8a17 commit b14a924

2 files changed

Lines changed: 26 additions & 14 deletions

File tree

openmc_plotter/plotgui.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -361,15 +361,19 @@ def _overlapInfo(self, id):
361361
label2 = self._cellLabel(cell2)
362362
return f"OVERLAP: Universe {universe}, Cells {label1} and {label2}"
363363

364-
def _undefinedInfo(self, event):
365-
"""Status-bar text for an undefined (not-found) pixel, if classified."""
364+
def _isUndefinedInternal(self, event):
365+
"""Whether the pixel under the event is an internal undefined region."""
366366
if self.model.undefined_internal is None:
367-
return ""
367+
return False
368368
xPos, yPos = self.getDataIndices(event)
369369
cv = self.model.currentView
370370
if not (0 <= yPos < cv.v_res and 0 <= xPos < cv.h_res):
371-
return ""
372-
if self.model.undefined_internal[yPos, xPos]:
371+
return False
372+
return bool(self.model.undefined_internal[yPos, xPos])
373+
374+
def _undefinedInfo(self, event):
375+
"""Status-bar text for an undefined (not-found) pixel, if classified."""
376+
if self._isUndefinedInternal(event):
373377
return "WARNING: undefined internal region"
374378
return ""
375379

@@ -580,7 +584,16 @@ def contextMenuEvent(self, event):
580584

581585
if cv.colorby not in _MODEL_PROPERTIES:
582586
self.menu.addSeparator()
583-
if int(id) == _NOT_FOUND:
587+
if int(id) == _NOT_FOUND and self._isUndefinedInternal(event):
588+
undefColorAction = self.menu.addAction(
589+
'Edit Undefined Color...')
590+
undefColorAction.setToolTip('Edit undefined color')
591+
undefColorAction.setStatusTip(
592+
'Edit plot undefined region color')
593+
connector = partial(self.main_window.editUndefinedColor,
594+
apply=True)
595+
undefColorAction.triggered.connect(connector)
596+
elif int(id) == _NOT_FOUND:
584597
bgColorAction = self.menu.addAction(
585598
'Edit Background Color...')
586599
bgColorAction.setToolTip('Edit background color')
@@ -610,6 +623,7 @@ def contextMenuEvent(self, event):
610623
self.menu.addAction(self.main_window.maskingAction)
611624
self.menu.addAction(self.main_window.highlightingAct)
612625
self.menu.addAction(self.main_window.overlapAct)
626+
self.menu.addAction(self.main_window.undefinedAct)
613627
self.menu.addSeparator()
614628
self.menu.addAction(self.main_window.dockAction)
615629

@@ -1145,10 +1159,8 @@ def createGeneralTab(self):
11451159
self.undefinedColorButton = QPushButton()
11461160
self.undefinedColorButton.setCursor(QtCore.Qt.PointingHandCursor)
11471161
self.undefinedColorButton.setFixedWidth(button_width)
1148-
self.undefinedColorButton.setFixedHeight(
1149-
self.font_metric.height() * 1.5)
1150-
self.undefinedColorButton.clicked.connect(
1151-
main_window.editUndefinedColor)
1162+
self.undefinedColorButton.setFixedHeight(self.font_metric.height() * 1.5)
1163+
self.undefinedColorButton.clicked.connect(main_window.editUndefinedColor)
11521164

11531165
self.colorResetButton = QPushButton("&Reset Colors")
11541166
self.colorResetButton.setCursor(QtCore.Qt.PointingHandCursor)
@@ -1415,8 +1427,8 @@ def updateOverlap(self):
14151427

14161428
def updateUndefinedColor(self):
14171429
color = self.model.activeView.undefined_color
1418-
style = "border-radius: 8px;background-color: rgb%s"
1419-
self.undefinedColorButton.setStyleSheet(style % str(color))
1430+
self.undefinedColorButton.setStyleSheet("border-radius: 8px;"
1431+
"background-color: rgb%s" % (str(color)))
14201432

14211433
def updateUndefined(self):
14221434
colorby = self.model.activeView.colorby

openmc_plotter/plotmodel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ def __init__(self):
13021302
self.overlap_color = (255, 0, 0)
13031303
# Undefined (not-found) region coloring (internal regions only)
13041304
self.color_undefined = False
1305-
self.undefined_color = (255, 0, 255)
1305+
self.undefined_color = (255, 165, 0)
13061306
self.domainAlpha = 1.0
13071307
self.domainVisible = True
13081308
self.outlinesCell = False
@@ -1344,7 +1344,7 @@ def __setstate__(self, state):
13441344
if not hasattr(self, 'color_undefined'):
13451345
self.color_undefined = False
13461346
if not hasattr(self, 'undefined_color'):
1347-
self.undefined_color = (255, 0, 255)
1347+
self.undefined_color = (255, 165, 0)
13481348
# Migrate old boolean attributes to new tallyDataMinMaxType
13491349
if not hasattr(self, 'tallyDataMinMaxType'):
13501350
if getattr(self, 'tallyDataUserMinMax', False):

0 commit comments

Comments
 (0)