From 5af75be21bd2c84cb4b6918a4c7f0a07ccbab44d Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 9 Jan 2013 14:09:22 +0100 Subject: [PATCH 01/10] License issues --- src/Gui/iisTaskPanel/tests/styles/main.cpp | 7 ++ src/Gui/iisTaskPanel/tests/styles/styles.cpp | 7 ++ src/Gui/iisTaskPanel/tests/styles/styles.h | 7 ++ src/Gui/iisTaskPanel/tests/test/main.cpp | 7 ++ src/Gui/iisTaskPanel/tests/test/test.cpp | 7 ++ src/Gui/iisTaskPanel/tests/test/test.h | 7 ++ src/Mod/PartDesign/Scripts/Epitrochoid.py | 4 + src/Tools/LicenseChecker.py | 83 ++++++++++++++++++++ 8 files changed, 129 insertions(+) create mode 100644 src/Tools/LicenseChecker.py diff --git a/src/Gui/iisTaskPanel/tests/styles/main.cpp b/src/Gui/iisTaskPanel/tests/styles/main.cpp index 9d4d665476..290bd60e15 100644 --- a/src/Gui/iisTaskPanel/tests/styles/main.cpp +++ b/src/Gui/iisTaskPanel/tests/styles/main.cpp @@ -1,3 +1,10 @@ +/*************************************************************************** + * * + * Copyright: http://www.ii-system.com * + * License: LGPL * + * * + ***************************************************************************/ + #include #include "styles.h" diff --git a/src/Gui/iisTaskPanel/tests/styles/styles.cpp b/src/Gui/iisTaskPanel/tests/styles/styles.cpp index 20477515fe..351e1775e1 100644 --- a/src/Gui/iisTaskPanel/tests/styles/styles.cpp +++ b/src/Gui/iisTaskPanel/tests/styles/styles.cpp @@ -1,3 +1,10 @@ +/*************************************************************************** + * * + * Copyright: http://www.ii-system.com * + * License: LGPL * + * * + ***************************************************************************/ + #include "styles.h" #include diff --git a/src/Gui/iisTaskPanel/tests/styles/styles.h b/src/Gui/iisTaskPanel/tests/styles/styles.h index 5c90969900..714ad56388 100644 --- a/src/Gui/iisTaskPanel/tests/styles/styles.h +++ b/src/Gui/iisTaskPanel/tests/styles/styles.h @@ -1,3 +1,10 @@ +/*************************************************************************** + * * + * Copyright: http://www.ii-system.com * + * License: LGPL * + * * + ***************************************************************************/ + #ifndef TEST_H #define TEST_H diff --git a/src/Gui/iisTaskPanel/tests/test/main.cpp b/src/Gui/iisTaskPanel/tests/test/main.cpp index 32081f9189..9a3c2f7101 100644 --- a/src/Gui/iisTaskPanel/tests/test/main.cpp +++ b/src/Gui/iisTaskPanel/tests/test/main.cpp @@ -1,3 +1,10 @@ +/*************************************************************************** + * * + * Copyright: http://www.ii-system.com * + * License: LGPL * + * * + ***************************************************************************/ + #include #include "test.h" diff --git a/src/Gui/iisTaskPanel/tests/test/test.cpp b/src/Gui/iisTaskPanel/tests/test/test.cpp index e323985bbf..8141183100 100644 --- a/src/Gui/iisTaskPanel/tests/test/test.cpp +++ b/src/Gui/iisTaskPanel/tests/test/test.cpp @@ -1,3 +1,10 @@ +/*************************************************************************** + * * + * Copyright: http://www.ii-system.com * + * License: LGPL * + * * + ***************************************************************************/ + #include "test.h" #include diff --git a/src/Gui/iisTaskPanel/tests/test/test.h b/src/Gui/iisTaskPanel/tests/test/test.h index bb075bca35..f9ec5ec547 100644 --- a/src/Gui/iisTaskPanel/tests/test/test.h +++ b/src/Gui/iisTaskPanel/tests/test/test.h @@ -1,3 +1,10 @@ +/*************************************************************************** + * * + * Copyright: http://www.ii-system.com * + * License: LGPL * + * * + ***************************************************************************/ + #ifndef TEST_H #define TEST_H diff --git a/src/Mod/PartDesign/Scripts/Epitrochoid.py b/src/Mod/PartDesign/Scripts/Epitrochoid.py index 391666b9f7..c6f6335877 100644 --- a/src/Mod/PartDesign/Scripts/Epitrochoid.py +++ b/src/Mod/PartDesign/Scripts/Epitrochoid.py @@ -1,3 +1,7 @@ +#! python +# -*- coding: utf-8 -*- +# (c) 2011 Werner Mayer LGPL +# from __future__ import division # allows floating point division from integers import FreeCAD, Part, math diff --git a/src/Tools/LicenseChecker.py b/src/Tools/LicenseChecker.py new file mode 100644 index 0000000000..f6e97c37d7 --- /dev/null +++ b/src/Tools/LicenseChecker.py @@ -0,0 +1,83 @@ +#! python +# -*- coding: utf-8 -*- +# (c) 2013 Werner Mayer LGPL +# +# Utility to search for source, header and Python files with a missing license text + +import codecs, os + +ext=[".cpp", ".cxx", ".cc", ".c", ".hpp", ".hxx", ".hh", ".h", ".inl", ".inc", ".py"] +flt=['__init__.py', '_rc.py', 'CxImage', + 'coin_header_includes.h', + 'CxxDebug.hxx', + 'IndirectPythonInterface.hxx', + ('src%sTools')%(os.path.sep), + ('App%skdl_cp')%(os.path.sep), + ('3rdParty%satlas')%(os.path.sep), + ('Mod%sGDML')%(os.path.sep), + ('boost%snumeric%sbindings')%(os.path.sep,os.path.sep), + ('salomesmesh%sinc')%(os.path.sep), + ('App%sCore%stritritest.h')%(os.path.sep,os.path.sep) + ] + # A note to tritritest.h + # tritritest.h has no licensing information, but Tomas Moller replied + # the following, when asked about it: + # + # The code is is free to use for anyone and any projects, but I give no + # warranties. + # + # See: http://anonscm.debian.org/gitweb/?p=debian-science/packages/freecad.git;a=blob;f=debian/copyright +lic=['LGPL', + 'GNU Library', + 'GNU Lesser', + 'Permission to copy, use, modify', + 'Permission to use, copy, modify', + 'Distributed under the Boost Software License', + 'Redistribution and use in source and binary forms', + 'This program is free software: you can redistribute it', + 'This module is free software, and you may redistribute it and/or modify', + 'This file was automatically generated by SWIG' + ] + +def startProcessing(): + fn = os.path.realpath(__file__) + # get path of parent directory + fn = os.path.dirname(fn) + fn = os.path.dirname(fn) + global ext + global flt + traverse(fn, ext, flt) + +def traverse(path, ext, flt): + for r,d,f in os.walk(path): + for i in f: + fn = os.path.join(r,i) + # filter out some file names + stop = False + for j in flt: + if fn.find(j) >= 0: + stop=True + break + if stop: + continue + bn = os.path.basename(fn).lower() + for j in ext: + if bn.endswith(j): + parsefile(fn) + break + +def parsefile(fn): + data = codecs.open(fn,'r','utf-8') + try: + lines = data.readlines() + data.close() + + global lic + for i in lines: + for j in lic: + if i.find(j) >= 0: + return + + print ("Missing license text in file %s") % (fn) + except: + pass From 646aa901370745d354d733d17a82ef68adc5e676 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 9 Jan 2013 14:28:47 +0100 Subject: [PATCH 02/10] License issues --- src/Tools/LicenseChecker.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Tools/LicenseChecker.py b/src/Tools/LicenseChecker.py index f6e97c37d7..4cd073a9ed 100644 --- a/src/Tools/LicenseChecker.py +++ b/src/Tools/LicenseChecker.py @@ -34,8 +34,8 @@ lic=['LGPL', 'Permission to use, copy, modify', 'Distributed under the Boost Software License', 'Redistribution and use in source and binary forms', - 'This program is free software: you can redistribute it', - 'This module is free software, and you may redistribute it and/or modify', + 'it under the same terms as Python itself', + 'As a special exception, you may create a larger work that contains', 'This file was automatically generated by SWIG' ] @@ -81,3 +81,6 @@ def parsefile(fn): print ("Missing license text in file %s") % (fn) except: pass + +if __name__ == "__main__": + startProcessing() From 598d21876fd1620fc8a6bd11e0a221aef2d09f24 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 9 Jan 2013 14:56:19 +0100 Subject: [PATCH 03/10] License issues --- src/Tools/LicenseChecker.py | 6 +++++- src/Tools/PythonToCPP.py | 3 +++ src/Tools/encode/lencode.cpp | 3 +++ src/Tools/updateppa.py | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Tools/LicenseChecker.py b/src/Tools/LicenseChecker.py index 4cd073a9ed..40f1b343e5 100644 --- a/src/Tools/LicenseChecker.py +++ b/src/Tools/LicenseChecker.py @@ -11,7 +11,9 @@ flt=['__init__.py', '_rc.py', 'CxImage', 'coin_header_includes.h', 'CxxDebug.hxx', 'IndirectPythonInterface.hxx', - ('src%sTools')%(os.path.sep), + ('thumbs%sIExtractImage.h')%(os.path.sep), + #('src%sTools')%(os.path.sep), + ('src%sTools%sembedded')%(os.path.sep,os.path.sep), ('App%skdl_cp')%(os.path.sep), ('3rdParty%satlas')%(os.path.sep), ('Mod%sGDML')%(os.path.sep), @@ -36,6 +38,8 @@ lic=['LGPL', 'Redistribution and use in source and binary forms', 'it under the same terms as Python itself', 'As a special exception, you may create a larger work that contains', + 'Permission is hereby granted, free of charge, to any person obtaining', + 'Permission is granted to anyone to use this software', 'This file was automatically generated by SWIG' ] diff --git a/src/Tools/PythonToCPP.py b/src/Tools/PythonToCPP.py index 613fcd0521..2f381f4eb6 100644 --- a/src/Tools/PythonToCPP.py +++ b/src/Tools/PythonToCPP.py @@ -1,4 +1,7 @@ #!/usr/bin/python +# -*- coding: utf-8 -*- +# (c) 2004 Werner Mayer LGPL + import os,sys,string #os.chdir("E:\\Develop\\FreeCADWin\\scripts") diff --git a/src/Tools/encode/lencode.cpp b/src/Tools/encode/lencode.cpp index 69337be0ae..170b6735b5 100644 --- a/src/Tools/encode/lencode.cpp +++ b/src/Tools/encode/lencode.cpp @@ -1,3 +1,6 @@ +/* + (c) 2006 Werner Mayer LGPL +*/ #include #include diff --git a/src/Tools/updateppa.py b/src/Tools/updateppa.py index 069c7e6e8f..896a1ede75 100644 --- a/src/Tools/updateppa.py +++ b/src/Tools/updateppa.py @@ -1,3 +1,7 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# (c) 2012 Werner Mayer LGPL + import sys from os import chdir from os import path From 0b2b5cb7f4c1429dd924fdf1b0204e92e93d631c Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 9 Jan 2013 15:03:23 +0100 Subject: [PATCH 04/10] License issues --- src/Tools/LicenseChecker.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Tools/LicenseChecker.py b/src/Tools/LicenseChecker.py index 40f1b343e5..fef97c0503 100644 --- a/src/Tools/LicenseChecker.py +++ b/src/Tools/LicenseChecker.py @@ -36,6 +36,7 @@ lic=['LGPL', 'Permission to use, copy, modify', 'Distributed under the Boost Software License', 'Redistribution and use in source and binary forms', + 'Redistribution and use in source and binary forms', 'it under the same terms as Python itself', 'As a special exception, you may create a larger work that contains', 'Permission is hereby granted, free of charge, to any person obtaining', From 0a876e18c9d80e5caa551ade02bce35cfc5d0751 Mon Sep 17 00:00:00 2001 From: Sebastian Hoogen Date: Thu, 3 Jan 2013 14:45:52 +0100 Subject: [PATCH 05/10] bugfix for handling of elipses in importSVG --- src/Mod/Draft/importSVG.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mod/Draft/importSVG.py b/src/Mod/Draft/importSVG.py index 5bf9de8591..74b98f1faf 100644 --- a/src/Mod/Draft/importSVG.py +++ b/src/Mod/Draft/importSVG.py @@ -887,7 +887,8 @@ class svgHandler(xml.sax.ContentHandler): rot90=FreeCAD.Matrix(0,-1,0,0,1,0) #90 m3=m3.multiply(rot90) m3.move(c.multiply(-1)) - sh.transform(m3) + sh.transformShape(m3) + #sh = sh.transformGeometry(m3) if self.fill: sh = Part.Wire([sh]) sh = Part.Face(sh) From de9c17ec07cae2b18050c86186d782f15468294f Mon Sep 17 00:00:00 2001 From: Sebastian Hoogen Date: Mon, 7 Jan 2013 12:55:59 +0100 Subject: [PATCH 06/10] importCSG reverse polyhedra if they have negative volume --- src/Mod/OpenSCAD/importCSG.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Mod/OpenSCAD/importCSG.py b/src/Mod/OpenSCAD/importCSG.py index ba8ad87bae..9140b29477 100644 --- a/src/Mod/OpenSCAD/importCSG.py +++ b/src/Mod/OpenSCAD/importCSG.py @@ -939,7 +939,10 @@ def p_polyhedron_action(p) : f = make_face(v[int(i[0])],v[int(i[1])],v[int(i[2])]) faces_list.append(f) shell=Part.makeShell(faces_list) - mypolyhed.Shape=Part.Solid(shell) + solid=Part.Solid(shell).removeSplitter() + if solid.Volume < 0: + solid.reverse() + mypolyhed.Shape=solid p[0] = [mypolyhed] def p_projection_action(p) : From d42a7c82ea2b08cc3048faa4b4ca020640d50d62 Mon Sep 17 00:00:00 2001 From: Sebastian Hoogen Date: Wed, 9 Jan 2013 14:09:28 +0100 Subject: [PATCH 07/10] added licences for OpenSCAD module --- src/Mod/OpenSCAD/InitGui.py | 46 ++++++++++++++-------------- src/Mod/OpenSCAD/OpenSCAD2Dgeom.py | 2 +- src/Mod/OpenSCAD/OpenSCADCommands.py | 30 ++++++++++++++++++ src/Mod/OpenSCAD/OpenSCADFeatures.py | 2 +- src/Mod/OpenSCAD/OpenSCADUtils.py | 2 +- src/Mod/OpenSCAD/colorcodeshapes.py | 31 +++++++++++++++++++ src/Mod/OpenSCAD/expandplacements.py | 31 +++++++++++++++++++ src/Mod/OpenSCAD/importCSG.py | 6 ++-- src/Mod/OpenSCAD/prototype.py | 1 - src/Mod/OpenSCAD/replaceobj.py | 30 ++++++++++++++++++ 10 files changed, 151 insertions(+), 30 deletions(-) diff --git a/src/Mod/OpenSCAD/InitGui.py b/src/Mod/OpenSCAD/InitGui.py index 7339c11642..4e91d66db6 100644 --- a/src/Mod/OpenSCAD/InitGui.py +++ b/src/Mod/OpenSCAD/InitGui.py @@ -4,29 +4,29 @@ # This is the second one of three init scripts, the third one # runs when the gui is up -#*************************************************************************** -#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 -#* * -#* This file is part of the FreeCAD CAx development system. * -#* * -#* This program is free software; you can redistribute it and/or modify * -#* it under the terms of the GNU General Public License (GPL) * -#* 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. * -#* * -#* FreeCAD 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 FreeCAD; if not, write to the Free Software * -#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * -#* USA * -#* * -#* Juergen Riegel 2002 * -#***************************************************************************/ +#*************************************************************************** +#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 * +#* * +#* This file is part of the FreeCAD CAx development system. * +#* * +#* 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. * +#* * +#* FreeCAD 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 Lesser General Public License for more details. * +#* * +#* You should have received a copy of the GNU Library General Public * +#* License along with FreeCAD; if not, write to the Free Software * +#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +#* USA * +#* * +#* Juergen Riegel 2002 * +#***************************************************************************/ import FreeCAD param = FreeCAD.ParamGet(\ diff --git a/src/Mod/OpenSCAD/OpenSCAD2Dgeom.py b/src/Mod/OpenSCAD/OpenSCAD2Dgeom.py index 7e6bddc9d0..709c087969 100644 --- a/src/Mod/OpenSCAD/OpenSCAD2Dgeom.py +++ b/src/Mod/OpenSCAD/OpenSCAD2Dgeom.py @@ -1,6 +1,6 @@ #*************************************************************************** #* * -#* Copyright (c) 2012 Sebastian Hoogen * +#* Copyright (c) 2012 Sebastian Hoogen * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * diff --git a/src/Mod/OpenSCAD/OpenSCADCommands.py b/src/Mod/OpenSCAD/OpenSCADCommands.py index 5d85395d06..0637640f0b 100644 --- a/src/Mod/OpenSCAD/OpenSCADCommands.py +++ b/src/Mod/OpenSCAD/OpenSCADCommands.py @@ -1,3 +1,33 @@ +#*************************************************************************** +#* * +#* Copyright (c) 2012 Sebastian Hoogen * +#* * +#* 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__="FreeCAD OpenSCAD Workbench - GUI Commands" +__author__ = "Sebastian Hoogen" +__url__ = ["http://free-cad.sourceforge.net"] + +''' +This Script includes the GUI Commands of the OpenSCAD module +''' + import FreeCAD,FreeCADGui from PyQt4 import QtGui, QtCore diff --git a/src/Mod/OpenSCAD/OpenSCADFeatures.py b/src/Mod/OpenSCAD/OpenSCADFeatures.py index fea2581c9d..6248f8bb84 100644 --- a/src/Mod/OpenSCAD/OpenSCADFeatures.py +++ b/src/Mod/OpenSCAD/OpenSCADFeatures.py @@ -1,6 +1,6 @@ #*************************************************************************** #* * -#* Copyright (c) 2012 Sebastian Hoogen * +#* Copyright (c) 2012 Sebastian Hoogen * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * diff --git a/src/Mod/OpenSCAD/OpenSCADUtils.py b/src/Mod/OpenSCAD/OpenSCADUtils.py index 8f815b1e24..f8fc175537 100644 --- a/src/Mod/OpenSCAD/OpenSCADUtils.py +++ b/src/Mod/OpenSCAD/OpenSCADUtils.py @@ -1,6 +1,6 @@ #*************************************************************************** #* * -#* Copyright (c) 2012 Sebastian Hoogen * +#* Copyright (c) 2012 Sebastian Hoogen * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * diff --git a/src/Mod/OpenSCAD/colorcodeshapes.py b/src/Mod/OpenSCAD/colorcodeshapes.py index c6fb192031..2149534889 100644 --- a/src/Mod/OpenSCAD/colorcodeshapes.py +++ b/src/Mod/OpenSCAD/colorcodeshapes.py @@ -1,3 +1,34 @@ +#*************************************************************************** +#* * +#* Copyright (c) 2012 Sebastian Hoogen * +#* * +#* 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__="FreeCAD OpenSCAD Workbench - 2D helper fuctions" +__author__ = "Sebastian Hoogen" +__url__ = ["http://free-cad.sourceforge.net"] + +''' +This Script includes python functions to ifind out the most basic shape type +in a compound and to change the color of shapes according to thier shape type +''' + import FreeCAD def shapedict(shapelst): return dict([(shape.hashCode(),shape) for shape in shapelst]) diff --git a/src/Mod/OpenSCAD/expandplacements.py b/src/Mod/OpenSCAD/expandplacements.py index b258c499ae..d4c1b9c632 100644 --- a/src/Mod/OpenSCAD/expandplacements.py +++ b/src/Mod/OpenSCAD/expandplacements.py @@ -1,3 +1,34 @@ +#*************************************************************************** +#* * +#* Copyright (c) 2012 Sebastian Hoogen * +#* * +#* 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__="FreeCAD OpenSCAD Workbench - expand placements and matrices fuctions" +__author__ = "Sebastian Hoogen" +__url__ = ["http://free-cad.sourceforge.net"] + +''' +This Script includes python functions to shift all placements down the +feature tree to the most baisc objects +''' + import FreeCAD from OpenSCADFeatures import * from OpenSCADUtils import isspecialorthogonalpython,isspecialorthogonal diff --git a/src/Mod/OpenSCAD/importCSG.py b/src/Mod/OpenSCAD/importCSG.py index 9140b29477..4891e4a1dd 100644 --- a/src/Mod/OpenSCAD/importCSG.py +++ b/src/Mod/OpenSCAD/importCSG.py @@ -416,12 +416,12 @@ def p_difference_action(p): print "difference" print len(p[5]) print p[5] - mycut = doc.addObject('Part::Cut',p[1]) - mycut.Base = p[5][0] if (len(p[5]) == 1 ): #single object p[0] = p[5] else: # Cut using Fuse + mycut = doc.addObject('Part::Cut',p[1]) + mycut.Base = p[5][0] # Can only Cut two objects do we need to fuse extras if (len(p[5]) > 2 ): print "Need to Fuse Extra First" @@ -803,7 +803,7 @@ def p_cylinder_action(p): mycyl.Height = h mycyl.Radius1 = r1 mycyl.Radius2 = r2 - print "Center = ",center + print "Center = ",tocenter if tocenter=='true' : center(mycyl,0,0,h) if False : diff --git a/src/Mod/OpenSCAD/prototype.py b/src/Mod/OpenSCAD/prototype.py index 166bac30c6..f43d1629df 100644 --- a/src/Mod/OpenSCAD/prototype.py +++ b/src/Mod/OpenSCAD/prototype.py @@ -687,7 +687,6 @@ def insert(filename,docname): #doc.recompute() -import FreeCAD global dxfcache dxfcache = {} diff --git a/src/Mod/OpenSCAD/replaceobj.py b/src/Mod/OpenSCAD/replaceobj.py index f5e50fedf7..a4b94e4c06 100644 --- a/src/Mod/OpenSCAD/replaceobj.py +++ b/src/Mod/OpenSCAD/replaceobj.py @@ -1,3 +1,33 @@ +#*************************************************************************** +#* * +#* Copyright (c) 2012 Sebastian Hoogen * +#* * +#* 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__="FreeCAD OpenSCAD Workbench - replace object fuction" +__author__ = "Sebastian Hoogen" +__url__ = ["http://free-cad.sourceforge.net"] + +''' +This fucntions allows to replace an object in the feature hierarchy +''' + def replaceobj(parent,oldchild,newchild): for propname in parent.PropertiesList: propvalue=parent.getPropertyByName(propname) From 9cd5810e154b50feb2e77c0bd9fcbe825865b01b Mon Sep 17 00:00:00 2001 From: Sebastian Hoogen Date: Wed, 9 Jan 2013 14:45:29 +0100 Subject: [PATCH 08/10] add license notice to ply/setup.py --- src/Mod/OpenSCAD/ply/__init__.py | 32 +++++++++++++++++++++++++++++++ src/Mod/OpenSCAD/ply/setup.py | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/src/Mod/OpenSCAD/ply/__init__.py b/src/Mod/OpenSCAD/ply/__init__.py index 853a985542..7aed3b575f 100644 --- a/src/Mod/OpenSCAD/ply/__init__.py +++ b/src/Mod/OpenSCAD/ply/__init__.py @@ -1,3 +1,35 @@ +# ----------------------------------------------------------------------------- +# ply: __init__.py +# +# Copyright (C) 2001-2011, +# David M. Beazley (Dabeaz LLC) +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of the David Beazley or Dabeaz LLC may be used to +# endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ----------------------------------------------------------------------------- # PLY package # Author: David Beazley (dave@dabeaz.com) diff --git a/src/Mod/OpenSCAD/ply/setup.py b/src/Mod/OpenSCAD/ply/setup.py index 670cb3cc2d..ed0a7a1427 100644 --- a/src/Mod/OpenSCAD/ply/setup.py +++ b/src/Mod/OpenSCAD/ply/setup.py @@ -1,3 +1,36 @@ +# ----------------------------------------------------------------------------- +# ply: setup.py +# +# Copyright (C) 2001-2011, +# David M. Beazley (Dabeaz LLC) +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of the David Beazley or Dabeaz LLC may be used to +# endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ----------------------------------------------------------------------------- + try: from setuptools import setup except ImportError: From 525cddaaf32e7e1fc2b07e56eada2a92e106aab9 Mon Sep 17 00:00:00 2001 From: logari81 Date: Wed, 9 Jan 2013 12:59:15 +0100 Subject: [PATCH 09/10] PartDesign: Refactor pattern features and gui - remove StdDirection,StdAxis and StdMirrorPlane properties - support sketch H_Axis, V_Axis, N_axis as valid references in patterns - polish reference selection gui (unified for standard axes and custom references) --- src/Mod/Part/App/Part2DObject.cpp | 4 + src/Mod/Part/App/Part2DObject.h | 1 + .../PartDesign/App/FeatureLinearPattern.cpp | 76 ++++----- src/Mod/PartDesign/App/FeatureLinearPattern.h | 3 - src/Mod/PartDesign/App/FeatureMirrored.cpp | 73 ++++----- src/Mod/PartDesign/App/FeatureMirrored.h | 2 - .../PartDesign/App/FeaturePolarPattern.cpp | 68 ++++---- src/Mod/PartDesign/App/FeaturePolarPattern.h | 2 - src/Mod/PartDesign/App/FeatureSketchBased.cpp | 1 - src/Mod/PartDesign/App/FeatureTransformed.cpp | 9 ++ src/Mod/PartDesign/App/FeatureTransformed.h | 3 + src/Mod/PartDesign/Gui/Command.cpp | 15 +- .../Gui/TaskLinearPatternParameters.cpp | 138 +++++++---------- .../Gui/TaskLinearPatternParameters.h | 7 +- .../Gui/TaskLinearPatternParameters.ui | 28 ++-- .../PartDesign/Gui/TaskMirroredParameters.cpp | 145 +++++++----------- .../PartDesign/Gui/TaskMirroredParameters.h | 7 +- .../PartDesign/Gui/TaskMirroredParameters.ui | 51 +++--- .../Gui/TaskMultiTransformParameters.cpp | 15 +- .../Gui/TaskPolarPatternParameters.cpp | 136 ++++++---------- .../Gui/TaskPolarPatternParameters.h | 6 +- .../Gui/TaskPolarPatternParameters.ui | 48 ++---- .../Gui/TaskTransformedParameters.cpp | 10 ++ .../Gui/TaskTransformedParameters.h | 3 +- src/Mod/Sketcher/App/SketchObject.cpp | 10 +- 25 files changed, 372 insertions(+), 489 deletions(-) diff --git a/src/Mod/Part/App/Part2DObject.cpp b/src/Mod/Part/App/Part2DObject.cpp index 662f0d8729..ecdefd60d6 100644 --- a/src/Mod/Part/App/Part2DObject.cpp +++ b/src/Mod/Part/App/Part2DObject.cpp @@ -53,6 +53,7 @@ using namespace Part; const int Part2DObject::H_Axis = -1; const int Part2DObject::V_Axis = -2; +const int Part2DObject::N_Axis = -3; PROPERTY_SOURCE(Part::Part2DObject, Part::Feature) @@ -215,6 +216,9 @@ Base::Axis Part2DObject::getAxis(int axId) const else if (axId == V_Axis) { return Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,1,0)); } + else if (axId == N_Axis) { + return Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,0,1)); + } return Base::Axis(); } diff --git a/src/Mod/Part/App/Part2DObject.h b/src/Mod/Part/App/Part2DObject.h index 1adf5c14d6..bb4e879d70 100644 --- a/src/Mod/Part/App/Part2DObject.h +++ b/src/Mod/Part/App/Part2DObject.h @@ -92,6 +92,7 @@ public: static const int H_Axis; static const int V_Axis; + static const int N_Axis; /** @name methods overide Feature */ //@{ diff --git a/src/Mod/PartDesign/App/FeatureLinearPattern.cpp b/src/Mod/PartDesign/App/FeatureLinearPattern.cpp index 766a5a0177..09f98141b8 100644 --- a/src/Mod/PartDesign/App/FeatureLinearPattern.cpp +++ b/src/Mod/PartDesign/App/FeatureLinearPattern.cpp @@ -34,8 +34,9 @@ #include "FeatureLinearPattern.h" -#include #include +#include +#include using namespace PartDesign; @@ -47,7 +48,6 @@ PROPERTY_SOURCE(PartDesign::LinearPattern, PartDesign::Transformed) LinearPattern::LinearPattern() { ADD_PROPERTY_TYPE(Direction,(0),"LinearPattern",(App::PropertyType)(App::Prop_None),"Direction"); - ADD_PROPERTY(StdDirection,("")); ADD_PROPERTY(Reversed,(0)); ADD_PROPERTY(Length,(100.0)); ADD_PROPERTY(Occurrences,(3)); @@ -56,7 +56,6 @@ LinearPattern::LinearPattern() short LinearPattern::mustExecute() const { if (Direction.isTouched() || - StdDirection.isTouched() || Reversed.isTouched() || Length.isTouched() || Occurrences.isTouched()) @@ -66,7 +65,6 @@ short LinearPattern::mustExecute() const const std::list LinearPattern::getTransformations(const std::vector) { - std::string stdDirection = StdDirection.getValue(); float distance = Length.getValue(); if (distance < Precision::Confusion()) throw Base::Exception("Pattern length too small"); @@ -75,37 +73,35 @@ const std::list LinearPattern::getTransformations(const std::vectorgetTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) - throw Base::Exception("Direction reference must be edge or face of a feature"); - std::vector subStrings = Direction.getSubValues(); - if (subStrings.empty() || subStrings[0].empty()) - throw Base::Exception("No direction reference specified"); + App::DocumentObject* refObject = Direction.getValue(); + if (refObject == NULL) + throw Base::Exception("No direction reference specified"); + if (!refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + throw Base::Exception("Direction reference must be edge or face of a feature"); + std::vector subStrings = Direction.getSubValues(); + if (subStrings.empty() || subStrings[0].empty()) + throw Base::Exception("No direction reference specified"); + gp_Dir dir; + if (refObject->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + Part::Part2DObject* refSketch = static_cast(refObject); + Base::Axis axis; + if (subStrings[0] == "H_Axis") + axis = refSketch->getAxis(Part::Part2DObject::H_Axis); + else if (subStrings[0] == "V_Axis") + axis = refSketch->getAxis(Part::Part2DObject::V_Axis); + else if (subStrings[0] == "N_Axis") + axis = refSketch->getAxis(Part::Part2DObject::N_Axis); + else if (subStrings[0].size() > 4 && subStrings[0].substr(0,4) == "Axis") { + int AxId = std::atoi(subStrings[0].substr(4,4000).c_str()); + if (AxId >= 0 && AxId < refSketch->getAxisCount()) + axis = refSketch->getAxis(AxId); + } + axis *= refSketch->Placement.getValue(); + dir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z); + } else { Part::Feature* refFeature = static_cast(refObject); Part::TopoShape refShape = refFeature->Shape.getShape(); TopoDS_Shape ref = refShape.getSubShape(subStrings[0].c_str()); @@ -119,8 +115,6 @@ const std::list LinearPattern::getTransformations(const std::vector LinearPattern::getTransformations(const std::vectorgetLocation().Inverted(); - dir.Transform(invObjLoc.Transformation()); } + TopLoc_Location invObjLoc = this->getLocation().Inverted(); + dir.Transform(invObjLoc.Transformation()); - // get the support placement - // TODO: Check for NULL pointer - /*Part::Feature* supportFeature = static_cast(originals.front()); - if (supportFeature == NULL) - throw Base::Exception("Cannot work on invalid support shape"); - Base::Placement supportPlacement = supportFeature->Placement.getValue(); - dir *= supportPlacement; - gp_Vec direction(dir.getDirection().x, dir.getDirection().y, dir.getDirection().z);*/ gp_Vec direction(dir.X(), dir.Y(), dir.Z()); if (reversed) diff --git a/src/Mod/PartDesign/App/FeatureLinearPattern.h b/src/Mod/PartDesign/App/FeatureLinearPattern.h index 6877441744..1e9878478c 100644 --- a/src/Mod/PartDesign/App/FeatureLinearPattern.h +++ b/src/Mod/PartDesign/App/FeatureLinearPattern.h @@ -39,7 +39,6 @@ public: LinearPattern(); App::PropertyLinkSub Direction; - App::PropertyString StdDirection; App::PropertyBool Reversed; App::PropertyFloat Length; App::PropertyInteger Occurrences; @@ -58,8 +57,6 @@ public: * Returns a list of (Occurrences - 1) transformations since the first, untransformed instance * is not counted. Each transformation will move the shape it is applied to by the distance * (Length / (Occurrences - 1)) so that the transformations will cover the total Length. - * If StdDirection is "X", "Y" or "Z" then the transformation direction will be parallel to the - * corresponding axis * If Direction contains a feature and a face name, then the transformation direction will be * the normal of the given face, which must be planar. If it contains an edge name, then the * transformation direction will be parallel to the given edge, which must be linear diff --git a/src/Mod/PartDesign/App/FeatureMirrored.cpp b/src/Mod/PartDesign/App/FeatureMirrored.cpp index 42913f129d..29aa2bc530 100644 --- a/src/Mod/PartDesign/App/FeatureMirrored.cpp +++ b/src/Mod/PartDesign/App/FeatureMirrored.cpp @@ -33,6 +33,7 @@ #include "FeatureMirrored.h" #include +#include using namespace PartDesign; @@ -44,45 +45,47 @@ PROPERTY_SOURCE(PartDesign::Mirrored, PartDesign::Transformed) Mirrored::Mirrored() { ADD_PROPERTY_TYPE(MirrorPlane,(0),"Mirrored",(App::PropertyType)(App::Prop_None),"Mirror plane"); - ADD_PROPERTY(StdMirrorPlane,("")); } short Mirrored::mustExecute() const { - if (MirrorPlane.isTouched() || - StdMirrorPlane.isTouched()) + if (MirrorPlane.isTouched()) return 1; return Transformed::mustExecute(); } const std::list Mirrored::getTransformations(const std::vector) { - App::DocumentObject* ref = MirrorPlane.getValue(); + App::DocumentObject* refObject = MirrorPlane.getValue(); + if (refObject == NULL) + throw Base::Exception("No mirror plane reference specified"); + if (!refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + throw Base::Exception("Mirror plane reference must be face of a feature"); std::vector subStrings = MirrorPlane.getSubValues(); - std::string stdPlane = StdMirrorPlane.getValue(); + if (subStrings.empty() || subStrings[0].empty()) + throw Base::Exception("No mirror plane reference specified"); - gp_Pnt p; - gp_Dir d; - if (!stdPlane.empty()) { - p = gp_Pnt(0,0,0); - if (stdPlane == "XY") { - d = gp_Dir(0,0,1); - } else if (stdPlane == "XZ") { - d = gp_Dir(0,1,0); - } else if(stdPlane == "YZ") { - d = gp_Dir(1,0,0); - } else { - throw Base::Exception("Invalid mirror plane (must be XY, XZ or YZ)"); + gp_Pnt axbase; + gp_Dir axdir; + if (refObject->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + Part::Part2DObject* refSketch = static_cast(refObject); + Base::Axis axis; + if (subStrings[0] == "H_Axis") + axis = refSketch->getAxis(Part::Part2DObject::V_Axis); + else if (subStrings[0] == "V_Axis") + axis = refSketch->getAxis(Part::Part2DObject::H_Axis); + else if (subStrings[0] == "") + axis = refSketch->getAxis(Part::Part2DObject::N_Axis); + else if (subStrings[0].size() > 4 && subStrings[0].substr(0,4) == "Axis") { + int AxId = std::atoi(subStrings[0].substr(4,4000).c_str()); + if (AxId >= 0 && AxId < refSketch->getAxisCount()) + axis = refSketch->getAxis(AxId); } + axis *= refSketch->Placement.getValue(); + axbase = gp_Pnt(axis.getBase().x, axis.getBase().y, axis.getBase().z); + axdir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z); } else { - if (ref == NULL) - throw Base::Exception("No mirror plane selected"); - if (!ref->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) - throw Base::Exception("Mirror plane must be face of a feature"); - Part::TopoShape baseShape = static_cast(ref)->Shape.getShape(); - - if (subStrings.empty() || subStrings[0].empty()) - throw Base::Exception("No mirror plane defined"); + Part::TopoShape baseShape = static_cast(refObject)->Shape.getShape(); // TODO: Check for multiple mirror planes? TopoDS_Face face = TopoDS::Face(baseShape.getSubShape(subStrings[0].c_str())); @@ -92,22 +95,14 @@ const std::list Mirrored::getTransformations(const std::vectorgetLocation().Inverted(); - p.Transform(invObjLoc.Transformation()); - d.Transform(invObjLoc.Transformation()); + axbase = getPointFromFace(face); + axdir = adapt.Plane().Axis().Direction(); } + TopLoc_Location invObjLoc = this->getLocation().Inverted(); + axbase.Transform(invObjLoc.Transformation()); + axdir.Transform(invObjLoc.Transformation()); - // get the support placement - // TODO: Check for NULL pointer - /*Part::Feature* supportFeature = static_cast(originals.front()); - if (supportFeature == NULL) - throw Base::Exception("Cannot work on invalid support shape"); - Base::Placement supportPlacement = supportFeature->Placement.getValue(); - ax *= supportPlacement; - gp_Ax2 mirrorAxis(gp_Pnt(ax.getBase().x, ax.getBase().y, ax.getBase().z), gp_Dir(ax.getDirection().x, ax.getDirection().y, ax.getDirection().z));*/ - gp_Ax2 mirrorAxis(p, d); + gp_Ax2 mirrorAxis(axbase, axdir); std::list transformations; gp_Trsf trans; diff --git a/src/Mod/PartDesign/App/FeatureMirrored.h b/src/Mod/PartDesign/App/FeatureMirrored.h index b89c0500c2..02c57b50c4 100644 --- a/src/Mod/PartDesign/App/FeatureMirrored.h +++ b/src/Mod/PartDesign/App/FeatureMirrored.h @@ -39,7 +39,6 @@ public: Mirrored(); App::PropertyLinkSub MirrorPlane; - App::PropertyString StdMirrorPlane; /** @name methods override feature */ //@{ @@ -54,7 +53,6 @@ public: /** Create transformations * Returns a list containing one transformation since the first, untransformed instance * is not counted. The transformation will mirror the shape it is applied to on a plane - * If StdMirrorPlane is "XY", "YZ" or "YZ" then the mirror plane will the corresponding plane * If MirrorPlane contains a feature and an face name, then the mirror plane will be * the the given face, which must be planar */ diff --git a/src/Mod/PartDesign/App/FeaturePolarPattern.cpp b/src/Mod/PartDesign/App/FeaturePolarPattern.cpp index 90e6b228a9..b4346954cf 100644 --- a/src/Mod/PartDesign/App/FeaturePolarPattern.cpp +++ b/src/Mod/PartDesign/App/FeaturePolarPattern.cpp @@ -32,9 +32,10 @@ #include "FeaturePolarPattern.h" -#include #include +#include #include +#include using namespace PartDesign; @@ -46,7 +47,6 @@ PROPERTY_SOURCE(PartDesign::PolarPattern, PartDesign::Transformed) PolarPattern::PolarPattern() { ADD_PROPERTY_TYPE(Axis,(0),"PolarPattern",(App::PropertyType)(App::Prop_None),"Direction"); - ADD_PROPERTY(StdAxis,("")); ADD_PROPERTY(Reversed,(0)); ADD_PROPERTY(Angle,(360.0)); ADD_PROPERTY(Occurrences,(3)); @@ -55,7 +55,6 @@ PolarPattern::PolarPattern() short PolarPattern::mustExecute() const { if (Axis.isTouched() || - StdAxis.isTouched() || Reversed.isTouched() || Angle.isTouched() || Occurrences.isTouched()) @@ -65,7 +64,6 @@ short PolarPattern::mustExecute() const const std::list PolarPattern::getTransformations(const std::vector) { - std::string stdAxis = StdAxis.getValue(); float angle = Angle.getValue(); if (angle < Precision::Confusion()) throw Base::Exception("Pattern angle too small"); @@ -80,32 +78,35 @@ const std::list PolarPattern::getTransformations(const std::vector(angle) / (occurrences - 1); + App::DocumentObject* refObject = Axis.getValue(); + if (refObject == NULL) + throw Base::Exception("No axis reference specified"); + if (!refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + throw Base::Exception("Axis reference must be edge of a feature"); + std::vector subStrings = Axis.getSubValues(); + if (subStrings.empty() || subStrings[0].empty()) + throw Base::Exception("No axis reference specified"); + gp_Pnt axbase; gp_Dir axdir; - if (!stdAxis.empty()) { - axbase = gp_Pnt(0,0,0); - if (stdAxis == "X") { - axdir = gp_Dir(1,0,0); - //ax = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(1,0,0)); - } else if (stdAxis == "Y") { - axdir = gp_Dir(0,1,0); - //ax = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,1,0)); - } else if(stdAxis == "Z") { - axdir = gp_Dir(0,0,1); - //ax = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,0,1)); - } else { - throw Base::Exception("Invalid axis (must be X, Y or Z)"); + if (refObject->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + Part::Part2DObject* refSketch = static_cast(refObject); + Base::Axis axis; + if (subStrings[0] == "H_Axis") + axis = refSketch->getAxis(Part::Part2DObject::H_Axis); + else if (subStrings[0] == "V_Axis") + axis = refSketch->getAxis(Part::Part2DObject::V_Axis); + else if (subStrings[0] == "N_Axis") + axis = refSketch->getAxis(Part::Part2DObject::N_Axis); + else if (subStrings[0].size() > 4 && subStrings[0].substr(0,4) == "Axis") { + int AxId = std::atoi(subStrings[0].substr(4,4000).c_str()); + if (AxId >= 0 && AxId < refSketch->getAxisCount()) + axis = refSketch->getAxis(AxId); } + axis *= refSketch->Placement.getValue(); + axbase = gp_Pnt(axis.getBase().x, axis.getBase().y, axis.getBase().z); + axdir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z); } else { - App::DocumentObject* refObject = Axis.getValue(); - if (refObject == NULL) - throw Base::Exception("No axis specified"); - if (!refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) - throw Base::Exception("Axis reference must be edge of a feature"); - std::vector subStrings = Axis.getSubValues(); - if (subStrings.empty() || subStrings[0].empty()) - throw Base::Exception("No axis reference specified"); - Part::Feature* refFeature = static_cast(refObject); Part::TopoShape refShape = refFeature->Shape.getShape(); TopoDS_Shape ref = refShape.getSubShape(subStrings[0].c_str()); @@ -123,20 +124,11 @@ const std::list PolarPattern::getTransformations(const std::vectorgetLocation().Inverted(); - axbase.Transform(invObjLoc.Transformation()); - axdir.Transform(invObjLoc.Transformation()); } + TopLoc_Location invObjLoc = this->getLocation().Inverted(); + axbase.Transform(invObjLoc.Transformation()); + axdir.Transform(invObjLoc.Transformation()); - // get the support placement - // TODO: Check for NULL pointer - /*Part::Feature* supportFeature = static_cast(originals.front()); - if (supportFeature == NULL) - throw Base::Exception("Cannot work on invalid support shape"); - Base::Placement supportPlacement = supportFeature->Placement.getValue(); - ax *= supportPlacement; - gp_Ax2 axis(gp_Pnt(ax.getBase().x, ax.getBase().y, ax.getBase().z), gp_Dir(ax.getDirection().x, ax.getDirection().y, ax.getDirection().z));*/ gp_Ax2 axis(axbase, axdir); if (reversed) diff --git a/src/Mod/PartDesign/App/FeaturePolarPattern.h b/src/Mod/PartDesign/App/FeaturePolarPattern.h index 4b05494bfb..1916184839 100644 --- a/src/Mod/PartDesign/App/FeaturePolarPattern.h +++ b/src/Mod/PartDesign/App/FeaturePolarPattern.h @@ -39,7 +39,6 @@ public: PolarPattern(); App::PropertyLinkSub Axis; - App::PropertyString StdAxis; App::PropertyBool Reversed; App::PropertyFloat Angle; App::PropertyInteger Occurrences; @@ -60,7 +59,6 @@ public: * (Angle / (Occurrences - 1)) so that the transformations will cover the total Angle. The only * exception is Angle = 360 degrees in which case the transformation angle will be * (Angle / Occurrences) so that the last transformed shape is not identical with the original shape - * If StdAxis is "X", "Y" or "Z" then the transformation axis will the corresponding axis * If Axis contains a feature and an edge name, then the transformation axis will be * the the given edge, which must be linear * If Reversed is true, the direction of rotation will be opposite diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index 5edc850c73..8eed4f07b0 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -65,7 +65,6 @@ #include #include "FeatureSketchBased.h" -#include using namespace PartDesign; diff --git a/src/Mod/PartDesign/App/FeatureTransformed.cpp b/src/Mod/PartDesign/App/FeatureTransformed.cpp index 6d5146333f..3cc80f1735 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.cpp +++ b/src/Mod/PartDesign/App/FeatureTransformed.cpp @@ -71,6 +71,15 @@ App::DocumentObject* Transformed::getSupportObject() const return NULL; } +App::DocumentObject* Transformed::getSketchObject() const +{ + std::vector originals = Originals.getValues(); + if (!originals.empty() && originals.front()->getTypeId().isDerivedFrom(PartDesign::SketchBased::getClassTypeId())) + return (static_cast(originals.front()))->getVerifiedSketch(); + else + return NULL; +} + short Transformed::mustExecute() const { if (Originals.isTouched()) diff --git a/src/Mod/PartDesign/App/FeatureTransformed.h b/src/Mod/PartDesign/App/FeatureTransformed.h index ab9b9ae434..32c2121597 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.h +++ b/src/Mod/PartDesign/App/FeatureTransformed.h @@ -52,6 +52,9 @@ public: /// Return first original, which serves as "Support" until Body feature becomes functional App::DocumentObject* getSupportObject() const; + /// Return the sketch of the first original + App::DocumentObject* getSketchObject() const; + /// Get the list of transformations describing the members of the pattern // Note: Only the Scaled feature requires the originals virtual const std::list getTransformations(const std::vector originals) { diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 4bb0b006a9..99d7cf1fe2 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -895,7 +895,10 @@ void CmdPartDesignMirrored::activated(int iMsg) // Exception (Thu Sep 6 11:52:01 2012): 'App.Document' object has no attribute 'Mirrored' updateActive(); // Helps to ensure that the object already exists when the next command comes up doCommand(Doc,str.str().c_str()); - doCommand(Doc,"App.activeDocument().%s.StdMirrorPlane = \"XY\"", FeatName.c_str()); + Part::Part2DObject *sketch = (static_cast(features.front()))->getVerifiedSketch(); + if (sketch) + doCommand(Doc,"App.activeDocument().%s.MirrorPlane = (App.activeDocument().%s, [\"V_Axis\"])", + FeatName.c_str(), sketch->getNameInDocument()); for (std::vector::iterator it = tempSelNames.begin(); it != tempSelNames.end(); ++it) doCommand(Gui,"Gui.activeDocument().%s.Visibility=False",it->c_str()); @@ -967,7 +970,10 @@ void CmdPartDesignLinearPattern::activated(int iMsg) doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::LinearPattern\",\"%s\")",FeatName.c_str()); updateActive(); doCommand(Doc,str.str().c_str()); - doCommand(Doc,"App.activeDocument().%s.StdDirection = \"X\"", FeatName.c_str()); + Part::Part2DObject *sketch = (static_cast(features.front()))->getVerifiedSketch(); + if (sketch) + doCommand(Doc,"App.activeDocument().%s.Direction = (App.activeDocument().%s, [\"H_Axis\"])", + FeatName.c_str(), sketch->getNameInDocument()); doCommand(Doc,"App.activeDocument().%s.Length = 100", FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.Occurrences = 2", FeatName.c_str()); for (std::vector::iterator it = tempSelNames.begin(); it != tempSelNames.end(); ++it) @@ -1041,7 +1047,10 @@ void CmdPartDesignPolarPattern::activated(int iMsg) doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::PolarPattern\",\"%s\")",FeatName.c_str()); updateActive(); doCommand(Doc,str.str().c_str()); - doCommand(Doc,"App.activeDocument().%s.StdAxis = \"X\"", FeatName.c_str()); + Part::Part2DObject *sketch = (static_cast(features.front()))->getVerifiedSketch(); + if (sketch) + doCommand(Doc,"App.activeDocument().%s.Axis = (App.activeDocument().%s, [\"N_Axis\"])", + FeatName.c_str(), sketch->getNameInDocument()); doCommand(Doc,"App.activeDocument().%s.Angle = 360", FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.Occurrences = 2", FeatName.c_str()); for (std::vector::iterator it = tempSelNames.begin(); it != tempSelNames.end(); ++it) diff --git a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp index 30e72df60e..593550285d 100644 --- a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp @@ -93,14 +93,14 @@ TaskLinearPatternParameters::TaskLinearPatternParameters(TaskMultiTransformParam void TaskLinearPatternParameters::setupUI() { + connect(ui->comboDirection, SIGNAL(activated(int)), + this, SLOT(onDirectionChanged(int))); connect(ui->checkReverse, SIGNAL(toggled(bool)), this, SLOT(onCheckReverse(bool))); connect(ui->spinLength, SIGNAL(valueChanged(double)), this, SLOT(onLength(double))); connect(ui->spinOccurrences, SIGNAL(valueChanged(int)), this, SLOT(onOccurrences(int))); - connect(ui->buttonReference, SIGNAL(toggled(bool)), - this, SLOT(onButtonReference(bool))); connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)), this, SLOT(onUpdateView(bool))); @@ -119,14 +119,10 @@ void TaskLinearPatternParameters::setupUI() } // --------------------- - //ui->buttonX->setEnabled(true); - //ui->buttonY->setEnabled(true); - //ui->buttonZ->setEnabled(true); + ui->comboDirection->setEnabled(true); ui->checkReverse->setEnabled(true); ui->spinLength->setEnabled(true); ui->spinOccurrences->setEnabled(true); - ui->buttonReference->setEnabled(true); - ui->lineReference->setEnabled(false); // This is never enabled since it is for optical feed-back only updateUI(); } @@ -140,35 +136,31 @@ void TaskLinearPatternParameters::updateUI() App::DocumentObject* directionFeature = pcLinearPattern->Direction.getValue(); std::vector directions = pcLinearPattern->Direction.getSubValues(); - std::string stdDirection = pcLinearPattern->StdDirection.getValue(); bool reverse = pcLinearPattern->Reversed.getValue(); double length = pcLinearPattern->Length.getValue(); unsigned occurrences = pcLinearPattern->Occurrences.getValue(); - ui->buttonReference->setChecked(referenceSelectionMode); - if (!stdDirection.empty()) - { - //ui->buttonX->setAutoExclusive(true); - //ui->buttonY->setAutoExclusive(true); - //ui->buttonZ->setAutoExclusive(true); - //ui->buttonX->setChecked(stdDirection == "X"); - //ui->buttonY->setChecked(stdDirection == "Y"); - //ui->buttonZ->setChecked(stdDirection == "Z"); - ui->lineReference->setText(tr("")); - } else if (directionFeature != NULL && !directions.empty()) { - //ui->buttonX->setAutoExclusive(false); - //ui->buttonY->setAutoExclusive(false); - //ui->buttonZ->setAutoExclusive(false); - //ui->buttonX->setChecked(false); - //ui->buttonY->setChecked(false); - //ui->buttonZ->setChecked(false); - ui->lineReference->setText(QString::fromAscii(directions.front().c_str())); + for (int i=ui->comboDirection->count()-1; i >= 2; i--) + ui->comboDirection->removeItem(i); + + if (directionFeature != NULL && !directions.empty()) { + if (directions.front() == "H_Axis") + ui->comboDirection->setCurrentIndex(0); + else if (directions.front() == "V_Axis") + ui->comboDirection->setCurrentIndex(1); + else if (directionFeature != NULL && !directions.empty()) { + ui->comboDirection->addItem(QString::fromAscii(directions.front().c_str())); + ui->comboDirection->setCurrentIndex(2); + } } else { // Error message? - ui->lineReference->setText(tr("")); } - if (referenceSelectionMode) - ui->lineReference->setText(tr("Select an edge or a face")); + + if (referenceSelectionMode) { + ui->comboDirection->addItem(tr("Select an edge or a face")); + ui->comboDirection->setCurrentIndex(ui->comboDirection->count() - 1); + } else + ui->comboDirection->addItem(tr("Select reference...")); // Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we // didn't check for blockUpdate @@ -201,31 +193,22 @@ void TaskLinearPatternParameters::onSelectionChanged(const Gui::SelectionChanges PartDesign::LinearPattern* pcLinearPattern = static_cast(getObject()); std::vector directions(1,subName); pcLinearPattern->Direction.setValue(getSupportObject(), directions); - pcLinearPattern->StdDirection.setValue(""); recomputeFeature(); updateUI(); } else { - ui->buttonReference->setChecked(referenceSelectionMode); - ui->lineReference->setText(QString::fromAscii(subName.c_str())); + for (int i=ui->comboDirection->count()-1; i >= 2; i--) + ui->comboDirection->removeItem(i); + + ui->comboDirection->addItem(QString::fromAscii(subName.c_str())); + ui->comboDirection->setCurrentIndex(2); + ui->comboDirection->addItem(tr("Select reference...")); } } } } -//void TaskLinearPatternParameters::onButtonX() { -// onStdDirection("X"); -//} -// -//void TaskLinearPatternParameters::onButtonY() { -// onStdDirection("Y"); -//} -// -//void TaskLinearPatternParameters::onButtonZ() { -// onStdDirection("Z"); -//} - void TaskLinearPatternParameters::onCheckReverse(const bool on) { if (blockUpdate) return; @@ -259,30 +242,32 @@ void TaskLinearPatternParameters::onOccurrences(const int n) { recomputeFeature(); } -void TaskLinearPatternParameters::onStdDirection(const std::string& dir) { +void TaskLinearPatternParameters::onDirectionChanged(int num) { if (blockUpdate) return; PartDesign::LinearPattern* pcLinearPattern = static_cast(getObject()); - pcLinearPattern->StdDirection.setValue(dir.c_str()); - pcLinearPattern->Direction.setValue(NULL); - exitSelectionMode(); - updateUI(); - recomputeFeature(); -} - -void TaskLinearPatternParameters::onButtonReference(bool checked) -{ - if (checked ) { + if (num == 0) { + pcLinearPattern->Direction.setValue(getSketchObject(), std::vector(1,"H_Axis")); + exitSelectionMode(); + } + else if (num == 1) { + pcLinearPattern->Direction.setValue(getSketchObject(), std::vector(1,"V_Axis")); + exitSelectionMode(); + } + else if (num == ui->comboDirection->count() - 1) { + // enter reference selection mode hideObject(); showOriginals(); referenceSelectionMode = true; Gui::Selection().clearSelection(); addReferenceSelectionGate(true, true); - } else { - exitSelectionMode(); } + else if (num == 2) + exitSelectionMode(); + updateUI(); + recomputeFeature(); } void TaskLinearPatternParameters::onUpdateView(bool on) @@ -295,16 +280,13 @@ void TaskLinearPatternParameters::onUpdateView(bool on) std::string direction = getDirection(); if (!direction.empty()) { std::vector directions(1,direction); - pcLinearPattern->Direction.setValue(getSupportObject(), directions); + if (direction == "H_Axis" || direction == "V_Axis") + pcLinearPattern->Direction.setValue(getSketchObject(), directions); + else + pcLinearPattern->Direction.setValue(getSupportObject(), directions); } else pcLinearPattern->Direction.setValue(NULL); - std::string stdDirection = getStdDirection(); - if (!stdDirection.empty()) - pcLinearPattern->StdDirection.setValue(stdDirection.c_str()); - else - pcLinearPattern->StdDirection.setValue(NULL); - pcLinearPattern->Reversed.setValue(getReverse()); pcLinearPattern->Length.setValue(getLength()); pcLinearPattern->Occurrences.setValue(getOccurrences()); @@ -313,20 +295,15 @@ void TaskLinearPatternParameters::onUpdateView(bool on) } } -const std::string TaskLinearPatternParameters::getStdDirection(void) const -{ - //if (ui->buttonX->isChecked()) - // return std::string("X"); - //else if (ui->buttonY->isChecked()) - // return std::string("Y"); - //else if (ui->buttonZ->isChecked()) - // return std::string("Z"); - return std::string(""); -} - const std::string TaskLinearPatternParameters::getDirection(void) const -{ - return ui->lineReference->text().toStdString(); +{ + if (ui->comboDirection->currentIndex() == 0) + return "H_Axis"; + else if (ui->comboDirection->currentIndex() == 1) + return "V_Axis"; + else if (ui->comboDirection->count() > 3 && ui->comboDirection->currentIndex() == 2) + return ui->comboDirection->currentText().toStdString(); + return std::string(""); } const bool TaskLinearPatternParameters::getReverse(void) const @@ -388,13 +365,14 @@ bool TaskDlgLinearPatternParameters::accept() std::string direction = linearpatternParameter->getDirection(); if (!direction.empty()) { QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])"); - buf = buf.arg(QString::fromUtf8(linearpatternParameter->getSupportObject()->getNameInDocument())); + if (direction == "H_Axis" || direction == "V_Axis") + buf = buf.arg(QString::fromUtf8(linearpatternParameter->getSketchObject()->getNameInDocument())); + else + buf = buf.arg(QString::fromUtf8(linearpatternParameter->getSupportObject()->getNameInDocument())); buf = buf.arg(QString::fromUtf8(direction.c_str())); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = %s", name.c_str(), buf.toStdString().c_str()); } else Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = None", name.c_str()); - std::string stdDirection = linearpatternParameter->getStdDirection(); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdDirection = \"%s\"",name.c_str(),stdDirection.c_str()); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),linearpatternParameter->getReverse()); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Length = %f",name.c_str(),linearpatternParameter->getLength()); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Occurrences = %u",name.c_str(),linearpatternParameter->getOccurrences()); diff --git a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.h b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.h index e3a88a779a..a76e946683 100644 --- a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.h +++ b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.h @@ -56,21 +56,16 @@ public: TaskLinearPatternParameters(TaskMultiTransformParameters *parentTask, QLayout *layout); virtual ~TaskLinearPatternParameters(); - const std::string getStdDirection(void) const; const std::string getDirection(void) const; const bool getReverse(void) const; const double getLength(void) const; const unsigned getOccurrences(void) const; private Q_SLOTS: - void onStdDirection(const std::string& dir); - //void onButtonX(); - //void onButtonY(); - //void onButtonZ(); + void onDirectionChanged(int num); void onCheckReverse(const bool on); void onLength(const double l); void onOccurrences(const int n); - void onButtonReference(const bool checked); virtual void onUpdateView(bool); protected: diff --git a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.ui b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.ui index c6421af4cf..913e46eeb6 100644 --- a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.ui @@ -6,7 +6,7 @@ 0 0 - 225 + 260 402 @@ -31,17 +31,30 @@ - + Direction - - true - - + + + + Horizontal sketch axis + + + + + Vertical sketch axis + + + + + Select reference... + + + @@ -69,9 +82,6 @@ 999999.000000000000000 - - 5.000000000000000 - 100.000000000000000 diff --git a/src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp b/src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp index ec4dd414ec..f4945d9189 100644 --- a/src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp @@ -93,14 +93,8 @@ TaskMirroredParameters::TaskMirroredParameters(TaskMultiTransformParameters *par void TaskMirroredParameters::setupUI() { - connect(ui->buttonXY, SIGNAL(pressed()), - this, SLOT(onButtonXY())); - connect(ui->buttonXZ, SIGNAL(pressed()), - this, SLOT(onButtonXZ())); - connect(ui->buttonYZ, SIGNAL(pressed()), - this, SLOT(onButtonYZ())); - connect(ui->buttonReference, SIGNAL(toggled(bool)), - this, SLOT(onButtonReference(bool))); + connect(ui->comboPlane, SIGNAL(activated(int)), + this, SLOT(onPlaneChanged(int))); connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)), this, SLOT(onUpdateView(bool))); @@ -119,11 +113,7 @@ void TaskMirroredParameters::setupUI() } // --------------------- - ui->buttonXY->setEnabled(true); - ui->buttonXZ->setEnabled(true); - ui->buttonYZ->setEnabled(true); - ui->buttonReference->setEnabled(true); - ui->lineReference->setEnabled(false); // This is never enabled since it is for optical feed-back only + ui->comboPlane->setEnabled(true); updateUI(); } @@ -132,35 +122,33 @@ void TaskMirroredParameters::updateUI() if (blockUpdate) return; blockUpdate = true; + PartDesign::Mirrored* pcMirrored = static_cast(getObject()); + App::DocumentObject* mirrorPlaneFeature = pcMirrored->MirrorPlane.getValue(); std::vector mirrorPlanes = pcMirrored->MirrorPlane.getSubValues(); - std::string stdMirrorPlane = pcMirrored->StdMirrorPlane.getValue(); + + for (int i=ui->comboPlane->count()-1; i >= 2; i--) + ui->comboPlane->removeItem(i); - ui->buttonReference->setChecked(referenceSelectionMode); - if (!stdMirrorPlane.empty()) - { - ui->buttonXY->setAutoExclusive(true); - ui->buttonXZ->setAutoExclusive(true); - ui->buttonYZ->setAutoExclusive(true); - ui->buttonXY->setChecked(stdMirrorPlane == "XY"); - ui->buttonXZ->setChecked(stdMirrorPlane == "XZ"); - ui->buttonYZ->setChecked(stdMirrorPlane == "YZ"); - ui->lineReference->setText(tr("")); - } else if (mirrorPlaneFeature != NULL && !mirrorPlanes.empty()) { - ui->buttonXY->setAutoExclusive(false); - ui->buttonXZ->setAutoExclusive(false); - ui->buttonYZ->setAutoExclusive(false); - ui->buttonXY->setChecked(false); - ui->buttonXZ->setChecked(false); - ui->buttonYZ->setChecked(false); - ui->lineReference->setText(QString::fromAscii(mirrorPlanes.front().c_str())); + if (mirrorPlaneFeature != NULL && !mirrorPlanes.empty()) { + if (mirrorPlanes.front() == "H_Axis") + ui->comboPlane->setCurrentIndex(0); + else if (mirrorPlanes.front() == "V_Axis") + ui->comboPlane->setCurrentIndex(1); + else if (mirrorPlaneFeature != NULL && !mirrorPlanes.empty()) { + ui->comboPlane->addItem(QString::fromAscii(mirrorPlanes.front().c_str())); + ui->comboPlane->setCurrentIndex(2); + } } else { // Error message? - ui->lineReference->setText(tr("")); } - if (referenceSelectionMode) - ui->lineReference->setText(tr("Select a plane")); + + if (referenceSelectionMode) { + ui->comboPlane->addItem(tr("Select a face")); + ui->comboPlane->setCurrentIndex(ui->comboPlane->count() - 1); + } else + ui->comboPlane->addItem(tr("Select reference...")); blockUpdate = false; } @@ -186,55 +174,48 @@ void TaskMirroredParameters::onSelectionChanged(const Gui::SelectionChanges& msg PartDesign::Mirrored* pcMirrored = static_cast(getObject()); std::vector mirrorPlanes(1,subName); pcMirrored->MirrorPlane.setValue(getSupportObject(), mirrorPlanes); - pcMirrored->StdMirrorPlane.setValue(""); recomputeFeature(); updateUI(); } else { - ui->buttonReference->setChecked(referenceSelectionMode); - ui->lineReference->setText(QString::fromAscii(subName.c_str())); + for (int i=ui->comboPlane->count()-1; i >= 2; i--) + ui->comboPlane->removeItem(i); + + ui->comboPlane->addItem(QString::fromAscii(subName.c_str())); + ui->comboPlane->setCurrentIndex(2); + ui->comboPlane->addItem(tr("Select reference...")); } } } } -void TaskMirroredParameters::onStdMirrorPlane(const std::string &plane) { +void TaskMirroredParameters::onPlaneChanged(int num) { if (blockUpdate) return; PartDesign::Mirrored* pcMirrored = static_cast(getObject()); - pcMirrored->StdMirrorPlane.setValue(plane.c_str()); - pcMirrored->MirrorPlane.setValue(NULL); - exitSelectionMode(); - updateUI(); - recomputeFeature(); -} - -void TaskMirroredParameters::onButtonXY() { - onStdMirrorPlane("XY"); -} - -void TaskMirroredParameters::onButtonXZ() { - onStdMirrorPlane("XZ"); -} - -void TaskMirroredParameters::onButtonYZ() { - onStdMirrorPlane("YZ"); -} - -void TaskMirroredParameters::onButtonReference(bool checked) -{ - if (checked ) { + if (num == 0) { + pcMirrored->MirrorPlane.setValue(getSketchObject(), std::vector(1,"H_Axis")); + exitSelectionMode(); + } + else if (num == 1) { + pcMirrored->MirrorPlane.setValue(getSketchObject(), std::vector(1,"V_Axis")); + exitSelectionMode(); + } + else if (num == ui->comboPlane->count() - 1) { + // enter reference selection mode hideObject(); showOriginals(); referenceSelectionMode = true; Gui::Selection().clearSelection(); addReferenceSelectionGate(false, true); - } else { - exitSelectionMode(); } + else if (num == 2) + exitSelectionMode(); + updateUI(); + recomputeFeature(); } void TaskMirroredParameters::onUpdateView(bool on) @@ -247,37 +228,28 @@ void TaskMirroredParameters::onUpdateView(bool on) std::string mirrorPlane = getMirrorPlane(); if (!mirrorPlane.empty()) { std::vector planes(1,mirrorPlane); - pcMirrored->MirrorPlane.setValue(getSupportObject(),planes); + if (mirrorPlane == "H_Axis" || mirrorPlane == "V_Axis") + pcMirrored->MirrorPlane.setValue(getSketchObject(),planes); + else + pcMirrored->MirrorPlane.setValue(getSupportObject(),planes); } else pcMirrored->MirrorPlane.setValue(NULL); - std::string stdMirrorPlane = getStdMirrorPlane(); - if (!stdMirrorPlane.empty()) - pcMirrored->StdMirrorPlane.setValue(stdMirrorPlane.c_str()); - else - pcMirrored->StdMirrorPlane.setValue(NULL); - recomputeFeature(); } } -const std::string TaskMirroredParameters::getStdMirrorPlane(void) const -{ - if (ui->buttonXY->isChecked()) - return std::string("XY"); - else if (ui->buttonYZ->isChecked()) - return std::string("YZ"); - else if (ui->buttonXZ->isChecked()) - return std::string("XZ"); - return std::string(""); -} - const std::string TaskMirroredParameters::getMirrorPlane(void) const { - return ui->lineReference->text().toStdString(); + if (ui->comboPlane->currentIndex() == 0) + return "H_Axis"; + else if (ui->comboPlane->currentIndex() == 1) + return "V_Axis"; + else if (ui->comboPlane->count() > 3 && ui->comboPlane->currentIndex() == 2) + return ui->comboPlane->currentText().toStdString(); + return std::string(""); } - TaskMirroredParameters::~TaskMirroredParameters() { delete ui; @@ -321,13 +293,14 @@ bool TaskDlgMirroredParameters::accept() std::string mirrorPlane = mirrorParameter->getMirrorPlane(); if (!mirrorPlane.empty()) { QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])"); - buf = buf.arg(QString::fromUtf8(mirrorParameter->getSupportObject()->getNameInDocument())); + if (mirrorPlane == "H_Axis" || mirrorPlane == "V_Axis") + buf = buf.arg(QString::fromUtf8(mirrorParameter->getSketchObject()->getNameInDocument())); + else + buf = buf.arg(QString::fromUtf8(mirrorParameter->getSupportObject()->getNameInDocument())); buf = buf.arg(QString::fromUtf8(mirrorPlane.c_str())); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = %s", name.c_str(), buf.toStdString().c_str()); } else Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = None", name.c_str()); - std::string stdMirrorPlane = mirrorParameter->getStdMirrorPlane(); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdMirrorPlane = \"%s\"",name.c_str(),stdMirrorPlane.c_str()); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); if (!TransformedView->getObject()->isValid()) throw Base::Exception(TransformedView->getObject()->getStatusString()); diff --git a/src/Mod/PartDesign/Gui/TaskMirroredParameters.h b/src/Mod/PartDesign/Gui/TaskMirroredParameters.h index ec9fd210f4..916c0c8f86 100644 --- a/src/Mod/PartDesign/Gui/TaskMirroredParameters.h +++ b/src/Mod/PartDesign/Gui/TaskMirroredParameters.h @@ -57,14 +57,10 @@ public: virtual ~TaskMirroredParameters(); - const std::string getStdMirrorPlane(void) const; const std::string getMirrorPlane(void) const; private Q_SLOTS: - void onButtonXY(); - void onButtonXZ(); - void onButtonYZ(); - void onButtonReference(const bool checked); + void onPlaneChanged(int num); virtual void onUpdateView(bool); protected: @@ -72,7 +68,6 @@ protected: virtual void onSelectionChanged(const Gui::SelectionChanges& msg); private: - void onStdMirrorPlane(const std::string& plane); void setupUI(); void updateUI(); diff --git a/src/Mod/PartDesign/Gui/TaskMirroredParameters.ui b/src/Mod/PartDesign/Gui/TaskMirroredParameters.ui index c34a29d170..f0f2e8d7d7 100644 --- a/src/Mod/PartDesign/Gui/TaskMirroredParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskMirroredParameters.ui @@ -28,48 +28,33 @@ - - - - - - XY - - - true - - - - - - - XZ - - - - - - - YZ - - - - - - + Plane - - true - - + + + + Horizontal sketch axis + + + + + Vertical sketch axis + + + + + Select reference... + + + diff --git a/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.cpp b/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.cpp index c581054fd9..fcad5116cd 100644 --- a/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.cpp @@ -218,7 +218,10 @@ void TaskMultiTransformParameters::onTransformAddMirrored() Gui::Command::openCommand("Mirrored"); Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\"PartDesign::Mirrored\",\"%s\")",newFeatName.c_str()); //Gui::Command::updateActive(); - Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.StdMirrorPlane = \"XY\"", newFeatName.c_str()); + App::DocumentObject* sketch = getSketchObject(); + if (sketch) + Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.MirrorPlane = (App.activeDocument().%s, [\"V_Axis\"])", + newFeatName.c_str(), sketch->getNameInDocument()); finishAdd(newFeatName); } @@ -231,7 +234,10 @@ void TaskMultiTransformParameters::onTransformAddLinearPattern() Gui::Command::openCommand("LinearPattern"); Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\"PartDesign::LinearPattern\",\"%s\")",newFeatName.c_str()); //Gui::Command::updateActive(); - Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.StdDirection = \"X\"", newFeatName.c_str()); + App::DocumentObject* sketch = getSketchObject(); + if (sketch) + Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Direction = (App.activeDocument().%s, [\"H_Axis\"])", + newFeatName.c_str(), sketch->getNameInDocument()); Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Length = 100", newFeatName.c_str()); Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Occurrences = 2", newFeatName.c_str()); @@ -246,7 +252,10 @@ void TaskMultiTransformParameters::onTransformAddPolarPattern() Gui::Command::openCommand("PolarPattern"); Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\"PartDesign::PolarPattern\",\"%s\")",newFeatName.c_str()); //Gui::Command::updateActive(); - Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.StdAxis = \"X\"", newFeatName.c_str()); + App::DocumentObject* sketch = getSketchObject(); + if (sketch) + Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Axis = (App.activeDocument().%s, [\"N_Axis\"])", + newFeatName.c_str(), sketch->getNameInDocument()); Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Angle = 360", newFeatName.c_str()); Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Occurrences = 2", newFeatName.c_str()); diff --git a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.cpp b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.cpp index 0c5e0750a2..e63051a7b7 100644 --- a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.cpp @@ -93,20 +93,14 @@ TaskPolarPatternParameters::TaskPolarPatternParameters(TaskMultiTransformParamet void TaskPolarPatternParameters::setupUI() { - connect(ui->buttonX, SIGNAL(pressed()), - this, SLOT(onButtonX())); - connect(ui->buttonY, SIGNAL(pressed()), - this, SLOT(onButtonY())); - connect(ui->buttonZ, SIGNAL(pressed()), - this, SLOT(onButtonZ())); + connect(ui->comboAxis, SIGNAL(activated(int)), + this, SLOT(onAxisChanged(int))); connect(ui->checkReverse, SIGNAL(toggled(bool)), this, SLOT(onCheckReverse(bool))); connect(ui->spinAngle, SIGNAL(valueChanged(double)), this, SLOT(onAngle(double))); connect(ui->spinOccurrences, SIGNAL(valueChanged(int)), this, SLOT(onOccurrences(int))); - connect(ui->buttonReference, SIGNAL(toggled(bool)), - this, SLOT(onButtonReference(bool))); connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)), this, SLOT(onUpdateView(bool))); @@ -125,14 +119,10 @@ void TaskPolarPatternParameters::setupUI() } // --------------------- - ui->buttonX->setEnabled(true); - ui->buttonY->setEnabled(true); - ui->buttonZ->setEnabled(true); + ui->comboAxis->setEnabled(true); ui->checkReverse->setEnabled(true); ui->spinAngle->setEnabled(true); ui->spinOccurrences->setEnabled(true); - ui->buttonReference->setEnabled(true); - ui->lineReference->setEnabled(false); // This is never enabled since it is for optical feed-back only updateUI(); } @@ -146,36 +136,32 @@ void TaskPolarPatternParameters::updateUI() App::DocumentObject* axisFeature = pcPolarPattern->Axis.getValue(); std::vector axes = pcPolarPattern->Axis.getSubValues(); - std::string stdAxis = pcPolarPattern->StdAxis.getValue(); bool reverse = pcPolarPattern->Reversed.getValue(); double angle = pcPolarPattern->Angle.getValue(); unsigned occurrences = pcPolarPattern->Occurrences.getValue(); - ui->buttonReference->setChecked(referenceSelectionMode); - if (!stdAxis.empty()) - { - ui->buttonX->setAutoExclusive(true); - ui->buttonY->setAutoExclusive(true); - ui->buttonZ->setAutoExclusive(true); - ui->buttonX->setChecked(stdAxis == "X"); - ui->buttonY->setChecked(stdAxis == "Y"); - ui->buttonZ->setChecked(stdAxis == "Z"); - ui->lineReference->setText(tr("")); - } else if (axisFeature != NULL && !axes.empty()) { - ui->buttonX->setAutoExclusive(false); - ui->buttonY->setAutoExclusive(false); - ui->buttonZ->setAutoExclusive(false); - ui->buttonX->setChecked(false); - ui->buttonY->setChecked(false); - ui->buttonZ->setChecked(false); - ui->lineReference->setText(QString::fromAscii(axes.front().c_str())); + for (int i=ui->comboAxis->count()-1; i >= 1; i--) + ui->comboAxis->removeItem(i); + + if (axisFeature != NULL && !axes.empty()) { + if (axes.front() == "N_Axis") + ui->comboAxis->setCurrentIndex(0); + else if (axisFeature != NULL && !axes.empty()) { + ui->comboAxis->addItem(QString::fromAscii(axes.front().c_str())); + ui->comboAxis->setCurrentIndex(1); + } } else { // Error message? - ui->lineReference->setText(tr("")); } - if (referenceSelectionMode) - ui->lineReference->setText(tr("Select an edge")); + if (referenceSelectionMode) { + ui->comboAxis->addItem(tr("Select an edge")); + ui->comboAxis->setCurrentIndex(ui->comboAxis->count() - 1); + } else + ui->comboAxis->addItem(tr("Select reference...")); + + // Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we + // didn't check for blockUpdate ui->checkReverse->setChecked(reverse); ui->spinAngle->setValue(angle); ui->spinOccurrences->setValue(occurrences); @@ -204,31 +190,22 @@ void TaskPolarPatternParameters::onSelectionChanged(const Gui::SelectionChanges& PartDesign::PolarPattern* pcPolarPattern = static_cast(getObject()); std::vector axes(1,subName); pcPolarPattern->Axis.setValue(getSupportObject(), axes); - pcPolarPattern->StdAxis.setValue(""); recomputeFeature(); updateUI(); } else { - ui->buttonReference->setChecked(referenceSelectionMode); - ui->lineReference->setText(QString::fromAscii(subName.c_str())); + for (int i=ui->comboAxis->count()-1; i >= 1; i--) + ui->comboAxis->removeItem(i); + + ui->comboAxis->addItem(QString::fromAscii(subName.c_str())); + ui->comboAxis->setCurrentIndex(1); + ui->comboAxis->addItem(tr("Select reference...")); } } } } -void TaskPolarPatternParameters::onButtonX() { - onStdAxis("X"); -} - -void TaskPolarPatternParameters::onButtonY() { - onStdAxis("Y"); -} - -void TaskPolarPatternParameters::onButtonZ() { - onStdAxis("Z"); -} - void TaskPolarPatternParameters::onCheckReverse(const bool on) { if (blockUpdate) return; @@ -262,30 +239,28 @@ void TaskPolarPatternParameters::onOccurrences(const int n) { recomputeFeature(); } -void TaskPolarPatternParameters::onStdAxis(const std::string& axis) { +void TaskPolarPatternParameters::onAxisChanged(int num) { if (blockUpdate) return; PartDesign::PolarPattern* pcPolarPattern = static_cast(getObject()); - pcPolarPattern->StdAxis.setValue(axis.c_str()); - pcPolarPattern->Axis.setValue(NULL); - exitSelectionMode(); - updateUI(); - recomputeFeature(); -} - -void TaskPolarPatternParameters::onButtonReference(bool checked) -{ - if (checked ) { + if (num == 0) { + pcPolarPattern->Axis.setValue(getSketchObject(), std::vector(1,"N_Axis")); + exitSelectionMode(); + } + else if (num == ui->comboAxis->count() - 1) { + // enter reference selection mode hideObject(); showOriginals(); referenceSelectionMode = true; Gui::Selection().clearSelection(); addReferenceSelectionGate(true, false); - } else { - exitSelectionMode(); } + else if (num == 1) + exitSelectionMode(); + updateUI(); + recomputeFeature(); } void TaskPolarPatternParameters::onUpdateView(bool on) @@ -298,16 +273,13 @@ void TaskPolarPatternParameters::onUpdateView(bool on) std::string axis = getAxis(); if (!axis.empty()) { std::vector axes(1,axis); - pcPolarPattern->Axis.setValue(getSupportObject(),axes); + if (axis == "N_Axis") + pcPolarPattern->Axis.setValue(getSketchObject(), axes); + else + pcPolarPattern->Axis.setValue(getSupportObject(), axes); } else pcPolarPattern->Axis.setValue(NULL); - std::string stdAxis = getStdAxis(); - if (!stdAxis.empty()) - pcPolarPattern->StdAxis.setValue(stdAxis.c_str()); - else - pcPolarPattern->StdAxis.setValue(NULL); - pcPolarPattern->Reversed.setValue(getReverse()); pcPolarPattern->Angle.setValue(getAngle()); pcPolarPattern->Occurrences.setValue(getOccurrences()); @@ -316,22 +288,15 @@ void TaskPolarPatternParameters::onUpdateView(bool on) } } -const std::string TaskPolarPatternParameters::getStdAxis(void) const +const std::string TaskPolarPatternParameters::getAxis(void) const { - if (ui->buttonX->isChecked()) - return std::string("X"); - else if (ui->buttonY->isChecked()) - return std::string("Y"); - else if (ui->buttonZ->isChecked()) - return std::string("Z"); + if (ui->comboAxis->currentIndex() == 0) + return "N_Axis"; + else if (ui->comboAxis->count() > 2 && ui->comboAxis->currentIndex() == 1) + return ui->comboAxis->currentText().toStdString(); return std::string(""); } -const std::string TaskPolarPatternParameters::getAxis(void) const -{ - return ui->lineReference->text().toStdString(); -} - const bool TaskPolarPatternParameters::getReverse(void) const { return ui->checkReverse->isChecked(); @@ -391,13 +356,14 @@ bool TaskDlgPolarPatternParameters::accept() std::string axis = polarpatternParameter->getAxis(); if (!axis.empty()) { QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])"); - buf = buf.arg(QString::fromUtf8(polarpatternParameter->getSupportObject()->getNameInDocument())); + if (axis == "N_Axis") + buf = buf.arg(QString::fromUtf8(polarpatternParameter->getSketchObject()->getNameInDocument())); + else + buf = buf.arg(QString::fromUtf8(polarpatternParameter->getSupportObject()->getNameInDocument())); buf = buf.arg(QString::fromUtf8(axis.c_str())); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = %s", name.c_str(), buf.toStdString().c_str()); } else Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = None", name.c_str()); - std::string stdAxis = polarpatternParameter->getStdAxis(); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdAxis = \"%s\"",name.c_str(),stdAxis.c_str()); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),polarpatternParameter->getReverse()); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Angle = %f",name.c_str(),polarpatternParameter->getAngle()); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Occurrences = %u",name.c_str(),polarpatternParameter->getOccurrences()); diff --git a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.h b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.h index 6b06f10a61..9d23bebffc 100644 --- a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.h +++ b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.h @@ -63,14 +63,10 @@ public: const unsigned getOccurrences(void) const; private Q_SLOTS: - void onStdAxis(const std::string& axis); - void onButtonX(); - void onButtonY(); - void onButtonZ(); + void onAxisChanged(int num); void onCheckReverse(const bool on); void onAngle(const double a); void onOccurrences(const int n); - void onButtonReference(const bool checked); virtual void onUpdateView(bool); protected: diff --git a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.ui b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.ui index a5ad73322d..2918f4ac08 100644 --- a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.ui @@ -28,48 +28,28 @@ - - - - - - X - - - true - - - - - - - Y - - - - - - - Z - - - - - - + - Direction - - - true + Axis - + + + + Normal sketch axis + + + + + Select reference... + + + diff --git a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp index f13165768b..129b6276b6 100644 --- a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp @@ -148,6 +148,16 @@ App::DocumentObject* TaskTransformedParameters::getSupportObject() const } } +App::DocumentObject* TaskTransformedParameters::getSketchObject() const +{ + if (insideMultiTransform) { + return parentTask->getSketchObject(); + } else { + PartDesign::Transformed* pcTransformed = static_cast(TransformedView->getObject()); + return pcTransformed->getSketchObject(); + } +} + void TaskTransformedParameters::hideObject() { Gui::Document* doc = Gui::Application::Instance->activeDocument(); diff --git a/src/Mod/PartDesign/Gui/TaskTransformedParameters.h b/src/Mod/PartDesign/Gui/TaskTransformedParameters.h index e50610497d..68bd60f8e8 100644 --- a/src/Mod/PartDesign/Gui/TaskTransformedParameters.h +++ b/src/Mod/PartDesign/Gui/TaskTransformedParameters.h @@ -61,7 +61,8 @@ public: const std::vector getOriginals(void) const; /// Get the support object either of the object associated with this feature or with the parent feature (MultiTransform mode) App::DocumentObject* getSupportObject() const; - + /// Get the sketch object of the first original either of the object associated with this feature or with the parent feature (MultiTransform mode) + App::DocumentObject* getSketchObject() const; protected Q_SLOTS: /// Connect the subTask OK button to the MultiTransform task diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 1f1278d13d..2e972531e8 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -274,14 +274,10 @@ int SketchObject::getAxisCount(void) const Base::Axis SketchObject::getAxis(int axId) const { - const std::vector< Part::Geometry * > &vals = getInternalGeometry(); - if (axId == H_Axis) { - return Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(1,0,0)); - } - else if (axId == V_Axis) { - return Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,1,0)); - } + if (axId == H_Axis || axId == V_Axis || axId == N_Axis) + return Part::Part2DObject::getAxis(axId); + const std::vector< Part::Geometry * > &vals = getInternalGeometry(); int count=0; for (std::vector::const_iterator geo=vals.begin(); geo != vals.end(); geo++) From 860a65d0a615f9ab42a6b26eeeddb96a8a3c509a Mon Sep 17 00:00:00 2001 From: logari81 Date: Wed, 9 Jan 2013 23:35:32 +0100 Subject: [PATCH 10/10] PartDesign: Deactivate nesting of original features in patterns --- src/Mod/PartDesign/Gui/ViewProviderMultiTransform.cpp | 6 +----- src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp | 11 ----------- src/Mod/PartDesign/Gui/ViewProviderTransformed.h | 2 -- 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/Mod/PartDesign/Gui/ViewProviderMultiTransform.cpp b/src/Mod/PartDesign/Gui/ViewProviderMultiTransform.cpp index 462dfc1af0..3c17680adc 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderMultiTransform.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderMultiTransform.cpp @@ -62,16 +62,12 @@ bool ViewProviderMultiTransform::setEdit(int ModNum) std::vector ViewProviderMultiTransform::claimChildren(void) const { - std::vector result = ViewProviderTransformed::claimChildren(); - PartDesign::MultiTransform* pcMultiTransform = static_cast(getObject()); if (pcMultiTransform == NULL) return std::vector(); // TODO: Show error? std::vector transformFeatures = pcMultiTransform->Transformations.getValues(); - - result.insert(result.end(), transformFeatures.begin(), transformFeatures.end()); - return result; + return transformFeatures; } bool ViewProviderMultiTransform::onDelete(const std::vector &svec) { diff --git a/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp b/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp index 9efe20aa41..5af43cd05f 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp @@ -38,17 +38,6 @@ using namespace PartDesignGui; PROPERTY_SOURCE(PartDesignGui::ViewProviderTransformed,PartDesignGui::ViewProvider) -std::vector ViewProviderTransformed::claimChildren(void)const -{ - PartDesign::Transformed* pcTransformed = static_cast(getObject()); - if (pcTransformed == NULL) - return std::vector(); // TODO: Show error? - - std::vector originals = pcTransformed->Originals.getValues(); - - return originals; -} - void ViewProviderTransformed::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) { QAction* act; diff --git a/src/Mod/PartDesign/Gui/ViewProviderTransformed.h b/src/Mod/PartDesign/Gui/ViewProviderTransformed.h index 39b7b099cf..1265f67e8a 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderTransformed.h +++ b/src/Mod/PartDesign/Gui/ViewProviderTransformed.h @@ -42,8 +42,6 @@ public: virtual ~ViewProviderTransformed() {} - /// grouping handling - std::vector claimChildren(void) const; void setupContextMenu(QMenu*, QObject*, const char*); virtual bool onDelete(const std::vector &);