Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of https://github.com/FreeCAD/FreeCAD
  • Loading branch information
wwmayer committed Feb 14, 2017
2 parents f4d8945 + 8868943 commit 3076b59
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/Mod/Arch/ArchWindow.py
Expand Up @@ -652,6 +652,7 @@ def __init__(self,obj):
obj.addProperty("App::PropertyArea","Area","Arch",QT_TRANSLATE_NOOP("App::Property","The area of this window"))
obj.addProperty("App::PropertyLength","LouvreWidth","Louvres",QT_TRANSLATE_NOOP("App::Property","the width of louvre elements"))
obj.addProperty("App::PropertyLength","LouvreSpacing","Louvres",QT_TRANSLATE_NOOP("App::Property","the space between louvre elements"))
obj.addProperty("App::PropertyPercent","Opening","Arch",QT_TRANSLATE_NOOP("App::Property","Opens the subcomponents that have a hinge defined"))
obj.setEditorMode("Preset",2)
obj.setEditorMode("WindowParts",2)
self.Type = "Window"
Expand Down Expand Up @@ -708,6 +709,7 @@ def execute(self,obj):
if hasattr(obj,"WindowParts"):
if obj.WindowParts and (len(obj.WindowParts)%5 == 0):
shapes = []
rotdata = None
for i in range(len(obj.WindowParts)/5):
wires = []
hinge = None
Expand Down Expand Up @@ -739,6 +741,10 @@ def execute(self,obj):
if not DraftVecUtils.isNull(obj.Normal):
norm = obj.Normal
if hinge and omode:
opening = None
if hasattr(obj,"Opening"):
if obj.Opening:
opening = obj.Opening/100.0
e = obj.Base.Shape.Edges[hinge]
ev1 = e.Vertexes[0].Point
ev2 = e.Vertexes[-1].Point
Expand All @@ -759,62 +765,78 @@ def execute(self,obj):
v1 = ev1.add(proj)
chord = p.sub(v1)
else:
v1 = e.Vertexes[0].Point
v1 = ev1
v4 = p.add(DraftVecUtils.scale(enorm,0.5))
if omode == 1: # Arc 90,"Arc 90 inv","Arc 45","Arc 45 inv","Arc 180","Arc 180 inv","Triangle","Triangle inv","Sliding","Sliding inv"
if omode == 1: # Arc 90
v2 = v1.add(DraftVecUtils.rotate(chord,math.pi/4,enorm))
v3 = v1.add(DraftVecUtils.rotate(chord,math.pi/2,enorm))
ssymbols.append(Part.Arc(p,v2,v3).toShape())
ssymbols.append(Part.LineSegment(v3,v1).toShape())
vsymbols.append(Part.LineSegment(v1,v4).toShape())
vsymbols.append(Part.LineSegment(v4,ev2).toShape())
if opening:
rotdata = [v1,ev2.sub(ev1),90*opening]
elif omode == 2: # Arc -90
v2 = v1.add(DraftVecUtils.rotate(chord,-math.pi/4,enorm))
v3 = v1.add(DraftVecUtils.rotate(chord,-math.pi/2,enorm))
ssymbols.append(Part.Arc(p,v2,v3).toShape())
ssymbols.append(Part.LineSegment(v3,v1).toShape())
vsymbols.append(Part.LineSegment(v1,v4).toShape())
vsymbols.append(Part.LineSegment(v4,ev2).toShape())
if opening:
rotdata = [v1,ev2.sub(ev1),-90*opening]
elif omode == 3: # Arc 45
v2 = v1.add(DraftVecUtils.rotate(chord,math.pi/8,enorm))
v3 = v1.add(DraftVecUtils.rotate(chord,math.pi/4,enorm))
ssymbols.append(Part.Arc(p,v2,v3).toShape())
ssymbols.append(Part.LineSegment(v3,v1).toShape())
vsymbols.append(Part.LineSegment(v1,v4).toShape())
vsymbols.append(Part.LineSegment(v4,ev2).toShape())
if opening:
rotdata = [v1,ev2.sub(ev1),45*opening]
elif omode == 4: # Arc -45
v2 = v1.add(DraftVecUtils.rotate(chord,-math.pi/8,enorm))
v3 = v1.add(DraftVecUtils.rotate(chord,-math.pi/4,enorm))
ssymbols.append(Part.Arc(p,v2,v3).toShape())
ssymbols.append(Part.LineSegment(v3,v1).toShape())
vsymbols.append(Part.LineSegment(v1,v4).toShape())
vsymbols.append(Part.LineSegment(v4,ev2).toShape())
if opening:
rotdata = [v1,ev2.sub(ev1),-45*opening]
elif omode == 5: # Arc 180
v2 = v1.add(DraftVecUtils.rotate(chord,math.pi/2,enorm))
v3 = v1.add(DraftVecUtils.rotate(chord,math.pi,enorm))
ssymbols.append(Part.Arc(p,v2,v3).toShape())
ssymbols.append(Part.LineSegment(v3,v1).toShape())
vsymbols.append(Part.LineSegment(v1,v4).toShape())
vsymbols.append(Part.LineSegment(v4,ev2).toShape())
if opening:
rotdata = [v1,ev2.sub(ev1),180*opening]
elif omode == 6: # Arc -180
v2 = v1.add(DraftVecUtils.rotate(chord,-math.pi/2,enorm))
v3 = v1.add(DraftVecUtils.rotate(chord,-math.pi,enorm))
ssymbols.append(Part.Arc(p,v2,v3).toShape())
ssymbols.append(Part.LineSegment(v3,v1).toShape())
vsymbols.append(Part.LineSegment(v1,v4).toShape())
vsymbols.append(Part.LineSegment(v4,ev2).toShape())
if opening:
rotdata = [ev1,ev2.sub(ev1),-180*opening]
elif omode == 7: # tri
v2 = v1.add(DraftVecUtils.rotate(chord,math.pi/2,enorm))
ssymbols.append(Part.LineSegment(p,v2).toShape())
ssymbols.append(Part.LineSegment(v2,v1).toShape())
vsymbols.append(Part.LineSegment(v1,v4).toShape())
vsymbols.append(Part.LineSegment(v4,ev2).toShape())
if opening:
rotdata = [v1,ev2.sub(ev1),90*opening]
elif omode == 8: # -tri
v2 = v1.add(DraftVecUtils.rotate(chord,-math.pi/2,enorm))
ssymbols.append(Part.LineSegment(p,v2).toShape())
ssymbols.append(Part.LineSegment(v2,v1).toShape())
vsymbols.append(Part.LineSegment(v1,v4).toShape())
vsymbols.append(Part.LineSegment(v4,ev2).toShape())
if opening:
rotdata = [v1,ev2.sub(ev1),-90*opening]
elif omode == 9: # sliding
pass
elif omode == 10: # -sliding
Expand All @@ -837,6 +859,8 @@ def execute(self,obj):
symb.translate(zov)
for symb in vsymbols:
symb.translate(zov)
if rotdata and hinge and omode:
rotdata[0] = rotdata[0].add(zov)
if obj.WindowParts[(i*5)+1] == "Louvre":
if hasattr(obj,"LouvreWidth"):
if obj.LouvreWidth and obj.LouvreSpacing:
Expand All @@ -855,6 +879,8 @@ def execute(self,obj):
self.boxes.rotate(self.boxes.BoundBox.Center,rot.Axis,math.degrees(rot.Angle))
self.boxes.translate(shape.BoundBox.Center.sub(self.boxes.BoundBox.Center))
shape = shape.common(self.boxes)
if rotdata:
shape.rotate(rotdata[0],rotdata[1],rotdata[2])
shapes.append(shape)
self.sshapes.extend(ssymbols)
self.vshapes.extend(vsymbols)
Expand Down
4 changes: 4 additions & 0 deletions src/Mod/Draft/DraftGeomUtils.py
Expand Up @@ -408,6 +408,10 @@ def getLineIntersections(pt1,pt2,pt3,pt4,infinite1,infinite2):
rad1 , rad2 = edge1.Curve.Radius, edge2.Curve.Radius
axis1, axis2 = edge1.Curve.Axis , edge2.Curve.Axis
c2c = cent2.sub(cent1)

if cent1.sub(cent2).Length == 0:
# circles are concentric
return []

if DraftVecUtils.isNull(axis1.cross(axis2)) :
if round(c2c.dot(axis1),precision()) == 0 :
Expand Down

0 comments on commit 3076b59

Please sign in to comment.