def update(self, **kwargs): super(ExodusResult, self).update(**kwargs) # Do not mess with the range if there is a source without a variable if any([src.getCurrentVariableInformation() is None for src in self._sources]): return # Re-compute ranges for all sources rng = list(self.getRange()) # Use range from all sources as the default if self.isOptionValid('range'): rng = self.getOption('range') else: if self.isOptionValid('min'): rng[0] = self.getOption('min') if self.isOptionValid('max'): rng[1] = self.getOption('max') if rng[0] > rng[1]: mooseutils.mooseDebug("Minimum range greater than maximum:", rng[0], ">", rng[1], ", the range/min/max settings are being ignored.") rng = list(self.getRange()) for src in self._sources: src.getVTKMapper().SetScalarRange(rng) # Explode if self.isOptionValid('explode'): factor = self.getOption('explode') m = self.getCenter() for src in self._sources: c = src.getVTKActor().GetCenter() d = (c[0]-m[0], c[1]-m[1], c[2]-m[2]) src.getVTKActor().AddPosition(d[0]*factor, d[1]*factor, d[2]*factor)
def start(self, timer=None): """ Begin the interactive VTK session. """ mooseutils.mooseDebug("{}.start()".format(self.__class__.__name__), color='MAGENTA') if self.needsUpdate(): self.update() if self.__vtkinteractor: self.__vtkinteractor.Initialize() if timer: if not isinstance(timer, base.ChiggerTimer): n = type(timer).__name__ msg = "The supplied timer of type {} must be a ChiggerTimer object.".format( n) raise mooseutils.MooseException(msg) self.__vtkinteractor.AddObserver('TimerEvent', timer.callback) self.__vtkinteractor.CreateRepeatingTimer(timer.duration()) self.__vtkinteractor.Start() if self.getOption('style') == 'test': self.__vtkwindow.Finalize()
def needsInitialize(self): """ Return True if the object requires an _initialize method call. (public) """ mooseutils.mooseDebug("{}.needsInitialize() = {}".format( self.__class__.__name__, self.__needs_initialize)) return self.__needs_initialize
def _setNeedsInitialize(self, value): """ Set the initialize flag for the _initialize method. (protected) """ mooseutils.mooseDebug("{}._setNeedsInitialize({})".format( self.__class__.__name__, value)) self.__needs_initialize = value
def debug(src, fltr): """ Inline function for debug messages. """ mooseutils.mooseDebug('{} --> {}'.format( type(src).__name__, type(fltr).__name__), color='GREEN')
def initialize(self): """ Initialize method that runs once when update() is first called. (protected) """ mooseutils.mooseDebug("{}.initialize()".format( self.__class__.__name__)) self.__needs_initialize = False self._setInitialOptions()
def onTimeChanged(self): """ Update the limits when the time changes. """ try: self.setLimit(0, emit=False) self.setLimit(1, emit=False) except Exception: mooseutils.mooseDebug('Failed to set limits, likely due to corrupt Exodus file.', color='RED', traceback=True)
def onTimeChanged(self): """ Update the limits when the time changes. """ try: self.setLimit(0, emit=False) self.setLimit(1, emit=False) except Exception: mooseutils.mooseDebug('Failed to set limits, likely due to corrupt Exodus file.', color='RED', traceback=True)
def setNeedsUpdate(self, value): """ Set the value of the need update flag. (protected) Inputs: value[bool]: The value for the update flag. """ mooseutils.mooseDebug("{}.setNeedsUpdate({})".format( self.__class__.__name__, value)) self.__needs_update = value
def needsUpdate(self): """ Indicates if this object needs its update method called. (override) This adds checking of the contained reader, if the reader needs updating then so does this class. """ needs_update = super(ExodusSource, self).needsUpdate() mooseutils.mooseDebug('ExodusSource.needsUpdate() = {}'.format(needs_update)) return needs_update or self.__reader.needsUpdate()
def needsUpdate(self): """ Indicates if this object needs its update method called. (override) This adds checking of the contained reader, if the reader needs updating then so does this class. """ needs_update = super(ExodusSource, self).needsUpdate() mooseutils.mooseDebug('ExodusSource.needsUpdate() = {}'.format(needs_update)) return needs_update or self.__reader.needsUpdate()
def update(self, initialize=True, **kwargs): """ Update method should contain calls to underlying vtk objects. (public) Inputs: initialize[bool]: When True the initialize() method will be called, but only if needed. """ if self.__needs_initialize and initialize: self.initialize() mooseutils.mooseDebug("{}.update()".format(self.__class__.__name__)) self.setOptions(**kwargs) self.setNeedsUpdate(False)
def onUpdateWindow(self, window, reader, result): """ Re-initializes the controls for a reader/result object. """ try: self._times = reader.getTimes() self._num_steps = len(self._times) self._current_step = reader.getTimeData().timestep self.updateTimeDisplay() self.timeChanged.emit() except: mooseutils.mooseDebug('Failed to update window.', traceback=True, color='RED')
def onWindowUpdated(self): """ Re-initializes the controls for a reader/result object. """ try: if self._reader: self._times = self._reader.getTimes() self._num_steps = len(self._times) self._current_step = self._reader.getTimeData().timestep self.updateTimeDisplay() self.timeChanged.emit() except: mooseutils.mooseDebug('Failed to update window.', traceback=True, color='RED')
def connect(self, other): """ Connect the slots of supplied plugin (other) to the signals emited by this (self) plugin. Args: other[Plugin]: A plugin object to connect. """ if self is not other: for name, signal in self.signals().iteritems(): slot_name = 'on' + name[0].upper() + name[1:] if hasattr(other, slot_name): mooseutils.mooseDebug('{}.{} --> {}.{}'.format(self.__class__.__name__, name, other.__class__.__name__, slot_name)) signal.connect(getattr(other, slot_name))
def setup(self): """ Call widget setup methods and connect signals and slots from plugins. """ super(PluginManager, self).setup() # Create the plugins for plugin_class in self._plugin_classes: # Create the widget instance widget = plugin_class() # Check the type if not isinstance(widget, self._plugin_base): mooseutils.MooseException( "The supplied widget is of type '{}' but must be a direct child of a '{}'" .format(widget.__class__.__name__, self._plugin_base.__name__)) # Define the widget name name = widget.__class__.__name__ # Store widget in a list if more than one exist if name in self._plugins: if not isinstance(self._plugins[name], list): self._plugins[name] = [self._plugins[name]] self._plugins[name].append(widget) # Store widget directly if only one else: self._plugins[name] = widget # Set the parent widget.setParent(self) # Add the widget self.addObject(widget) # Set the class attribute base on plugin name setattr(self, name, self._plugins[name]) mooseutils.mooseDebug('Adding plugin as member: {}'.format(name)) # Store in the temporary flat list self._all_plugins.append(widget) # Connect signal/slots of plugins for plugin0 in self._all_plugins: plugin0._plugin_manager = self for plugin1 in self._all_plugins: plugin0.connect(plugin1)
def connect(self, other): """ Connect the slots of supplied plugin (other) to the signals emited by this (self) plugin. Args: other[Plugin]: A plugin object to connect. """ if self is not other: for name, signal in self.signals().items(): slot_name = 'on' + name[0].upper() + name[1:] if hasattr(other, slot_name): mooseutils.mooseDebug('{}.{} --> {}.{}'.format(self.__class__.__name__, name, other.__class__.__name__, slot_name)) signal.connect(getattr(other, slot_name))
def append(self, *args): """ Append result object(s) to the window. """ self.setNeedsUpdate(True) for result in args: mooseutils.mooseDebug('RenderWindow.append {}'.format(type(result).__name__)) if isinstance(result, base.ResultGroup): self.append(*result.getResults()) elif not isinstance(result, self.RESULT_TYPE): n = result.__class__.__name__ t = self.RESULT_TYPE.__name__ msg = 'The supplied result type of {} must be of type {}.'.format(n, t) raise mooseutils.MooseException(msg) self._results.append(result)
def append(self, *args): """ Append result object(s) to the window. """ self.setNeedsUpdate(True) for result in args: mooseutils.mooseDebug('RenderWindow.append {}'.format(type(result).__name__)) if isinstance(result, base.ResultGroup): self.append(*result.getResults()) elif not isinstance(result, self.RESULT_TYPE): n = result.__class__.__name__ t = self.RESULT_TYPE.__name__ msg = 'The supplied result type of {} must be of type {}.'.format(n, t) raise mooseutils.MooseException(msg) self._results.append(result)
def onWindowRequiresUpdate(self): """ Updates the VTK render window, if needed. This is what should be called after changes to this plugin have been made. This is the only slot that actually causes a render to happen. The other slots should be used to setup the window, then this called to actually preform the update. This avoids performing multiple updates to the window. """ file_exists = os.path.exists( self._filename) if self._filename else False if file_exists and (os.path.getmtime(self._filename) < self._run_start_time): self._reset() msg = '{} is currently out of date.\nIt will load automatically when it is updated.' self._setLoadingMessage(msg.format(self._filename)) if (not self._initialized) and file_exists and (os.path.getsize(self._filename) > 0) and \ (os.path.getmtime(self._filename) >= self._run_start_time): self._renderResult() elif (self._filename is not None) and (not file_exists): self._reset() msg = '{} does not currently exist.\nIt will load automatically when it is created.' self._setLoadingMessage(msg.format(self._filename)) elif (self._filename is None): self._reset() self._setLoadingMessage('No file selected.') if self._window.needsUpdate(): # and (self._reader is not None): self._window.update() for result in self._window: result.getVTKRenderer().DrawOn() if self._reader is not None: self.updateWindow.emit(self._window, self._reader, self._result) if self._reader is not None: err = self._reader.getErrorObserver() if err: mooseutils.mooseDebug('Failed to update VTK window.', traceback=True)
def onWindowRequiresUpdate(self, *args): """ Updates the VTK render window. """ if not self._initialized: return if self._window.needsUpdate(): self._window.update() self.windowUpdated.emit() if self._reader: err = self._reader.getErrorObserver() if err: self.onReloadWindow() mooseutils.mooseDebug('Failed to update VTK window.', traceback=True)
def onWindowRequiresUpdate(self, *args): """ Updates the VTK render window. """ if not self._initialized: return # Try to preform an update, if the file disappears startup the initialization timer again and remove results try: if self._window.needsUpdate(): self._window.update() self.windowUpdated.emit() except Exception: mooseutils.mooseDebug('Failed to update VTK window.', traceback=True) self.reset()
def setup(self): """ Call widget setup methods and connect signals and slots from plugins. """ super(PluginManager, self).setup() # Create the plugins for plugin_class in self._plugin_classes: # Create the widget instance widget = plugin_class() # Check the type if not isinstance(widget, self._plugin_base): mooseutils.MooseException("The supplied widget is of type '{}' but must be a direct child of a '{}'".format(widget.__class__.__name__, self._plugin_base.__name__)) # Define the widget name name = widget.__class__.__name__ # Store widget in a list if more than one exist if name in self._plugins: if not isinstance(self._plugins[name], list): self._plugins[name] = [self._plugins[name]] self._plugins[name].append(widget) # Store widget directly if only one else: self._plugins[name] = widget # Set the parent widget.setParent(self) # Add the widget self.addObject(widget) # Set the class attribute base on plugin name setattr(self, name, self._plugins[name]) mooseutils.mooseDebug('Adding plugin as member: {}'.format(name)) # Store in the temporary flat list self._all_plugins.append(widget) # Connect signal/slots of plugins for plugin0 in self._all_plugins: plugin0._plugin_manager = self for plugin1 in self._all_plugins: plugin0.connect(plugin1)
def onWindowRequiresUpdate(self): """ Updates the VTK render window, if needed. This is what should be called after changes to this plugin have been made. This is the only slot that actually causes a render to happen. The other slots should be used to setup the window, then this called to actually preform the update. This avoids performing multiple updates to the window. """ file_exists = os.path.exists(self._filename) if self._filename else False if file_exists and (os.path.getmtime(self._filename) < self._run_start_time): self._reset() msg = '{} is currently out of date.\nIt will load automatically when it is updated.' self._setLoadingMessage(msg.format(self._filename)) if (not self._initialized) and file_exists and (os.path.getsize(self._filename) > 0) and \ (os.path.getmtime(self._filename) >= self._run_start_time): self._renderResult() elif (self._filename is not None) and (not file_exists): self._reset() msg = '{} does not currently exist.\nIt will load automatically when it is created.' self._setLoadingMessage(msg.format(self._filename)) elif (self._filename is None): self._reset() self._setLoadingMessage('No file selected.') if self._window.needsUpdate():# and (self._reader is not None): self._window.update() for result in self._window: result.getVTKRenderer().DrawOn() if self._reader is not None: self.updateWindow.emit(self._window, self._reader, self._result) if self._reader is not None: err = self._reader.getErrorObserver() if err: mooseutils.mooseDebug('Failed to update VTK window.', traceback=True)
def write(self, filename, dialog=False, **kwargs): """ Writes the VTKWindow to an image. """ mooseutils.mooseDebug('RenderWindow.write()', color='MAGENTA') if self.needsUpdate() or kwargs: self.update(**kwargs) # Allowed extensions and the associated readers writers = dict() writers['.png'] = vtk.vtkPNGWriter writers['.ps'] = vtk.vtkPostScriptWriter writers['.tiff'] = vtk.vtkTIFFWriter writers['.bmp'] = vtk.vtkBMPWriter writers['.jpg'] = vtk.vtkJPEGWriter # Extract the extensionq _, ext = os.path.splitext(filename) if ext not in writers: w = ', '.join(writers.keys()) msg = "The filename must end with one of the following extensions: {}.".format( w) mooseutils.mooseError(msg, dialog=dialog) return # Check that the directory exists dirname = os.path.dirname(filename) if (len(dirname) > 0) and (not os.path.isdir(dirname)): msg = "The directory does not exist: {}".format(dirname) mooseutils.mooseError(msg, dialog=dialog) return # Build a filter for writing an image window_filter = vtk.vtkWindowToImageFilter() window_filter.SetInput(self.__vtkwindow) window_filter.Update() # Write it writer = writers[ext]() writer.SetFileName(filename) writer.SetInputData(window_filter.GetOutput()) writer.Write()
def start(self, timer=None): """ Begin the interactive VTK session. """ if timer: msg = "The timer argument is deprecated, please use the 'observers' setting." mooseutils.mooseWarning(msg) mooseutils.mooseDebug("{}.start()".format(self.__class__.__name__), color='MAGENTA') if self.needsUpdate(): self.update() if self.__vtkinteractor: self.__vtkinteractor.Initialize() self.__vtkinteractor.Start() if self.getOption('style') == 'test': self.__vtkwindow.Finalize()
def start(self, timer=None): """ Begin the interactive VTK session. """ if timer: msg = "The timer argument is deprecated, please use the 'observers' setting." mooseutils.mooseWarning(msg) mooseutils.mooseDebug("{}.start()".format(self.__class__.__name__), color='MAGENTA') if self.needsUpdate(): self.update() if self.__vtkinteractor: self.__vtkinteractor.Initialize() self.__vtkinteractor.Start() if self.getOption('style') == 'test': self.__vtkwindow.Finalize()
def write(self, filename, dialog=False, **kwargs): """ Writes the VTKWindow to an image. """ mooseutils.mooseDebug('RenderWindow.write()', color='MAGENTA') if self.needsUpdate() or kwargs: self.update(**kwargs) # Allowed extensions and the associated readers writers = dict() writers['.png'] = vtk.vtkPNGWriter writers['.ps'] = vtk.vtkPostScriptWriter writers['.tiff'] = vtk.vtkTIFFWriter writers['.bmp'] = vtk.vtkBMPWriter writers['.jpg'] = vtk.vtkJPEGWriter # Extract the extensionq _, ext = os.path.splitext(filename) if ext not in writers: w = ', '.join(writers.keys()) msg = "The filename must end with one of the following extensions: {}.".format(w) mooseutils.mooseError(msg, dialog=dialog) return # Check that the directory exists dirname = os.path.dirname(filename) if (len(dirname) > 0) and (not os.path.isdir(dirname)): msg = "The directory does not exist: {}".format(dirname) mooseutils.mooseError(msg, dialog=dialog) return # Build a filter for writing an image window_filter = vtk.vtkWindowToImageFilter() window_filter.SetInput(self.__vtkwindow) window_filter.Update() # Write it writer = writers[ext]() writer.SetFileName(filename) writer.SetInputData(window_filter.GetOutput()) writer.Write()
def update(self, **kwargs): super(ExodusResult, self).update(**kwargs) # Do not mess with the range if there is a source without a variable if any([ src.getCurrentVariableInformation() is None for src in self._sources ]): return # Re-compute ranges for all sources rng = list( self.getRange()) # Use range from all sources as the default if self.isOptionValid('range'): rng = self.getOption('range') else: if self.isOptionValid('min'): rng[0] = self.getOption('min') if self.isOptionValid('max'): rng[1] = self.getOption('max') if rng[0] > rng[1]: mooseutils.mooseDebug( "Minimum range greater than maximum:", rng[0], ">", rng[1], ", the range/min/max settings are being ignored.") rng = list(self.getRange()) for src in self._sources: src.getVTKMapper().SetScalarRange(rng) # Explode if self.isOptionValid('explode'): factor = self.getOption('explode') m = self.getCenter() for src in self._sources: c = src.getVTKActor().GetCenter() d = (c[0] - m[0], c[1] - m[1], c[2] - m[2]) src.getVTKActor().AddPosition(d[0] * factor, d[1] * factor, d[2] * factor)
def setup(self): """ Inspects the class members. (1) Calls _setup methods of QObject member variables (2) Assigns Qt object name base on the member variable name (3) Stores all signals that may be accessed via signals() method. """ # Clear the list of signals self._signals = dict() parent_name = self.objectName() if parent_name: parent_name += '/' for member in dir(self): if not hasattr(self, member): continue attr = getattr(self, member) setup = '_setup' + member slot = '_on' + member[0].upper() + member[1:] if isinstance(attr, QtCore.QObject): name = str(parent_name) + member attr.setObjectName(name) if hasattr(self, setup): mooseutils.mooseDebug(name + "::" + setup, color='GREEN') setupMethod = getattr(self, setup) setupMethod(attr) elif isinstance(attr, QtCore.pyqtBoundSignal): self._signals[member] = attr if hasattr(self, slot): mooseutils.mooseDebug(member, '-->', slot, color='MAGENTA') attr.connect(getattr(self, slot))
def setup(self): """ Inspects the class members. (1) Calls _setup methods of QObject member variables (2) Assigns Qt object name base on the member variable name (3) Stores all signals that may be accessed via signals() method. """ # Clear the list of signals self._signals = dict() parent_name = self.objectName() if parent_name: parent_name += '/' for member in dir(self): if not hasattr(self, member): continue attr = getattr(self, member) setup = '_setup' + member slot = '_on' + member[0].upper() + member[1:] if isinstance(attr, QtCore.QObject): name = str(parent_name) + member attr.setObjectName(name) if hasattr(self, setup): mooseutils.mooseDebug(name + "::" + setup, color='GREEN') setupMethod = getattr(self, setup) setupMethod(attr) elif isinstance(attr, QtCore.pyqtBoundSignal): self._signals[member] = attr if hasattr(self, slot): mooseutils.mooseDebug(member, '-->', slot, color='MAGENTA') attr.connect(getattr(self, slot))
def __updateVariable(self): """ Method to update the active variable to display on the object. (private) """ def get_available_variables(): """ Returns a sting listing the available nodal and elemental variable names. """ nvars = self.__reader.getVariableInformation(var_types=[ExodusReader.NODAL]).keys() evars = self.__reader.getVariableInformation(var_types=[ExodusReader.ELEMENTAL]).keys() msg = ["Nodal:"] msg += [" " + var for var in nvars] msg += ["\nElemental:"] msg += [" " + var for var in evars] return ''.join(msg) # Define the active variable name available = self.__reader.getVariableInformation(var_types=[ExodusReader.NODAL, ExodusReader.ELEMENTAL]) # Case when no variable exists if not available: return default = available[available.keys()[0]] if not self.isOptionValid('variable'): varinfo = default else: var_name = self.getOption('variable') if var_name not in available: msg = "The variable '{}' provided does not exist, using '{}', available " \ "variables include:\n{}" mooseutils.mooseError(msg.format(var_name, default.name, get_available_variables())) varinfo = default else: varinfo = available[var_name] # Update vtkMapper to the correct data mode if varinfo.object_type == ExodusReader.ELEMENTAL: self._vtkmapper.SetScalarModeToUseCellFieldData() elif varinfo.object_type == ExodusReader.NODAL: self._vtkmapper.SetScalarModeToUsePointFieldData() else: raise mooseutils.MooseException('Unknown variable type, not sure how you made it here.') self.__current_variable = varinfo # Colormap if not self.isOptionValid('color'): self._colormap.setOptions(cmap=self.getOption('cmap'), cmap_reverse=self.getOption('cmap_reverse'), cmap_num_colors=self.getOption('cmap_num_colors')) self._vtkmapper.SelectColorArray(varinfo.name) self._vtkmapper.SetLookupTable(self._colormap()) self._vtkmapper.UseLookupTableScalarRangeOff() # Component component = -1 # Default component to utilize if not valid if self.isOptionValid('component'): component = self.getOption('component') if component == -1: self._vtkmapper.GetLookupTable().SetVectorModeToMagnitude() else: if component > varinfo.num_components: msg = 'Invalid component number ({}), the variable "{}" has {} components.' mooseutils.mooseError(msg.format(component, varinfo.name, varinfo.num_components)) self._vtkmapper.GetLookupTable().SetVectorModeToComponent() self._vtkmapper.GetLookupTable().SetVectorComponent(component) # Range if (self.isOptionValid('min') or self.isOptionValid('max')) and self.isOptionValid('range'): mooseutils.mooseError('Both a "min" and/or "max" options has been set along with the ' '"range" option, the "range" is being utilized, the others are ' 'ignored.') # Range rng = list(self.__getRange()) # Use range from all sources as the default if self.isOptionValid('range'): rng = self.getOption('range') else: if self.isOptionValid('min'): rng[0] = self.getOption('min') if self.isOptionValid('max'): rng[1] = self.getOption('max') if rng[0] > rng[1]: mooseutils.mooseDebug("Minimum range greater than maximum:", rng[0], ">", rng[1], ", the range/min/max settings are being ignored.") rng = list(self.__getRange()) self.getVTKMapper().SetScalarRange(rng)
def __updateVariable(self): """ Method to update the active variable to display on the object. (private) """ def get_available_variables(): """ Returns a sting listing the available nodal and elemental variable names. """ nvars = self.__reader.getVariableInformation( var_types=[ExodusReader.NODAL]).keys() evars = self.__reader.getVariableInformation( var_types=[ExodusReader.ELEMENTAL]).keys() msg = ["Nodal:"] msg += [" " + var for var in nvars] msg += ["\nElemental:"] msg += [" " + var for var in evars] return ''.join(msg) # Define the active variable name available = self.__reader.getVariableInformation( var_types=[ExodusReader.NODAL, ExodusReader.ELEMENTAL]) # Case when no variable exists if not available: return default = available[available.keys()[0]] if not self.isOptionValid('variable'): varinfo = default else: var_name = self.getOption('variable') if var_name not in available: msg = "The variable '{}' provided does not exist, using '{}', available " \ "variables include:\n{}" mooseutils.mooseError( msg.format(var_name, default.name, get_available_variables())) varinfo = default else: varinfo = available[var_name] # Update vtkMapper to the correct data mode if varinfo.object_type == ExodusReader.ELEMENTAL: self._vtkmapper.SetScalarModeToUseCellFieldData() elif varinfo.object_type == ExodusReader.NODAL: self._vtkmapper.SetScalarModeToUsePointFieldData() else: raise mooseutils.MooseException( 'Unknown variable type, not sure how you made it here.') self.__current_variable = varinfo # Colormap if not self.isOptionValid('color'): self._colormap.setOptions( cmap=self.getOption('cmap'), cmap_reverse=self.getOption('cmap_reverse'), cmap_num_colors=self.getOption('cmap_num_colors')) self._vtkmapper.SelectColorArray(varinfo.name) self._vtkmapper.SetLookupTable(self._colormap()) self._vtkmapper.UseLookupTableScalarRangeOff() # Component component = -1 # Default component to utilize if not valid if self.isOptionValid('component'): component = self.getOption('component') if component == -1: self._vtkmapper.GetLookupTable().SetVectorModeToMagnitude() else: if component > varinfo.num_components: msg = 'Invalid component number ({}), the variable "{}" has {} components.' mooseutils.mooseError( msg.format(component, varinfo.name, varinfo.num_components)) self._vtkmapper.GetLookupTable().SetVectorModeToComponent() self._vtkmapper.GetLookupTable().SetVectorComponent(component) # Range if (self.isOptionValid('min') or self.isOptionValid('max')) and self.isOptionValid('range'): mooseutils.mooseError( 'Both a "min" and/or "max" options has been set along with the ' '"range" option, the "range" is being utilized, the others are ' 'ignored.') # Range rng = list( self.__getRange()) # Use range from all sources as the default if self.isOptionValid('range'): rng = self.getOption('range') else: if self.isOptionValid('min'): rng[0] = self.getOption('min') if self.isOptionValid('max'): rng[1] = self.getOption('max') if rng[0] > rng[1]: mooseutils.mooseDebug( "Minimum range greater than maximum:", rng[0], ">", rng[1], ", the range/min/max settings are being ignored.") rng = list(self.__getRange()) self.getVTKMapper().SetScalarRange(rng) # Handle Elemental variables that are not everywhere on the domain varname = self.__current_variable.name block = self.getOption('block') if (self.__current_variable.object_type == ExodusReader.ELEMENTAL) and (block is not None): for i in range( self.__vtkextractblock.GetOutput().GetNumberOfBlocks()): if not hasattr(self.__vtkextractblock.GetOutput().GetBlock(i), 'GetNumberOfBlocks'): continue for j in range(self.__vtkextractblock.GetOutput().GetBlock( i).GetNumberOfBlocks()): blk = self.__vtkextractblock.GetOutput().GetBlock( i).GetBlock(j) if not blk.GetCellData().HasArray(varname): data = vtk.vtkDoubleArray() data.SetName(varname) data.SetNumberOfTuples( blk.GetCellData().GetArray(0).GetNumberOfTuples()) data.FillComponent(0, vtk.vtkMath.Nan()) blk.GetCellData().AddArray(data)
def debug(src, fltr): """ Inline function for debug messages. """ mooseutils.mooseDebug('{} --> {}'.format(type(src).__name__, type(fltr).__name__), color='GREEN')