From d38cb857a75d9df1755982f7e9f9ab737cd53b2b Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Fri, 28 Jun 2024 13:00:30 -0500 Subject: [PATCH] Adding ability to display origin as a crosshair --- openmc_plotter/docks.py | 6 ++++++ openmc_plotter/main_window.py | 6 ++++++ openmc_plotter/plotgui.py | 5 +++++ openmc_plotter/plotmodel.py | 3 +++ 4 files changed, 20 insertions(+) diff --git a/openmc_plotter/docks.py b/openmc_plotter/docks.py index b1db673..57870f4 100644 --- a/openmc_plotter/docks.py +++ b/openmc_plotter/docks.py @@ -112,11 +112,17 @@ def _createOriginBox(self): dimension=2) self.zOrBox.valueChanged.connect(zbox_connector) + self.orCrossHairBox = QCheckBox() + crosshair_connector = partial(self.main_window.toggleOriginCrosshair, apply=False) + self.orCrossHairBox.setCheckState(QtCore.Qt.Checked if self.model.currentView.originCrosshair else QtCore.Qt.Unchecked) + self.orCrossHairBox.stateChanged.connect(crosshair_connector) + # Origin Form Layout self.orLayout = QFormLayout() self.orLayout.addRow('X:', self.xOrBox) self.orLayout.addRow('Y:', self.yOrBox) self.orLayout.addRow('Z:', self.zOrBox) + self.orLayout.addRow('Crosshair:', self.orCrossHairBox) self.orLayout.setLabelAlignment(QtCore.Qt.AlignLeft) self.orLayout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow) diff --git a/openmc_plotter/main_window.py b/openmc_plotter/main_window.py index 2e1180d..9a2e63b 100755 --- a/openmc_plotter/main_window.py +++ b/openmc_plotter/main_window.py @@ -828,6 +828,12 @@ def showExportDialog(self): def editSingleOrigin(self, value, dimension): self.model.activeView.origin[dimension] = value + def toggleOriginCrosshair(self, state, apply=False): + self.model.activeView.originCrosshair = bool(state) + + if apply: + self.applyChanges() + def editPlotAlpha(self, value): self.model.activeView.domainAlpha = value diff --git a/openmc_plotter/plotgui.py b/openmc_plotter/plotgui.py index 834ae67..9277bef 100644 --- a/openmc_plotter/plotgui.py +++ b/openmc_plotter/plotgui.py @@ -648,6 +648,11 @@ def updatePixmap(self): self.ax.dataLim.y0 = data_bounds[2] self.ax.dataLim.y1 = data_bounds[3] + if cv.originCrosshair: + self.ax.plot(cv.origin[self.main_window.xBasis], + cv.origin[self.main_window.yBasis], + 'b+') + self.draw() return "Done" diff --git a/openmc_plotter/plotmodel.py b/openmc_plotter/plotmodel.py index b1d5068..6ebc3c7 100644 --- a/openmc_plotter/plotmodel.py +++ b/openmc_plotter/plotmodel.py @@ -872,6 +872,8 @@ class PlotViewIndependent: Alpha value of the geometry plot plotVisibile : bool Controls visibility of geometry + originCrosshair: bool + Controls visibility of origin crosshair outlines: bool Controls visibility of geometry outlines tallyDataColormap : str @@ -915,6 +917,7 @@ def __init__(self): self.overlap_color = (255, 0, 0) self.domainAlpha = 1.0 self.domainVisible = True + self.originCrosshair = False self.outlines = False self.colormaps = {'temperature': 'Oranges', 'density': 'Greys'} # set defaults for color dialog