Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Integrating overlap coloring into the plotter menus.
  • Loading branch information
pshriwise committed Jun 17, 2019
commit d07561794e23993e36af10afee7a4bfc1df45603
22 changes: 22 additions & 0 deletions openmc-plotter
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,16 @@ class MainWindow(QMainWindow):
self.highlightingAct.toggled.connect(highlight_connector)
self.editMenu.addAction(self.highlightingAct)

self.overlapAct = QAction('Enable Overlap Coloring', self)
self.overlapAct.setShortcut('Ctrl+P')
self.overlapAct.setCheckable(True)
self.overlapAct.setToolTip('Toggle overlapping regions')
self.overlapAct.setStatusTip('Toggle display of overlapping '
'regions when enabled')
overlap_connector = partial(self.toggleOverlaps, apply=True)
self.overlapAct.toggled.connect(overlap_connector)
self.editMenu.addAction(self.overlapAct)

# View Menu
self.dockAction = QAction('Hide &Dock', self)
self.dockAction.setShortcut("Ctrl+D")
Expand Down Expand Up @@ -678,6 +688,18 @@ class MainWindow(QMainWindow):
def editSeed(self, value):
self.model.activeView.highlightSeed = value

def editOverlapColor(self, apply=False):
current_color = self.model.activeView.overlap_color
dlg = QColorDialog(self)
dlg.setCurrentColor(QtGui.QColor.fromRgb(*current_color))
if dlg.exec_():
new_color = dlg.currentColor().getRgb()[:3]
self.model.activeView.overlap_color = new_color
self.colorDialog.updateOverlapColor()

if apply:
self.applyChanges()

def editBackgroundColor(self, apply=False):
current_color = self.model.activeView.plotBackground
dlg = QColorDialog(self)
Expand Down
1 change: 1 addition & 0 deletions overlays.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ShortcutsOverlay(QWidget):
("Zoom", "Shift+Scroll"),
("Toggle Masking", c_key + "+M"),
("Toggle Highlighting", c_key + "+L"),
("Toggle Overlap Coloring", c_key + "+P"),
("Set XY Basis", "Alt+X"),
("Set YZ Basis", "Alt+Y"),
("Set XZ Basis", "Alt+Z"),
Expand Down
39 changes: 32 additions & 7 deletions plotgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ def contextMenuEvent(self, event):
self.menu.addAction(self.mw.redoAction)
self.menu.addSeparator()

if id != str(_NOT_FOUND) and cv.colorby not in _MODEL_PROPERTIES:
if int(id) not in (_NOT_FOUND, _OVERLAP) and \
cv.colorby not in _MODEL_PROPERTIES:

# Domain ID
if domain[id].name:
Expand Down Expand Up @@ -334,11 +335,18 @@ def contextMenuEvent(self, event):

if cv.colorby not in _MODEL_PROPERTIES:
self.menu.addSeparator()
bgColorAction = self.menu.addAction('Edit Background Color...')
bgColorAction.setToolTip('Edit background color')
bgColorAction.setStatusTip('Edit plot background color')
connector = partial(self.mw.editBackgroundColor, apply=True)
bgColorAction.triggered.connect(connector)
if int(id) == _NOT_FOUND:
bgColorAction = self.menu.addAction('Edit Background Color...')
bgColorAction.setToolTip('Edit background color')
bgColorAction.setStatusTip('Edit plot background color')
connector = partial(self.mw.editBackgroundColor, apply=True)
bgColorAction.triggered.connect(connector)
elif int(id) == _OVERLAP:
olapColorAction = self.menu.addAction('Edit Overlap Color...')
olapColorAction.setToolTip('Edit overlap color')
olapColorAction.setStatusTip('Edit plot overlap color')
connector = partial(self.mw.editOverlapColor, apply=True)
olapColorAction.triggered.connect(connector)

self.menu.addSeparator()
self.menu.addAction(self.mw.saveImageAction)
Expand All @@ -351,11 +359,13 @@ def contextMenuEvent(self, event):
if domain_kind.lower() not in ('density', 'temperature'):
self.menu.addAction(self.mw.maskingAction)
self.menu.addAction(self.mw.highlightingAct)
self.menu.addAction(self.mw.overlapAct)
self.menu.addSeparator()
self.menu.addAction(self.mw.dockAction)

