diff --git a/src/Mod/Sketcher/Init.py b/src/Mod/Sketcher/Init.py index 5338e2b2d4..571ab825ef 100644 --- a/src/Mod/Sketcher/Init.py +++ b/src/Mod/Sketcher/Init.py @@ -1,26 +1,26 @@ -#*************************************************************************** -#* Copyright (c) 2001,2002 Juergen Riegel * -#* * -#* 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 * -#* * -#***************************************************************************/ +# *************************************************************************** +# * Copyright (c) 2001,2002 Juergen Riegel * +# * * +# * 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 * +# * * +# ***************************************************************************/ # FreeCAD init script of the Sketcher module -FreeCAD.__unit_test__ += [ "TestSketcherApp" ] +FreeCAD.__unit_test__ += ["TestSketcherApp"] diff --git a/src/Mod/Sketcher/InitGui.py b/src/Mod/Sketcher/InitGui.py index 0022ccf96f..1b2ae6f8a0 100644 --- a/src/Mod/Sketcher/InitGui.py +++ b/src/Mod/Sketcher/InitGui.py @@ -1,25 +1,25 @@ -#*************************************************************************** -#* Copyright (c) 2002,2003 Juergen Riegel * -#* * -#* 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 * -#* * -#***************************************************************************/ +# *************************************************************************** +# * Copyright (c) 2002,2003 Juergen Riegel * +# * * +# * 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 * +# * * +# ***************************************************************************/ # Sketcher gui init module # @@ -27,10 +27,15 @@ # This is the second one of three init scripts, the third one # runs when the gui is up -class SketcherWorkbench ( Workbench ): + +class SketcherWorkbench(Workbench): "Sketcher workbench object" + def __init__(self): - self.__class__.Icon = FreeCAD.getResourceDir() + "Mod/Sketcher/Resources/icons/SketcherWorkbench.svg" + self.__class__.Icon = ( + FreeCAD.getResourceDir() + + "Mod/Sketcher/Resources/icons/SketcherWorkbench.svg" + ) self.__class__.MenuText = "Sketcher" self.__class__.ToolTip = "Sketcher workbench" @@ -47,6 +52,7 @@ class SketcherWorkbench ( Workbench ): def GetClassName(self): return "SketcherGui::Workbench" + Gui.addWorkbench(SketcherWorkbench()) -FreeCAD.__unit_test__ += [ "TestSketcherGui" ] +FreeCAD.__unit_test__ += ["TestSketcherGui"] diff --git a/src/Mod/Sketcher/Profiles.py b/src/Mod/Sketcher/Profiles.py index 2ad089fb35..80dcb7a90a 100644 --- a/src/Mod/Sketcher/Profiles.py +++ b/src/Mod/Sketcher/Profiles.py @@ -1,23 +1,23 @@ -#*************************************************************************** -#* Copyright (c) 2014 Juergen Riegel * -#* * -#* This program is free software; you can redistribute it and/or modify * -#* it under the terms of the GNU Lesser General Public License (LGPL) * -#* as published by the Free Software Foundation; either version 2 of * -#* the License, or (at your option) any later version. * -#* for detail see the LICENCE text file. * -#* * -#* This program is distributed in the hope that it will be useful, * -#* but WITHOUT ANY WARRANTY; without even the implied warranty of * -#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -#* GNU Library General Public License for more details. * -#* * -#* You should have received a copy of the GNU Library General Public * -#* License along with this program; if not, write to the Free Software * -#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * -#* USA * -#* * -#*************************************************************************** +# *************************************************************************** +# * Copyright (c) 2014 Juergen Riegel * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * This program is distributed in the hope that it will be useful, * +# * but WITHOUT ANY WARRANTY; without even the implied warranty of * +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# * GNU Library General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with this program; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** import FreeCAD @@ -25,11 +25,11 @@ if FreeCAD.GuiUp: import FreeCADGui from PySide import QtCore - #s=os.path.dirname(__file__) - #s=os.path.join(s,"ProfileLib") - #FreeCADGui.addIconPath(s) + # s=os.path.dirname(__file__) + # s=os.path.join(s,"ProfileLib") + # FreeCADGui.addIconPath(s) -__title__="Sketcher profile lib handling" +__title__ = "Sketcher profile lib handling" __author__ = "Juergen Riegel" __url__ = "http://www.freecad.org" @@ -37,30 +37,41 @@ __url__ = "http://www.freecad.org" def isProfileActive(): return not FreeCAD.ActiveDocument is None + def getSketch(): edit = FreeCADGui.ActiveDocument.getInEdit() - if edit and edit.isDerivedFrom('SketcherGui::ViewProviderSketch'): + if edit and edit.isDerivedFrom("SketcherGui::ViewProviderSketch"): return edit.Object - #act = FreeCAD.ActiveDocument.ActiveObject - #if act and act.isDerivedFrom('Sketcher::SketchObject'): + # act = FreeCAD.ActiveDocument.ActiveObject + # if act and act.isDerivedFrom('Sketcher::SketchObject'): # return act return None + class _CommandProfileHexagon1: "The basis hexagon profile command definition" + def GetResources(self): - return {'Pixmap' : 'Sketcher_ProfilesHexagon1', - 'MenuText': QtCore.QT_TRANSLATE_NOOP("Sketcher_ProfilesHexagon1","Creates a hexagonal profile"), - 'Accel': "", - 'CmdType': "ForEdit", - 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Sketcher_ProfilesHexagon1","Creates a hexagonal profile in the sketch")} + return { + "Pixmap": "Sketcher_ProfilesHexagon1", + "MenuText": QtCore.QT_TRANSLATE_NOOP( + "Sketcher_ProfilesHexagon1", "Creates a hexagonal profile" + ), + "Accel": "", + "CmdType": "ForEdit", + "ToolTip": QtCore.QT_TRANSLATE_NOOP( + "Sketcher_ProfilesHexagon1", "Creates a hexagonal profile in the sketch" + ), + } def Activated(self): FreeCAD.ActiveDocument.openTransaction("Create hexagon profile") FreeCADGui.addModule("ProfileLib.Hexagon") sketch = getSketch() if not sketch is None: - FreeCADGui.doCommand("ProfileLib.Hexagon.makeHexagonSimple('%s')" % (sketch.Name)) + FreeCADGui.doCommand( + "ProfileLib.Hexagon.makeHexagonSimple('%s')" % (sketch.Name) + ) else: FreeCADGui.doCommand("ProfileLib.Hexagon.makeHexagonSimple()") FreeCAD.ActiveDocument.recompute() @@ -69,4 +80,4 @@ class _CommandProfileHexagon1: return isProfileActive() -FreeCADGui.addCommand('Sketcher_ProfilesHexagon1',_CommandProfileHexagon1()) +FreeCADGui.addCommand("Sketcher_ProfilesHexagon1", _CommandProfileHexagon1()) diff --git a/src/Mod/Sketcher/SketcherExample.py b/src/Mod/Sketcher/SketcherExample.py index a55f06d974..2cc80e739d 100644 --- a/src/Mod/Sketcher/SketcherExample.py +++ b/src/Mod/Sketcher/SketcherExample.py @@ -10,22 +10,26 @@ EndPoint = 2 MiddlePoint = 3 # create a document and a Sketch object -if(App.activeDocument() is None):App.newDocument() +if App.activeDocument() is None: + App.newDocument() -f = App.activeDocument().addObject("Sketcher::SketchObject","Sketch") +f = App.activeDocument().addObject("Sketcher::SketchObject", "Sketch") # add geometry to the sketch -f.Geometry = [LineSegment(Vector(0,0,0),Vector(2,20,0)),LineSegment(Vector(0,0,0),Vector(20,2,0))] +f.Geometry = [ + LineSegment(Vector(0, 0, 0), Vector(2, 20, 0)), + LineSegment(Vector(0, 0, 0), Vector(20, 2, 0)), +] # add constraints to the sketch -f.Constraints = [Constraint('Vertical',0),Constraint('Horizontal',1)] +f.Constraints = [Constraint("Vertical", 0), Constraint("Horizontal", 1)] # recompute (solving) the sketch App.activeDocument().recompute() # add another constraint to tie the start points together l = f.Constraints -l.append(Constraint('Coincident',0,StartPoint,1,StartPoint)) +l.append(Constraint("Coincident", 0, StartPoint, 1, StartPoint)) f.Constraints = l # again recompute diff --git a/src/Mod/Sketcher/TestSketcherApp.py b/src/Mod/Sketcher/TestSketcherApp.py index a7f1f2c2d7..4960c3ce7a 100644 --- a/src/Mod/Sketcher/TestSketcherApp.py +++ b/src/Mod/Sketcher/TestSketcherApp.py @@ -1,4 +1,4 @@ -#************************************************************************** +# ************************************************************************** # Copyright (c) 2011 Juergen Riegel * # Copyright (c) 2021 Emmanuel O'Brien * # * @@ -19,7 +19,7 @@ # License along with FreeCAD; if not, write to the Free Software * # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * # USA * -#************************************************************************** +# ************************************************************************** # Broken-out test modules from SketcherTests.TestSketcherSolver import TestSketcherSolver diff --git a/src/Mod/Sketcher/TestSketcherGui.py b/src/Mod/Sketcher/TestSketcherGui.py index 3bb1d067d5..29b3c7e043 100644 --- a/src/Mod/Sketcher/TestSketcherGui.py +++ b/src/Mod/Sketcher/TestSketcherGui.py @@ -1,4 +1,4 @@ -#************************************************************************** +# ************************************************************************** # Copyright (c) 2011 Juergen Riegel * # * # This file is part of the FreeCAD CAx development system. * @@ -18,17 +18,17 @@ # License along with FreeCAD; if not, write to the Free Software * # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * # USA * -#************************************************************************** +# ************************************************************************** -#import FreeCAD, FreeCADGui, os, sys, unittest, Sketcher, SketcherGui +# import FreeCAD, FreeCADGui, os, sys, unittest, Sketcher, SketcherGui -#--------------------------------------------------------------------------- +# --------------------------------------------------------------------------- # define the test cases to test the FreeCAD Sketcher module -#--------------------------------------------------------------------------- +# --------------------------------------------------------------------------- -#class SketcherGuiTestCases(unittest.TestCase): +# class SketcherGuiTestCases(unittest.TestCase): # def setUp(self): # self.Doc = FreeCAD.newDocument("SketchGuiTest") #