Example #1
0
 def parseIntNum(self , numStr , itemName='None'):
     try:
         num = int(numStr)
     except:
         showErrorMessageBox( 'InputError' , itemName + ' should be a integer')
         return None
     return num
Example #2
0
    def __readBlocksData(self):
        '''
        read block data from file
        '''
        import Base , os
        filename = os.path.join(Base.__currentProjectPath__ , 'data.df')
        if not os.path.exists(filename):
            Base.showErrorMessageBox('FileNotFound', '\'data.df\' file was not found in project path.')
            return
        
        from loadDataTools import ParseDFInputGraphData
        self.dataParser = ParseDFInputGraphData()
        
        if not self.dataParser.parse(str(filename)):
            showErrorMessageBox('Data Error' , 'the schema of file is incorrected')
            self.__mainWidget.ui.loadDataLabel.setText('faild')
            return

        self.__mainWidget.ui.loadDataLabel.setText('sucessed')

        print 'DF data parse successfully'    
        self.__mainWidget.enableConfigPanel(True)
        
        from DDADatabase import df_inputDatabase
        data = df_inputDatabase
        self.__mainWidget.ui.blockNumLineE.setText(str(len(df_inputDatabase.blockMatCollections)))
        print df_inputDatabase.blockMatCollections
        self.__mainWidget.ui.jointNumLineE.setText(str(len(df_inputDatabase.jointMatCollections)))
        print df_inputDatabase.jointMatCollections
        self.dataParser = None
        
        self.__setDefaultParameters()
Example #3
0
 def parseIntNum(self , numStr , itemName='None'):
     try:
         num = int(numStr)
     except:
         showErrorMessageBox( 'InputError' , itemName + ' should be a integer')
         return None
     return num
Example #4
0
    def __readBlocksData(self):
        '''
        read block data from file
        '''
        import Base
        filename = str( QtGui.QFileDialog.getOpenFileName(None , 'please select input file' , Base.__currentProjectPath__) )
        if not filename:
            return
        
        from loadDataTools import ParseDFInputGraphData
        self.dataParser = ParseDFInputGraphData()
        
        if not self.dataParser.parse(str(filename)):
            showErrorMessageBox('Data Error' , 'the schema of file is incorrected')
            return

        print 'DF data parse successfully'    
        self.__enableConfigPanel(True)
        
        from DDADatabase import df_inputDatabase
        data = df_inputDatabase
        self.configUI.ui.lineE_Path.setText(filename)                
        self.configUI.ui.lineE_BlockNum.setText(str(len(df_inputDatabase.blockMatCollections)))
        self.configUI.ui.lineE_JointNum.setText(str(len(df_inputDatabase.jointMatCollections)))
        self.__initMatConfigUI()
        
        self.dataParser = None
Example #5
0
 def setFile(self, fileName):
     self.__fileName = fileName
     try:
         self.__file = open(self.__fileName , 'rb')
     except:
         showErrorMessageBox('file open error' , fileName + ' open failed')
         return False
     return True
Example #6
0
 def setFile(self, fileName):
     self.__fileName = fileName
     try:
         self.__file = open(self.__fileName , 'rb')
     except:
         showErrorMessageBox('file open error' , fileName + ' open failed')
         return False
     return True
Example #7
0
def splitContent(content):
    texts = content.split()
    nums = {}
    try:
        for i in range(len(texts)/3):
            nums[texts[3*i].strip()] = float(texts[3*i+2])
    except:
        showErrorMessageBox('DataError', 'unvalid data read : (%s , %s)'%(texts[3*i],texts[3*i+2]))
    return nums
Example #8
0
    def checkDataValid(self):
#        if not (self.boundaryLines and len(self.boundaryLines)>0) :
        from DDADatabase import dl_database
        if not len(dl_database.boundaryNodes)>0 :
            FreeCAD.Console.PrintError('boundary lines store failed. \nPlease input boundary lines first.\n')
            showErrorMessageBox('Input Error' , 'Please input boundary lines first')
            return False
            
        return True
Example #9
0
    def delRow(self ):
#        if not (rowIdx>=0 and rowIdx<self.__table.rowCount()):
        if self.__table.rowCount()==0:
            from Base import showErrorMessageBox
            showErrorMessageBox('dataError', 'Unvalid row')
        rowIdx = self.__table.rowCount()-1
        self.__signalMapper.removeMappings(self.__table.cellWidget(rowIdx,1),rowIdx)
        self.__table.removeRow(rowIdx)
        if self.__table.rowCount()>0:
            self.delBtn.setEnabled(False)
        else:
            self.delBtn.setEnabled(True)
        self.addBtn.setEnabled(True)
Example #10
0
 def __readParameters(self):
     '''
     read parameters from file
     '''
     import Base
     filename = str( QtGui.QFileDialog.getOpenFileName(None , 'please select input file' , Base.__currentProjectPath__) )
     if not filename:
         return
     from loadDataTools import ParseDFInputParameters
     parasParser = ParseDFInputParameters()
     
     if not parasParser.parse(str(filename)):
         showErrorMessageBox('Data Error' , 'the schema of file is incorrected')
         return        
     self.__storePara2Panel()
