Exemplo n.º 1
0
    def openParaview(self):
        self.Start = time.time()
        QApplication.setOverrideCursor(Qt.WaitCursor)

        script_name = os.path.abspath(
            os.path.join(self.working_dir, self.solver_object.InputCaseName,
                         "pvScript.py"))

        paraview_cmd = "paraview"
        # If using blueCFD, use paraview supplied
        if CfdTools.getFoamRuntime() == 'BlueCFD':
            paraview_cmd = '{}\\..\\AddOns\\ParaView\\bin\\paraview.exe'.format(
                CfdTools.getFoamDir())
        # Otherwise, the command 'paraview' must be in the path. Possibly make path user-settable.
        # Test to see if it exists, as the exception thrown is cryptic on Windows if it doesn't
        import distutils.spawn
        if distutils.spawn.find_executable(paraview_cmd) is None:
            raise IOError("Paraview executable " + paraview_cmd +
                          " not found in path.")

        arg = '--script={}'.format(script_name)

        self.consoleMessage("Running " + paraview_cmd + " " + arg)
        self.open_paraview.start(paraview_cmd, [arg])
        if self.open_paraview.waitForStarted():
            self.consoleMessage("Paraview started")
        else:
            self.consoleMessage("Error starting paraview")
        QApplication.restoreOverrideCursor()
Exemplo n.º 2
0
 def writeSolverInput(self):
     QApplication.restoreOverrideCursor()
     if self.validateSolverInput():
         # self.solver_object.SolverName == "OpenFOAM":
         self.femConsoleMessage("{} case writer is called".format(
             self.solver_object.SolverName))
         """
         QApplication.setOverrideCursor(Qt.WaitCursor)
         try:  # protect code from exception and freezing UI by waitCursor
             ret = self.solver_runner.write_case(self.analysis_object)
         except: # catch *all* exceptions
             print "Unexpected error:", sys.exc_info()[0]
         finally:
             QApplication.restoreOverrideCursor()
         """
         ret = self.solver_runner.write_case()
         if ret:
             self.femConsoleMessage("Write {} case is completed.".format(
                 self.solver_object.SolverName))
             self.form.pb_edit_inp.setEnabled(True)
             self.form.pb_run_solver.setEnabled(True)
         else:
             self.femConsoleMessage("Write case setup file failed!",
                                    "#FF0000")
     else:
         self.femConsoleMessage("Case check failed!", "#FF0000")
    def calculixFinished(self,exitCode):
        print "calculixFinished()",exitCode
        print self.Calculix.state()
        out = self.Calculix.readAllStandardOutput()
        print out
        if out:
            self.femConsoleMessage(unicode(out).replace('\n','<br>'))

        self.Timer.stop()
        
        self.femConsoleMessage("Calculix done!", "#00FF00")

        self.form.pushButton_generate.setText("Re-run Calculix")
        print "Loading results...."
        self.femConsoleMessage("Loading result sets...")
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start) )

        if os.path.isfile(self.Basename + '.frd'):
            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            CalculixLib.importFrd(self.Basename + '.frd',FemGui.getActiveAnalysis() )
            QApplication.restoreOverrideCursor()
            self.femConsoleMessage("Loading results done!", "#00FF00")
        else:
            self.femConsoleMessage("Loading results failed! Results file doesn\'t exist", "#FF0000")
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start) )
Exemplo n.º 4
0
    def threadFinished(self, status):
        if self.thread.task == DEPENDENCY_CHECK:
            QApplication.restoreOverrideCursor()

        elif self.thread.task == DOWNLOAD_CFMESH:
            if status:
                self.consoleMessage("Download completed")
                user_dir = self.thread.user_dir
                self.consoleMessage(
                    "Building cfMesh. Lengthy process - please wait...")
                if CfdTools.getFoamRuntime() == "BlueCFD":
                    script_name = "buildCfMeshOnBlueCFD.sh"
                    self.consoleMessage("Log file: {}\\log.{}".format(
                        user_dir, script_name))
                    shutil.copy(
                        os.path.join(CfdTools.get_module_path(), 'data',
                                     script_name),
                        os.path.join(user_dir, script_name))
                    self.install_process = CfdTools.startFoamApplication(
                        "./" + script_name, "$WM_PROJECT_USER_DIR",
                        self.installFinished)
                else:
                    self.consoleMessage("Log file: {}/{}/log.Allwmake".format(
                        user_dir, CFMESH_FILE_BASE))
                    self.install_process = CfdTools.startFoamApplication(
                        "./Allwmake",
                        "$WM_PROJECT_USER_DIR/" + CFMESH_FILE_BASE,
                        self.installFinished)
            else:
                self.consoleMessage("Download unsuccessful")
Exemplo n.º 5
0
 def write_input_file_handler(self):
     QApplication.restoreOverrideCursor()
     if self.check_prerequisites():
         QApplication.setOverrideCursor(Qt.WaitCursor)
         try:
             import ccxInpWriter as iw
             inp_writer = iw.inp_writer(self.TempDir, self.MeshObject,
                                        self.MaterialObjects,
                                        self.FixedObjects,
                                        self.ForceObjects,
                                        self.PressureObjects)
             self.base_name = inp_writer.write_calculix_input_file()
             if self.base_name != "":
                 self.femConsoleMessage("Write completed.")
             else:
                 self.femConsoleMessage("Write .inp file failed!",
                                        "#FF0000")
         except:
             print "Unexpected error when writing CalculiX input file:", sys.exc_info(
             )[0]
             raise
         finally:
             QApplication.restoreOverrideCursor()
         if self.base_name:
             self.form.pushButton_edit.setEnabled(True)
             self.form.pushButton_generate.setEnabled(True)
 def run_gmsh(self):
     QApplication.setOverrideCursor(Qt.WaitCursor)
     part = self.obj.Part
     if self.mesh_obj.MeshRegionList:
         if part.Shape.ShapeType == "Compound" and hasattr(part, "Proxy"):  # other part obj might not have a Proxy, thus an exception would be raised
             if (part.Proxy.Type == "FeatureBooleanFragments" or part.Proxy.Type == "FeatureSlice" or part.Proxy.Type == "FeatureXOR"):
                 error_message = "The mesh to shape is a boolean split tools Compound and the mesh has mesh region list. Gmsh could return unexpected meshes in such circumstances. It is strongly recommended to extract the shape to mesh from the Compound and use this one."
                 QtGui.QMessageBox.critical(None, "Shape to mesh is a BooleanFragmentsCompound and mesh regions are defined", error_message)
     self.Start = time.time()
     self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
     self.console_message_gmsh = ''
     self.gmsh_runs = True
     self.console_log("We are going to start ...")
     self.get_active_analysis()
     import femmesh.gmshtools as gmshtools
     gmsh_mesh = gmshtools.GmshTools(self.obj, self.analysis)
     self.console_log("Start Gmsh ...")
     error = ''
     try:
         error = gmsh_mesh.create_mesh()
     except:
         import sys
         print("Unexpected error when creating mesh: ", sys.exc_info()[0])
     if error:
         print(error)
         self.console_log('Gmsh had warnings ...')
         self.console_log(error, '#FF0000')
     else:
         self.console_log('Clean run of Gmsh')
     self.console_log("Gmsh done!")
     self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
     self.Timer.stop()
     self.update()
     QApplication.restoreOverrideCursor()
