Skip to content
Permalink
Browse files

Merge pull request #13286 from aeslaughter/input-mesh-reload-13014

Improve mesh reloading
  • Loading branch information...
permcody committed Apr 29, 2019
2 parents dd6395c + 109a546 commit 8b24685ce3f93ff2377177c3f48dde30c146bb52
@@ -9,8 +9,8 @@
#* https://www.gnu.org/licenses/lgpl-2.1.html
import os
from plugins import MeshViewerPlugin
from plugins import MeshCameraPlugin
from peacock.ExodusViewer.plugins.BackgroundPlugin import BackgroundPlugin
from peacock.ExodusViewer.plugins.CameraPlugin import CameraPlugin
from BlockHighlighterPlugin import BlockHighlighterPlugin
from peacock.base.PluginManager import PluginManager
from peacock.base.TabPlugin import TabPlugin
@@ -46,7 +46,7 @@ def __init__(self, size=None, plugins=None):
settings_key="input",
set_result_color=True),
lambda: BlockHighlighterPlugin(layout='WindowBottomLayout'),
lambda: CameraPlugin(layout='WindowBottomLayout')]
lambda: MeshCameraPlugin(layout='WindowBottomLayout')]

super(InputFileEditorWithMesh, self).__init__(plugins=plugins)
self.setTabName('Input file')
@@ -72,6 +72,7 @@ def __init__(self, size=None, plugins=None):
self.InputFileEditorPlugin.blockChanged.connect(self.blockChanged)
self.InputFileEditorPlugin.blockSelected.connect(self.highlightChanged)
self.InputFileEditorPlugin.inputFileChanged.connect(self._updateFromInputFile)
self.MeshCameraPlugin.reloadMesh.connect(self.onMeshChanged)

self.fixLayoutWidth('LeftLayout')

@@ -105,13 +106,19 @@ def _updateFromInputFile(self, path):

def onExecutableInfoChanged(self, exe_info):
"""
When the exeuctable has changed we need to update the mesh
When the executable has changed we need to update the mesh
Input:
exe_info[ExecutableInfo]: new information from the executable
"""
self.InputFileEditorPlugin.executableInfoChanged(exe_info)
self.updateView.emit(self.InputFileEditorPlugin.tree, True)

def onMeshChanged(self):
"""
Re-create the mesh file.
"""
self.updateView.emit(self.InputFileEditorPlugin.tree, True)

def blockChanged(self, block):
"""
Called when a block in the input file changed.
@@ -122,6 +129,10 @@ def blockChanged(self, block):
self.highlightChanged(block)
elif block.path == "/Mesh" or block.path.startswith("/Mesh/"):
self.updateView.emit(self.InputFileEditorPlugin.tree, False)
elif block.path == "/MeshModifiers" or block.path.startswith("/MeshModifiers/"):
self.updateView.emit(self.InputFileEditorPlugin.tree, False)
elif block.path == "/MeshGenerators" or block.path.startswith("/MeshGenerators/"):
self.updateView.emit(self.InputFileEditorPlugin.tree, False)
elif block.path == "/Executioner" or block.path.startswith("/Executioner/"):
num_steps = TimeStepEstimate.findTimeSteps(self.InputFileEditorPlugin.tree)
self.numTimeStepsChanged.emit(num_steps)
@@ -0,0 +1,27 @@
#* This file is part of the MOOSE framework
#* https://www.mooseframework.org
#*
#* All rights reserved, see COPYRIGHT for full restrictions
#* https://github.com/idaholab/moose/blob/master/COPYRIGHT
#*
#* Licensed under LGPL 2.1, please see LICENSE for details
#* https://www.gnu.org/licenses/lgpl-2.1.html
from PyQt5 import QtCore, QtWidgets
from peacock.ExodusViewer.plugins.CameraPlugin import CameraPlugin

class MeshCameraPlugin(CameraPlugin):
"""
Adds a Reload Mesh button to the CameraPlugin.
"""
reloadMesh = QtCore.pyqtSignal()

def __init__(self, **kwargs):
self.ReloadButton = QtWidgets.QPushButton('Reload Mesh')
super(MeshCameraPlugin, self).__init__(**kwargs)
self.MainLayout.addWidget(self.ReloadButton)

def _setupReloadButton(self, qobject):
qobject.clicked.connect(self._callbackReloadButton)

def _callbackReloadButton(self):
self.reloadMesh.emit()
@@ -8,3 +8,4 @@
#* https://www.gnu.org/licenses/lgpl-2.1.html

from MeshViewerPlugin import MeshViewerPlugin
from MeshCameraPlugin import MeshCameraPlugin

0 comments on commit 8b24685

Please sign in to comment.
You can’t perform that action at this time.