Skip to content

Commit 16f8a17

Browse files
committed
Implemented button for undefined region plotting
1 parent 6e2b6c2 commit 16f8a17

3 files changed

Lines changed: 30 additions & 65 deletions

File tree

openmc_plotter/main_window.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -952,26 +952,14 @@ def editOverlapColor(self, apply=False):
952952
if apply:
953953
self.applyChanges()
954954

955-
def editUndefinedInternalColor(self, apply=False):
956-
current_color = self.model.activeView.undefined_internal_color
955+
def editUndefinedColor(self, apply=False):
956+
current_color = self.model.activeView.undefined_color
957957
dlg = QColorDialog(self)
958958
dlg.setCurrentColor(QtGui.QColor.fromRgb(*current_color))
959959
if dlg.exec():
960960
new_color = dlg.currentColor().getRgb()[:3]
961-
self.model.activeView.undefined_internal_color = new_color
962-
self.colorDialog.updateUndefinedColors()
963-
964-
if apply:
965-
self.applyChanges()
966-
967-
def editUndefinedExternalColor(self, apply=False):
968-
current_color = self.model.activeView.undefined_external_color
969-
dlg = QColorDialog(self)
970-
dlg.setCurrentColor(QtGui.QColor.fromRgb(*current_color))
971-
if dlg.exec():
972-
new_color = dlg.currentColor().getRgb()[:3]
973-
self.model.activeView.undefined_external_color = new_color
974-
self.colorDialog.updateUndefinedColors()
961+
self.model.activeView.undefined_color = new_color
962+
self.colorDialog.updateUndefinedColor()
975963

976964
if apply:
977965
self.applyChanges()

openmc_plotter/plotgui.py

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,6 @@ def _undefinedInfo(self, event):
371371
return ""
372372
if self.model.undefined_internal[yPos, xPos]:
373373
return "WARNING: undefined internal region"
374-
if self.model.undefined_external[yPos, xPos]:
375-
return "Safe external undefined region"
376374
return ""
377375

378376
def mouseDoubleClickEvent(self, event):
@@ -1144,21 +1142,13 @@ def createGeneralTab(self):
11441142
undefined_connector = partial(main_window.toggleUndefined)
11451143
self.undefinedCheck.stateChanged.connect(undefined_connector)
11461144