Exemplo n.º 7
0
 def keyReleaseEvent(self, event):
     super(myCodeWidget, self).keyReleaseEvent(event)
     # self.setMouseTracking(False)
     QApplication.restoreOverrideCursor()
     if self.popup:
         self.popup.close()
         self.popup = None
Exemplo n.º 8
0
  def update(self):
    
    QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
    
    self.updateButton.setEnabled(False)
    
    cube = self.getCurrentCube()
    plotType = self.selectPlotType.currentText()
    projection = self.selectProjection.currentText()
    cmap = self.selectColormap.currentText()
    Ncontours = self.contourSlider.value()
    coastlines = self.actionCoastlines.isChecked()
    gridlines = self.actionGridlines.isChecked()
    contourLabels = self.actionContour_Labels.isChecked()
    countries = self.actionCountry_Boundaries.isChecked()
    rivers = self.actionRivers_and_Lakes.isChecked()
    dim1_name = self.selectDimension1.currentText()
    dim1_index = self.selectDimension1.currentIndex()
    dim2_name = self.selectDimension2.currentText()
    dim2_index = self.selectDimension2.currentIndex()
    slicedDimName = self.selectSlicedDim.currentText()
    slicedDimIndex = self.selectSlicedDim.currentIndex()
    sliceIndex = self.selectSliceScroll.value()
    collapsedNames = []
    collapsedIndices = []
    for i in range(cube.ndim - 3):
      exec("collapsedNames.append(self.collapsedDim{}.text())".format(i+1))
      exec("collapsedIndices.append(self.selectSliceIndex{}.currentIndex())".format(i+1))
    if self.cbDialog.autoselectRange.isChecked():
      cbMax = None
      cbMin = None
    elif self.cbDialog.fixedColorbar.isChecked():
      if self.fixedCb == False:
	self.Max, self.Min = cc.setFixedColorbar(cube, dim1_name, dim2_name, slicedDimName, dim1_index, dim2_index, slicedDimIndex, collapsedIndices)
	self.fixedCb == True
      cbMax = self.Max
      cbMin = self.Min
    else:
      cbMax = self.cbDialog.maxContour.value()
      cbMin = self.cbDialog.minContour.value()
    
    self.clearFig()
    
    self.statusBar().showMessage('Plotting Cube')
    try:
      self.plotted_cube = cc.update(cube, plotType, projection, cmap, Ncontours, coastlines, gridlines, contourLabels, countries, rivers,
		cbMax, cbMin, dim1_name, dim1_index, dim2_name, dim2_index, slicedDimName,
		slicedDimIndex, sliceIndex, collapsedNames, collapsedIndices)
    
    except Exception as e:
      flags = QtGui.QMessageBox.StandardButton.Ok
      response = QtGui.QMessageBox.critical(self, 'Unable to plot cube!', str(e), flags)
      self.statusBar().showMessage('Failed to Plot Cube')
      QApplication.restoreOverrideCursor()
    
    self.statusBar().showMessage('Drawing Plot')
    self.display()
    self.printCubeSliceBrowser.setText(str(self.plotted_cube))
    self.statusBar().showMessage('Ready')
    QApplication.restoreOverrideCursor()
Exemplo n.º 9
0
  def showOpenDialog(self):
    """
    Handles the loading of a file, and calls functions to set up the GUI accordingly and then display the cube
    """
    
    self.filename, _ = QtGui.QFileDialog.getOpenFileName(self, 'Open File', '/project/avd/iris/resources/public_sample_data_1.0')
    self.clearAll()
    
    QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
    self.statusBar().showMessage('Loading Cube')
    try:
      self.cubes = iris.load(self.filename)
    except ValueError as e:
      flags = QtGui.QMessageBox.StandardButton.Ok
      response = QtGui.QMessageBox.critical(self, 'Unable to Load Cube: File type could not be read', str(e), flags) 
      self.statusBar().showMessage('Load Failed')
      QApplication.restoreOverrideCursor()
    QApplication.restoreOverrideCursor()
    
    for self.cube in self.cubes:
      self.selectCube.addItem(self.cube.name())        #fills the selectCube combo box with the cubes from the file
    if len(self.cubes) == 1:
      self.selectCube.setEnabled(False)
    else:
      self.selectCube.setEnabled(True)
    self.cubeLoaded = True
    
    self.printCubeBrowser.setText(str(self.cube))

    self.setDimensionCombos()
    self.update()
Exemplo n.º 10
0
    def runCalculix(self):
        if self.fea.ccx_binary_present is False:
            self.femConsoleMessage(
                "CalculiX can not be started. No or wrong CalculiX binary: {}".
                format(self.fea.ccx_binary))
            # TODO deactivate the run button
            return
        # print("runCalculix")
        self.Start = time.time()

        self.femConsoleMessage("CalculiX binary: {}".format(
            self.fea.ccx_binary))
        self.femConsoleMessage("CalculiX input file: {}".format(
            self.fea.inp_file_name))
        self.femConsoleMessage("Run CalculiX...")

        FreeCAD.Console.PrintMessage("run CalculiX at: {} with: {}\n".format(
            self.fea.ccx_binary, self.fea.inp_file_name))
        # change cwd because ccx may crash if directory has no write permission
        # there is also a limit of the length of file names so jump to the document directory
        self.cwd = QtCore.QDir.currentPath()
        fi = QtCore.QFileInfo(self.fea.inp_file_name)
        QtCore.QDir.setCurrent(fi.path())
        self.Calculix.start(self.fea.ccx_binary, ["-i", fi.baseName()])

        QApplication.restoreOverrideCursor()
Exemplo n.º 11
0
 def openXix(self, filename=None):
     if self.isReadOnly(
             filename if filename is not None else self.filename):
         return
     self.closeXix()
     if filename is not None:
         self.filename = filename
     try:
         self.recent_files.remove(self.filename)
         self.updateRecentFilesMenu()
     except ValueError:
         pass  # No problem if it isn't there to be removed
     self.state.indexPath = os.path.dirname(self.filename)
     QApplication.setOverrideCursor(Qt.WaitCursor)
     try:
         say("Opening {}…".format(os.path.normpath(self.filename)))
         QApplication.processEvents()
         self.state.entryPanel.clearForm()
         self._openModel("Opened")
         self.state.entryPanel.termEdit.setFocus()
         self.state.updateUi()
         self.updateWorkTime()
         self.updateLanguageIndicator()
         self.state.setMode(ModeKind.VIEW)
         self.refreshBookmarks()
     finally:
         QApplication.restoreOverrideCursor()
