Exemplo n.º 1
0
    def updateOptions(self):
        """
        Control the Gold/Diff VTK windows.
        """
        value = mooseutils.gold(self._filename) is not None
        self.setVisible(value)
        self.setEnabled(value)
        if not value:
            self.GoldToggle.setChecked(False)
            self.DiffToggle.setChecked(False)

        # Gold window toggle
        gold = self.GoldToggle.isChecked()
        goldname = mooseutils.gold(self._filename)
        if gold and (not self.GoldVTKWindow.isVisible()):
            self.GoldVTKWindow.show()
            self.GoldVTKWindow.onSetFilename(goldname)
            self.GoldVTKWindow.onSetVariable(self._variable)
            self.GoldVTKWindow.onSetComponent(self._component)
            self.GoldVTKWindow.onWindowRequiresUpdate()
        elif (not gold) and self.GoldVTKWindow.isVisible():
            self.GoldVTKWindow.hide()

        # Diff Window toggle
        diff = self.DiffToggle.isChecked() if self._exodiff else False
        if diff and (not self.DiffVTKWindow.isVisible()):

            diffname = self._filename + '.diff'
            cmd = [self._exodiff, '-map', '-F', '1e-10', '-t', '5.5e-06',
                   os.path.abspath(self._filename),
                   os.path.abspath(goldname),
                   os.path.abspath(diffname)]
            subprocess.call(cmd)

            self.DiffVTKWindow.show()
            self.DiffVTKWindow.onSetFilename(diffname)
            self.DiffVTKWindow.onSetVariable(self._variable)
            self.DiffVTKWindow.onSetComponent(self._component)
            self.DiffVTKWindow.onWindowRequiresUpdate()

        elif (not diff) and (self.DiffVTKWindow is not None) and self.DiffVTKWindow.isVisible():
            self.DiffVTKWindow.hide()

        # Camera linkage
        link = self.LinkToggle.isChecked()
        if link:
            if gold and (self._gold_observer is None):
                self._gold_observer = self.GoldVTKWindow._window.getVTKInteractor().AddObserver("RenderEvent", self._callbackGoldRenderEvent)

            if diff and (self._diff_observer is None):
                self._diff_observer = self.DiffVTKWindow._window.getVTKInteractor().AddObserver("RenderEvent", self._callbackDiffRenderEvent)

        else:
            if self._gold_observer is not None:
                self.GoldVTKWindow._window.getVTKInteractor().RemoveObserver(self._gold_observer)
                self._gold_observer = None

            if self._diff_observer is not None:
                self.DiffVTKWindow._window.getVTKInteractor().RemoveObserver(self._diff_observer)
                self._diff_observer = None
Exemplo n.º 2
0
    def updateOptions(self):
        """
        Control the Gold/Diff VTK windows.
        """
        value = mooseutils.gold(self._filename) is not None
        self.setVisible(value)
        self.setEnabled(value)
        if not value:
            self.GoldToggle.setChecked(False)
            self.DiffToggle.setChecked(False)

        # Gold window toggle
        gold = self.GoldToggle.isChecked() if self.GoldVTKWindow else False
        goldname = mooseutils.gold(self._filename)
        if gold and (not self.GoldVTKWindow.isVisible()):
            self.GoldVTKWindow.show()
            self.GoldVTKWindow.onSetFilename(goldname)
            self.GoldVTKWindow.onSetVariable(self._variable)
            self.GoldVTKWindow.onSetComponent(self._component)
            self.GoldVTKWindow.onWindowRequiresUpdate()
        elif (not gold) and self.GoldVTKWindow and self.GoldVTKWindow.isVisible():
            self.GoldVTKWindow.hide()

        # Diff Window toggle
        diff = self.DiffToggle.isChecked() if self._exodiff else False
        if diff and (not self.DiffVTKWindow.isVisible()):

            diffname = self._filename + '.diff'
            cmd = [self._exodiff, '-map', '-F', '1e-10', '-t', '5.5e-06',
                   os.path.abspath(self._filename),
                   os.path.abspath(goldname),
                   os.path.abspath(diffname)]
            subprocess.call(cmd)

            self.DiffVTKWindow.show()
            self.DiffVTKWindow.onSetFilename(diffname)
            self.DiffVTKWindow.onSetVariable(self._variable)
            self.DiffVTKWindow.onSetComponent(self._component)
            self.DiffVTKWindow.onWindowRequiresUpdate()

        elif (not diff) and (self.DiffVTKWindow is not None) and self.DiffVTKWindow.isVisible():
            self.DiffVTKWindow.hide()

        # Camera linkage
        link = self.LinkToggle.isChecked()
        if link:
            if gold and (self._gold_observer is None):
                self._gold_observer = self.GoldVTKWindow._window.getVTKInteractor().AddObserver("RenderEvent", self._callbackGoldRenderEvent)

            if diff and (self._diff_observer is None):
                self._diff_observer = self.DiffVTKWindow._window.getVTKInteractor().AddObserver("RenderEvent", self._callbackDiffRenderEvent)

        else:
            if self._gold_observer is not None:
                self.GoldVTKWindow._window.getVTKInteractor().RemoveObserver(self._gold_observer)
                self._gold_observer = None

            if self._diff_observer is not None:
                self.DiffVTKWindow._window.getVTKInteractor().RemoveObserver(self._diff_observer)
                self._diff_observer = None
