From 1968b8c4378dc307588a65a0989615ece658e642 Mon Sep 17 00:00:00 2001 From: mapeze Date: Mon, 17 May 2021 22:36:11 +0200 Subject: [PATCH 1/8] Fix TechDraw View Spreadsheet with merged cells. https://forum.freecadweb.org/viewtopic.php?f=35&t=58563 --- src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp b/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp index eb1007a836..ce315d2f1d 100644 --- a/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp +++ b/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp @@ -356,6 +356,7 @@ std::string DrawViewSpreadsheet::getSheetImage(void) << " fill=\"" << fcolor << "\">" << celltext << "" << endl; } } + cellheight = sheet->getRowHeight(address.row()); rowoffset = rowoffset + cellheight; } result << " " << endl; From 78d3d0039ff26794b418769b61575a9ff5f9f8bb Mon Sep 17 00:00:00 2001 From: luz paz Date: Mon, 17 May 2021 10:42:22 -0400 Subject: [PATCH 2/8] Crowdin: fix Draft mirror code typo ref: https://crowdin.com/translate/freecad/548/en-en?filter=basic&value=2#6587132 --- src/Mod/Draft/draftfunctions/mirror.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Draft/draftfunctions/mirror.py b/src/Mod/Draft/draftfunctions/mirror.py index 189e424424..dc3ea48cc2 100644 --- a/src/Mod/Draft/draftfunctions/mirror.py +++ b/src/Mod/Draft/draftfunctions/mirror.py @@ -110,7 +110,7 @@ def mirror(objlist, p1, p2): for obj in objlist: mir = App.ActiveDocument.addObject("Part::Mirroring", "mirror") - mir.Label = obj.Label + " (" + translate("draft","mirrored" + ")") + mir.Label = obj.Label + " (" + translate("draft","mirrored") + ") " mir.Source = obj mir.Base = p1 mir.Normal = pnorm From cd490c71432e599bc10d79d11ef8b0b8d8595252 Mon Sep 17 00:00:00 2001 From: luz paz Date: Fri, 21 May 2021 08:41:01 -0400 Subject: [PATCH 3/8] StartWB: Add missing tooltip for 'Show tips' preference dialog --- src/Mod/Start/Gui/DlgStartPreferences.ui | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Mod/Start/Gui/DlgStartPreferences.ui b/src/Mod/Start/Gui/DlgStartPreferences.ui index e8985acfe0..f0bb823747 100644 --- a/src/Mod/Start/Gui/DlgStartPreferences.ui +++ b/src/Mod/Start/Gui/DlgStartPreferences.ui @@ -159,6 +159,9 @@ By using ";;" to separate paths, you can add several folders here Qt::RightToLeft + + Displays help tips in the Start workbench Documents tab + From c2c4d647048e18f8f0865c4cec0eab79a6217248 Mon Sep 17 00:00:00 2001 From: mapeze Date: Fri, 21 May 2021 16:51:52 +0200 Subject: [PATCH 4/8] Fix TechDraw View Spreadsheet with merged cells, 2 --- src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp b/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp index eb1007a836..af55c417d9 100644 --- a/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp +++ b/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp @@ -356,7 +356,7 @@ std::string DrawViewSpreadsheet::getSheetImage(void) << " fill=\"" << fcolor << "\">" << celltext << "" << endl; } } - rowoffset = rowoffset + cellheight; + rowoffset = rowoffset + sheet->getRowHeight(address.row()); } result << " " << endl; rowoffset = 0.0; From 630b0f2af4bb8b2559f02ff6cea6dbc455f04d90 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Sat, 22 May 2021 16:29:50 +0200 Subject: [PATCH 5/8] Draft: Do not move children of App::Link objects This caused the original object to be moved when using the Draft move tool to move a link object, when the original object has MoveWithHost set (e.g. a Window). There was already a similar exception for clones, so it makes sense to extend this for links too. Note that there seem to be more problems with the "MoveWithHost" mechanism and fixing them might completely refactor this code, but until then, this is a simple and targeted fix that at least makes moving links to windows work as expected. See https://forum.freecadweb.org/viewtopic.php?f=23&t=57223 for discussion of this bug, its fix and the additional problems mentioned. --- src/Mod/Draft/draftutils/groups.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Draft/draftutils/groups.py b/src/Mod/Draft/draftutils/groups.py index c1557fb552..25118adc94 100644 --- a/src/Mod/Draft/draftutils/groups.py +++ b/src/Mod/Draft/draftutils/groups.py @@ -297,7 +297,7 @@ def get_movable_children(objectslist, recursive=True): for obj in objectslist: # Skips some objects that should never move their children if utils.get_type(obj) not in ("Clone", "SectionPlane", - "Facebinder", "BuildingPart"): + "Facebinder", "BuildingPart", "App::Link"): children = obj.OutList if (hasattr(obj, "Proxy") and obj.Proxy and hasattr(obj.Proxy, "getSiblings") From 2bbcb4994a93973e41d604d817041f93755ba140 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Sat, 22 May 2021 17:28:39 +0200 Subject: [PATCH 6/8] Arch: Simplify some ifs in ArchComponent This commit does not change behavior. --- src/Mod/Arch/ArchComponent.py | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/Mod/Arch/ArchComponent.py b/src/Mod/Arch/ArchComponent.py index a94396d6ae..a89be869a9 100644 --- a/src/Mod/Arch/ArchComponent.py +++ b/src/Mod/Arch/ArchComponent.py @@ -737,20 +737,18 @@ class Component(ArchIFC.IfcProduct): base = base.fuse(add) elif hasattr(o,'Shape'): - if o.Shape: - if not o.Shape.isNull(): - if o.Shape.Solids: - s = o.Shape.copy() - if placement: - s.Placement = s.Placement.multiply(placement) - if base: - if base.Solids: - try: - base = base.fuse(s) - except Part.OCCError: - print("Arch: unable to fuse object ", obj.Name, " with ", o.Name) - else: - base = s + if o.Shape and not o.Shape.isNull() and o.Shape.Solids: + s = o.Shape.copy() + if placement: + s.Placement = s.Placement.multiply(placement) + if base: + if base.Solids: + try: + base = base.fuse(s) + except Part.OCCError: + print("Arch: unable to fuse object ", obj.Name, " with ", o.Name) + else: + base = s # treat subtractions subs = obj.Subtractions @@ -1420,11 +1418,7 @@ class ViewProviderComponent: if hasattr(self,"Object"): c = [] if hasattr(self.Object,"Base"): - if Draft.getType(self.Object) != "Wall": - c = [self.Object.Base] - elif Draft.getType(self.Object.Base) == "Space": - c = [] - else: + if not (Draft.getType(self.Object) == "Wall" and Draft.getType(self.Object.Base) == "Space"): c = [self.Object.Base] if hasattr(self.Object,"Additions"): c.extend(self.Object.Additions) From 1cabfd8e6b6d08340927241e3743768e8e4cb85e Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Sat, 22 May 2021 17:30:23 +0200 Subject: [PATCH 7/8] Draft: Simplify code using getattr default value This uses the default value that can be passed to getattr to simplify code that uses it. By choosing an appropriate default value, a separate call to hasattr can be avoided and in some cases duplicate code can be avoided. This applies this trick where possible in wire.py and circle.py. This commit does not change behavior. --- src/Mod/Draft/draftobjects/circle.py | 5 +-- src/Mod/Draft/draftobjects/wire.py | 60 ++++++++++++---------------- 2 files changed, 26 insertions(+), 39 deletions(-) diff --git a/src/Mod/Draft/draftobjects/circle.py b/src/Mod/Draft/draftobjects/circle.py index a3a520aa5b..3a7af22c91 100644 --- a/src/Mod/Draft/draftobjects/circle.py +++ b/src/Mod/Draft/draftobjects/circle.py @@ -79,10 +79,7 @@ class Circle(DraftObject): if obj.FirstAngle.Value == obj.LastAngle.Value: shape = Part.Wire(shape) - if hasattr(obj,"MakeFace"): - if obj.MakeFace: - shape = Part.Face(shape) - else: + if getattr(obj,"MakeFace",True): shape = Part.Face(shape) obj.Shape = shape diff --git a/src/Mod/Draft/draftobjects/wire.py b/src/Mod/Draft/draftobjects/wire.py index d4a0731283..71becfb5a9 100644 --- a/src/Mod/Draft/draftobjects/wire.py +++ b/src/Mod/Draft/draftobjects/wire.py @@ -102,10 +102,7 @@ class Wire(DraftObject): if obj.Base.isDerivedFrom("Sketcher::SketchObject"): shape = obj.Base.Shape.copy() if obj.Base.Shape.isClosed(): - if hasattr(obj,"MakeFace"): - if obj.MakeFace: - shape = Part.Face(shape) - else: + if getattr(obj,"MakeFace",True): shape = Part.Face(shape) obj.Shape = shape elif obj.Base and obj.Tool: @@ -126,21 +123,20 @@ class Wire(DraftObject): obj.Points.pop() if obj.Closed and (len(obj.Points) > 2): pts = obj.Points - if hasattr(obj,"Subdivisions"): - if obj.Subdivisions > 0: - npts = [] - for i in range(len(pts)): - p1 = pts[i] - npts.append(pts[i]) - if i == len(pts)-1: - p2 = pts[0] - else: - p2 = pts[i+1] - v = p2.sub(p1) - v = DraftVecUtils.scaleTo(v,v.Length/(obj.Subdivisions+1)) - for j in range(obj.Subdivisions): - npts.append(p1.add(App.Vector(v).multiply(j+1))) - pts = npts + if getattr(obj,"Subdivisions",0) > 0: + npts = [] + for i in range(len(pts)): + p1 = pts[i] + npts.append(pts[i]) + if i == len(pts)-1: + p2 = pts[0] + else: + p2 = pts[i+1] + v = p2.sub(p1) + v = DraftVecUtils.scaleTo(v,v.Length/(obj.Subdivisions+1)) + for j in range(obj.Subdivisions): + npts.append(p1.add(App.Vector(v).multiply(j+1))) + pts = npts shape = Part.makePolygon(pts+[pts[0]]) if "ChamferSize" in obj.PropertiesList: if obj.ChamferSize.Value != 0: @@ -153,10 +149,7 @@ class Wire(DraftObject): if w: shape = w try: - if hasattr(obj,"MakeFace"): - if obj.MakeFace: - shape = Part.Face(shape) - else: + if getattr(obj,"MakeFace",True): shape = Part.Face(shape) except Part.OCCError: pass @@ -166,18 +159,15 @@ class Wire(DraftObject): lp = obj.Points[0] for p in pts: if not DraftVecUtils.equals(lp,p): - if hasattr(obj,"Subdivisions"): - if obj.Subdivisions > 0: - npts = [] - v = p.sub(lp) - v = DraftVecUtils.scaleTo(v,v.Length/(obj.Subdivisions+1)) - edges.append(Part.LineSegment(lp,lp.add(v)).toShape()) - lv = lp.add(v) - for j in range(obj.Subdivisions): - edges.append(Part.LineSegment(lv,lv.add(v)).toShape()) - lv = lv.add(v) - else: - edges.append(Part.LineSegment(lp,p).toShape()) + if getattr(obj,"Subdivisions",0) > 0: + npts = [] + v = p.sub(lp) + v = DraftVecUtils.scaleTo(v,v.Length/(obj.Subdivisions+1)) + edges.append(Part.LineSegment(lp,lp.add(v)).toShape()) + lv = lp.add(v) + for j in range(obj.Subdivisions): + edges.append(Part.LineSegment(lv,lv.add(v)).toShape()) + lv = lv.add(v) else: edges.append(Part.LineSegment(lp,p).toShape()) lp = p From d928f3776115028acdfca26ea8ef41f7d7f5de3c Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Sat, 22 May 2021 18:24:56 +0200 Subject: [PATCH 8/8] Draft: Fix "Show groups in layer list drop-down button" preference The code that was intended to handle this preference looked inside Mod/BIM instad of Mod/Draft for the preference. This seems to have been broken since the preference was first introduced in commit 9976a5ece0 (Draft: Turned autogroup button into layers selector (added pref option to restore old groups-based system)). This also removes a stray "-" that was probably a leftover from a merge conflict, introduced in commit 0547d23660 (Draft: move Draft_AutoGroup to gui_groups module). Since -True is still true and -False is still false, this did not actually break the code, though. See https://forum.freecadweb.org/viewtopic.php?t=42018 for related discussion. --- src/Mod/Draft/draftguitools/gui_groups.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_groups.py b/src/Mod/Draft/draftguitools/gui_groups.py index 705b920f96..a5d2b22988 100644 --- a/src/Mod/Draft/draftguitools/gui_groups.py +++ b/src/Mod/Draft/draftguitools/gui_groups.py @@ -258,7 +258,7 @@ class SetAutoGroup(gui_base.GuiCommandSimplest): s = Gui.Selection.getSelection() if len(s) == 1: if (utils.get_type(s[0]) == "Layer") or \ -- (App.ParamGet("User parameter:BaseApp/Preferences/Mod/BIM").GetBool("AutogroupAddGroups", False) + (App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetBool("AutogroupAddGroups", False) and (s[0].isDerivedFrom("App::DocumentObjectGroup") or utils.get_type(s[0]) in ["Site", "Building", "Floor", "BuildingPart"])): @@ -269,7 +269,7 @@ class SetAutoGroup(gui_base.GuiCommandSimplest): # including the options "None" and "Add new layer". self.groups = ["None"] gn = [o.Name for o in self.doc.Objects if utils.get_type(o) == "Layer"] - if App.ParamGet("User parameter:BaseApp/Preferences/Mod/BIM").GetBool("AutogroupAddGroups", False): + if App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetBool("AutogroupAddGroups", False): gn.extend(groups.get_group_names()) if gn: self.groups.extend(gn)