Exemplo n.º 12
0
    def calculixFinished(self, exitCode):
        print "calculixFinished()", exitCode
        print self.Calculix.state()
        out = self.Calculix.readAllStandardOutput()
        print out
        if out:
            self.OutStr = self.OutStr + unicode(out).replace('\n', '<br>')
            self.formUi.textEdit_Output.setText(self.OutStr)

        self.Timer.stop()

        self.OutStr = self.OutStr + '<font color="#0000FF">{0:4.1f}:</font> '.format(
            time.time() -
            self.Start) + '<font color="#00FF00">Calculix done!</font><br>'
        self.formUi.textEdit_Output.setText(self.OutStr)

        self.formUi.pushButton_generate.setText("Re-run Calculix")
        print "Loading results...."
        self.OutStr = self.OutStr + '<font color="#0000FF">{0:4.1f}:</font> '.format(
            time.time() - self.Start) + 'Loading result sets...<br>'
        self.formUi.textEdit_Output.setText(self.OutStr)
        self.formUi.label_Time.setText('Time: {0:4.1f}: '.format(time.time() -
                                                                 self.Start))

        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        CalculixLib.importFrd(self.Basename + '.frd',
                              FemGui.getActiveAnalysis())
        QApplication.restoreOverrideCursor()
        self.OutStr = self.OutStr + '<font color="#0000FF">{0:4.1f}:</font> '.format(
            time.time() - self.Start
        ) + '<font color="#00FF00">Loading results done!</font><br>'
        self.formUi.textEdit_Output.setText(self.OutStr)
        self.formUi.label_Time.setText('Time: {0:4.1f}: '.format(time.time() -
                                                                 self.Start))
Exemplo n.º 13
0
    def update_max_min(self):
        """
        Updates the max and min boxes in colorbar dialog.

        There should be code in here which stops this process on large cubes...
        The time taken in this case is too large for the small reward.

        """
        QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
        scheme = self.colorbar_dialog.get_colorbar_scheme()

        if scheme is "auto":
            colorbar_max, colorbar_min = cl.find_max_min(self.plotted_cube)
            self.colorbar_dialog.set_max_min(colorbar_max, colorbar_min)

        elif scheme is "fixed":
            # want to fix the colorbar across all of the slices.
            cube = self.cube
            dim_1_index = self.select_dimension_1.currentIndex()
            dim_2_index = self.select_dimension_2.currentIndex()
            sliced_dim_index = self.select_sliced_dim.currentIndex()
            dim_indices = {'dim 1 index': dim_1_index,
                           'dim 2 index': dim_2_index,
                           'sliced dim index': sliced_dim_index}
            collapsed_indices = []
            for i in xrange(self.ndim - 3):
                box_name = "select_slice_index_" + str(i+1)
                box = self.findChild(QtGui.QComboBox, box_name)
                collapsed_indices.append(box.currentIndex())

            colorbar_max, colorbar_min = cl.set_fixed_colorbar(
                cube, dim_indices, collapsed_indices)
            self.colorbar_dialog.set_max_min(colorbar_max, colorbar_min)

        QApplication.restoreOverrideCursor()
Exemplo n.º 14
0
    def calculixFinished(self, exitCode):
        print "calculixFinished()", exitCode
        print self.Calculix.state()

        # Restore previous cwd
        QtCore.QDir.setCurrent(self.cwd)

        self.printCalculiXstdout()
        self.Timer.stop()

        self.femConsoleMessage("Calculix done!", "#00AA00")

        self.form.pushButton_generate.setText("Re-run Calculix")
        print "Loading results...."
        self.femConsoleMessage("Loading result sets...")
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
        fea = FemTools()
        fea.reset_all()
        frd_result_file = os.path.splitext(self.inp_file_name)[0] + '.frd'
        if os.path.isfile(frd_result_file):
            QApplication.setOverrideCursor(Qt.WaitCursor)
            ccxFrdReader.importFrd(frd_result_file, FemGui.getActiveAnalysis())
            QApplication.restoreOverrideCursor()
            self.femConsoleMessage("Loading results done!", "#00AA00")
        else:
            self.femConsoleMessage("Loading results failed! Results file doesn\'t exist", "#FF0000")
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
Exemplo n.º 15
0
    def calculixFinished(self, exitCode):
        print "calculixFinished()", exitCode
        print self.Calculix.state()
        out = self.Calculix.readAllStandardOutput()
        print out
        if out:
            self.femConsoleMessage(unicode(out).replace('\n', '<br>'))

        self.Timer.stop()

        self.femConsoleMessage("Calculix done!", "#00FF00")

        self.form.pushButton_generate.setText("Re-run Calculix")
        print "Loading results...."
        self.femConsoleMessage("Loading result sets...")
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() -
                                                               self.Start))

        if os.path.isfile(self.Basename + '.frd'):
            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            CalculixLib.importFrd(self.Basename + '.frd',
                                  FemGui.getActiveAnalysis())
            QApplication.restoreOverrideCursor()
            self.femConsoleMessage("Loading results done!", "#00FF00")
        else:
            self.femConsoleMessage(
                "Loading results failed! Results file doesn\'t exist",
                "#FF0000")
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() -
                                                               self.Start))
Exemplo n.º 16
0
    def calculixFinished(self, exitCode):
        print "calculixFinished()", exitCode
        print self.Calculix.state()

        # Restore previous cwd
        QtCore.QDir.setCurrent(self.cwd)

        self.printCalculiXstdout()
        self.Timer.stop()

        self.femConsoleMessage("Calculix done!", "#00AA00")

        self.form.pushButton_generate.setText("Re-run Calculix")
        print "Loading results...."
        self.femConsoleMessage("Loading result sets...")
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() -
                                                               self.Start))
        fea = FemTools()
        fea.purge_results()
        fea.reset_mesh_color()
        fea.reset_mesh_deformation()
        if os.path.isfile(self.base_name + '.frd'):
            QApplication.setOverrideCursor(Qt.WaitCursor)
            ccxFrdReader.importFrd(self.base_name + '.frd',
                                   FemGui.getActiveAnalysis())
            QApplication.restoreOverrideCursor()
            self.femConsoleMessage("Loading results done!", "#00AA00")
        else:
            self.femConsoleMessage(
                "Loading results failed! Results file doesn\'t exist",
                "#FF0000")
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() -
                                                               self.Start))
Exemplo n.º 17
0
    def calculixFinished(self, exitCode):
        print("calculixFinished() {}".format(exitCode))
        print(self.Calculix.state())

        # Restore previous cwd
        QtCore.QDir.setCurrent(self.cwd)

        self.printCalculiXstdout()
        self.Timer.stop()

        self.femConsoleMessage("CalculiX done!", "#00AA00")

        self.form.pb_run_ccx.setText("Re-run CalculiX")
        self.femConsoleMessage("Loading result sets...")
        self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() -
                                                           self.Start))
        fea = FemToolsCcx.FemToolsCcx(None, self.solver_object)
        fea.reset_mesh_purge_results_checked()
        fea.inp_file_name = self.inp_file_name
        QApplication.setOverrideCursor(Qt.WaitCursor)
        try:
            fea.load_results()
        except:
            QApplication.restoreOverrideCursor()
            majorVersion, minorVersion = fea.get_ccx_version()
            if majorVersion == 2 and minorVersion <= 10:
                message = "The used CalculiX version {}.{} creates broken output files.\n" \
                    "Please upgrade to a newer version.".format(majorVersion, minorVersion)
                QtGui.QMessageBox.warning(None, "Upgrade CalculiX", message)
            raise
        else:
            QApplication.restoreOverrideCursor()
            self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() -
                                                               self.Start))
