Merge branch 'master' of github.com:FreeCAD/FreeCAD

This commit is contained in:
Yorik van Havre 2015-10-13 16:44:33 -03:00
commit 167b094258
12 changed files with 170 additions and 91 deletions

View File

@ -82,6 +82,7 @@ SET(FemScripts_SRCS
MechanicalMaterial.ui
MechanicalMaterial.py
ShowDisplacement.ui
FemCommands.py
_ResultControlTaskPanel.py
_JobControlTaskPanel.py
_ViewProviderFemAnalysis.py

View File

@ -24,6 +24,7 @@ INSTALL(
MechanicalMaterial.ui
MechanicalAnalysis.ui
ShowDisplacement.ui
FemCommands.py
_ResultControlTaskPanel.py
_JobControlTaskPanel.py
_ViewProviderFemAnalysis.py

View File

@ -0,0 +1,74 @@
#***************************************************************************
#* *
#* Copyright (c) 2015 - FreeCAD Developers *
#* Author (c) 2015 - Przemo Fiszt < przemo@firszt.eu> *
#* *
#* 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__ = "Fem Commands"
__author__ = "Przemo Firszt"
__url__ = "http://www.freecadweb.org"
import FreeCAD
if FreeCAD.GuiUp:
import FreeCADGui
import FemGui
from PySide import QtCore
class FemCommands(object):
def __init__(self):
self.resources = {'Pixmap': 'fem-frequency-analysis',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Command", "Default Fem Command MenuText"),
'Accel': "",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Command", "Default Fem Command ToolTip")}
#FIXME add option description
self.is_active = None
def GetResources(self):
return self.resources
def IsActive(self):
if not self.is_active:
active = False
elif self.is_active == 'with_document':
active = FreeCADGui.ActiveDocument is not None
elif self.is_active == 'with_analysis':
active = FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None
elif self.is_active == 'with_results':
active = FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None and self.results_present()
elif self.is_active == 'with_part_feature':
active = FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None and self.part_feature_selected()
return active
def results_present(self):
results = False
analysis_members = FemGui.getActiveAnalysis().Member
for o in analysis_members:
if o.isDerivedFrom('Fem::FemResultObject'):
results = True
return results
def part_feature_selected(self):
sel = FreeCADGui.Selection.getSelection()
if len(sel) == 1 and sel[0].isDerivedFrom("Part::Feature"):
return True
else:
return False

View File

@ -102,6 +102,8 @@ void FemGuiExport initFemGui()
FemGui::ViewProviderResult ::init();
FemGui::ViewProviderResultPython ::init();
Base::Interpreter().loadModule("FemCommands");
Base::Interpreter().loadModule("_CommandMechanicalShowResult");
Base::Interpreter().loadModule("_CommandFrequencyAnalysis");
Base::Interpreter().loadModule("_CommandQuickAnalysis");

View File

@ -25,17 +25,20 @@ __author__ = "Juergen Riegel"
__url__ = "http://www.freecadweb.org"
import FreeCAD
from FemCommands import FemCommands
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore
class _CommandFemFromShape:
def GetResources(self):
return {'Pixmap': 'fem-fem-mesh-from-shape',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_CreateFromShape", "Create FEM mesh"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_CreateFromShape", "Create FEM mesh from shape")}
class _CommandFemFromShape(FemCommands):
def __init__(self):
super(_CommandFemFromShape, self).__init__()
self.resources = {'Pixmap': 'fem-fem-mesh-from-shape',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_CreateFromShape", "Create FEM mesh"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_CreateFromShape", "Create FEM mesh from shape")}
self.is_active = 'with_part_feature'
def Activated(self):
FreeCAD.ActiveDocument.openTransaction("Create FEM mesh")
@ -50,11 +53,6 @@ class _CommandFemFromShape:
FreeCADGui.Selection.clearSelection()
def IsActive(self):
sel = FreeCADGui.Selection.getSelection()
if len(sel) == 1:
return sel[0].isDerivedFrom("Part::Feature")
return False
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Fem_CreateFromShape', _CommandFemFromShape())

View File

@ -1,18 +1,46 @@
#***************************************************************************
#* *
#* Copyright (c) 2013-2015 - Juergen Riegel <FreeCAD@juergen-riegel.net> *
#* *
#* 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__ = "Command Frequency Analysis"
__author__ = "Juergen Riegel"
__url__ = "http://www.freecadweb.org"
import FreeCAD
from FemCommands import FemCommands
from FemTools import FemTools
if FreeCAD.GuiUp:
import FreeCADGui
import FemGui
from PySide import QtCore, QtGui
class _CommandFrequencyAnalysis:
def GetResources(self):
return {'Pixmap': 'fem-frequency-analysis',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Frequency_Analysis", "Run frequency analysis with CalculiX ccx"),
'Accel': "R, F",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Frequency_Analysis", "Write .inp file and run frequency analysis with CalculiX ccx")}
class _CommandFrequencyAnalysis(FemCommands):
def __init__(self):
super(_CommandFrequencyAnalysis, self).__init__()
self.resources = {'Pixmap': 'fem-frequency-analysis',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Frequency_Analysis", "Run frequency analysis with CalculiX ccx"),
'Accel': "R, F",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Frequency_Analysis", "Write .inp file and run frequency analysis with CalculiX ccx")}
self.is_active = 'with_analysis'
def Activated(self):
def load_results(ret_code):
@ -31,9 +59,6 @@ class _CommandFrequencyAnalysis:
self.fea.finished.connect(load_results)
QtCore.QThreadPool.globalInstance().start(self.fea)
def IsActive(self):
return FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Fem_Frequency_Analysis', _CommandFrequencyAnalysis())

View File

@ -25,6 +25,7 @@ __author__ = "Juergen Riegel"
__url__ = "http://www.freecadweb.org"
import FreeCAD
from FemCommands import FemCommands
if FreeCAD.GuiUp:
import FreeCADGui
@ -32,13 +33,15 @@ if FreeCAD.GuiUp:
from PySide import QtCore
class _CommandMechanicalJobControl:
class _CommandMechanicalJobControl(FemCommands):
"the Fem JobControl command definition"
def GetResources(self):
return {'Pixmap': 'fem-new-analysis',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_JobControl", "Start calculation"),
'Accel': "S, C",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_JobControl", "Dialog to start the calculation of the mechanical anlysis")}
def __init__(self):
super(_CommandMechanicalJobControl, self).__init__()
self.resources = {'Pixmap': 'fem-new-analysis',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_JobControl", "Start calculation"),
'Accel': "S, C",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_JobControl", "Dialog to start the calculation of the mechanical anlysis")}
self.is_active = 'with_analysis'
def Activated(self):
import _JobControlTaskPanel
@ -47,9 +50,6 @@ class _CommandMechanicalJobControl:
taskd.update()
FreeCADGui.Control.showDialog(taskd)
def IsActive(self):
return FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Fem_MechanicalJobControl', _CommandMechanicalJobControl())

View File

@ -25,19 +25,22 @@ __author__ = "Juergen Riegel"
__url__ = "http://www.freecadweb.org"
import FreeCAD
from FemCommands import FemCommands
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore, QtGui
class _CommandMechanicalShowResult:
class _CommandMechanicalShowResult(FemCommands):
"the Fem JobControl command definition"
def GetResources(self):
return {'Pixmap': 'fem-result',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Result", "Show result"),
'Accel': "S, R",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Result", "Show result information of an analysis")}
def __init__(self):
super(_CommandMechanicalShowResult, self).__init__()
self.resources = {'Pixmap': 'fem-result',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Result", "Show result"),
'Accel': "S, R",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Result", "Show result information of an analysis")}
self.is_active = 'with_results'
def Activated(self):
self.result_object = get_results_object(FreeCADGui.Selection.getSelection())
@ -50,20 +53,6 @@ class _CommandMechanicalShowResult:
taskd = _ResultControlTaskPanel._ResultControlTaskPanel()
FreeCADGui.Control.showDialog(taskd)
def IsActive(self):
return FreeCADGui.ActiveDocument is not None and results_present()
#Code duplidation - to be removed after migration to FemTools
def results_present():
import FemGui
results = False
analysis_members = FemGui.getActiveAnalysis().Member
for o in analysis_members:
if o.isDerivedFrom('Fem::FemResultObject'):
results = True
return results
#Code duplidation - to be removed after migration to FemTools
def get_results_object(sel):

View File

@ -25,20 +25,22 @@ __author__ = "Juergen Riegel"
__url__ = "http://www.freecadweb.org"
import FreeCAD
from FemCommands import FemCommands
if FreeCAD.GuiUp:
import FreeCADGui
import FemGui
from PySide import QtCore
class _CommandNewMechanicalAnalysis:
class _CommandNewMechanicalAnalysis(FemCommands):
"the Fem Analysis command definition"
def GetResources(self):
return {'Pixmap': 'fem-analysis',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Analysis", "New mechanical analysis"),
'Accel': "N, A",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Analysis", "Create a new mechanical analysis")}
def __init__(self):
super(_CommandNewMechanicalAnalysis, self).__init__()
self.resources = {'Pixmap': 'fem-analysis',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Analysis", "New mechanical analysis"),
'Accel': "N, A",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Analysis", "Create a new mechanical analysis")}
self.is_active = 'with_document'
def Activated(self):
FreeCAD.ActiveDocument.openTransaction("Create Analysis")
@ -63,9 +65,5 @@ class _CommandNewMechanicalAnalysis:
#FreeCAD.ActiveDocument.commitTransaction()
FreeCADGui.Selection.clearSelection()
def IsActive(self):
return FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is None
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Fem_NewMechanicalAnalysis', _CommandNewMechanicalAnalysis())

View File

@ -25,6 +25,7 @@ __author__ = "Juergen Riegel"
__url__ = "http://www.freecadweb.org"
import FreeCAD
from FemCommands import FemCommands
from FemTools import FemTools
if FreeCAD.GuiUp:
@ -32,30 +33,19 @@ if FreeCAD.GuiUp:
from PySide import QtCore
class _CommandPurgeFemResults:
def GetResources(self):
return {'Pixmap': 'fem-purge-results',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_PurgeResults", "Purge results"),
'Accel': "S, S",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_PurgeResults", "Purge results from an analysis")}
class _CommandPurgeFemResults(FemCommands):
def __init__(self):
super(_CommandPurgeFemResults, self).__init__()
self.resources = {'Pixmap': 'fem-purge-results',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_PurgeResults", "Purge results"),
'Accel': "S, S",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_PurgeResults", "Purge results from an analysis")}
self.is_active = 'with_results'
def Activated(self):
fea = FemTools()
fea.reset_all()
def IsActive(self):
return FreeCADGui.ActiveDocument is not None and results_present()
#Code duplication to be removed after migration to FemTools
def results_present():
import FemGui
results = False
analysis_members = FemGui.getActiveAnalysis().Member
for o in analysis_members:
if o.isDerivedFrom('Fem::FemResultObject'):
results = True
return results
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Fem_PurgeResults', _CommandPurgeFemResults())

View File

@ -26,19 +26,21 @@ __url__ = "http://www.freecadweb.org"
import FreeCAD
from FemTools import FemTools
from FemCommands import FemCommands
if FreeCAD.GuiUp:
import FreeCADGui
import FemGui
from PySide import QtCore, QtGui
class _CommandQuickAnalysis:
def GetResources(self):
return {'Pixmap': 'fem-quick-analysis',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Quick_Analysis", "Run CalculiX ccx"),
'Accel': "R, C",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Quick_Analysis", "Write .inp file and run CalculiX ccx")}
class _CommandQuickAnalysis(FemCommands):
def __init__(self):
super(_CommandQuickAnalysis, self).__init__()
self.resources = {'Pixmap': 'fem-quick-analysis',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Quick_Analysis", "Run CalculiX ccx"),
'Accel': "R, C",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Quick_Analysis", "Write .inp file and run CalculiX ccx")}
self.is_active = 'with_analysis'
def Activated(self):
def load_results(ret_code):
@ -64,9 +66,6 @@ class _CommandQuickAnalysis:
tp = _ResultControlTaskPanel._ResultControlTaskPanel()
tp.restore_result_dialog()
def IsActive(self):
return FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Fem_Quick_Analysis', _CommandQuickAnalysis())

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2008 *
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2008 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@ -2754,7 +2754,9 @@ int SketchObject::delAllExternal()
std::vector< Constraint * > newConstraints(0);
for (std::vector<Constraint *>::const_iterator it = constraints.begin(); it != constraints.end(); ++it) {
if ((*it)->First > -3 && (*it)->Second > -3 && (*it)->Third > -3) {
if ((*it)->First > -3 &&
((*it)->Second > -3 || (*it)->Second == Constraint::GeoUndef ) &&
((*it)->Third > -3 || (*it)->Third == Constraint::GeoUndef) ) {
Constraint *copiedConstr = (*it)->clone();
newConstraints.push_back(copiedConstr);