Draft: removed unnecessary uses of DraftVecUtils
This commit is contained in:
parent
8b75c6a206
commit
b3f79881c5
|
@ -362,9 +362,9 @@ def getCutVolume(cutplane,shapes):
|
|||
wm1 = DraftVecUtils.project(dv,ax).Length
|
||||
wm = max(wm,wm1)
|
||||
vu = DraftVecUtils.scaleTo(u,um)
|
||||
vui = DraftVecUtils.neg(vu)
|
||||
vui = vu.negative()
|
||||
vv = DraftVecUtils.scaleTo(v,vm)
|
||||
vvi = DraftVecUtils.neg(vv)
|
||||
vvi = vv.negative()
|
||||
p1 = ce.add(vu.add(vvi))
|
||||
p2 = ce.add(vu.add(vv))
|
||||
p3 = ce.add(vui.add(vv))
|
||||
|
@ -373,7 +373,7 @@ def getCutVolume(cutplane,shapes):
|
|||
cutface = Part.Face(cutface)
|
||||
cutnormal = DraftVecUtils.scaleTo(ax,wm)
|
||||
cutvolume = cutface.extrude(cutnormal)
|
||||
cutnormal = DraftVecUtils.neg(cutnormal)
|
||||
cutnormal = cutnormal.negative()
|
||||
invcutvolume = cutface.extrude(cutnormal)
|
||||
return cutface,cutvolume,invcutvolume
|
||||
|
||||
|
@ -459,7 +459,7 @@ def removeShape(objs,mark=True):
|
|||
length = dims[1]
|
||||
width = dims[2]
|
||||
v1 = Vector(length/2,0,0)
|
||||
v2 = DraftVecUtils.neg(v1)
|
||||
v2 = v1.negative()
|
||||
v1 = dims[0].multVec(v1)
|
||||
v2 = dims[0].multVec(v2)
|
||||
line = Draft.makeLine(v1,v2)
|
||||
|
|
|
@ -308,8 +308,8 @@ class Component:
|
|||
n = f.normalAt(0,0)
|
||||
v1 = DraftVecUtils.scaleTo(n,width*1.1) # we extrude a little more to avoid face-on-face
|
||||
f.translate(v1)
|
||||
v2 = DraftVecUtils.neg(v1)
|
||||
v2 = DraftVecUtils.scale(v1,-2)
|
||||
v2 = v1.negative()
|
||||
v2 = v1.multiply(-2)
|
||||
f = f.extrude(v2)
|
||||
if plac:
|
||||
f.Placement = plac
|
||||
|
|
|
@ -227,7 +227,7 @@ class _CommandWall:
|
|||
elif self.Align == "Left":
|
||||
self.tracker.update([b.add(dv),point.add(dv)])
|
||||
else:
|
||||
dv = DraftVecUtils.neg(dv)
|
||||
dv = dv.negative()
|
||||
self.tracker.update([b.add(dv),point.add(dv)])
|
||||
if self.Length:
|
||||
self.Length.setValue(bv.Length)
|
||||
|
@ -417,14 +417,14 @@ class _Wall(ArchComponent.Component):
|
|||
sh = DraftGeomUtils.bind(w1,w2)
|
||||
elif obj.Align == "Right":
|
||||
dvec = dvec.multiply(width)
|
||||
dvec = DraftVecUtils.neg(dvec)
|
||||
dvec = dvec.negative()
|
||||
w2 = DraftGeomUtils.offsetWire(wire,dvec)
|
||||
w1 = Part.Wire(DraftGeomUtils.sortEdges(wire.Edges))
|
||||
sh = DraftGeomUtils.bind(w1,w2)
|
||||
elif obj.Align == "Center":
|
||||
dvec = dvec.multiply(width/2)
|
||||
w1 = DraftGeomUtils.offsetWire(wire,dvec)
|
||||
dvec = DraftVecUtils.neg(dvec)
|
||||
dvec = dvec.negative()
|
||||
w2 = DraftGeomUtils.offsetWire(wire,dvec)
|
||||
sh = DraftGeomUtils.bind(w1,w2)
|
||||
# fixing self-intersections
|
||||
|
|
|
@ -1018,12 +1018,12 @@ def array(objectslist,arg1,arg2,arg3,arg4=None):
|
|||
typecheck([(xvector,Vector), (yvector,Vector), (xnum,int), (ynum,int)], "rectArray")
|
||||
if not isinstance(objectslist,list): objectslist = [objectslist]
|
||||
for xcount in range(xnum):
|
||||
currentxvector=DraftVecUtils.scale(xvector,xcount)
|
||||
currentxvector=xvector.multiply(xcount)
|
||||
if not xcount==0:
|
||||
move(objectslist,currentxvector,True)
|
||||
for ycount in range(ynum):
|
||||
currentxvector=FreeCAD.Base.Vector(currentxvector)
|
||||
currentyvector=currentxvector.add(DraftVecUtils.scale(yvector,ycount))
|
||||
currentyvector=currentxvector.add(yvector.multiply(ycount))
|
||||
if not ycount==0:
|
||||
move(objectslist,currentyvector,True)
|
||||
def polarArray(objectslist,center,angle,num):
|
||||
|
@ -1111,7 +1111,7 @@ def scale(objectslist,delta=Vector(1,1,1),center=Vector(0,0,0),copy=False,legacy
|
|||
sh = sh.transformGeometry(m)
|
||||
corr = Vector(center.x,center.y,center.z)
|
||||
corr.scale(delta.x,delta.y,delta.z)
|
||||
corr = DraftVecUtils.neg(corr.sub(center))
|
||||
corr = (corr.sub(center)).negative()
|
||||
sh.translate(corr)
|
||||
if getType(obj) == "Rectangle":
|
||||
p = []
|
||||
|
@ -1155,7 +1155,7 @@ def scale(objectslist,delta=Vector(1,1,1),center=Vector(0,0,0),copy=False,legacy
|
|||
obj.Scale = delta
|
||||
corr = Vector(center.x,center.y,center.z)
|
||||
corr.scale(delta.x,delta.y,delta.z)
|
||||
corr = DraftVecUtils.neg(corr.sub(center))
|
||||
corr = (corr.sub(center)).negative()
|
||||
p = obj.Placement
|
||||
p.move(corr)
|
||||
obj.Placement = p
|
||||
|
@ -1213,7 +1213,7 @@ def offset(obj,delta,copy=False,bind=False,sym=False,occ=False):
|
|||
else:
|
||||
if sym:
|
||||
d1 = delta.multiply(0.5)
|
||||
d2 = DraftVecUtils.neg(d1)
|
||||
d2 = d1.negative()
|
||||
n1 = DraftGeomUtils.offsetWire(obj.Shape,d1)
|
||||
n2 = DraftGeomUtils.offsetWire(obj.Shape,d2)
|
||||
else:
|
||||
|
@ -1348,7 +1348,7 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct
|
|||
if isinstance(direction,FreeCAD.Vector):
|
||||
if direction != Vector(0,0,0):
|
||||
plane = WorkingPlane.plane()
|
||||
plane.alignToPointAndAxis(Vector(0,0,0),DraftVecUtils.neg(direction),0)
|
||||
plane.alignToPointAndAxis(Vector(0,0,0),direction.negative(),0)
|
||||
elif isinstance(direction,WorkingPlane.plane):
|
||||
plane = direction
|
||||
|
||||
|
@ -2606,35 +2606,35 @@ class _ViewProviderDimension(_ViewProviderDraft):
|
|||
p2 = p1
|
||||
p3 = p4
|
||||
else:
|
||||
p2 = p1.add(DraftVecUtils.neg(proj))
|
||||
p3 = p4.add(DraftVecUtils.neg(proj))
|
||||
p2 = p1.add(proj.negative())
|
||||
p3 = p4.add(proj.negative())
|
||||
dmax = obj.ViewObject.ExtLines
|
||||
if dmax and (proj.Length > dmax):
|
||||
p1 = p2.add(DraftVecUtils.scaleTo(proj,dmax))
|
||||
p4 = p3.add(DraftVecUtils.scaleTo(proj,dmax))
|
||||
midpoint = p2.add(DraftVecUtils.scale(p3.sub(p2),0.5))
|
||||
midpoint = p2.add((p3.sub(p2).multiply(0.5)))
|
||||
if not proj:
|
||||
ed = DraftGeomUtils.vec(base)
|
||||
proj = ed.cross(Vector(0,0,1))
|
||||
if not proj: norm = Vector(0,0,1)
|
||||
else: norm = DraftVecUtils.neg(p3.sub(p2).cross(proj))
|
||||
else: norm = (p3.sub(p2).cross(proj)).negative()
|
||||
if not DraftVecUtils.isNull(norm):
|
||||
norm.normalize()
|
||||
va = get3DView().getViewDirection()
|
||||
if va.getAngle(norm) < math.pi/2:
|
||||
norm = DraftVecUtils.neg(norm)
|
||||
norm = norm.negative()
|
||||
u = p3.sub(p2)
|
||||
u.normalize()
|
||||
c = get3DView().getCameraNode()
|
||||
r = c.orientation.getValue()
|
||||
ru = Vector(r.multVec(coin.SbVec3f(1,0,0)).getValue())
|
||||
if ru.getAngle(u) > math.pi/2: u = DraftVecUtils.neg(u)
|
||||
if ru.getAngle(u) > math.pi/2: u = u.negative()
|
||||
v = norm.cross(u)
|
||||
offset = DraftVecUtils.scaleTo(v,obj.ViewObject.FontSize*.2)
|
||||
if obj.ViewObject:
|
||||
if hasattr(obj.ViewObject,"DisplayMode"):
|
||||
if obj.ViewObject.DisplayMode == "3D":
|
||||
offset = DraftVecUtils.neg(offset)
|
||||
offset = offset.negative()
|
||||
if hasattr(obj.ViewObject,"TextPosition"):
|
||||
if obj.ViewObject.TextPosition == Vector(0,0,0):
|
||||
tbase = midpoint.add(offset)
|
||||
|
@ -2733,7 +2733,7 @@ class _ViewProviderDimension(_ViewProviderDraft):
|
|||
if obj.LinkedVertices[1] == 1:
|
||||
v1 = c
|
||||
else:
|
||||
v1 = c.add(DraftVecUtils.neg(bray))
|
||||
v1 = c.add(bray.negative())
|
||||
v2 = c.add(bray)
|
||||
else:
|
||||
# linear linked dimension
|
||||
|
@ -3695,21 +3695,21 @@ class _Array(_DraftObject):
|
|||
import Part
|
||||
base = [shape.copy()]
|
||||
for xcount in range(xnum):
|
||||
currentxvector=DraftVecUtils.scale(xvector,xcount)
|
||||
currentxvector=xvector.multiply(xcount)
|
||||
if not xcount==0:
|
||||
nshape = shape.copy()
|
||||
nshape.translate(currentxvector)
|
||||
base.append(nshape)
|
||||
for ycount in range(ynum):
|
||||
currentyvector=FreeCAD.Vector(currentxvector)
|
||||
currentyvector=currentyvector.add(DraftVecUtils.scale(yvector,ycount))
|
||||
currentyvector=currentyvector.add(yvector.multiply(ycount))
|
||||
if not ycount==0:
|
||||
nshape = shape.copy()
|
||||
nshape.translate(currentyvector)
|
||||
base.append(nshape)
|
||||
for zcount in range(znum):
|
||||
currentzvector=FreeCAD.Vector(currentyvector)
|
||||
currentzvector=currentzvector.add(DraftVecUtils.scale(zvector,zcount))
|
||||
currentzvector=currentzvector.add(zvector.multiply(zcount))
|
||||
if not zcount==0:
|
||||
nshape = shape.copy()
|
||||
nshape.translate(currentzvector)
|
||||
|
|
|
@ -413,8 +413,8 @@ def geom(edge,plac=FreeCAD.Placement()):
|
|||
c = edge.Curve.Center
|
||||
cu = Part.Circle(edge.Curve.Center,normal,edge.Curve.Radius)
|
||||
ref = plac.Rotation.multVec(Vector(1,0,0))
|
||||
a1 = DraftVecUtils.angle(v1.sub(c),ref,DraftVecUtils.neg(normal))
|
||||
a2 = DraftVecUtils.angle(v2.sub(c),ref,DraftVecUtils.neg(normal))
|
||||
a1 = DraftVecUtils.angle(v1.sub(c),ref,normal.negative())
|
||||
a2 = DraftVecUtils.angle(v2.sub(c),ref,normal.negative())
|
||||
|
||||
# direction check
|
||||
if edge.Curve.Axis.getAngle(normal) > 1:
|
||||
|
@ -431,7 +431,7 @@ def mirror (point, edge):
|
|||
normPoint = point.add(findDistance(point, edge, False))
|
||||
if normPoint:
|
||||
normPoint_point = Vector.sub(point, normPoint)
|
||||
normPoint_refl = DraftVecUtils.neg(normPoint_point)
|
||||
normPoint_refl = normPoint_point.negative()
|
||||
refl = Vector.add(normPoint, normPoint_refl)
|
||||
return refl
|
||||
else:
|
||||
|
@ -451,7 +451,7 @@ def isClockwise(edge,ref=None):
|
|||
if not ref:
|
||||
ref = Vector(0,0,1)
|
||||
if n.getAngle(ref) > math.pi/2:
|
||||
n = DraftVecUtils.neg(n)
|
||||
n = n.negative()
|
||||
if DraftVecUtils.angle(v1,v2,n) < 0:
|
||||
return False
|
||||
if n.z < 0:
|
||||
|
@ -734,7 +734,7 @@ def findMidpoint(edge):
|
|||
if len(edge.Vertexes) == 1:
|
||||
# Circle
|
||||
dv = first.sub(center)
|
||||
dv = DraftVecUtils.neg(dv)
|
||||
dv = dv.negative()
|
||||
return center.add(dv)
|
||||
axis = edge.Curve.Axis
|
||||
chord = last.sub(first)
|
||||
|
@ -743,12 +743,12 @@ def findMidpoint(edge):
|
|||
ray = first.sub(center)
|
||||
apothem = ray.dot(perp)
|
||||
sagitta = radius - apothem
|
||||
startpoint = Vector.add(first, DraftVecUtils.scale(chord,0.5))
|
||||
startpoint = Vector.add(first, chord.multiply(0.5))
|
||||
endpoint = DraftVecUtils.scaleTo(perp,sagitta)
|
||||
return Vector.add(startpoint,endpoint)
|
||||
|
||||
elif geomType(edge) == "Line":
|
||||
halfedge = DraftVecUtils.scale(last.sub(first),.5)
|
||||
halfedge = (last.sub(first)).multiply(.5)
|
||||
return Vector.add(first,halfedge)
|
||||
|
||||
else:
|
||||
|
@ -863,7 +863,8 @@ def getNormal(shape):
|
|||
if FreeCAD.GuiUp:
|
||||
import Draft
|
||||
vdir = Draft.get3DView().getViewDirection()
|
||||
if n.getAngle(vdir) < 0.78: n = DraftVecUtils.neg(n)
|
||||
if n.getAngle(vdir) < 0.78:
|
||||
n = n.negative()
|
||||
return n
|
||||
|
||||
def getRotation(v1,v2=FreeCAD.Vector(0,0,1)):
|
||||
|
@ -1016,7 +1017,7 @@ def findDistance(point,edge,strict=False):
|
|||
center = edge.Curve.Center
|
||||
segment = center.sub(point)
|
||||
ratio = (segment.Length - edge.Curve.Radius) / segment.Length
|
||||
dist = DraftVecUtils.scale(segment,ratio)
|
||||
dist = segment.multiply(ratio)
|
||||
newpoint = Vector.add(point, dist)
|
||||
if (dist.Length == 0):
|
||||
return None
|
||||
|
@ -1066,7 +1067,7 @@ def angleBisection(edge1, edge2):
|
|||
return Part.Line(origin,origin.add(dir)).toShape()
|
||||
else:
|
||||
diff = p3.sub(p1)
|
||||
origin = p1.add(DraftVecUtils.scale(diff, 0.5))
|
||||
origin = p1.add(diff.multiply(0.5))
|
||||
dir = p2.sub(p1); dir.normalize()
|
||||
return Part.Line(origin,origin.add(dir)).toShape()
|
||||
else:
|
||||
|
@ -1870,8 +1871,8 @@ def circlefrom1Line2Points(edge, p1, p2):
|
|||
v2 = p2.sub(s)
|
||||
projectedDist = math.sqrt(abs(v1.dot(v2)))
|
||||
edgeDir = vec(edge); edgeDir.normalize()
|
||||
projectedCen1 = Vector.add(s, DraftVecUtils.scale(edgeDir, projectedDist))
|
||||
projectedCen2 = Vector.add(s, DraftVecUtils.scale(edgeDir, -projectedDist))
|
||||
projectedCen1 = Vector.add(s, edgeDir.multiply(projectedDist))
|
||||
projectedCen2 = Vector.add(s, edgeDir.multiply(-projectedDist))
|
||||
perpEdgeDir = edgeDir.cross(Vector(0,0,1))
|
||||
perpCen1 = Vector.add(projectedCen1, perpEdgeDir)
|
||||
perpCen2 = Vector.add(projectedCen2, perpEdgeDir)
|
||||
|
@ -1903,13 +1904,13 @@ def circleFrom2LinesRadius (edge1, edge2, radius):
|
|||
dist12 = radius / math.sin(ang12 * 0.5)
|
||||
dist21 = radius / math.sin(ang21 * 0.5)
|
||||
circles = []
|
||||
cen = Vector.add(int, DraftVecUtils.scale(vec(bis12), dist12))
|
||||
cen = Vector.add(int, vec(bis12).multiply(dist12))
|
||||
circles.append(Part.Circle(cen, NORM, radius))
|
||||
cen = Vector.add(int, DraftVecUtils.scale(vec(bis12), -dist12))
|
||||
cen = Vector.add(int, vec(bis12).multiply(-dist12))
|
||||
circles.append(Part.Circle(cen, NORM, radius))
|
||||
cen = Vector.add(int, DraftVecUtils.scale(vec(bis21), dist21))
|
||||
cen = Vector.add(int, vec(bis21).multiply(dist21))
|
||||
circles.append(Part.Circle(cen, NORM, radius))
|
||||
cen = Vector.add(int, DraftVecUtils.scale(vec(bis21), -dist21))
|
||||
cen = Vector.add(int, vec(bis21).multiply(-dist21))
|
||||
circles.append(Part.Circle(cen, NORM, radius))
|
||||
return circles
|
||||
|
||||
|
@ -1967,15 +1968,15 @@ def circleFromPointLineRadius (point, edge, radius):
|
|||
if dist.Length == 0:
|
||||
segment = vec(edge)
|
||||
perpVec = DraftVecUtils.crossproduct(segment); perpVec.normalize()
|
||||
normPoint_c1 = DraftVecUtils.scale(perpVec, radius)
|
||||
normPoint_c2 = DraftVecUtils.scale(perpVec, -radius)
|
||||
normPoint_c1 = perpVec.multiply(radius)
|
||||
normPoint_c2 = perpVec.multiply(-radius)
|
||||
center1 = point.add(normPoint_c1)
|
||||
center2 = point.add(normPoint_c2)
|
||||
elif dist.Length > 2 * radius:
|
||||
return None
|
||||
elif dist.Length == 2 * radius:
|
||||
normPoint = point.add(findDistance(point, edge, False))
|
||||
dummy = DraftVecUtils.scale(normPoint.sub(point), 0.5)
|
||||
dummy = (normPoint.sub(point)).multiply(0.5)
|
||||
cen = point.add(dummy)
|
||||
circ = Part.Circle(cen, NORM, radius)
|
||||
if circ:
|
||||
|
@ -1988,8 +1989,8 @@ def circleFromPointLineRadius (point, edge, radius):
|
|||
dist = math.sqrt(radius**2 - (radius - normDist)**2)
|
||||
centerNormVec = DraftVecUtils.scaleTo(point.sub(normPoint), radius)
|
||||
edgeDir = edge.Vertexes[0].Point.sub(normPoint); edgeDir.normalize()
|
||||
center1 = centerNormVec.add(normPoint.add(DraftVecUtils.scale(edgeDir, dist)))
|
||||
center2 = centerNormVec.add(normPoint.add(DraftVecUtils.scale(edgeDir, -dist)))
|
||||
center1 = centerNormVec.add(normPoint.add(edgeDir.multiply(dist)))
|
||||
center2 = centerNormVec.add(normPoint.add(edgeDir.multiply(-dist)))
|
||||
circles = []
|
||||
if center1:
|
||||
circ = Part.Circle(center1, NORM, radius)
|
||||
|
@ -2019,8 +2020,8 @@ def circleFrom2PointsRadius(p1, p2, radius):
|
|||
dir = vec(p1_p2); dir.normalize()
|
||||
perpDir = dir.cross(Vector(0,0,1)); perpDir.normailze()
|
||||
dist = math.sqrt(radius**2 - (dist_p1p2 / 2.0)**2)
|
||||
cen1 = Vector.add(mid, DraftVecUtils.scale(perpDir, dist))
|
||||
cen2 = Vector.add(mid, DraftVecUtils.scale(perpDir, -dist))
|
||||
cen1 = Vector.add(mid, perpDir.multiply(dist))
|
||||
cen2 = Vector.add(mid, perpDir.multiply(-dist))
|
||||
circles = []
|
||||
if cen1: circles.append(Part.Circle(cen1, norm, radius))
|
||||
if cen2: circles.append(Part.Circle(cen2, norm, radius))
|
||||
|
@ -2265,12 +2266,12 @@ def findHomotheticCenterOfCircles(circle1, circle2):
|
|||
perpCenDir = cenDir.cross(Vector(0,0,1)); perpCenDir.normalize()
|
||||
|
||||
# Get point on first circle
|
||||
p1 = Vector.add(circle1.Curve.Center, DraftVecUtils.scale(perpCenDir, circle1.Curve.Radius))
|
||||
p1 = Vector.add(circle1.Curve.Center, perpCenDir.multiply(circle1.Curve.Radius))
|
||||
|
||||
centers = []
|
||||
# Calculate inner homothetic center
|
||||
# Get point on second circle
|
||||
p2_inner = Vector.add(circle1.Curve.Center, DraftVecUtils.scale(perpCenDir, -circle1.Curve.Radius))
|
||||
p2_inner = Vector.add(circle1.Curve.Center, perpCenDir.multiply(-circle1.Curve.Radius))
|
||||
hCenterInner = DraftVecUtils.intersect(circle1.Curve.Center, circle2.Curve.Center, p1, p2_inner, True, True)
|
||||
if hCenterInner:
|
||||
centers.append(hCenterInner)
|
||||
|
@ -2278,7 +2279,7 @@ def findHomotheticCenterOfCircles(circle1, circle2):
|
|||
# Calculate outer homothetic center (only exists of the circles have different radii)
|
||||
if circle1.Curve.Radius != circle2.Curve.Radius:
|
||||
# Get point on second circle
|
||||
p2_outer = Vector.add(circle1.Curve.Center, DraftVecUtils.scale(perpCenDir, circle1.Curve.Radius))
|
||||
p2_outer = Vector.add(circle1.Curve.Center, perpCenDir.multiply(circle1.Curve.Radius))
|
||||
hCenterOuter = DraftVecUtils.intersect(circle1.Curve.Center, circle2.Curve.Center, p1, p2_outer, True, True)
|
||||
if hCenterOuter:
|
||||
centers.append(hCenterOuter)
|
||||
|
@ -2328,7 +2329,7 @@ def findRadicalAxis(circle1, circle2):
|
|||
k1 = (dist + (r1^2 - r2^2) / dist) / 2.0
|
||||
#k2 = dist - k1
|
||||
|
||||
K = Vector.add(cen1, DraftVecUtils.scale(cenDir, k1))
|
||||
K = Vector.add(cen1, cenDir.multiply(k1))
|
||||
|
||||
# K_ .. A point somewhere between K and J (actually with a distance of 1 unit from K).
|
||||
K_ = Vector,add(K, perpCenDir)
|
||||
|
|
|
@ -466,13 +466,13 @@ class Snapper:
|
|||
FreeCAD.Vector(0,0,1)]
|
||||
for a in self.polarAngles:
|
||||
if a == 90:
|
||||
vecs.extend([ax[0],DraftVecUtils.neg(ax[0])])
|
||||
vecs.extend([ax[1],DraftVecUtils.neg(ax[1])])
|
||||
vecs.extend([ax[0],ax[0].negative()])
|
||||
vecs.extend([ax[1],ax[1].negative()])
|
||||
else:
|
||||
v = DraftVecUtils.rotate(ax[0],math.radians(a),ax[2])
|
||||
vecs.extend([v,DraftVecUtils.neg(v)])
|
||||
vecs.extend([v,v.negative()])
|
||||
v = DraftVecUtils.rotate(ax[1],math.radians(a),ax[2])
|
||||
vecs.extend([v,DraftVecUtils.neg(v)])
|
||||
vecs.extend([v,v.negative()])
|
||||
for v in vecs:
|
||||
de = Part.Line(last,last.add(v)).toShape()
|
||||
np = self.getPerpendicular(de,point)
|
||||
|
|
|
@ -377,7 +377,7 @@ class SelectPlane(DraftTool):
|
|||
self.display('side')
|
||||
self.finish()
|
||||
elif arg == "currentView":
|
||||
viewDirection = DraftVecUtils.neg(self.view.getViewDirection())
|
||||
viewDirection = self.view.getViewDirection().negative()
|
||||
plane.alignToPointAndAxis(Vector(0,0,0), viewDirection, self.offset)
|
||||
self.display(viewDirection)
|
||||
self.finish()
|
||||
|
@ -775,10 +775,10 @@ class Rectangle(Creator):
|
|||
base = p1
|
||||
if length < 0:
|
||||
length = -length
|
||||
base = base.add(DraftVecUtils.neg(p1.sub(p4)))
|
||||
base = base.add((p1.sub(p4)).negative())
|
||||
if height < 0:
|
||||
height = -height
|
||||
base = base.add(DraftVecUtils.neg(p1.sub(p2)))
|
||||
base = base.add((p1.sub(p2)).negative())
|
||||
self.commit(translate("draft","Create Plane"),
|
||||
['plane = FreeCAD.ActiveDocument.addObject("Part::Plane","Plane")',
|
||||
'plane.Length = '+str(length),
|
||||
|
@ -910,7 +910,7 @@ class Arc(Creator):
|
|||
if self.center and DraftVecUtils.dist(self.point,self.center) > 0:
|
||||
viewdelta = DraftVecUtils.project(self.point.sub(self.center), plane.axis)
|
||||
if not DraftVecUtils.isNull(viewdelta):
|
||||
self.point = self.point.add(DraftVecUtils.neg(viewdelta))
|
||||
self.point = self.point.add(viewdelta.negative())
|
||||
if (self.step == 0): # choose center
|
||||
if hasMod(arg,MODALT):
|
||||
if not self.altdown:
|
||||
|
@ -1197,7 +1197,7 @@ class Polygon(Creator):
|
|||
if self.center and DraftVecUtils.dist(self.point,self.center) > 0:
|
||||
viewdelta = DraftVecUtils.project(self.point.sub(self.center), plane.axis)
|
||||
if not DraftVecUtils.isNull(viewdelta):
|
||||
self.point = self.point.add(DraftVecUtils.neg(viewdelta))
|
||||
self.point = self.point.add(viewdelta.negative())
|
||||
if (self.step == 0): # choose center
|
||||
if hasMod(arg,MODALT):
|
||||
if not self.altdown:
|
||||
|
@ -1351,7 +1351,7 @@ class Ellipse(Creator):
|
|||
p1 = self.node[0]
|
||||
p3 = self.node[-1]
|
||||
diagonal = p3.sub(p1)
|
||||
halfdiag = DraftVecUtils.scale(diagonal,0.5)
|
||||
halfdiag = diagonal.multiply(0.5)
|
||||
center = p1.add(halfdiag)
|
||||
p2 = p1.add(DraftVecUtils.project(diagonal, plane.v))
|
||||
p4 = p1.add(DraftVecUtils.project(diagonal, plane.u))
|
||||
|
@ -1655,7 +1655,7 @@ class Dimension(Creator):
|
|||
rad = self.edges[0].Curve.Radius
|
||||
baseray = self.point.sub(cen)
|
||||
v2 = DraftVecUtils.scaleTo(baseray,rad)
|
||||
v1 = DraftVecUtils.neg(v2)
|
||||
v1 = v2.negative()
|
||||
if shift:
|
||||
self.node = [cen,cen.add(v2)]
|
||||
self.arcmode = "radius"
|
||||
|
@ -1761,7 +1761,7 @@ class Dimension(Creator):
|
|||
# for unlinked arc mode:
|
||||
# if self.arcmode:
|
||||
# v = self.node[1].sub(self.node[0])
|
||||
# v = DraftVecUtils.scale(v,0.5)
|
||||
# v = v.multiply(0.5)
|
||||
# cen = self.node[0].add(v)
|
||||
# self.node = [self.node[0],self.node[1],cen]
|
||||
self.createObject()
|
||||
|
@ -2143,7 +2143,7 @@ class Rotate(Modifier):
|
|||
if self.center and DraftVecUtils.dist(self.point,self.center):
|
||||
viewdelta = DraftVecUtils.project(self.point.sub(self.center), plane.axis)
|
||||
if not DraftVecUtils.isNull(viewdelta):
|
||||
self.point = self.point.add(DraftVecUtils.neg(viewdelta))
|
||||
self.point = self.point.add(viewdelta.negative())
|
||||
if self.extendedCopy:
|
||||
if not hasMod(arg,MODALT):
|
||||
self.step = 3
|
||||
|
@ -2322,7 +2322,7 @@ class Offset(Modifier):
|
|||
if dist:
|
||||
self.ghost.on()
|
||||
if self.mode == "Wire":
|
||||
d = DraftVecUtils.neg(dist[0])
|
||||
d = dist[0].negative()
|
||||
v1 = DraftGeomUtils.getTangent(self.shape.Edges[0],self.point)
|
||||
v2 = DraftGeomUtils.getTangent(self.shape.Edges[dist[1]],self.point)
|
||||
a = -DraftVecUtils.angle(v1,v2)
|
||||
|
@ -2330,7 +2330,7 @@ class Offset(Modifier):
|
|||
occmode = self.ui.occOffset.isChecked()
|
||||
self.ghost.update(DraftGeomUtils.offsetWire(self.shape,self.dvec,occ=occmode),forceclosed=occmode)
|
||||
elif self.mode == "BSpline":
|
||||
d = DraftVecUtils.neg(dist[0])
|
||||
d = dist[0].negative()
|
||||
e = self.shape.Edges[0]
|
||||
basetan = DraftGeomUtils.getTangent(e,self.point)
|
||||
self.npts = []
|
||||
|
@ -2656,7 +2656,7 @@ class Trimex(Modifier):
|
|||
if real:
|
||||
if self.force:
|
||||
ray = self.newpoint.sub(v1)
|
||||
ray = DraftVecUtils.scale(ray,self.force/ray.Length)
|
||||
ray = ray.multiply(self.force/ray.Length)
|
||||
self.newpoint = Vector.add(v1,ray)
|
||||
newedges.append(Part.Line(self.newpoint,v2).toShape())
|
||||
else:
|
||||
|
@ -2865,7 +2865,7 @@ class Scale(Modifier):
|
|||
# calculate a correction factor depending on the scaling center
|
||||
corr = Vector(self.node[0].x,self.node[0].y,self.node[0].z)
|
||||
corr.scale(delta.x,delta.y,delta.z)
|
||||
corr = DraftVecUtils.neg(corr.sub(self.node[0]))
|
||||
corr = (corr.sub(self.node[0])).negative()
|
||||
self.ghost.move(corr)
|
||||
self.ghost.on()
|
||||
if self.extendedCopy:
|
||||
|
@ -3070,9 +3070,11 @@ class Edit(Modifier):
|
|||
self.editpoints.append(self.obj.Shape.Vertexes[2].Point)
|
||||
v = self.obj.Shape.Vertexes
|
||||
self.bx = v[1].Point.sub(v[0].Point)
|
||||
if self.obj.Length < 0: self.bx = DraftVecUtils.neg(self.bx)
|
||||
if self.obj.Length < 0:
|
||||
self.bx = self.bx.negative()
|
||||
self.by = v[2].Point.sub(v[1].Point)
|
||||
if self.obj.Height < 0: self.by = DraftVecUtils.neg(self.by)
|
||||
if self.obj.Height < 0:
|
||||
self.by = self.by.negative()
|
||||
elif Draft.getType(self.obj) == "Polygon":
|
||||
self.editpoints.append(self.obj.Placement.Base)
|
||||
self.editpoints.append(self.obj.Shape.Vertexes[0].Point)
|
||||
|
@ -3589,7 +3591,7 @@ class Point:
|
|||
self.stack = []
|
||||
rot = self.view.getCameraNode().getField("orientation").getValue()
|
||||
upv = Vector(rot.multVec(coin.SbVec3f(0,1,0)).getValue())
|
||||
plane.setup(DraftVecUtils.neg(self.view.getViewDirection()), Vector(0,0,0), upv)
|
||||
plane.setup(self.view.getViewDirection().negative(), Vector(0,0,0), upv)
|
||||
self.point = None
|
||||
# adding 2 callback functions
|
||||
self.callbackClick = self.view.addEventCallbackPivy(coin.SoMouseButtonEvent.getClassTypeId(),self.click)
|
||||
|
|
|
@ -272,8 +272,8 @@ class dimTracker(Tracker):
|
|||
p2 = p1
|
||||
p3 = p4
|
||||
else:
|
||||
p2 = p1.add(DraftVecUtils.neg(proj))
|
||||
p3 = p4.add(DraftVecUtils.neg(proj))
|
||||
p2 = p1.add(proj.negative())
|
||||
p3 = p4.add(proj.negative())
|
||||
points = [DraftVecUtils.tup(p1),DraftVecUtils.tup(p2),DraftVecUtils.tup(p3),DraftVecUtils.tup(p4)]
|
||||
self.coords.point.setValues(0,4,points)
|
||||
|
||||
|
@ -743,7 +743,7 @@ class boxTracker(Tracker):
|
|||
self.cube.width.setValue(lvec.Length)
|
||||
p = WorkingPlane.getPlacementFromPoints([bp,bp.add(lvec),bp.add(right)])
|
||||
self.trans.rotation.setValue(p.Rotation.Q)
|
||||
bp = bp.add(DraftVecUtils.scale(lvec,0.5))
|
||||
bp = bp.add(lvec.multiply(0.5))
|
||||
bp = bp.add(DraftVecUtils.scaleTo(normal,self.cube.depth.getValue()/2))
|
||||
self.pos(bp)
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ class plane:
|
|||
gp = self.getGlobalCoords(Vector(lp.x,lp.y,0))
|
||||
a = direction.getAngle(gp.sub(p))
|
||||
if a > math.pi/2:
|
||||
direction = DraftVecUtils.neg(direction)
|
||||
direction = direction.negative()
|
||||
a = math.pi - a
|
||||
ld = self.getLocalRot(direction)
|
||||
gd = self.getGlobalRot(Vector(ld.x,ld.y,0))
|
||||
|
@ -198,7 +198,7 @@ class plane:
|
|||
rot = FreeCADGui.ActiveDocument.ActiveView.getCameraNode().getField("orientation").getValue()
|
||||
upvec = Vector(rot.multVec(coin.SbVec3f(0,1,0)).getValue())
|
||||
vdir = FreeCADGui.ActiveDocument.ActiveView.getViewDirection()
|
||||
self.alignToPointAndAxis(Vector(0,0,0), DraftVecUtils.neg(vdir), 0, upvec)
|
||||
self.alignToPointAndAxis(Vector(0,0,0), vdir.negative(), 0, upvec)
|
||||
except:
|
||||
print "Draft: Unable to align the working plane to the current view"
|
||||
self.weak = True
|
||||
|
@ -261,9 +261,9 @@ class plane:
|
|||
|
||||
def getGlobalCoords(self,point):
|
||||
"returns the global coordinates of the given point, taken relatively to this working plane"
|
||||
vx = DraftVecUtils.scale(self.u,point.x)
|
||||
vy = DraftVecUtils.scale(self.v,point.y)
|
||||
vz = DraftVecUtils.scale(self.axis,point.z)
|
||||
vx = self.u.multiply(point.x)
|
||||
vy = self.v.multiply(point.y)
|
||||
vz = self.axis.multiply(point.z)
|
||||
pt = (vx.add(vy)).add(vz)
|
||||
return pt.add(self.position)
|
||||
|
||||
|
@ -285,9 +285,9 @@ class plane:
|
|||
|
||||
def getGlobalRot(self,point):
|
||||
"Same as getGlobalCoords, but discards the WP position"
|
||||
vx = DraftVecUtils.scale(self.u,point.x)
|
||||
vy = DraftVecUtils.scale(self.v,point.y)
|
||||
vz = DraftVecUtils.scale(self.axis,point.z)
|
||||
vx = self.u.multiply(point.x)
|
||||
vy = self.v.multiply(point.y)
|
||||
vz = self.axis.multiply(point.z)
|
||||
pt = (vx.add(vy)).add(vz)
|
||||
return pt
|
||||
|
||||
|
@ -296,9 +296,9 @@ class plane:
|
|||
ax = point.getAngle(self.u)
|
||||
ay = point.getAngle(self.v)
|
||||
az = point.getAngle(self.axis)
|
||||
bx = point.getAngle(DraftVecUtils.neg(self.u))
|
||||
by = point.getAngle(DraftVecUtils.neg(self.v))
|
||||
bz = point.getAngle(DraftVecUtils.neg(self.axis))
|
||||
bx = point.getAngle(self.u.negative())
|
||||
by = point.getAngle(self.v.negative())
|
||||
bz = point.getAngle(self.axis.negative())
|
||||
b = min(ax,ay,az,bx,by,bz)
|
||||
if b in [ax,bx]:
|
||||
return "x"
|
||||
|
|
|
@ -145,10 +145,10 @@ def calcBulge(v1,bulge,v2):
|
|||
'''
|
||||
chord = v2.sub(v1)
|
||||
sagitta = (bulge * chord.Length)/2
|
||||
startpoint = v1.add(DraftVecUtils.scale(chord,0.5))
|
||||
startpoint = v1.add(chord.multiply(0.5))
|
||||
perp = chord.cross(Vector(0,0,1))
|
||||
if not DraftVecUtils.isNull(perp): perp.normalize()
|
||||
endpoint = DraftVecUtils.scale(perp,sagitta)
|
||||
endpoint = perp.multiply(sagitta)
|
||||
return startpoint.add(endpoint)
|
||||
|
||||
def getGroup(ob):
|
||||
|
@ -231,7 +231,7 @@ class fcformat:
|
|||
v1 = FreeCAD.Vector(r1,g1,b1)
|
||||
v2 = FreeCAD.Vector(r2,g2,b2)
|
||||
v = v2.sub(v1)
|
||||
v = DraftVecUtils.scale(v,0.5)
|
||||
v = v.multiply(0.5)
|
||||
cv = v1.add(v)
|
||||
else:
|
||||
c1 = bparams.GetUnsigned("BackgroundColor")
|
||||
|
@ -750,7 +750,7 @@ def addText(text,attrib=False):
|
|||
if rx or ry or rz:
|
||||
xv = Vector(rx,ry,rz)
|
||||
if not DraftVecUtils.isNull(xv):
|
||||
ax = DraftVecUtils.neg(xv.cross(Vector(1,0,0)))
|
||||
ax = (xv.cross(Vector(1,0,0))).negative()
|
||||
if DraftVecUtils.isNull(ax):
|
||||
ax = Vector(0,0,1)
|
||||
ang = -math.degrees(DraftVecUtils.angle(xv,Vector(1,0,0),ax))
|
||||
|
@ -1500,7 +1500,7 @@ def export(objectslist,filename,nospline=False):
|
|||
if not proj:
|
||||
pbase = DraftVecUtils.tup(ob.End)
|
||||
else:
|
||||
pbase = DraftVecUtils.tup(ob.End.add(DraftVecUtils.neg(proj)))
|
||||
pbase = DraftVecUtils.tup(ob.End.add(proj.negative()))
|
||||
dxf.append(dxfLibrary.Dimension(pbase,p1,p2,color=getACI(ob),
|
||||
layer=getGroup(ob)))
|
||||
|
||||
|
|
|
@ -347,7 +347,7 @@ def arcend2center(lastvec,currentvec,rx,ry,xrotation=0.0,correction=False):
|
|||
m2=FreeCAD.Matrix()
|
||||
m2.rotateZ(xrotation)
|
||||
centeroff = currentvec.add(lastvec)
|
||||
centeroff = DraftVecUtils.scale(centeroff,.5)
|
||||
centeroff = centeroff.multiply(.5)
|
||||
vcenter = m2.multiply(vcx1).add(centeroff) # Step3 F.6.5.3
|
||||
#angle1 = Vector(1,0,0).getAngle(Vector((v1.x-vcx1.x)/rx,(v1.y-vcx1.y)/ry,0)) # F.6.5.5
|
||||
#angledelta = Vector((v1.x-vcx1.x)/rx,(v1.y-vcx1.y)/ry,0).getAngle(Vector((-v1.x-vcx1.x)/rx,(-v1.y-vcx1.y)/ry,0)) # F.6.5.6
|
||||
|
@ -616,11 +616,11 @@ class svgHandler(xml.sax.ContentHandler):
|
|||
else:
|
||||
# anticlockwise
|
||||
perp = DraftVecUtils.rotate2D(chord,math.pi/2)
|
||||
chord = DraftVecUtils.scale(chord,.5)
|
||||
chord = chord.multiply(.5)
|
||||
if chord.Length > rx: a = 0
|
||||
else: a = math.sqrt(rx**2-chord.Length**2)
|
||||
s = rx - a
|
||||
perp = DraftVecUtils.scale(perp,s/perp.Length)
|
||||
perp = perp.multiply(s/perp.Length)
|
||||
midpoint = lastvec.add(chord.add(perp))
|
||||
seg = Part.Arc(lastvec,midpoint,currentvec).toShape()
|
||||
else:# big arc or elliptical arc
|
||||
|
|
Loading…
Reference in New Issue
Block a user