Exemplo n.º 18
0
 def run_gmsh(self):
     QApplication.setOverrideCursor(Qt.WaitCursor)
     self.Start = time.time()
     self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() -
                                                        self.Start))
     self.console_message_gmsh = ''
     self.gmsh_runs = True
     self.console_log("We gone start ...")
     self.get_active_analysis()
     self.set_mesh_params()
     import FemGmshTools
     gmsh_mesh = FemGmshTools.FemGmshTools(self.obj, self.analysis)
     self.console_log("Start GMSH ...")
     error = ''
     try:
         error = gmsh_mesh.create_mesh()
     except:
         import sys
         print("Unexpected error when creating mesh: ", sys.exc_info()[0])
     if error:
         print(error)
         self.console_log('GMSH had warnings ...')
         self.console_log(error, '#FF0000')
     else:
         self.console_log('Clean run of GMSH')
     self.console_log("GMSH done!")
     self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() -
                                                        self.Start))
     self.Timer.stop()
     self.update()
     QApplication.restoreOverrideCursor()
Exemplo n.º 19
0
    def runCart(self, cart_mesh):
        cart_mesh.error = False
        QApplication.setOverrideCursor(Qt.WaitCursor)

        try:
            tmpdir = tempfile.gettempdir()
            meshCaseDir = os.path.join(tmpdir, 'meshCase')
            cmd = CfdTools.makeRunCommand('./Allmesh',
                                          meshCaseDir,
                                          source_env=False)
            FreeCAD.Console.PrintMessage("Executing: " + ' '.join(cmd) + "\n")
            env = QtCore.QProcessEnvironment.systemEnvironment()
            env_vars = CfdTools.getRunEnvironment()
            for key in env_vars:
                env.insert(key, env_vars[key])
            self.mesh_process.setProcessEnvironment(env)
            self.mesh_process.start(cmd[0], cmd[1:])
            if self.mesh_process.waitForStarted():
                self.form.pb_run_mesh.setEnabled(
                    False)  # Prevent user running a second instance
                self.form.pb_stop_mesh.setEnabled(True)
                self.form.pb_paraview.setEnabled(False)
            else:
                self.console_log("Error starting meshing process", "#FF0000")
                cart_mesh.error = True
        finally:
            QApplication.restoreOverrideCursor()
Exemplo n.º 20
0
 def keyReleaseEvent(self, event):
     super(myCodeWidget, self).keyReleaseEvent(event)
     # self.setMouseTracking(False)
     QApplication.restoreOverrideCursor()
     if self.popup:
         self.popup.close()
         self.popup = None
 def mouseReleaseEvent(self, event):
     if event.button() == Qt.MidButton:
         QApplication.restoreOverrideCursor()
         self._pan_pos = None
         event.accept()
     else:
         event.ignore()
    def calculixFinished(self, exitCode):
        print("calculixFinished() {}".format(exitCode))
        print(self.Calculix.state())

        # Restore previous cwd
        QtCore.QDir.setCurrent(self.cwd)

        self.printCalculiXstdout()
        self.Timer.stop()

        self.femConsoleMessage("CalculiX done!", "#00AA00")

        self.form.pb_run_ccx.setText("Re-run CalculiX")
        self.femConsoleMessage("Loading result sets...")
        self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
        fea = ccxtools.FemToolsCcx(None, self.solver_object)
        fea.reset_mesh_purge_results_checked()
        fea.inp_file_name = self.inp_file_name
        QApplication.setOverrideCursor(Qt.WaitCursor)
        try:
            fea.load_results()
        except:
            QApplication.restoreOverrideCursor()
            majorVersion, minorVersion = fea.get_ccx_version()
            if majorVersion == 2 and minorVersion <= 10:
                message = "The used CalculiX version {}.{} creates broken output files.\n" \
                    "Please upgrade to a newer version.".format(majorVersion, minorVersion)
                QtGui.QMessageBox.warning(None, "Upgrade CalculiX", message)
            raise
        else:
            QApplication.restoreOverrideCursor()
            self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
Exemplo n.º 23
0
 def run_gmsh(self):
     QApplication.setOverrideCursor(Qt.WaitCursor)
     part = self.obj.Part
     if self.mesh_obj.MeshRegionList:
         if part.Shape.ShapeType == "Compound" and hasattr(part, "Proxy"):  # other part obj might not have a Proxy, thus an exception would be raised
             if (part.Proxy.Type == "FeatureBooleanFragments" or part.Proxy.Type == "FeatureSlice" or part.Proxy.Type == "FeatureXOR"):
                 error_message = "The mesh to shape is a boolean split tools Compound and the mesh has mesh region list. Gmsh could return unexpected meshes in such circumstances. It is strongly recommended to extract the shape to mesh from the Compound and use this one."
                 QtGui.QMessageBox.critical(None, "Shape to mesh is a BooleanFragmentsCompound and mesh regions are defined", error_message)
     self.Start = time.time()
     self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
     self.console_message_gmsh = ''
     self.gmsh_runs = True
     self.console_log("We are going to start ...")
     self.get_active_analysis()
     import femmesh.gmshtools as gmshtools
     gmsh_mesh = gmshtools.GmshTools(self.obj, self.analysis)
     self.console_log("Start Gmsh ...")
     error = ''
     try:
         error = gmsh_mesh.create_mesh()
     except:
         import sys
         print("Unexpected error when creating mesh: ", sys.exc_info()[0])
     if error:
         print(error)
         self.console_log('Gmsh had warnings ...')
         self.console_log(error, '#FF0000')
     else:
         self.console_log('Clean run of Gmsh')
     self.console_log("Gmsh done!")
     self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
     self.Timer.stop()
     self.update()
     QApplication.restoreOverrideCursor()
Exemplo n.º 24
0
    def calculixFinished(self, exitCode):
        print ("calculixFinished() {}".format(exitCode))
        print (self.Calculix.state())

        # Restore previous cwd
        QtCore.QDir.setCurrent(self.cwd)

        self.printCalculiXstdout()
        self.Timer.stop()

        self.femConsoleMessage("Calculix done!", "#00AA00")

        self.form.pb_run_ccx.setText("Re-run CalculiX")
        self.femConsoleMessage("Loading result sets...")
        self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
        fea = FemTools()
        fea.reset_all()
        frd_result_file = os.path.splitext(self.inp_file_name)[0] + '.frd'
        if os.path.isfile(frd_result_file):
            QApplication.setOverrideCursor(Qt.WaitCursor)
            ccxFrdReader.importFrd(frd_result_file, FemGui.getActiveAnalysis())
            QApplication.restoreOverrideCursor()
            self.femConsoleMessage("Loading results done!", "#00AA00")
        else:
            self.femConsoleMessage("Loading results failed! Results file doesn\'t exist", "#FF0000")
        self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
Exemplo n.º 25
0
 def write_input_file_handler(self):
     self.Start = time.time()
     if self.check_prerequisites_helper():
         self.consoleMessage("Case writer called")
         self.form.pb_paraview.setEnabled(False)
         self.form.pb_edit_inp.setEnabled(False)
         self.form.pb_run_solver.setEnabled(False)
         QApplication.setOverrideCursor(Qt.WaitCursor)
         try:
             FreeCADGui.addModule("CfdCaseWriterFoam")
             FreeCADGui.doCommand(
                 "writer = CfdCaseWriterFoam.CfdCaseWriterFoam(FreeCAD.ActiveDocument."
                 + self.solver_runner.analysis.Name + ")")
             FreeCADGui.doCommand("writer.writeCase()")
         except Exception as e:
             self.consoleMessage("Error writing case:", "#FF0000")
             self.consoleMessage(str(e), "#FF0000")
             self.consoleMessage("Write case setup file failed", "#FF0000")
             raise
         finally:
             QApplication.restoreOverrideCursor()
         self.consoleMessage("Write case is completed")
         self.updateUI()
         self.form.pb_run_solver.setEnabled(True)
     else:
         self.consoleMessage("Case check failed", "#FF0000")
