MachiningDistortionCommands.py

Go to the documentation of this file.
00001 # Machining Distortion Commands
00002 
00003 
00004 # import FreeCAD modules
00005 import FreeCAD, FreeCADGui, Fem, sys
00006 from PyQt4 import QtGui,QtCore
00007 from FreeCAD import Base
00008 
00009 # globals
00010 import mach_dist_gui
00011 import postprocess_gui
00012 import time
00013 
00014 
00015 #---------------------------------------------------------------------------
00016 # The command classes
00017 #---------------------------------------------------------------------------
00018 
00019 class MachiningDistortion_StartGUI:
00020 
00021     def Activated(self):
00022 #        pi=Base.ProgressIndicator()
00023 #        pi.start("Hello, World!",100)
00024 #        for i in range(100):
00025 #            time.sleep(1)
00026 #            pi.next()
00027 #        pi.stop()
00028         myapp = mach_dist_gui.MyForm(QtGui.qApp.activeWindow())
00029         myapp.exec_()
00030 
00031     def GetResources(self):
00032         return {'Pixmap'  : 'Std_Tool1', 'MenuText': 'Open Machining Distortion GUI', 'ToolTip': 'Start Up the main GUI'}
00033 
00034 class MachiningDistortion_StartPostprocess:
00035 
00036     def Activated(self):
00037         app = postprocess_gui.MyForm(QtGui.qApp.activeWindow())
00038         app.exec_()
00039 
00040     def GetResources(self):
00041         return {'Pixmap'  : 'Std_Tool2', 'MenuText': 'Open Machining Distortion Postprocess GUI', 'ToolTip': 'Start Up the postprocess GUI'}
00042 
00043 
00044 class MachiningDistortion_ChooseParameter:
00045     "Start Main GUI"
00046     def Activated(self):
00047         from PyQt4 import QtGui
00048         import PyQt4.uic as uic
00049         form_class, base_class = uic.loadUiType(FreeCAD.getHomePath() + "Mod/MachiningDistortion/User_Interface_Mach_Dist.ui")
00050         # instaciate the UI dialog
00051         form = form_class()
00052         # create the actuall dialog
00053         dlg = QtGui.QDialog()
00054         # set the Ui to the dialog
00055         form.setupUi(dlg)
00056         #run the dialog
00057         rtn = dlg.exec_()
00058         # get the values of the Form
00059         
00060         #Connect Signals and Slots
00061         QtCore.QObject.connect(form.button_select_files, QtCore.SIGNAL("clicked()"), self.select_files)
00062         QtCore.QObject.connect(form.button_select_output, QtCore.SIGNAL("clicked()"), self.select_output)
00063         QtCore.QObject.connect(form.button_dialog, QtCore.SIGNAL("accepted()"), self.onAbbrechen)
00064         QtCore.QObject.connect(form.button_dialog, QtCore.SIGNAL("rejected()"), self.onAbbrechen)
00065         QtCore.QObject.connect(form.button_start_calculation, QtCore.SIGNAL("clicked()"), self.start_calculation)
00066 
00067 
00068     def select_files(self):
00069         filenames=QtGui.QFileDialog.getOpenFileNames(None, 'Open file','','Nastran Files (*.bdf)')
00070 
00071     def select_output(self):
00072         self.dirname=QtGui.QFileDialog.getExistingDirectory(None, 'Open working directory', '', QtGui.QFileDialog.ShowDirsOnly)
00073         self.button_start_calculation.setEnabled(True)
00074 
00075     def onAbbrechen(self):
00076         form.close()
00077 
00078     def start_calculation(self):
00079         ##Get values from the GUI
00080         young_modulus = form.spinBox_young_modulus.value()
00081         poisson_ratio = form.spinBox_poisson_ratio.value()
00082         z_level_from = form.spinBox_z_level_from.value()
00083         z_level_to = form.spinBox_z_level_to.value()
00084         misalignment_x = form.spinBox_misalignment_x.value()
00085         misalignment_y = form.spinBox_misalignment_y.value()
00086         misalignment_z = form.spinBox_misalignment_z.value()
00087         fly_to_buy = form.check_fly_to_buy.isChecked()
00088 
00089 
00090         FreeCAD.Console.PrintMessage("Start with:"+ `misalignment_x` + "\n" )
00091         
00092         
00093     def GetResources(self):
00094         return {'Pixmap'  : 'Std_Tool3', 'MenuText': 'parameters...', 'ToolTip': 'Choose the parameters'}
00095 
00096 
00097 
00098 #---------------------------------------------------------------------------
00099 # Adds the commands to the FreeCAD command manager
00100 #---------------------------------------------------------------------------
00101 
00102 FreeCADGui.addCommand('MachiningDistortion_StartGUI',MachiningDistortion_StartGUI())
00103 FreeCADGui.addCommand('MachiningDistortion_StartPostprocess',MachiningDistortion_StartPostprocess())
00104 FreeCADGui.addCommand('MachiningDistortion_ChooseParameter',MachiningDistortion_ChooseParameter())
00105 

Generated on Wed Nov 23 19:00:20 2011 for FreeCAD by  doxygen 1.6.1