Merge branch 'master' of ssh://git.code.sf.net/p/free-cad/code

This commit is contained in:
wmayer 2013-08-16 12:59:42 +02:00
commit dc4c861e84
8 changed files with 208 additions and 1 deletions

View File

@ -22,6 +22,7 @@ SET(Arch_SRCS
ArchRoof.py
importWebGL.py
ArchSpace.py
TestArch.py
)
SOURCE_GROUP("" FILES ${Arch_SRCS})

53
src/Mod/Arch/TestArch.py Normal file
View File

@ -0,0 +1,53 @@
# Unit test for the Arch module
#***************************************************************************
#* (c) Yorik van Havre <yorik@uncreated.net> 2013 *
#* *
#* 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 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 *
#* *
#***************************************************************************/
import FreeCAD, os, unittest, FreeCADGui, Arch, Draft
class ArchTest(unittest.TestCase):
def setUp(self):
# setting a new document to hold the tests
if FreeCAD.ActiveDocument:
if FreeCAD.ActiveDocument.Name != "ArchTest":
FreeCAD.newDocument("ArchTest")
else:
FreeCAD.newDocument("ArchTest")
FreeCAD.setActiveDocument("ArchTest")
def testWall(self):
FreeCAD.Console.PrintLog ('Checking Arch Wall...\n')
l=Draft.makeLine(FreeCAD.Vector(0,0,0),FreeCAD.Vector(-2,0,0))
w = Arch.makeWall(l)
self.failUnless(w,"Arch Wall failed")
def testStructure(self):
FreeCAD.Console.PrintLog ('Checking Arch Structure...\n')
s = Arch.makeStructure(length=2,width=3,hright=5)
self.failUnless(s,"Arch Structure failed")
def tearDown(self):
FreeCAD.closeDocument("ArchTest")
pass

View File

@ -17,6 +17,7 @@ SET(Draft_SRCS
importAirfoilDAT.py
macros.py
Draft_rc.py
TestDraft.py
)
SOURCE_GROUP("" FILES ${Draft_SRCS})

View File