Exemplo n.º 26
0
    def update_max_min(self):
        """
        Updates the max and min boxes in colorbar dialog.

        There should be code in here which stops this process on large cubes...
        The time taken in this case is too large for the small reward.

        """
        QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
        scheme = self.colorbar_dialog.get_colorbar_scheme()

        if scheme is "auto":
            colorbar_max, colorbar_min = cl.find_max_min(self.plotted_cube)
            self.colorbar_dialog.set_max_min(colorbar_max, colorbar_min)

        elif scheme is "fixed":
            # want to fix the colorbar across all of the slices.
            cube = self.cube
            dim_1_index = self.select_dimension_1.currentIndex()
            dim_2_index = self.select_dimension_2.currentIndex()
            sliced_dim_index = self.select_sliced_dim.currentIndex()
            dim_indices = {'dim 1 index': dim_1_index,
                           'dim 2 index': dim_2_index,
                           'sliced dim index': sliced_dim_index}
            collapsed_indices = []
            for i in xrange(self.ndim - 3):
                box_name = "select_slice_index_" + str(i+1)
                box = self.findChild(QtGui.QComboBox, box_name)
                collapsed_indices.append(box.currentIndex())

            colorbar_max, colorbar_min = cl.set_fixed_colorbar(
                cube, dim_indices, collapsed_indices)
            self.colorbar_dialog.set_max_min(colorbar_max, colorbar_min)

        QApplication.restoreOverrideCursor()
Exemplo n.º 27
0
    def runSolverProcess(self):
        # Re-starting a simulation from the last time step has currently been de-actived by using an AllRun script.
        # re-setting the residuals is NOT needed for plotting

        self.Start = time.time()
        #self.femConsoleMessage("Run {} at {} with command:".format(self.solver_object.SolverName, self.solver_object.WorkingDir))
        cmd = self.solver_runner.get_solver_cmd()

        solverDirectory = os.path.join(self.solver_object.WorkingDir,
                                       self.solver_object.InputCaseName)
        self.femConsoleMessage(cmd)

        FreeCAD.Console.PrintMessage(solverDirectory + "\n")
        if sys.platform == 'win32':  # FIXME: a tmp solution
            #getRunEnvironment() for blueCFD
            #self.solver_run_process.setWorkingDirectory(solverDirectory)  # cause error on WSL
            self.solver_run_process.start(cmd)
        else:
            self.solver_run_process.setWorkingDirectory(
                solverDirectory)  # has error in source bashrc
            self.solver_run_process.start('./Allrun')

        #NOTE: setting solve button to inactive to ensure that two instances of the same simulation aren's started simulataneously
        self.form.pb_run_solver.setEnabled(False)
        self.form.pb_terminate_solver.setEnabled(True)
        self.femConsoleMessage("Solver started")

        QApplication.restoreOverrideCursor()
    def calculixFinished(self,exitCode):
        print "calculixFinished()",exitCode
        print self.Calculix.state()
        out = self.Calculix.readAllStandardOutput()
        print out
        if out:
            self.OutStr = self.OutStr + unicode(out).replace('\n','<br>')
            self.form.textEdit_Output.setText(self.OutStr)

        self.Timer.stop()
        
        self.OutStr = self.OutStr + '<font color="#0000FF">{0:4.1f}:</font> '.format(time.time() - self.Start) + '<font color="#00FF00">Calculix done!</font><br>'
        self.form.textEdit_Output.setText(self.OutStr)

        self.form.pushButton_generate.setText("Re-run Calculix")
        print "Loading results...."
        self.OutStr = self.OutStr + '<font color="#0000FF">{0:4.1f}:</font> '.format(time.time() - self.Start) + 'Loading result sets...<br>'
        self.form.textEdit_Output.setText(self.OutStr)
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start) )

        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        CalculixLib.importFrd(self.Basename + '.frd',FemGui.getActiveAnalysis() )
        QApplication.restoreOverrideCursor()
        self.OutStr = self.OutStr + '<font color="#0000FF">{0:4.1f}:</font> '.format(time.time() - self.Start) + '<font color="#00FF00">Loading results done!</font><br>'
        self.form.textEdit_Output.setText(self.OutStr)
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start) )
Exemplo n.º 29
0
 def runMesh(self):
     self.Start = time.time()
     self.Timer.start()
     cart_mesh = self.cart_mesh
     try:
         QApplication.setOverrideCursor(Qt.WaitCursor)
         self.consoleMessage("Running {} ...".format(
             self.mesh_obj.MeshUtility))
         cart_mesh.error = False
         cmd = CfdTools.makeRunCommand('./Allmesh',
                                       cart_mesh.meshCaseDir,
                                       source_env=False)
         FreeCAD.Console.PrintMessage("Executing: " + ' '.join(cmd) + "\n")
         env_vars = CfdTools.getRunEnvironment()
         self.mesh_process.start(cmd, env_vars=env_vars)
         if self.mesh_process.waitForStarted():
             self.form.pb_run_mesh.setEnabled(
                 False)  # Prevent user running a second instance
             self.form.pb_stop_mesh.setEnabled(True)
             self.form.pb_paraview.setEnabled(False)
             self.form.pb_load_mesh.setEnabled(False)
             self.consoleMessage("Mesher started")
         else:
             self.consoleMessage("Error starting meshing process",
                                 "#FF0000")
             cart_mesh.error = True
     except Exception as ex:
         self.consoleMessage("Error: " + str(ex), '#FF0000')
         raise
     finally:
         QApplication.restoreOverrideCursor()
Exemplo n.º 30
0
 def run_gmsh(self):
     QApplication.setOverrideCursor(Qt.WaitCursor)
     self.Start = time.time()
     self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
     self.console_message_gmsh = ''
     self.gmsh_runs = True
     self.console_log("We gone start ...")
     self.get_active_analysis()
     self.set_mesh_params()
     import FemGmshTools
     gmsh_mesh = FemGmshTools.FemGmshTools(self.obj, self.analysis)
     self.console_log("Start GMSH ...")
     error = ''
     try:
         error = gmsh_mesh.create_mesh()
     except:
         import sys
         print("Unexpected error when creating mesh: ", sys.exc_info()[0])
     if error:
         print(error)
         self.console_log('GMSH had warnings ...')
         self.console_log(error, '#FF0000')
     else:
         self.console_log('Clean run of GMSH')
     self.console_log("GMSH done!")
     self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
     self.Timer.stop()
     self.update()
     QApplication.restoreOverrideCursor()