Exemplo n.º 3
0
    def _callbackDiffToggle(self, value):
        """
        Callback for DiffToggle widget.

        Args:
            value[bool]: True/False indicating the toggle state of the widget.
        """
        self.store(self._filename, 'Filename')

        if value:
            goldname = mooseutils.gold(self._filename)
            diffname = 'peacock_tmp_diff.exo'

            if not os.path.exists(goldname):
                mooseutils.mooseError('The gold file was not located: {}'.format(goldname))

            cmd = [self._exodiff, '-map', '-F', '1e-10', '-t', '5.5e-06', os.path.abspath(self._filename), os.path.abspath(goldname), os.path.abspath(diffname)]
            subprocess.call(cmd)

            if os.path.exists(diffname):
                self.DiffVTKWindow.blockSignals(True)
                self.DiffVTKWindow.setVisible(True)
                self.DiffVTKWindow.onFileChanged(diffname)
                self.DiffVTKWindow.onCameraChanged(self._result.getVTKRenderer().GetActiveCamera())
                self.DiffVTKWindow.blockSignals(False)
                self.onWindowUpdated()
            else:
                mooseutils.mooseError('Failed to generate Exodiff file with command:\n{}'.format(' '.join(cmd)))

        else:
            self.DiffVTKWindow.setVisible(False)
    def _callbackDiffToggle(self, value):
        """
        Callback for DiffToggle widget.

        Args:
            value[bool]: True/False indicating the toggle state of the widget.
        """
        self.store(self._filename, 'Filename')

        if value:
            goldname = mooseutils.gold(self._filename)
            diffname = 'peacock_tmp_diff.exo'

            if not os.path.exists(goldname):
                mooseutils.mooseError('The gold file was not located: {}'.format(goldname))

            cmd = [self._exodiff, '-map', '-F', '1e-10', '-t', '5.5e-06', os.path.abspath(self._filename), os.path.abspath(goldname), os.path.abspath(diffname)]
            subprocess.call(cmd)

            if os.path.exists(diffname):
                self.DiffVTKWindow.blockSignals(True)
                self.DiffVTKWindow.setVisible(True)
                self.DiffVTKWindow.onFileChanged(diffname)
                self.DiffVTKWindow.onCameraChanged(self._result.getVTKRenderer().GetActiveCamera())
                self.DiffVTKWindow.blockSignals(False)
                self.onWindowUpdated()
            else:
                mooseutils.mooseError('Failed to generate Exodiff file with command:\n{}'.format(' '.join(cmd)))

        else:
            self.DiffVTKWindow.setVisible(False)
Exemplo n.º 5
0
 def setActive(self):
     """
     Sets the Qt enabled status for this widget.
     """
     value = mooseutils.gold(self._filename) is not None
     self.setEnabled(value)
     if value:
         self._callbackGoldToggle(self.GoldToggle.isChecked())
         self._callbackDiffToggle(self.DiffToggle.isChecked())
     else:
         self._callbackGoldToggle(False)
         self._callbackDiffToggle(False)
Exemplo n.º 6
0
 def setActive(self):
     """
     Sets the Qt enabled status for this widget.
     """
     value = mooseutils.gold(self._filename) is not None
     self.setEnabled(value)
     if value:
         self._callbackGoldToggle(self.GoldToggle.isChecked())
         self._callbackDiffToggle(self.DiffToggle.isChecked())
     else:
         self._callbackGoldToggle(False)
         self._callbackDiffToggle(False)