From dc224265fa0c0fed4e88eb881b1e7d4968ca6fa9 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Tue, 13 Oct 2015 14:13:21 +0200 Subject: [PATCH 1/8] Sketcher: Bug fix: Constraints dissapear after a sketch loses support ===================================================================== Issue: http://freecadweb.org/tracker/view.php?id=2292 Constraints dissapear after a sketch loses support Steps To Reproduce: 1. Make a sketch on a face. 2. Constrain it 3. Select "reorient sketch" 4. Do you want to lose support? Yes 5. Click cancel on the reorientation dialog. 6. Enter edit mode: No constraints... Why? GeoUndef not checked when deleting all external geometry (on dettaching from the support). Solution: Check for GeoUndef. --- src/Mod/Sketcher/App/SketchObject.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index c5fc2703a..646321f54 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -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::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); From f1f67b229801bca1127f1354dccc333d5ab460d2 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Sat, 10 Oct 2015 14:28:42 +0100 Subject: [PATCH 2/8] FEM: Add FemCommand class and use it in _CommandFrequencyAnalysis FemCommand class will gather all common functions/propertied od FEM gui commands. That should allow to reduce some common code. Signed-off-by: Przemo Firszt --- src/Mod/Fem/App/CMakeLists.txt | 1 + src/Mod/Fem/CMakeLists.txt | 1 + src/Mod/Fem/FemCommands.py | 55 ++++++++++++++++++++++++ src/Mod/Fem/Gui/AppFemGui.cpp | 2 + src/Mod/Fem/_CommandFrequencyAnalysis.py | 45 ++++++++++++++----- 5 files changed, 94 insertions(+), 10 deletions(-) create mode 100644 src/Mod/Fem/FemCommands.py diff --git a/src/Mod/Fem/App/CMakeLists.txt b/src/Mod/Fem/App/CMakeLists.txt index 6d64ae9c6..309c1b29c 100755 --- a/src/Mod/Fem/App/CMakeLists.txt +++ b/src/Mod/Fem/App/CMakeLists.txt @@ -82,6 +82,7 @@ SET(FemScripts_SRCS MechanicalMaterial.ui MechanicalMaterial.py ShowDisplacement.ui + FemCommands.py _ResultControlTaskPanel.py _JobControlTaskPanel.py _ViewProviderFemAnalysis.py diff --git a/src/Mod/Fem/CMakeLists.txt b/src/Mod/Fem/CMakeLists.txt index 607b0d180..73de859b0 100755 --- a/src/Mod/Fem/CMakeLists.txt +++ b/src/Mod/Fem/CMakeLists.txt @@ -24,6 +24,7 @@ INSTALL( MechanicalMaterial.ui MechanicalAnalysis.ui ShowDisplacement.ui + FemCommands.py _ResultControlTaskPanel.py _JobControlTaskPanel.py _ViewProviderFemAnalysis.py diff --git a/src/Mod/Fem/FemCommands.py b/src/Mod/Fem/FemCommands.py new file mode 100644 index 000000000..a3a7e6c80 --- /dev/null +++ b/src/Mod/Fem/FemCommands.py @@ -0,0 +1,55 @@ +#*************************************************************************** +#* * +#* 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 + return active diff --git a/src/Mod/Fem/Gui/AppFemGui.cpp b/src/Mod/Fem/Gui/AppFemGui.cpp index dc427f658..c8e621f3d 100644 --- a/src/Mod/Fem/Gui/AppFemGui.cpp +++ b/src/Mod/Fem/Gui/AppFemGui.cpp @@ -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"); diff --git a/src/Mod/Fem/_CommandFrequencyAnalysis.py b/src/Mod/Fem/_CommandFrequencyAnalysis.py index aa3a29165..0f2ebb88c 100644 --- a/src/Mod/Fem/_CommandFrequencyAnalysis.py +++ b/src/Mod/Fem/_CommandFrequencyAnalysis.py @@ -1,18 +1,46 @@ +#*************************************************************************** +#* * +#* Copyright (c) 2013-2015 - Juergen Riegel * +#* * +#* 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()) From 044c16d218faf897401c2b463b34ac56e6c9df01 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Mon, 12 Oct 2015 21:48:01 +0100 Subject: [PATCH 3/8] FEM: Migrate _CommandNewMechanicalAnalysis to FemCommands Signed-off-by: Przemo Firszt --- src/Mod/Fem/_CommandNewMechanicalAnalysis.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Mod/Fem/_CommandNewMechanicalAnalysis.py b/src/Mod/Fem/_CommandNewMechanicalAnalysis.py index 82317cdf6..3d41f404f 100644 --- a/src/Mod/Fem/_CommandNewMechanicalAnalysis.py +++ b/src/Mod/Fem/_CommandNewMechanicalAnalysis.py @@ -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()) From 217103affb66cb37f8fb9d9a3987b65999fa88c3 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Tue, 13 Oct 2015 10:41:38 +0100 Subject: [PATCH 4/8] FEM: Migrate _CommandPurgeFemResults to FemCommands and add new is_active type Signed-off-by: Przemo Firszt --- src/Mod/Fem/FemCommands.py | 10 +++++++++ src/Mod/Fem/_CommandPurgeFemResults.py | 28 +++++++++----------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Mod/Fem/FemCommands.py b/src/Mod/Fem/FemCommands.py index a3a7e6c80..2c959d12f 100644 --- a/src/Mod/Fem/FemCommands.py +++ b/src/Mod/Fem/FemCommands.py @@ -52,4 +52,14 @@ class FemCommands(object): 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() 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 diff --git a/src/Mod/Fem/_CommandPurgeFemResults.py b/src/Mod/Fem/_CommandPurgeFemResults.py index 3e6993f87..16331923d 100644 --- a/src/Mod/Fem/_CommandPurgeFemResults.py +++ b/src/Mod/Fem/_CommandPurgeFemResults.py @@ -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()) From 1ad481b43531d7119fc69829f71b2852f0120476 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Tue, 13 Oct 2015 14:11:48 +0100 Subject: [PATCH 5/8] FEM: Migrate _CommandFemFromShape to FemCommands and add new is_active type Signed-off-by: Przemo Firszt --- src/Mod/Fem/FemCommands.py | 9 +++++++++ src/Mod/Fem/_CommandFemFromShape.py | 18 ++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/Mod/Fem/FemCommands.py b/src/Mod/Fem/FemCommands.py index 2c959d12f..2fdf417a9 100644 --- a/src/Mod/Fem/FemCommands.py +++ b/src/Mod/Fem/FemCommands.py @@ -54,6 +54,8 @@ class FemCommands(object): 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): @@ -63,3 +65,10 @@ class FemCommands(object): 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 diff --git a/src/Mod/Fem/_CommandFemFromShape.py b/src/Mod/Fem/_CommandFemFromShape.py index d1c3f5977..99e8bc21a 100644 --- a/src/Mod/Fem/_CommandFemFromShape.py +++ b/src/Mod/Fem/_CommandFemFromShape.py @@ -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()) From 6725c540a6efeaac2e231204b50043bd38d547e0 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Tue, 13 Oct 2015 15:25:57 +0100 Subject: [PATCH 6/8] FEM: Migrate _CommandMechanicalJobControl to FemCommands Signed-off-by: Przemo Firszt --- src/Mod/Fem/_CommandMechanicalJobControl.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Mod/Fem/_CommandMechanicalJobControl.py b/src/Mod/Fem/_CommandMechanicalJobControl.py index aeac10499..2f4182470 100644 --- a/src/Mod/Fem/_CommandMechanicalJobControl.py +++ b/src/Mod/Fem/_CommandMechanicalJobControl.py @@ -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()) From b122cb5866d609d1e55a5210c2b055a068f62c79 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Tue, 13 Oct 2015 15:26:20 +0100 Subject: [PATCH 7/8] FEM: Migrate _CommandMechanicalShowResult to FemCommands Signed-off-by: Przemo Firszt --- src/Mod/Fem/_CommandMechanicalShowResult.py | 29 +++++++-------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/Mod/Fem/_CommandMechanicalShowResult.py b/src/Mod/Fem/_CommandMechanicalShowResult.py index 039576523..9796da791 100644 --- a/src/Mod/Fem/_CommandMechanicalShowResult.py +++ b/src/Mod/Fem/_CommandMechanicalShowResult.py @@ -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): From cddb6aa390ce5c29727c9c9da168d750de810896 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Tue, 13 Oct 2015 15:26:37 +0100 Subject: [PATCH 8/8] FEM: Migrate _CommandQuickAnalysis to FemCommands Signed-off-by: Przemo Firszt --- src/Mod/Fem/_CommandQuickAnalysis.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Mod/Fem/_CommandQuickAnalysis.py b/src/Mod/Fem/_CommandQuickAnalysis.py index b401d50ba..0c574d5db 100644 --- a/src/Mod/Fem/_CommandQuickAnalysis.py +++ b/src/Mod/Fem/_CommandQuickAnalysis.py @@ -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())