Exemplo n.º 31
0
    def runSolverProcess(self):
        #Re-starting a simulation from the last time step has currently been de-actived
        #by using an AllRun script. Therefore just re-setting the residuals here for plotting
        self.UxResiduals = [1]
        self.UyResiduals = [1]
        self.UzResiduals = [1]
        self.pResiduals = [1]
        self.niter = 0

        self.Start = time.time()
        #self.femConsoleMessage("Run {} at {} with command:".format(self.solver_object.SolverName, self.solver_object.WorkingDir))
        cmd = self.solver_runner.get_solver_cmd()

        solverDirectory = os.path.join(self.solver_object.WorkingDir,
                                       self.solver_object.InputCaseName)
        self.femConsoleMessage(cmd)
        FreeCAD.Console.PrintMessage(solverDirectory + "\n")
        self.solver_run_process.setWorkingDirectory(solverDirectory)
        self.solver_run_process.start(cmd)

        #NOTE: setting solve button to inactive to ensure that two instances of the same simulation aren's started simulataneously
        self.form.pb_run_solver.setEnabled(False)
        self.form.pb_terminate_solver.setEnabled(True)
        self.femConsoleMessage("Solver started")

        QApplication.restoreOverrideCursor()
Exemplo n.º 32
0
 def writerFinished(self, success):
     if success:
         self.consoleMessage("Write {} case is completed".format(self.solver_object.SolverName))
         self.form.pb_edit_inp.setEnabled(True)
         self.form.pb_run_solver.setEnabled(True)
     else:
         self.consoleMessage("Write case setup file failed", "#FF0000")
     QApplication.restoreOverrideCursor()
Exemplo n.º 33
0
 def __del__(self):
     if self.thread and self.thread.isRunning():
         FreeCAD.Console.PrintMessage("Terminating a pending install task")
         self.thread.terminate()
     if self.install_process and self.install_process.state() == QtCore.QProcess.Running:
         FreeCAD.Console.PrintMessage("Terminating a pending install task")
         self.install_process.terminate()
     QApplication.restoreOverrideCursor()
Exemplo n.º 34
0
Arquivo: accd.py Projeto: Sugz/Python
    def mouseReleaseEvent( self, event ):
        if self._scrolling:
            QApplication.restoreOverrideCursor()

        self._scrolling = False
        self._scrollInitY = 0
        self._scrollInitVal = 0
        event.accept()
Exemplo n.º 35
0
 def run_gmsh(self):
     QApplication.setOverrideCursor(Qt.WaitCursor)
     part = self.mesh_obj.Part
     if (
         self.mesh_obj.MeshRegionList and part.Shape.ShapeType == "Compound"
         and (
             is_of_type(part, "FeatureBooleanFragments")
             or is_of_type(part, "FeatureSlice")
             or is_of_type(part, "FeatureXOR")
         )
     ):
         error_message = (
             "The shape to mesh is a boolean split tools Compound "
             "and the mesh has mesh region list. "
             "Gmsh could return unexpected meshes in such circumstances. "
             "It is strongly recommended to extract the shape "
             "to mesh from the Compound and use this one."
         )
         qtbox_title = (
             "Shape to mesh is a BooleanFragmentsCompound "
             "and mesh regions are defined"
         )
         QtGui.QMessageBox.critical(
             None,
             qtbox_title,
             error_message
         )
     self.Start = time.time()
     self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() - self.Start))
     self.console_message_gmsh = ""
     self.gmsh_runs = True
     self.console_log("We are going to start ...")
     self.get_active_analysis()
     from femmesh import gmshtools
     gmsh_mesh = gmshtools.GmshTools(self.mesh_obj, self.analysis)
     self.console_log("Start Gmsh ...")
     error = ""
     try:
         error = gmsh_mesh.create_mesh()
     except Exception:
         error = sys.exc_info()[1]
         FreeCAD.Console.PrintMessage(
             "Unexpected error when creating mesh: {}\n"
             .format(error)
         )
     if error:
         FreeCAD.Console.PrintMessage("Gmsh had warnings ...\n")
         FreeCAD.Console.PrintMessage("{}\n".format(error))
         self.console_log("Gmsh had warnings ...")
         self.console_log(error, "#FF0000")
     else:
         FreeCAD.Console.PrintMessage("Clean run of Gmsh\n")
         self.console_log("Clean run of Gmsh")
     self.console_log("Gmsh done!")
     self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() - self.Start))
     self.Timer.stop()
     self.update()
     QApplication.restoreOverrideCursor()
Exemplo n.º 36
0
 def cleanUp(self):
     if self.thread and self.thread.isRunning():
         FreeCAD.Console.PrintError("Terminating a pending install task\n")
         self.thread.quit = True
     if self.install_process and self.install_process.state(
     ) == QtCore.QProcess.Running:
         FreeCAD.Console.PrintError("Terminating a pending install task\n")
         self.install_process.terminate()
     QApplication.restoreOverrideCursor()
Exemplo n.º 37
0
 def openParaview(self):
     self.Start = time.time()
     QApplication.setOverrideCursor(Qt.WaitCursor)
     case_path = os.path.abspath(self.cart_mesh.meshCaseDir)
     script_name = "pvScriptMesh.py"
     try:
         self.open_paraview = CfdTools.startParaview(case_path, script_name, self.consoleMessage)
     finally:
         QApplication.restoreOverrideCursor()
Exemplo n.º 38
0
 def openParaview(self):
     self.Start = time.time()
     QApplication.setOverrideCursor(Qt.WaitCursor)
     case_path = os.path.abspath(os.path.join(self.working_dir, self.solver_object.InputCaseName))
     script_name = "pvScript.py"
     try:
         self.open_paraview = CfdTools.startParaview(case_path, script_name, self.consoleMessage)
     finally:
         QApplication.restoreOverrideCursor()
Exemplo n.º 39
0
    def FrontISTRFinished(self, exitCode):
        # print("FrontISTRFinished(), exit code: {}".format(exitCode))
        FreeCAD.Console.PrintLog("FrontISTR state: {}\n".format(
            self.FrontISTR.state()))

        # Restore previous cwd
        QtCore.QDir.setCurrent(self.cwd)

        self.Timer.stop()

        if self.printFrontISTRstdout():
            self.FrontISTRNoError()
        else:
            self.FrontISTRError()

        self.form.pb_run_fistr.setText("Re-run FrontISTR")
        self.femConsoleMessage("Loading result sets...\n")
        self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() -
                                                           self.Start))
        self.fea.reset_mesh_purge_results_checked()
        self.fea.inp_file_name = self.fea.inp_file_name

        majorVersion, minorVersion = self.fea.get_fistr_version()
        if majorVersion == 2 and minorVersion <= 10:
            message = (
                "The used FrontISTR version {}.{} creates broken output files. "
                "The result file will not be read by FreeCAD FEM. "
                "You still can try to read it stand alone with FreeCAD, but it is "
                "strongly recommended to upgrade FrontISTR to a newer version.\n"
                .format(majorVersion, minorVersion))
            QtGui.QMessageBox.warning(None, "Upgrade FrontISTR", message)
            raise

        QApplication.setOverrideCursor(Qt.WaitCursor)

        if self.fea.solver.AnalysisType != "check":
            try:
                FreeCAD.Console.PrintMessage("OutputFileFormat: {}\n".format(
                    self.fea.solver.OutputFileFormat))
                if self.fea.solver.OutputFileFormat == "AVS":  #AVS
                    self.fea.load_results()
                    self.femConsoleMessage("Done loading result sets.\n")
                else:  # 1.VTK, 2.Binary VTK
                    message = (
                        "VTK or Binary VTK is specified for output file format. "
                        "The result file will not be read by FreeCAD FEM.\n"
                        "Open a *.pvtu file with paraview and you can view the result.\n"
                    )
                    FreeCAD.Console.PrintMessage(message)
            except Exception as err:
                FreeCAD.Console.PrintError(
                    "loading results failed: {}\n".format(err))

        QApplication.restoreOverrideCursor()
        self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() -
                                                           self.Start))