Example #11
0
    def __calculateDF(self):
        '''
        save parameters to self.current_path/parameters.df , and then start calculation
        '''
        if not self.matConfigUI.ifMatConfigPanelOK(): # all 3 tables' parameters are valid
            showErrorMessageBox('Data Error' , 'check recorrect parameters in tables')
            return
        self.__saveParameters2File()

        print 'Calculation button pressed'
        
        import os
        originPath = os.getcwd() 
        import Base
        print 'change dir to ' , Base.__workbenchPath__
        os.chdir(Base.__workbenchPath__)
        
        
        # begin to calculation

        processDialog =  Ui_DFCalculationProcess()
        print 'processbar widget showed'
        
        import Base
        f = open(Base.__currentProjectPath__+'/data.dg' , 'wb')  # clear file
        f.close()
        
        maxSteps = int(str(self.configUI.ui.spinBox__NumStep.text()))
#        maxSteps = 20000
        processDialog.ui.progressBar.setMaximum(maxSteps)
        processDialog.show()
        process = PyDDA.DF()
        process.calculationInit()
        for i in range(maxSteps):
            process.calculate1Step()
            processDialog.ui.progressBar.setValue(i)
            processDialog.ui.label_rate.setText('steps : %d /%d '%(i , maxSteps))
            e=QtCore.QEventLoop()
            e.processEvents()
        
        file = open('dg_ff.c' , 'wb')
        file.write(Base.__currentProjectPath__+'/data.dg')
        file.close()
        
        print 'change dir to ' , originPath
        os.chdir(originPath)        
Example #12
0
    def __readParameters(self):
        '''
        read parameters from file
        '''
        import Base
        filename = os.path.join(Base.__currentProjectPath__ , 'parameters.df')
        if not os.path.exists(filename):
            Base.showErrorMessageBox('FileNotFound', '\'parameters.df\' file was not found in project path.')
            return

        from loadDataTools import ParseDFInputParameters
        parasParser = ParseDFInputParameters()
        
        if not parasParser.parse(str(filename)):
            showErrorMessageBox('Data Error' , 'the schema of file is incorrected')
            self.__mainWidget.ui.loadParasLabel.setText('faild')
            return        
        self.__mainWidget.ui.loadParasLabel.setText('sucessed')

        self.__storePara2Panel()
Example #13
0
 def Activated(self):
     '''
     这个命令是工具,不要清除其它命令
     '''
     print 'begin check validation joint sets and tunnels'
     self.valid = True
     if not DDAJointSets.checkTable():
         self.valid = False
         showErrorMessageBox('Input Error' , 'JointSets data unvalid.\nPlease correct it first.')
     else:
         if DDAJointSets.IsSlopeTableBlank():
             Base.showErrorMessageBox('InputError', 'slope data not found .\nPlease input it first.')
             self.valid = False
         else:
             DDAJointSets.save2Database()
         
     if not DDATunnels.checkTable():
         self.valid = False
         showErrorMessageBox('Input Error' , 'Tunnels data unvalid.\nPlease correct it first.')
     else:
         DDATunnels.save2Database()
Example #14
0
 def __saveParameters2File(self):
     '''
     save parameters to self.current_path/parameters.df,and revise df_Ff.c
     '''
     import Base
     outfile = open(Base.__currentProjectPath__+'/parameters.df',  'wb' )
     print Base.__currentProjectPath__+'/parameters.df'
     if not outfile:
         showErrorMessageBox('File open failed' , 'Can\'t open parameters.df')
         return
     
     # schema
     from DDADatabase import df_inputDatabase
     paras = df_inputDatabase.paras
     tmpUI = self.__mainWidget.ui
     outfile.write('%f\n%d\n%d\n%d\n%f\n%f\n%f\n'%(paras.ifDynamic\
                     , int(paras.stepsNum) , int(paras.blockMatsNum)\
                     , int(paras.jointMatsNum) , paras.ratio\
                     , paras.OneSteptimeLimit , paras.springStiffness))
     print 'schema store done.'
     
     # fixed points and loading points
     if len(df_inputDatabase.fixedPoints)>0:
         fps = len(df_inputDatabase.fixedPoints)
         outfile.write('0 '*fps )
         print 'fixed points : ' ,fps 
     if len(paras.loadingPointMats)>0:
         for lp in paras.loadingPointMats:
             outfile.write('%d '%len(lp))
         print 'loading points : ' , paras.loadingPointMats 
     outfile.write('\n')
     for lp in paras.loadingPointMats:
         for nums in lp:
             outfile.write( '%f %f %f\n'%tuple(nums))
     print 'fixed points and loading points materials store done.'
      
     # block materials
     for block in paras.blockMats:
         outfile.write( '%f %f %f %f %f\n%f %f %f\n%f %f %f\n%f %f %f\n'%(block[0] ,block[1] ,block[2]\
                            ,block[3] ,block[4] ,block[5] ,block[6] ,block[7] ,block[8] ,block[9] ,block[10]\
                            ,block[11] ,block[12] ,block[13]))
     print 'block materials store done.'
     
     # joints materials
     for joint in paras.jointMats:
         outfile.write( '%f %f %f\n'%(joint[0] ,joint[1] ,joint[2]))
     print 'joint materials store done.'
     
     # rest parameters
     if paras.ifRightHand==1: # right hand
         outfile.write('%s\n0 1 2\n'%str(self.__mainWidget.ui.SORSpinB.value()))
     else:
         outfile.write('%s\n0 0 0\n'%str(self.__mainWidget.ui.SORSpinB.value()))
     print 'all parameters store done.'
     
     # water
     outfile.write('%f\n%d %f\n'%(paras.sectionAngle \
               ,len(paras.waterControlPoints) , paras.waterUnitWeight))
     for nums in paras.waterControlPoints:
         outfile.write('%f %f\n'%tuple(nums))
     outfile.close()
     
     #earthquake
     if not paras.ifRightHand: return
     self.__matsWidget.storeEarthquakeData()
