diff --git a/src/Mod/Fem/App/CMakeLists.txt b/src/Mod/Fem/App/CMakeLists.txt old mode 100755 new mode 100644 index f7fa2c5408..7fd859ecbb --- a/src/Mod/Fem/App/CMakeLists.txt +++ b/src/Mod/Fem/App/CMakeLists.txt @@ -109,6 +109,7 @@ SET(FemScripts_SRCS _ViewProviderFemSolverCalculix.py _ViewProviderFemSolverZ88.py _ViewProviderFemMaterial.py + _ViewProviderFemResult.py ccxDatReader.py ccxFrdReader.py convert2TetGen.py @@ -139,6 +140,7 @@ SET(FemScripts_SRCS FemToolsCcx.py FemToolsZ88.py FemMaterial.py + FemResult.py FemSelectionObserver.py TestFem.py TaskPanelFemBeamSection.ui diff --git a/src/Mod/Fem/App/FemResultObject.cpp b/src/Mod/Fem/App/FemResultObject.cpp index 5a793f786a..36b5dfad37 100644 --- a/src/Mod/Fem/App/FemResultObject.cpp +++ b/src/Mod/Fem/App/FemResultObject.cpp @@ -38,8 +38,12 @@ PROPERTY_SOURCE(Fem::FemResultObject, App::DocumentObject) FemResultObject::FemResultObject() { + ADD_PROPERTY_TYPE(Mesh,(0), "General",Prop_None,"Link to the corresponding mesh"); ADD_PROPERTY_TYPE(NodeNumbers,(0), "Data",Prop_None,"Numbers of the result nodes"); ADD_PROPERTY_TYPE(Stats,(0), "Fem",Prop_None,"Statistics of the results"); + ADD_PROPERTY_TYPE(Time,(0), "Fem",Prop_None,"Time of analysis incement"); + + /* ADD_PROPERTY_TYPE(DisplacementVectors,(), "Fem",Prop_None,"List of displacement vectors"); ADD_PROPERTY_TYPE(DisplacementLengths,(0), "Fem",Prop_None,"List of displacement lengths"); ADD_PROPERTY_TYPE(StressVectors,(), "Fem",Prop_None,"List of Stress vectors"); @@ -50,15 +54,16 @@ FemResultObject::FemResultObject() ADD_PROPERTY_TYPE(PrincipalMin,(0), "Fem",Prop_None,"List of Third Principal (Min) stress values"); ADD_PROPERTY_TYPE(MaxShear,(0), "Fem",Prop_None,"List of Maximum Shear stress values"); ADD_PROPERTY_TYPE(Temperature,(0), "Fem",Prop_None,"Nodal temperatures"); - ADD_PROPERTY_TYPE(Mesh,(0), "General",Prop_None,"Link to the corresponding mesh"); ADD_PROPERTY_TYPE(Eigenmode,(0), "Fem",Prop_None,"Number of the eigenmode"); ADD_PROPERTY_TYPE(EigenmodeFrequency,(0), "Fem",Prop_None,"Frequency of the eigenmode"); - ADD_PROPERTY_TYPE(Time,(0), "Fem",Prop_None,"Time of analysis incement"); ADD_PROPERTY_TYPE(UserDefined,(0), "Fem",Prop_None,"User Defined Results"); + */ // make read-only for property editor NodeNumbers.setStatus(App::Property::ReadOnly, true); Stats.setStatus(App::Property::ReadOnly, true); + Time.setStatus(App::Property::ReadOnly, true); + /* DisplacementVectors.setStatus(App::Property::ReadOnly, true); DisplacementLengths.setStatus(App::Property::ReadOnly, true); StressVectors.setStatus(App::Property::ReadOnly, true); @@ -71,8 +76,8 @@ FemResultObject::FemResultObject() Temperature.setStatus(App::Property::ReadOnly, true); Eigenmode.setStatus(App::Property::ReadOnly, true); EigenmodeFrequency.setStatus(App::Property::ReadOnly, true); - Time.setStatus(App::Property::ReadOnly, true); UserDefined.setStatus(App::Property::ReadOnly, false); + * */ } FemResultObject::~FemResultObject() diff --git a/src/Mod/Fem/App/FemResultObject.h b/src/Mod/Fem/App/FemResultObject.h index 1d765385e8..8f3e1feef2 100644 --- a/src/Mod/Fem/App/FemResultObject.h +++ b/src/Mod/Fem/App/FemResultObject.h @@ -46,35 +46,12 @@ public: /// Link to the corresponding mesh App::PropertyLink Mesh; /// Stats of analysis - App::PropertyFloatList Stats; - /// Displacement vectors of analysis - App::PropertyVectorList DisplacementVectors; - /// Lengths of displacement vectors of analysis - App::PropertyFloatList DisplacementLengths; - /// Stress vectors of analysis - App::PropertyVectorList StressVectors; - /// Strain vectors of analysis - App::PropertyVectorList StrainVectors; - /// Von Mises Stress values of analysis - App::PropertyFloatList StressValues; - /// First principal Stress values of analysis - App::PropertyFloatList PrincipalMax; - /// Second principal Stress values of analysis - App::PropertyFloatList PrincipalMed; - /// Third principal Stress values of analysis - App::PropertyFloatList PrincipalMin; - /// Shear Stress values of analysis - App::PropertyFloatList MaxShear; - /// Temperature - App::PropertyFloatList Temperature; - /// Eigenmode - App::PropertyInteger Eigenmode; - /// Eigenmode frequency - App::PropertyFloat EigenmodeFrequency; - /// Increment time App::PropertyFloat Time; /// User defined results - App::PropertyFloatList UserDefined; + App::PropertyFloatList Stats; + /// Displacement vectors of analysis + + /// returns the type name of the ViewProvider virtual const char* getViewProviderName(void) const { diff --git a/src/Mod/Fem/CMakeLists.txt b/src/Mod/Fem/CMakeLists.txt index 7fe32b3cba..e42622e5ff 100755 --- a/src/Mod/Fem/CMakeLists.txt +++ b/src/Mod/Fem/CMakeLists.txt @@ -126,6 +126,8 @@ INSTALL( # additional imports and exports importVTKResults.py + FemResult.py + _ViewProviderFemResult.py DESTINATION Mod/Fem diff --git a/src/Mod/Fem/FemResult.py b/src/Mod/Fem/FemResult.py new file mode 100644 index 0000000000..07ac709f21 --- /dev/null +++ b/src/Mod/Fem/FemResult.py @@ -0,0 +1,90 @@ +#*************************************************************************** +#* * +#* Copyright (c) 2016 - Qingfeng Xia * +#* * +#* This program is free software; you can redistribute it and/or modify * +#* it under the terms of the GNU Lesser General Public License (LGPL) * +#* as published by the Free Software Foundation; either version 2 of * +#* the License, or (at your option) any later version. * +#* for detail see the LICENCE text file. * +#* * +#* This program is distributed in the hope that it will be useful, * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +#* GNU Library General Public License for more details. * +#* * +#* You should have received a copy of the GNU Library General Public * +#* License along with this program; if not, write to the Free Software * +#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +#* USA * +#* * +#*************************************************************************** + +__title__ = "DocumentOject Class to hold Fem result" +__author__ = "Qingfeng Xia" +__url__ = "http://www.freecadweb.org" + +import FreeCAD +import Fem + +def makeFemResult(result_obj_name): + obj= FreeCAD.ActiveDocument.addObject('Fem::FemResultObjectPython', result_obj_name) + # detect domain later, CFD or Mechanical later + _MechanicalResult(obj) + if FreeCAD.GuiUp: + from _ViewProviderFemResult import _ViewProviderFemResult + _ViewProviderFemResult(obj.ViewObject) + return obj + +class _MechanicalResult(object): + def __init__(self, obj): + self.Type = "MechanicalResult" + self.Object = obj # keep a ref to the DocObj for nonGui usage + obj.Proxy = self # link between App::DocumentObject to this object + + # `Time, Stats` should have been defined in base cpp class + obj.addProperty("App::PropertyVectorList", "DisplacementVectors", "Fem", + "List of displacement vectors", True) # does not show up in propertyEditor of combiView + obj.addProperty("App::PropertyVectorList", "StressVectors", "Fem", + "List of stress vectors", True) # does not show up in propertyEditor of combiView + obj.addProperty("App::PropertyVectorList", "StrainVectors", "Fem", + "List of strain vectors", True) # does not show up in propertyEditor of combiView + obj.addProperty("App::PropertyFloatList", "DisplacementLengths", "Fem", + "List of displacement lengths", True) # readonly in propertyEditor of combiView + obj.addProperty("App::PropertyFloatList", "StressValues", "Fem", + "", True) + obj.addProperty("App::PropertyFloatList", "PrincipalMax", "Fem", + "", True) + obj.addProperty("App::PropertyFloatList", "PrincipalMed", "Fem", + "", True) + obj.addProperty("App::PropertyFloatList", "PrincipalMin", "Fem", + "", True) + obj.addProperty("App::PropertyFloatList", "MaxShear", "Fem", + "List of Maximum Shear stress values", True) + obj.addProperty("App::PropertyFloatList", "UserDefined", "Fem", + "User Defined Results", True) + # temperature field is needed in the thermal stress analysis + obj.addProperty("App::PropertyFloatList", "Temperature", "Fem", + "Temperature field", True) + # for frequency analysis + obj.addProperty("App::PropertyInteger", "Eigenmode", "Fem", + "", True) + obj.addProperty("App::PropertyFloat", "EigenmodeFrequency", "Fem", + "User Defined Results", True) + + ############ standard FeutureT methods ########## + def execute(self, obj): + """"this method is executed on object creation and whenever the document is recomputed" + update Part or Mesh should NOT lead to recompution of the analysis automatically, time consuming + """ + return + + def onChanged(self, obj, prop): + return + + def __getstate__(self): + return self.Type + + def __setstate__(self, state): + if state: + self.Type = state diff --git a/src/Mod/Fem/Gui/ViewProviderResult.cpp b/src/Mod/Fem/Gui/ViewProviderResult.cpp index 61516e846d..1059b0259a 100644 --- a/src/Mod/Fem/Gui/ViewProviderResult.cpp +++ b/src/Mod/Fem/Gui/ViewProviderResult.cpp @@ -45,12 +45,13 @@ ViewProviderResult::~ViewProviderResult() } +/* not needed since _ViewProviderFemResult.py is made bool ViewProviderResult::doubleClicked(void) { Gui::Command::runCommand(Gui::Command::Gui, "Gui.runCommand('Fem_ShowResult')"); return true; } - +*/ // Python feature ----------------------------------------------------------------------- diff --git a/src/Mod/Fem/Gui/ViewProviderResult.h b/src/Mod/Fem/Gui/ViewProviderResult.h index 8edcd04d7d..9b43c57acc 100644 --- a/src/Mod/Fem/Gui/ViewProviderResult.h +++ b/src/Mod/Fem/Gui/ViewProviderResult.h @@ -45,7 +45,7 @@ public: virtual bool isShow(void) const { return true; } - bool doubleClicked(void); + //bool doubleClicked(void); }; typedef Gui::ViewProviderPythonFeatureT ViewProviderResultPython; diff --git a/src/Mod/Fem/_ViewProviderFemResult.py b/src/Mod/Fem/_ViewProviderFemResult.py new file mode 100644 index 0000000000..d28d09f908 --- /dev/null +++ b/src/Mod/Fem/_ViewProviderFemResult.py @@ -0,0 +1,78 @@ +#*************************************************************************** +#* * +#* Copyright (c) 2015 - Qingfeng Xia * +#* * +#* This program is free software; you can redistribute it and/or modify * +#* it under the terms of the GNU Lesser General Public License (LGPL) * +#* as published by the Free Software Foundation; either version 2 of * +#* the License, or (at your option) any later version. * +#* for detail see the LICENCE text file. * +#* * +#* This program is distributed in the hope that it will be useful, * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +#* GNU Library General Public License for more details. * +#* * +#* You should have received a copy of the GNU Library General Public * +#* License along with this program; if not, write to the Free Software * +#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +#* USA * +#* * +#*************************************************************************** + +__title__ = "ViewProvider for Fem ResultObjectPython" +__author__ = "Qingfeng Xia" +__url__ = "http://www.freecadweb.org" + +import FreeCAD +import FreeCADGui +import FemGui + +class _ViewProviderFemResult: + """A View Provider for the FemResultObject Python dervied FemResult class + """ + + def __init__(self, vobj): + vobj.Proxy = self + + def getIcon(self): + """after load from FCStd file, self.icon does not exist, return constant path instead""" + return ":/icons/fem-result.svg" + + def attach(self, vobj): + self.ViewObject = vobj + self.Object = vobj.Object + + def updateData(self, obj, prop): + return + + def onChanged(self, vobj, prop): + return + + def doubleClicked(self, vobj): + if FreeCADGui.activeWorkbench().name() != 'FemWorkbench': + FreeCADGui.activateWorkbench("FemWorkbench") + doc = FreeCADGui.getDocument(vobj.Object.Document) + if not doc.getInEdit(): + doc.setEdit(vobj.Object.Name) + else: + FreeCAD.Console.PrintError('Active Task Dialog found! Please close this one first!\n') + return True + + def setEdit(self, vobj, mode): + #if FemGui.getActiveAnalysis(): + from _TaskPanelShowResult import _TaskPanelShowResult + taskd = _TaskPanelShowResult() + taskd.obj = vobj.Object + FreeCADGui.Control.showDialog(taskd) + return True + + def unsetEdit(self, vobj, mode): + FreeCADGui.Control.closeDialog() + return + + def __getstate__(self): + return None + + def __setstate__(self, state): + return None