From 88689439bd2df86524b1364b168165ea035c474b Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 14 Feb 2017 10:07:59 -0200 Subject: [PATCH] Arch: Testing opening property for windows --- src/Mod/Arch/ArchWindow.py | 30 ++++++++++++++++++++++++++++-- src/Mod/Draft/DraftGeomUtils.py | 4 ++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/Mod/Arch/ArchWindow.py b/src/Mod/Arch/ArchWindow.py index 729637216..b9bcc570a 100644 --- a/src/Mod/Arch/ArchWindow.py +++ b/src/Mod/Arch/ArchWindow.py @@ -652,6 +652,7 @@ class _Window(ArchComponent.Component): 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" @@ -708,6 +709,7 @@ class _Window(ArchComponent.Component): 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 @@ -739,6 +741,10 @@ class _Window(ArchComponent.Component): 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 @@ -759,15 +765,17 @@ class _Window(ArchComponent.Component): 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)) @@ -775,6 +783,8 @@ class _Window(ArchComponent.Component): 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)) @@ -782,6 +792,8 @@ class _Window(ArchComponent.Component): 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)) @@ -789,6 +801,8 @@ class _Window(ArchComponent.Component): 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)) @@ -796,6 +810,8 @@ class _Window(ArchComponent.Component): 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)) @@ -803,18 +819,24 @@ class _Window(ArchComponent.Component): 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 @@ -837,6 +859,8 @@ class _Window(ArchComponent.Component): 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: @@ -855,6 +879,8 @@ class _Window(ArchComponent.Component): 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) diff --git a/src/Mod/Draft/DraftGeomUtils.py b/src/Mod/Draft/DraftGeomUtils.py index dca8f977d..aa0aa324f 100755 --- a/src/Mod/Draft/DraftGeomUtils.py +++ b/src/Mod/Draft/DraftGeomUtils.py @@ -408,6 +408,10 @@ def findIntersection(edge1,edge2,infinite1=False,infinite2=False,ex1=False,ex2=F 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 :