Example #15
0
 def __saveParameters2File(self):
     '''
     save parameters to self.current_path/parameters.df,and revise df_Ff.c
     '''
     import Base
     outfile = open(Base.__currentProjectPath__+'/parameters.df',  'wb' )
     if not outfile:
         showErrorMessageBox('File open failed' , 'Can\'t open parameters.df')
         return
     
     # schema
     tmpUI = self.configUI.ui
     outfile.write('%s\n%s\n%s\n%s\n%s\n%s\n%s\n'%(str(tmpUI.doubleSpinBox_IFStatic.text())\
                     , str(tmpUI.spinBox__NumStep.text()) , str(tmpUI.lineE_BlockNum.text())\
                     , str(tmpUI.lineE_JointNum.text()) , str(tmpUI.spinBox_Ratio.text())\
                     , str(tmpUI.spinBox_timeInterval.text()) , str(tmpUI.spinBox_SpringStiffness.text())))
     print 'schema store done.'
     
     # fixed points and loading points
     from DDADatabase import df_inputDatabase
     if len(df_inputDatabase.fixedPoints)>0:
         fps = len(df_inputDatabase.fixedPoints)
         outfile.write('0 '*fps +'\n')
         print 'fixed points : ' ,fps 
     if len(df_inputDatabase.loadingPoints)>0:
         lps = len(df_inputDatabase.loadingPoints)
         outfile.write('2 '*lps +'\n')
         print 'loading points : ' , lps 
     tmpTable = self.matConfigUI.tableLoadingPointsMats
     nums = [1]*6
     for i in range(len(df_inputDatabase.loadingPoints)):
         for j in range(6):
             nums[j] = str(tmpTable.item(i,j).text())
         outfile.write( '%s %s %s\n%s %s %s\n'%(nums[0] ,nums[1] ,nums[2] ,nums[3] ,nums[4] ,nums[5] ))
     print 'fixed points and loading points materials store done.'
      
     # block materials
     tmpTable = self.matConfigUI.tableBLocksMats
     nums = [1]*14
     for i in range(tmpTable.rowCount()):
         for j in range(14):
             nums[j] = str(tmpTable.item(i,j).text())
         outfile.write( '%s %s %s %s %s\n%s %s %s\n%s %s %s\n%s %s %s\n'%(nums[0] ,nums[1] ,nums[2]\
                            ,nums[3] ,nums[4] ,nums[5] ,nums[6] ,nums[7] ,nums[8] ,nums[9] ,nums[10]\
                            ,nums[11] ,nums[12] ,nums[13]))
     print 'block materials store done.'
     
     # joints materials
     tmpTable = self.matConfigUI.tableJointsMats
     nums = [1]*3
     for i in range(tmpTable.rowCount()):
         for j in range(3):
             nums[j] = str(tmpTable.item(i,j).text())
         outfile.write( '%s %s %s\n'%(nums[0] ,nums[1] ,nums[2]))
     print 'joint materials store done.'
     
     # rest parameters
     outfile.write('%s\n0 0 0'%str(self.configUI.ui.spinBox_SOR.text()))
     print 'all parameters store done.'
     
     outfile.close()
     
     import Base
     outfile = open(Base.__workbenchPath__+'/df_Ff.c' , 'wb')
     outfile.write(str(self.configUI.ui.lineE_Path.text())+'\n')
     outfile.write(Base.__currentProjectPath__+'/parameters.df')
     outfile.close()
Example #16
0
def checkFileExists(path):
    import os
    if not os.path.isfile(path):
        showErrorMessageBox("FileError" , "File \"%s\" doesn't exist"%path)
        return False
    return True
Example #17
0
def checkFileExists(path):
    import os
    if not os.path.isfile(path):
        showErrorMessageBox("FileError" , "File \"%s\" doesn't exist"%path)
        return False
    return True