From dbed1e35e591d4d374411414bd6418ef16bc422a Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Wed, 6 Aug 2014 19:33:55 -0300 Subject: [PATCH 1/5] Draft: small fix in Array object --- src/Mod/Draft/Draft.py | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 72c3e30a2af7..9ccc3303a562 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -4439,32 +4439,6 @@ def __init__(self,obj): obj.Angle = 360 obj.Axis = Vector(0,0,1) - def onChanged(self,obj,prop): - if prop == "ArrayType": - if obj.ViewObject: - if obj.ArrayType == "ortho": - obj.ViewObject.setEditorMode('Axis',2) - obj.ViewObject.setEditorMode('NumberPolar',2) - obj.ViewObject.setEditorMode('Center',2) - obj.ViewObject.setEditorMode('Angle',2) - obj.ViewObject.setEditorMode('NumberX',0) - obj.ViewObject.setEditorMode('NumberY',0) - obj.ViewObject.setEditorMode('NumberZ',0) - obj.ViewObject.setEditorMode('IntervalX',0) - obj.ViewObject.setEditorMode('IntervalY',0) - obj.ViewObject.setEditorMode('IntervalZ',0) - else: - obj.ViewObject.setEditorMode('Axis',0) - obj.ViewObject.setEditorMode('NumberPolar',0) - obj.ViewObject.setEditorMode('Center',0) - obj.ViewObject.setEditorMode('Angle',0) - obj.ViewObject.setEditorMode('NumberX',2) - obj.ViewObject.setEditorMode('NumberY',2) - obj.ViewObject.setEditorMode('NumberY',2) - obj.ViewObject.setEditorMode('IntervalX',2) - obj.ViewObject.setEditorMode('IntervalY',2) - obj.ViewObject.setEditorMode('IntervalZ',2) - def execute(self,obj): import DraftGeomUtils if obj.Base: @@ -4520,8 +4494,7 @@ def polarArray(self,shape,center,angle,num,axis,axisvector): nshape.rotate(DraftVecUtils.tup(center), DraftVecUtils.tup(axis), currangle) if axisvector: if not DraftVecUtils.isNull(axisvector): - if i > 0: - nshape.translate(FreeCAD.Vector(axisvector).multiply(i)) + nshape.translate(FreeCAD.Vector(axisvector).multiply(i+1)) base.append(nshape) return Part.makeCompound(base) From c66de2f8cb6c69aba6449eaff2c7902933a52eab Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Wed, 6 Aug 2014 19:55:26 -0300 Subject: [PATCH 2/5] Draft: fix in SelectGroup tool - fixes #1568 --- src/Mod/Draft/DraftTools.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Mod/Draft/DraftTools.py b/src/Mod/Draft/DraftTools.py index 4a069714a9aa..0f02a7b95908 100644 --- a/src/Mod/Draft/DraftTools.py +++ b/src/Mod/Draft/DraftTools.py @@ -3868,10 +3868,10 @@ def Activated(self): for ob in sel: for child in ob.OutList: FreeCADGui.Selection.addSelection(child) - for parent in ob.InList: - FreeCADGui.Selection.addSelection(parent) - for child in parent.OutList: - FreeCADGui.Selection.addSelection(child) + for parent in ob.InList: + FreeCADGui.Selection.addSelection(parent) + for child in parent.OutList: + FreeCADGui.Selection.addSelection(child) class Shape2DView(Modifier): From e0bdc07c4dc64c76c6427fb8d78a32a1d038cfa7 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 7 Aug 2014 10:38:41 -0300 Subject: [PATCH 3/5] Fixed output of ViewObject attribute in console mode --- src/App/DocumentObjectPyImp.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index c8d490c2fdcb..902493e3692e 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -98,6 +98,10 @@ Py::Object DocumentObjectPy::getViewObject(void) const { try { Py::Module module(PyImport_ImportModule("FreeCADGui"),true); + if (!module.hasAttr("getDocument")) { + // in v0.14+, the GUI module can be loaded in console mode (but doesn't have all its document methods) + return Py::None(); + } Py::Callable method(module.getAttr("getDocument")); Py::Tuple arg(1); arg.setItem(0, Py::String(getDocumentObjectPtr()->getDocument()->getName())); From dc3ebfb502378dd3e0ff9b885f65259363b6ddc1 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 7 Aug 2014 10:39:33 -0300 Subject: [PATCH 4/5] Fix in Drawing page object - fixes #1540 * Changing the editable texts updates the page automatically * Added a doc.recompute() after creating a new page --- src/Mod/Drawing/App/FeaturePage.cpp | 8 ++++++-- src/Mod/Drawing/Gui/Command.cpp | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Mod/Drawing/App/FeaturePage.cpp b/src/Mod/Drawing/App/FeaturePage.cpp index e8c78797f367..79a1b3478cf9 100644 --- a/src/Mod/Drawing/App/FeaturePage.cpp +++ b/src/Mod/Drawing/App/FeaturePage.cpp @@ -76,8 +76,12 @@ void FeaturePage::onChanged(const App::Property* prop) if (!fi.exists()) return; } - } - if (prop == &Template) { + } else if (prop == &EditableTexts) { + if (!this->isRestoring()) { + this->execute(); + return; + } + } else if (prop == &Template) { if (!this->isRestoring()) { EditableTexts.setValues(getEditableTextsFromTemplate()); } diff --git a/src/Mod/Drawing/Gui/Command.cpp b/src/Mod/Drawing/Gui/Command.cpp index 45415285c883..d8d4be7f4f69 100644 --- a/src/Mod/Drawing/Gui/Command.cpp +++ b/src/Mod/Drawing/Gui/Command.cpp @@ -104,6 +104,7 @@ void CmdDrawingNewPage::activated(int iMsg) openCommand("Drawing create page"); doCommand(Doc,"App.activeDocument().addObject('Drawing::FeaturePage','%s')",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.Template = '%s'",FeatName.c_str(), (const char*)tfi.filePath().toUtf8()); + doCommand(Doc,"App.activeDocument().recompute()"); commitCommand(); } else { @@ -231,6 +232,7 @@ void CmdDrawingNewA3Landscape::activated(int iMsg) openCommand("Drawing create page"); doCommand(Doc,"App.activeDocument().addObject('Drawing::FeaturePage','%s')",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.Template = 'A3_Landscape.svg'",FeatName.c_str()); + doCommand(Doc,"App.activeDocument().recompute()"); commitCommand(); } From 3c0c72e4c00acb1e3d8b2c8ff97ef8063c59e9c7 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 7 Aug 2014 11:07:22 -0300 Subject: [PATCH 5/5] Draft: removed macros menu - fixes #490 The macros menu code is on http://www.freecadweb.org/wiki/index.php?title=Macro_MacroMenu --- src/Mod/Draft/CMakeLists.txt | 1 - src/Mod/Draft/InitGui.py | 2 +- src/Mod/Draft/macros.py | 54 ------------------------------------ 3 files changed, 1 insertion(+), 56 deletions(-) delete mode 100644 src/Mod/Draft/macros.py diff --git a/src/Mod/Draft/CMakeLists.txt b/src/Mod/Draft/CMakeLists.txt index 95a21c33f810..8d49098e2e8a 100644 --- a/src/Mod/Draft/CMakeLists.txt +++ b/src/Mod/Draft/CMakeLists.txt @@ -15,7 +15,6 @@ SET(Draft_SRCS importSVG.py importDWG.py importAirfoilDAT.py - macros.py Draft_rc.py TestDraft.py ) diff --git a/src/Mod/Draft/InitGui.py b/src/Mod/Draft/InitGui.py index 210e348e9f36..d09bb65c23a2 100644 --- a/src/Mod/Draft/InitGui.py +++ b/src/Mod/Draft/InitGui.py @@ -95,7 +95,7 @@ def QT_TRANSLATE_NOOP(scope, text): # import Draft tools, icons and macros menu try: - import os,macros,Draft_rc,DraftTools, DraftGui + import os,Draft_rc,DraftTools, DraftGui from DraftTools import translate FreeCADGui.addLanguagePath(":/translations") FreeCADGui.addIconPath(":/icons") diff --git a/src/Mod/Draft/macros.py b/src/Mod/Draft/macros.py deleted file mode 100644 index 1b71af68d807..000000000000 --- a/src/Mod/Draft/macros.py +++ /dev/null @@ -1,54 +0,0 @@ -#*************************************************************************** -#* * -#* Copyright (c) 2009 Yorik van Havre * -#* * -#* 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 * -#* * -#*************************************************************************** - -import os,FreeCAD,FreeCADGui - -macrosList = [] -macroPath = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro").GetString("MacroPath") - -class MacroCommand(): - "A template for macro commands" - def __init__(self,macroname): - self.macroname = macroname - - def GetResources(self): - return {'Pixmap' : 'Draft_Macro', - 'MenuText': self.macroname, - 'ToolTip': 'Executes the '+self.macroname+' macro'} - - def Activated(self): - target = macroPath+os.sep+self.macroname+'.FCMacro' - if os.path.exists(target): execfile(target) - - -if macroPath and os.path.isdir(macroPath): - macros = [] - for f in os.listdir(macroPath): - if ".FCMacro" in f: - macros.append(f[:-8]) - for m in macros: - cmd = 'Macro_'+m - FreeCADGui.addCommand(cmd,MacroCommand(m)) - macrosList.append(cmd) - - -