From 0285dfede9bb8764f9d7a8c0ee95c837e11102f3 Mon Sep 17 00:00:00 2001 From: jriegel Date: Mon, 19 Aug 2013 21:30:56 +0200 Subject: [PATCH] clean up commands in FEM --- src/Mod/Fem/Gui/Command.cpp | 2 +- src/Mod/Fem/Gui/Workbench.cpp | 3 +- src/Mod/Fem/MechanicalAnalysis.py | 12 ++-- src/Mod/Fem/MechanicalAnalysis.ui | 105 ++++-------------------------- src/Mod/Fem/MechanicalMaterial.py | 41 ++++-------- src/Mod/Fem/MechanicalMaterial.ui | 4 +- 6 files changed, 35 insertions(+), 132 deletions(-) diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index e43b7faa7f..4380fc62cc 100755 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -633,7 +633,7 @@ void CreateFemCommands(void) { Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); rcCmdMgr.addCommand(new CmdFemCreateFromShape()); - rcCmdMgr.addCommand(new CmdFemCreateAnalysis()); + //rcCmdMgr.addCommand(new CmdFemCreateAnalysis()); rcCmdMgr.addCommand(new CmdFemAddPart()); rcCmdMgr.addCommand(new CmdFemCreateNodesSet()); rcCmdMgr.addCommand(new CmdFemDefineNodesSet()); diff --git a/src/Mod/Fem/Gui/Workbench.cpp b/src/Mod/Fem/Gui/Workbench.cpp index 5f13fd5248..1291cad2dd 100755 --- a/src/Mod/Fem/Gui/Workbench.cpp +++ b/src/Mod/Fem/Gui/Workbench.cpp @@ -56,7 +56,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const Gui::ToolBarItem* fem = new Gui::ToolBarItem(root); fem->setCommand("FEM"); *fem << "Fem_CreateFromShape" - << "Fem_CreateAnalysis" + << "Fem_NewMechanicalAnalysis" << "Fem_FemAddPart" << "Fem_CreateNodesSet" << "Fem_ConstraintFixed" @@ -78,7 +78,6 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "Fem_MechanicalMaterial" << "Fem_NewMechanicalAnalysis" << "Fem_MechanicalJobControl" - << "Fem_CreateAnalysis" << "Fem_CreateNodesSet" << "Fem_ConstraintFixed" << "Fem_ConstraintForce" diff --git a/src/Mod/Fem/MechanicalAnalysis.py b/src/Mod/Fem/MechanicalAnalysis.py index 49ca9fe6f6..40112306f7 100644 --- a/src/Mod/Fem/MechanicalAnalysis.py +++ b/src/Mod/Fem/MechanicalAnalysis.py @@ -47,7 +47,7 @@ def makeMechanicalAnalysis(name): class _CommandNewMechanicalAnalysis: "the Fem Analysis command definition" def GetResources(self): - return {'Pixmap' : 'Fem_NewAnalysis', + return {'Pixmap' : 'Fem_Analysis', 'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Analysis","New mechanical analysis"), 'Accel': "A", 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Analysis","Create a new mechanical analysis")} @@ -163,13 +163,13 @@ class _ViewProviderFemAnalysis: class _JobControlTaskPanel: '''The editmode TaskPanel for Material objects''' - def __init__(self,object): + def __init__(self): # the panel has a tree widget that contains categories # for the subcomponents, such as additions, subtractions. # the categories are shown only if they are not empty. - form_class, base_class = uic.loadUiType(FreeCAD.getHomePath() + "Mod/Machining_Distortion/JobControl.ui") + form_class, base_class = uic.loadUiType(FreeCAD.getHomePath() + "Mod/Fem/MechanicalAnalysis.ui") - self.obj = object + #self.obj = object self.formUi = form_class() self.form = QtGui.QWidget() self.formUi.setupUi(self.form) @@ -177,7 +177,7 @@ class _JobControlTaskPanel: #Connect Signals and Slots QtCore.QObject.connect(self.formUi.toolButton_chooseOutputDir, QtCore.SIGNAL("clicked()"), self.chooseOutputDir) - QtCore.QObject.connect(self.formUi.pushButton_generate, QtCore.SIGNAL("clicked()"), self.generate) + QtCore.QObject.connect(self.formUi.pushButton_generate, QtCore.SIGNAL("clicked()"), self.run) self.update() @@ -206,8 +206,6 @@ class _JobControlTaskPanel: self.formUi.lineEdit_outputDir.setText(dirname) def run(self): - print "pushButton_generate" - print self.formUi.lineEdit_outputDir.text() dirName = self.formUi.lineEdit_outputDir.text() MeshObject = None diff --git a/src/Mod/Fem/MechanicalAnalysis.ui b/src/Mod/Fem/MechanicalAnalysis.ui index 812e6e7423..b04b907b1c 100644 --- a/src/Mod/Fem/MechanicalAnalysis.ui +++ b/src/Mod/Fem/MechanicalAnalysis.ui @@ -6,118 +6,37 @@ 0 0 - 194 - 142 + 193 + 354 - Form + Mechanical analysis - - - - - choose... - - - - - + + + + - MatWeb database... + ... - - - Qt::Horizontal + + + Run - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - - 60 - 20 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 999999.989999999990687 - - - 70000.000000000000000 - - - - - - - Young Modulus (KPa) - - - - - - - - 0 - 0 - - - - - 60 - 20 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0.100000000000000 - - - 0.300000000000000 - - - - - - - Poisson Ratio - - - - + diff --git a/src/Mod/Fem/MechanicalMaterial.py b/src/Mod/Fem/MechanicalMaterial.py index 3525ded729..1003d4cb53 100644 --- a/src/Mod/Fem/MechanicalMaterial.py +++ b/src/Mod/Fem/MechanicalMaterial.py @@ -33,8 +33,9 @@ __title__="Machine-Distortion FemSetGeometryObject managment" __author__ = "Juergen Riegel" __url__ = "http://free-cad.sourceforge.net" -StartMat = {'FEM_youngsmodulus' :'7000.00', - 'PartDist_poissonratio' :'0.30', +StartMat = {'General_name' :'Steel', + 'Mechanical_youngsmodulus' :'7000.00', + 'FEM_poissonratio' :'0.30', } @@ -64,8 +65,8 @@ class _CommandMechanicalMaterial: if (not MatObj): FreeCAD.ActiveDocument.openTransaction("Create Material") FreeCADGui.addModule("MechanicalMaterial") - FreeCADGui.doCommand("mat = MechanicalMaterial.makeMechanicalMaterial('Material')") - FreeCADGui.doCommand("App.activeDocument()."+FemGui.getActiveAnalysis().Name+".Member = App.activeDocument()."+FemGui.getActiveAnalysis().Name+".Member + [mat]") + FreeCADGui.doCommand("MechanicalMaterial.makeMechanicalMaterial('MechanicalMaterial')") + FreeCADGui.doCommand("App.activeDocument()."+FemGui.getActiveAnalysis().Name+".Member = App.activeDocument()."+FemGui.getActiveAnalysis().Name+".Member + [App.ActiveDocument.activeObject()]") FreeCADGui.doCommand("Gui.activeDocument().setEdit(mat.Name,0)") #FreeCADGui.doCommand("Fem.makeMaterial()") else: @@ -153,8 +154,8 @@ class _MechanicalMaterialTaskPanel: matmap = self.obj.Material - matmap['FEM_youngsmodulus'] = str(self.formUi.spinBox_young_modulus.value()) - matmap['PartDist_poissonratio'] = str(self.formUi.spinBox_poisson_ratio.value()) + matmap['Mechanical_youngsmodulus'] = str(self.formUi.spinBox_young_modulus.value()) + matmap['FEM_poissonratio'] = str(self.formUi.spinBox_poisson_ratio.value()) self.obj.Material = matmap @@ -163,8 +164,10 @@ class _MechanicalMaterialTaskPanel: "Transfer from the object to the dialog" matmap = self.obj.Material - self.formUi.spinBox_young_modulus.setValue(float(matmap['FEM_youngsmodulus'])) - self.formUi.spinBox_poisson_ratio.setValue(float(matmap['PartDist_poissonratio'])) + if matmap.has_key('Mechanical_youngsmodulus'): + self.formUi.spinBox_young_modulus.setValue(float(matmap['Mechanical_youngsmodulus'])) + if matmap.has_key('FEM_poissonratio'): + self.formUi.spinBox_poisson_ratio.setValue(float(matmap['FEM_poissonratio'])) def isAllowedAlterSelection(self): return False @@ -204,11 +207,12 @@ class _MechanicalMaterialTaskPanel: def chooseMat(self,index): if index == 0:return import Material + print index name = self.pathList[index-1] - #print 'Import ', str(name) + print 'Import ', str(name) self.obj.Material = Material.importFCMat(str(name)) - #print self.obj.Material + print self.obj.Material self.transferFrom() @@ -223,22 +227,5 @@ class _MechanicalMaterialTaskPanel: - def parse_R_output(self,filename): - file = open(str(filename)) - lines = file.readlines() - found = False - coeff = [] - for line in lines: - if line[0:9] == "c0 to c5:": - found = True - coeff.append(float(line[15:])) - continue - if found and line[0:4] == "MSE:": - found = False - if found: - coeff.append(float(line[15:])) - - file.close() - return coeff[0],coeff[1],coeff[2],coeff[3],coeff[4],coeff[5] FreeCADGui.addCommand('Fem_MechanicalMaterial',_CommandMechanicalMaterial()) diff --git a/src/Mod/Fem/MechanicalMaterial.ui b/src/Mod/Fem/MechanicalMaterial.ui index f8d4df3fae..7d121ed41c 100644 --- a/src/Mod/Fem/MechanicalMaterial.ui +++ b/src/Mod/Fem/MechanicalMaterial.ui @@ -11,7 +11,7 @@ - Form + Mechanical material @@ -81,7 +81,7 @@ - Young Modulus (KPa) + Young Modulus (kPa)