@ -514,7 +514,11 @@ def makeCircle(radius, placement=None, face=True, startangle=None, endangle=None
is passed, its Curve must be a Part.Circle'''
import Part, DraftGeomUtils
if placement: typecheck([(placement,FreeCAD.Placement)], "makeCircle")
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Circle")
if startangle != endangle:
n = "Arc"
else:
n = "Circle"
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython",n)
_Circle(obj)
if isinstance(radius,Part.Edge):
edge = radius
@ -888,6 +892,8 @@ def makeEllipse(majradius,minradius,placement=None,face=True,support=None):
a placement.'''
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Ellipse")
_Ellipse(obj)
if minradius > majradius:
majradius,minradius = minradius,majradius
obj.MajorRadius = majradius
obj.MinorRadius = minradius
obj.Support = support

142
src/Mod/Draft/TestDraft.py Normal file
View File

@ -0,0 +1,142 @@
# Unit test for the Draft module
#***************************************************************************
#* (c) Yorik van Havre <yorik@uncreated.net> 2013 *
#* *
#* 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 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 *
#* *
#***************************************************************************/
import FreeCAD, os, unittest, FreeCADGui, Draft
class DraftTest(unittest.TestCase):
def setUp(self):
# setting a new document to hold the tests
if FreeCAD.ActiveDocument:
if FreeCAD.ActiveDocument.Name != "DraftTest":
FreeCAD.newDocument("DraftTest")
else:
FreeCAD.newDocument("DraftTest")
FreeCAD.setActiveDocument("DraftTest")
def testPivy(self):
FreeCAD.Console.PrintLog ('Checking Pivy...\n')
from pivy import coin
c = coin.SoCube()
FreeCADGui.ActiveDocument.ActiveView.getSceneGraph().addChild(c)
self.failUnless(c,"Pivy is not working properly")
# creation tools
def testLine(self):
FreeCAD.Console.PrintLog ('Checking Draft Line...\n')
Draft.makeLine(FreeCAD.Vector(0,0,0),FreeCAD.Vector(-2,0,0))
self.failUnless(FreeCAD.ActiveDocument.getObject("Line"),"Draft Line failed")
def testWire(self):
FreeCAD.Console.PrintLog ('Checking Draft Wire...\n')
Draft.makeWire([FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0),FreeCAD.Vector(2,2,0)])
self.failUnless(FreeCAD.ActiveDocument.getObject("DWire"),"Draft Wire failed")
def testBSpline(self):
FreeCAD.Console.PrintLog ('Checking Draft BSpline...\n')
Draft.makeBSpline([FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0),FreeCAD.Vector(2,2,0)])
self.failUnless(FreeCAD.ActiveDocument.getObject("BSpline"),"Draft BSpline failed")
def testRectangle(self):
FreeCAD.Console.PrintLog ('Checking Draft Rectangle...\n')
Draft.makeRectangle(4,2)
self.failUnless(FreeCAD.ActiveDocument.getObject("Rectangle"),"Draft Rectangle failed")
def testArc(self):
FreeCAD.Console.PrintLog ('Checking Draft Arc...\n')
Draft.makeCircle(2, startangle=0, endangle=90)
self.failUnless(FreeCAD.ActiveDocument.getObject("Arc"),"Draft Arc failed")
def testCircle(self):
FreeCAD.Console.PrintLog ('Checking Draft Circle...\n')
Draft.makeCircle(3)
self.failUnless(FreeCAD.ActiveDocument.getObject("Circle"),"Draft Circle failed")
def testPolygon(self):
FreeCAD.Console.PrintLog ('Checking Draft Polygon...\n')
Draft.makePolygon(5,5)
self.failUnless(FreeCAD.ActiveDocument.getObject("Polygon"),"Draft Polygon failed")
def testEllipse(self):
FreeCAD.Console.PrintLog ('Checking Draft Ellipse...\n')
Draft.makeEllipse(5,3)
self.failUnless(FreeCAD.ActiveDocument.getObject("Ellipse"),"Draft Ellipse failed")
def testPoint(self):
FreeCAD.Console.PrintLog ('Checking Draft Point...\n')
Draft.makePoint(5,3,2)
self.failUnless(FreeCAD.ActiveDocument.getObject("Point"),"Draft Point failed")
def testText(self):
FreeCAD.Console.PrintLog ('Checking Draft Text...\n')
Draft.makeText("Testing Draft")
self.failUnless(FreeCAD.ActiveDocument.getObject("Text"),"Draft Text failed")
#def testShapeString(self):
# not working ATM because it needs a font file
# FreeCAD.Console.PrintLog ('Checking Draft ShapeString...\n')
# Draft.makeShapeString("Testing Draft")
# self.failUnless(FreeCAD.ActiveDocument.getObject("ShapeString"),"Draft ShapeString failed")
def testDimension(self):
FreeCAD.Console.PrintLog ('Checking Draft Dimension...\n')
Draft.makeDimension(FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0),FreeCAD.Vector(1,-1,0))
self.failUnless(FreeCAD.ActiveDocument.getObject("Dimension"),"Draft Dimension failed")
# modification tools
def testMove(self):
FreeCAD.Console.PrintLog ('Checking Draft Move...\n')
l = Draft.makeLine(FreeCAD.Vector(0,0,0),FreeCAD.Vector(-2,0,0))
Draft.move(l,FreeCAD.Vector(2,0,0))
self.failUnless(l.Start == FreeCAD.Vector(2,0,0),"Draft Move failed")
def testCopy(self):
FreeCAD.Console.PrintLog ('Checking Draft Move with copy...\n')
l = Draft.makeLine(FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0))
l2 = Draft.move(l,FreeCAD.Vector(2,0,0),copy=True)
self.failUnless(l2,"Draft Move with copy failed")
def testRotate(self):
FreeCAD.Console.PrintLog ('Checking Draft Rotate...\n')
l = Draft.makeLine(FreeCAD.Vector(2,0,0),FreeCAD.Vector(4,0,0))
Draft.rotate(l,90)
self.failUnless(l.Start == FreeCAD.Vector(0,2,0),"Draft Rotate failed")
def testOffset(self):
FreeCAD.Console.PrintLog ('Checking Draft Offset...\n')
r = Draft.makeRectangle(4,2)
r2 = Draft.offset(r,FreeCAD.Vector(-1,-1,0),copy=True)
self.failUnless(r2,"Draft Offset failed")
# modification tools
def tearDown(self):
FreeCAD.closeDocument("DraftTest")
pass

View File

@ -51,6 +51,8 @@ def All():
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestSketcherGui") )
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestPartGui") )
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestPartDesignGui") )
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestDraft") )
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestArch") )
return suite

View File

@ -46,6 +46,7 @@
<File Id="ArchRoofPy" Name="ArchRoof.py" DiskId="1" />
<File Id="importWebGLPy" Name="importWebGL.py" DiskId="1" />
<File Id="ArchSpacePy" Name="ArchSpace.py" DiskId="1" />
<File Id="TestArchPy" Name="TestArch.py" DiskId="1" />
</Component>
</Directory>
</Include>

View File

@ -41,6 +41,7 @@
<File Id="DraftVecUtilsPy" Name="DraftVecUtils.py" DiskId="1" />
<File Id="DraftGeomUtilsPy" Name="DraftGeomUtils.py" DiskId="1" />
<File Id="importDWGPy" Name="importDWG.py" DiskId="1" />
<File Id="TestDraftPy" Name="TestDraft.py" DiskId="1" />
</Component>
</Directory>
</Include>