Exemplo n.º 40
0
 def showResult(self):
     self.femConsoleMessage("Loading result sets...")
     self.Start = time.time()
     QApplication.setOverrideCursor(Qt.WaitCursor)
     #import FemTools
     #fea = FemTools.FemTools(self.analysis_object, self.solver_object)
     #fea.reset_mesh_purge_results_checked()
     #
     self.solver_runner.view_result()
     QApplication.restoreOverrideCursor()
     self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
Exemplo n.º 41
0
    def runCalculix(self):
        print 'runCalculix'
        self.Start = time.time()

        self.femConsoleMessage(self.CalculixBinary)
        self.femConsoleMessage("Run Calculix...")

        # run Claculix
        print 'run Calclulix at: ', self.CalculixBinary, '  with: ', self.Basename
        self.Calculix.start(self.CalculixBinary, ['-i', self.Basename])

        QApplication.restoreOverrideCursor()
Exemplo n.º 42
0
def busy_cursor(widget=None, cursor=Qt.WaitCursor):
    if widget:
        widget.setCursor(cursor)
    else:
        QApplication.setOverrideCursor(cursor)
    try:
        yield
    finally:
        if widget:
            widget.unsetCursor()
        else:
            QApplication.restoreOverrideCursor()
Exemplo n.º 43
0
 def z88_solve_run(self):
     # z88_solve run
     QtCore.QDir.setCurrent(self.calc_path.path())
     if not self.z88_is_running:
         z88_solverun_binary = self.z88_binary + "  -c  -choly"
         print("Solverun Z88")
         print(z88_solverun_binary)
         self.z88_is_running = True
         self.z88_solverun.start(z88_solverun_binary)
     else:
         print("Unable to start Z88, because it runs (solverun)!")
     QtCore.QDir.setCurrent(self.cwd)
     QApplication.restoreOverrideCursor()
Exemplo n.º 44
0
 def write_input_file_handler(self):
     QApplication.restoreOverrideCursor()
     if self.check_prerequisites():
         QApplication.setOverrideCursor(Qt.WaitCursor)
         try:
             self.write_calculix_input_file()
         except:
             print "Unexpected error when writing CalculiX input file:", sys.exc_info()[0]
             raise
         finally:
             QApplication.restoreOverrideCursor()
         self.form.pushButton_edit.setEnabled(True)
         self.form.pushButton_generate.setEnabled(True)
    def runCalculix(self):
        print 'runCalculix'
        self.Start = time.time()

        self.femConsoleMessage("CalculiX binary: {}".format(self.CalculixBinary))
        self.femConsoleMessage("Run Calculix...")

        # run Claculix
        print 'run Calclulix at: ', self.CalculixBinary , '  with: ', self.Basename
        self.Calculix.start(self.CalculixBinary, ['-i',self.Basename])
        
        
        QApplication.restoreOverrideCursor()
 def write_input_file_handler(self):
     self.Start = time.time()
     self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
     QApplication.restoreOverrideCursor()
     if self.check_prerequisites_helper():
         QApplication.setOverrideCursor(Qt.WaitCursor)
         self.fea.write_inp_file()
         if self.fea.inp_file_name != "":
             self.femConsoleMessage("Write completed.")
             self.form.pb_edit_inp.setEnabled(True)
             self.form.pb_run_ccx.setEnabled(True)
         else:
             self.femConsoleMessage("Write .inp file failed!", "#FF0000")
         QApplication.restoreOverrideCursor()
     self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
Exemplo n.º 47
0
 def z88_test_run(self):
     # z88_testrun for memory
     QtCore.QDir.setCurrent(self.calc_path.path())
     if not self.z88_is_running:
         #self.z88_binary = "/home/hugo/z88progr/z88v14os/bin/unix64/z88r"
         #self.z88_testrun.start(self.z88_binary, ["-c -choly"])
         z88_testrun_binary = self.z88_binary + "  -t  -choly"
         print("Testrun Z88")
         print(z88_testrun_binary)
         self.z88_is_running = True
         self.z88_testrun.start(z88_testrun_binary)
     else:
         print("Can not stat CalculiX, because it runs (testrun)!")
     QtCore.QDir.setCurrent(self.cwd)
     QApplication.restoreOverrideCursor()
Exemplo n.º 48
0
    def wrapper(*args, **kwargs):
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        exception = None

        try:
            rtn = func(*args, **kwargs)
        except Exception as e:
            exception = e
            rtn = None
        finally:
            QApplication.restoreOverrideCursor()

        if exception:
            raise exception

        return rtn
Exemplo n.º 49
0
 def write_input_file_handler(self):
     QApplication.restoreOverrideCursor()
     if self.check_prerequisites_helper():
         QApplication.setOverrideCursor(Qt.WaitCursor)
         self.inp_file_name = ""
         fea = FemTools()
         fea.update_objects()
         fea.write_inp_file()
         if fea.inp_file_name != "":
             self.inp_file_name = fea.inp_file_name
             self.femConsoleMessage("Write completed.")
             self.form.pushButton_edit.setEnabled(True)
             self.form.pushButton_generate.setEnabled(True)
         else:
             self.femConsoleMessage("Write .inp file failed!", "#FF0000")
         QApplication.restoreOverrideCursor()
    def runCalculix(self):
        print 'runCalculix'
        self.Start = time.time()

        self.femConsoleMessage("CalculiX binary: {}".format(self.CalculixBinary))
        self.femConsoleMessage("Run Calculix...")

        # run Calculix
        print 'run Calculix at: ', self.CalculixBinary , '  with: ', self.Basename
        # change cwd because ccx may crash if directory has no write permission
        self.cwd = QtCore.QDir.currentPath()
        QtCore.QDir.setCurrent(QtCore.QDir.homePath())
        self.Calculix.start(self.CalculixBinary, ['-i',self.Basename])
        
        
        QApplication.restoreOverrideCursor()
Exemplo n.º 51
0
 def write_input_file_handler(self):
     QApplication.restoreOverrideCursor()
     if self.check_prerequisites_helper():
         QApplication.setOverrideCursor(Qt.WaitCursor)
         self.inp_file_name = ""
         fea = FemTools()
         fea.set_analysis_type(self.analysis_object.AnalysisType)
         fea.update_objects()
         fea.write_inp_file()
         if fea.inp_file_name != "":
             self.inp_file_name = fea.inp_file_name
             self.femConsoleMessage("Write completed.")
             self.form.pb_edit_inp.setEnabled(True)
             self.form.pb_run_ccx.setEnabled(True)
         else:
             self.femConsoleMessage("Write .inp file failed!", "#FF0000")
         QApplication.restoreOverrideCursor()
