From 4d3bc006ae44e6759bfeb853d93351be543e3b74 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 30 Mar 2022 13:50:39 -0500 Subject: [PATCH 1/2] Adding option to ignore the plot_settings.pkl file --- openmc_plotter/__main__.py | 8 +++++--- openmc_plotter/main_window.py | 13 ++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/openmc_plotter/__main__.py b/openmc_plotter/__main__.py index 9c2cbe4..c94290c 100644 --- a/openmc_plotter/__main__.py +++ b/openmc_plotter/__main__.py @@ -16,16 +16,18 @@ def main(): ap = ArgumentParser(description='OpenMC Plotter GUI') ap.add_argument('-d','--model-directory', default=None, help='Location of model dir (default is current dir)') + ap.add_argument('-e','--ignore-settings', action='store_false', + help='Ignore plot_settings.pkl file if flag is present.') args = ap.parse_args() if args.model_directory is not None: os.chdir(args.model_directory) - run_app() + run_app(use_settings_pkl=args.ignore_settings) -def run_app(): +def run_app(use_settings_pkl=True): path_icon = str(Path(__file__).parent / 'assets/openmc_logo.png') path_splash = str(Path(__file__).parent / 'assets/splash.png') @@ -61,7 +63,7 @@ def run_app(): screen_size = app.primaryScreen().size() mainWindow = MainWindow(font_metric, screen_size) # connect splashscreen to main window, close when main window opens - mainWindow.loadGui() + mainWindow.loadGui(use_settings_pkl=use_settings_pkl) mainWindow.show() splash.close() diff --git a/openmc_plotter/main_window.py b/openmc_plotter/main_window.py index d85fc9d..3432a04 100755 --- a/openmc_plotter/main_window.py +++ b/openmc_plotter/main_window.py @@ -38,19 +38,21 @@ def _openmcReload(): openmc.lib.settings.verbosity = 1 class MainWindow(QMainWindow): - def __init__(self, font=QtGui.QFontMetrics(QtGui.QFont()), screen_size=QtCore.QSize()): + def __init__(self, + font=QtGui.QFontMetrics(QtGui.QFont()), + screen_size=QtCore.QSize()): super().__init__() self.screen = screen_size self.font_metric = font self.setWindowTitle('OpenMC Plot Explorer') - def loadGui(self): + def loadGui(self, use_settings_pkl=True): self.pixmap = None self.zoom = 100 - self.loadModel() + self.loadModel(use_settings_pkl=use_settings_pkl) # Create viewing area self.frame = QScrollArea(self) @@ -439,13 +441,14 @@ def updateWindowMenu(self): self.mainWindowAction.setChecked(self.isActiveWindow()) # Menu and shared methods - def loadModel(self, reload=False): + def loadModel(self, reload=False, use_settings_pkl=True): if reload: self.resetModels() else: # create new plot model self.model = PlotModel() - self.restoreModelSettings() + if use_settings_pkl: + self.restoreModelSettings() # update plot and model settings self.updateRelativeBases() From e4d8a57406810812243790e1ae151eb15ddb4261 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 30 Mar 2022 13:59:53 -0500 Subject: [PATCH 2/2] Update ignore settings flag description --- openmc_plotter/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc_plotter/__main__.py b/openmc_plotter/__main__.py index c94290c..b851d82 100644 --- a/openmc_plotter/__main__.py +++ b/openmc_plotter/__main__.py @@ -17,7 +17,7 @@ def main(): ap.add_argument('-d','--model-directory', default=None, help='Location of model dir (default is current dir)') ap.add_argument('-e','--ignore-settings', action='store_false', - help='Ignore plot_settings.pkl file if flag is present.') + help='Ignore plot_settings.pkl file if present.') args = ap.parse_args()