self.mw.maskingAction.setChecked(cv.masking)
self.mw.highlightingAct.setChecked(cv.highlighting)
self.mw.overlapAct.setChecked(cv.color_overlaps)

if self.mw.dock.isVisible():
self.mw.dockAction.setText('Hide &Dock')
Expand Down Expand Up @@ -822,6 +832,12 @@ def createGeneralTab(self):
overlap_connector = partial(self.mw.toggleOverlaps)
self.overlapCheck.stateChanged.connect(overlap_connector)

self.overlapColorButton = QPushButton()
self.overlapColorButton.setCursor(QtCore.Qt.PointingHandCursor)
self.overlapColorButton.setFixedWidth(self.FM.width("XXXXXXXXXX"))
self.overlapColorButton.setFixedHeight(self.FM.height() * 1.5)
self.overlapColorButton.clicked.connect(self.mw.editOverlapColor)

self.colorbyBox.currentTextChanged[str].connect(self.mw.editColorBy)

formLayout = QFormLayout()
Expand All @@ -838,8 +854,11 @@ def createGeneralTab(self):
formLayout.addRow('Highlight Seed:', self.seedBox)
formLayout.addRow(HorizontalLine())
formLayout.addRow('Background Color: ', self.bgButton)
formLayout.addRow('Color Plot By:', self.colorbyBox)
formLayout.addRow(HorizontalLine())
formLayout.addRow('Show Overlaps', self.overlapCheck)
formLayout.addRow('OVerlap Color', self.overlapColorButton)
formLayout.addRow(HorizontalLine())
formLayout.addRow('Color Plot By:', self.colorbyBox)

generalLayout = QHBoxLayout()
innerWidget = QWidget()
Expand Down Expand Up @@ -996,6 +1015,7 @@ def updateDialogValues(self):
self.updateColorBy()
self.updateDomainTabs()
self.updateOverlap()
self.updateOverlapColor()

def updateMasking(self):
masking = self.model.activeView.masking
Expand Down Expand Up @@ -1054,6 +1074,11 @@ def updateBackgroundColor(self):
self.bgButton.setStyleSheet("border-radius: 8px;"
"background-color: rgb%s" % (str(color)))

def updateOverlapColor(self):
color = self.model.activeView.overlap_color
self.overlapColorButton.setStyleSheet("border-radius: 8px;"
"background-color: rgb%s" % (str(color)))

def updateOverlap(self):
colorby = self.model.activeView.colorby
overlap_val = self.model.activeView.color_overlaps
Expand Down
10 changes: 6 additions & 4 deletions plotmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ def makePlot(self):

cv = self.currentView = copy.deepcopy(self.activeView)
ids = capi_plot.id_map(cv)


print("Creating property map")
props = capi_plot.property_map(cv)
# empty image data
image = np.ones((cv.v_res, cv.h_res, 3), dtype=int)
Expand Down Expand Up @@ -162,7 +159,7 @@ def makePlot(self):
if id == _NOT_FOUND:
image[self.ids == id] = cv.plotBackground
elif id == _OVERLAP:
image[self.ids == id] = (255, 0, 0)
image[self.ids == id] = cv.overlap_color
else:
image[self.ids == id] = domain[str(id)].color

Expand Down Expand Up @@ -259,6 +256,10 @@ class PlotView(_PlotBase):
is active
plotBackground : 3-tuple of int
RGB color to apply to plot background
color_overlaps : bool
Indicator of whether or not overlaps will be shown
overlap_color : 3-tuple of int
RGB color to apply for cell overlap regions
cells : Dict of DomainView instances
Dictionary of cell view settings by ID
materials : Dict of DomainView instances
Expand Down Expand Up @@ -291,6 +292,7 @@ def __init__(self, origin, width, height):
self.highlightAlpha = 0.5
self.highlightSeed = 1
self.plotBackground = (50, 50, 50)
self.overlap_color = (255, 0 , 0)
Comment thread
paulromano marked this conversation as resolved.
Resolved

self.plotAlpha = 1.0

Expand Down