Exemplo n.º 52
0
  def showData(self):
    
    """
    Here we take the currently plotted cube (in general NOT the full cube)
    and write the data in it into a table. 
    
    The table used is a table widget from Qt. This has the advantage of an
    elegant presentation and could in future support interactivity with the 
    plot, as clicking on a cell can be used as a signal. 
    However, the disadvantage of this method is that it is quite slow. This 
    is probably because of the number of objects created to draw the table,
    and because each of the objects is more complicated than required as they
    are capable of holding more complex objects such as buttons.
    This lack of speed may require a rewrite of this section.
    """
    
    if self.tableDrawn == False and self.cubeInfoTab.currentIndex() == 2:
      
      QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
      self.statusBar().showMessage('Constructing Data Table')
      self.dataViewer.clear()
      
      coord1 = self.selectDimension1.currentText()
      coord2 = self.selectDimension2.currentText()
      shape = self.plotted_cube.shape
      self.dataViewer.setColumnCount(shape[1])
      self.dataViewer.setRowCount(shape[0])
      headersx = []
      headersy = []

      for i in range(shape[0]):
	headersx.append(str(self.cube.coord(coord1).points[i])) 
      self.dataViewer.setVerticalHeaderLabels(headersx)
      for j in range(shape[1]):
	headersy.append(str(self.cube.coord(coord2).points[j])) 
      self.dataViewer.setHorizontalHeaderLabels(headersy)
	
      for i in range(shape[0]):
	for j in range(shape[1]):
	  exec("lbl{}{} = QtGui.QLabel()".format(i,j))
	  exec("lbl{}{}.setText(str(self.plotted_cube.data[i,j]))".format(i,j))
	  exec("self.dataViewer.setCellWidget(i,j,lbl{}{})".format(i,j))
	  
      QApplication.restoreOverrideCursor()  
      self.statusBar().showMessage('Ready')
      self.tableDrawn = True
Exemplo n.º 53
0
    def runCalculix(self):
        print 'runCalculix'
        self.Start = time.time()

        self.femConsoleMessage("CalculiX binary: {}".format(self.CalculixBinary))
        self.femConsoleMessage("Run Calculix...")

        # run Calculix
        print 'run Calculix at: ', self.CalculixBinary, ' with: ', os.path.splitext(self.inp_file_name)[0]
        # change cwd because ccx may crash if directory has no write permission
        # there is also a limit of the length of file names so jump to the document directory
        self.cwd = QtCore.QDir.currentPath()
        fi = QtCore.QFileInfo(self.inp_file_name)
        QtCore.QDir.setCurrent(fi.path())
        self.Calculix.start(self.CalculixBinary, ['-i', fi.baseName()])

        QApplication.restoreOverrideCursor()
Exemplo n.º 54
0
 def showSaveDialog(self):
   """
   Saves the image which is currently being displayed
   """
   
   filename,_ = QtGui.QFileDialog.getSaveFileName()
   
   QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
   self.statusBar().showMessage('Saving')
   
   try:
     plt.savefig(filename)
   except Exception as e:
     flags = QtGui.QMessageBox.StandardButton.Ok
     response = QtGui.QMessageBox.critical(self, 'Unable to Save Cube', str(e), flags) 
     self.statusBar().showMessage('Save Failed')
   
   QApplication.restoreOverrideCursor()
   self.statusBar().showMessage('Ready')
Exemplo n.º 55
0
    def show_open_dialog(self):
        """
        Handles the loading of a file, and calls functions to
        set up the GUI accordingly and then display the cube
        public samlpe data is used as default folder for now. Want to change
        this to default to the last folder that the program was in.

        """
        self.filename, _ = QtGui.QFileDialog.getOpenFileName(self, 'Open File')

        QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
        self.statusBar().showMessage('Loading Cube')

        self.load_file(self.filename)

        QApplication.restoreOverrideCursor()

        self.set_dimension_combos()
        self.update()
Exemplo n.º 56
0
    def show_data(self):
        """
        Here we take the currently plotted cube (in general NOT the full
        cube) and write the data in it into a table.

        """
        if self.cube_info_tab.currentIndex() == 2:
            QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
            self.data_table.clearSpans()

            if self.ndim == 1:
                coord_1 = None
                coord_2 = self.select_dimension_1.currentText()
                horiz_headers = [""]

            else:
                dim_1 = self.select_dimension_1.currentIndex()
                dim_2 = self.select_dimension_2.currentIndex()
                if dim_1 < dim_2:
                    coord_1 = self.select_dimension_1.currentText()
                    coord_2 = self.select_dimension_2.currentText()
                else:
                    coord_1 = self.select_dimension_2.currentText()
                    coord_2 = self.select_dimension_1.currentText()
                try:
                    horiz_headers = self.cube.coord(coord_2).points
                # An anonymous coord will not be found.
                except iris.exceptions.CoordinateNotFoundError:
                    # We default to using the index.
                    horiz_headers = [i for i in xrange(
                        self.plotted_cube.shape[1])]

            data = self.plotted_cube.data.tolist()
            try:
                vert_headers = self.cube.coord(coord_1).points
            except iris.exceptions.CoordinateNotFoundError:
                vert_headers = [i for i in xrange(self.plotted_cube.shape[0])]

            table = table_model.TableModel(data, horiz_headers,
                                           vert_headers, self.data_tab)
            self.data_table.setModel(table)
            QApplication.restoreOverrideCursor()
Exemplo n.º 57
0
    def show_save_dialog(self):
        """
        Opens a dialog box allowing you to save the current image.

        """
        filename, _ = QtGui.QFileDialog.getSaveFileName()

        QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
        self.statusBar().showMessage('Saving')

        try:
            plt.savefig(filename)
        except Exception as e:
            flags = QtGui.QMessageBox.StandardButton.Ok
            QtGui.QMessageBox.critical(
                self, 'Unable to Save Cube', str(e), flags)
            self.statusBar().showMessage('Save Failed')

        QApplication.restoreOverrideCursor()
        self.statusBar().showMessage('Ready')
Exemplo n.º 58
0
 def write_input_file_handler(self):
     self.Start = time.time()
     self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
     QApplication.restoreOverrideCursor()
     if self.check_prerequisites_helper():
         QApplication.setOverrideCursor(Qt.WaitCursor)
         self.inp_file_name = ""
         fea = FemToolsCcx.FemToolsCcx(None, self.solver_object)
         fea.set_analysis_type(self.solver_object.AnalysisType)
         fea.update_objects()
         fea.write_inp_file()
         if fea.inp_file_name != "":
             self.inp_file_name = fea.inp_file_name
             self.femConsoleMessage("Write completed.")
             self.form.pb_edit_inp.setEnabled(True)
             self.form.pb_run_ccx.setEnabled(True)
         else:
             self.femConsoleMessage("Write .inp file failed!", "#FF0000")
         QApplication.restoreOverrideCursor()
     self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
Exemplo n.º 59
0
 def write_input_file_handler(self):
     QApplication.restoreOverrideCursor()
     if self.check_prerequisites():
         QApplication.setOverrideCursor(Qt.WaitCursor)
         try:
             import ccxInpWriter as iw
             inp_writer = iw.inp_writer(self.TempDir, self.MeshObject, self.MaterialObjects,
                                        self.FixedObjects, self.ForceObjects, self.PressureObjects)
             self.base_name = inp_writer.write_calculix_input_file()
             if self.base_name != "":
                 self.femConsoleMessage("Write completed.")
             else:
                 self.femConsoleMessage("Write .inp file failed!", "#FF0000")
         except:
             print "Unexpected error when writing CalculiX input file:", sys.exc_info()[0]
             raise
         finally:
             QApplication.restoreOverrideCursor()
         if self.base_name:
             self.form.pushButton_edit.setEnabled(True)
             self.form.pushButton_generate.setEnabled(True)