1147-
self.undefinedInternalColorButton = QPushButton()
1148-
self.undefinedInternalColorButton.setCursor(QtCore.Qt.PointingHandCursor)
1149-
self.undefinedInternalColorButton.setFixedWidth(button_width)
1150-
self.undefinedInternalColorButton.setFixedHeight(
1145+
self.undefinedColorButton = QPushButton()
1146+
self.undefinedColorButton.setCursor(QtCore.Qt.PointingHandCursor)
1147+
self.undefinedColorButton.setFixedWidth(button_width)
1148+
self.undefinedColorButton.setFixedHeight(
11511149
self.font_metric.height() * 1.5)
1152-
self.undefinedInternalColorButton.clicked.connect(
1153-
main_window.editUndefinedInternalColor)
1154-
1155-
self.undefinedExternalColorButton = QPushButton()
1156-
self.undefinedExternalColorButton.setCursor(QtCore.Qt.PointingHandCursor)
1157-
self.undefinedExternalColorButton.setFixedWidth(button_width)
1158-
self.undefinedExternalColorButton.setFixedHeight(
1159-
self.font_metric.height() * 1.5)
1160-
self.undefinedExternalColorButton.clicked.connect(
1161-
main_window.editUndefinedExternalColor)
1150+
self.undefinedColorButton.clicked.connect(
1151+
main_window.editUndefinedColor)
11621152

11631153
self.colorResetButton = QPushButton("&Reset Colors")
11641154
self.colorResetButton.setCursor(QtCore.Qt.PointingHandCursor)
@@ -1183,10 +1173,7 @@ def createGeneralTab(self):
11831173
formLayout.addRow('Overlap Color:', self.overlapColorButton)
11841174
formLayout.addRow(HorizontalLine())
11851175
formLayout.addRow('Show Undefined:', self.undefinedCheck)
1186-
formLayout.addRow('Undefined Internal (warning):',
1187-
self.undefinedInternalColorButton)
1188-
formLayout.addRow('Undefined External (safe):',
1189-
self.undefinedExternalColorButton)
1176+
formLayout.addRow('Undefined Color:', self.undefinedColorButton)
11901177
formLayout.addRow(HorizontalLine())
11911178
formLayout.addRow('Color Plot By:', self.colorbyBox)
11921179
formLayout.addRow('Universe Level:', self.universeLevelBox)
@@ -1356,7 +1343,7 @@ def updateDialogValues(self):
13561343
self.updateOverlap()
13571344
self.updateOverlapColor()
13581345
self.updateUndefined()
1359-
self.updateUndefinedColors()
1346+
self.updateUndefinedColor()
13601347

13611348
def updateMasking(self):
13621349
masking = self.model.activeView.masking
@@ -1426,12 +1413,10 @@ def updateOverlap(self):
14261413
if colorby in ('cell', 'material'):
14271414
self.overlapCheck.setChecked(overlap_val)
14281415

1429-
def updateUndefinedColors(self):
1430-
internal = self.model.activeView.undefined_internal_color
1431-
external = self.model.activeView.undefined_external_color
1416+
def updateUndefinedColor(self):
1417+
color = self.model.activeView.undefined_color
14321418
style = "border-radius: 8px;background-color: rgb%s"
1433-
self.undefinedInternalColorButton.setStyleSheet(style % str(internal))
1434-
self.undefinedExternalColorButton.setStyleSheet(style % str(external))
1419+
self.undefinedColorButton.setStyleSheet(style % str(color))
14351420

14361421
def updateUndefined(self):
14371422
colorby = self.model.activeView.colorby

openmc_plotter/plotmodel.py

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,11 @@ def __init__(self, use_settings_pkl, model_path, default_res):
327327
# Map to be populated by overlap functions
328328
self.overlap_info = None
329329

330-
# Boolean masks of undefined (not-found) regions, populated by
330+
# Boolean mask of internal undefined (not-found) regions, populated by
331331
# makePlot when undefined-region coloring is enabled. Internal regions
332332
# are enclosed by defined geometry (potentially unsafe); external
333-
# regions connect to the slice boundary.
333+
# (boundary-connected) undefined regions are intentionally ignored.
334334
self.undefined_internal = None
335-
self.undefined_external = None
336335

337336
self.version = __version__
338337

@@ -592,20 +591,17 @@ def makePlot(self, view: Optional["PlotView"] = None,
592591
if dom.highlight:
593592
image[self.ids == int(id)] = cv.highlightBackground
594593

595-
# Classify and color undefined (not-found) regions. Internal regions
596-
# are holes enclosed by defined geometry (flagged as a warning);
597-
# external regions connect to the slice boundary and are considered
598-
# safe.
594+
# Classify and color undefined (not-found) regions. Only internal
595+
# regions (holes enclosed by defined geometry) are flagged as a
596+
# warning; external regions connect to the slice boundary and are
597+
# left untouched.
599598
self.undefined_internal = None
600-
self.undefined_external = None
601599
if cv.color_undefined:
602-
_, external, internal = \
600+
_, _, internal = \
603601
openmc.Model._classify_undefined_regions(self.cell_ids)
604602
if internal is not None:
605603
self.undefined_internal = internal
606-
self.undefined_external = external
607-
image[external] = cv.undefined_external_color
608-
image[internal] = cv.undefined_internal_color
604+
image[internal] = cv.undefined_color
609605

610606
# set model image
611607
self.image = image
@@ -1251,11 +1247,10 @@ class PlotViewIndependent:
12511247
overlap_color : 3-tuple of int
12521248
RGB color to apply for cell overlap regions
12531249
color_undefined : bool
1254-
Indicator of whether or not undefined (not-found) regions will be shown
1255-
undefined_internal_color : 3-tuple of int
1250+
Indicator of whether or not internal undefined (not-found) regions
1251+
will be shown
1252+
undefined_color : 3-tuple of int
12561253
RGB color to apply for internal (enclosed) undefined regions
1257-
undefined_external_color : 3-tuple of int
1258-
RGB color to apply for external (boundary-connected) undefined regions
12591254
domainAlpha : float between 0 and 1
12601255
Alpha value of the geometry plot
12611256
plotVisibile : bool
@@ -1305,10 +1300,9 @@ def __init__(self):
13051300
self.highlightSeed = 1
13061301
self.domainBackground = (50, 50, 50)
13071302
self.overlap_color = (255, 0, 0)
1308-
# Undefined (not-found) region coloring
1303+
# Undefined (not-found) region coloring (internal regions only)
13091304
self.color_undefined = False
1310-
self.undefined_internal_color = (255, 0, 255)
1311-
self.undefined_external_color = (0, 170, 255)
1305+
self.undefined_color = (255, 0, 255)
13121306
self.domainAlpha = 1.0
13131307
self.domainVisible = True
13141308
self.outlinesCell = False
@@ -1349,10 +1343,8 @@ def __setstate__(self, state):
13491343
# Undefined region coloring (added in a later version)
13501344
if not hasattr(self, 'color_undefined'):
13511345
self.color_undefined = False
1352-
if not hasattr(self, 'undefined_internal_color'):
1353-
self.undefined_internal_color = (255, 0, 255)
1354-
if not hasattr(self, 'undefined_external_color'):
1355-
self.undefined_external_color = (0, 170, 255)
1346+
if not hasattr(self, 'undefined_color'):
1347+
self.undefined_color = (255, 0, 255)
13561348
# Migrate old boolean attributes to new tallyDataMinMaxType
13571349
if not hasattr(self, 'tallyDataMinMaxType'):
13581350
if getattr(self, 'tallyDataUserMinMax', False):

0 commit comments

Comments
 (0)