Skip to content

Commit e21cb32

Browse files
committed
Add option to import properties
1 parent bf03181 commit e21cb32

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

openmc_plotter/main_window.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,13 @@ def createMenuBar(self):
190190
self.openStatePointAction.setToolTip('Open statepoint file')
191191
self.openStatePointAction.triggered.connect(self.openStatePoint)
192192

193+
self.importPropertiesAction = QAction("&Import properties...", self)
194+
self.importPropertiesAction.setToolTip("Import properties")
195+
self.importPropertiesAction.triggered.connect(self.importProperties)
196+
193197
self.dataMenu = self.mainMenu.addMenu('D&ata')
194198
self.dataMenu.addAction(self.openStatePointAction)
199+
self.dataMenu.addAction(self.importPropertiesAction)
195200
self.updateDataMenu()
196201

197202
# Edit Menu
@@ -531,6 +536,28 @@ def openStatePoint(self):
531536
self.updateDataMenu()
532537
self.tallyDock.update()
533538

539+
def importProperties(self):
540+
filename, ext = QFileDialog.getOpenFileName(self, "Import properties",
541+
".", "*.h5")
542+
if not filename:
543+
return
544+
545+
try:
546+
openmc.lib.import_properties(filename)
547+
message = 'Imported properties: {}'
548+
except (FileNotFoundError, OSError, openmc.lib.exc.OpenMCError) as e:
549+
message = 'Error opening properties file: {}'
550+
msg_box = QMessageBox()
551+
msg_box.setText(f"Error opening properties file: \n\n {e} \n")
552+
msg_box.setIcon(QMessageBox.Warning)
553+
msg_box.setStandardButtons(QMessageBox.Ok)
554+
msg_box.exec_()
555+
finally:
556+
self.statusBar().showMessage(message.format(filename), 5000)
557+
558+
if self.model.activeView.colorby == 'temperature':
559+
self.applyChanges()
560+
534561
def closeStatePoint(self):
535562
# remove the statepoint object and update the data menu
536563
filename = self.model.statepoint.filename

0 commit comments

Comments
 (0)