From c02ccca6404a2ec4d65757c9b4fd82fb5d5117a0 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Thu, 24 Mar 2022 09:46:15 -0500 Subject: [PATCH 01/39] Changes from lcorley --- .../Path/PathScripts/PathDressupLeadInOut.py | 229 ++++++++++-------- 1 file changed, 122 insertions(+), 107 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py index 4b460da593..13bd8fe3b2 100644 --- a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py +++ b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py @@ -162,6 +162,7 @@ class ObjectDressup: return None def __setstate__(self, state): + # pylint: disable=unused-argument return None def setup(self, obj): @@ -247,7 +248,8 @@ class ObjectDressup: return FreeCAD.Vector(xnew, ynew, Vector.z) def getLeadStart(self, obj, queue, action): - """returns Lead In G-code.""" + '''returns Lead In G-code.''' + # Modified March 2022 by lcorley to support leadin extension results = [] op = PathDressup.baseOp(obj.Base) tc = PathDressup.toolController(obj.Base) @@ -257,7 +259,7 @@ class ObjectDressup: arcs_identical = False # Set the correct twist command - if self.getDirectionOfPath(obj) == "left": + if self.getDirectionOfPath(obj) == 'left': arcdir = "G3" else: arcdir = "G2" @@ -267,18 +269,18 @@ class ObjectDressup: p0 = queue[0].Placement.Base p1 = queue[1].Placement.Base v = self.normalize(p1.sub(p0)) - # PathLog.debug(" CURRENT_IN : P0 Z:{} p1 Z:{}".format(p0.z,p1.z)) + PathLog.debug(" CURRENT_IN Line : P0 Z:{} p1 Z:{}".format(p0.z,p1.z)) else: p0 = queue[0].Placement.Base p1 = queue[1].Placement.Base v = self.normalize(p1.sub(p0)) - # PathLog.debug(" CURRENT_IN ARC : P0 X:{} Y:{} P1 X:{} Y:{} ".format(p0.x,p0.y,p1.x,p1.y)) + PathLog.debug(" CURRENT_IN ARC : P0 X:{} Y:{} P1 X:{} Y:{} ".format(p0.x,p0.y,p1.x,p1.y)) # Calculate offset vector (will be overwritten for arcs) - if self.getDirectionOfPath(obj) == "right": - off_v = FreeCAD.Vector(v.y * R, -v.x * R, 0.0) + if self.getDirectionOfPath(obj) == 'right': + off_v = FreeCAD.Vector(v.y*R, -v.x*R, 0.0) else: - off_v = FreeCAD.Vector(-v.y * R, v.x * R, 0.0) + off_v = FreeCAD.Vector(-v.y*R, v.x*R, 0.0) # Check if we enter at line or arc command if queue[1].Name in movecommands and queue[1].Name not in arccommands: @@ -286,14 +288,14 @@ class ObjectDressup: vec = p1.sub(p0) vec_n = self.normalize(vec) vec_inv = self.invert(vec_n) - vec_off = self.multiply(vec_inv, obj.ExtendLeadIn) - # PathLog.debug("LineCMD: {}, Vxinv: {}, Vyinv: {}, Vxoff: {}, Vyoff: {}".format(queue[0].Name, vec_inv.x, vec_inv.y, vec_off.x, vec_off.y)) + vec_off = self.multiply(vec_inv, obj.ExtendLeadIn) + PathLog.debug("LineCMD: {}, Vxinv: {}, Vyinv: {}, Vxoff: {}, Vyoff: {}".format(queue[0].Name, vec_inv.x, vec_inv.y, vec_off.x, vec_off.y)) else: # We have an arc move # Calculate coordinates for middle of circle pij = copy.deepcopy(p0) - pij.x += queue[1].Parameters["I"] - pij.y += queue[1].Parameters["J"] + pij.x += queue[1].Parameters['I'] + pij.y += queue[1].Parameters['J'] # Check if lead in and operation go in same direction (usually for inner circles) if arcdir == queue[1].Name: @@ -304,9 +306,9 @@ class ObjectDressup: # Rotate vector to get direction for lead in if arcdir == "G2": - vec_rot = self.rotate(vec_circ, 90) + vec_rot = self.rotate(vec_circ, 90) else: - vec_rot = self.rotate(vec_circ, -90) + vec_rot = self.rotate(vec_circ, -90) # Normalize and invert vector vec_n = self.normalize(vec_rot) @@ -315,104 +317,108 @@ class ObjectDressup: # Calculate offset of lead in if arcdir == "G3": - off_v = FreeCAD.Vector(-v.y * R, v.x * R, 0.0) + off_v = FreeCAD.Vector(-v.y*R, v.x*R, 0.0) else: - off_v = FreeCAD.Vector(v.y * R, -v.x * R, 0.0) + off_v = FreeCAD.Vector(v.y*R, -v.x*R, 0.0) # Multiply offset by LeadIn length - vec_off = self.multiply(vec_n, obj.ExtendLeadIn) + #vec_off = self.multiply(vec_n, obj.ExtendLeadIn) - offsetvector = FreeCAD.Vector(v.x * R - vec_off.x, v.y * R - vec_off.y, 0) # IJ + #offsetvector = FreeCAD.Vector(v.x*R-vec_off.x, v.y*R-vec_off.y, 0) # IJ + offsetvector = FreeCAD.Vector(v.x*R, v.y*R, 0) # IJ - if obj.RadiusCenter == "Radius": + if obj.RadiusCenter == 'Radius': leadstart = (p0.add(off_v)).sub(offsetvector) # Rmode if arcs_identical: t = p0.sub(leadstart) t = p0.add(t) leadstart = t - offsetvector = self.multiply(offsetvector, -1) + offsetvector = self.multiply(offsetvector, -1) else: leadstart = p0.add(off_v) # Dmode + # At this point leadstart is the beginning of the leadin arc + # and offsetvector points from leadstart to the center of the leadin arc + # so the offsetvector is a radius of the leadin arc at its start + # The extend line should be tangent to the leadin arc at this point, or perpendicular to the radius + if arcdir == "G2": + tangentvec = self.rotate(offsetvector, -90) + else: + tangentvec = self.rotate(offsetvector, 90) + #print ("tangentvec = ", tangentvec) + # Normalize the tangent vector + tangentvecNorm = self.normalize(tangentvec) + #print ("tangentvecNorm = ", tangentvecNorm) + # Multiply tangentvecNorm by LeadIn length + leadlinevec = self.multiply(tangentvecNorm, obj.ExtendLeadIn) + #print ("leadlinevec = ", leadlinevec) + # leadlinevec provides the offset from the beginning of the lead arc to the beginning of the extend line + extendstart = leadstart.add(leadlinevec) + #print ("extendstart = ", extendstart) - if action == "start": - # extendcommand = Path.Command('G0', {"X": 0.0, "Y": 0.0, "Z": op.ClearanceHeight.Value}) - # results.append(extendcommand) - extendcommand = Path.Command( - "G0", - {"X": leadstart.x, "Y": leadstart.y, "Z": op.ClearanceHeight.Value}, - ) + if action == 'start': + if obj.ExtendLeadIn != 0: + # Rapid move to beginning of extend line + extendcommand = Path.Command('G0', {"X": extendstart.x, "Y": extendstart.y, "Z": op.ClearanceHeight.Value}) + else: + # Rapid move to beginning of leadin arc + extendcommand = Path.Command('G0', {"X": leadstart.x, "Y": leadstart.y, "Z": op.ClearanceHeight.Value}) results.append(extendcommand) - extendcommand = Path.Command("G0", {"Z": op.SafeHeight.Value}) + extendcommand = Path.Command('G0', {"Z": op.SafeHeight.Value}) results.append(extendcommand) - if action == "layer": + if action == 'layer': if not obj.KeepToolDown: - extendcommand = Path.Command("G0", {"Z": op.SafeHeight.Value}) + extendcommand = Path.Command('G0', {"Z": op.SafeHeight.Value}) results.append(extendcommand) - extendcommand = Path.Command("G0", {"X": leadstart.x, "Y": leadstart.y}) + extendcommand = Path.Command('G0', {"X": leadstart.x, "Y": leadstart.y}) results.append(extendcommand) if not obj.RapidPlunge: - extendcommand = Path.Command( - "G1", {"X": leadstart.x, "Y": leadstart.y, "Z": p1.z, "F": vertFeed} - ) + extendcommand = Path.Command('G1', {"X": leadstart.x, "Y": leadstart.y, "Z": p1.z, "F": vertFeed}) else: - extendcommand = Path.Command( - "G0", - { - "X": leadstart.x, - "Y": leadstart.y, - "Z": p1.z, - }, - ) + extendcommand = Path.Command('G0', {"X": leadstart.x, "Y": leadstart.y, "Z": p1.z,}) results.append(extendcommand) if obj.UseMachineCRC: - if self.getDirectionOfPath(obj) == "right": - results.append(Path.Command("G42", {"D": toolnummer})) + if self.getDirectionOfPath(obj) == 'right': + results.append(Path.Command('G42', {'D': toolnummer})) else: - results.append(Path.Command("G41", {"D": toolnummer})) + results.append(Path.Command('G41', {'D': toolnummer})) - if obj.StyleOn == "Arc": - arcmove = Path.Command( - arcdir, - { - "X": p0.x + vec_off.x, - "Y": p0.y + vec_off.y, - "Z": p1.z, - "I": offsetvector.x + vec_off.x, - "J": offsetvector.y + vec_off.y, - "K": p1.z, - "F": horizFeed, - }, - ) # add G2/G3 move - results.append(arcmove) + if obj.StyleOn == 'Arc': if obj.ExtendLeadIn != 0: - extendcommand = Path.Command( - "G1", {"X": p0.x, "Y": p0.y, "F": horizFeed} - ) + # Insert move to beginning of leadin arc + extendcommand = Path.Command('G1', {"X": leadstart.x, "Y": leadstart.y, "F": horizFeed}) results.append(extendcommand) - elif obj.StyleOn == "Tangent": - extendcommand = Path.Command("G1", {"X": p0.x, "Y": p0.y, "F": horizFeed}) + arcmove = Path.Command(arcdir, {"X": p0.x, "Y": p0.y, "I": offsetvector.x, "J": offsetvector.y, "F": horizFeed}) # add G2/G3 move + results.append(arcmove) + elif obj.StyleOn == 'Tangent': + extendcommand = Path.Command('G1', {"X": p0.x, "Y": p0.y, "F": horizFeed}) results.append(extendcommand) else: PathLog.debug(" CURRENT_IN Perp") currLocation.update(results[-1].Parameters) - currLocation["Z"] = p1.z + currLocation['Z'] = p1.z return results def getLeadEnd(self, obj, queue, action): - """returns the Gcode of LeadOut.""" + '''returns the Gcode of LeadOut.''' + # Modified March 2022 by lcorley to support leadout extension + # pylint: disable=unused-argument results = [] + #print ("action =", action) + #print ("queue[0] =" ,queue[0]) + #print ("queue[1] =" ,queue[1]) + #print ("queue[2] =" ,queue[2]) horizFeed = PathDressup.toolController(obj.Base).HorizFeed.Value R = obj.Length.Value # Radius of roll or length arcs_identical = False # Set the correct twist command - if self.getDirectionOfPath(obj) == "right": + if self.getDirectionOfPath(obj) == 'right': arcdir = "G2" else: arcdir = "G3" @@ -426,10 +432,10 @@ class ObjectDressup: p1 = queue[1].Placement.Base v = self.normalize(p1.sub(p0)) - if self.getDirectionOfPath(obj) == "right": - off_v = FreeCAD.Vector(v.y * R, -v.x * R, 0.0) + if self.getDirectionOfPath(obj) == 'right': + off_v = FreeCAD.Vector(v.y*R, -v.x*R, 0.0) else: - off_v = FreeCAD.Vector(-v.y * R, v.x * R, 0.0) + off_v = FreeCAD.Vector(-v.y*R, v.x*R, 0.0) # Check if we leave at line or arc command if queue[1].Name in movecommands and queue[1].Name not in arccommands: @@ -437,82 +443,86 @@ class ObjectDressup: vec = p1.sub(p0) vec_n = self.normalize(vec) vec_inv = self.invert(vec_n) - vec_off = self.multiply(vec_inv, obj.ExtendLeadOut) - # PathLog.debug("LineCMD: {}, Vxinv: {}, Vyinv: {}, Vxoff: {}, Vyoff: {}".format(queue[0].Name, vec_inv.x, vec_inv.y, vec_off.x, vec_off.y)) + vec_off = self.multiply(vec_inv, obj.ExtendLeadOut) + #PathLog.debug("LineCMD: {}, Vxinv: {}, Vyinv: {}, Vxoff: {}, Vyoff: {}".format(queue[0].Name, vec_inv.x, vec_inv.y, vec_off.x, vec_off.y)) else: # We have an arc move pij = copy.deepcopy(p0) - pij.x += queue[1].Parameters["I"] - pij.y += queue[1].Parameters["J"] + pij.x += queue[1].Parameters['I'] + pij.y += queue[1].Parameters['J'] ve = pij.sub(p1) if arcdir == queue[1].Name: arcs_identical = True if arcdir == "G2": - vec_rot = self.rotate(ve, -90) + vec_rot = self.rotate(ve, -90) else: - vec_rot = self.rotate(ve, 90) + vec_rot = self.rotate(ve, 90) vec_n = self.normalize(vec_rot) v = vec_n if arcdir == "G3": - off_v = FreeCAD.Vector(-v.y * R, v.x * R, 0.0) + off_v = FreeCAD.Vector(-v.y*R, v.x*R, 0.0) else: - off_v = FreeCAD.Vector(v.y * R, -v.x * R, 0.0) + off_v = FreeCAD.Vector(v.y*R, -v.x*R, 0.0) vec_inv = self.invert(vec_rot) - vec_off = self.multiply(vec_inv, obj.ExtendLeadOut) + #vec_off = self.multiply(vec_inv, obj.ExtendLeadOut) - offsetvector = FreeCAD.Vector(v.x * R - vec_off.x, v.y * R - vec_off.y, 0.0) - if obj.RadiusCenter == "Radius": + #offsetvector = FreeCAD.Vector(v.x*R-vec_off.x, v.y*R-vec_off.y, 0.0) + offsetvector = FreeCAD.Vector(v.x*R, v.y*R, 0.0) + if obj.RadiusCenter == 'Radius': leadend = (p1.add(off_v)).add(offsetvector) # Rmode if arcs_identical: t = p1.sub(leadend) t = p1.add(t) leadend = t - off_v = self.multiply(off_v, -1) + off_v = self.multiply(off_v, -1) else: leadend = p1.add(off_v) # Dmode IJ = off_v # .negative() - # results.append(queue[1]) - if obj.StyleOff == "Arc": - if obj.ExtendLeadOut != 0: - extendcommand = Path.Command( - "G1", {"X": p1.x - vec_off.x, "Y": p1.y - vec_off.y, "F": horizFeed} - ) - results.append(extendcommand) - arcmove = Path.Command( - arcdir, - { - "X": leadend.x, - "Y": leadend.y, - "Z": p1.z, - "I": IJ.x, - "J": IJ.y, - "K": p1.z, - "F": horizFeed, - }, - ) # add G2/G3 move + #print ("leadend = ", leadend) + #print ("IJ = ", IJ) + # At this point leadend is the location of the end of the leadout arc + # IJ is an offset from the begining of the leadout arc to its center. + # It is parallel to a tangent line at the end of the leadout arc + # Create the normalized tangent vector + tangentvecNorm = self.normalize(IJ) + #print ("tangentvecNorm = ", tangentvecNorm) + # Multiply tangentvecNorm by LeadOut length + leadlinevec = self.multiply(tangentvecNorm, obj.ExtendLeadOut) + #print ("leadlinevec = ", leadlinevec) + # leadlinevec provides the offset from the end of the leadout arc to the end of the extend line + extendleadoutend = leadend.add(leadlinevec) + #print ("extendleadoutend = ", extendleadoutend) + + #results.append(queue[1]) + if obj.StyleOff == 'Arc': + arcmove = Path.Command(arcdir, {"X": leadend.x, "Y": leadend.y, "I": IJ.x, "J": IJ.y, "F": horizFeed}) # add G2/G3 move results.append(arcmove) - elif obj.StyleOff == "Tangent": - extendcommand = Path.Command( - "G1", {"X": leadend.x, "Y": leadend.y, "F": horizFeed} - ) + if obj.ExtendLeadOut != 0: + extendcommand = Path.Command('G1', {"X": extendleadoutend.x, "Y": extendleadoutend.y, "F": horizFeed}) + results.append(extendcommand) + elif obj.StyleOff == 'Tangent': + extendcommand = Path.Command('G1', {"X": leadend.x, "Y": leadend.y, "F": horizFeed}) results.append(extendcommand) else: PathLog.debug(" CURRENT_IN Perp") if obj.UseMachineCRC: # crc off - results.append(Path.Command("G40", {})) + results.append(Path.Command('G40', {})) + + #print ("results =",results) return results + def generateLeadInOutCurve(self, obj): - global currLocation + global currLocation # pylint: disable=global-statement firstmove = Path.Command("G0", {"X": 0, "Y": 0, "Z": 0}) op = PathDressup.baseOp(obj.Base) currLocation.update(firstmove.Parameters) @@ -642,6 +652,7 @@ class ViewProviderDressup: return [self.obj.Base] def setEdit(self, vobj, mode=0): + # pylint: disable=unused-argument FreeCADGui.Control.closeDialog() panel = TaskDressupLeadInOut(vobj.Object, self) FreeCADGui.Control.showDialog(panel) @@ -653,6 +664,7 @@ class ViewProviderDressup: def onDelete(self, arg1=None, arg2=None): """this makes sure that the base operation is added back to the project and visible""" + # pylint: disable=unused-argument PathLog.debug("Deleting Dressup") if arg1.Object and arg1.Object.Base: FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True @@ -666,6 +678,7 @@ class ViewProviderDressup: return None def __setstate__(self, state): + # pylint: disable=unused-argument return None def clearTaskPanel(self): @@ -673,6 +686,8 @@ class ViewProviderDressup: class CommandPathDressupLeadInOut: + # pylint: disable=no-init + def GetResources(self): return { "Pixmap": "Path_Dressup", @@ -732,7 +747,7 @@ class CommandPathDressupLeadInOut: FreeCADGui.doCommand( "Gui.ActiveDocument.getObject(base.Name).Visibility = False" ) - # FreeCAD.ActiveDocument.commitTransaction() # Final `commitTransaction()` called via TaskPanel.accept() + FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() From 1f453b23397bf37d6d37ec2859c9e1df8f6ea99a Mon Sep 17 00:00:00 2001 From: sliptonic Date: Thu, 24 Mar 2022 09:46:40 -0500 Subject: [PATCH 02/39] Black reformat --- .../Path/PathScripts/PathDressupLeadInOut.py | 209 +++++++++++------- 1 file changed, 127 insertions(+), 82 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py index 13bd8fe3b2..3c0671b65f 100644 --- a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py +++ b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py @@ -248,7 +248,7 @@ class ObjectDressup: return FreeCAD.Vector(xnew, ynew, Vector.z) def getLeadStart(self, obj, queue, action): - '''returns Lead In G-code.''' + """returns Lead In G-code.""" # Modified March 2022 by lcorley to support leadin extension results = [] op = PathDressup.baseOp(obj.Base) @@ -259,7 +259,7 @@ class ObjectDressup: arcs_identical = False # Set the correct twist command - if self.getDirectionOfPath(obj) == 'left': + if self.getDirectionOfPath(obj) == "left": arcdir = "G3" else: arcdir = "G2" @@ -269,18 +269,22 @@ class ObjectDressup: p0 = queue[0].Placement.Base p1 = queue[1].Placement.Base v = self.normalize(p1.sub(p0)) - PathLog.debug(" CURRENT_IN Line : P0 Z:{} p1 Z:{}".format(p0.z,p1.z)) + PathLog.debug(" CURRENT_IN Line : P0 Z:{} p1 Z:{}".format(p0.z, p1.z)) else: p0 = queue[0].Placement.Base p1 = queue[1].Placement.Base v = self.normalize(p1.sub(p0)) - PathLog.debug(" CURRENT_IN ARC : P0 X:{} Y:{} P1 X:{} Y:{} ".format(p0.x,p0.y,p1.x,p1.y)) + PathLog.debug( + " CURRENT_IN ARC : P0 X:{} Y:{} P1 X:{} Y:{} ".format( + p0.x, p0.y, p1.x, p1.y + ) + ) # Calculate offset vector (will be overwritten for arcs) - if self.getDirectionOfPath(obj) == 'right': - off_v = FreeCAD.Vector(v.y*R, -v.x*R, 0.0) + if self.getDirectionOfPath(obj) == "right": + off_v = FreeCAD.Vector(v.y * R, -v.x * R, 0.0) else: - off_v = FreeCAD.Vector(-v.y*R, v.x*R, 0.0) + off_v = FreeCAD.Vector(-v.y * R, v.x * R, 0.0) # Check if we enter at line or arc command if queue[1].Name in movecommands and queue[1].Name not in arccommands: @@ -288,14 +292,18 @@ class ObjectDressup: vec = p1.sub(p0) vec_n = self.normalize(vec) vec_inv = self.invert(vec_n) - vec_off = self.multiply(vec_inv, obj.ExtendLeadIn) - PathLog.debug("LineCMD: {}, Vxinv: {}, Vyinv: {}, Vxoff: {}, Vyoff: {}".format(queue[0].Name, vec_inv.x, vec_inv.y, vec_off.x, vec_off.y)) + vec_off = self.multiply(vec_inv, obj.ExtendLeadIn) + PathLog.debug( + "LineCMD: {}, Vxinv: {}, Vyinv: {}, Vxoff: {}, Vyoff: {}".format( + queue[0].Name, vec_inv.x, vec_inv.y, vec_off.x, vec_off.y + ) + ) else: # We have an arc move # Calculate coordinates for middle of circle pij = copy.deepcopy(p0) - pij.x += queue[1].Parameters['I'] - pij.y += queue[1].Parameters['J'] + pij.x += queue[1].Parameters["I"] + pij.y += queue[1].Parameters["J"] # Check if lead in and operation go in same direction (usually for inner circles) if arcdir == queue[1].Name: @@ -306,9 +314,9 @@ class ObjectDressup: # Rotate vector to get direction for lead in if arcdir == "G2": - vec_rot = self.rotate(vec_circ, 90) + vec_rot = self.rotate(vec_circ, 90) else: - vec_rot = self.rotate(vec_circ, -90) + vec_rot = self.rotate(vec_circ, -90) # Normalize and invert vector vec_n = self.normalize(vec_rot) @@ -317,23 +325,23 @@ class ObjectDressup: # Calculate offset of lead in if arcdir == "G3": - off_v = FreeCAD.Vector(-v.y*R, v.x*R, 0.0) + off_v = FreeCAD.Vector(-v.y * R, v.x * R, 0.0) else: - off_v = FreeCAD.Vector(v.y*R, -v.x*R, 0.0) + off_v = FreeCAD.Vector(v.y * R, -v.x * R, 0.0) # Multiply offset by LeadIn length - #vec_off = self.multiply(vec_n, obj.ExtendLeadIn) + # vec_off = self.multiply(vec_n, obj.ExtendLeadIn) - #offsetvector = FreeCAD.Vector(v.x*R-vec_off.x, v.y*R-vec_off.y, 0) # IJ - offsetvector = FreeCAD.Vector(v.x*R, v.y*R, 0) # IJ + # offsetvector = FreeCAD.Vector(v.x*R-vec_off.x, v.y*R-vec_off.y, 0) # IJ + offsetvector = FreeCAD.Vector(v.x * R, v.y * R, 0) # IJ - if obj.RadiusCenter == 'Radius': + if obj.RadiusCenter == "Radius": leadstart = (p0.add(off_v)).sub(offsetvector) # Rmode if arcs_identical: t = p0.sub(leadstart) t = p0.add(t) leadstart = t - offsetvector = self.multiply(offsetvector, -1) + offsetvector = self.multiply(offsetvector, -1) else: leadstart = p0.add(off_v) # Dmode # At this point leadstart is the beginning of the leadin arc @@ -344,81 +352,111 @@ class ObjectDressup: tangentvec = self.rotate(offsetvector, -90) else: tangentvec = self.rotate(offsetvector, 90) - #print ("tangentvec = ", tangentvec) + # print ("tangentvec = ", tangentvec) # Normalize the tangent vector tangentvecNorm = self.normalize(tangentvec) - #print ("tangentvecNorm = ", tangentvecNorm) + # print ("tangentvecNorm = ", tangentvecNorm) # Multiply tangentvecNorm by LeadIn length - leadlinevec = self.multiply(tangentvecNorm, obj.ExtendLeadIn) - #print ("leadlinevec = ", leadlinevec) + leadlinevec = self.multiply(tangentvecNorm, obj.ExtendLeadIn) + # print ("leadlinevec = ", leadlinevec) # leadlinevec provides the offset from the beginning of the lead arc to the beginning of the extend line extendstart = leadstart.add(leadlinevec) - #print ("extendstart = ", extendstart) + # print ("extendstart = ", extendstart) - if action == 'start': + if action == "start": if obj.ExtendLeadIn != 0: # Rapid move to beginning of extend line - extendcommand = Path.Command('G0', {"X": extendstart.x, "Y": extendstart.y, "Z": op.ClearanceHeight.Value}) + extendcommand = Path.Command( + "G0", + { + "X": extendstart.x, + "Y": extendstart.y, + "Z": op.ClearanceHeight.Value, + }, + ) else: # Rapid move to beginning of leadin arc - extendcommand = Path.Command('G0', {"X": leadstart.x, "Y": leadstart.y, "Z": op.ClearanceHeight.Value}) + extendcommand = Path.Command( + "G0", + {"X": leadstart.x, "Y": leadstart.y, "Z": op.ClearanceHeight.Value}, + ) results.append(extendcommand) - extendcommand = Path.Command('G0', {"Z": op.SafeHeight.Value}) + extendcommand = Path.Command("G0", {"Z": op.SafeHeight.Value}) results.append(extendcommand) - if action == 'layer': + if action == "layer": if not obj.KeepToolDown: - extendcommand = Path.Command('G0', {"Z": op.SafeHeight.Value}) + extendcommand = Path.Command("G0", {"Z": op.SafeHeight.Value}) results.append(extendcommand) - extendcommand = Path.Command('G0', {"X": leadstart.x, "Y": leadstart.y}) + extendcommand = Path.Command("G0", {"X": leadstart.x, "Y": leadstart.y}) results.append(extendcommand) if not obj.RapidPlunge: - extendcommand = Path.Command('G1', {"X": leadstart.x, "Y": leadstart.y, "Z": p1.z, "F": vertFeed}) + extendcommand = Path.Command( + "G1", {"X": leadstart.x, "Y": leadstart.y, "Z": p1.z, "F": vertFeed} + ) else: - extendcommand = Path.Command('G0', {"X": leadstart.x, "Y": leadstart.y, "Z": p1.z,}) + extendcommand = Path.Command( + "G0", + { + "X": leadstart.x, + "Y": leadstart.y, + "Z": p1.z, + }, + ) results.append(extendcommand) if obj.UseMachineCRC: - if self.getDirectionOfPath(obj) == 'right': - results.append(Path.Command('G42', {'D': toolnummer})) + if self.getDirectionOfPath(obj) == "right": + results.append(Path.Command("G42", {"D": toolnummer})) else: - results.append(Path.Command('G41', {'D': toolnummer})) + results.append(Path.Command("G41", {"D": toolnummer})) - if obj.StyleOn == 'Arc': + if obj.StyleOn == "Arc": if obj.ExtendLeadIn != 0: # Insert move to beginning of leadin arc - extendcommand = Path.Command('G1', {"X": leadstart.x, "Y": leadstart.y, "F": horizFeed}) + extendcommand = Path.Command( + "G1", {"X": leadstart.x, "Y": leadstart.y, "F": horizFeed} + ) results.append(extendcommand) - arcmove = Path.Command(arcdir, {"X": p0.x, "Y": p0.y, "I": offsetvector.x, "J": offsetvector.y, "F": horizFeed}) # add G2/G3 move + arcmove = Path.Command( + arcdir, + { + "X": p0.x, + "Y": p0.y, + "I": offsetvector.x, + "J": offsetvector.y, + "F": horizFeed, + }, + ) # add G2/G3 move results.append(arcmove) - elif obj.StyleOn == 'Tangent': - extendcommand = Path.Command('G1', {"X": p0.x, "Y": p0.y, "F": horizFeed}) + elif obj.StyleOn == "Tangent": + extendcommand = Path.Command("G1", {"X": p0.x, "Y": p0.y, "F": horizFeed}) results.append(extendcommand) else: PathLog.debug(" CURRENT_IN Perp") currLocation.update(results[-1].Parameters) - currLocation['Z'] = p1.z + currLocation["Z"] = p1.z return results def getLeadEnd(self, obj, queue, action): - '''returns the Gcode of LeadOut.''' + """returns the Gcode of LeadOut.""" # Modified March 2022 by lcorley to support leadout extension - # pylint: disable=unused-argument + # pylint: disable=unused-argument results = [] - #print ("action =", action) - #print ("queue[0] =" ,queue[0]) - #print ("queue[1] =" ,queue[1]) - #print ("queue[2] =" ,queue[2]) + # print ("action =", action) + # print ("queue[0] =" ,queue[0]) + # print ("queue[1] =" ,queue[1]) + # print ("queue[2] =" ,queue[2]) horizFeed = PathDressup.toolController(obj.Base).HorizFeed.Value R = obj.Length.Value # Radius of roll or length arcs_identical = False # Set the correct twist command - if self.getDirectionOfPath(obj) == 'right': + if self.getDirectionOfPath(obj) == "right": arcdir = "G2" else: arcdir = "G3" @@ -432,10 +470,10 @@ class ObjectDressup: p1 = queue[1].Placement.Base v = self.normalize(p1.sub(p0)) - if self.getDirectionOfPath(obj) == 'right': - off_v = FreeCAD.Vector(v.y*R, -v.x*R, 0.0) + if self.getDirectionOfPath(obj) == "right": + off_v = FreeCAD.Vector(v.y * R, -v.x * R, 0.0) else: - off_v = FreeCAD.Vector(-v.y*R, v.x*R, 0.0) + off_v = FreeCAD.Vector(-v.y * R, v.x * R, 0.0) # Check if we leave at line or arc command if queue[1].Name in movecommands and queue[1].Name not in arccommands: @@ -443,84 +481,91 @@ class ObjectDressup: vec = p1.sub(p0) vec_n = self.normalize(vec) vec_inv = self.invert(vec_n) - vec_off = self.multiply(vec_inv, obj.ExtendLeadOut) - #PathLog.debug("LineCMD: {}, Vxinv: {}, Vyinv: {}, Vxoff: {}, Vyoff: {}".format(queue[0].Name, vec_inv.x, vec_inv.y, vec_off.x, vec_off.y)) + vec_off = self.multiply(vec_inv, obj.ExtendLeadOut) + # PathLog.debug("LineCMD: {}, Vxinv: {}, Vyinv: {}, Vxoff: {}, Vyoff: {}".format(queue[0].Name, vec_inv.x, vec_inv.y, vec_off.x, vec_off.y)) else: # We have an arc move pij = copy.deepcopy(p0) - pij.x += queue[1].Parameters['I'] - pij.y += queue[1].Parameters['J'] + pij.x += queue[1].Parameters["I"] + pij.y += queue[1].Parameters["J"] ve = pij.sub(p1) if arcdir == queue[1].Name: arcs_identical = True if arcdir == "G2": - vec_rot = self.rotate(ve, -90) + vec_rot = self.rotate(ve, -90) else: - vec_rot = self.rotate(ve, 90) + vec_rot = self.rotate(ve, 90) vec_n = self.normalize(vec_rot) v = vec_n if arcdir == "G3": - off_v = FreeCAD.Vector(-v.y*R, v.x*R, 0.0) + off_v = FreeCAD.Vector(-v.y * R, v.x * R, 0.0) else: - off_v = FreeCAD.Vector(v.y*R, -v.x*R, 0.0) + off_v = FreeCAD.Vector(v.y * R, -v.x * R, 0.0) vec_inv = self.invert(vec_rot) - #vec_off = self.multiply(vec_inv, obj.ExtendLeadOut) + # vec_off = self.multiply(vec_inv, obj.ExtendLeadOut) - #offsetvector = FreeCAD.Vector(v.x*R-vec_off.x, v.y*R-vec_off.y, 0.0) - offsetvector = FreeCAD.Vector(v.x*R, v.y*R, 0.0) - if obj.RadiusCenter == 'Radius': + # offsetvector = FreeCAD.Vector(v.x*R-vec_off.x, v.y*R-vec_off.y, 0.0) + offsetvector = FreeCAD.Vector(v.x * R, v.y * R, 0.0) + if obj.RadiusCenter == "Radius": leadend = (p1.add(off_v)).add(offsetvector) # Rmode if arcs_identical: t = p1.sub(leadend) t = p1.add(t) leadend = t - off_v = self.multiply(off_v, -1) + off_v = self.multiply(off_v, -1) else: leadend = p1.add(off_v) # Dmode IJ = off_v # .negative() - #print ("leadend = ", leadend) - #print ("IJ = ", IJ) + # print ("leadend = ", leadend) + # print ("IJ = ", IJ) # At this point leadend is the location of the end of the leadout arc # IJ is an offset from the begining of the leadout arc to its center. # It is parallel to a tangent line at the end of the leadout arc # Create the normalized tangent vector tangentvecNorm = self.normalize(IJ) - #print ("tangentvecNorm = ", tangentvecNorm) + # print ("tangentvecNorm = ", tangentvecNorm) # Multiply tangentvecNorm by LeadOut length - leadlinevec = self.multiply(tangentvecNorm, obj.ExtendLeadOut) - #print ("leadlinevec = ", leadlinevec) + leadlinevec = self.multiply(tangentvecNorm, obj.ExtendLeadOut) + # print ("leadlinevec = ", leadlinevec) # leadlinevec provides the offset from the end of the leadout arc to the end of the extend line extendleadoutend = leadend.add(leadlinevec) - #print ("extendleadoutend = ", extendleadoutend) + # print ("extendleadoutend = ", extendleadoutend) - #results.append(queue[1]) - if obj.StyleOff == 'Arc': - arcmove = Path.Command(arcdir, {"X": leadend.x, "Y": leadend.y, "I": IJ.x, "J": IJ.y, "F": horizFeed}) # add G2/G3 move + # results.append(queue[1]) + if obj.StyleOff == "Arc": + arcmove = Path.Command( + arcdir, + {"X": leadend.x, "Y": leadend.y, "I": IJ.x, "J": IJ.y, "F": horizFeed}, + ) # add G2/G3 move results.append(arcmove) if obj.ExtendLeadOut != 0: - extendcommand = Path.Command('G1', {"X": extendleadoutend.x, "Y": extendleadoutend.y, "F": horizFeed}) + extendcommand = Path.Command( + "G1", + {"X": extendleadoutend.x, "Y": extendleadoutend.y, "F": horizFeed}, + ) results.append(extendcommand) - elif obj.StyleOff == 'Tangent': - extendcommand = Path.Command('G1', {"X": leadend.x, "Y": leadend.y, "F": horizFeed}) + elif obj.StyleOff == "Tangent": + extendcommand = Path.Command( + "G1", {"X": leadend.x, "Y": leadend.y, "F": horizFeed} + ) results.append(extendcommand) else: PathLog.debug(" CURRENT_IN Perp") if obj.UseMachineCRC: # crc off - results.append(Path.Command('G40', {})) - - #print ("results =",results) + results.append(Path.Command("G40", {})) + + # print ("results =",results) return results - def generateLeadInOutCurve(self, obj): global currLocation # pylint: disable=global-statement firstmove = Path.Command("G0", {"X": 0, "Y": 0, "Z": 0}) From 8fd52094f5ee9719be4ee7c2bc38387c2cea730b Mon Sep 17 00:00:00 2001 From: sliptonic Date: Thu, 24 Mar 2022 10:07:59 -0500 Subject: [PATCH 03/39] remove pylint, commented code, and uncomment PathLogs --- .../Path/PathScripts/PathDressupLeadInOut.py | 51 +++---------------- 1 file changed, 8 insertions(+), 43 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py index 3c0671b65f..0fecc17184 100644 --- a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py +++ b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py @@ -162,7 +162,6 @@ class ObjectDressup: return None def __setstate__(self, state): - # pylint: disable=unused-argument return None def setup(self, obj): @@ -329,10 +328,6 @@ class ObjectDressup: else: off_v = FreeCAD.Vector(v.y * R, -v.x * R, 0.0) - # Multiply offset by LeadIn length - # vec_off = self.multiply(vec_n, obj.ExtendLeadIn) - - # offsetvector = FreeCAD.Vector(v.x*R-vec_off.x, v.y*R-vec_off.y, 0) # IJ offsetvector = FreeCAD.Vector(v.x * R, v.y * R, 0) # IJ if obj.RadiusCenter == "Radius": @@ -352,16 +347,12 @@ class ObjectDressup: tangentvec = self.rotate(offsetvector, -90) else: tangentvec = self.rotate(offsetvector, 90) - # print ("tangentvec = ", tangentvec) # Normalize the tangent vector tangentvecNorm = self.normalize(tangentvec) - # print ("tangentvecNorm = ", tangentvecNorm) # Multiply tangentvecNorm by LeadIn length leadlinevec = self.multiply(tangentvecNorm, obj.ExtendLeadIn) - # print ("leadlinevec = ", leadlinevec) # leadlinevec provides the offset from the beginning of the lead arc to the beginning of the extend line extendstart = leadstart.add(leadlinevec) - # print ("extendstart = ", extendstart) if action == "start": if obj.ExtendLeadIn != 0: @@ -444,13 +435,7 @@ class ObjectDressup: def getLeadEnd(self, obj, queue, action): """returns the Gcode of LeadOut.""" - # Modified March 2022 by lcorley to support leadout extension - # pylint: disable=unused-argument results = [] - # print ("action =", action) - # print ("queue[0] =" ,queue[0]) - # print ("queue[1] =" ,queue[1]) - # print ("queue[2] =" ,queue[2]) horizFeed = PathDressup.toolController(obj.Base).HorizFeed.Value R = obj.Length.Value # Radius of roll or length arcs_identical = False @@ -482,7 +467,7 @@ class ObjectDressup: vec_n = self.normalize(vec) vec_inv = self.invert(vec_n) vec_off = self.multiply(vec_inv, obj.ExtendLeadOut) - # PathLog.debug("LineCMD: {}, Vxinv: {}, Vyinv: {}, Vxoff: {}, Vyoff: {}".format(queue[0].Name, vec_inv.x, vec_inv.y, vec_off.x, vec_off.y)) + PathLog.debug("LineCMD: {}, Vxinv: {}, Vyinv: {}, Vxoff: {}, Vyoff: {}".format(queue[0].Name, vec_inv.x, vec_inv.y, vec_off.x, vec_off.y)) else: # We have an arc move pij = copy.deepcopy(p0) @@ -508,9 +493,6 @@ class ObjectDressup: vec_inv = self.invert(vec_rot) - # vec_off = self.multiply(vec_inv, obj.ExtendLeadOut) - - # offsetvector = FreeCAD.Vector(v.x*R-vec_off.x, v.y*R-vec_off.y, 0.0) offsetvector = FreeCAD.Vector(v.x * R, v.y * R, 0.0) if obj.RadiusCenter == "Radius": leadend = (p1.add(off_v)).add(offsetvector) # Rmode @@ -522,23 +504,15 @@ class ObjectDressup: else: leadend = p1.add(off_v) # Dmode - IJ = off_v # .negative() - # print ("leadend = ", leadend) - # print ("IJ = ", IJ) + IJ = off_v # At this point leadend is the location of the end of the leadout arc - # IJ is an offset from the begining of the leadout arc to its center. + # IJ is an offset from the beginning of the leadout arc to its center. # It is parallel to a tangent line at the end of the leadout arc # Create the normalized tangent vector tangentvecNorm = self.normalize(IJ) - # print ("tangentvecNorm = ", tangentvecNorm) - # Multiply tangentvecNorm by LeadOut length leadlinevec = self.multiply(tangentvecNorm, obj.ExtendLeadOut) - # print ("leadlinevec = ", leadlinevec) - # leadlinevec provides the offset from the end of the leadout arc to the end of the extend line extendleadoutend = leadend.add(leadlinevec) - # print ("extendleadoutend = ", extendleadoutend) - # results.append(queue[1]) if obj.StyleOff == "Arc": arcmove = Path.Command( arcdir, @@ -562,12 +536,10 @@ class ObjectDressup: if obj.UseMachineCRC: # crc off results.append(Path.Command("G40", {})) - # print ("results =",results) - return results def generateLeadInOutCurve(self, obj): - global currLocation # pylint: disable=global-statement + global currLocation firstmove = Path.Command("G0", {"X": 0, "Y": 0, "Z": 0}) op = PathDressup.baseOp(obj.Base) currLocation.update(firstmove.Parameters) @@ -579,7 +551,7 @@ class ObjectDressup: # Read in all commands for curCommand in obj.Base.Path.Commands: - # PathLog.debug("CurCMD: {}".format(curCommand)) + PathLog.debug("CurCMD: {}".format(curCommand)) if curCommand.Name not in movecommands + rapidcommands: # Don't worry about non-move commands, just add to output newpath.append(curCommand) @@ -606,7 +578,7 @@ class ObjectDressup: and prevCmd.Name in movecommands ): # Layer change within move cmds - # PathLog.debug("Layer change in move: {}->{}".format(currLocation['Z'], curCommand.z)) + PathLog.debug("Layer change in move: {}->{}".format(currLocation['Z'], curCommand.z)) layers.append(queue) queue = [] @@ -623,16 +595,14 @@ class ObjectDressup: # Go through each layer and add leadIn/Out idx = 0 for layer in layers: - # PathLog.debug("Layer {}".format(idx)) + PathLog.debug("Layer {}".format(idx)) if obj.LeadIn: temp = self.getLeadStart(obj, layer, action) newpath.extend(temp) for cmd in layer: - # PathLog.debug("CurLoc: {}, NewCmd: {}".format(currLocation, cmd)) - # if currLocation['X'] == cmd.x and currLocation['Y'] == cmd.y and currLocation['Z'] == cmd.z and cmd.Name in ['G1', 'G01']: - # continue + PathLog.debug("CurLoc: {}, NewCmd: {}".format(currLocation, cmd)) newpath.append(cmd) if obj.LeadOut: @@ -693,11 +663,9 @@ class ViewProviderDressup: group.remove(g) i.Group = group print(i.Group) - # FreeCADGui.ActiveDocument.getObject(obj.Base.Name).Visibility = False return [self.obj.Base] def setEdit(self, vobj, mode=0): - # pylint: disable=unused-argument FreeCADGui.Control.closeDialog() panel = TaskDressupLeadInOut(vobj.Object, self) FreeCADGui.Control.showDialog(panel) @@ -709,7 +677,6 @@ class ViewProviderDressup: def onDelete(self, arg1=None, arg2=None): """this makes sure that the base operation is added back to the project and visible""" - # pylint: disable=unused-argument PathLog.debug("Deleting Dressup") if arg1.Object and arg1.Object.Base: FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True @@ -723,7 +690,6 @@ class ViewProviderDressup: return None def __setstate__(self, state): - # pylint: disable=unused-argument return None def clearTaskPanel(self): @@ -731,7 +697,6 @@ class ViewProviderDressup: class CommandPathDressupLeadInOut: - # pylint: disable=no-init def GetResources(self): return { From 1e9094272c1dfc0e20687253f0fb95f7982a583c Mon Sep 17 00:00:00 2001 From: sliptonic Date: Mon, 28 Mar 2022 16:30:41 -0500 Subject: [PATCH 04/39] [Path] Fix initial descent at start --- .../Path/PathScripts/PathDressupLeadInOut.py | 54 +++++++++++++------ 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py index 0fecc17184..e1076adc22 100644 --- a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py +++ b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py @@ -41,7 +41,7 @@ from PathPythonGui.simple_edit_panel import SimpleEditPanel translate = FreeCAD.Qt.translate -if False: +if True: PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) PathLog.trackModule(PathLog.thisModule()) else: @@ -354,6 +354,16 @@ class ObjectDressup: # leadlinevec provides the offset from the beginning of the lead arc to the beginning of the extend line extendstart = leadstart.add(leadlinevec) + # commandname = "G0" if obj.RapidPlunge else "G1" + # extendcommand = Path.Command( + # commandname, + # { + # "X": leadstart.x, + # "Y": leadstart.y, + # "Z": p1.z, + # }, + # ) + # results.append(extendcommand) if action == "start": if obj.ExtendLeadIn != 0: # Rapid move to beginning of extend line @@ -369,7 +379,7 @@ class ObjectDressup: # Rapid move to beginning of leadin arc extendcommand = Path.Command( "G0", - {"X": leadstart.x, "Y": leadstart.y, "Z": op.ClearanceHeight.Value}, + {"X": extendstart.x, "Y": extendstart.y, "Z": op.ClearanceHeight.Value}, ) results.append(extendcommand) extendcommand = Path.Command("G0", {"Z": op.SafeHeight.Value}) @@ -380,23 +390,33 @@ class ObjectDressup: extendcommand = Path.Command("G0", {"Z": op.SafeHeight.Value}) results.append(extendcommand) - extendcommand = Path.Command("G0", {"X": leadstart.x, "Y": leadstart.y}) + extendcommand = Path.Command("G0", {"X": extendstart.x, "Y": extendstart.y}) results.append(extendcommand) - if not obj.RapidPlunge: - extendcommand = Path.Command( - "G1", {"X": leadstart.x, "Y": leadstart.y, "Z": p1.z, "F": vertFeed} - ) - else: - extendcommand = Path.Command( - "G0", - { - "X": leadstart.x, - "Y": leadstart.y, - "Z": p1.z, - }, - ) + commandname = "G0" if obj.RapidPlunge else "G1" + extendcommand = Path.Command( + commandname, + { + # "X": leadstart.x, + # "Y": leadstart.y, + "Z": p1.z, + }, + ) results.append(extendcommand) + # if not obj.RapidPlunge: + # extendcommand = Path.Command( + # "G1", {"X": leadstart.x, "Y": leadstart.y, "Z": p1.z, "F": vertFeed} + # ) + # else: + # extendcommand = Path.Command( + # "G0", + # { + # "X": leadstart.x, + # "Y": leadstart.y, + # "Z": p1.z, + # }, + # ) + # results.append(extendcommand) if obj.UseMachineCRC: if self.getDirectionOfPath(obj) == "right": @@ -602,7 +622,7 @@ class ObjectDressup: newpath.extend(temp) for cmd in layer: - PathLog.debug("CurLoc: {}, NewCmd: {}".format(currLocation, cmd)) + PathLog.debug("CurLoc: {}, NewCmd: {}!!".format(currLocation, cmd)) newpath.append(cmd) if obj.LeadOut: From eb380178286eb1c8693190294ad3c2bd3283126a Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Sun, 27 Mar 2022 20:50:49 +0200 Subject: [PATCH 05/39] Gui: fix locale number formatting propagation --- src/Gui/InputField.cpp | 3 --- src/Gui/Language/Translator.cpp | 7 ++++--- src/Gui/QuantitySpinBox.cpp | 6 +++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Gui/InputField.cpp b/src/Gui/InputField.cpp index fb0aec5731..d03a521d4d 100644 --- a/src/Gui/InputField.cpp +++ b/src/Gui/InputField.cpp @@ -95,9 +95,6 @@ InputField::InputField(QWidget * parent) QObject::connect(this, SIGNAL(textChanged(QString)), this, SLOT(newInput(QString))); -#ifdef FC_OS_WIN32 - setLocale(QLocale()); -#endif } InputField::~InputField() diff --git a/src/Gui/Language/Translator.cpp b/src/Gui/Language/Translator.cpp index eaa4148e6e..ec91bff293 100644 --- a/src/Gui/Language/Translator.cpp +++ b/src/Gui/Language/Translator.cpp @@ -28,6 +28,7 @@ # include # include # include +# include #endif #include @@ -275,9 +276,9 @@ void Translator::setSystemLocale() const void Translator::updateLocaleChange() const { - // Need to manually send the event so locale change is fully took into account on widgets - auto ev = QEvent(QEvent::LocaleChange); - qApp->sendEvent(qApp, &ev); + for (auto &topLevelWidget: qApp->topLevelWidgets()) { + topLevelWidget->setLocale(QLocale()); + } } QStringList Translator::directories() const diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index d503c3625d..fc13b9ad51 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -139,7 +139,7 @@ public: { try { QString copy = str; - copy.remove(QLocale().groupSeparator()); + copy.remove(locale.groupSeparator()); result = Base::Quantity::parse(copy); value = result.getValue(); @@ -162,8 +162,6 @@ public: const bool plus = max >= 0; const bool minus = min <= 0; - auto locale = QLocale(); - switch (len) { case 0: state = max != min ? QValidator::Intermediate : QValidator::Invalid; @@ -292,6 +290,7 @@ end: return res; } + QLocale locale; bool validInput; bool pendingEmit; QString validStr; @@ -314,6 +313,7 @@ QuantitySpinBox::QuantitySpinBox(QWidget *parent) ExpressionSpinBox(this), d_ptr(new QuantitySpinBoxPrivate(this)) { + d_ptr->locale = locale(); this->setContextMenuPolicy(Qt::DefaultContextMenu); QObject::connect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(userInput(QString))); From 63d211dca9adf8c35926e8715a1a0729d15bf032 Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Mon, 28 Mar 2022 18:44:32 +0200 Subject: [PATCH 06/39] Gui: improve a bit number format selection --- src/Gui/DlgGeneral.ui | 84 +++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 48 deletions(-) diff --git a/src/Gui/DlgGeneral.ui b/src/Gui/DlgGeneral.ui index 9312c3b95b..3e4e81f9de 100644 --- a/src/Gui/DlgGeneral.ui +++ b/src/Gui/DlgGeneral.ui @@ -57,39 +57,27 @@ 6 - - - 6 + + + Change language: - - 0 + + + + + + Language of the application's user interface - - 0 - - - 0 - - - 0 - - - - - Change language: - - - - - - - Language of the application's user interface - - - - + + + + Number format: + + + + UseLocaleFormatting @@ -99,37 +87,37 @@ - Number format of operating system + Operating system - Use selected language number format + Selected language - C/POSIX number format + C/POSIX - - - - If enabled, numerical keypad decimal separator will be substituted with locale separator - - - Substitute decimal separator (needs restart) - - - SubstituteDecimalSeparator - - - General - - - + + + + If enabled, numerical keypad decimal separator will be substituted with locale separator + + + Substitute decimal separator (needs restart) + + + SubstituteDecimalSeparator + + + General + + + From c6ea26a70c80c561ca1b726dc5efdfd35540201f Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Mon, 28 Mar 2022 19:00:10 +0200 Subject: [PATCH 07/39] Gui: fix algorithmic issue in language change If number format mode is "Selected language", even if this mode isn't modified, we need to force 'setLocale' to update if "Language" has been changed --- src/Gui/DlgGeneralImp.cpp | 13 ++++++++----- src/Gui/DlgGeneralImp.h | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Gui/DlgGeneralImp.cpp b/src/Gui/DlgGeneralImp.cpp index d9e2e65bf4..c184f74352 100644 --- a/src/Gui/DlgGeneralImp.cpp +++ b/src/Gui/DlgGeneralImp.cpp @@ -120,7 +120,7 @@ void DlgGeneralImp::setRecentFileSize() } } -void DlgGeneralImp::setLanguage() +bool DlgGeneralImp::setLanguage() { ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("General"); QString lang = QLocale::languageToString(QLocale().language()); @@ -129,15 +129,17 @@ void DlgGeneralImp::setLanguage() if (current != language) { hGrp->SetASCII("Language", current.constData()); Translator::instance()->activateLanguage(current.constData()); + return true; } + return false; } -void DlgGeneralImp::setNumberLocale() +void DlgGeneralImp::setNumberLocale(bool force/* = false*/) { int localeFormat = ui->UseLocaleFormatting->currentIndex(); // Only make the change if locale setting has changed - if (localeIndex == localeFormat) + if (!force && localeIndex == localeFormat) return; if (localeFormat == 0) { @@ -167,8 +169,9 @@ void DlgGeneralImp::saveSettings() ui->SplashScreen->onSave(); setRecentFileSize(); - setLanguage(); - setNumberLocale(); + bool force = setLanguage(); + // In case type is "Selected language", we need to force locale change + setNumberLocale(force); ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("General"); QVariant size = ui->toolbarIconSize->itemData(ui->toolbarIconSize->currentIndex()); diff --git a/src/Gui/DlgGeneralImp.h b/src/Gui/DlgGeneralImp.h index 6cfa09c918..7ea991d203 100644 --- a/src/Gui/DlgGeneralImp.h +++ b/src/Gui/DlgGeneralImp.h @@ -64,8 +64,8 @@ private: void setRecentFileSize(); void saveAsNewPreferencePack(); void revertToSavedConfig(); - void setLanguage(); - void setNumberLocale(); + bool setLanguage(); //Returns true if language has been changed + void setNumberLocale(bool force = false); private: int localeIndex; From 32f6443bd4062d314a0bb43305a398b4a5d54bd7 Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Mon, 28 Mar 2022 19:20:14 +0200 Subject: [PATCH 08/39] Gui: fix (another) algorithmic issue in number format change 'localeIndex' shall be updated not only at settings loading but each time settings are saved, otherwise it can lead to unexpected behavior (number format not took into account) when changing number format back and forth and only using 'Apply' button. --- src/Gui/DlgGeneralImp.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Gui/DlgGeneralImp.cpp b/src/Gui/DlgGeneralImp.cpp index c184f74352..6b1321ca12 100644 --- a/src/Gui/DlgGeneralImp.cpp +++ b/src/Gui/DlgGeneralImp.cpp @@ -138,8 +138,9 @@ void DlgGeneralImp::setNumberLocale(bool force/* = false*/) { int localeFormat = ui->UseLocaleFormatting->currentIndex(); - // Only make the change if locale setting has changed - if (!force && localeIndex == localeFormat) + // Only make the change if locale setting has changed or if forced + // Except if format is "OS" where we don't want to run setLocale + if (localeIndex == localeFormat && (!force || localeFormat == 0)) return; if (localeFormat == 0) { @@ -152,6 +153,10 @@ void DlgGeneralImp::setNumberLocale(bool force/* = false*/) else if (localeFormat == 2) { Translator::instance()->setLocale("C"); } + else { + return; // Prevent localeIndex updating if localeFormat is out of range + } + localeIndex = localeFormat; } void DlgGeneralImp::saveSettings() From 7a74ae01d34d1b3ca01b45a0bcd5d914dde8a65f Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Mon, 28 Mar 2022 19:15:04 +0200 Subject: [PATCH 09/39] Gui: Default Translator::SetLocale to OS locale + simplify code --- src/Gui/DlgGeneralImp.cpp | 2 +- src/Gui/Language/Translator.cpp | 23 ++++++++++------------- src/Gui/Language/Translator.h | 5 ++--- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/Gui/DlgGeneralImp.cpp b/src/Gui/DlgGeneralImp.cpp index 6b1321ca12..80df23edae 100644 --- a/src/Gui/DlgGeneralImp.cpp +++ b/src/Gui/DlgGeneralImp.cpp @@ -144,7 +144,7 @@ void DlgGeneralImp::setNumberLocale(bool force/* = false*/) return; if (localeFormat == 0) { - Translator::instance()->setSystemLocale(); + Translator::instance()->setLocale(); // Defaults to system locale } else if (localeFormat == 1) { QByteArray current = ui->Languages->itemData(ui->Languages->currentIndex()).toByteArray(); diff --git a/src/Gui/Language/Translator.cpp b/src/Gui/Language/Translator.cpp index ec91bff293..3e40fe3341 100644 --- a/src/Gui/Language/Translator.cpp +++ b/src/Gui/Language/Translator.cpp @@ -252,26 +252,23 @@ std::string Translator::locale(const std::string& lang) const return loc; } -bool Translator::setLocale(const std::string& language) const +void Translator::setLocale(const std::string& language) const { - auto loc = QLocale::c(); //Defaulting to POSIX locale - auto bcp47 = locale(language); - if (!bcp47.empty()) - loc = QLocale(QString::fromStdString(bcp47)); + auto loc = QLocale::system(); //Defaulting to OS locale + if (language == "C" || language == "c") { + loc = QLocale::c(); + } + else { + auto bcp47 = locale(language); + if (!bcp47.empty()) + loc = QLocale(QString::fromStdString(bcp47)); + } QLocale::setDefault(loc); updateLocaleChange(); #ifdef FC_DEBUG Base::Console().Log("Locale changed to %s => %s\n", qPrintable(loc.bcp47Name()), qPrintable(loc.name())); #endif - - return (loc.language() != loc.C); -} - -void Translator::setSystemLocale() const -{ - QLocale::setDefault(QLocale::system()); - updateLocaleChange(); } void Translator::updateLocaleChange() const diff --git a/src/Gui/Language/Translator.h b/src/Gui/Language/Translator.h index 982fd15ce0..0ec3f2e516 100644 --- a/src/Gui/Language/Translator.h +++ b/src/Gui/Language/Translator.h @@ -66,9 +66,8 @@ public: std::string activeLanguage() const; /** Returns the locale (e.g. "de") to the given language name. */ std::string locale(const std::string&) const; - /** Sets default Qt locale based on given language name. Returns true if matching QLocale found**/ - bool setLocale(const std::string&) const; - void setSystemLocale() const; + /** Sets default Qt locale based on given language name **/ + void setLocale(const std::string& = "") const; /** Returns a list of supported languages. */ TStringList supportedLanguages() const; /** Returns a map of supported languages/locales. */ From 3753a4b2371ae5ebebf7a3d471c686e1eecf1c25 Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Mon, 28 Mar 2022 19:49:33 +0200 Subject: [PATCH 10/39] Gui: Add dual info about FC + OS locale in full information + clean some horrible old code --- src/Gui/Splashscreen.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Gui/Splashscreen.cpp b/src/Gui/Splashscreen.cpp index 63733a0777..deb6e922d7 100644 --- a/src/Gui/Splashscreen.cpp +++ b/src/Gui/Splashscreen.cpp @@ -683,15 +683,15 @@ void AboutDialog::on_copyButton_clicked() QString minor = QString::fromLatin1(config["BuildVersionMinor"].c_str()); QString build = QString::fromLatin1(config["BuildRevision"].c_str()); - QString deskEnv = QProcessEnvironment::systemEnvironment().value(QString::fromLatin1("XDG_CURRENT_DESKTOP"),QString::fromLatin1("")); - QString deskSess = QProcessEnvironment::systemEnvironment().value(QString::fromLatin1("DESKTOP_SESSION"),QString::fromLatin1("")); - QString deskInfo = QString::fromLatin1(""); + QString deskEnv = QProcessEnvironment::systemEnvironment().value(QStringLiteral("XDG_CURRENT_DESKTOP"),QStringLiteral("")); + QString deskSess = QProcessEnvironment::systemEnvironment().value(QStringLiteral("DESKTOP_SESSION"),QStringLiteral("")); + QString deskInfo = QStringLiteral(""); - if (!(deskEnv == QString::fromLatin1("") && deskSess == QString::fromLatin1(""))) { - if (deskEnv == QString::fromLatin1("") || deskSess == QString::fromLatin1("")) - deskInfo = QString::fromLatin1(" (") + deskEnv + deskSess + QString::fromLatin1(")"); + if ( !(deskEnv.isEmpty() && deskSess.isEmpty()) ) { + if ( deskEnv.isEmpty() || deskSess.isEmpty() ) + deskInfo = QLatin1String(" (") + deskEnv + deskSess + QLatin1String(")"); else - deskInfo = QString::fromLatin1(" (") + deskEnv + QString::fromLatin1("/") + deskSess + QString::fromLatin1(")"); + deskInfo = QLatin1String(" (") + deskEnv + QLatin1String("/") + deskSess + QLatin1String(")"); } str << "[code]\n"; @@ -735,7 +735,14 @@ void AboutDialog::on_copyButton_clicked() QLocale loc; str << "Locale: " << loc.languageToString(loc.language()) << "/" << loc.countryToString(loc.country()) - << " (" << loc.name() << ")\n"; + << " (" << loc.name() << ")"; + if (loc != QLocale::system()) { + loc = QLocale::system(); + str << " [ OS: " << loc.languageToString(loc.language()) << "/" + << loc.countryToString(loc.country()) + << " (" << loc.name() << ") ]"; + } + str << "\n"; // Add installed module information: auto modDir = fs::path(App::Application::getUserAppDataDir()) / "Mod"; From 9069fdee15e5be76bbc67ee195e2273851da0af4 Mon Sep 17 00:00:00 2001 From: Wanderer Fan Date: Sat, 19 Mar 2022 13:07:35 -0400 Subject: [PATCH 11/39] [TD]skip LCS infinite shapes --- src/Mod/TechDraw/App/ShapeExtractor.cpp | 64 ++++++++++++++++++++----- src/Mod/TechDraw/App/ShapeExtractor.h | 2 + 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/src/Mod/TechDraw/App/ShapeExtractor.cpp b/src/Mod/TechDraw/App/ShapeExtractor.cpp index f28fb98c9c..e1073298d3 100644 --- a/src/Mod/TechDraw/App/ShapeExtractor.cpp +++ b/src/Mod/TechDraw/App/ShapeExtractor.cpp @@ -115,7 +115,6 @@ TopoDS_Shape ShapeExtractor::getShapes(const std::vector l } else { auto shape = Part::Feature::getShape(l); if(!shape.IsNull()) { - // BRepTools::Write(shape, "DVPgetShape.brep"); //debug sourceShapes.push_back(shape); } else { std::vector shapeList = getShapesFromObject(l); @@ -129,21 +128,31 @@ TopoDS_Shape ShapeExtractor::getShapes(const std::vector l builder.MakeCompound(comp); bool found = false; for (auto& s:sourceShapes) { - if (s.IsNull() || Part::TopoShape(s).isInfinite()) { - continue; // has no shape or the shape is infinite + if (s.ShapeType() < TopAbs_SOLID) { + //clean up composite shapes + TopoDS_Shape cleanShape = stripInfiniteShapes(s); + if (!cleanShape.IsNull()) { + builder.Add(comp, cleanShape); + found = true; + } + } else if (s.IsNull()) { + continue; // has no shape + } else if (Part::TopoShape(s).isInfinite()) { + continue; //shape is infinite + } else { + //a simple shape - add to compound + builder.Add(comp, s); + found = true; } - found = true; - BRepBuilderAPI_Copy BuilderCopy(s); - TopoDS_Shape shape = BuilderCopy.Shape(); - builder.Add(comp, shape); } //it appears that an empty compound is !IsNull(), so we need to check a different way //if we added anything to the compound. if (!found) { - Base::Console().Error("SE::getSourceShapes - source shape is empty!\n"); + Base::Console().Error("SE::getShapes - source shape is empty!\n"); } else { result = comp; } +// BRepTools::Write(result, "SEresult.brep"); //debug return result; } @@ -293,6 +302,32 @@ TopoDS_Shape ShapeExtractor::getShapesFused(const std::vectorgetNameInDocument()); bool result = false; - Base::Type t = obj->getTypeId(); - if (t.isDerivedFrom(Part::Vertex::getClassTypeId())) { - result = true; - } else if (isDraftPoint(obj)) { - result = true; + if (obj) { + Base::Type t = obj->getTypeId(); + if (t.isDerivedFrom(Part::Vertex::getClassTypeId())) { + result = true; + } else if (isDraftPoint(obj)) { + result = true; + } } return result; } diff --git a/src/Mod/TechDraw/App/ShapeExtractor.h b/src/Mod/TechDraw/App/ShapeExtractor.h index 23e09717ae..e2c9462ac7 100644 --- a/src/Mod/TechDraw/App/ShapeExtractor.h +++ b/src/Mod/TechDraw/App/ShapeExtractor.h @@ -52,6 +52,8 @@ public: static Base::Vector3d getLocation3dFromFeat(App::DocumentObject* obj); static bool prefAdd2d(void); + static TopoDS_Shape stripInfiniteShapes(TopoDS_Shape inShape); + protected: private: From c01846c3e7a2a7e10794da934c20257f117ad739 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 29 Mar 2022 14:54:03 +0200 Subject: [PATCH 12/39] Base: fix handling of path separators in parameter group names --- src/Base/Parameter.cpp | 31 ++++++------- src/Base/ParameterPy.cpp | 38 +++++++++++----- src/Mod/Test/BaseTests.py | 91 ++++++++++++++++++++++----------------- 3 files changed, 96 insertions(+), 64 deletions(-) diff --git a/src/Base/Parameter.cpp b/src/Base/Parameter.cpp index c5e9eb9221..f2158a8ba8 100644 --- a/src/Base/Parameter.cpp +++ b/src/Base/Parameter.cpp @@ -312,33 +312,34 @@ void ParameterGrp::insert(const char* FileName) Base::Reference ParameterGrp::GetGroup(const char* Name) { std::string cName = Name; + if (cName.empty()) + throw Base::ValueError("Empty group name"); + + // Remove all leading slashes + std::string::size_type beg = cName.find_first_not_of('/'); + if (beg > 0) { + cName.erase(0, beg); + } + + // Remove all trailing slashes + std::string::size_type end = cName.find_last_not_of('/'); + if (end+1 < cName.size()) { + cName.erase(end+1); + } std::string::size_type pos = cName.find('/'); // is there a path separator ? if (pos == std::string::npos) { - return _GetGroup(Name); - } - else if (pos == cName.size()) { - // ending slash! cut it away - cName.erase(pos); return _GetGroup(cName.c_str()); } - else if (pos == 0) { - // a leading slash is not handled (root unknown) - //throw FCException("ParameterGrp::GetGroup() leading slash not allowed"); - // remove leading slash - cName.erase(0,1); - // subsequent call - return GetGroup(cName.c_str()); - } else { // path, split the first path std::string cTemp; // getting the first part - cTemp.assign(cName,0,pos); + cTemp.assign(cName, 0, pos); // removing the first part from the original - cName.erase(0,pos+1); + cName.erase(0, pos+1); //subsequent call return _GetGroup(cTemp.c_str())->GetGroup(cName.c_str()); } diff --git a/src/Base/ParameterPy.cpp b/src/Base/ParameterPy.cpp index e69b11d103..2664ce5cb5 100644 --- a/src/Base/ParameterPy.cpp +++ b/src/Base/ParameterPy.cpp @@ -98,6 +98,7 @@ public: Py::Object repr(); Py::Object getGroup(const Py::Tuple&); + Py::Object getGroupName(const Py::Tuple&); Py::Object getGroups(const Py::Tuple&); Py::Object remGroup(const Py::Tuple&); Py::Object hasGroup(const Py::Tuple&); @@ -159,6 +160,7 @@ void ParameterGrpPy::init_type() behaviors().readyType(); add_varargs_method("GetGroup",&ParameterGrpPy::getGroup,"GetGroup(str)"); + add_varargs_method("GetGroupName",&ParameterGrpPy::getGroupName,"GetGroupName()"); add_varargs_method("GetGroups",&ParameterGrpPy::getGroups,"GetGroups()"); add_varargs_method("RemGroup",&ParameterGrpPy::remGroup,"RemGroup(str)"); add_varargs_method("HasGroup",&ParameterGrpPy::hasGroup,"HasGroup(str)"); @@ -260,17 +262,33 @@ Py::Object ParameterGrpPy::getGroup(const Py::Tuple& args) if (!PyArg_ParseTuple(args.ptr(), "s", &pstr)) throw Py::Exception(); + try { + // get the Handle of the wanted group + Base::Reference handle = _cParamGrp->GetGroup(pstr); + if (handle.isValid()) { + // create a python wrapper class + ParameterGrpPy *pcParamGrp = new ParameterGrpPy(handle); + // increment the ref count + return Py::asObject(pcParamGrp); + } + else { + throw Py::RuntimeError("GetGroup failed"); + } + } + catch (const Base::Exception& e) { + e.setPyException(); + throw Py::Exception(); + } +} + +Py::Object ParameterGrpPy::getGroupName(const Py::Tuple& args) +{ + if (!PyArg_ParseTuple(args.ptr(), "")) + throw Py::Exception(); + // get the Handle of the wanted group - Base::Reference handle = _cParamGrp->GetGroup(pstr); - if (handle.isValid()) { - // create a python wrapper class - ParameterGrpPy *pcParamGrp = new ParameterGrpPy(handle); - // increment the ref count - return Py::asObject(pcParamGrp); - } - else { - throw Py::RuntimeError("GetGroup failed"); - } + std::string name = _cParamGrp->GetGroupName(); + return Py::String(name); } Py::Object ParameterGrpPy::getGroups(const Py::Tuple& args) diff --git a/src/Mod/Test/BaseTests.py b/src/Mod/Test/BaseTests.py index c7c0a0b460..b9f0a49d0a 100644 --- a/src/Mod/Test/BaseTests.py +++ b/src/Mod/Test/BaseTests.py @@ -115,6 +115,15 @@ class ParameterTestCase(unittest.TestCase): self.assertTrue(self.TestPar.HasGroup("44"),"A referenced group must not be deleted") Temp = 0 + def testGroupNames(self): + with self.assertRaises(ValueError): + # no empty groups allowed + self.TestPar.GetGroup("") + grp1 = self.TestPar.GetGroup("////Sub1/////Sub2/////") + grp2 = self.TestPar.GetGroup("Sub1/Sub2") + self.assertEqual(grp1.GetGroupName(), "Sub2") + self.assertEqual(grp2.GetGroupName(), "Sub2") + # check on special conditions def testInt(self): #FreeCAD.Console.PrintLog("Base::ParameterTestCase::testInt\n") @@ -156,6 +165,49 @@ class ParameterTestCase(unittest.TestCase): self.TestPar.RemString("44") self.assertEqual(self.TestPar.GetString("44","hallo"), "hallo","Deletion error at String") + def testNesting(self): + # Parameter testing + #FreeCAD.Console.PrintLog("Base::ParameterTestCase::testNesting\n") + for i in range(50): + self.TestPar.SetFloat(str(i),4711.4711) + self.TestPar.SetInt(str(i),4711) + self.TestPar.SetBool(str(i),1) + Temp = self.TestPar.GetGroup(str(i)) + for l in range(50): + Temp.SetFloat(str(l),4711.4711) + Temp.SetInt(str(l),4711) + Temp.SetBool(str(l),1) + Temp = 0 + + def testExportImport(self): + # Parameter testing + #FreeCAD.Console.PrintLog("Base::ParameterTestCase::testNesting\n") + self.TestPar.SetFloat("ExTest",4711.4711) + self.TestPar.SetInt("ExTest",4711) + self.TestPar.SetString("ExTest","4711") + self.TestPar.SetBool("ExTest",1) + Temp = self.TestPar.GetGroup("ExTest") + Temp.SetFloat("ExTest",4711.4711) + Temp.SetInt("ExTest",4711) + Temp.SetString("ExTest","4711") + Temp.SetBool("ExTest",1) + TempPath = tempfile.gettempdir() + os.sep + "ExportTest.FCExport" + + self.TestPar.Export(TempPath) + Temp = self.TestPar.GetGroup("ImportTest") + Temp.Import(TempPath) + self.assertEqual(Temp.GetFloat("ExTest"), 4711.4711,"ExportImport error") + Temp = 0 + + def tearDown(self): + #remove all + TestPar = FreeCAD.ParamGet("System parameter:Test") + TestPar.Clear() + +class AlgebraTestCase(unittest.TestCase): + def setUp(self): + pass + def testAngle(self): v1 = FreeCAD.Vector(0,0,0.000001) v2 = FreeCAD.Vector(0,0.000001,0) @@ -313,45 +365,6 @@ class ParameterTestCase(unittest.TestCase): self.assertFalse(b.intersected(FreeCAD.BoundBox(4,4,4,6,6,6)).isValid(),"Bbox should not intersect with Bbox outside") self.assertEqual(b.intersected(FreeCAD.BoundBox(-2,-2,-2,2,2,2)).Center, b.Center,"Bbox is not a full subset") - def testNesting(self): - # Parameter testing - #FreeCAD.Console.PrintLog("Base::ParameterTestCase::testNesting\n") - for i in range(50): - self.TestPar.SetFloat(str(i),4711.4711) - self.TestPar.SetInt(str(i),4711) - self.TestPar.SetBool(str(i),1) - Temp = self.TestPar.GetGroup(str(i)) - for l in range(50): - Temp.SetFloat(str(l),4711.4711) - Temp.SetInt(str(l),4711) - Temp.SetBool(str(l),1) - Temp = 0 - - def testExportImport(self): - # Parameter testing - #FreeCAD.Console.PrintLog("Base::ParameterTestCase::testNesting\n") - self.TestPar.SetFloat("ExTest",4711.4711) - self.TestPar.SetInt("ExTest",4711) - self.TestPar.SetString("ExTest","4711") - self.TestPar.SetBool("ExTest",1) - Temp = self.TestPar.GetGroup("ExTest") - Temp.SetFloat("ExTest",4711.4711) - Temp.SetInt("ExTest",4711) - Temp.SetString("ExTest","4711") - Temp.SetBool("ExTest",1) - TempPath = tempfile.gettempdir() + os.sep + "ExportTest.FCExport" - - self.TestPar.Export(TempPath) - Temp = self.TestPar.GetGroup("ImportTest") - Temp.Import(TempPath) - self.assertEqual(Temp.GetFloat("ExTest"), 4711.4711,"ExportImport error") - Temp = 0 - - def tearDown(self): - #remove all - TestPar = FreeCAD.ParamGet("System parameter:Test") - TestPar.Clear() - class MatrixTestCase(unittest.TestCase): def setUp(self): self.mat = FreeCAD.Matrix() From 8c35e7776cc782402a28086d7d2c7c18e282ae72 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 29 Mar 2022 15:25:54 +0200 Subject: [PATCH 13/39] Base: [skip ci] optimize iteration over container with parameter group elements --- src/Base/ParameterPy.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Base/ParameterPy.cpp b/src/Base/ParameterPy.cpp index 2664ce5cb5..de7f17c2a1 100644 --- a/src/Base/ParameterPy.cpp +++ b/src/Base/ParameterPy.cpp @@ -299,7 +299,7 @@ Py::Object ParameterGrpPy::getGroups(const Py::Tuple& args) // get the Handle of the wanted group std::vector > handle = _cParamGrp->GetGroups(); Py::List list; - for (auto it : handle) { + for (const auto& it : handle) { list.append(Py::String(it->GetGroupName())); } @@ -335,7 +335,7 @@ Py::Object ParameterGrpPy::getBools(const Py::Tuple& args) std::vector > map = _cParamGrp->GetBoolMap(filter); Py::List list; - for (auto it : map) { + for (const auto& it : map) { list.append(Py::String(it.first)); } @@ -370,7 +370,7 @@ Py::Object ParameterGrpPy::getInts(const Py::Tuple& args) std::vector > map = _cParamGrp->GetIntMap(filter); Py::List list; - for (auto it : map) { + for (const auto& it : map) { list.append(Py::String(it.first)); } @@ -405,7 +405,7 @@ Py::Object ParameterGrpPy::getUnsigneds(const Py::Tuple& args) std::vector > map = _cParamGrp->GetUnsignedMap(filter); Py::List list; - for (auto it : map) { + for (const auto& it : map) { list.append(Py::String(it.first)); } @@ -441,7 +441,7 @@ Py::Object ParameterGrpPy::getFloats(const Py::Tuple& args) std::vector > map = _cParamGrp->GetFloatMap(filter); Py::List list; - for (auto it : map) { + for (const auto& it : map) { list.append(Py::String(it.first)); } @@ -477,7 +477,7 @@ Py::Object ParameterGrpPy::getStrings(const Py::Tuple& args) std::vector > map = _cParamGrp->GetASCIIMap(filter); Py::List list; - for (auto it : map) { + for (const auto& it : map) { list.append(Py::String(it.first)); } From f7edc74eeef50d58d88d9a74addf31e1f27d4aa5 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 12:33:37 -0500 Subject: [PATCH 14/39] App: PR6497 move return statement to new line --- src/App/AutoTransaction.cpp | 3 ++- src/App/ComplexGeoData.cpp | 15 ++++++++++----- src/App/Document.cpp | 3 ++- src/App/DocumentObject.cpp | 12 ++++++++---- src/App/DocumentPyImp.cpp | 3 ++- src/App/Expression.cpp | 3 ++- src/App/ExtensionContainer.cpp | 6 ++++-- src/App/GeoFeature.cpp | 3 ++- src/App/Link.cpp | 24 ++++++++++++++++-------- src/App/ObjectIdentifier.cpp | 9 ++++++--- src/App/PropertyContainer.cpp | 15 ++++++++++----- src/App/PropertyLinks.cpp | 12 ++++++++---- src/App/PropertyStandard.cpp | 3 ++- src/App/Transactions.cpp | 3 ++- 14 files changed, 76 insertions(+), 38 deletions(-) diff --git a/src/App/AutoTransaction.cpp b/src/App/AutoTransaction.cpp index 5803ebcb87..6597f7109c 100644 --- a/src/App/AutoTransaction.cpp +++ b/src/App/AutoTransaction.cpp @@ -160,7 +160,8 @@ const char *Application::getActiveTransaction(int *id) const { void Application::closeActiveTransaction(bool abort, int id) { if(!id) id = _activeTransactionID; - if(!id) return; + if(!id) + return; if(_activeTransactionGuard>0 && !abort) { FC_LOG("ignore close transaction"); diff --git a/src/App/ComplexGeoData.cpp b/src/App/ComplexGeoData.cpp index adab0b8a0a..c3a88688cd 100644 --- a/src/App/ComplexGeoData.cpp +++ b/src/App/ComplexGeoData.cpp @@ -172,9 +172,11 @@ const char *ComplexGeoData::isMappedElement(const char *name) { } std::string ComplexGeoData::newElementName(const char *name) { - if(!name) return std::string(); + if(!name) + return std::string(); const char *dot = strrchr(name,'.'); - if(!dot || dot==name) return name; + if(!dot || dot==name) + return name; const char *c = dot-1; for(;c!=name;--c) { if(*c == '.') { @@ -188,9 +190,11 @@ std::string ComplexGeoData::newElementName(const char *name) { } std::string ComplexGeoData::oldElementName(const char *name) { - if(!name) return std::string(); + if(!name) + return std::string(); const char *dot = strrchr(name,'.'); - if(!dot || dot==name) return name; + if(!dot || dot==name) + return name; const char *c = dot-1; for(;c!=name;--c) { if(*c == '.') { @@ -204,7 +208,8 @@ std::string ComplexGeoData::oldElementName(const char *name) { } std::string ComplexGeoData::noElementName(const char *name) { - if(!name) return std::string(); + if(!name) + return std::string(); auto element = findElementName(name); if(element) return std::string(name,element-name); diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 991a6fe34b..3fa9a00395 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -1170,7 +1170,8 @@ void Document::_checkTransaction(DocumentObject* pcDelObj, const Property *What, return; } } - if(!pcDelObj) return; + if(!pcDelObj) + return; // When the object is going to be deleted we have to check if it has already been added to // the undo transactions std::list::iterator it; diff --git a/src/App/DocumentObject.cpp b/src/App/DocumentObject.cpp index 5beefe7c3f..fa0c215981 100644 --- a/src/App/DocumentObject.cpp +++ b/src/App/DocumentObject.cpp @@ -275,7 +275,8 @@ const char *DocumentObject::getNameInDocument() const // to an object that has been removed from the document. In this case we should rather // return 0. //assert(pcNameInDocument); - if (!pcNameInDocument) return nullptr; + if (!pcNameInDocument) + return nullptr; return pcNameInDocument->c_str(); } @@ -1055,7 +1056,8 @@ void App::DocumentObject::_addBackLink(DocumentObject* newObj) int DocumentObject::setElementVisible(const char *element, bool visible) { for(auto ext : getExtensionsDerivedFromType()) { int ret = ext->extensionSetElementVisible(element,visible); - if(ret>=0) return ret; + if(ret>=0) + return ret; } return -1; @@ -1064,7 +1066,8 @@ int DocumentObject::setElementVisible(const char *element, bool visible) { int DocumentObject::isElementVisible(const char *element) const { for(auto ext : getExtensionsDerivedFromType()) { int ret = ext->extensionIsElementVisible(element); - if(ret>=0) return ret; + if(ret>=0) + return ret; } return -1; @@ -1256,7 +1259,8 @@ const std::string &DocumentObject::hiddenMarker() { } const char *DocumentObject::hasHiddenMarker(const char *subname) { - if(!subname) return nullptr; + if(!subname) + return nullptr; const char *marker = strrchr(subname,'.'); if(!marker) marker = subname; diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp index ec02a6b4b6..236bdaeb7f 100644 --- a/src/App/DocumentPyImp.cpp +++ b/src/App/DocumentPyImp.cpp @@ -835,7 +835,8 @@ int DocumentPy::setCustomAttributes(const char* attr, PyObject *) return 0; } PyObject* item = PyDict_GetItemString(this->ob_type->tp_dict, attr); - if (item) return 0; + if (item) + return 0; DocumentObject* obj = getDocumentPtr()->getObject(attr); if (obj) { diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp index 54836181e1..ec918dcd58 100644 --- a/src/App/Expression.cpp +++ b/src/App/Expression.cpp @@ -3158,7 +3158,8 @@ double num_change(char* yytext,char dez_delim,char grp_delim) else temp[i++] = *c; // check buffer overflow - if (i>39) return 0.0; + if (i>39) + return 0.0; } temp[i] = '\0'; diff --git a/src/App/ExtensionContainer.cpp b/src/App/ExtensionContainer.cpp index db26f4b359..0c3d9022a9 100644 --- a/src/App/ExtensionContainer.cpp +++ b/src/App/ExtensionContainer.cpp @@ -102,7 +102,8 @@ Extension* ExtensionContainer::getExtension(Base::Type t, bool derived, bool no_ if(entry.first.isDerivedFrom(t)) return entry.second; } - if(no_except) return nullptr; + if(no_except) + return nullptr; //if we arrive here we don't have anything matching throw Base::TypeError("ExtensionContainer::getExtension: No extension of given type available"); } @@ -110,7 +111,8 @@ Extension* ExtensionContainer::getExtension(Base::Type t, bool derived, bool no_ return result->second; } else { - if(no_except) return nullptr; + if(no_except) + return nullptr; //if we arrive here we don't have anything matching throw Base::TypeError("ExtensionContainer::getExtension: No extension of given type available"); } diff --git a/src/App/GeoFeature.cpp b/src/App/GeoFeature.cpp index 51a46511ab..0015d545d0 100644 --- a/src/App/GeoFeature.cpp +++ b/src/App/GeoFeature.cpp @@ -87,7 +87,8 @@ std::pair GeoFeature::getElementName( (void)type; std::pair ret; - if(!name) return ret; + if(!name) + return ret; ret.second = name; return ret; diff --git a/src/App/Link.cpp b/src/App/Link.cpp index c1cdf5e97c..1532a49014 100644 --- a/src/App/Link.cpp +++ b/src/App/Link.cpp @@ -399,7 +399,8 @@ App::DocumentObjectExecReturn *LinkBaseExtension::extensionExecute(void) { short LinkBaseExtension::extensionMustExecute(void) { auto link = getLink(); - if(!link) return 0; + if(!link) + return 0; return link->mustExecute(); } @@ -982,7 +983,8 @@ int LinkBaseExtension::extensionSetElementVisible(const char *element, bool visi if(!propElementVis || !element || !element[0]) return -1; if(propElementVis->getSize()<=index) { - if(visible) return 1; + if(visible) + return 1; propElementVis->setSize(index+1, true); } propElementVis->setStatus(Property::User3,true); @@ -1047,10 +1049,12 @@ int LinkBaseExtension::getArrayIndex(const char *subname, const char **psubname) return -1; const char *dot = strchr(subname,'.'); if(!dot) dot= subname+strlen(subname); - if(dot == subname) return -1; + if(dot == subname) + return -1; int idx = 0; for(const char *c=subname;c!=dot;++c) { - if(!isdigit(*c)) return -1; + if(!isdigit(*c)) + return -1; idx = idx*10 + *c -'0'; } if(psubname) { @@ -1072,7 +1076,8 @@ int LinkBaseExtension::getElementIndex(const char *subname, const char **psubnam if(isdigit(subname[0])) { // If the name start with digits, treat as index reference idx = getArrayIndex(subname,nullptr); - if(idx<0) return -1; + if(idx<0) + return -1; if(_getElementCountProperty()) { if(idx>=_getElementCountValue()) return -1; @@ -1103,7 +1108,8 @@ int LinkBaseExtension::getElementIndex(const char *subname, const char **psubnam // Then check for the actual linked object's name or label, and // redirect that reference to the first array element auto linked = getTrueLinkedObject(false); - if(!linked || !linked->getNameInDocument()) return -1; + if(!linked || !linked->getNameInDocument()) + return -1; if(subname[0]=='$') { CharRange sub(subname+1, dot); if (boost::equals(sub, linked->Label.getValue())) @@ -1424,7 +1430,8 @@ DocumentObject *LinkBaseExtension::getTrueLinkedObject( } auto ret = getLink(depth); - if(!ret) return nullptr; + if(!ret) + return nullptr; bool transform = linkTransform(); const char *subname = getSubName(); if(subname || (mat && transform)) { @@ -1557,7 +1564,8 @@ void LinkBaseExtension::updateGroup() { } void LinkBaseExtension::update(App::DocumentObject *parent, const Property *prop) { - if(!prop) return; + if(!prop) + return; if(prop == getLinkPlacementProperty() || prop == getPlacementProperty()) { auto src = getLinkPlacementProperty(); diff --git a/src/App/ObjectIdentifier.cpp b/src/App/ObjectIdentifier.cpp index ac3ac9a5b4..3d1c2589a9 100644 --- a/src/App/ObjectIdentifier.cpp +++ b/src/App/ObjectIdentifier.cpp @@ -297,11 +297,13 @@ int ObjectIdentifier::numSubComponents() const bool ObjectIdentifier::verify(const App::Property &prop, bool silent) const { ResolveResults result(*this); if(components.size() - result.propertyIndex != 1) { - if(silent) return false; + if(silent) + return false; FC_THROWM(Base::ValueError,"Invalid property path: single component expected"); } if(!components[result.propertyIndex].isSimple()) { - if(silent) return false; + if(silent) + return false; FC_THROWM(Base::ValueError,"Invalid property path: simple component expected"); } const std::string &name = components[result.propertyIndex].getName(); @@ -310,7 +312,8 @@ bool ObjectIdentifier::verify(const App::Property &prop, bool silent) const { if((isAddress && addr.toString(CellAddress::Cell::ShowRowColumn) != prop.getName()) || (!isAddress && name!=prop.getName())) { - if(silent) return false; + if(silent) + return false; FC_THROWM(Base::ValueError,"Invalid property path: name mismatch"); } return true; diff --git a/src/App/PropertyContainer.cpp b/src/App/PropertyContainer.cpp index 8faea17b58..e66628eae9 100644 --- a/src/App/PropertyContainer.cpp +++ b/src/App/PropertyContainer.cpp @@ -77,7 +77,8 @@ App::Property* PropertyContainer::addDynamicProperty( Property *PropertyContainer::getPropertyByName(const char* name) const { auto prop = dynamicProps.getDynamicPropertyByName(name); - if(prop) return prop; + if(prop) + return prop; return getPropertyData().getPropertyByName(this,name); } @@ -120,28 +121,32 @@ short PropertyContainer::getPropertyType(const char *name) const const char* PropertyContainer::getPropertyGroup(const Property* prop) const { auto group = dynamicProps.getPropertyGroup(prop); - if(group) return group; + if(group) + return group; return getPropertyData().getGroup(this,prop); } const char* PropertyContainer::getPropertyGroup(const char *name) const { auto group = dynamicProps.getPropertyGroup(name); - if(group) return group; + if(group) + return group; return getPropertyData().getGroup(this,name); } const char* PropertyContainer::getPropertyDocumentation(const Property* prop) const { auto doc = dynamicProps.getPropertyDocumentation(prop); - if(doc) return doc; + if(doc) + return doc; return getPropertyData().getDocumentation(this,prop); } const char* PropertyContainer::getPropertyDocumentation(const char *name) const { auto doc = dynamicProps.getPropertyDocumentation(name); - if(doc) return doc; + if(doc) + return doc; return getPropertyData().getDocumentation(this,name); } diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index b42f5b416a..7e899b9a2b 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -649,7 +649,8 @@ void PropertyLinkList::set1Value(int idx, DocumentObject* const &value) { DocumentObject *obj = nullptr; if(idx>=0 && idx<(int)_lValueList.size()) { obj = _lValueList[idx]; - if(obj == value) return; + if(obj == value) + return; } if(!value || !value->getNameInDocument()) @@ -2806,7 +2807,8 @@ public: } void slotFinishRestoreDocument(const App::Document &doc) { - if(pcDoc) return; + if(pcDoc) + return; QString fullpath(getFullPath()); if(!fullpath.isEmpty() && getFullPath(doc.getFileName())==fullpath) attach(const_cast(&doc)); @@ -2817,7 +2819,8 @@ public: slotFinishRestoreDocument(doc); return; } - if(&doc!=pcDoc) return; + if(&doc!=pcDoc) + return; QFileInfo info(myPos->first); // QString path(info.canonicalFilePath()); @@ -2879,7 +2882,8 @@ public: deinit(); return; } - if(pcDoc!=&doc) return; + if(pcDoc!=&doc) + return; std::map > parentLinks; for(auto link : links) { link->setFlag(PropertyLinkBase::LinkDetached); diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index 0fc1cf9821..abfc5d443c 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -1374,7 +1374,8 @@ PropertyString::~PropertyString() void PropertyString::setValue(const char* newLabel) { - if(!newLabel) return; + if(!newLabel) + return; if(_cValue == newLabel) return; diff --git a/src/App/Transactions.cpp b/src/App/Transactions.cpp index 297942a79a..a345e375d2 100644 --- a/src/App/Transactions.cpp +++ b/src/App/Transactions.cpp @@ -99,7 +99,8 @@ static std::atomic _TransactionID; int Transaction::getNewID() { int id = ++_TransactionID; - if(id) return id; + if(id) + return id; // wrap around? really? return ++_TransactionID; } From 5df3dbae6f367c8c92b31adbcc522acc848ef256 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 12:33:50 -0500 Subject: [PATCH 15/39] Gui: PR6497 move return statement to new line --- src/Gui/3Dconnexion/GuiNativeEventWin32.cpp | 15 ++-- src/Gui/Application.cpp | 3 +- src/Gui/BlenderNavigationStyle.cpp | 4 +- src/Gui/CADNavigationStyle.cpp | 4 +- src/Gui/CallTips.cpp | 6 +- src/Gui/Command.cpp | 9 ++- src/Gui/CommandDoc.cpp | 3 +- src/Gui/CommandLink.cpp | 3 +- src/Gui/CommandTest.cpp | 15 ++-- src/Gui/CommandView.cpp | 9 ++- src/Gui/DAGView/DAGView.cpp | 3 +- src/Gui/DemoMode.cpp | 6 +- src/Gui/DlgDisplayPropertiesImp.cpp | 3 +- src/Gui/DlgObjectSelection.cpp | 3 +- src/Gui/DlgPropertyLink.cpp | 3 +- src/Gui/DockWindowManager.cpp | 3 +- src/Gui/Document.cpp | 3 +- src/Gui/EditorView.cpp | 9 ++- src/Gui/GestureNavigationStyle.cpp | 7 +- src/Gui/Inventor/SmSwitchboard.cpp | 3 +- src/Gui/InventorNavigationStyle.cpp | 4 +- src/Gui/LinkViewPyImp.cpp | 3 +- src/Gui/MainWindow.cpp | 3 +- src/Gui/ManualAlignment.cpp | 3 +- src/Gui/MayaGestureNavigationStyle.cpp | 4 +- src/Gui/NavigationStyle.cpp | 53 +++++++++----- src/Gui/OpenCascadeNavigationStyle.cpp | 4 +- src/Gui/OpenSCADNavigationStyle.cpp | 4 +- src/Gui/Placement.cpp | 6 +- src/Gui/PythonDebugger.cpp | 3 +- src/Gui/QSint/actionpanel/actionbox.cpp | 3 +- src/Gui/Quarter/DragDropHandler.cpp | 16 ++-- src/Gui/RevitNavigationStyle.cpp | 4 +- src/Gui/Selection.cpp | 24 ++++-- src/Gui/SelectionView.cpp | 12 ++- src/Gui/SoFCOffscreenRenderer.cpp | 4 +- src/Gui/SoFCSelection.cpp | 12 ++- src/Gui/SoFCUnifiedSelection.cpp | 27 ++++--- src/Gui/SoFCVectorizeSVGAction.cpp | 3 +- src/Gui/SoFCVectorizeU3DAction.cpp | 3 +- src/Gui/SoTextLabel.cpp | 3 +- src/Gui/TaskElementColors.cpp | 3 +- src/Gui/TaskView/TaskAppearance.cpp | 3 +- src/Gui/TinkerCADNavigationStyle.cpp | 4 +- src/Gui/TouchpadNavigationStyle.cpp | 4 +- src/Gui/Tree.cpp | 21 ++++-- src/Gui/TreeView.cpp | 3 +- src/Gui/UiLoader.cpp | 3 +- src/Gui/View3DInventor.cpp | 3 +- src/Gui/View3DInventorExamples.cpp | 9 ++- src/Gui/View3DInventorViewer.cpp | 42 +++++++---- src/Gui/View3DPy.cpp | 6 +- src/Gui/ViewProvider.cpp | 3 +- src/Gui/ViewProviderDocumentObject.cpp | 18 +++-- src/Gui/ViewProviderInventorObject.cpp | 3 +- src/Gui/ViewProviderLink.cpp | 81 ++++++++++++++------- src/Gui/ViewProviderPythonFeature.cpp | 3 +- 57 files changed, 352 insertions(+), 169 deletions(-) diff --git a/src/Gui/3Dconnexion/GuiNativeEventWin32.cpp b/src/Gui/3Dconnexion/GuiNativeEventWin32.cpp index 24726546be..02012ec989 100644 --- a/src/Gui/3Dconnexion/GuiNativeEventWin32.cpp +++ b/src/Gui/3Dconnexion/GuiNativeEventWin32.cpp @@ -327,7 +327,8 @@ unsigned short HidToVirtualKey(unsigned long pid, unsigned short hidKeyCode) bool Gui::GuiNativeEvent::RawInputEventFilter(void* msg, long* result) { - if (gMouseInput == 0) return false; + if (gMouseInput == 0) + return false; MSG* message = (MSG*)(msg); @@ -438,7 +439,8 @@ bool Gui::GuiNativeEvent::Is3dmouseAttached() return false; } - if (nDevices == 0) return false; + if (nDevices == 0) + return false; std::vector rawInputDeviceList(nDevices); if (::GetRawInputDeviceList(&rawInputDeviceList[0], &nDevices, sizeof(RAWINPUTDEVICELIST)) == static_cast(-1)) { @@ -479,12 +481,14 @@ bool Gui::GuiNativeEvent::InitializeRawInput(HWND hwndTarget) fWindow = hwndTarget; // Simply fail if there is no window - if (!hwndTarget) return false; + if (!hwndTarget) + return false; unsigned int numDevices = 0; PRAWINPUTDEVICE devicesToRegister = GetDevicesToRegister(&numDevices); - if (numDevices == 0) return false; + if (numDevices == 0) + return false; // Get OS version. OSVERSIONINFO osvi = {sizeof(OSVERSIONINFO),0}; @@ -753,7 +757,8 @@ bool Gui::GuiNativeEvent::TranslateRawInputData(UINT nInputCode, PRAWINPUT pRawI qDebug("Rawinput.header.dwType=0x%x\n", pRawInput->header.dwType); #endif // We are not interested in keyboard or mouse data received via raw input - if (pRawInput->header.dwType != RIM_TYPEHID) return false; + if (pRawInput->header.dwType != RIM_TYPEHID) + return false; #if _TRACE_RIDI_DEVICENAME UINT dwSize=0; diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 2fb742be05..dbfe69dc90 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -2438,7 +2438,8 @@ void Application::checkForPreviousCrashes() } App::Document *Application::reopen(App::Document *doc) { - if(!doc) return nullptr; + if(!doc) + return nullptr; std::string name = doc->FileName.getValue(); std::set untouchedDocs; for(auto &v : d->documents) { diff --git a/src/Gui/BlenderNavigationStyle.cpp b/src/Gui/BlenderNavigationStyle.cpp index 6a5ef070b6..ccccc0d008 100644 --- a/src/Gui/BlenderNavigationStyle.cpp +++ b/src/Gui/BlenderNavigationStyle.cpp @@ -68,7 +68,9 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev) // Events when in "ready-to-seek" mode are ignored, except those // which influence the seek mode itself -- these are handled further // up the inheritance hierarchy. - if (this->isSeekMode()) { return inherited::processSoEvent(ev); } + if (this->isSeekMode()) { + return inherited::processSoEvent(ev); + } // Switch off viewing mode (Bug #0000911) if (!this->isSeekMode() && !this->isAnimating() && this->isViewing()) this->setViewing(false); // by default disable viewing mode to render the scene diff --git a/src/Gui/CADNavigationStyle.cpp b/src/Gui/CADNavigationStyle.cpp index 04c24d4886..7cd4002ced 100644 --- a/src/Gui/CADNavigationStyle.cpp +++ b/src/Gui/CADNavigationStyle.cpp @@ -69,7 +69,9 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev) // Events when in "ready-to-seek" mode are ignored, except those // which influence the seek mode itself -- these are handled further // up the inheritance hierarchy. - if (this->isSeekMode()) { return inherited::processSoEvent(ev); } + if (this->isSeekMode()) { + return inherited::processSoEvent(ev); + } #else // Switch off viewing mode (Bug #0000911) if (!this->isSeekMode() && !this->isAnimating() && this->isViewing()) diff --git a/src/Gui/CallTips.cpp b/src/Gui/CallTips.cpp index 8e97cdf9c1..24fa27a0ab 100644 --- a/src/Gui/CallTips.cpp +++ b/src/Gui/CallTips.cpp @@ -443,7 +443,8 @@ void CallTipsList::extractTipsFromProperties(Py::Object& obj, QMapgetPropertyContainerPtr(); // Make sure that the C++ object is alive - if (!container) return; + if (!container) + return; std::map Map; container->getPropertyMap(Map); @@ -689,7 +690,8 @@ bool CallTipsList::eventFilter(QObject * watched, QEvent * event) void CallTipsList::callTipItemActivated(QListWidgetItem *item) { hide(); - if (!item->isSelected()) return; + if (!item->isSelected()) + return; QString text = item->text(); QTextCursor cursor = textEdit->textCursor(); diff --git a/src/Gui/Command.cpp b/src/Gui/Command.cpp index da8be223ed..720bcedbed 100644 --- a/src/Gui/Command.cpp +++ b/src/Gui/Command.cpp @@ -228,9 +228,11 @@ Command::~Command() bool Command::isViewOfType(Base::Type t) const { Gui::Document *d = getGuiApplication()->activeDocument(); - if (!d) return false; + if (!d) + return false; Gui::BaseView *v = d->getActiveView(); - if (!v) return false; + if (!v) + return false; if (v->getTypeId().isDerivedFrom(t)) return true; else @@ -938,7 +940,8 @@ void Command::adjustCameraPosition() SoGetBoundingBoxAction action(viewer->getSoRenderManager()->getViewportRegion()); action.apply(viewer->getSceneGraph()); SbBox3f box = action.getBoundingBox(); - if (box.isEmpty()) return; + if (box.isEmpty()) + return; // get cirumscribing sphere and check if camera is inside SbVec3f cam_pos = camera->position.getValue(); diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index 3df3e6ed0d..cc2a256d81 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -1158,7 +1158,8 @@ bool StdCmdPaste::isActive(void) return true; QClipboard* cb = QApplication::clipboard(); const QMimeData* mime = cb->mimeData(); - if (!mime) return false; + if (!mime) + return false; return getMainWindow()->canInsertFromMimeData(mime); } diff --git a/src/Gui/CommandLink.cpp b/src/Gui/CommandLink.cpp index 43b7bbe676..34fb044168 100644 --- a/src/Gui/CommandLink.cpp +++ b/src/Gui/CommandLink.cpp @@ -468,7 +468,8 @@ static bool linkConvertible(bool unlink) { int count = 0; for(auto &sel : TreeWidget::getSelection()) { auto parent = sel.parentVp; - if(!parent) return false; + if(!parent) + return false; auto obj = sel.vp->getObject(); if(unlink) { auto linked = obj->getLinkedObject(false); diff --git a/src/Gui/CommandTest.cpp b/src/Gui/CommandTest.cpp index 74a46bf651..c1f4f9ab12 100644 --- a/src/Gui/CommandTest.cpp +++ b/src/Gui/CommandTest.cpp @@ -185,7 +185,8 @@ void FCCmdTest3::activated(int iMsg) { Q_UNUSED(iMsg); App::Document *pcDoc = getDocument(); - if (!pcDoc) return; + if (!pcDoc) + return; } @@ -215,7 +216,8 @@ void FCCmdTest4::activated(int iMsg) { Q_UNUSED(iMsg); App::Document *pcDoc = getDocument(); - if(!pcDoc) return; + if(!pcDoc) + return; } @@ -244,7 +246,8 @@ void FCCmdTest5::activated(int iMsg) { Q_UNUSED(iMsg); App::Document *pcDoc = getDocument(); - if(!pcDoc) return; + if(!pcDoc) + return; } bool FCCmdTest5::isActive(void) @@ -273,7 +276,8 @@ void FCCmdTest6::activated(int iMsg) { Q_UNUSED(iMsg); App::Document *pcDoc = getDocument(); - if(!pcDoc) return; + if(!pcDoc) + return; } bool FCCmdTest6::isActive(void) @@ -301,7 +305,8 @@ void CmdTestCmdFuncs::activated(int iMsg) Q_UNUSED(iMsg); App::Document *doc = getDocument(); auto obj = doc->addObject("App::Annotation", "obj"); - if (!obj) return; + if (!obj) + return; std::string objName = obj->getNameInDocument(); diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index fd33ea0749..59114f5828 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -458,7 +458,8 @@ void StdCmdFreezeViews::onRestoreViews() bool ok; int scheme = root.attribute(QString::fromLatin1("SchemaVersion")).toInt(&ok); - if (!ok) return; + if (!ok) + return; // SchemeVersion "1" if (scheme == 1) { // read the views, ignore the attribute 'Count' @@ -1693,7 +1694,8 @@ void StdViewDockUndockFullscreen::activated(int iMsg) getMainWindow()->showNormal(); MDIView* view = getMainWindow()->activeWindow(); - if (!view) return; // no active view + if (!view) // no active view + return; // nothing to do when the view is docked and 'Docked' is pressed if (iMsg == 0 && view->currentViewMode() == MDIView::Child) @@ -2167,7 +2169,8 @@ bool StdCmdAxisCross::isActive(void) if (_pcAction->isChecked()) _pcAction->setChecked(false); } - if (view ) return true; + if (view ) + return true; return false; } diff --git a/src/Gui/DAGView/DAGView.cpp b/src/Gui/DAGView/DAGView.cpp index b8859dfac9..a9e99c532f 100644 --- a/src/Gui/DAGView/DAGView.cpp +++ b/src/Gui/DAGView/DAGView.cpp @@ -114,7 +114,8 @@ void View::onSelectionChanged(const SelectionChanges& msg) return; } auto doc = Gui::Application::Instance->getDocument(msg.pDocName); - if (!doc) return; + if (!doc) + return; auto &model = modelMap[doc]; if(!model) model = std::make_shared(this, *doc); diff --git a/src/Gui/DemoMode.cpp b/src/Gui/DemoMode.cpp index 55f81a8a62..73beef6d03 100644 --- a/src/Gui/DemoMode.cpp +++ b/src/Gui/DemoMode.cpp @@ -140,7 +140,8 @@ float DemoMode::getSpeed(int v) const SbVec3f DemoMode::getDirection(Gui::View3DInventor* view) const { SoCamera* cam = view->getViewer()->getSoRenderManager()->getCamera(); - if (!cam) return this->viewAxis; + if (!cam) + return this->viewAxis; SbRotation rot = cam->orientation.getValue(); SbRotation inv = rot.inverse(); SbVec3f vec(this->viewAxis); @@ -156,7 +157,8 @@ void DemoMode::on_angleSlider_valueChanged(int v) Gui::View3DInventor* view = activeView(); if (view) { SoCamera* cam = view->getViewer()->getSoRenderManager()->getCamera(); - if (!cam) return; + if (!cam) + return; float angle = Base::toRadians(/*90-v*/v - this->oldvalue); SbRotation rot(SbVec3f(-1, 0, 0), angle); reorientCamera(cam ,rot); diff --git a/src/Gui/DlgDisplayPropertiesImp.cpp b/src/Gui/DlgDisplayPropertiesImp.cpp index 75cec6e3e7..2af0df35dc 100644 --- a/src/Gui/DlgDisplayPropertiesImp.cpp +++ b/src/Gui/DlgDisplayPropertiesImp.cpp @@ -399,7 +399,8 @@ void DlgDisplayPropertiesImp::setDisplayModes(const std::vectorgetPropertyByName("DisplayMode"); if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) { App::PropertyEnumeration* display = static_cast(prop); - if (!display->getEnums()) return; + if (!display->getEnums()) + return; const std::vector& value = display->getEnumVector(); if (it == views.begin()) { for (std::vector::const_iterator jt = value.begin(); jt != value.end(); ++jt) diff --git a/src/Gui/DlgObjectSelection.cpp b/src/Gui/DlgObjectSelection.cpp index 375f324deb..e6de8139d5 100644 --- a/src/Gui/DlgObjectSelection.cpp +++ b/src/Gui/DlgObjectSelection.cpp @@ -343,7 +343,8 @@ std::vector DlgObjectSelection::getSelections(SelectionOpt } void DlgObjectSelection::onDepItemChanged(QTreeWidgetItem * depItem, int column) { - if(column) return; + if(column) + return; QSignalBlocker blocker(ui->depList); QSignalBlocker blocker2(ui->inList); QSignalBlocker blocker3(ui->treeWidget); diff --git a/src/Gui/DlgPropertyLink.cpp b/src/Gui/DlgPropertyLink.cpp index b6a16e14b0..8036235892 100644 --- a/src/Gui/DlgPropertyLink.cpp +++ b/src/Gui/DlgPropertyLink.cpp @@ -1023,7 +1023,8 @@ void DlgPropertyLink::onItemExpanded(QTreeWidgetItem * item) { } } else if(allowSubObject) { auto obj = doc->getObject(objName); - if(!obj) return; + if(!obj) + return; std::set childSet; std::string sub; for(auto child : obj->getLinkedObject(true)->getOutList()) { diff --git a/src/Gui/DockWindowManager.cpp b/src/Gui/DockWindowManager.cpp index 5e40d7b5cc..8480c9015a 100644 --- a/src/Gui/DockWindowManager.cpp +++ b/src/Gui/DockWindowManager.cpp @@ -256,7 +256,8 @@ void DockWindowManager::activate(QWidget* widget) par = par->parentWidget(); } - if (!dw) return; + if (!dw) + return; if (!dw->toggleViewAction()->isChecked()) { dw->toggleViewAction()->activate(QAction::Trigger); diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 4c08af803e..6cbb1e82ac 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -737,7 +737,8 @@ void Document::slotDeletedObject(const App::DocumentObject& Obj) // cycling to all views of the document ViewProvider* viewProvider = getViewProvider(&Obj); - if(!viewProvider) return; + if(!viewProvider) + return; if (d->_editViewProvider==viewProvider || d->_editViewProviderParent==viewProvider) _resetEdit(); diff --git a/src/Gui/EditorView.cpp b/src/Gui/EditorView.cpp index c805fbbaf2..32ff54967f 100644 --- a/src/Gui/EditorView.cpp +++ b/src/Gui/EditorView.cpp @@ -623,9 +623,12 @@ bool PythonEditorView::onMsg(const char* pMsg,const char** ppReturn) */ bool PythonEditorView::onHasMsg(const char* pMsg) const { - if (strcmp(pMsg,"Run")==0) return true; - if (strcmp(pMsg,"StartDebug")==0) return true; - if (strcmp(pMsg,"ToggleBreakpoint")==0) return true; + if (strcmp(pMsg,"Run")==0) + return true; + if (strcmp(pMsg,"StartDebug")==0) + return true; + if (strcmp(pMsg,"ToggleBreakpoint")==0) + return true; return EditorView::onHasMsg(pMsg); } diff --git a/src/Gui/GestureNavigationStyle.cpp b/src/Gui/GestureNavigationStyle.cpp index 39295d9da0..3f4b953d43 100644 --- a/src/Gui/GestureNavigationStyle.cpp +++ b/src/Gui/GestureNavigationStyle.cpp @@ -869,7 +869,9 @@ SbBool GestureNavigationStyle::processSoEvent(const SoEvent* const ev) // Events when in "ready-to-seek" mode are ignored, except those // which influence the seek mode itself -- these are handled further // up the inheritance hierarchy. - if (this->isSeekMode()) { return superclass::processSoEvent(ev); } + if (this->isSeekMode()) { + return superclass::processSoEvent(ev); + } // Switch off viewing mode (Bug #0000911) if (!this->isSeekMode()&& !this->isAnimating() && this->isViewing() ) this->setViewing(false); // by default disable viewing mode to render the scene @@ -887,7 +889,8 @@ SbBool GestureNavigationStyle::processSoEvent(const SoEvent* const ev) // give the nodes in the foreground root the chance to handle events (e.g color bar) if (!viewer->isEditing()) { bool processed = handleEventInForeground(ev); - if (processed) return true; + if (processed) + return true; } if ( (smev.isRelease(1) && this->button1down == false) diff --git a/src/Gui/Inventor/SmSwitchboard.cpp b/src/Gui/Inventor/SmSwitchboard.cpp index e9ed020b80..bf2a72d669 100644 --- a/src/Gui/Inventor/SmSwitchboard.cpp +++ b/src/Gui/Inventor/SmSwitchboard.cpp @@ -203,6 +203,7 @@ void SmSwitchboard::search(SoSearchAction * action) { SoNode::search(action); // clazy:exclude=skipped-base-method - if (action->isFound()) return; + if (action->isFound()) + return; SmSwitchboard::doAction(action); } diff --git a/src/Gui/InventorNavigationStyle.cpp b/src/Gui/InventorNavigationStyle.cpp index 347b6a4097..476d10cc89 100644 --- a/src/Gui/InventorNavigationStyle.cpp +++ b/src/Gui/InventorNavigationStyle.cpp @@ -75,7 +75,9 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev) // Events when in "ready-to-seek" mode are ignored, except those // which influence the seek mode itself -- these are handled further // up the inheritance hierarchy. - if (this->isSeekMode()) { return inherited::processSoEvent(ev); } + if (this->isSeekMode()) { + return inherited::processSoEvent(ev); + } // Switch off viewing mode (Bug #0000911) if (!this->isSeekMode()&& !this->isAnimating() && this->isViewing() ) this->setViewing(false); // by default disable viewing mode to render the scene diff --git a/src/Gui/LinkViewPyImp.cpp b/src/Gui/LinkViewPyImp.cpp index c60f683069..f6c68ed524 100644 --- a/src/Gui/LinkViewPyImp.cpp +++ b/src/Gui/LinkViewPyImp.cpp @@ -236,7 +236,8 @@ PyObject* LinkViewPy::setLink(PyObject *args) Py::Object LinkViewPy::getOwner() const { auto owner = getLinkViewPtr()->getOwner(); - if(!owner) return Py::Object(); + if(!owner) + return Py::Object(); return Py::Object(owner->getPyObject(),true); } diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index da07ab1b9a..48bce66be4 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -1004,7 +1004,8 @@ void MainWindow::setActiveWindow(MDIView* view) void MainWindow::onWindowActivated(QMdiSubWindow* w) { - if (!w) return; + if (!w) + return; MDIView* view = dynamic_cast(w->widget()); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View"); diff --git a/src/Gui/ManualAlignment.cpp b/src/Gui/ManualAlignment.cpp index 7b26871d86..85b7ed6000 100644 --- a/src/Gui/ManualAlignment.cpp +++ b/src/Gui/ManualAlignment.cpp @@ -518,7 +518,8 @@ public: static void reorientCamera(SoCamera * cam, const SbRotation & rot) { - if (cam == nullptr) return; + if (cam == nullptr) + return; // Find global coordinates of focal point. SbVec3f direction; diff --git a/src/Gui/MayaGestureNavigationStyle.cpp b/src/Gui/MayaGestureNavigationStyle.cpp index 80e82a5ebf..30bc333d94 100644 --- a/src/Gui/MayaGestureNavigationStyle.cpp +++ b/src/Gui/MayaGestureNavigationStyle.cpp @@ -120,7 +120,9 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev) // Events when in "ready-to-seek" mode are ignored, except those // which influence the seek mode itself -- these are handled further // up the inheritance hierarchy. - if (this->isSeekMode()) { return inherited::processSoEvent(ev); } + if (this->isSeekMode()) { + return inherited::processSoEvent(ev); + } // Switch off viewing mode (Bug #0000911) if (!this->isSeekMode()&& !this->isAnimating() && this->isViewing() ) this->setViewing(false); // by default disable viewing mode to render the scene diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index 3b43290d9e..ae6d62356e 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -325,7 +325,8 @@ void NavigationStyle::seekToPoint(const SbVec3f& scenepos) SbBool NavigationStyle::lookAtPoint(const SbVec2s screenpos) { SoCamera* cam = viewer->getSoRenderManager()->getCamera(); - if (cam == nullptr) return false; + if (cam == nullptr) + return false; SoRayPickAction rpaction(viewer->getSoRenderManager()->getViewportRegion()); rpaction.setPoint(screenpos); @@ -347,7 +348,8 @@ SbBool NavigationStyle::lookAtPoint(const SbVec2s screenpos) void NavigationStyle::lookAtPoint(const SbVec3f& pos) { SoCamera* cam = viewer->getSoRenderManager()->getCamera(); - if (cam == nullptr) return; + if (cam == nullptr) + return; PRIVATE(this)->rotationCenterFound = false; // Find global coordinates of focal point. @@ -405,7 +407,8 @@ void NavigationStyle::lookAtPoint(const SbVec3f& pos) void NavigationStyle::setCameraOrientation(const SbRotation& rot, SbBool moveToCenter) { SoCamera* cam = viewer->getSoRenderManager()->getCamera(); - if (cam == nullptr) return; + if (cam == nullptr) + return; // Find global coordinates of focal point. SbVec3f direction; @@ -484,7 +487,8 @@ void NavigationStyleP::viewAnimationCB(void * data, SoSensor * sensor) SbRotation slerp = SbRotation::slerp(that->spinRotation, PRIVATE(that)->endRotation, step); SbVec3f focalpoint = (1.0f-step)*PRIVATE(that)->focal1 + step*PRIVATE(that)->focal2; SoCamera* cam = that->viewer->getSoRenderManager()->getCamera(); - if (!cam) return; // no camera + if (!cam) // no camera + return; SbVec3f direction; cam->orientation.setValue(slerp); @@ -508,7 +512,8 @@ void NavigationStyleP::viewAnimationCB(void * data, SoSensor * sensor) void NavigationStyle::boxZoom(const SbBox2s& box) { SoCamera* cam = viewer->getSoRenderManager()->getCamera(); - if (!cam) return; // no camera + if (!cam) // no camera + return; const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion(); SbViewVolume vv = cam->getViewVolume(vp.getViewportAspectRatio()); @@ -551,7 +556,8 @@ void NavigationStyle::viewAll() SoGetBoundingBoxAction action(viewer->getSoRenderManager()->getViewportRegion()); action.apply(viewer->getSceneGraph()); SbBox3f box = action.getBoundingBox(); - if (box.isEmpty()) return; + if (box.isEmpty()) + return; #if 0 // check whether the box is very wide or tall, if not do nothing @@ -564,7 +570,8 @@ void NavigationStyle::viewAll() #endif SoCamera* cam = viewer->getSoRenderManager()->getCamera(); - if (!cam) return; + if (!cam) + return; SbViewVolume vol = cam->getViewVolume(); if (vol.ulf == vol.llf) @@ -615,7 +622,8 @@ void NavigationStyle::viewAll() */ void NavigationStyle::reorientCamera(SoCamera * cam, const SbRotation & rot) { - if (cam == nullptr) return; + if (cam == nullptr) + return; // Find global coordinates of focal point. SbVec3f direction; @@ -634,8 +642,10 @@ void NavigationStyle::reorientCamera(SoCamera * cam, const SbRotation & rot) void NavigationStyle::panCamera(SoCamera * cam, float aspectratio, const SbPlane & panplane, const SbVec2f & currpos, const SbVec2f & prevpos) { - if (cam == nullptr) return; // can happen for empty scenegraph - if (currpos == prevpos) return; // useless invocation + if (cam == nullptr) // can happen for empty scenegraph + return; + if (currpos == prevpos) // useless invocation + return; // Find projection points for the last and current mouse coordinates. @@ -693,7 +703,8 @@ void NavigationStyle::panToCenter(const SbPlane & pplane, const SbVec2f & currpo */ void NavigationStyle::zoom(SoCamera * cam, float diffvalue) { - if (cam == nullptr) return; // can happen for empty scenegraph + if (cam == nullptr) // can happen for empty scenegraph + return; SoType t = cam->getTypeId(); SbName tname = t.getName(); @@ -890,7 +901,8 @@ SbVec3f NavigationStyle::getFocalPoint() const */ void NavigationStyle::spin(const SbVec2f & pointerpos) { - if (this->log.historysize < 2) return; + if (this->log.historysize < 2) + return; assert(this->spinprojector != nullptr); const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion(); @@ -1050,7 +1062,8 @@ void NavigationStyle::saveCursorPosition(const SoEvent * const ev) float ratio = vp.getViewportAspectRatio(); SoCamera* cam = viewer->getSoRenderManager()->getCamera(); - if (!cam) return; // no camera + if (!cam) // no camera + return; SbViewVolume vv = cam->getViewVolume(ratio); SbLine line; @@ -1069,7 +1082,8 @@ void NavigationStyle::saveCursorPosition(const SoEvent * const ev) float ratio = vp.getViewportAspectRatio(); SoCamera* cam = viewer->getSoRenderManager()->getCamera(); - if (!cam) return; // no camera + if (!cam) // no camera + return; SoGetBoundingBoxAction action(viewer->getSoRenderManager()->getViewportRegion()); action.apply(viewer->getSceneGraph()); @@ -1187,7 +1201,8 @@ SbBool NavigationStyle::isAnimating() const */ void NavigationStyle::startAnimating(const SbVec3f& axis, float velocity) { - if (!isAnimationEnabled()) return; + if (!isAnimationEnabled()) + return; this->prevRedrawTime = SbTime::getTimeOfDay(); this->spinincrement = SbRotation::identity(); @@ -1396,7 +1411,9 @@ void NavigationStyle::syncModifierKeys(const SoEvent * const ev) void NavigationStyle::setViewingMode(const ViewerMode newmode) { const ViewerMode oldmode = this->currentmode; - if (newmode == oldmode) { return; } + if (newmode == oldmode) { + return; + } switch (newmode) { case DRAGGING: @@ -1522,7 +1539,9 @@ void NavigationStyle::syncWithEvent(const SoEvent * const ev) // Events when in "ready-to-seek" mode are ignored, except those // which influence the seek mode itself -- these are handled further // up the inheritance hierarchy. - if (this->isSeekMode()) { return; } + if (this->isSeekMode()) { + return; + } const SoType type(ev->getTypeId()); diff --git a/src/Gui/OpenCascadeNavigationStyle.cpp b/src/Gui/OpenCascadeNavigationStyle.cpp index 0e2e060e98..8869703f86 100644 --- a/src/Gui/OpenCascadeNavigationStyle.cpp +++ b/src/Gui/OpenCascadeNavigationStyle.cpp @@ -67,7 +67,9 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev) // Events when in "ready-to-seek" mode are ignored, except those // which influence the seek mode itself -- these are handled further // up the inheritance hierarchy. - if (this->isSeekMode()) { return inherited::processSoEvent(ev); } + if (this->isSeekMode()) { + return inherited::processSoEvent(ev); + } // Switch off viewing mode if (!this->isSeekMode() && !this->isAnimating() && this->isViewing()) this->setViewing(false); // by default disable viewing mode to render the scene diff --git a/src/Gui/OpenSCADNavigationStyle.cpp b/src/Gui/OpenSCADNavigationStyle.cpp index 03836aac78..76a8dc5891 100644 --- a/src/Gui/OpenSCADNavigationStyle.cpp +++ b/src/Gui/OpenSCADNavigationStyle.cpp @@ -67,7 +67,9 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev) // Events when in "ready-to-seek" mode are ignored, except those // which influence the seek mode itself -- these are handled further // up the inheritance hierarchy. - if (this->isSeekMode()) { return inherited::processSoEvent(ev); } + if (this->isSeekMode()) { + return inherited::processSoEvent(ev); + } // Switch off viewing mode if (!this->isSeekMode() && !this->isAnimating() && this->isViewing()) this->setViewing(false); // by default disable viewing mode to render the scene diff --git a/src/Gui/Placement.cpp b/src/Gui/Placement.cpp index c9810d749b..d486e800d2 100644 --- a/src/Gui/Placement.cpp +++ b/src/Gui/Placement.cpp @@ -219,7 +219,8 @@ void Placement::revertTransformation() void Placement::applyPlacement(const Base::Placement& p, bool incremental) { Gui::Document* document = Application::Instance->activeDocument(); - if (!document) return; + if (!document) + return; std::vector sel = Gui::Selection().getObjectsOfType (App::DocumentObject::getClassTypeId(), document->getDocument()->getName()); @@ -257,7 +258,8 @@ void Placement::applyPlacement(const Base::Placement& p, bool incremental) void Placement::applyPlacement(const QString& data, bool incremental) { Gui::Document* document = Application::Instance->activeDocument(); - if (!document) return; + if (!document) + return; // When directly changing the property we now only have to commit the transaction, // do a recompute and open a new transaction diff --git a/src/Gui/PythonDebugger.cpp b/src/Gui/PythonDebugger.cpp index c733340605..e6d7783358 100644 --- a/src/Gui/PythonDebugger.cpp +++ b/src/Gui/PythonDebugger.cpp @@ -430,7 +430,8 @@ void PythonDebugger::runFile(const QString& fn) #else FILE *fp = fopen((const char*)pxFileName,"r"); #endif - if (!fp) return; + if (!fp) + return; Base::PyGILStateLocker locker; PyObject *module, *dict; diff --git a/src/Gui/QSint/actionpanel/actionbox.cpp b/src/Gui/QSint/actionpanel/actionbox.cpp index 7635555f96..bc9d582c79 100644 --- a/src/Gui/QSint/actionpanel/actionbox.cpp +++ b/src/Gui/QSint/actionpanel/actionbox.cpp @@ -215,7 +215,8 @@ void ActionBox::addLayout(QLayout * l) void ActionBox::addWidget(QWidget * w, QLayout * l) { - if (!w) return; + if (!w) + return; w->setParent(this); diff --git a/src/Gui/Quarter/DragDropHandler.cpp b/src/Gui/Quarter/DragDropHandler.cpp index da02a2952e..f8b957c42b 100644 --- a/src/Gui/Quarter/DragDropHandler.cpp +++ b/src/Gui/Quarter/DragDropHandler.cpp @@ -115,12 +115,15 @@ void DragDropHandlerP::dragEnterEvent(QDragEnterEvent * event) { const QMimeData * mimedata = event->mimeData(); - if (!mimedata->hasUrls() && !mimedata->hasText()) return; + if (!mimedata->hasUrls() && !mimedata->hasText()) + return; if (mimedata->hasUrls()) { QFileInfo fileinfo(mimedata->urls().takeFirst().path()); QString suffix = fileinfo.suffix().toLower(); - if (!this->suffixes.contains(suffix)) { return; } + if (!this->suffixes.contains(suffix)) { + return; + } } event->acceptProposedAction(); @@ -139,18 +142,21 @@ DragDropHandlerP::dropEvent(QDropEvent * event) QUrl url = mimedata->urls().takeFirst(); if (url.scheme().isEmpty() || url.scheme().toLower() == QString("file") ) { // attempt to open file - if (!in.openFile(url.toLocalFile().toLatin1().constData())) return; + if (!in.openFile(url.toLocalFile().toLatin1().constData())) + return; } } else if (mimedata->hasText()) { /* FIXME 2007-11-09 preng: dropping text buffer does not work on Windows Vista. */ bytes = mimedata->text().toUtf8(); in.setBuffer((void *) bytes.constData(), bytes.size()); - if (!in.isValidBuffer()) return; + if (!in.isValidBuffer()) + return; } // attempt to import it root = SoDB::readAll(&in); - if (root == nullptr) return; + if (root == nullptr) + return; // set new scenegraph this->quarterwidget->setSceneGraph(root); diff --git a/src/Gui/RevitNavigationStyle.cpp b/src/Gui/RevitNavigationStyle.cpp index 0f70546fb6..f8e337ebbc 100644 --- a/src/Gui/RevitNavigationStyle.cpp +++ b/src/Gui/RevitNavigationStyle.cpp @@ -67,7 +67,9 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev) // Events when in "ready-to-seek" mode are ignored, except those // which influence the seek mode itself -- these are handled further // up the inheritance hierarchy. - if (this->isSeekMode()) { return inherited::processSoEvent(ev); } + if (this->isSeekMode()) { + return inherited::processSoEvent(ev); + } // Switch off viewing mode (Bug #0000911) if (!this->isSeekMode() && !this->isAnimating() && this->isViewing()) this->setViewing(false); // by default disable viewing mode to render the scene diff --git a/src/Gui/Selection.cpp b/src/Gui/Selection.cpp index aa79a4b80e..92a872fa0c 100644 --- a/src/Gui/Selection.cpp +++ b/src/Gui/Selection.cpp @@ -723,12 +723,14 @@ void SelectionSingleton::slotSelectionChanged(const SelectionChanges& msg) { if(msg.Object.getSubName().size()) { auto pParent = msg.Object.getObject(); - if(!pParent) return; + if(!pParent) + return; std::pair elementName; auto &newElementName = elementName.first; auto &oldElementName = elementName.second; auto pObject = App::GeoFeature::resolveElement(pParent,msg.pSubName,elementName); - if (!pObject) return; + if (!pObject) + return; SelectionChanges msg2(msg.Type,pObject->getDocument()->getName(), pObject->getNameInDocument(), newElementName.size()?newElementName.c_str():oldElementName.c_str(), @@ -892,7 +894,8 @@ void SelectionSingleton::setPreselectCoord( float x, float y, float z) static char buf[513]; // if nothing is in preselect ignore - if(CurrentPreselection.Object.getObjectName().empty()) return; + if(CurrentPreselection.Object.getObjectName().empty()) + return; CurrentPreselection.x = x; CurrentPreselection.y = y; @@ -1285,9 +1288,11 @@ bool SelectionSingleton::updateSelection(bool show, const char* pDocName, rmvPreselect(); } auto pDoc = getDocument(pDocName); - if(!pDoc) return false; + if(!pDoc) + return false; auto pObject = pDoc->getObject(pObjectName); - if(!pObject) return false; + if(!pObject) + return false; if (!isSelected(pObject, pSubName,0)) return false; @@ -1352,7 +1357,8 @@ void SelectionSingleton::rmvSelection(const char* pDocName, const char* pObjectN notify(SelectionChanges(SelectionChanges::PickedListChanged)); } - if(!pDocName) return; + if(!pDocName) + return; _SelObj temp; int ret = checkSelection(pDocName,pObjectName,pSubName,0,temp); @@ -1704,7 +1710,8 @@ int SelectionSingleton::checkSelection(const char *pDocName, const char *pObject const char *SelectionSingleton::getSelectedElement(App::DocumentObject *obj, const char* pSubName) const { - if (!obj) return nullptr; + if (!obj) + return nullptr; for(list<_SelObj>::const_iterator It = _SelList.begin();It != _SelList.end();++It) { if (It->pObject == obj) { @@ -1722,7 +1729,8 @@ const char *SelectionSingleton::getSelectedElement(App::DocumentObject *obj, con void SelectionSingleton::slotDeletedObject(const App::DocumentObject& Obj) { - if(!Obj.getNameInDocument()) return; + if(!Obj.getNameInDocument()) + return; // For safety reason, don't bother checking rmvPreselect(); diff --git a/src/Gui/SelectionView.cpp b/src/Gui/SelectionView.cpp index 84713911f8..d0d90d43b2 100644 --- a/src/Gui/SelectionView.cpp +++ b/src/Gui/SelectionView.cpp @@ -360,11 +360,13 @@ void SelectionView::deselect(void) void SelectionView::toggleSelect(QListWidgetItem* item) { - if (!item) return; + if (!item) + return; std::string name = item->text().toLatin1().constData(); char *docname = &name.at(0); char *objname = std::strchr(docname,'#'); - if(!objname) return; + if(!objname) + return; *objname++ = 0; char *subname = std::strchr(objname,'.'); if(subname) { @@ -398,11 +400,13 @@ void SelectionView::toggleSelect(QListWidgetItem* item) void SelectionView::preselect(QListWidgetItem* item) { - if (!item) return; + if (!item) + return; std::string name = item->text().toLatin1().constData(); char *docname = &name.at(0); char *objname = std::strchr(docname,'#'); - if(!objname) return; + if(!objname) + return; *objname++ = 0; char *subname = std::strchr(objname,'.'); if(subname) { diff --git a/src/Gui/SoFCOffscreenRenderer.cpp b/src/Gui/SoFCOffscreenRenderer.cpp index 33cecb0de5..dbb27928cb 100644 --- a/src/Gui/SoFCOffscreenRenderer.cpp +++ b/src/Gui/SoFCOffscreenRenderer.cpp @@ -496,7 +496,9 @@ SoQtOffscreenRenderer::getBackgroundColor(void) const void SoQtOffscreenRenderer::setGLRenderAction(SoGLRenderAction * action) { - if (action == PRIVATE(this)->renderaction) { return; } + if (action == PRIVATE(this)->renderaction) { + return; + } if (PRIVATE(this)->didallocation) { delete PRIVATE(this)->renderaction; } PRIVATE(this)->renderaction = action; diff --git a/src/Gui/SoFCSelection.cpp b/src/Gui/SoFCSelection.cpp index da112473da..7e6386324a 100644 --- a/src/Gui/SoFCSelection.cpp +++ b/src/Gui/SoFCSelection.cpp @@ -308,10 +308,14 @@ void SoFCSelection::doAction(SoAction *action) int SoFCSelection::getPriority(const SoPickedPoint* p) { const SoDetail* detail = p->getDetail(); - if(!detail) return 0; - if(detail->isOfType(SoFaceDetail::getClassTypeId())) return 1; - if(detail->isOfType(SoLineDetail::getClassTypeId())) return 2; - if(detail->isOfType(SoPointDetail::getClassTypeId())) return 3; + if(!detail) + return 0; + if(detail->isOfType(SoFaceDetail::getClassTypeId())) + return 1; + if(detail->isOfType(SoLineDetail::getClassTypeId())) + return 2; + if(detail->isOfType(SoPointDetail::getClassTypeId())) + return 3; return 0; } diff --git a/src/Gui/SoFCUnifiedSelection.cpp b/src/Gui/SoFCUnifiedSelection.cpp index d8321cc854..12274ce71a 100644 --- a/src/Gui/SoFCUnifiedSelection.cpp +++ b/src/Gui/SoFCUnifiedSelection.cpp @@ -204,7 +204,8 @@ void SoFCUnifiedSelection::write(SoWriteAction * action) SoOutput * out = action->getOutput(); if (out->getStage() == SoOutput::WRITE) { // Do not write out the fields of this class - if (this->writeHeader(out, true, false)) return; + if (this->writeHeader(out, true, false)) + return; SoGroup::doAction((SoAction *)action); this->writeFooter(out); } @@ -216,10 +217,14 @@ void SoFCUnifiedSelection::write(SoWriteAction * action) int SoFCUnifiedSelection::getPriority(const SoPickedPoint* p) { const SoDetail* detail = p->getDetail(); - if (!detail) return 0; - if (detail->isOfType(SoFaceDetail::getClassTypeId())) return 1; - if (detail->isOfType(SoLineDetail::getClassTypeId())) return 2; - if (detail->isOfType(SoPointDetail::getClassTypeId())) return 3; + if (!detail) + return 0; + if (detail->isOfType(SoFaceDetail::getClassTypeId())) + return 1; + if (detail->isOfType(SoLineDetail::getClassTypeId())) + return 2; + if (detail->isOfType(SoPointDetail::getClassTypeId())) + return 3; return 0; } @@ -263,7 +268,8 @@ SoFCUnifiedSelection::getPickedList(SoHandleEventAction* action, bool singlePick ret.push_back(info); } - if(ret.size()<=1) return ret; + if(ret.size()<=1) + return ret; // To identify the picking of lines in a concave area we have to // get all intersection points. If we have two or more intersection @@ -534,7 +540,8 @@ bool SoFCUnifiedSelection::setHighlight(SoFullPath *path, const SoDetail *det, } bool SoFCUnifiedSelection::setSelection(const std::vector &infos, bool ctrlDown) { - if(infos.empty() || !infos[0].vpd) return false; + if(infos.empty() || !infos[0].vpd) + return false; std::vector sels; if(infos.size()>1) { @@ -559,9 +566,11 @@ bool SoFCUnifiedSelection::setSelection(const std::vector &infos, bo const auto &info = infos[0]; auto vpd = info.vpd; - if(!vpd) return false; + if(!vpd) + return false; const char *objname = vpd->getObject()->getNameInDocument(); - if(!objname) return false; + if(!objname) + return false; const char *docname = vpd->getObject()->getDocument()->getName(); bool hasNext = false; diff --git a/src/Gui/SoFCVectorizeSVGAction.cpp b/src/Gui/SoFCVectorizeSVGAction.cpp index 9e14fe955e..b37bcad4fd 100644 --- a/src/Gui/SoFCVectorizeSVGAction.cpp +++ b/src/Gui/SoFCVectorizeSVGAction.cpp @@ -294,7 +294,8 @@ Separator { */ void SoFCVectorizeSVGActionP::printTriangle(const SbVec3f * v, const SbColor * c) const { - if (v[0] == v[1] || v[1] == v[2] || v[0] == v[2]) return; + if (v[0] == v[1] || v[1] == v[2] || v[0] == v[2]) + return; uint32_t cc = c->getPackedValue(); std::ostream& str = publ->getSVGOutput()->getFileStream(); diff --git a/src/Gui/SoFCVectorizeU3DAction.cpp b/src/Gui/SoFCVectorizeU3DAction.cpp index 2c786e9117..de876ad066 100644 --- a/src/Gui/SoFCVectorizeU3DAction.cpp +++ b/src/Gui/SoFCVectorizeU3DAction.cpp @@ -228,7 +228,8 @@ void SoFCVectorizeU3DActionP::printTriangle(const SoVectorizeTriangle * item) co void SoFCVectorizeU3DActionP::printTriangle(const SbVec3f * v, const SbColor * c) const { - if (v[0] == v[1] || v[1] == v[2] || v[0] == v[2]) return; + if (v[0] == v[1] || v[1] == v[2] || v[0] == v[2]) + return; //uint32_t cc = c->getPackedValue(); //std::ostream& str = publ->getU3DOutput()->getFileStream(); diff --git a/src/Gui/SoTextLabel.cpp b/src/Gui/SoTextLabel.cpp index e230fb7825..9ec2118c01 100644 --- a/src/Gui/SoTextLabel.cpp +++ b/src/Gui/SoTextLabel.cpp @@ -114,7 +114,8 @@ SoTextLabel::SoTextLabel() */ void SoTextLabel::GLRender(SoGLRenderAction *action) { - if (!this->shouldGLRender(action)) return; + if (!this->shouldGLRender(action)) + return; // only draw text without background if (!this->background.getValue()) { diff --git a/src/Gui/TaskElementColors.cpp b/src/Gui/TaskElementColors.cpp index 9a4c5c3c9d..08452e1e8d 100644 --- a/src/Gui/TaskElementColors.cpp +++ b/src/Gui/TaskElementColors.cpp @@ -271,7 +271,8 @@ public: } void onSelectionChanged() { - if(busy) return; + if(busy) + return; busy = true; std::map sels; for(auto &sel : Selection().getSelectionEx( diff --git a/src/Gui/TaskView/TaskAppearance.cpp b/src/Gui/TaskView/TaskAppearance.cpp index b6e7b87f8e..cd6d93deff 100644 --- a/src/Gui/TaskView/TaskAppearance.cpp +++ b/src/Gui/TaskView/TaskAppearance.cpp @@ -202,7 +202,8 @@ void TaskAppearance::setDisplayModes(const std::vector& view App::Property* prop = (*it)->getPropertyByName("DisplayMode"); if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) { App::PropertyEnumeration* display = static_cast(prop); - if (!display->getEnums()) return; + if (!display->getEnums()) + return; const std::vector& value = display->getEnumVector(); if (it == views.begin()) { for (std::vector::const_iterator jt = value.begin(); jt != value.end(); ++jt) diff --git a/src/Gui/TinkerCADNavigationStyle.cpp b/src/Gui/TinkerCADNavigationStyle.cpp index 30c84bada9..f3d6159a7b 100644 --- a/src/Gui/TinkerCADNavigationStyle.cpp +++ b/src/Gui/TinkerCADNavigationStyle.cpp @@ -67,7 +67,9 @@ SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev) // Events when in "ready-to-seek" mode are ignored, except those // which influence the seek mode itself -- these are handled further // up the inheritance hierarchy. - if (this->isSeekMode()) { return inherited::processSoEvent(ev); } + if (this->isSeekMode()) { + return inherited::processSoEvent(ev); + } // Switch off viewing mode if (!this->isSeekMode() && !this->isAnimating() && this->isViewing()) this->setViewing(false); // by default disable viewing mode to render the scene diff --git a/src/Gui/TouchpadNavigationStyle.cpp b/src/Gui/TouchpadNavigationStyle.cpp index 184562bb16..8f9ed4b552 100644 --- a/src/Gui/TouchpadNavigationStyle.cpp +++ b/src/Gui/TouchpadNavigationStyle.cpp @@ -66,7 +66,9 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev) // Events when in "ready-to-seek" mode are ignored, except those // which influence the seek mode itself -- these are handled further // up the inheritance hierarchy. - if (this->isSeekMode()) { return inherited::processSoEvent(ev); } + if (this->isSeekMode()) { + return inherited::processSoEvent(ev); + } // Switch off viewing mode (Bug #0000911) if (!this->isSeekMode() && !this->isAnimating() && this->isViewing()) this->setViewing(false); // by default disable viewing mode to render the scene diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 4f682b8bb9..b805759295 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -1060,7 +1060,8 @@ void TreeWidget::onFinishEditing() DocumentObjectItem* objitem = static_cast (this->contextItem); App::DocumentObject* obj = objitem->object()->getObject(); - if (!obj) return; + if (!obj) + return; Gui::Document* doc = Gui::Application::Instance->getDocument(obj->getDocument()); doc->commitCommand(); doc->resetEdit(); @@ -1238,7 +1239,8 @@ std::vector TreeWidget::getSelection(App::Document* doc) break; } } - if (!tree) return ret; + if (!tree) + return ret; if (tree->selectTimer->isActive()) tree->onSelectTimer(); @@ -1438,13 +1440,15 @@ void TreeWidget::keyPressEvent(QKeyEvent* event) void TreeWidget::mouseDoubleClickEvent(QMouseEvent* event) { QTreeWidgetItem* item = itemAt(event->pos()); - if (!item) return; + if (!item) + return; try { if (item->type() == TreeWidget::DocumentType) { //QTreeWidget::mouseDoubleClickEvent(event); Gui::Document* doc = static_cast(item)->document(); - if (!doc) return; + if (!doc) + return; if (doc->getDocument()->testStatus(App::Document::PartialDoc)) { contextItem = item; onReloadDoc(); @@ -2867,7 +2871,8 @@ void TreeWidget::syncView(ViewProviderDocumentObject* vp) void TreeWidget::onShowHidden() { - if (!this->contextItem) return; + if (!this->contextItem) + return; DocumentItem* docItem = nullptr; if (this->contextItem->type() == DocumentType) docItem = static_cast(contextItem); @@ -4144,7 +4149,8 @@ void DocumentItem::updateSelection(QTreeWidgetItem* ti, bool unselect) { } } - if (unselect) return; + if (unselect) + return; for (int i = 0, count = ti->childCount(); i < count; ++i) updateSelection(ti->child(i)); } @@ -4469,7 +4475,8 @@ void DocumentItem::selectItems(SelectionReason reason) { void DocumentItem::populateParents(const ViewProvider* vp, ViewParentMap& parentMap) { auto it = parentMap.find(vp); - if (it == parentMap.end()) return; + if (it == parentMap.end()) + return; for (auto parent : it->second) { auto it = ObjectMap.find(parent->getObject()); if (it == ObjectMap.end()) diff --git a/src/Gui/TreeView.cpp b/src/Gui/TreeView.cpp index 3f937ddb5c..6b5945c9ed 100644 --- a/src/Gui/TreeView.cpp +++ b/src/Gui/TreeView.cpp @@ -65,7 +65,8 @@ void TreeView::mouseDoubleClickEvent (QMouseEvent * event) QTreeView::mouseDoubleClickEvent(event); const Gui::Document* doc = static_cast(item); MDIView *view = doc->getActiveView(); - if (!view) return; + if (!view) + return; getMainWindow()->setActiveWindow(view); } else if (item->getTypeId().isDerivedFrom(ViewProvider::getClassTypeId())) { diff --git a/src/Gui/UiLoader.cpp b/src/Gui/UiLoader.cpp index eb50ac9fad..47c88f046c 100644 --- a/src/Gui/UiLoader.cpp +++ b/src/Gui/UiLoader.cpp @@ -408,7 +408,8 @@ QDir QUiLoader::workingDirectory() const PythonWrapper wrap; Py::Object dir((uiloader.callMemberFunction("workingDirectory"))); QDir* d = wrap.toQDir(dir.ptr()); - if (d) return *d; + if (d) + return *d; return QDir::current(); } catch (Py::Exception& e) { diff --git a/src/Gui/View3DInventor.cpp b/src/Gui/View3DInventor.cpp index 8967c722b0..97a1cb1d56 100644 --- a/src/Gui/View3DInventor.cpp +++ b/src/Gui/View3DInventor.cpp @@ -584,7 +584,8 @@ bool View3DInventor::onMsg(const char* pMsg, const char** ppReturn) } else if(strcmp("GetCamera",pMsg) == 0 ) { SoCamera * Cam = _viewer->getSoRenderManager()->getCamera(); - if (!Cam) return false; + if (!Cam) + return false; *ppReturn = SoFCDB::writeNodesToString(Cam).c_str(); return true; } diff --git a/src/Gui/View3DInventorExamples.cpp b/src/Gui/View3DInventorExamples.cpp index e0225ea2af..a4e23fb0e2 100644 --- a/src/Gui/View3DInventorExamples.cpp +++ b/src/Gui/View3DInventorExamples.cpp @@ -276,7 +276,8 @@ void LightManip(SoSeparator * root) SoInput in; in.setBuffer((void *)scenegraph, std::strlen(scenegraph)); SoSeparator * _root = SoDB::readAll( &in ); - if ( _root == nullptr ) return; // Shouldn't happen. + if ( _root == nullptr ) // Shouldn't happen. + return; root->addChild(_root); root->ref(); @@ -289,7 +290,8 @@ void LightManip(SoSeparator * root) sa.setSearchingAll( false ); sa.apply( root ); SoPath * path = sa.getPath(); - if ( path == nullptr) return; // Shouldn't happen. + if ( path == nullptr) // Shouldn't happen. + return; SoPointLightManip * manip = new SoPointLightManip; manip->replaceNode( path ); @@ -394,7 +396,8 @@ timersensorcallback(void * data, SoSensor *) void AnimationTexture(SoSeparator * root) { // Scene graph - if ( root == nullptr ) return; // Shouldn't happen. + if ( root == nullptr ) // Shouldn't happen. + return; // Generate a julia set to use as a texturemap julia(global_cr, global_ci, 2.5, texturewidth, textureheight, 4, bitmap, 64); diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 6454627033..9863c86d49 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -2404,7 +2404,8 @@ void View3DInventorViewer::setSeekMode(SbBool on) void View3DInventorViewer::printDimension() { SoCamera* cam = getSoRenderManager()->getCamera(); - if (!cam) return; // no camera there + if (!cam) // no camera there + return; SoType t = getSoRenderManager()->getCamera()->getTypeId(); if (t.isDerivedFrom(SoOrthographicCamera::getClassTypeId())) { @@ -2493,7 +2494,8 @@ SbVec3f View3DInventorViewer::getViewDirection() const { SoCamera* cam = this->getSoRenderManager()->getCamera(); - if (!cam) return SbVec3f(0,0,-1); // this is the default + if (!cam) // this is the default + return SbVec3f(0,0,-1); SbVec3f projDir = cam->getViewVolume().getProjectionDirection(); return projDir; @@ -2510,7 +2512,8 @@ SbVec3f View3DInventorViewer::getUpDirection() const { SoCamera* cam = this->getSoRenderManager()->getCamera(); - if (!cam) return SbVec3f(0,1,0); + if (!cam) + return SbVec3f(0,1,0); SbRotation camrot = cam->orientation.getValue(); SbVec3f upvec(0, 1, 0); // init to default up vector @@ -2559,7 +2562,8 @@ SbVec3f View3DInventorViewer::getPointOnFocalPlane(const SbVec2s& pnt) const SbVec2f pnt2d = getNormalizedPosition(pnt); SoCamera* pCam = this->getSoRenderManager()->getCamera(); - if (!pCam) return SbVec3f(); // return invalid point + if (!pCam) // return invalid point + return SbVec3f(); SbViewVolume vol = pCam->getViewVolume(); @@ -2599,7 +2603,8 @@ void View3DInventorViewer::getNearPlane(SbVec3f& rcPt, SbVec3f& rcNormal) const { SoCamera* pCam = getSoRenderManager()->getCamera(); - if (!pCam) return; // just do nothing + if (!pCam) // just do nothing + return; SbViewVolume vol = pCam->getViewVolume(); @@ -2617,7 +2622,8 @@ void View3DInventorViewer::getFarPlane(SbVec3f& rcPt, SbVec3f& rcNormal) const { SoCamera* pCam = getSoRenderManager()->getCamera(); - if (!pCam) return; // just do nothing + if (!pCam) // just do nothing + return; SbViewVolume vol = pCam->getViewVolume(); @@ -2636,7 +2642,8 @@ SbVec3f View3DInventorViewer::projectOnNearPlane(const SbVec2f& pt) const SbVec3f pt1, pt2; SoCamera* cam = this->getSoRenderManager()->getCamera(); - if (!cam) return SbVec3f(); // return invalid point + if (!cam) // return invalid point + return SbVec3f(); SbViewVolume vol = cam->getViewVolume(); vol.projectPointToLine(pt, pt1, pt2); @@ -2648,7 +2655,8 @@ SbVec3f View3DInventorViewer::projectOnFarPlane(const SbVec2f& pt) const SbVec3f pt1, pt2; SoCamera* cam = this->getSoRenderManager()->getCamera(); - if (!cam) return SbVec3f(); // return invalid point + if (!cam) // return invalid point + return SbVec3f(); SbViewVolume vol = cam->getViewVolume(); vol.projectPointToLine(pt, pt1, pt2); @@ -2660,7 +2668,8 @@ void View3DInventorViewer::projectPointToLine(const SbVec2s& pt, SbVec3f& pt1, S SbVec2f pnt2d = getNormalizedPosition(pt); SoCamera* pCam = this->getSoRenderManager()->getCamera(); - if (!pCam) return; + if (!pCam) + return; SbViewVolume vol = pCam->getViewVolume(); vol.projectPointToLine(pnt2d, pt1, pt2); @@ -2754,7 +2763,8 @@ const SoPickedPoint* View3DInventorViewer::getPickedPoint(SoEventCallback* n) co { if (selectionRoot) { auto ret = selectionRoot->getPickedList(n->getAction(), true); - if(ret.size()) return ret[0].pp; + if(ret.size()) + return ret[0].pp; return nullptr; } return n->getPickedPoint(); @@ -2786,7 +2796,8 @@ void View3DInventorViewer::setCameraType(SoType t) // close camera but we don't have this other ugly effect. SoCamera* cam = this->getSoRenderManager()->getCamera(); - if(cam == nullptr) return; + if(cam == nullptr) + return; static_cast(cam)->heightAngle = (float)(M_PI / 4.0); } @@ -2827,7 +2838,8 @@ namespace Gui { void View3DInventorViewer::moveCameraTo(const SbRotation& rot, const SbVec3f& pos, int steps, int ms) { SoCamera* cam = this->getSoRenderManager()->getCamera(); - if (cam == nullptr) return; + if (cam == nullptr) + return; CameraAnimation anim(cam, rot, pos); anim.setDuration(Base::clamp(ms,0,5000)); @@ -2991,9 +3003,11 @@ void View3DInventorViewer::viewAll(float factor) { SoCamera* cam = this->getSoRenderManager()->getCamera(); - if (!cam) return; + if (!cam) + return; - if (factor <= 0.0f) return; + if (factor <= 0.0f) + return; if (factor != 1.0f) { SoSearchAction sa; diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index 060cd09b69..ad2e42cc8f 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -943,7 +943,8 @@ Py::Object View3DInventorPy::viewPosition(const Py::Tuple& args) } SoCamera* cam = getView3DIventorPtr()->getViewer()->getSoRenderManager()->getCamera(); - if (!cam) return Py::None(); + if (!cam) + return Py::None(); SbRotation rot = cam->orientation.getValue(); SbVec3f pos = cam->position.getValue(); @@ -1783,7 +1784,8 @@ void View3DInventorPy::eventCallback(void * ud, SoEventCallback * n) try { Py::Dict dict; const SoEvent* e = n->getEvent(); - if (!e) return; // invalid event + if (!e) // invalid event + return; // Type dict.setItem("Type", Py::String(std::string(e->getTypeId().getName().getString()))); // Time diff --git a/src/Gui/ViewProvider.cpp b/src/Gui/ViewProvider.cpp index dc265b759d..29f94b01d4 100644 --- a/src/Gui/ViewProvider.cpp +++ b/src/Gui/ViewProvider.cpp @@ -904,7 +904,8 @@ std::vector< App::DocumentObject* > ViewProvider::claimChildren3D(void) const return vec; } bool ViewProvider::getElementPicked(const SoPickedPoint *pp, std::string &subname) const { - if(!isSelectable()) return false; + if(!isSelectable()) + return false; auto vector = getExtensionsDerivedFromType(); for(Gui::ViewProviderExtension* ext : vector) { if(ext->extensionGetElementPicked(pp,subname)) diff --git a/src/Gui/ViewProviderDocumentObject.cpp b/src/Gui/ViewProviderDocumentObject.cpp index 26daa82db9..ad26d09c15 100644 --- a/src/Gui/ViewProviderDocumentObject.cpp +++ b/src/Gui/ViewProviderDocumentObject.cpp @@ -581,7 +581,8 @@ bool ViewProviderDocumentObject::showInTree() const { bool ViewProviderDocumentObject::getElementPicked(const SoPickedPoint *pp, std::string &subname) const { - if(!isSelectable()) return false; + if(!isSelectable()) + return false; auto vector = getExtensionsDerivedFromType(); for(Gui::ViewProviderExtension* ext : vector) if(ext->extensionGetElementPicked(pp,subname)) @@ -601,7 +602,8 @@ bool ViewProviderDocumentObject::getElementPicked(const SoPickedPoint *pp, std:: if(idx<0 || idx+1>=path->getLength()) return false; auto vp = getDocument()->getViewProvider(path->getNode(idx+1)); - if(!vp) return false; + if(!vp) + return false; auto obj = vp->getObject(); if(!obj || !obj->getNameInDocument()) return false; @@ -629,13 +631,17 @@ bool ViewProviderDocumentObject::getDetailPath(const char *subname, SoFullPath * } const char *dot = strchr(subname,'.'); - if(!dot) return false; + if(!dot) + return false; auto obj = getObject(); - if(!obj || !obj->getNameInDocument()) return false; + if(!obj || !obj->getNameInDocument()) + return false; auto sobj = obj->getSubObject(std::string(subname,dot-subname+1).c_str()); - if(!sobj) return false; + if(!sobj) + return false; auto vp = Application::Instance->getViewProvider(sobj); - if(!vp) return false; + if(!vp) + return false; auto childRoot = getChildRoot(); if(!childRoot) diff --git a/src/Gui/ViewProviderInventorObject.cpp b/src/Gui/ViewProviderInventorObject.cpp index 7ab56b8184..96900b6269 100644 --- a/src/Gui/ViewProviderInventorObject.cpp +++ b/src/Gui/ViewProviderInventorObject.cpp @@ -94,7 +94,8 @@ void ViewProviderInventorObject::updateData(const App::Property* prop) SoInput in; std::string buffer = ivObj->Buffer.getValue(); coinRemoveAllChildren(pcBuffer); - if (buffer.empty()) return; + if (buffer.empty()) + return; in.setBuffer((void *)buffer.c_str(), buffer.size()); SoSeparator * node = SoDB::readAll(&in); if (node) { diff --git a/src/Gui/ViewProviderLink.cpp b/src/Gui/ViewProviderLink.cpp index 25e09e926b..4ac8ea3457 100644 --- a/src/Gui/ViewProviderLink.cpp +++ b/src/Gui/ViewProviderLink.cpp @@ -151,7 +151,8 @@ public: } static Pointer get(ViewProviderDocumentObject *vp, LinkOwner *owner) { - if(!vp) return Pointer(); + if(!vp) + return Pointer(); auto ext = vp->getExtensionByType(true); if(!ext) { @@ -272,7 +273,8 @@ public: } void updateSwitch(SoSwitch *node=nullptr) { - if(!isLinked() || !pcLinkedSwitch) return; + if(!isLinked() || !pcLinkedSwitch) + return; int index = pcLinkedSwitch->whichChild.getValue(); for(size_t i=0;igetUseSelectionRoot()) pcSnapshot = new SoFCSelectionRoot; @@ -505,9 +508,11 @@ public: { SoPath *path = pp->getPath(); int index = path->findNode(pcChildGroup); - if(index<=0) return false; + if(index<=0) + return false; auto it = nodeMap.find(path->getNode(index+1)); - if(it==nodeMap.end()) return false; + if(it==nodeMap.end()) + return false; return it->second->getElementPicked(true,LinkView::SnapshotChild,pp,str); }else{ std::string subname; @@ -540,11 +545,13 @@ public: bool getDetail(bool checkname, int type, const char* subname, SoDetail *&det, SoFullPath *path) const { - if(!isLinked()) return false; + if(!isLinked()) + return false; if(checkname) { subname = checkSubname(pcLinked->getObject(),subname); - if(!subname) return false; + if(!subname) + return false; } if(pcSnapshots[type]->findChild(pcSwitches[type]) < 0) { @@ -563,7 +570,8 @@ public: return false; appendPath(path,pcSwitches[type]); } - if(*subname == 0) return true; + if(*subname == 0) + return true; auto pcSwitch = pcSwitches[type]; if(!pcChildGroup || !pcSwitch || pcSwitch->whichChild.getValue()<0 || @@ -597,7 +605,8 @@ public: const char *dot = strchr(subname,'.'); const char *nextsub = subname; - if(!dot) return false; + if(!dot) + return false; auto geoGroup = pcLinked->getObject(); auto sobj = geoGroup; while(1) { @@ -732,7 +741,8 @@ void ViewProviderLinkObserver::extensionReattach(App::DocumentObject *) { void ViewProviderLinkObserver::extensionOnChanged(const App::Property *prop) { #if 0 auto owner = freecad_dynamic_cast(getExtendedContainer()); - if(!owner || !linkInfo) return; + if(!owner || !linkInfo) + return; if(prop != &owner->Visibility && prop != &owner->DisplayMode) linkInfo->update(); #else @@ -1270,7 +1280,8 @@ std::vector LinkView::getSubNames() const { void LinkView::setNodeType(SnapshotType type, bool sublink) { autoSubLink = sublink; - if(nodeType==type) return; + if(nodeType==type) + return; if(type>=SnapshotMax || (type<0 && type!=SnapshotContainer && type!=SnapshotContainerTransform)) LINK_THROW(Base::ValueError,"LinkView: invalid node type"); @@ -1445,7 +1456,8 @@ bool LinkView::linkGetElementPicked(const SoPickedPoint *pp, std::string &subnam } } - if(!isLinked()) return false; + if(!isLinked()) + return false; if(nodeType >= 0) { if(linkInfo->getElementPicked(false,nodeType,pp,ss)) { @@ -1455,7 +1467,8 @@ bool LinkView::linkGetElementPicked(const SoPickedPoint *pp, std::string &subnam return false; } auto idx = path->findNode(pcLinkedRoot); - if(idx<0 || idx+1>=path->getLength()) return false; + if(idx<0 || idx+1>=path->getLength()) + return false; auto node = path->getNode(idx+1); for(const auto &v : subInfo) { auto &sub = *v.second; @@ -1494,7 +1507,8 @@ bool LinkView::getGroupHierarchy(int index, SoFullPath *path) const { bool LinkView::linkGetDetailPath(const char *subname, SoFullPath *path, SoDetail *&det) const { - if(!subname || *subname==0) return true; + if(!subname || *subname==0) + return true; auto len = path->getLength(); if(nodeArray.empty()) { if(!appendPathSafe(path,pcLinkRoot)) @@ -1594,7 +1608,8 @@ bool LinkView::linkGetDetailPath(const char *subname, SoFullPath *path, SoDetail } void LinkView::unlink(LinkInfoPtr info) { - if(!info) return; + if(!info) + return; if(info == linkOwner) { linkOwner->remove(this); linkOwner.reset(); @@ -1798,7 +1813,8 @@ void ViewProviderLink::onChanged(const App::Property* prop) { bool ViewProviderLink::setLinkType(App::LinkBaseExtension *ext) { auto propLink = ext->getLinkedObjectProperty(); - if(!propLink) return false; + if(!propLink) + return false; LinkType type; if(hasSubName) type = LinkTypeSubs; @@ -1848,7 +1864,8 @@ static inline bool canScale(const Base::Vector3d &v) { } void ViewProviderLink::updateDataPrivate(App::LinkBaseExtension *ext, const App::Property *prop) { - if(!prop) return; + if(!prop) + return; if(prop == &ext->_ChildCache) { updateElementList(ext); } else if(prop == &ext->_LinkTouched) { @@ -2050,7 +2067,8 @@ void ViewProviderLink::updateElementList(App::LinkBaseExtension *ext) { void ViewProviderLink::checkIcon(const App::LinkBaseExtension *ext) { if(!ext) { ext = getLinkExtension(); - if(!ext) return; + if(!ext) + return; } const char *icon; auto element = freecad_dynamic_cast(getObject()); @@ -2089,7 +2107,8 @@ void ViewProviderLink::applyMaterial() { void ViewProviderLink::finishRestoring() { FC_TRACE("finish restoring"); auto ext = getLinkExtension(); - if(!ext) return; + if(!ext) + return; linkView->setDrawStyle(DrawStyle.getValue(),LineWidth.getValue(),PointSize.getValue()); updateDataPrivate(ext,ext->getLinkedObjectProperty()); if(ext->getLinkPlacementProperty()) @@ -2115,7 +2134,8 @@ void ViewProviderLink::finishRestoring() { bool ViewProviderLink::hasElements(const App::LinkBaseExtension *ext) const { if(!ext) { ext = getLinkExtension(); - if(!ext) return false; + if(!ext) + return false; } const auto &elements = ext->getElementListValue(); return elements.size() && (int)elements.size()==ext->_getElementCountValue(); @@ -2124,7 +2144,8 @@ bool ViewProviderLink::hasElements(const App::LinkBaseExtension *ext) const { bool ViewProviderLink::isGroup(const App::LinkBaseExtension *ext, bool plainGroup) const { if(!ext) { ext = getLinkExtension(); - if(!ext) return false; + if(!ext) + return false; } return (plainGroup && ext->linkedPlainGroup()) || (ext->getElementListProperty() && !ext->getLinkedObjectProperty()); @@ -2297,7 +2318,8 @@ std::string ViewProviderLink::dropObjectEx(App::DocumentObject* obj, bool ViewProviderLink::canDragAndDropObject(App::DocumentObject* obj) const { auto ext = getLinkExtension(); - if(!ext) return true; + if(!ext) + return true; if(isGroup(ext)) { return ext->getLinkModeValue()getDocument()==getObject()->getDocument(); @@ -2313,9 +2335,11 @@ bool ViewProviderLink::canDragAndDropObject(App::DocumentObject* obj) const { } bool ViewProviderLink::getElementPicked(const SoPickedPoint *pp, std::string &subname) const { - if(!isSelectable()) return false; + if(!isSelectable()) + return false; auto ext = getLinkExtension(); - if(!ext) return false; + if(!ext) + return false; if(childVpLink && childVp) { auto path = pp->getPath(); int idx = path->findNode(childVpLink->getSnapshot(LinkView::SnapshotTransform)); @@ -2342,7 +2366,8 @@ bool ViewProviderLink::getDetailPath( const char *subname, SoFullPath *pPath, bool append, SoDetail *&det) const { auto ext = getLinkExtension(); - if(!ext) return false; + if(!ext) + return false; auto len = pPath->getLength(); if(append) { @@ -2963,7 +2988,8 @@ void ViewProviderLink::updateDraggingPlacement(const Base::Placement &pla, bool } bool ViewProviderLink::callDraggerProxy(const char *fname, bool update) { - if(!pcDragger) return false; + if(!pcDragger) + return false; Base::PyGILStateLocker lock; try { auto* proxy = getPropertyByName("Proxy"); @@ -3341,7 +3367,8 @@ void ViewProviderLink::applyColors() { void ViewProviderLink::setOverrideMode(const std::string &mode) { auto ext = getLinkExtension(); - if(!ext) return; + if(!ext) + return; auto obj = ext->getTrueLinkedObject(false); if(obj && obj!=getObject()) { auto vp = Application::Instance->getViewProvider(obj); diff --git a/src/Gui/ViewProviderPythonFeature.cpp b/src/Gui/ViewProviderPythonFeature.cpp index 3de75aad5f..0085bcb537 100644 --- a/src/Gui/ViewProviderPythonFeature.cpp +++ b/src/Gui/ViewProviderPythonFeature.cpp @@ -465,7 +465,8 @@ ViewProviderPythonFeatureImp::getElementPicked(const SoPickedPoint *pp, std::str Py::Tuple args(1); args.setItem(0, Py::Object(pivy, true)); Py::Object ret(Base::pyCall(py_getElementPicked.ptr(),args.ptr())); - if(!ret.isString()) return Rejected; + if(!ret.isString()) + return Rejected; subname = ret.as_string(); return Accepted; } From b5c72abee4477e11124fc1296f3c06d02f6f75e9 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 12:34:34 -0500 Subject: [PATCH 16/39] Base: PR6497 move return statement to new line --- src/Base/Console.cpp | 3 +- src/Base/FileInfo.cpp | 9 ++- src/Base/GeometryPyCXX.cpp | 3 +- src/Base/Interpreter.cpp | 3 +- src/Base/Matrix.cpp | 3 +- src/Base/Parameter.cpp | 12 ++-- src/Base/Quantity.cpp | 3 +- src/Base/StackWalker.cpp | 3 +- src/Base/Tools2D.cpp | 9 ++- src/Base/Unit.cpp | 117 ++++++++++++++++++++++++------------- 10 files changed, 110 insertions(+), 55 deletions(-) diff --git a/src/Base/Console.cpp b/src/Base/Console.cpp index d10c714556..db41dbbac3 100644 --- a/src/Base/Console.cpp +++ b/src/Base/Console.cpp @@ -409,7 +409,8 @@ int *ConsoleSingleton::GetLogLevel(const char *tag, bool create) { if (!tag) tag = ""; if (_logLevels.find(tag) != _logLevels.end()) return &_logLevels[tag]; - if (!create) return nullptr; + if (!create) + return nullptr; int &ret = _logLevels[tag]; ret = -1; return &ret; diff --git a/src/Base/FileInfo.cpp b/src/Base/FileInfo.cpp index a6e26eba0e..106255d39f 100644 --- a/src/Base/FileInfo.cpp +++ b/src/Base/FileInfo.cpp @@ -377,7 +377,8 @@ bool FileInfo::isFile () const // If we can open it must be an existing file, otherwise we assume it // is a directory (which doesn't need to be true for any cases) std::ifstream str(FileName.c_str(), std::ios::in | std::ios::binary); - if (!str) return false; + if (!str) + return false; str.close(); return true; } @@ -551,7 +552,8 @@ bool FileInfo::createDirectories() const bool FileInfo::deleteDirectory() const { - if (isDir() == false ) return false; + if (isDir() == false ) + return false; #if defined (FC_OS_WIN32) std::wstring wstr = toStdWString(); return _wrmdir(wstr.c_str()) == 0; @@ -564,7 +566,8 @@ bool FileInfo::deleteDirectory() const bool FileInfo::deleteDirectoryRecursive() const { - if (isDir() == false ) return false; + if (isDir() == false ) + return false; std::vector List = getDirectoryContent(); for (std::vector::iterator It = List.begin();It!=List.end();++It) { diff --git a/src/Base/GeometryPyCXX.cpp b/src/Base/GeometryPyCXX.cpp index 5d6fafb789..032e5a8238 100644 --- a/src/Base/GeometryPyCXX.cpp +++ b/src/Base/GeometryPyCXX.cpp @@ -61,7 +61,8 @@ Py::Vector::Vector (const Base::Vector3f& v) Py::Vector& Py::Vector::operator= (PyObject* rhsp) { - if(ptr() == rhsp) return *this; + if(ptr() == rhsp) + return *this; set (rhsp, false); return *this; } diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp index 3721150a9f..558a14d4d6 100644 --- a/src/Base/Interpreter.cpp +++ b/src/Base/Interpreter.cpp @@ -511,7 +511,8 @@ void InterpreterSingleton::addType(PyTypeObject* Type,PyObject* Module, const ch // NOTE: To finish the initialization of our own type objects we must // call PyType_Ready, otherwise we run into a segmentation fault, later on. // This function is responsible for adding inherited slots from a type's base class. - if (PyType_Ready(Type) < 0) return; + if (PyType_Ready(Type) < 0) + return; union PyType_Object pyType = {Type}; PyModule_AddObject(Module, Name, pyType.o); } diff --git a/src/Base/Matrix.cpp b/src/Base/Matrix.cpp index 06eba0c295..6c7cc228d6 100644 --- a/src/Base/Matrix.cpp +++ b/src/Base/Matrix.cpp @@ -539,7 +539,8 @@ void Matrix_gauss(Matrix a, Matrix b) } indxr[i] = irow; indxc[i] = icol; - if (a[4*icol+icol] == 0.0) return; + if (a[4*icol+icol] == 0.0) + return; pivinv = 1.0/a[4*icol+icol]; a[4*icol+icol] = 1.0; for (l = 0; l < 4; l++) diff --git a/src/Base/Parameter.cpp b/src/Base/Parameter.cpp index f2158a8ba8..5ab8eefef9 100644 --- a/src/Base/Parameter.cpp +++ b/src/Base/Parameter.cpp @@ -413,7 +413,8 @@ bool ParameterGrp::GetBool(const char* Name, bool bPreset) const // check if Element in group DOMElement *pcElem = FindElement(_pGroupNode,"FCBool",Name); // if not return preset - if (!pcElem) return bPreset; + if (!pcElem) + return bPreset; // if yes check the value and return if (strcmp(StrX(pcElem->getAttribute(XStr("Value").unicodeForm())).c_str(),"1")) return false; @@ -480,7 +481,8 @@ long ParameterGrp::GetInt(const char* Name, long lPreset) const // check if Element in group DOMElement *pcElem = FindElement(_pGroupNode,"FCInt",Name); // if not return preset - if (!pcElem) return lPreset; + if (!pcElem) + return lPreset; // if yes check the value and return return atol (StrX(pcElem->getAttribute(XStr("Value").unicodeForm())).c_str()); } @@ -541,7 +543,8 @@ unsigned long ParameterGrp::GetUnsigned(const char* Name, unsigned long lPreset) // check if Element in group DOMElement *pcElem = FindElement(_pGroupNode,"FCUInt",Name); // if not return preset - if (!pcElem) return lPreset; + if (!pcElem) + return lPreset; // if yes check the value and return return strtoul (StrX(pcElem->getAttribute(XStr("Value").unicodeForm())).c_str(),nullptr,10); } @@ -602,7 +605,8 @@ double ParameterGrp::GetFloat(const char* Name, double dPreset) const // check if Element in group DOMElement *pcElem = FindElement(_pGroupNode,"FCFloat",Name); // if not return preset - if (!pcElem) return dPreset; + if (!pcElem) + return dPreset; // if yes check the value and return return atof (StrX(pcElem->getAttribute(XStr("Value").unicodeForm())).c_str()); } diff --git a/src/Base/Quantity.cpp b/src/Base/Quantity.cpp index b92aa8073e..16ac75f295 100644 --- a/src/Base/Quantity.cpp +++ b/src/Base/Quantity.cpp @@ -430,7 +430,8 @@ double num_change(char* yytext,char dez_delim,char grp_delim) else temp[i++] = *c; // check buffer overflow - if (i>39) return 0.0; + if (i>39) + return 0.0; } temp[i] = '\0'; diff --git a/src/Base/StackWalker.cpp b/src/Base/StackWalker.cpp index b713be014a..cec306306b 100644 --- a/src/Base/StackWalker.cpp +++ b/src/Base/StackWalker.cpp @@ -242,7 +242,8 @@ DWORD64 static void MyStrCpy(char* szDest, size_t nMaxDestSize, const char* szSrc) { - if (nMaxDestSize <= 0) return; + if (nMaxDestSize <= 0) + return; if (strlen(szSrc) < nMaxDestSize) { strcpy_s(szDest, nMaxDestSize, szSrc); diff --git a/src/Base/Tools2D.cpp b/src/Base/Tools2D.cpp index 14ef848496..84eabf5512 100644 --- a/src/Base/Tools2D.cpp +++ b/src/Base/Tools2D.cpp @@ -145,7 +145,8 @@ bool BoundBox2d::Intersect(const Polygon2d &rclPoly) const return true; /***** RETURN INTERSECTION *********/ // test intersections of bound-lines - if (rclPoly.GetCtVectors() < 3) return false; + if (rclPoly.GetCtVectors() < 3) + return false; for (i = 0; i < rclPoly.GetCtVectors(); i++) { if (i == rclPoly.GetCtVectors() - 1) @@ -288,7 +289,8 @@ static short _CalcTorsion (double *pfLine, double fX, double fY) // Abort at line points within a quadrant // Abort at non-intersecting line points - if (abs (sQuad[0] - sQuad[1]) <= 1) return 0; + if (abs (sQuad[0] - sQuad[1]) <= 1) + return 0; // Both points to the left of ulX if (abs (sQuad[0] - sQuad[1]) == 3) @@ -317,7 +319,8 @@ bool Polygon2d::Contains (const Vector2d &rclV) const short sTorsion = 0; // Error check - if (GetCtVectors() < 3) return false; + if (GetCtVectors() < 3) + return false; // for all polygon lines for (i = 0; i < GetCtVectors(); i++) diff --git a/src/Base/Unit.cpp b/src/Base/Unit.cpp index 596e072dd1..9e00bd98f4 100644 --- a/src/Base/Unit.cpp +++ b/src/Base/Unit.cpp @@ -426,45 +426,84 @@ QString Unit::getString() const QString Unit::getTypeString() const { - if(*this == Unit::Length ) return QString::fromLatin1("Length"); - if(*this == Unit::Area ) return QString::fromLatin1("Area"); - if(*this == Unit::Volume ) return QString::fromLatin1("Volume"); - if(*this == Unit::Mass ) return QString::fromLatin1("Mass"); - if(*this == Unit::Angle ) return QString::fromLatin1("Angle"); - if(*this == Unit::Density ) return QString::fromLatin1("Density"); - if(*this == Unit::TimeSpan ) return QString::fromLatin1("TimeSpan"); - if(*this == Unit::Frequency ) return QString::fromLatin1("Frequency"); - if(*this == Unit::Velocity ) return QString::fromLatin1("Velocity"); - if(*this == Unit::Acceleration ) return QString::fromLatin1("Acceleration"); - if(*this == Unit::Temperature ) return QString::fromLatin1("Temperature"); - if(*this == Unit::ElectricCurrent ) return QString::fromLatin1("ElectricCurrent"); - if(*this == Unit::ElectricPotential ) return QString::fromLatin1("ElectricPotential"); - if(*this == Unit::ElectricCharge ) return QString::fromLatin1("ElectricCharge"); - if(*this == Unit::MagneticFieldStrength ) return QString::fromLatin1("MagneticFieldStrength"); - if(*this == Unit::MagneticFlux ) return QString::fromLatin1("MagneticFlux"); - if(*this == Unit::MagneticFluxDensity ) return QString::fromLatin1("MagneticFluxDensity"); - if(*this == Unit::ElectricalCapacitance ) return QString::fromLatin1("ElectricalCapacitance"); - if(*this == Unit::ElectricalInductance ) return QString::fromLatin1("ElectricalInductance"); - if(*this == Unit::ElectricalConductance ) return QString::fromLatin1("ElectricalConductance"); - if(*this == Unit::ElectricalResistance ) return QString::fromLatin1("ElectricalResistance"); - if(*this == Unit::ElectricalConductivity ) return QString::fromLatin1("ElectricalConductivity"); - if(*this == Unit::AmountOfSubstance ) return QString::fromLatin1("AmountOfSubstance"); - if(*this == Unit::LuminousIntensity ) return QString::fromLatin1("LuminousIntensity"); - if(*this == Unit::Pressure ) return QString::fromLatin1("Pressure"); - if(*this == Unit::Force ) return QString::fromLatin1("Force"); - if(*this == Unit::Work ) return QString::fromLatin1("Work"); - if(*this == Unit::Power ) return QString::fromLatin1("Power"); - if(*this == Unit::Stiffness ) return QString::fromLatin1("Stiffness"); - if(*this == Unit::SpecificEnergy ) return QString::fromLatin1("SpecificEnergy"); - if(*this == Unit::ThermalConductivity ) return QString::fromLatin1("ThermalConductivity"); - if(*this == Unit::ThermalExpansionCoefficient ) return QString::fromLatin1("ThermalExpansionCoefficient"); - if(*this == Unit::VolumetricThermalExpansionCoefficient ) return QString::fromLatin1("VolumetricThermalExpansionCoefficient"); - if(*this == Unit::SpecificHeat ) return QString::fromLatin1("SpecificHeat"); - if(*this == Unit::ThermalTransferCoefficient ) return QString::fromLatin1("ThermalTransferCoefficient"); - if(*this == Unit::HeatFlux ) return QString::fromLatin1("HeatFlux"); - if(*this == Unit::DynamicViscosity ) return QString::fromLatin1("DynamicViscosity"); - if(*this == Unit::KinematicViscosity ) return QString::fromLatin1("KinematicViscosity"); - if(*this == Unit::VacuumPermittivity ) return QString::fromLatin1("VacuumPermittivity"); + if(*this == Unit::Length ) + return QString::fromLatin1("Length"); + if(*this == Unit::Area ) + return QString::fromLatin1("Area"); + if(*this == Unit::Volume ) + return QString::fromLatin1("Volume"); + if(*this == Unit::Mass ) + return QString::fromLatin1("Mass"); + if(*this == Unit::Angle ) + return QString::fromLatin1("Angle"); + if(*this == Unit::Density ) + return QString::fromLatin1("Density"); + if(*this == Unit::TimeSpan ) + return QString::fromLatin1("TimeSpan"); + if(*this == Unit::Frequency ) + return QString::fromLatin1("Frequency"); + if(*this == Unit::Velocity ) + return QString::fromLatin1("Velocity"); + if(*this == Unit::Acceleration ) + return QString::fromLatin1("Acceleration"); + if(*this == Unit::Temperature ) + return QString::fromLatin1("Temperature"); + if(*this == Unit::ElectricCurrent ) + return QString::fromLatin1("ElectricCurrent"); + if(*this == Unit::ElectricPotential ) + return QString::fromLatin1("ElectricPotential"); + if(*this == Unit::ElectricCharge ) + return QString::fromLatin1("ElectricCharge"); + if(*this == Unit::MagneticFieldStrength ) + return QString::fromLatin1("MagneticFieldStrength"); + if(*this == Unit::MagneticFlux ) + return QString::fromLatin1("MagneticFlux"); + if(*this == Unit::MagneticFluxDensity ) + return QString::fromLatin1("MagneticFluxDensity"); + if(*this == Unit::ElectricalCapacitance ) + return QString::fromLatin1("ElectricalCapacitance"); + if(*this == Unit::ElectricalInductance ) + return QString::fromLatin1("ElectricalInductance"); + if(*this == Unit::ElectricalConductance ) + return QString::fromLatin1("ElectricalConductance"); + if(*this == Unit::ElectricalResistance ) + return QString::fromLatin1("ElectricalResistance"); + if(*this == Unit::ElectricalConductivity ) + return QString::fromLatin1("ElectricalConductivity"); + if(*this == Unit::AmountOfSubstance ) + return QString::fromLatin1("AmountOfSubstance"); + if(*this == Unit::LuminousIntensity ) + return QString::fromLatin1("LuminousIntensity"); + if(*this == Unit::Pressure ) + return QString::fromLatin1("Pressure"); + if(*this == Unit::Force ) + return QString::fromLatin1("Force"); + if(*this == Unit::Work ) + return QString::fromLatin1("Work"); + if(*this == Unit::Power ) + return QString::fromLatin1("Power"); + if(*this == Unit::Stiffness ) + return QString::fromLatin1("Stiffness"); + if(*this == Unit::SpecificEnergy ) + return QString::fromLatin1("SpecificEnergy"); + if(*this == Unit::ThermalConductivity ) + return QString::fromLatin1("ThermalConductivity"); + if(*this == Unit::ThermalExpansionCoefficient ) + return QString::fromLatin1("ThermalExpansionCoefficient"); + if(*this == Unit::VolumetricThermalExpansionCoefficient ) + return QString::fromLatin1("VolumetricThermalExpansionCoefficient"); + if(*this == Unit::SpecificHeat ) + return QString::fromLatin1("SpecificHeat"); + if(*this == Unit::ThermalTransferCoefficient ) + return QString::fromLatin1("ThermalTransferCoefficient"); + if(*this == Unit::HeatFlux ) + return QString::fromLatin1("HeatFlux"); + if(*this == Unit::DynamicViscosity ) + return QString::fromLatin1("DynamicViscosity"); + if(*this == Unit::KinematicViscosity ) + return QString::fromLatin1("KinematicViscosity"); + if(*this == Unit::VacuumPermittivity ) + return QString::fromLatin1("VacuumPermittivity"); return QString(); From 4e15c4876531f57cacb0c6bd8310db50bd091431 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 12:35:10 -0500 Subject: [PATCH 17/39] Tools: PR6497 move return statement to new line --- src/Tools/thumbs/FCStdExtractor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Tools/thumbs/FCStdExtractor.cpp b/src/Tools/thumbs/FCStdExtractor.cpp index d0f9904880..fa04b37a7c 100644 --- a/src/Tools/thumbs/FCStdExtractor.cpp +++ b/src/Tools/thumbs/FCStdExtractor.cpp @@ -222,7 +222,8 @@ HRESULT CFCStdExtractor::GetLocation(LPWSTR pszPathBuffer, DWORD *pdwFlags) { m_bmSize = *prgSize; - if (*pdwFlags & IEIFLAG_ASYNC) return E_PENDING; + if (*pdwFlags & IEIFLAG_ASYNC) + return E_PENDING; return NOERROR; } @@ -297,7 +298,8 @@ HRESULT CFCStdExtractor::GetDateStamp(FILETIME *pDateStamp) // open the file and get last write time HANDLE hFile = CreateFile(m_szFile,GENERIC_READ,FILE_SHARE_READ,NULL, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); - if(!hFile) return E_FAIL; + if(!hFile) + return E_FAIL; GetFileTime(hFile,&ftCreationTime,&ftLastAccessTime,&ftLastWriteTime); CloseHandle(hFile); *pDateStamp = ftLastWriteTime; From f442b7d36d08b62be8c32fbefade848409ee1087 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 12:35:46 -0500 Subject: [PATCH 18/39] Draft: PR6497 move return statement to new line --- src/Mod/Draft/App/dxf.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Mod/Draft/App/dxf.cpp b/src/Mod/Draft/App/dxf.cpp index 4331bbd985..95aeb636d3 100644 --- a/src/Mod/Draft/App/dxf.cpp +++ b/src/Mod/Draft/App/dxf.cpp @@ -1089,7 +1089,8 @@ bool CDxfRead::ReadLwPolyLine() case 70: // flags get_line(); - if(sscanf(m_str, "%d", &flags) != 1)return false; + if(sscanf(m_str, "%d", &flags) != 1) + return false; closed = ((flags & 1) != 0); break; case 62: @@ -1249,7 +1250,8 @@ bool CDxfRead::ReadPolyLine() case 70: // flags get_line(); - if(sscanf(m_str, "%d", &flags) != 1)return false; + if(sscanf(m_str, "%d", &flags) != 1) + return false; closed = ((flags & 1) != 0); break; case 62: @@ -1649,7 +1651,8 @@ bool CDxfRead::ReadLayer() case 62: // layer color ; if negative, layer is off get_line(); - if(sscanf(m_str, "%d", &aci) != 1)return false; + if(sscanf(m_str, "%d", &aci) != 1) + return false; break; case 6: // linetype name @@ -1673,14 +1676,16 @@ bool CDxfRead::ReadLayer() void CDxfRead::DoRead(const bool ignore_errors /* = false */ ) { m_ignore_errors = ignore_errors; - if(m_fail)return; + if(m_fail) + return; get_line(); while(!((*m_ifs).eof())) { if (!strcmp( m_str, "$INSUNITS" )){ - if (!ReadUnits())return; + if (!ReadUnits()) + return; continue; } // End if - then From cb9c4ad696523b88f8e80a53b775d19e926b35a5 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 12:35:58 -0500 Subject: [PATCH 19/39] FEM: PR6497 move return statement to new line --- src/Mod/Fem/App/FemMeshPyImp.cpp | 3 ++- src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp | 21 ++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Mod/Fem/App/FemMeshPyImp.cpp b/src/Mod/Fem/App/FemMeshPyImp.cpp index b50c943a3e..4d18185fdb 100644 --- a/src/Mod/Fem/App/FemMeshPyImp.cpp +++ b/src/Mod/Fem/App/FemMeshPyImp.cpp @@ -85,7 +85,8 @@ int FemMeshPy::PyInit(PyObject* args, PyObject* /*kwd*/) try { // if no mesh is given - if (!pcObj) return 0; + if (!pcObj) + return 0; if (PyObject_TypeCheck(pcObj, &(FemMeshPy::Type))) { getFemMeshPtr()->operator= (*static_cast(pcObj)->getFemMeshPtr()); } diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp index b155a90330..483474005f 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp @@ -502,19 +502,26 @@ void ViewProviderFemConstraint::checkForWizard() wizardWidget= nullptr; wizardSubLayout = nullptr; Gui::MainWindow* mw = Gui::getMainWindow(); - if (mw == nullptr) return; + if (mw == nullptr) + return; QDockWidget* dw = mw->findChild(QString::fromLatin1("Combo View")); - if (dw == nullptr) return; + if (dw == nullptr) + return; QWidget* cw = dw->findChild(QString::fromLatin1("Combo View")); - if (cw == nullptr) return; + if (cw == nullptr) + return; QTabWidget* tw = cw->findChild(QString::fromLatin1("combiTab")); - if (tw == nullptr) return; + if (tw == nullptr) + return; QStackedWidget* sw = tw->findChild(QString::fromLatin1("qt_tabwidget_stackedwidget")); - if (sw == nullptr) return; + if (sw == nullptr) + return; QScrollArea* sa = sw->findChild(); - if (sa== nullptr) return; + if (sa== nullptr) + return; QWidget* wd = sa->widget(); // This is the reason why we cannot use findChildByName() right away!!! - if (wd == nullptr) return; + if (wd == nullptr) + return; QObject* wiz = findChildByName(wd, QString::fromLatin1("ShaftWizard")); if (wiz != nullptr) { wizardWidget = static_cast(wiz); From a9c33d8f58404e5e80681bef1d1b82c17653dbd4 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 12:36:18 -0500 Subject: [PATCH 20/39] Import: PR6497 move return statement to new line --- src/Mod/Import/App/dxf.cpp | 15 ++++++++++----- src/Mod/Import/Gui/AppImportGuiPy.cpp | 6 ++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Mod/Import/App/dxf.cpp b/src/Mod/Import/App/dxf.cpp index 874f33e79e..21fc50a1a5 100644 --- a/src/Mod/Import/App/dxf.cpp +++ b/src/Mod/Import/App/dxf.cpp @@ -2675,7 +2675,8 @@ bool CDxfRead::ReadLwPolyLine() case 70: // flags get_line(); - if(sscanf(m_str, "%d", &flags) != 1)return false; + if(sscanf(m_str, "%d", &flags) != 1) + return false; closed = ((flags & 1) != 0); break; case 62: @@ -2835,7 +2836,8 @@ bool CDxfRead::ReadPolyLine() case 70: // flags get_line(); - if(sscanf(m_str, "%d", &flags) != 1)return false; + if(sscanf(m_str, "%d", &flags) != 1) + return false; closed = ((flags & 1) != 0); break; case 62: @@ -3235,7 +3237,8 @@ bool CDxfRead::ReadLayer() case 62: // layer color ; if negative, layer is off get_line(); - if(sscanf(m_str, "%d", &aci) != 1)return false; + if(sscanf(m_str, "%d", &aci) != 1) + return false; break; case 6: // linetype name @@ -3259,14 +3262,16 @@ bool CDxfRead::ReadLayer() void CDxfRead::DoRead(const bool ignore_errors /* = false */ ) { m_ignore_errors = ignore_errors; - if(m_fail)return; + if(m_fail) + return; get_line(); while(!((*m_ifs).eof())) { if (!strcmp( m_str, "$INSUNITS" )){ - if (!ReadUnits())return; + if (!ReadUnits()) + return; continue; } // End if - then diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index b7b6bb1ac8..ba5cc4cc3b 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -298,7 +298,8 @@ public: private: virtual void applyFaceColors(Part::Feature* part, const std::vector& colors) override { auto vp = dynamic_cast(Gui::Application::Instance->getViewProvider(part)); - if (!vp) return; + if (!vp) + return; if(colors.empty()) { // vp->MapFaceColor.setValue(true); // vp->MapLineColor.setValue(true); @@ -316,7 +317,8 @@ private: } virtual void applyEdgeColors(Part::Feature* part, const std::vector& colors) override { auto vp = dynamic_cast(Gui::Application::Instance->getViewProvider(part)); - if (!vp) return; + if (!vp) + return; // vp->MapLineColor.setValue(false); if(colors.size() == 1) vp->LineColor.setValue(colors.front()); From 3ecd16e0bd84dfa082e10f68a496a67a90e06703 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 12:36:30 -0500 Subject: [PATCH 21/39] Mesh: PR6497 move return statement to new line --- src/Mod/Mesh/App/Core/Algorithm.cpp | 3 ++- src/Mod/Mesh/App/Core/Builder.cpp | 3 ++- src/Mod/Mesh/App/Core/Degeneration.cpp | 11 +++++--- src/Mod/Mesh/App/Core/MeshIO.cpp | 3 ++- src/Mod/Mesh/App/Core/TopoAlgorithm.cpp | 6 +++-- src/Mod/Mesh/App/Core/Triangulation.cpp | 12 ++++++--- src/Mod/Mesh/App/FeatureMeshDefects.cpp | 30 ++++++++++++++-------- src/Mod/Mesh/App/Mesh.cpp | 4 ++- src/Mod/Mesh/App/MeshPyImp.cpp | 9 ++++--- src/Mod/Mesh/Gui/Command.cpp | 12 ++++++--- src/Mod/Mesh/Gui/MeshSelection.cpp | 3 ++- src/Mod/Mesh/Gui/RemoveComponents.cpp | 3 ++- src/Mod/Mesh/Gui/SoFCIndexedFaceSet.cpp | 12 ++++++--- src/Mod/Mesh/Gui/SoFCMeshFaceSet.cpp | 16 ++++++++---- src/Mod/Mesh/Gui/SoFCMeshNode.cpp | 9 ++++--- src/Mod/Mesh/Gui/SoFCMeshObject.cpp | 24 +++++++++++------ src/Mod/Mesh/Gui/SoFCMeshVertex.cpp | 10 +++++--- src/Mod/Mesh/Gui/SoPolygon.cpp | 12 ++++++--- src/Mod/Mesh/Gui/ViewProvider.cpp | 6 +++-- src/Mod/Mesh/Gui/ViewProviderCurvature.cpp | 3 ++- src/Mod/Mesh/Gui/ViewProviderMeshNode.cpp | 3 ++- 21 files changed, 131 insertions(+), 63 deletions(-) diff --git a/src/Mod/Mesh/App/Core/Algorithm.cpp b/src/Mod/Mesh/App/Core/Algorithm.cpp index e63cdc721e..298246ffe2 100644 --- a/src/Mod/Mesh/App/Core/Algorithm.cpp +++ b/src/Mod/Mesh/App/Core/Algorithm.cpp @@ -789,7 +789,8 @@ bool MeshAlgorithm::FillupHole(const std::vector& boundary, void MeshAlgorithm::SetFacetsProperty(const std::vector &raulInds, const std::vector &raulProps) const { - if (raulInds.size() != raulProps.size()) return; + if (raulInds.size() != raulProps.size()) + return; std::vector::const_iterator iP = raulProps.begin(); for (std::vector::const_iterator i = raulInds.begin(); i != raulInds.end(); ++i, ++iP) diff --git a/src/Mod/Mesh/App/Core/Builder.cpp b/src/Mod/Mesh/App/Core/Builder.cpp index e32a2bfcf8..248f758df5 100644 --- a/src/Mod/Mesh/App/Core/Builder.cpp +++ b/src/Mod/Mesh/App/Core/Builder.cpp @@ -275,7 +275,8 @@ struct MeshFastBuilder::Private { } bool operator<(const Vertex& rhs) const { - if (x != rhs.x) return x < rhs.x; + if (x != rhs.x) + return x < rhs.x; else if (y != rhs.y) return y < rhs.y; else if (z != rhs.z) return z < rhs.z; else return false; diff --git a/src/Mod/Mesh/App/Core/Degeneration.cpp b/src/Mod/Mesh/App/Core/Degeneration.cpp index 321a22259b..02b06a0ff3 100644 --- a/src/Mod/Mesh/App/Core/Degeneration.cpp +++ b/src/Mod/Mesh/App/Core/Degeneration.cpp @@ -301,7 +301,8 @@ struct MeshFacet_Less if (y1 > y2) { tmp = y1; y1 = y2; y2 = tmp; } - if (x0 < y0) return true; + if (x0 < y0) + return true; else if (x0 > y0) return false; else if (x1 < y1) return true; else if (x1 > y1) return false; @@ -1065,7 +1066,9 @@ bool MeshEvalRangePoint::Evaluate() PointIndex ulCtPoints = _rclMesh.CountPoints(); for (MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it) { - if (std::find_if(it->_aulPoints, it->_aulPoints + 3, [ulCtPoints](PointIndex i) { return i >= ulCtPoints; }) < it->_aulPoints + 3) + if (std::find_if(it->_aulPoints, it->_aulPoints + 3, [ulCtPoints](PointIndex i) { + return i >= ulCtPoints; + }) < it->_aulPoints + 3) return false; } @@ -1080,7 +1083,9 @@ std::vector MeshEvalRangePoint::GetIndices() const PointIndex ind=0; for (MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it, ind++) { - if (std::find_if(it->_aulPoints, it->_aulPoints + 3, [ulCtPoints](PointIndex i) { return i >= ulCtPoints; }) < it->_aulPoints + 3) + if (std::find_if(it->_aulPoints, it->_aulPoints + 3, [ulCtPoints](PointIndex i) { + return i >= ulCtPoints; + }) < it->_aulPoints + 3) aInds.push_back(ind); } diff --git a/src/Mod/Mesh/App/Core/MeshIO.cpp b/src/Mod/Mesh/App/Core/MeshIO.cpp index eca94ac74d..f338d623be 100644 --- a/src/Mod/Mesh/App/Core/MeshIO.cpp +++ b/src/Mod/Mesh/App/Core/MeshIO.cpp @@ -250,7 +250,8 @@ bool MeshInput::LoadSTL (std::istream &rstrIn) // the file size has only 134 bytes in this case. On the other hand we must overread the first 80 bytes // because it can happen that the file is binary but contains one of these keywords. std::streambuf* buf = rstrIn.rdbuf(); - if (!buf) return false; + if (!buf) + return false; buf->pubseekoff(80, std::ios::beg, std::ios::in); uint32_t ulCt, ulBytes=50; rstrIn.read((char*)&ulCt, sizeof(ulCt)); diff --git a/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp b/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp index 22f9d7d2a6..ab36dcc34b 100644 --- a/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp +++ b/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp @@ -1406,7 +1406,8 @@ void MeshTopoAlgorithm::SplitNeighbourFacet(FacetIndex ulFacetPos, unsigned shor bool MeshTopoAlgorithm::RemoveDegeneratedFacet(FacetIndex index) { - if (index >= _rclMesh._aclFacetArray.size()) return false; + if (index >= _rclMesh._aclFacetArray.size()) + return false; MeshFacet& rFace = _rclMesh._aclFacetArray[index]; // coincident corners (either topological or geometrical) @@ -1475,7 +1476,8 @@ bool MeshTopoAlgorithm::RemoveDegeneratedFacet(FacetIndex index) bool MeshTopoAlgorithm::RemoveCorruptedFacet(FacetIndex index) { - if (index >= _rclMesh._aclFacetArray.size()) return false; + if (index >= _rclMesh._aclFacetArray.size()) + return false; MeshFacet& rFace = _rclMesh._aclFacetArray[index]; // coincident corners (topological) diff --git a/src/Mod/Mesh/App/Core/Triangulation.cpp b/src/Mod/Mesh/App/Core/Triangulation.cpp index 799e806e0e..6c0fa88766 100644 --- a/src/Mod/Mesh/App/Core/Triangulation.cpp +++ b/src/Mod/Mesh/App/Core/Triangulation.cpp @@ -383,13 +383,15 @@ bool EarClippingTriangulator::Triangulate::Snip(const std::vector (((Bx-Ax)*(Cy-Ay)) - ((By-Ay)*(Cx-Ax)))) return false; + if (FLOAT_EPS > (((Bx-Ax)*(Cy-Ay)) - ((By-Ay)*(Cx-Ax)))) + return false; for (p=0;pgetPropertyByName("Mesh"); if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); @@ -107,7 +108,8 @@ FlipNormals::~FlipNormals() App::DocumentObjectExecReturn *FlipNormals::execute() { App::DocumentObject* link = Source.getValue(); - if (!link) return new App::DocumentObjectExecReturn("No mesh linked"); + if (!link) + return new App::DocumentObjectExecReturn("No mesh linked"); App::Property* prop = link->getPropertyByName("Mesh"); if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); @@ -135,7 +137,8 @@ FixNonManifolds::~FixNonManifolds() App::DocumentObjectExecReturn *FixNonManifolds::execute() { App::DocumentObject* link = Source.getValue(); - if (!link) return new App::DocumentObjectExecReturn("No mesh linked"); + if (!link) + return new App::DocumentObjectExecReturn("No mesh linked"); App::Property* prop = link->getPropertyByName("Mesh"); if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); @@ -163,7 +166,8 @@ FixDuplicatedFaces::~FixDuplicatedFaces() App::DocumentObjectExecReturn *FixDuplicatedFaces::execute() { App::DocumentObject* link = Source.getValue(); - if (!link) return new App::DocumentObjectExecReturn("No mesh linked"); + if (!link) + return new App::DocumentObjectExecReturn("No mesh linked"); App::Property* prop = link->getPropertyByName("Mesh"); if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); @@ -191,7 +195,8 @@ FixDuplicatedPoints::~FixDuplicatedPoints() App::DocumentObjectExecReturn *FixDuplicatedPoints::execute() { App::DocumentObject* link = Source.getValue(); - if (!link) return new App::DocumentObjectExecReturn("No mesh linked"); + if (!link) + return new App::DocumentObjectExecReturn("No mesh linked"); App::Property* prop = link->getPropertyByName("Mesh"); if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); @@ -219,7 +224,8 @@ FixDegenerations::~FixDegenerations() App::DocumentObjectExecReturn *FixDegenerations::execute() { App::DocumentObject* link = Source.getValue(); - if (!link) return new App::DocumentObjectExecReturn("No mesh linked"); + if (!link) + return new App::DocumentObjectExecReturn("No mesh linked"); App::Property* prop = link->getPropertyByName("Mesh"); if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); @@ -248,7 +254,8 @@ FixDeformations::~FixDeformations() App::DocumentObjectExecReturn *FixDeformations::execute() { App::DocumentObject* link = Source.getValue(); - if (!link) return new App::DocumentObjectExecReturn("No mesh linked"); + if (!link) + return new App::DocumentObjectExecReturn("No mesh linked"); App::Property* prop = link->getPropertyByName("Mesh"); if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); @@ -278,7 +285,8 @@ FixIndices::~FixIndices() App::DocumentObjectExecReturn *FixIndices::execute() { App::DocumentObject* link = Source.getValue(); - if (!link) return new App::DocumentObjectExecReturn("No mesh linked"); + if (!link) + return new App::DocumentObjectExecReturn("No mesh linked"); App::Property* prop = link->getPropertyByName("Mesh"); if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); @@ -308,7 +316,8 @@ FillHoles::~FillHoles() App::DocumentObjectExecReturn *FillHoles::execute() { App::DocumentObject* link = Source.getValue(); - if (!link) return new App::DocumentObjectExecReturn("No mesh linked"); + if (!link) + return new App::DocumentObjectExecReturn("No mesh linked"); App::Property* prop = link->getPropertyByName("Mesh"); if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); @@ -339,7 +348,8 @@ RemoveComponents::~RemoveComponents() App::DocumentObjectExecReturn *RemoveComponents::execute() { App::DocumentObject* link = Source.getValue(); - if (!link) return new App::DocumentObjectExecReturn("No mesh linked"); + if (!link) + return new App::DocumentObjectExecReturn("No mesh linked"); App::Property* prop = link->getPropertyByName("Mesh"); if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); diff --git a/src/Mod/Mesh/App/Mesh.cpp b/src/Mod/Mesh/App/Mesh.cpp index 4aeafa3f1d..b7475173a1 100644 --- a/src/Mod/Mesh/App/Mesh.cpp +++ b/src/Mod/Mesh/App/Mesh.cpp @@ -1454,7 +1454,9 @@ void MeshObject::removeSelfIntersections(const std::vector& indices) if (indices.size() % 2 != 0) return; unsigned long cntfacets = _kernel.CountFacets(); - if (std::find_if(indices.begin(), indices.end(), [cntfacets](FacetIndex v) { return v >= cntfacets; }) < indices.end()) + if (std::find_if(indices.begin(), indices.end(), [cntfacets](FacetIndex v) { + return v >= cntfacets; + }) < indices.end()) return; std::vector > selfIntersections; std::vector::const_iterator it; diff --git a/src/Mod/Mesh/App/MeshPyImp.cpp b/src/Mod/Mesh/App/MeshPyImp.cpp index 440ed4b5b3..5b23ff0583 100644 --- a/src/Mod/Mesh/App/MeshPyImp.cpp +++ b/src/Mod/Mesh/App/MeshPyImp.cpp @@ -72,7 +72,8 @@ int MeshPy::PyInit(PyObject* args, PyObject*) try { this->parentProperty = nullptr; // if no mesh is given - if (!pcObj) return 0; + if (!pcObj) + return 0; if (PyObject_TypeCheck(pcObj, &(MeshPy::Type))) { getMeshObjectPtr()->operator = (*static_cast(pcObj)->getMeshObjectPtr()); } @@ -80,13 +81,15 @@ int MeshPy::PyInit(PyObject* args, PyObject*) PyObject* ret = addFacets(args); bool ok = (ret!=nullptr); Py_XDECREF(ret); - if (!ok) return -1; + if (!ok) + return -1; } else if (PyTuple_Check(pcObj)) { PyObject* ret = addFacets(args); bool ok = (ret!=nullptr); Py_XDECREF(ret); - if (!ok) return -1; + if (!ok) + return -1; } else if (PyUnicode_Check(pcObj)) { getMeshObjectPtr()->load(PyUnicode_AsUTF8(pcObj)); diff --git a/src/Mod/Mesh/Gui/Command.cpp b/src/Mod/Mesh/Gui/Command.cpp index 9bbd35519a..f50b26d9ee 100644 --- a/src/Mod/Mesh/Gui/Command.cpp +++ b/src/Mod/Mesh/Gui/Command.cpp @@ -102,7 +102,8 @@ CmdMeshTransform::CmdMeshTransform() void CmdMeshTransform::activated(int) { unsigned int n = getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()); - if ( n!=1 ) return; + if ( n!=1 ) + return; std::string fName = getUniqueObjectName("Move"); std::vector cSel = getSelection().getSelection(); @@ -141,7 +142,8 @@ CmdMeshDemolding::CmdMeshDemolding() void CmdMeshDemolding::activated(int) { unsigned int n = getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()); - if ( n!=1 ) return; + if ( n!=1 ) + return; std::string fName = getUniqueObjectName("Demolding"); std::vector cSel = getSelection().getSelection(); @@ -608,7 +610,8 @@ void CmdMeshFromGeometry::activated(int) bool CmdMeshFromGeometry::isActive() { App::Document* doc = App::GetApplication().getActiveDocument(); - if (!doc) return false; + if (!doc) + return false; return getSelection().countObjectsOfType(App::GeoFeature::getClassTypeId()) >= 1; } @@ -1647,7 +1650,8 @@ void CmdMeshFillupHoles::activated(int) bool ok; int FillupHolesOfLength = QInputDialog::getInt(Gui::getMainWindow(), QObject::tr("Fill holes"), QObject::tr("Fill holes with maximum number of edges:"), 3, 3, 10000, 1, &ok, Qt::MSWindowsFixedSizeDialogHint); - if (!ok) return; + if (!ok) + return; openCommand(QT_TRANSLATE_NOOP("Command", "Fill up holes")); for (std::vector::const_iterator it = meshes.begin(); it != meshes.end(); ++it) { doCommand(Doc,"App.activeDocument().getObject(\"%s\").Mesh.fillupHoles(%d)" diff --git a/src/Mod/Mesh/Gui/MeshSelection.cpp b/src/Mod/Mesh/Gui/MeshSelection.cpp index 319c3bd07f..8e2936326c 100644 --- a/src/Mod/Mesh/Gui/MeshSelection.cpp +++ b/src/Mod/Mesh/Gui/MeshSelection.cpp @@ -163,7 +163,8 @@ Gui::View3DInventorViewer* MeshSelection::getViewer() const return ivViewer; Gui::Document* doc = Gui::Application::Instance->activeDocument(); - if (!doc) return nullptr; + if (!doc) + return nullptr; Gui::MDIView* view = doc->getActiveView(); if (view && view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { Gui::View3DInventorViewer* viewer = static_cast(view)->getViewer(); diff --git a/src/Mod/Mesh/Gui/RemoveComponents.cpp b/src/Mod/Mesh/Gui/RemoveComponents.cpp index 81f29f2446..fc23a0b491 100644 --- a/src/Mod/Mesh/Gui/RemoveComponents.cpp +++ b/src/Mod/Mesh/Gui/RemoveComponents.cpp @@ -125,7 +125,8 @@ void RemoveComponents::on_cbDeselectComp_toggled(bool on) void RemoveComponents::deleteSelection() { Gui::Document* doc = Gui::Application::Instance->activeDocument(); - if (!doc) return; + if (!doc) + return; // delete all selected faces doc->openCommand(QT_TRANSLATE_NOOP("Command", "Delete selection")); bool ok = meshSel.deleteSelection(); diff --git a/src/Mod/Mesh/Gui/SoFCIndexedFaceSet.cpp b/src/Mod/Mesh/Gui/SoFCIndexedFaceSet.cpp index 2ac9a6c008..8d9d0467c1 100644 --- a/src/Mod/Mesh/Gui/SoFCIndexedFaceSet.cpp +++ b/src/Mod/Mesh/Gui/SoFCIndexedFaceSet.cpp @@ -909,7 +909,8 @@ void SoFCIndexedFaceSet::doAction(SoAction * action) { if (action->getTypeId() == Gui::SoGLSelectAction::getClassTypeId()) { SoNode* node = action->getNodeAppliedTo(); - if (!node) return; // on no node applied + if (!node) // on no node applied + return; // The node we have is the parent of this node and the coordinate node // thus we search there for it. @@ -919,7 +920,8 @@ void SoFCIndexedFaceSet::doAction(SoAction * action) sa.setType(SoCoordinate3::getClassTypeId(), 1); sa.apply(node); SoPath * path = sa.getPath(); - if (!path) return; + if (!path) + return; // make sure we got the node we wanted SoNode* coords = path->getNodeFromTail(0); @@ -931,7 +933,8 @@ void SoFCIndexedFaceSet::doAction(SoAction * action) } else if (action->getTypeId() == Gui::SoVisibleFaceAction::getClassTypeId()) { SoNode* node = action->getNodeAppliedTo(); - if (!node) return; // on no node applied + if (!node) // on no node applied + return; // The node we have is the parent of this node and the coordinate node // thus we search there for it. @@ -941,7 +944,8 @@ void SoFCIndexedFaceSet::doAction(SoAction * action) sa.setType(SoCoordinate3::getClassTypeId(), 1); sa.apply(node); SoPath * path = sa.getPath(); - if (!path) return; + if (!path) + return; // make sure we got the node we wanted SoNode* coords = path->getNodeFromTail(0); diff --git a/src/Mod/Mesh/Gui/SoFCMeshFaceSet.cpp b/src/Mod/Mesh/Gui/SoFCMeshFaceSet.cpp index 13a3d9b780..8b43ff947a 100644 --- a/src/Mod/Mesh/Gui/SoFCMeshFaceSet.cpp +++ b/src/Mod/Mesh/Gui/SoFCMeshFaceSet.cpp @@ -114,7 +114,9 @@ SbBool SoSFMeshFacetArray::readValue(SoInput *in) } value->resize(numtoread); - if (!this->readBinaryValues(in, numtoread)) { return FALSE; } + if (!this->readBinaryValues(in, numtoread)) { + return FALSE; + } } // ** ASCII format ******************************************************* @@ -135,7 +137,8 @@ SbBool SoSFMeshFacetArray::readValue(SoInput *in) // makeRoom() makes sure the allocation strategy is decent. if (currentidx >= value->size()) value->resize(currentidx + 1); - if (!this->read1Value(in, currentidx++)) return FALSE; + if (!this->read1Value(in, currentidx++)) + return FALSE; READ_VAL(c); if (c == ',') { READ_VAL(c); } // Treat trailing comma as whitespace. @@ -158,7 +161,8 @@ SbBool SoSFMeshFacetArray::readValue(SoInput *in) else { in->putBack(c); value->resize(1); - if (!this->read1Value(in, 0)) return FALSE; + if (!this->read1Value(in, 0)) + return FALSE; } } @@ -1046,7 +1050,8 @@ void SoFCMeshFaceSet::computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢e */ void SoFCMeshFaceSet::getPrimitiveCount(SoGetPrimitiveCountAction * action) { - if (!this->shouldPrimitiveCount(action)) return; + if (!this->shouldPrimitiveCount(action)) + return; SoState* state = action->getState(); const MeshCore::MeshFacetArray * coordIndex = SoFCMeshFacetElement::get(state); action->addNumTriangles(coordIndex->size()); @@ -1193,7 +1198,8 @@ void SoFCMeshOpenEdgeSet::computeBBox(SoAction *action, SbBox3f &box, SbVec3f &c */ void SoFCMeshOpenEdgeSet::getPrimitiveCount(SoGetPrimitiveCountAction * action) { - if (!this->shouldPrimitiveCount(action)) return; + if (!this->shouldPrimitiveCount(action)) + return; SoState* state = action->getState(); const MeshCore::MeshFacetArray * rFaces = SoFCMeshFacetElement::get(state); diff --git a/src/Mod/Mesh/Gui/SoFCMeshNode.cpp b/src/Mod/Mesh/Gui/SoFCMeshNode.cpp index 69d613d90b..1a9b8f7fef 100644 --- a/src/Mod/Mesh/Gui/SoFCMeshNode.cpp +++ b/src/Mod/Mesh/Gui/SoFCMeshNode.cpp @@ -566,7 +566,8 @@ void SoFCMeshNode::computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er) */ void SoFCMeshNode::getPrimitiveCount(SoGetPrimitiveCountAction * action) { - if (!this->shouldPrimitiveCount(action)) return; + if (!this->shouldPrimitiveCount(action)) + return; action->addNumTriangles(countTriangles()); } @@ -591,7 +592,8 @@ void SoFCMeshNode::write( SoWriteAction* action ) else if (out->getStage() == SoOutput::WRITE) { const MeshCore::MeshPointArray& rPoints = _mesh->getKernel().GetPoints(); const MeshCore::MeshFacetArray& rFacets = _mesh->getKernel().GetFacets(); - if (this->writeHeader(out, FALSE, FALSE)) return; + if (this->writeHeader(out, FALSE, FALSE)) + return; point.setNum(rPoints.size()); unsigned int pos=0; for (MeshCore::MeshPointArray::_TConstIterator cP=rPoints.begin(); cP!=rPoints.end(); ++cP) @@ -744,7 +746,8 @@ void SoFCMeshOpenEdge::computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢ */ void SoFCMeshOpenEdge::getPrimitiveCount(SoGetPrimitiveCountAction * action) { - if (!this->shouldPrimitiveCount(action)) return; + if (!this->shouldPrimitiveCount(action)) + return; // Count number of open edges first int ctEdges=0; diff --git a/src/Mod/Mesh/Gui/SoFCMeshObject.cpp b/src/Mod/Mesh/Gui/SoFCMeshObject.cpp index d4206eda16..777fbd2105 100644 --- a/src/Mod/Mesh/Gui/SoFCMeshObject.cpp +++ b/src/Mod/Mesh/Gui/SoFCMeshObject.cpp @@ -634,7 +634,8 @@ void SoFCMeshObjectShape::GLRender(SoGLRenderAction *action) SbBool mode = Gui::SoFCInteractiveElement::get(state); const Mesh::MeshObject * mesh = SoFCMeshObjectElement::get(state); - if (!mesh || mesh->countPoints() == 0) return; + if (!mesh || mesh->countPoints() == 0) + return; Binding mbind = this->findMaterialBinding(state); @@ -974,7 +975,8 @@ void SoFCMeshObjectShape::doAction(SoAction * action) { if (action->getTypeId() == Gui::SoGLSelectAction::getClassTypeId()) { SoNode* node = action->getNodeAppliedTo(); - if (!node) return; // on no node applied + if (!node) // on no node applied + return; // The node we have is the parent of this node and the coordinate node // thus we search there for it. @@ -984,7 +986,8 @@ void SoFCMeshObjectShape::doAction(SoAction * action) sa.setType(SoFCMeshObjectNode::getClassTypeId(), 1); sa.apply(node); SoPath * path = sa.getPath(); - if (!path) return; + if (!path) + return; // make sure we got the node we wanted SoNode* coords = path->getNodeFromTail(0); @@ -1241,7 +1244,8 @@ void SoFCMeshObjectShape::computeBBox(SoAction *action, SbBox3f &box, SbVec3f &c */ void SoFCMeshObjectShape::getPrimitiveCount(SoGetPrimitiveCountAction * action) { - if (!this->shouldPrimitiveCount(action)) return; + if (!this->shouldPrimitiveCount(action)) + return; SoState* state = action->getState(); const Mesh::MeshObject * mesh = SoFCMeshObjectElement::get(state); action->addNumTriangles(mesh->countFacets()); @@ -1284,7 +1288,8 @@ void SoFCMeshSegmentShape::GLRender(SoGLRenderAction *action) SbBool mode = Gui::SoFCInteractiveElement::get(state); const Mesh::MeshObject * mesh = SoFCMeshObjectElement::get(state); - if (!mesh) return; + if (!mesh) + return; Binding mbind = this->findMaterialBinding(state); @@ -1652,7 +1657,8 @@ void SoFCMeshSegmentShape::computeBBox(SoAction *action, SbBox3f &box, SbVec3f & */ void SoFCMeshSegmentShape::getPrimitiveCount(SoGetPrimitiveCountAction * action) { - if (!this->shouldPrimitiveCount(action)) return; + if (!this->shouldPrimitiveCount(action)) + return; SoState* state = action->getState(); const Mesh::MeshObject * mesh = SoFCMeshObjectElement::get(state); if (mesh && mesh->countSegments() > this->index.getValue()) { @@ -1684,7 +1690,8 @@ void SoFCMeshObjectBoundary::GLRender(SoGLRenderAction *action) { SoState* state = action->getState(); const Mesh::MeshObject * mesh = SoFCMeshObjectElement::get(state); - if (!mesh) return; + if (!mesh) + return; SoMaterialBundle mb(action); SoTextureCoordinateBundle tb(action, true, false); @@ -1801,7 +1808,8 @@ void SoFCMeshObjectBoundary::computeBBox(SoAction *action, SbBox3f &box, SbVec3f */ void SoFCMeshObjectBoundary::getPrimitiveCount(SoGetPrimitiveCountAction * action) { - if (!this->shouldPrimitiveCount(action)) return; + if (!this->shouldPrimitiveCount(action)) + return; SoState* state = action->getState(); const Mesh::MeshObject * mesh = SoFCMeshObjectElement::get(state); if (!mesh) diff --git a/src/Mod/Mesh/Gui/SoFCMeshVertex.cpp b/src/Mod/Mesh/Gui/SoFCMeshVertex.cpp index 92e667f495..61c711d5ac 100644 --- a/src/Mod/Mesh/Gui/SoFCMeshVertex.cpp +++ b/src/Mod/Mesh/Gui/SoFCMeshVertex.cpp @@ -91,7 +91,9 @@ SbBool SoSFMeshPointArray::readValue(SoInput *in) } value->resize(numtoread); - if (!this->readBinaryValues(in, numtoread)) { return FALSE; } + if (!this->readBinaryValues(in, numtoread)) { + return FALSE; + } } // ** ASCII format ******************************************************* @@ -112,7 +114,8 @@ SbBool SoSFMeshPointArray::readValue(SoInput *in) // makeRoom() makes sure the allocation strategy is decent. if (currentidx >= value->size()) value->resize(currentidx + 1); - if (!this->read1Value(in, currentidx++)) return FALSE; + if (!this->read1Value(in, currentidx++)) + return FALSE; READ_VAL(c); if (c == ',') { READ_VAL(c); } // Treat trailing comma as whitespace. @@ -135,7 +138,8 @@ SbBool SoSFMeshPointArray::readValue(SoInput *in) else { in->putBack(c); value->resize(1); - if (!this->read1Value(in, 0)) return FALSE; + if (!this->read1Value(in, 0)) + return FALSE; } } diff --git a/src/Mod/Mesh/Gui/SoPolygon.cpp b/src/Mod/Mesh/Gui/SoPolygon.cpp index 42d6ea9b50..9024fd990d 100644 --- a/src/Mod/Mesh/Gui/SoPolygon.cpp +++ b/src/Mod/Mesh/Gui/SoPolygon.cpp @@ -81,9 +81,11 @@ void SoPolygon::GLRender(SoGLRenderAction *action) { SoState* state = action->getState(); const SoCoordinateElement * coords = SoCoordinateElement::getInstance(state); - if (!coords) return; + if (!coords) + return; const SbVec3f * points = coords->getArrayPtr3(); - if (!points) return; + if (!points) + return; SoMaterialBundle mb(action); SoTextureCoordinateBundle tb(action, true, false); @@ -145,9 +147,11 @@ void SoPolygon::computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er) { SoState* state = action->getState(); const SoCoordinateElement * coords = SoCoordinateElement::getInstance(state); - if (!coords) return; + if (!coords) + return; const SbVec3f * points = coords->getArrayPtr3(); - if (!points) return; + if (!points) + return; float maxX=-FLT_MAX, minX=FLT_MAX, maxY=-FLT_MAX, minY=FLT_MAX, maxZ=-FLT_MAX, minZ=FLT_MAX; diff --git a/src/Mod/Mesh/Gui/ViewProvider.cpp b/src/Mod/Mesh/Gui/ViewProvider.cpp index cc90768278..f4501fd719 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.cpp +++ b/src/Mod/Mesh/Gui/ViewProvider.cpp @@ -1260,8 +1260,10 @@ std::vector ViewProviderMesh::getFacetsOfRegion(const SbViewpo void ViewProviderMesh::panCamera(SoCamera * cam, float aspectratio, const SbPlane & panplane, const SbVec2f & currpos, const SbVec2f & prevpos) { - if (cam == nullptr) return; // can happen for empty scenegraph - if (currpos == prevpos) return; // useless invocation + if (cam == nullptr) // can happen for empty scenegraph + return; + if (currpos == prevpos) // useless invocation + return; // Find projection points for the last and current mouse coordinates. diff --git a/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp b/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp index 1fdceddf8d..49f764e1fc 100644 --- a/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp @@ -309,7 +309,8 @@ void ViewProviderMeshCurvature::updateData(const App::Property* prop) } else if (prop->getTypeId() == Mesh::PropertyCurvatureList::getClassTypeId()) { const Mesh::PropertyCurvatureList* curv = static_cast(prop); - if (curv->getSize() < 3) return; // invalid array + if (curv->getSize() < 3) // invalid array + return; #if 0 // FIXME: Do not always change the range init(curv); // init color bar #endif diff --git a/src/Mod/Mesh/Gui/ViewProviderMeshNode.cpp b/src/Mod/Mesh/Gui/ViewProviderMeshNode.cpp index bf012a7c5f..7bca56a1b3 100644 --- a/src/Mod/Mesh/Gui/ViewProviderMeshNode.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderMeshNode.cpp @@ -258,7 +258,8 @@ std::vector ViewProviderMeshNode::getDisplayModes(void) const bool ViewProviderMeshNode::setEdit(int ModNum) { - if ( m_bEdit ) return true; + if ( m_bEdit ) + return true; m_bEdit = true; return true; } From 2ecc125497fdbbec42eb4e5cd1dc3f014f95197f Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 12:37:00 -0500 Subject: [PATCH 22/39] Part: PR6497 move return statement to new line --- src/Mod/Part/App/Attacher.cpp | 3 +- src/Mod/Part/App/PartFeature.cpp | 6 +- src/Mod/Part/App/PartFeatures.cpp | 6 +- src/Mod/Part/App/PropertyTopoShape.cpp | 3 +- src/Mod/Part/App/TopoShape.cpp | 3 +- src/Mod/Part/App/TopoShapePyImp.cpp | 3 +- src/Mod/Part/App/modelRefine.cpp | 24 ++++-- src/Mod/Part/Gui/Command.cpp | 6 +- src/Mod/Part/Gui/DlgBooleanOperation.cpp | 12 ++- src/Mod/Part/Gui/DlgExtrusion.cpp | 3 +- src/Mod/Part/Gui/DlgFilletEdges.cpp | 3 +- src/Mod/Part/Gui/DlgProjectionOnSurface.cpp | 93 ++++++++++++++------- src/Mod/Part/Gui/DlgRevolution.cpp | 3 +- src/Mod/Part/Gui/Mirroring.cpp | 6 +- src/Mod/Part/Gui/SoBrepFaceSet.cpp | 18 ++-- src/Mod/Part/Gui/SoFCShapeObject.cpp | 12 ++- src/Mod/Part/Gui/TaskAttacher.cpp | 9 +- src/Mod/Part/Gui/TaskLoft.cpp | 3 +- src/Mod/Part/Gui/TaskShapeBuilder.cpp | 3 +- src/Mod/Part/Gui/TaskSweep.cpp | 3 +- src/Mod/Part/Gui/ViewProvider2DObject.cpp | 3 +- 21 files changed, 150 insertions(+), 75 deletions(-) diff --git a/src/Mod/Part/App/Attacher.cpp b/src/Mod/Part/App/Attacher.cpp index 34a7e09f50..ede1359034 100644 --- a/src/Mod/Part/App/Attacher.cpp +++ b/src/Mod/Part/App/Attacher.cpp @@ -433,7 +433,8 @@ eRefType AttachEngine::getShapeType(const TopoDS_Shape& sh) case TopAbs_COMPOUND:{ const TopoDS_Compound &cmpd = TopoDS::Compound(sh); TopoDS_Iterator it (cmpd, Standard_False, Standard_False);//don't mess with placements, to hopefully increase speed - if (! it.More()) return rtAnything;//empty compound + if (! it.More())//empty compound + return rtAnything; const TopoDS_Shape &sh1 = it.Value(); it.Next(); if (it.More()){ diff --git a/src/Mod/Part/App/PartFeature.cpp b/src/Mod/Part/App/PartFeature.cpp index 87405b6c74..9d43c9ef66 100644 --- a/src/Mod/Part/App/PartFeature.cpp +++ b/src/Mod/Part/App/PartFeature.cpp @@ -287,7 +287,8 @@ static TopoShape _getTopoShape(const App::DocumentObject *obj, const char *subna { TopoShape shape; - if(!obj) return shape; + if(!obj) + return shape; PyObject *pyobj = nullptr; Base::Matrix4D mat; @@ -526,7 +527,8 @@ TopoShape Feature::getTopoShape(const App::DocumentObject *obj, const char *subn App::DocumentObject *Feature::getShapeOwner(const App::DocumentObject *obj, const char *subname) { - if(!obj) return nullptr; + if(!obj) + return nullptr; auto owner = obj->getSubObject(subname); if(owner) { auto linked = owner->getLinkedObject(true); diff --git a/src/Mod/Part/App/PartFeatures.cpp b/src/Mod/Part/App/PartFeatures.cpp index a25d607cc6..9e597d9d42 100644 --- a/src/Mod/Part/App/PartFeatures.cpp +++ b/src/Mod/Part/App/PartFeatures.cpp @@ -117,12 +117,14 @@ App::DocumentObjectExecReturn *RuledSurface::execute(void) // get the first input shape TopoDS_Shape S1; ret = getShape(Curve1, S1); - if (ret) return ret; + if (ret) + return ret; // get the second input shape TopoDS_Shape S2; ret = getShape(Curve2, S2); - if (ret) return ret; + if (ret) + return ret; // check for expected type if (S1.IsNull() || S2.IsNull()) diff --git a/src/Mod/Part/App/PropertyTopoShape.cpp b/src/Mod/Part/App/PropertyTopoShape.cpp index d8bbae2222..8b2edaee53 100644 --- a/src/Mod/Part/App/PropertyTopoShape.cpp +++ b/src/Mod/Part/App/PropertyTopoShape.cpp @@ -243,7 +243,8 @@ static Standard_Boolean BRepTools_Write(const TopoDS_Shape& Sh, const Standard_ #else os.open(File, std::ios::out); #endif - if (!os.rdbuf()->is_open()) return Standard_False; + if (!os.rdbuf()->is_open()) + return Standard_False; Standard_Boolean isGood = (os.good() && !os.eof()); if(!isGood) diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index cfc3833c9f..115dd625aa 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -395,7 +395,8 @@ TopoDS_Shape TopoShape::getSubShape(TopAbs_ShapeEnum type, int index, bool silen unsigned long TopoShape::countSubShapes(const char* Type) const { - if(!Type) return 0; + if(!Type) + return 0; if(strcmp(Type,"SubShape")==0) return countSubShapes(TopAbs_SHAPE); auto type = shapeType(Type,true); diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index e4b8a7d95a..d44665c68e 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -3245,7 +3245,8 @@ Py::Float TopoShapePy::getVolume(void) const PyObject *TopoShapePy::getCustomAttributes(const char* attr) const { - if (!attr) return nullptr; + if (!attr) + return nullptr; PY_TRY { TopoDS_Shape res = getTopoShapePtr()->getSubShape(attr,true); if(!res.IsNull()) diff --git a/src/Mod/Part/App/modelRefine.cpp b/src/Mod/Part/App/modelRefine.cpp index 90dabaea99..a51135f3e4 100644 --- a/src/Mod/Part/App/modelRefine.cpp +++ b/src/Mod/Part/App/modelRefine.cpp @@ -826,14 +826,22 @@ bool FaceTypedBSpline::isEqual(const TopoDS_Face &faceOne, const TopoDS_Face &fa if (surfaceOne.IsNull() || surfaceTwo.IsNull()) return false; - if (surfaceOne->IsURational() != surfaceTwo->IsURational()) return false; - if (surfaceOne->IsVRational() != surfaceTwo->IsVRational()) return false; - if (surfaceOne->IsUPeriodic() != surfaceTwo->IsUPeriodic()) return false; - if (surfaceOne->IsVPeriodic() != surfaceTwo->IsVPeriodic()) return false; - if (surfaceOne->IsUClosed() != surfaceTwo->IsUClosed()) return false; - if (surfaceOne->IsVClosed() != surfaceTwo->IsVClosed()) return false; - if (surfaceOne->UDegree() != surfaceTwo->UDegree()) return false; - if (surfaceOne->VDegree() != surfaceTwo->VDegree()) return false; + if (surfaceOne->IsURational() != surfaceTwo->IsURational()) + return false; + if (surfaceOne->IsVRational() != surfaceTwo->IsVRational()) + return false; + if (surfaceOne->IsUPeriodic() != surfaceTwo->IsUPeriodic()) + return false; + if (surfaceOne->IsVPeriodic() != surfaceTwo->IsVPeriodic()) + return false; + if (surfaceOne->IsUClosed() != surfaceTwo->IsUClosed()) + return false; + if (surfaceOne->IsVClosed() != surfaceTwo->IsVClosed()) + return false; + if (surfaceOne->UDegree() != surfaceTwo->UDegree()) + return false; + if (surfaceOne->VDegree() != surfaceTwo->VDegree()) + return false; //pole test int uPoleCountOne(surfaceOne->NbUPoles()); diff --git a/src/Mod/Part/Gui/Command.cpp b/src/Mod/Part/Gui/Command.cpp index e98a4d845d..e5916ebace 100644 --- a/src/Mod/Part/Gui/Command.cpp +++ b/src/Mod/Part/Gui/Command.cpp @@ -1004,7 +1004,8 @@ void CmdPartImport::activated(int iMsg) if (!fn.isEmpty()) { Gui::WaitCursor wc; App::Document* pDoc = getDocument(); - if (!pDoc) return; // no document + if (!pDoc) // no document + return; fn = Base::Tools::escapeEncodeFilename(fn); openCommand(QT_TRANSLATE_NOOP("Command", "Import Part")); @@ -1065,7 +1066,8 @@ void CmdPartExport::activated(int iMsg) QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")), &select); if (!fn.isEmpty()) { App::Document* pDoc = getDocument(); - if (!pDoc) return; // no document + if (!pDoc) // no document + return; if (select == filter[1] || select == filter[3]) { Gui::Application::Instance->exportTo((const char*)fn.toUtf8(),pDoc->getName(),"ImportGui"); diff --git a/src/Mod/Part/Gui/DlgBooleanOperation.cpp b/src/Mod/Part/Gui/DlgBooleanOperation.cpp index 7c927ad693..5479fc58e6 100644 --- a/src/Mod/Part/Gui/DlgBooleanOperation.cpp +++ b/src/Mod/Part/Gui/DlgBooleanOperation.cpp @@ -62,7 +62,8 @@ namespace PartGui { QTreeWidgetItem::setData(column, role, value); if (role == Qt::CheckStateRole && value.toBool() == true) { QTreeWidget* tree = this->treeWidget(); - if (!tree) return; + if (!tree) + return; int numChild = tree->topLevelItemCount(); for (int i=0; itopLevelItem(i); @@ -117,7 +118,8 @@ void DlgBooleanOperation::changeEvent(QEvent *e) void DlgBooleanOperation::slotCreatedObject(const App::DocumentObject& obj) { App::Document* activeDoc = App::GetApplication().getActiveDocument(); - if (!activeDoc) return; + if (!activeDoc) + return; App::Document* doc = obj.getDocument(); if (activeDoc == doc && obj.getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { observe.push_back(&obj); @@ -205,9 +207,11 @@ bool DlgBooleanOperation::hasSolids(const App::DocumentObject* obj) const void DlgBooleanOperation::findShapes() { App::Document* activeDoc = App::GetApplication().getActiveDocument(); - if (!activeDoc) return; + if (!activeDoc) + return; Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc); - if (!activeGui) return; + if (!activeGui) + return; std::vector objs = activeDoc->getObjectsOfType (Part::Feature::getClassTypeId()); diff --git a/src/Mod/Part/Gui/DlgExtrusion.cpp b/src/Mod/Part/Gui/DlgExtrusion.cpp index 00e0b2fadb..1d8a610b8e 100644 --- a/src/Mod/Part/Gui/DlgExtrusion.cpp +++ b/src/Mod/Part/Gui/DlgExtrusion.cpp @@ -346,7 +346,8 @@ void DlgExtrusion::autoSolid() void DlgExtrusion::findShapes() { App::Document* activeDoc = App::GetApplication().getActiveDocument(); - if (!activeDoc) return; + if (!activeDoc) + return; Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc); this->document = activeDoc->getName(); this->label = activeDoc->Label.getValue(); diff --git a/src/Mod/Part/Gui/DlgFilletEdges.cpp b/src/Mod/Part/Gui/DlgFilletEdges.cpp index c5deed8d9a..db9ce6e7dc 100644 --- a/src/Mod/Part/Gui/DlgFilletEdges.cpp +++ b/src/Mod/Part/Gui/DlgFilletEdges.cpp @@ -528,7 +528,8 @@ void DlgFilletEdges::toggleCheckState(const QModelIndex& index) void DlgFilletEdges::findShapes() { App::Document* activeDoc = App::GetApplication().getActiveDocument(); - if (!activeDoc) return; + if (!activeDoc) + return; std::vector objs = activeDoc->getObjectsOfType (Part::Feature::getClassTypeId()); diff --git a/src/Mod/Part/Gui/DlgProjectionOnSurface.cpp b/src/Mod/Part/Gui/DlgProjectionOnSurface.cpp index 4934565cec..b6f8847314 100644 --- a/src/Mod/Part/Gui/DlgProjectionOnSurface.cpp +++ b/src/Mod/Part/Gui/DlgProjectionOnSurface.cpp @@ -86,15 +86,20 @@ public: bool allow(App::Document* /*pDoc*/, App::DocumentObject* iPObj, const char* sSubName) { Part::Feature* aPart = dynamic_cast(iPObj); - if (!aPart) return false; - if (!sSubName) return false; + if (!aPart) + return false; + if (!sSubName) + return false; std::string subName(sSubName); - if (subName.empty()) return false; + if (subName.empty()) + return false; auto subShape = aPart->Shape.getShape().getSubShape(sSubName); - if (subShape.IsNull()) return false; + if (subShape.IsNull()) + return false; auto type = subShape.ShapeType(); - if (type != TopAbs_EDGE) return false; + if (type != TopAbs_EDGE) + return false; return true; } }; @@ -115,15 +120,20 @@ public: bool allow(App::Document* /*pDoc*/, App::DocumentObject* iPObj, const char* sSubName) { Part::Feature* aPart = dynamic_cast(iPObj); - if (!aPart) return false; - if (!sSubName) return false; + if (!aPart) + return false; + if (!sSubName) + return false; std::string subName(sSubName); - if (subName.empty()) return false; + if (subName.empty()) + return false; auto subShape = aPart->Shape.getShape().getSubShape(sSubName, true); - if (subShape.IsNull()) return false; + if (subShape.IsNull()) + return false; auto type = subShape.ShapeType(); - if (type != TopAbs_FACE) return false; + if (type != TopAbs_FACE) + return false; return true; } }; @@ -333,7 +343,8 @@ void PartGui::DlgProjectionOnSurface::get_camera_direction(void) auto mainWindow = Gui::getMainWindow(); auto mdiObject = dynamic_cast(mainWindow->activeWindow()); - if (!mdiObject) return; + if (!mdiObject) + return; auto camerRotation = mdiObject->getViewer()->getCameraOrientation(); SbVec3f lookAt(0, 0, -1); @@ -349,7 +360,8 @@ void PartGui::DlgProjectionOnSurface::get_camera_direction(void) void PartGui::DlgProjectionOnSurface::store_current_selected_parts(std::vector& iStoreVec, const unsigned int iColor) { - if (!m_partDocument) return; + if (!m_partDocument) + return; std::vector selObj = Gui::Selection().getSelectionEx(); if (selObj.size()) { @@ -402,7 +414,8 @@ void PartGui::DlgProjectionOnSurface::store_current_selected_parts(std::vector& iStoreVec) { - if (iCurrentShape.inputShape.IsNull()) return false; + if (iCurrentShape.inputShape.IsNull()) + return false; auto currentType = iCurrentShape.inputShape.ShapeType(); for ( auto it = iStoreVec.begin(); it != iStoreVec.end(); ++it) { @@ -450,7 +463,8 @@ void PartGui::DlgProjectionOnSurface::create_projection_wire(std::vector& iShapeVec) { - if (iShapeVec.empty()) return TopoDS_Shape(); + if (iShapeVec.empty()) + return TopoDS_Shape(); TopoDS_Compound aCompound; TopoDS_Builder aBuilder; @@ -581,11 +596,13 @@ TopoDS_Shape PartGui::DlgProjectionOnSurface::create_compound(const std::vector< void PartGui::DlgProjectionOnSurface::show_projected_shapes(const std::vector& iShapeStoreVec) { - if (!m_projectionObject) return; + if (!m_projectionObject) + return; auto aCompound = create_compound(iShapeStoreVec); if ( aCompound.IsNull() ) { - if (!m_partDocument) return; + if (!m_partDocument) + return; m_projectionObject->Shape.setValue(TopoDS_Shape()); return; } @@ -625,7 +642,8 @@ void PartGui::DlgProjectionOnSurface::enable_ui_elements(const std::vectorShape.getShape().getShape(); auto subShape = iCurrentObject->Shape.getShape().getSubShape(iShapeName.c_str(), true); @@ -635,8 +653,10 @@ void PartGui::DlgProjectionOnSurface::higlight_object(Part::Feature* iCurrentObj auto currentShapeType = currentShape.ShapeType(); TopTools_IndexedMapOfShape anIndices; TopExp::MapShapes(partenShape, currentShapeType, anIndices); - if (anIndices.IsEmpty()) return; - if (!anIndices.Contains(currentShape)) return; + if (anIndices.IsEmpty()) + return; + if (!anIndices.Contains(currentShape)) + return; auto index = anIndices.FindIndex(currentShape); //set color @@ -698,7 +718,8 @@ void PartGui::DlgProjectionOnSurface::create_projection_face_from_wire(std::vect { try { - if (iCurrentShape.empty()) return; + if (iCurrentShape.empty()) + return; for ( auto &itCurrentShape : iCurrentShape ) { @@ -813,7 +834,8 @@ TopoDS_Wire PartGui::DlgProjectionOnSurface::sort_and_heal_wire(const std::vecto shapeAnalyzer.ConnectEdgesToWires(shapeList, 0.0001, false, aWireHandle); shapeAnalyzer.ConnectWiresToWires(aWireHandle, 0.0001, false, aWireWireHandle); - if (!aWireWireHandle) return TopoDS_Wire(); + if (!aWireWireHandle) + return TopoDS_Wire(); for (auto it = 1; it <= aWireWireHandle->Length(); ++it) { auto aShape = TopoDS::Wire(aWireWireHandle->Value(it)); @@ -835,7 +857,8 @@ void PartGui::DlgProjectionOnSurface::create_face_extrude(std::vector& iStoreVec, const unsigned int iColor) { - if (m_currentSelection != "add_wire") return; - if (iParentShape.IsNull()) return; - if (iCurrentShape.inputShape.IsNull()) return; + if (m_currentSelection != "add_wire") + return; + if (iParentShape.IsNull()) + return; + if (iCurrentShape.inputShape.IsNull()) + return; auto currentType = iCurrentShape.inputShape.ShapeType(); - if (currentType != TopAbs_EDGE) return; + if (currentType != TopAbs_EDGE) + return; std::vector aWireVec; for (TopExp_Explorer aExplorer(iParentShape, TopAbs_WIRE); aExplorer.More(); aExplorer.Next()) @@ -888,15 +916,18 @@ void PartGui::DlgProjectionOnSurface::store_wire_in_vector(const SShapeStore& iC edgeVec.clear(); } - if (edgeVec.empty()) return; + if (edgeVec.empty()) + return; TopTools_IndexedMapOfShape indexMap; TopExp::MapShapes(iParentShape, TopAbs_EDGE, indexMap); - if (indexMap.IsEmpty()) return; + if (indexMap.IsEmpty()) + return; for ( auto it : edgeVec ) { if ( it.IsSame(iCurrentShape.inputShape)) continue; - if (!indexMap.Contains(it)) return; + if (!indexMap.Contains(it)) + return; auto index = indexMap.FindIndex(it); auto newEdgeObject = iCurrentShape; newEdgeObject.inputShape = it; diff --git a/src/Mod/Part/Gui/DlgRevolution.cpp b/src/Mod/Part/Gui/DlgRevolution.cpp index 1f27449f57..61ab1a62fa 100644 --- a/src/Mod/Part/Gui/DlgRevolution.cpp +++ b/src/Mod/Part/Gui/DlgRevolution.cpp @@ -323,7 +323,8 @@ void DlgRevolution::keyPressEvent(QKeyEvent* ke) void DlgRevolution::findShapes() { App::Document* activeDoc = App::GetApplication().getActiveDocument(); - if (!activeDoc) return; + if (!activeDoc) + return; Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc); std::vector objs = activeDoc->getObjectsOfType diff --git a/src/Mod/Part/Gui/Mirroring.cpp b/src/Mod/Part/Gui/Mirroring.cpp index babb050620..c3adead1e0 100644 --- a/src/Mod/Part/Gui/Mirroring.cpp +++ b/src/Mod/Part/Gui/Mirroring.cpp @@ -89,9 +89,11 @@ void Mirroring::changeEvent(QEvent *e) void Mirroring::findShapes() { App::Document* activeDoc = App::GetApplication().getActiveDocument(); - if (!activeDoc) return; + if (!activeDoc) + return; Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc); - if (!activeGui) return; + if (!activeGui) + return; this->document = QString::fromLatin1(activeDoc->getName()); std::vector objs = activeDoc->getObjectsOfType diff --git a/src/Mod/Part/Gui/SoBrepFaceSet.cpp b/src/Mod/Part/Gui/SoBrepFaceSet.cpp index 4a93c115c4..b716daa39d 100644 --- a/src/Mod/Part/Gui/SoBrepFaceSet.cpp +++ b/src/Mod/Part/Gui/SoBrepFaceSet.cpp @@ -459,7 +459,8 @@ void SoBrepFaceSet::GLRender(SoGLRenderAction *action) void SoBrepFaceSet::renderSimpleArray() { int cnt = index_array.size(); - if (cnt == 0) return; + if (cnt == 0) + return; glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); @@ -485,7 +486,8 @@ void SoBrepFaceSet::renderColoredArray(SoMaterialBundle *const materials) { int num_parts = partIndex.getNum(); int cnt = index_array.size(); - if (cnt == 0) return; + if (cnt == 0) + return; glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); @@ -687,19 +689,22 @@ void SoBrepFaceSet::GLRender(SoGLRenderAction *action) #endif bool SoBrepFaceSet::overrideMaterialBinding(SoGLRenderAction *action, SelContextPtr ctx, SelContextPtr ctx2) { - if(!ctx && !ctx2) return false; + if(!ctx && !ctx2) + return false; auto state = action->getState(); auto mb = SoMaterialBindingElement::get(state); auto element = SoLazyElement::getInstance(state); const SbColor *diffuse = element->getDiffusePointer(); - if(!diffuse) return false; + if(!diffuse) + return false; int diffuse_size = element->getNumDiffuse(); const float *trans = element->getTransparencyPointer(); int trans_size = element->getNumTransparencies(); - if(!trans || !trans_size) return false; + if(!trans || !trans_size) + return false; float trans0=0.0; bool hasTransparency = false; for(int i=0;icoordIndex.getNum() < 3) return; + if (this->coordIndex.getNum() < 3) + return; SoState * state = action->getState(); if (this->vertexProperty.getValue()) { diff --git a/src/Mod/Part/Gui/SoFCShapeObject.cpp b/src/Mod/Part/Gui/SoFCShapeObject.cpp index b50fa52274..b5a4d7fbe1 100644 --- a/src/Mod/Part/Gui/SoFCShapeObject.cpp +++ b/src/Mod/Part/Gui/SoFCShapeObject.cpp @@ -81,9 +81,11 @@ void SoFCControlPoints::GLRender(SoGLRenderAction *action) { SoState* state = action->getState(); const SoCoordinateElement * coords = SoCoordinateElement::getInstance(state); - if (!coords) return; + if (!coords) + return; const SbVec3f * points = coords->getArrayPtr3(); - if (!points) return; + if (!points) + return; SoMaterialBundle mb(action); SoTextureCoordinateBundle tb(action, true, false); @@ -159,9 +161,11 @@ void SoFCControlPoints::computeBBox(SoAction *action, SbBox3f &box, SbVec3f &cen { SoState* state = action->getState(); const SoCoordinateElement * coords = SoCoordinateElement::getInstance(state); - if (!coords) return; + if (!coords) + return; const SbVec3f * points = coords->getArrayPtr3(); - if (!points) return; + if (!points) + return; float maxX=-FLT_MAX, minX=FLT_MAX, maxY=-FLT_MAX, minY=FLT_MAX, maxZ=-FLT_MAX, minZ=FLT_MAX; diff --git a/src/Mod/Part/Gui/TaskAttacher.cpp b/src/Mod/Part/Gui/TaskAttacher.cpp index 14884c2e23..9405a7e995 100644 --- a/src/Mod/Part/Gui/TaskAttacher.cpp +++ b/src/Mod/Part/Gui/TaskAttacher.cpp @@ -365,7 +365,8 @@ void TaskAttacher::onSelectionChanged(const Gui::SelectionChanges& msg) std::vector refs = pcAttach->Support.getValues(); std::vector refnames = pcAttach->Support.getSubValues(); App::DocumentObject* selObj = ViewProvider->getObject()->getDocument()->getObject(msg.pObjectName); - if (!selObj || selObj == ViewProvider->getObject()) return;//prevent self-referencing + if (!selObj || selObj == ViewProvider->getObject())//prevent self-referencing + return; std::string subname = msg.pSubName; @@ -563,7 +564,8 @@ void TaskAttacher::onRefName(const QString& text, unsigned idx) return; QLineEdit* line = getLine(idx); - if (line == nullptr) return; + if (line == nullptr) + return; if (text.length() == 0) { // Reference was removed @@ -606,7 +608,8 @@ void TaskAttacher::onRefName(const QString& text, unsigned idx) parts.push_back(QString::fromLatin1("")); // Check whether this is the name of an App::Plane or Part::Datum feature App::DocumentObject* obj = ViewProvider->getObject()->getDocument()->getObject(parts[0].toLatin1()); - if (obj == nullptr) return; + if (obj == nullptr) + return; std::string subElement; diff --git a/src/Mod/Part/Gui/TaskLoft.cpp b/src/Mod/Part/Gui/TaskLoft.cpp index 181ee8baa7..8ad5edf8a0 100644 --- a/src/Mod/Part/Gui/TaskLoft.cpp +++ b/src/Mod/Part/Gui/TaskLoft.cpp @@ -98,7 +98,8 @@ void LoftWidget::findShapes() { App::Document* activeDoc = App::GetApplication().getActiveDocument(); Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc); - if (!activeGui) return; + if (!activeGui) + return; d->document = activeDoc->getName(); std::vector objs = activeDoc->getObjectsOfType(); diff --git a/src/Mod/Part/Gui/TaskShapeBuilder.cpp b/src/Mod/Part/Gui/TaskShapeBuilder.cpp index 765f6d0ed5..1fe74024eb 100644 --- a/src/Mod/Part/Gui/TaskShapeBuilder.cpp +++ b/src/Mod/Part/Gui/TaskShapeBuilder.cpp @@ -172,7 +172,8 @@ void ShapeBuilderWidget::on_createButton_clicked() { int mode = d->bg.checkedId(); Gui::Document* doc = Gui::Application::Instance->activeDocument(); - if (!doc) return; + if (!doc) + return; try { if (mode == 0) { diff --git a/src/Mod/Part/Gui/TaskSweep.cpp b/src/Mod/Part/Gui/TaskSweep.cpp index 31552a94bd..ce676c0eca 100644 --- a/src/Mod/Part/Gui/TaskSweep.cpp +++ b/src/Mod/Part/Gui/TaskSweep.cpp @@ -155,7 +155,8 @@ void SweepWidget::findShapes() { App::Document* activeDoc = App::GetApplication().getActiveDocument(); Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc); - if (!activeGui) return; + if (!activeGui) + return; d->document = activeDoc->getName(); std::vector objs = activeDoc->getObjectsOfType(); diff --git a/src/Mod/Part/Gui/ViewProvider2DObject.cpp b/src/Mod/Part/Gui/ViewProvider2DObject.cpp index c5ad6b8484..661cc1c876 100644 --- a/src/Mod/Part/Gui/ViewProvider2DObject.cpp +++ b/src/Mod/Part/Gui/ViewProvider2DObject.cpp @@ -246,7 +246,8 @@ void ViewProvider2DObjectGrid::updateData(const App::Property* prop) if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId()) { if (GridAutoSize.getValue()) { Base::BoundBox3d bbox = static_cast(prop)->getBoundingBox(); - if (!bbox.IsValid()) return; + if (!bbox.IsValid()) + return; Gui::coinRemoveAllChildren(GridRoot); Base::Placement place = static_cast(prop)->getComplexData()->getPlacement(); place.invert(); From 65aa374083b378a719d16d32e41cdfee0fe9ecf6 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 12:37:21 -0500 Subject: [PATCH 23/39] PD: PR6497 move return statement to new line --- src/Mod/PartDesign/Gui/Command.cpp | 45 ++++++++++++------- src/Mod/PartDesign/Gui/CommandBody.cpp | 19 +++++--- src/Mod/PartDesign/Gui/CommandPrimitive.cpp | 3 +- .../Gui/TaskMultiTransformParameters.cpp | 3 +- .../Gui/TaskTransformedParameters.cpp | 3 +- src/Mod/PartDesign/Gui/Utils.cpp | 7 ++- src/Mod/PartDesign/Gui/ViewProviderDatum.cpp | 3 +- .../PartDesign/Gui/ViewProviderDressUp.cpp | 6 ++- .../Gui/ViewProviderShapeBinder.cpp | 6 ++- 9 files changed, 64 insertions(+), 31 deletions(-) diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 1e70a25181..09be681a2e 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -121,7 +121,8 @@ void UnifiedDatumCommand(Gui::Command &cmd, Base::Type type, std::string name) support.removeValue(pcActiveBody); auto Feat = pcActiveBody->getDocument()->getObject(FeatName.c_str()); - if (!Feat) return; + if (!Feat) + return; //test if current selection fits a mode. if (support.getSize() > 0) { @@ -311,7 +312,8 @@ void CmdPartDesignShapeBinder::activated(int iMsg) support.removeValue(pcActiveBody); auto Feat = pcActiveBody->getObject(FeatName.c_str()); - if (!Feat) return; + if (!Feat) + return; //test if current selection fits a mode. if (support.getSize() > 0) { @@ -395,7 +397,8 @@ void CmdPartDesignSubShapeBinder::activated(int iMsg) binder = dynamic_cast( App::GetApplication().getActiveDocument()->getObject(FeatName.c_str())); } - if (!binder) return; + if (!binder) + return; binder->setLinks(std::move(values)); updateActive(); commitCommand(); @@ -1386,7 +1389,8 @@ void CmdPartDesignHole::activated(int iMsg) Gui::Command* cmd = this; auto worker = [cmd](Part::Feature* sketch, App::DocumentObject *Feat) { - if (!Feat) return; + if (!Feat) + return; finishProfileBased(cmd, sketch, Feat); cmd->adjustCameraPosition(); @@ -1432,7 +1436,8 @@ void CmdPartDesignRevolution::activated(int iMsg) Gui::Command* cmd = this; auto worker = [cmd, &pcActiveBody](Part::Feature* sketch, App::DocumentObject *Feat) { - if (!Feat) return; + if (!Feat) + return; if (sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId())) { FCMD_OBJ_CMD(Feat,"ReferenceAxis = (" << getObjectCmd(sketch) << ",['V_Axis'])"); @@ -1490,7 +1495,8 @@ void CmdPartDesignGroove::activated(int iMsg) Gui::Command* cmd = this; auto worker = [cmd, &pcActiveBody](Part::Feature* sketch, App::DocumentObject *Feat) { - if (!Feat) return; + if (!Feat) + return; if (sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId())) { FCMD_OBJ_CMD(Feat,"ReferenceAxis = ("<getUniqueObjectName(which.c_str(), base); auto body = PartDesignGui::getBodyFor(base, false); - if (!body) return; + if (!body) + return; cmd->openCommand((std::string("Make ") + which).c_str()); FCMD_OBJ_CMD(body,"newObject('PartDesign::"<getDocument()->getObject(FeatName.c_str()); @@ -2532,7 +2545,8 @@ void CmdPartDesignMultiTransform::activated(int iMsg) f++; } - if (features.empty()) return; + if (features.empty()) + return; // Note: If multiple Transformed features were selected, only the first one is used PartDesign::Transformed* trFeat = static_cast(features.front()); @@ -2634,7 +2648,8 @@ void CmdPartDesignBoolean::activated(int iMsg) { Q_UNUSED(iMsg); PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */true); - if (!pcActiveBody) return; + if (!pcActiveBody) + return; Gui::SelectionFilter BodyFilter("SELECT Part::Feature COUNT 1.."); diff --git a/src/Mod/PartDesign/Gui/CommandBody.cpp b/src/Mod/PartDesign/Gui/CommandBody.cpp index dacf18823f..4a24405f56 100644 --- a/src/Mod/PartDesign/Gui/CommandBody.cpp +++ b/src/Mod/PartDesign/Gui/CommandBody.cpp @@ -667,10 +667,13 @@ void CmdPartDesignMoveFeature::activated(int iMsg) { Q_UNUSED(iMsg); std::vector features = getSelection().getObjectsOfType(Part::Feature::getClassTypeId()); - if (features.empty()) return; + if (features.empty()) + return; // Check if all features are valid to move - if (std::any_of(std::begin(features), std::end(features), [](App::DocumentObject* obj){return !PartDesignGui::isFeatureMovable(obj); })) + if (std::any_of(std::begin(features), std::end(features), [](App::DocumentObject* obj){ + return !PartDesignGui::isFeatureMovable(obj); + })) { //show messagebox and cancel QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Features cannot be moved"), @@ -725,9 +728,11 @@ void CmdPartDesignMoveFeature::activated(int iMsg) qApp->translate("PartDesign_MoveFeature", "Select body"), qApp->translate("PartDesign_MoveFeature", "Select a body from the list"), items, 0, false, &ok, Qt::MSWindowsFixedSizeDialogHint); - if (!ok) return; + if (!ok) + return; int index = items.indexOf(text); - if (index < 0) return; + if (index < 0) + return; PartDesign::Body* target = static_cast(target_bodies[index]); @@ -829,7 +834,8 @@ void CmdPartDesignMoveFeatureInTree::activated(int iMsg) { Q_UNUSED(iMsg); std::vector features = getSelection().getObjectsOfType(Part::Feature::getClassTypeId()); - if (features.empty()) return; + if (features.empty()) + return; PartDesign::Body *body = PartDesignGui::getBodyFor ( features.front(), false ); App::DocumentObject * bodyBase = nullptr; @@ -875,7 +881,8 @@ void CmdPartDesignMoveFeatureInTree::activated(int iMsg) qApp->translate("PartDesign_MoveFeatureInTree", "Select feature"), qApp->translate("PartDesign_MoveFeatureInTree", "Select a feature from the list"), items, 0, false, &ok, Qt::MSWindowsFixedSizeDialogHint); - if (!ok) return; + if (!ok) + return; int index = items.indexOf(text); // first object is the beginning of the body App::DocumentObject* target = index != 0 ? model[index-1] : nullptr; diff --git a/src/Mod/PartDesign/Gui/CommandPrimitive.cpp b/src/Mod/PartDesign/Gui/CommandPrimitive.cpp index cb8dd7f158..702120a21a 100644 --- a/src/Mod/PartDesign/Gui/CommandPrimitive.cpp +++ b/src/Mod/PartDesign/Gui/CommandPrimitive.cpp @@ -118,7 +118,8 @@ void CmdPrimtiveCompAdditive::activated(int iMsg) auto* prm = static_cast( pcActiveBody->getDocument()->getObject(FeatName.c_str())); - if(!prm) return; + if(!prm) + return; FCMD_OBJ_CMD(pcActiveBody,"addObject("<(TransformedView->getObject()); std::vector transformFeatures = pcMultiTransform->Transformations.getValues(); - if (transformFeatures.empty()) return; + if (transformFeatures.empty()) + return; App::DocumentObject* feature = transformFeatures[row]; transformFeatures.erase(transformFeatures.begin() + row); diff --git a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp index d9facc0bc6..03771b7fd5 100644 --- a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp @@ -203,7 +203,8 @@ void TaskTransformedParameters::onButtonAddFeature(bool checked) void TaskTransformedParameters::checkVisibility() { auto feat = getObject(); auto body = feat->getFeatureBody(); - if(!body) return; + if(!body) + return; auto inset = feat->getInListEx(true); inset.emplace(feat); for(auto o : body->Group.getValues()) { diff --git a/src/Mod/PartDesign/Gui/Utils.cpp b/src/Mod/PartDesign/Gui/Utils.cpp index 6db7922e22..9fd9d45dc5 100644 --- a/src/Mod/PartDesign/Gui/Utils.cpp +++ b/src/Mod/PartDesign/Gui/Utils.cpp @@ -68,7 +68,8 @@ bool setEdit(App::DocumentObject *obj, PartDesign::Body *body) { } } auto *activeView = Gui::Application::Instance->activeView(); - if(!activeView) return false; + if(!activeView) + return false; App::DocumentObject *parent = nullptr; std::string subname; auto activeBody = activeView->getActiveObject(PDBODYKEY,&parent,&subname); @@ -451,7 +452,9 @@ bool isFeatureMovable(App::DocumentObject* const feat) return false; if (auto prop = static_cast(prim->getPropertyByName("Sections"))) { - if (std::any_of(prop->getValues().begin(), prop->getValues().end(), [](App::DocumentObject* obj){return !isFeatureMovable(obj); })) + if (std::any_of(prop->getValues().begin(), prop->getValues().end(), [](App::DocumentObject* obj){ + return !isFeatureMovable(obj); + })) return false; } diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp index 5a3c167b25..62b7f8bc6c 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp @@ -274,7 +274,8 @@ bool ViewProviderDatum::doubleClicked(void) if(!activeDoc) activeDoc = getDocument(); auto activeView = activeDoc->getActiveView(); - if(!activeView) return false; + if(!activeView) + return false; std::string Msg("Edit "); Msg += this->pcObject->Label.getValue(); diff --git a/src/Mod/PartDesign/Gui/ViewProviderDressUp.cpp b/src/Mod/PartDesign/Gui/ViewProviderDressUp.cpp index b961423f1c..7196da835e 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDressUp.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDressUp.cpp @@ -86,10 +86,12 @@ void ViewProviderDressUp::highlightReferences(const bool on) { PartDesign::DressUp* pcDressUp = static_cast(getObject()); Part::Feature* base = pcDressUp->getBaseObject (/*silent =*/ true); - if (base == nullptr) return; + if (base == nullptr) + return; PartGui::ViewProviderPart* vp = dynamic_cast( Gui::Application::Instance->getViewProvider(base)); - if (vp == nullptr) return; + if (vp == nullptr) + return; std::vector faces = pcDressUp->Base.getSubValuesStartsWith("Face"); std::vector edges = pcDressUp->Base.getSubValuesStartsWith("Edge"); diff --git a/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp b/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp index dc527007e3..2234fee4da 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp @@ -144,7 +144,8 @@ void ViewProviderShapeBinder::highlightReferences(const bool on, bool /*auxiliar PartGui::ViewProviderPart* svp = dynamic_cast( Gui::Application::Instance->getViewProvider(obj)); - if (svp == nullptr) return; + if (svp == nullptr) + return; if (on) { if (!subs.empty() && originalLineColors.empty()) { @@ -270,7 +271,8 @@ std::string ViewProviderSubShapeBinder::dropObjectEx(App::DocumentObject* obj, A const char* subname, const std::vector& elements) { auto self = dynamic_cast(getObject()); - if (!self) return std::string(); + if (!self) + return std::string(); std::map > values; if (!subname) subname = ""; std::string sub(subname); From 5f0d6f2a747d8b2063cbf8070fea7801801f3afc Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 12:37:49 -0500 Subject: [PATCH 24/39] Path: PR6497 move return statement to new line --- src/Mod/Path/App/Area.cpp | 45 +++++-- src/Mod/Path/App/FeatureArea.cpp | 6 +- src/Mod/Path/Gui/ViewProviderPath.cpp | 6 +- src/Mod/Path/libarea/Arc.cpp | 6 +- src/Mod/Path/libarea/Area.cpp | 21 ++- src/Mod/Path/libarea/AreaClipper.cpp | 3 +- src/Mod/Path/libarea/AreaPocket.cpp | 81 ++++++++---- src/Mod/Path/libarea/Circle.cpp | 9 +- src/Mod/Path/libarea/Curve.cpp | 39 ++++-- src/Mod/Path/libarea/PythonStuff.cpp | 6 +- src/Mod/Path/libarea/clipper.cpp | 138 +++++++++++++------- src/Mod/Path/libarea/dxf.cpp | 15 ++- src/Mod/Path/libarea/kurve/Construction.cpp | 69 ++++++---- src/Mod/Path/libarea/kurve/Finite.cpp | 99 +++++++++----- src/Mod/Path/libarea/kurve/Matrix.cpp | 15 ++- src/Mod/Path/libarea/kurve/kurve.cpp | 48 ++++--- src/Mod/Path/libarea/kurve/offset.cpp | 3 +- src/Mod/Path/libarea/pyarea.cpp | 6 +- 18 files changed, 411 insertions(+), 204 deletions(-) diff --git a/src/Mod/Path/App/Area.cpp b/src/Mod/Path/App/Area.cpp index d2209d9a75..3c7fee6eb2 100644 --- a/src/Mod/Path/App/Area.cpp +++ b/src/Mod/Path/App/Area.cpp @@ -265,8 +265,10 @@ static bool getShapePlane(const TopoDS_Shape &shape, gp_Pln &pln) { } bool Area::isCoplanar(const TopoDS_Shape &s1, const TopoDS_Shape &s2) { - if(s1.IsNull() || s2.IsNull()) return false; - if(s1.IsSame(s2)) return true; + if(s1.IsNull() || s2.IsNull()) + return false; + if(s1.IsSame(s2)) + return true; gp_Pln pln1,pln2; if(!getShapePlane(s1,pln1) || !getShapePlane(s2,pln2)) return false; @@ -290,7 +292,8 @@ int Area::addShape(CArea &area, const TopoDS_Shape &shape, const gp_Trsf *trsf, addWire(area,TopoDS::Wire(it.Current()),trsf,deflection); } - if(haveShape) return skipped; + if(haveShape) + return skipped; CArea _area; CArea _areaOpen; @@ -1052,7 +1055,8 @@ void Area::explode(const TopoDS_Shape &shape) { TopoDS::Edge(xp.Current())).Wire(),&myTrsf,myParams.Deflection,true); } } - if(haveShape) return; + if(haveShape) + return; for(TopExp_Explorer it(shape, TopAbs_EDGE); it.More(); it.Next()) { if(myParams.Coplanar!=CoplanarNone && !isCoplanar(it.Current(),plane)){ ++mySkippedShapes; @@ -1616,7 +1620,8 @@ std::list Area::getProjectedShapes(const gp_Trsf &trsf, bool invers } void Area::build() { - if(isBuilt()) return; + if(isBuilt()) + return; if(myShapes.empty()) throw Base::ValueError("no shape added"); @@ -1773,9 +1778,11 @@ TopoDS_Shape Area::getShape(int index) { build(); AREA_SECTION(getShape,index); - if(myShapeDone) return myShape; + if(myShapeDone) + return myShape; - if(!myArea) return TopoDS_Shape(); + if(!myArea) + return TopoDS_Shape(); CAreaConfig conf(myParams); @@ -2270,7 +2277,8 @@ TopoDS_Shape Area::toShape(const CArea &area, bool fill, const gp_Trsf *trsf, in builder.Add(compound,wire); } TopExp_Explorer xp(compound,TopAbs_EDGE); - if(!xp.More()) return TopoDS_Shape(); + if(!xp.More()) + return TopoDS_Shape(); if(fill) { try{ FC_TIME_INIT(t); @@ -2750,7 +2758,8 @@ struct ShapeInfoBuilder { if(type == TopAbs_EDGE) { BRepAdaptor_Curve curve(TopoDS::Edge(shape)); - if(curve.GetType()!=GeomAbs_Circle) return; + if(curve.GetType()!=GeomAbs_Circle) + return; }else{ bool found = false; for(TopExp_Explorer it(shape,TopAbs_EDGE);it.More();it.Next()) { @@ -2760,7 +2769,8 @@ struct ShapeInfoBuilder { break; } } - if(!found) return; + if(!found) + return; } gp_Ax3 pos = myList.back().myPln.Position(); if(!pos.Direct()) pos = gp_Ax3(pos.Ax2()); @@ -2788,15 +2798,21 @@ struct ShapeInfoBuilder { myArcPlaneFound = true; return; }case Area::ArcPlaneXY: - if(x0&&y0) {myArcPlaneFound=true;return;} + if(x0&&y0) {myArcPlaneFound=true; + return; + } dstPos = gp_Ax3(pos.Location(),gp_Dir(0,0,1)); break; case Area::ArcPlaneZX: - if(x0&&z0) {myArcPlaneFound=true;return;} + if(x0&&z0) {myArcPlaneFound=true; + return; + } dstPos = gp_Ax3(pos.Location(),gp_Dir(0,1,0)); break; case Area::ArcPlaneYZ: - if(z0&&y0) {myArcPlaneFound=true;return;} + if(z0&&y0) {myArcPlaneFound=true; + return; + } dstPos = gp_Ax3(pos.Location(),gp_Dir(1,0,0)); break; default: @@ -2873,7 +2889,8 @@ std::list Area::sortWires(const std::list &shapes, { std::list wires; - if(shapes.empty()) return wires; + if(shapes.empty()) + return wires; AxisGetter getter; AxisSetter setter; diff --git a/src/Mod/Path/App/FeatureArea.cpp b/src/Mod/Path/App/FeatureArea.cpp index 73d13606e1..c5c48b5c53 100644 --- a/src/Mod/Path/App/FeatureArea.cpp +++ b/src/Mod/Path/App/FeatureArea.cpp @@ -174,7 +174,8 @@ FeatureAreaView::FeatureAreaView() std::list FeatureAreaView::getShapes() { std::list shapes; App::DocumentObject* pObj = Source.getValue(); - if (!pObj) return shapes; + if (!pObj) + return shapes; if(!pObj->isDerivedFrom(FeatureArea::getClassTypeId())) return shapes; @@ -186,7 +187,8 @@ std::list FeatureAreaView::getShapes() { int index=SectionIndex.getValue(),count=SectionCount.getValue(); if(index<0) { index += ((int)all_shapes.size()); - if(index<0) return shapes; + if(index<0) + return shapes; if(count<=0 || index+1-count<0) { count = index+1; index = 0; diff --git a/src/Mod/Path/Gui/ViewProviderPath.cpp b/src/Mod/Path/Gui/ViewProviderPath.cpp index 7360128d98..870e937702 100644 --- a/src/Mod/Path/Gui/ViewProviderPath.cpp +++ b/src/Mod/Path/Gui/ViewProviderPath.cpp @@ -338,7 +338,8 @@ SoDetail* ViewProviderPath::getDetail(const char* subelement) const void ViewProviderPath::onChanged(const App::Property* prop) { - if(blockPropertyChange) return; + if(blockPropertyChange) + return; if (prop == &LineWidth) { pcDrawStyle->lineWidth = LineWidth.getValue(); @@ -648,7 +649,8 @@ void ViewProviderPath::updateVisual(bool rebuild) { for(i=StartIndex.getValue();i<(int)command2Edge.size();++i) if((edgeStart=command2Edge[i])>=0) break; - if(edgeStart<0) return; + if(edgeStart<0) + return; if(i!=StartIndex.getValue() && StartIndex.getValue()!=0) { blockPropertyChange = true; diff --git a/src/Mod/Path/libarea/Arc.cpp b/src/Mod/Path/libarea/Arc.cpp index fd357b8b3a..af65d52455 100644 --- a/src/Mod/Path/libarea/Arc.cpp +++ b/src/Mod/Path/libarea/Arc.cpp @@ -53,8 +53,10 @@ bool CArc::AlmostALine()const Point CArc::MidParam(double param)const { /// returns a point which is 0-1 along arc - if(fabs(param) < 0.00000000000001)return m_s; - if(fabs(param - 1.0) < 0.00000000000001)return m_e; + if(fabs(param) < 0.00000000000001) + return m_s; + if(fabs(param - 1.0) < 0.00000000000001) + return m_e; Point p; Point v = m_s - m_c; diff --git a/src/Mod/Path/libarea/Area.cpp b/src/Mod/Path/libarea/Area.cpp index 3ddccf2bd7..4346eb18a0 100644 --- a/src/Mod/Path/libarea/Area.cpp +++ b/src/Mod/Path/libarea/Area.cpp @@ -88,7 +88,8 @@ void CArea::ChangeStartToNearest(const Point *point, double min_dist) m_curves.erase(It); } - if(m_curves.empty()) return; + if(m_curves.empty()) + return; std::list curves; Point p; @@ -521,7 +522,8 @@ static void zigzag(const CArea &input_a) Point null_point(0, 0); rightward_for_zigs = true; - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; double step_percent_increment = 0.8 * CArea::m_single_area_processing_length / num_steps; @@ -544,7 +546,8 @@ static void zigzag(const CArea &input_a) a2.Intersect(a); make_zig(a2, y0, y); rightward_for_zigs = !rightward_for_zigs; - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; CArea::m_processing_done += step_percent_increment; } @@ -566,7 +569,8 @@ void CArea::SplitAndMakePocketToolpath(std::list &curve_list, const CAre CArea::m_processing_done = m_split_processing_length; CArea::m_units = save_units; - if(areas.size() == 0)return; + if(areas.size() == 0) + return; double single_area_length = 50.0 / areas.size(); @@ -601,7 +605,8 @@ void CArea::MakePocketToolpath(std::list &curve_list, const CAreaPocketP { std::list m_areas; a_offset.Split(m_areas); - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; if(m_areas.size() == 0) { CArea::m_processing_done += CArea::m_single_area_processing_length; @@ -644,7 +649,8 @@ void CArea::Split(std::list &m_areas)const CArea a = *this; a.Reorder(); - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; for(std::list::const_iterator It = a.m_curves.begin(); It != a.m_curves.end(); It++) { @@ -732,7 +738,8 @@ bool IsInside(const Point& p, const CArea& a) c.m_vertices.emplace_back(Point(p.x - 0.01, p.y - 0.01)); a2.m_curves.push_back(c); a2.Intersect(a); - if(fabs(a2.GetArea()) < 0.0004)return false; + if(fabs(a2.GetArea()) < 0.0004) + return false; return true; } diff --git a/src/Mod/Path/libarea/AreaClipper.cpp b/src/Mod/Path/libarea/AreaClipper.cpp index eb52e0425f..d3e9ff8397 100644 --- a/src/Mod/Path/libarea/AreaClipper.cpp +++ b/src/Mod/Path/libarea/AreaClipper.cpp @@ -303,7 +303,8 @@ static void MakePoly(const CCurve& curve, TPolygon &p, bool reverse = false) pts_for_AddVertex.clear(); const CVertex* prev_vertex = NULL; - if(!curve.m_vertices.size()) return; + if(!curve.m_vertices.size()) + return; if(!curve.IsClosed()) AddVertex(curve.m_vertices.front(),NULL); for (std::list::const_iterator It2 = curve.m_vertices.begin(); It2 != curve.m_vertices.end(); It2++) diff --git a/src/Mod/Path/libarea/AreaPocket.cpp b/src/Mod/Path/libarea/AreaPocket.cpp index 0dd13c9d27..e4ebde685a 100644 --- a/src/Mod/Path/libarea/AreaPocket.cpp +++ b/src/Mod/Path/libarea/AreaPocket.cpp @@ -85,7 +85,8 @@ void GetCurveItem::GetCurve(CCurve& output) // then add a line from the inner's point_on_parent to inner's start point, then GetCurve from inner // add start point - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; output.m_vertices.insert(this->EndIt, CVertex(curve_tree->curve.m_vertices.front())); std::list inners_to_visit; @@ -118,10 +119,12 @@ void GetCurveItem::GetCurve(CCurve& output) { It2++; } - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; } - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; for(std::multimap::iterator It2 = ordered_inners.begin(); It2 != ordered_inners.end(); It2++) { CurveTree& inner = *(It2->second); @@ -129,7 +132,8 @@ void GetCurveItem::GetCurve(CCurve& output) { output.m_vertices.insert(this->EndIt, CVertex(vertex.m_type, inner.point_on_parent, vertex.m_c)); } - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; // vertex add after GetCurve std::list::iterator VIt = output.m_vertices.insert(this->EndIt, CVertex(inner.point_on_parent)); @@ -143,7 +147,8 @@ void GetCurveItem::GetCurve(CCurve& output) prev_vertex = &vertex; } - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; for(std::list::iterator It2 = inners_to_visit.begin(); It2 != inners_to_visit.end(); It2++) { CurveTree &inner = *(*It2); @@ -151,7 +156,8 @@ void GetCurveItem::GetCurve(CCurve& output) { output.m_vertices.insert(this->EndIt, CVertex(inner.point_on_parent)); } - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; // vertex add after GetCurve std::list::iterator VIt = output.m_vertices.insert(this->EndIt, CVertex(inner.point_on_parent)); @@ -196,12 +202,14 @@ void CurveTree::MakeOffsets2() { // make offsets - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; CArea smaller; smaller.m_curves.push_back(curve); smaller.Offset(pocket_params->stepover); - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; // test islands for(std::list::iterator It = offset_islands.begin(); It != offset_islands.end();) @@ -215,11 +223,14 @@ void CurveTree::MakeOffsets2() inners.push_back(new CurveTree(*island_and_offset->island)); islands_added.push_back(inners.back()); inners.back()->point_on_parent = curve.NearestPoint(*island_and_offset->island); - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; Point island_point = island_and_offset->island->NearestPoint(inners.back()->point_on_parent); - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; inners.back()->curve.ChangeStart(island_point); - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; // add the island offset's inner curves for(std::list::const_iterator It2 = island_and_offset->island_inners.begin(); It2 != island_and_offset->island_inners.end(); It2++) @@ -227,12 +238,15 @@ void CurveTree::MakeOffsets2() const CCurve& island_inner = *It2; inners.back()->inners.push_back(new CurveTree(island_inner)); inners.back()->inners.back()->point_on_parent = inners.back()->curve.NearestPoint(island_inner); - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; Point island_point = island_inner.NearestPoint(inners.back()->inners.back()->point_on_parent); - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; inners.back()->inners.back()->curve.ChangeStart(island_point); to_do_list_for_MakeOffsets.push_back(inners.back()->inners.back()); // do it later, in a while loop - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; } smaller.Subtract(island_and_offset->offset); @@ -264,12 +278,15 @@ void CurveTree::MakeOffsets2() const CCurve& island_inner = *It2; touching.add_to->inners.back()->inners.push_back(new CurveTree(island_inner)); touching.add_to->inners.back()->inners.back()->point_on_parent = touching.add_to->inners.back()->curve.NearestPoint(island_inner); - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; Point island_point = island_inner.NearestPoint(touching.add_to->inners.back()->inners.back()->point_on_parent); - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; touching.add_to->inners.back()->inners.back()->curve.ChangeStart(island_point); to_do_list_for_MakeOffsets.push_back(touching.add_to->inners.back()->inners.back()); // do it later, in a while loop - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; } for(std::list::const_iterator It2 = touching.island_and_offset->touching_offsets.begin(); It2 != touching.island_and_offset->touching_offsets.end(); It2++) @@ -282,7 +299,8 @@ void CurveTree::MakeOffsets2() } } - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; It = offset_islands.erase(It); for(std::set::iterator It2 = added.begin(); It2 != added.end(); It2++) @@ -301,7 +319,8 @@ void CurveTree::MakeOffsets2() std::list separate_areas; smaller.Split(separate_areas); - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; for(std::list::iterator It = separate_areas.begin(); It != separate_areas.end(); It++) { CArea& separate_area = *It; @@ -317,18 +336,23 @@ void CurveTree::MakeOffsets2() const IslandAndOffset* island_and_offset = *It; if(GetOverlapType(island_and_offset->offset, separate_area) == eInside) nearest_curve_tree->inners.back()->offset_islands.push_back(island_and_offset); - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; } nearest_curve_tree->inners.back()->point_on_parent = near_point; - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; Point first_curve_point = first_curve.NearestPoint(nearest_curve_tree->inners.back()->point_on_parent); - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; nearest_curve_tree->inners.back()->curve.ChangeStart(first_curve_point); - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; to_do_list_for_MakeOffsets.push_back(nearest_curve_tree->inners.back()); // do it later, in a while loop - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; } } @@ -423,7 +447,8 @@ void MarkOverlappingOffsetIslands(std::list &offset_islands) void CArea::MakeOnePocketCurve(std::list &curve_list, const CAreaPocketParams ¶ms)const { - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; #if 0 // simple offsets with feed or rapid joins CArea area_for_feed_possible = *this; @@ -484,7 +509,8 @@ void CArea::MakeOnePocketCurve(std::list &curve_list, const CAreaPocketP IslandAndOffset island_and_offset(&c); offset_islands.push_back(island_and_offset); top_level.offset_islands.push_back(&(offset_islands.back())); - if(m_please_abort)return; + if(m_please_abort) + return; } } @@ -498,7 +524,8 @@ void CArea::MakeOnePocketCurve(std::list &curve_list, const CAreaPocketP CArea::m_MakeOffsets_increment = MakeOffsets_processing_length / guess_num_offsets; top_level.MakeOffsets(); - if(CArea::m_please_abort)return; + if(CArea::m_please_abort) + return; CArea::m_processing_done = CArea::m_after_MakeOffsets_length; curve_list.emplace_back(); diff --git a/src/Mod/Path/libarea/Circle.cpp b/src/Mod/Path/libarea/Circle.cpp index 6fc4a12eb1..ff973d89b4 100644 --- a/src/Mod/Path/libarea/Circle.cpp +++ b/src/Mod/Path/libarea/Circle.cpp @@ -93,11 +93,14 @@ bool Circle::LineIsOn(const Point& p0, const Point& p1, double accuracy) { // checks the points are on the arc, to the given accuracy, and the mid point of the line. - if(!PointIsOn(p0, accuracy))return false; - if(!PointIsOn(p1, accuracy))return false; + if(!PointIsOn(p0, accuracy)) + return false; + if(!PointIsOn(p1, accuracy)) + return false; Point mid = Point((p0 + p1)/2); - if(!PointIsOn(mid, accuracy))return false; + if(!PointIsOn(mid, accuracy)) + return false; return true; } \ No newline at end of file diff --git a/src/Mod/Path/libarea/Curve.cpp b/src/Mod/Path/libarea/Curve.cpp index 7141335778..f5dd918004 100644 --- a/src/Mod/Path/libarea/Curve.cpp +++ b/src/Mod/Path/libarea/Curve.cpp @@ -65,7 +65,8 @@ bool CCurve::CheckForArc(const CVertex& prev_vt, std::list& migh // this examines the vertices in might_be_an_arc // if they do fit an arc, set arc to be the arc that they fit and return true // returns true, if arc added - if(might_be_an_arc.size() < 2)return false; + if(might_be_an_arc.size() < 2) + return false; // find middle point std::size_t num = might_be_an_arc.size(); @@ -125,7 +126,8 @@ bool CCurve::CheckForArc(const CVertex& prev_vt, std::list& migh if(angs < ange)angs += 6.2831853071795864; } - if(arc.IncludedAngle() >= 3.15)return false; // We don't want full arcs, so limit to about 180 degrees + if(arc.IncludedAngle() >= 3.15) // We don't want full arcs, so limit to about 180 degrees + return false; for(std::list::iterator It = might_be_an_arc.begin(); It != might_be_an_arc.end(); It++) { @@ -135,13 +137,15 @@ bool CCurve::CheckForArc(const CVertex& prev_vt, std::list& migh { // make sure angp > angs if(angp < angs)angp += 6.2831853071795864; - if(angp > ange)return false; + if(angp > ange) + return false; } else { // make sure angp > ange if(angp < ange)angp += 6.2831853071795864; - if(angp > angs)return false; + if(angp > angs) + return false; } } @@ -489,7 +493,8 @@ double CCurve::GetArea()const bool CCurve::IsClosed()const { - if(m_vertices.size() == 0)return false; + if(m_vertices.size() == 0) + return false; return m_vertices.front().m_p == m_vertices.back().m_p; } @@ -911,7 +916,8 @@ double CCurve::Perim()const Point CCurve::PerimToPoint(double perim)const { - if(m_vertices.size() == 0)return Point(0, 0); + if(m_vertices.size() == 0) + return Point(0, 0); const Point *prev_p = NULL; double kperim = 0.0; @@ -1037,7 +1043,8 @@ Point Span::NearestPointNotOnSpan(const Point& p)const { double radius = m_p.dist(m_v.m_c); double r = p.dist(m_v.m_c); - if(r < Point::tolerance)return m_p; + if(r < Point::tolerance) + return m_p; Point vc = (m_v.m_c - p); return p + vc * ((r - radius) / r); } @@ -1047,12 +1054,14 @@ Point Span::NearestPoint(const Point& p)const { Point np = NearestPointNotOnSpan(p); double t = Parameter(np); - if(t >= 0.0 && t <= 1.0)return np; + if(t >= 0.0 && t <= 1.0) + return np; double d1 = p.dist(this->m_p); double d2 = p.dist(this->m_v.m_p); - if(d1 < d2)return this->m_p; + if(d1 < d2) + return this->m_p; else return m_v.m_p; } @@ -1075,8 +1084,10 @@ Point Span::MidPerim(double d)const { Point Span::MidParam(double param)const { /// returns a point which is 0-1 along span - if(fabs(param) < 0.00000000000001)return m_p; - if(fabs(param - 1.0) < 0.00000000000001)return m_v.m_p; + if(fabs(param) < 0.00000000000001) + return m_p; + if(fabs(param - 1.0) < 0.00000000000001) + return m_v.m_p; Point p; if(m_v.m_type == 0) { @@ -1189,7 +1200,8 @@ void Span::GetBox(CBox2D &box) double IncludedAngle(const Point& v0, const Point& v1, int dir) { // returns the absolute included angle between 2 vectors in the direction of dir ( 1=acw -1=cw) double inc_ang = v0 * v1; - if(inc_ang > 1. - 1.0e-10) return 0; + if(inc_ang > 1. - 1.0e-10) + return 0; if(inc_ang < -1. + 1.0e-10) inc_ang = PI; else { // dot product, v1 . v2 = cos ang @@ -1264,7 +1276,8 @@ double Span::Parameter(const Point& p)const bool Span::On(const Point& p, double* t)const { - if(p != NearestPoint(p))return false; + if(p != NearestPoint(p)) + return false; if(t)*t = Parameter(p); return true; } diff --git a/src/Mod/Path/libarea/PythonStuff.cpp b/src/Mod/Path/libarea/PythonStuff.cpp index 7ae208ce03..87f54a8712 100644 --- a/src/Mod/Path/libarea/PythonStuff.cpp +++ b/src/Mod/Path/libarea/PythonStuff.cpp @@ -204,7 +204,8 @@ boost::python::list getCurveSpans(const CCurve& c) Span getFirstCurveSpan(const CCurve& c) { - if(c.m_vertices.size() < 2)return Span(); + if(c.m_vertices.size() < 2) + return Span(); std::list::const_iterator VIt = c.m_vertices.begin(); const Point &p = (*VIt).m_p; @@ -214,7 +215,8 @@ Span getFirstCurveSpan(const CCurve& c) Span getLastCurveSpan(const CCurve& c) { - if(c.m_vertices.size() < 2)return Span(); + if(c.m_vertices.size() < 2) + return Span(); std::list::const_reverse_iterator VIt = c.m_vertices.rbegin(); const CVertex &v = (*VIt); diff --git a/src/Mod/Path/libarea/clipper.cpp b/src/Mod/Path/libarea/clipper.cpp index e1277f0583..89799588ab 100644 --- a/src/Mod/Path/libarea/clipper.cpp +++ b/src/Mod/Path/libarea/clipper.cpp @@ -134,7 +134,8 @@ struct LocMinSorter inline cInt Round(double val) { - if ((val < 0)) return static_cast(val - 0.5); + if ((val < 0)) + return static_cast(val - 0.5); else return static_cast(val + 0.5); } //------------------------------------------------------------------------------ @@ -337,7 +338,8 @@ class Int128 const double shift64 = 18446744073709551616.0; //2^64 if (hi < 0) { - if (lo == 0) return (double)hi * shift64; + if (lo == 0) + return (double)hi * shift64; else return -(double)(~lo + ~hi * shift64); } else @@ -394,7 +396,8 @@ bool Orientation(const Path &poly) double Area(const Path &poly) { int size = (int)poly.size(); - if (size < 3) return 0; + if (size < 3) + return 0; double a = 0; for (int i = 0, j = size -1; i < size; ++i) @@ -409,7 +412,8 @@ double Area(const Path &poly) double Area(const OutRec &outRec) { OutPt *op = outRec.Pts; - if (!op) return 0; + if (!op) + return 0; double a = 0; do { a += (double)(op->Prev->Pt.X + op->Pt.X) * (double)(op->Prev->Pt.Y - op->Pt.Y); @@ -424,7 +428,8 @@ bool PointIsVertex(const IntPoint &Pt, OutPt *pp) OutPt *pp2 = pp; do { - if (pp2->Pt == Pt) return true; + if (pp2->Pt == Pt) + return true; pp2 = pp2->Next; } while (pp2 != pp); @@ -439,7 +444,8 @@ int PointInPolygon (const IntPoint &pt, const Path &path) //http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.88.5498&rep=rep1&type=pdf int result = 0; size_t cnt = path.size(); - if (cnt < 3) return 0; + if (cnt < 3) + return 0; IntPoint ip = path[0]; for(size_t i = 1; i <= cnt; ++i) { @@ -458,7 +464,8 @@ int PointInPolygon (const IntPoint &pt, const Path &path) { double d = (double)(ip.X - pt.X) * (ipNext.Y - pt.Y) - (double)(ipNext.X - pt.X) * (ip.Y - pt.Y); - if (!d) return -1; + if (!d) + return -1; if ((d > 0) == (ipNext.Y > ip.Y)) result = 1 - result; } } else @@ -467,7 +474,8 @@ int PointInPolygon (const IntPoint &pt, const Path &path) { double d = (double)(ip.X - pt.X) * (ipNext.Y - pt.Y) - (double)(ipNext.X - pt.X) * (ip.Y - pt.Y); - if (!d) return -1; + if (!d) + return -1; if ((d > 0) == (ipNext.Y > ip.Y)) result = 1 - result; } } @@ -499,7 +507,8 @@ int PointInPolygon (const IntPoint &pt, OutPt *op) { double d = (double)(op->Pt.X - pt.X) * (op->Next->Pt.Y - pt.Y) - (double)(op->Next->Pt.X - pt.X) * (op->Pt.Y - pt.Y); - if (!d) return -1; + if (!d) + return -1; if ((d > 0) == (op->Next->Pt.Y > op->Pt.Y)) result = 1 - result; } } else @@ -508,7 +517,8 @@ int PointInPolygon (const IntPoint &pt, OutPt *op) { double d = (double)(op->Pt.X - pt.X) * (op->Next->Pt.Y - pt.Y) - (double)(op->Next->Pt.X - pt.X) * (op->Pt.Y - pt.Y); - if (!d) return -1; + if (!d) + return -1; if ((d > 0) == (op->Next->Pt.Y > op->Pt.Y)) result = 1 - result; } } @@ -527,7 +537,8 @@ bool Poly2ContainsPoly1(OutPt *OutPt1, OutPt *OutPt2) { //nb: PointInPolygon returns 0 if false, +1 if true, -1 if pt on polygon int res = PointInPolygon(op->Pt, OutPt2); - if (res >= 0) return res > 0; + if (res >= 0) + return res > 0; op = op->Next; } while (op != OutPt1); @@ -688,7 +699,8 @@ void IntersectPoint(TEdge &Edge1, TEdge &Edge2, IntPoint &ip) void ReversePolyPtLinks(OutPt *pp) { - if (!pp) return; + if (!pp) + return; OutPt *pp1, *pp2; pp1 = pp; do { @@ -702,7 +714,8 @@ void ReversePolyPtLinks(OutPt *pp) void DisposeOutPts(OutPt*& pp) { - if (pp == 0) return; + if (pp == 0) + return; pp->Prev->Next = 0; while( pp ) { @@ -1058,7 +1071,8 @@ bool ClipperBase::AddPath(const Path &pg, PolyType PolyTyp, bool Closed) int highI = (int)pg.size() -1; if (Closed) while (highI > 0 && (pg[highI] == pg[0])) --highI; while (highI > 0 && (pg[highI] == pg[highI -1])) --highI; - if ((Closed && highI < 2) || (!Closed && highI < 1)) return false; + if ((Closed && highI < 2) || (!Closed && highI < 1)) + return false; //create a new edge array ... TEdge *edges = new TEdge [highI +1]; @@ -1254,7 +1268,8 @@ void ClipperBase::Clear() void ClipperBase::Reset() { m_CurrentLM = m_MinimaList.begin(); - if (m_CurrentLM == m_MinimaList.end()) return; //ie nothing to process + if (m_CurrentLM == m_MinimaList.end()) //ie nothing to process + return; std::sort(m_MinimaList.begin(), m_MinimaList.end(), LocMinSorter()); //reset all edges ... @@ -1288,7 +1303,8 @@ void ClipperBase::DisposeLocalMinimaList() void ClipperBase::PopLocalMinima() { - if (m_CurrentLM == m_MinimaList.end()) return; + if (m_CurrentLM == m_MinimaList.end()) + return; ++m_CurrentLM; } //------------------------------------------------------------------------------ @@ -1383,7 +1399,8 @@ void Clipper::Reset() bool Clipper::Execute(ClipType clipType, Paths &solution, PolyFillType subjFillType, PolyFillType clipFillType) { - if( m_ExecuteLocked ) return false; + if( m_ExecuteLocked ) + return false; if (m_HasOpenPaths) throw clipperException("Error: PolyTree struct is need for open path clipping."); m_ExecuteLocked = true; @@ -1403,7 +1420,8 @@ bool Clipper::Execute(ClipType clipType, Paths &solution, bool Clipper::Execute(ClipType clipType, PolyTree& polytree, PolyFillType subjFillType, PolyFillType clipFillType) { - if( m_ExecuteLocked ) return false; + if( m_ExecuteLocked ) + return false; m_ExecuteLocked = true; m_SubjFillType = subjFillType; m_ClipFillType = clipFillType; @@ -1437,7 +1455,8 @@ bool Clipper::ExecuteInternal() bool succeeded = true; try { Reset(); - if (m_CurrentLM == m_MinimaList.end()) return true; + if (m_CurrentLM == m_MinimaList.end()) + return true; cInt botY = PopScanbeam(); do { InsertLocalMinimaIntoAEL(botY); @@ -1646,16 +1665,20 @@ bool Clipper::IsContributing(const TEdge& edge) const { case pftEvenOdd: //return false if a subj line has been flagged as inside a subj polygon - if (edge.WindDelta == 0 && edge.WindCnt != 1) return false; + if (edge.WindDelta == 0 && edge.WindCnt != 1) + return false; break; case pftNonZero: - if (Abs(edge.WindCnt) != 1) return false; + if (Abs(edge.WindCnt) != 1) + return false; break; case pftPositive: - if (edge.WindCnt != 1) return false; + if (edge.WindCnt != 1) + return false; break; default: //pftNegative - if (edge.WindCnt != -1) return false; + if (edge.WindCnt != -1) + return false; } switch(m_ClipType) @@ -1954,7 +1977,8 @@ void Clipper::DeleteFromAEL(TEdge *e) { TEdge* AelPrev = e->PrevInAEL; TEdge* AelNext = e->NextInAEL; - if( !AelPrev && !AelNext && (e != m_ActiveEdges) ) return; //already deleted + if( !AelPrev && !AelNext && (e != m_ActiveEdges) ) //already deleted + return; if( AelPrev ) AelPrev->NextInAEL = AelNext; else m_ActiveEdges = AelNext; if( AelNext ) AelNext->PrevInAEL = AelPrev; @@ -1967,7 +1991,8 @@ void Clipper::DeleteFromSEL(TEdge *e) { TEdge* SelPrev = e->PrevInSEL; TEdge* SelNext = e->NextInSEL; - if( !SelPrev && !SelNext && (e != m_SortedEdges) ) return; //already deleted + if( !SelPrev && !SelNext && (e != m_SortedEdges) ) //already deleted + return; if( SelPrev ) SelPrev->NextInSEL = SelNext; else m_SortedEdges = SelNext; if( SelNext ) SelNext->PrevInSEL = SelPrev; @@ -1979,7 +2004,8 @@ void Clipper::DeleteFromSEL(TEdge *e) #ifdef use_xyz void Clipper::SetZ(IntPoint& pt, TEdge& e1, TEdge& e2) { - if (pt.Z != 0 || !m_ZFill) return; + if (pt.Z != 0 || !m_ZFill) + return; else if (pt == e1.Bot) pt.Z = e1.Bot.Z; else if (pt == e1.Top) pt.Z = e1.Top.Z; else if (pt == e2.Bot) pt.Z = e2.Bot.Z; @@ -2004,7 +2030,8 @@ void Clipper::IntersectEdges(TEdge *e1, TEdge *e2, IntPoint &Pt) { //ignore subject-subject open path intersections UNLESS they //are both open paths, AND they are both 'contributing maximas' ... - if (e1->WindDelta == 0 && e2->WindDelta == 0) return; + if (e1->WindDelta == 0 && e2->WindDelta == 0) + return; //if intersecting a subj line with a subj poly ... else if (e1->PolyTyp == e2->PolyTyp && @@ -2211,7 +2238,8 @@ OutRec* GetLowermostRec(OutRec *outRec1, OutRec *outRec2) outRec2->BottomPt = GetBottomPt(outRec2->Pts); OutPt *OutPt1 = outRec1->BottomPt; OutPt *OutPt2 = outRec2->BottomPt; - if (OutPt1->Pt.Y > OutPt2->Pt.Y) return outRec1; + if (OutPt1->Pt.Y > OutPt2->Pt.Y) + return outRec1; else if (OutPt1->Pt.Y < OutPt2->Pt.Y) return outRec2; else if (OutPt1->Pt.X < OutPt2->Pt.X) return outRec1; else if (OutPt1->Pt.X > OutPt2->Pt.X) return outRec2; @@ -2227,7 +2255,8 @@ bool Param1RightOfParam2(OutRec* outRec1, OutRec* outRec2) do { outRec1 = outRec1->FirstLeft; - if (outRec1 == outRec2) return true; + if (outRec1 == outRec2) + return true; } while (outRec1); return false; } @@ -2379,7 +2408,8 @@ OutPt* Clipper::AddOutPt(TEdge *e, const IntPoint &pt) //OutRec.Pts is the 'Left-most' point & OutRec.Pts.Prev is the 'Right-most' OutPt* op = outRec->Pts; - if (ToFront && (pt == op->Pt)) return op; + if (ToFront && (pt == op->Pt)) + return op; else if (!ToFront && (pt == op->Prev->Pt)) return op->Prev; OutPt* newOp = new OutPt; @@ -2490,8 +2520,10 @@ void Clipper::SwapPositionsInAEL(TEdge *Edge1, TEdge *Edge2) void Clipper::SwapPositionsInSEL(TEdge *Edge1, TEdge *Edge2) { - if( !( Edge1->NextInSEL ) && !( Edge1->PrevInSEL ) ) return; - if( !( Edge2->NextInSEL ) && !( Edge2->PrevInSEL ) ) return; + if( !( Edge1->NextInSEL ) && !( Edge1->PrevInSEL ) ) + return; + if( !( Edge2->NextInSEL ) && !( Edge2->PrevInSEL ) ) + return; if( Edge1->NextInSEL == Edge2 ) { @@ -2655,7 +2687,8 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge, bool isTopOfScanbeam) OutPt* op1 = AddOutPt( horzEdge, horzEdge->Top); if (isTopOfScanbeam) AddGhostJoin(op1, horzEdge->Bot); UpdateEdgeIntoAEL(horzEdge); - if (horzEdge->WindDelta == 0) return; + if (horzEdge->WindDelta == 0) + return; //nb: HorzEdge is no longer horizontal here TEdge* ePrev = horzEdge->PrevInAEL; TEdge* eNext = horzEdge->NextInAEL; @@ -2712,11 +2745,13 @@ void Clipper::UpdateEdgeIntoAEL(TEdge *&e) bool Clipper::ProcessIntersections(const cInt topY) { - if( !m_ActiveEdges ) return true; + if( !m_ActiveEdges ) + return true; try { BuildIntersectList(topY); size_t IlSize = m_IntersectList.size(); - if (IlSize == 0) return true; + if (IlSize == 0) + return true; if (IlSize == 1 || FixupIntersectionOrder()) ProcessIntersectList(); else return false; } @@ -2741,7 +2776,8 @@ void Clipper::DisposeIntersectNodes() void Clipper::BuildIntersectList(const cInt topY) { - if ( !m_ActiveEdges ) return; + if ( !m_ActiveEdges ) + return; //prepare for sorting ... TEdge* e = m_ActiveEdges; @@ -2830,7 +2866,8 @@ bool Clipper::FixupIntersectionOrder() { size_t j = i + 1; while (j < cnt && !EdgesAdjacent(*m_IntersectList[j])) j++; - if (j == cnt) return false; + if (j == cnt) + return false; std::swap(m_IntersectList[i], m_IntersectList[j]); } SwapPositionsInSEL(m_IntersectList[i]->Edge1, m_IntersectList[i]->Edge2); @@ -3033,7 +3070,8 @@ void Clipper::FixupOutPolygon(OutRec &outrec) int PointCount(OutPt *Pts) { - if (!Pts) return 0; + if (!Pts) + return 0; int result = 0; OutPt* p = Pts; do @@ -3223,7 +3261,8 @@ bool JoinHorz(OutPt* op1, OutPt* op1b, OutPt* op2, OutPt* op2b, { Direction Dir1 = (op1->Pt.X > op1b->Pt.X ? dRightToLeft : dLeftToRight); Direction Dir2 = (op2->Pt.X > op2b->Pt.X ? dRightToLeft : dLeftToRight); - if (Dir1 == Dir2) return false; + if (Dir1 == Dir2) + return false; //When DiscardLeft, we want Op1b to be on the Left of Op1, otherwise we //want Op1b to be on the Right. (And likewise with Op2 and Op2b.) @@ -3323,7 +3362,8 @@ bool Clipper::JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2) (j->OffPt == j->OutPt2->Pt)) { //Strictly Simple join ... - if (outRec1 != outRec2) return false; + if (outRec1 != outRec2) + return false; op1b = j->OutPt1->Next; while (op1b != op1 && (op1b->Pt == j->OffPt)) op1b = op1b->Next; @@ -3332,7 +3372,8 @@ bool Clipper::JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2) while (op2b != op2 && (op2b->Pt == j->OffPt)) op2b = op2b->Next; bool reverse2 = (op2b->Pt.Y > j->OffPt.Y); - if (reverse1 == reverse2) return false; + if (reverse1 == reverse2) + return false; if (reverse1) { op1b = DupOutPt(op1, false); @@ -3367,14 +3408,16 @@ bool Clipper::JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2) op1 = op1->Prev; while (op1b->Next->Pt.Y == op1b->Pt.Y && op1b->Next != op1 && op1b->Next != op2) op1b = op1b->Next; - if (op1b->Next == op1 || op1b->Next == op2) return false; //a flat 'polygon' + if (op1b->Next == op1 || op1b->Next == op2) //a flat 'polygon' + return false; op2b = op2; while (op2->Prev->Pt.Y == op2->Pt.Y && op2->Prev != op2b && op2->Prev != op1b) op2 = op2->Prev; while (op2b->Next->Pt.Y == op2b->Pt.Y && op2b->Next != op2 && op2b->Next != op1) op2b = op2b->Next; - if (op2b->Next == op2 || op2b->Next == op1) return false; //a flat 'polygon' + if (op2b->Next == op2 || op2b->Next == op1) //a flat 'polygon' + return false; cInt Left, Right; //Op1 --> Op1b & Op2 --> Op2b are the extremites of the horizontal edges @@ -3653,7 +3696,8 @@ void ClipperOffset::Clear() void ClipperOffset::AddPath(const Path& path, JoinType joinType, EndType endType) { int highI = (int)path.size() - 1; - if (highI < 0) return; + if (highI < 0) + return; PolyNode* newNode = new PolyNode(); newNode->m_jointype = joinType; newNode->m_endtype = endType; @@ -3681,7 +3725,8 @@ void ClipperOffset::AddPath(const Path& path, JoinType joinType, EndType endType m_polyNodes.AddChild(*newNode); //if this path's lowest pt is lower than all the others then update m_lowest - if (endType != etClosedPolygon) return; + if (endType != etClosedPolygon) + return; if (m_lowest.X < 0) m_lowest = IntPoint(m_polyNodes.ChildCount() - 1, k); else @@ -4450,7 +4495,8 @@ std::ostream& operator <<(std::ostream &s, const IntPoint &p) std::ostream& operator <<(std::ostream &s, const Path &p) { - if (p.empty()) return s; + if (p.empty()) + return s; Path::size_type last = p.size() -1; for (Path::size_type i = 0; i < last; i++) s << "(" << p[i].X << "," << p[i].Y << "), "; diff --git a/src/Mod/Path/libarea/dxf.cpp b/src/Mod/Path/libarea/dxf.cpp index 290ed46be7..e5ff5b4a2a 100644 --- a/src/Mod/Path/libarea/dxf.cpp +++ b/src/Mod/Path/libarea/dxf.cpp @@ -1047,7 +1047,8 @@ bool CDxfRead::ReadLwPolyLine() case 70: // flags get_line(); - if(sscanf(m_str, "%d", &flags) != 1)return false; + if(sscanf(m_str, "%d", &flags) != 1) + return false; closed = ((flags & 1) != 0); break; case 62: @@ -1207,7 +1208,8 @@ bool CDxfRead::ReadPolyLine() case 70: // flags get_line(); - if(sscanf(m_str, "%d", &flags) != 1)return false; + if(sscanf(m_str, "%d", &flags) != 1) + return false; closed = ((flags & 1) != 0); break; case 62: @@ -1452,7 +1454,8 @@ bool CDxfRead::ReadLayer() case 62: // layer color ; if negative, layer is off get_line(); - if(sscanf(m_str, "%d", &aci) != 1)return false; + if(sscanf(m_str, "%d", &aci) != 1) + return false; break; case 6: // linetype name @@ -1476,14 +1479,16 @@ bool CDxfRead::ReadLayer() void CDxfRead::DoRead(const bool ignore_errors /* = false */ ) { m_ignore_errors = ignore_errors; - if(m_fail)return; + if(m_fail) + return; get_line(); while(!((*m_ifs).eof())) { if (!strcmp( m_str, "$INSUNITS" )){ - if (!ReadUnits())return; + if (!ReadUnits()) + return; continue; } // End if - then diff --git a/src/Mod/Path/libarea/kurve/Construction.cpp b/src/Mod/Path/libarea/kurve/Construction.cpp index 6cd0a37c3b..837e362fa3 100644 --- a/src/Mod/Path/libarea/kurve/Construction.cpp +++ b/src/Mod/Path/libarea/kurve/Construction.cpp @@ -150,7 +150,8 @@ namespace geoff_geometry { bool Point3d::operator==(const Point3d &p)const{ // p1 == p2 (uses TOLERANCE) - if(FNE(this->x, p.x, TOLERANCE) || FNE(this->y, p.y, TOLERANCE) || FNE(this->z, p.z, TOLERANCE)) return false; + if(FNE(this->x, p.x, TOLERANCE) || FNE(this->y, p.y, TOLERANCE) || FNE(this->z, p.z, TOLERANCE)) + return false; return true; } @@ -179,7 +180,8 @@ namespace geoff_geometry { bool Point::operator==(const Point &p) const{ // p1 == p2 (uses TOLERANCE) - if(FNE(this->x, p.x, TOLERANCE) || FNE(this->y, p.y, TOLERANCE)) return false; + if(FNE(this->x, p.x, TOLERANCE) || FNE(this->y, p.y, TOLERANCE)) + return false; return true; } @@ -504,12 +506,15 @@ namespace geoff_geometry { intof = s.Intof(normal); double d = intof.Dist(c.pc); - if(fabs(d - c.radius) < TOLERANCE) return intof; // tangent (near enough for non-large radius I suppose?) + if(fabs(d - c.radius) < TOLERANCE) // tangent (near enough for non-large radius I suppose?) + return intof; - if(d > c.radius + TOLERANCE) return INVALID_POINT; // no intersection + if(d > c.radius + TOLERANCE) // no intersection + return INVALID_POINT; double q = (c.radius - d) * (c.radius + d); - if(q < 0) return intof; // line inside tolerance + if(q < 0) // line inside tolerance + return intof; return Along(s, -(double)NF * sqrt(q), intof); // 2 intersections (return near/far case) } @@ -545,20 +550,24 @@ namespace geoff_geometry { // returns the number of intersctions Vector2d v(c0.pc, c1.pc); double d = v.normalise(); - if(d < TOLERANCE) return 0; // co-incident circles + if(d < TOLERANCE) // co-incident circles + return 0; double sum = fabs(c0.radius) + fabs(c1.radius); double diff = fabs(fabs(c0.radius) - fabs(c1.radius)); - if(d > sum + TOLERANCE || d < diff - TOLERANCE) return 0; + if(d > sum + TOLERANCE || d < diff - TOLERANCE) + return 0; // dist from centre of this circle to mid intersection double d0 = 0.5 * (d + (c0.radius + c1.radius) * (c0.radius - c1.radius) / d); - if(d0 - c0.radius > TOLERANCE) return 0; // circles don't intersect + if(d0 - c0.radius > TOLERANCE) // circles don't intersect + return 0; double h = (c0.radius - d0) * (c0.radius + d0); // half distance between intersects squared if(h < 0) d0 = c0.radius; // tangent pLeft = v * d0 + c0.pc; // mid-point of intersects - if(h < TOLERANCE_SQ) return 1; // tangent + if(h < TOLERANCE_SQ) // tangent + return 1; h = sqrt(h); v = ~v; // calculate 2 intersects @@ -571,7 +580,8 @@ namespace geoff_geometry { Circle Tanto(int NF, CLine& s0, Point& p, double rad) { // circle tanto a CLine thro' a point double d = s0.Dist(p); - if(fabs(d) > rad + TOLERANCE) return INVALID_CIRCLE; // point too far from line + if(fabs(d) > rad + TOLERANCE) // point too far from line + return INVALID_CIRCLE; CLine s0offset = Parallel(RIGHTINT, s0, rad); return Circle(Intof(NF, s0offset, Circle(p, rad)), rad); @@ -590,11 +600,13 @@ namespace geoff_geometry { double d = s1.v.gety() * (AT2 * s3.v.getx() - AT3 * s2.v.getx()) + s2.v.gety() * (AT3 * s1.v.getx() - AT1 * s3.v.getx()) + s3.v.gety() * (AT1 * s2.v.getx() - AT2 * s1.v.getx()); - if(fabs(d) < UNIT_VECTOR_TOLERANCE) return INVALID_CIRCLE; + if(fabs(d) < UNIT_VECTOR_TOLERANCE) + return INVALID_CIRCLE; double radius = (s1.v.gety() * (s2.v.getx() * s3c - s3.v.getx() * s2c) + s2.v.gety() * (s3.v.getx() * s1c - s1.v.getx() * s3c) + s3.v.gety() * (s1.v.getx() * s2c - s2.v.getx() * s1c)) / d ; - if(radius < TOLERANCE) return INVALID_CIRCLE; + if(radius < TOLERANCE) + return INVALID_CIRCLE; CLine Offs1 = Parallel(AT1, s1, radius); CLine Offs2 = Parallel(AT2, s2, radius); @@ -603,7 +615,8 @@ namespace geoff_geometry { if(!p.ok) { CLine Offs3 = Parallel(AT3, s3, radius); // s1 & s2 parallel p = Intof(Offs1, Offs3); - if(!p.ok) return INVALID_CIRCLE; // 3 parallel lines + if(!p.ok) // 3 parallel lines + return INVALID_CIRCLE; } return Circle(p, radius); } @@ -614,7 +627,8 @@ namespace geoff_geometry { double d = 0.5 * p0.Dist(p1); Point pm = Mid(p0, p1); - if(d > rad + TOLERANCE) return INVALID_CIRCLE; + if(d > rad + TOLERANCE) + return INVALID_CIRCLE; else if(d > rad - TOLERANCE) { // within tolerance of centre of 2 points return Circle(pm, d); @@ -634,13 +648,16 @@ namespace geoff_geometry { Circle Thro(const Point& p0, const Point& p1, const Point& p2) { // circle thro 3 points CLine s0(p0, p1); - if(!s0.ok) return Thro(p1,p2); // p0 & p1 coincident + if(!s0.ok) // p0 & p1 coincident + return Thro(p1,p2); CLine s1(p0, p2); - if(!s1.ok) return Thro(p0, p1); // p0 & p2 coincident + if(!s1.ok) // p0 & p2 coincident + return Thro(p0, p1); CLine s2(p2, p1); - if(!s2.ok) return Thro(p0, p2); // p1 & p2 coincident + if(!s2.ok) // p1 & p2 coincident + return Thro(p0, p2); Point p = Intof(Normal(s0, Mid(p0, p1)), Normal(s1, Mid(p0, p2))); return (p.ok)? Circle(p, p0.Dist(p)) : INVALID_CIRCLE; @@ -707,7 +724,8 @@ namespace geoff_geometry { double IncludedAngle(const Vector2d& v0, const Vector2d& v1, int dir) { // returns the absolute included angle between 2 vectors in the direction of dir ( 1=acw -1=cw) double inc_ang = v0 * v1; - if(inc_ang > 1. - UNIT_VECTOR_TOLERANCE) return 0; + if(inc_ang > 1. - UNIT_VECTOR_TOLERANCE) + return 0; if(inc_ang < -1. + UNIT_VECTOR_TOLERANCE) inc_ang = PI; else { // dot product, v1 . v2 = cos ang @@ -740,7 +758,8 @@ namespace geoff_geometry { // 1 (LEFT) = left turn // -1 (RIGHT) = right turn double cp = v0 ^ v1; - if(fabs(cp) < cpTol) return TANGENT; + if(fabs(cp) < cpTol) + return TANGENT; return (cp > 0)?GEOFF_LEFT : GEOFF_RIGHT; } @@ -752,14 +771,16 @@ namespace geoff_geometry { double epsilon = (geoff_geometry::UNITS == METRES)?1.0e-09 : 1.0e-06; double epsilonsq = epsilon * epsilon; if(fabs(a) < epsilon) { - if(fabs(b) < epsilon) return 0; // invalid + if(fabs(b) < epsilon) // invalid + return 0; x0 = - c / b; return 1; } b /= a; c /= a; double s = b * b - 4 * c; - if(s < -epsilon) return 0; // imaginary roots + if(s < -epsilon) // imaginary roots + return 0; x0 = - 0.5 * b; if(s > epsilonsq) { s = 0.5 * sqrt(s); @@ -810,7 +831,8 @@ namespace geoff_geometry { // output intof // method returns true for valid intersection double den = l.v * this->normal; - if(fabs(den) < UNIT_VECTOR_TOLERANCE) return false; // line is parallel to the plane, return false, even if the line lies on the plane + if(fabs(den) < UNIT_VECTOR_TOLERANCE) // line is parallel to the plane, return false, even if the line lies on the plane + return false; t = -(normal * Vector3d(l.p0) + d) / den; intof = l.v * t + l.p0; @@ -822,7 +844,8 @@ namespace geoff_geometry { Vector3d d = this->normal ^ pl.normal; d.normalise(); intof.ok = false; - if(d == NULL_VECTOR) return false; // parallel planes + if(d == NULL_VECTOR) // parallel planes + return false; intof.v = d; intof.length = 1; diff --git a/src/Mod/Path/libarea/kurve/Finite.cpp b/src/Mod/Path/libarea/kurve/Finite.cpp index 137209c7e2..d84d20d850 100644 --- a/src/Mod/Path/libarea/kurve/Finite.cpp +++ b/src/Mod/Path/libarea/kurve/Finite.cpp @@ -18,7 +18,8 @@ namespace geoff_geometry { int Intof(const Span& sp0, const Span& sp1, Point& p0, Point& p1, double t[4]) { // returns the number of intersects (lying within spans sp0, sp1) - if(sp0.box.outside(sp1.box) == true) return 0; + if(sp0.box.outside(sp1.box) == true) + return 0; if(!sp0.dir) { if(!sp1.dir) { // line line @@ -64,9 +65,11 @@ namespace geoff_geometry { double toler = geoff_geometry::TOLERANCE / sp0.length; // calc a parametric tolerance t[1] = (v0 ^ v2) / cp; - if(t[0] < -toler || t[0] > 1 + toler) return 0; // intersection on first? + if(t[0] < -toler || t[0] > 1 + toler) // intersection on first? + return 0; toler = geoff_geometry::TOLERANCE / sp1.length; // calc a parametric tolerance - if(t[1] < -toler || t[1] > 1 + toler) return 0; // intersection on second? + if(t[1] < -toler || t[1] > 1 + toler) // intersection on second? + return 0; return 1; } @@ -237,7 +240,8 @@ namespace geoff_geometry { bool Line::atZ(double z, Point3d& p)const { // returns p at z on line - if(FEQZ(this->v.getz())) return false; + if(FEQZ(this->v.getz())) + return false; double t = (z - this->p0.z) / this->v.getz(); p = Point3d(this->p0.x + t * this->v.getx(), this->p0.y + t * this->v.gety(), z); return true; @@ -259,7 +263,8 @@ namespace geoff_geometry { */ Vector3d v13(l2.p0, this->p0); - if(this->ok == false || l2.ok == false) return false; + if(this->ok == false || l2.ok == false) + return false; double d1343 = v13 * l2.v; // dot products double d4321 = l2.v * this->v; @@ -268,7 +273,8 @@ namespace geoff_geometry { double d2121 = this->v * this->v; double denom = d2121 * d4343 - d4321 * d4321; - if(fabs(denom) < 1.0e-09) return false; + if(fabs(denom) < 1.0e-09) + return false; double numer = d1343 * d4321 - d1321 * d4343; t1 = numer / denom; @@ -308,7 +314,8 @@ namespace geoff_geometry { c = Vector3d(l1, l0) */ // Vector3d a = l0.v; - if(l0.box.outside(l1.box) == true) return 0; + if(l0.box.outside(l1.box) == true) + return 0; Vector3d b = -l1.v; Vector3d c = Vector3d(l1.p0, l0.p0); Vector3d det = l0.v ^ b; @@ -331,17 +338,20 @@ namespace geoff_geometry { } } - if(fabs(d) < 1.0e-06) return 0; + if(fabs(d) < 1.0e-06) + return 0; t0 /= d; intof = l0.v * t0 + l0.p0; Point3d other; double t1; - if(Dist(l1, intof, other, t1) > geoff_geometry::TOLERANCE) return 0; + if(Dist(l1, intof, other, t1) > geoff_geometry::TOLERANCE) + return 0; t0 *= l0.length; - if( t0 < -geoff_geometry::TOLERANCE || t0 > l0.length + geoff_geometry::TOLERANCE || t1 < -geoff_geometry::TOLERANCE || t1 > l1.length + geoff_geometry::TOLERANCE ) return 0; + if( t0 < -geoff_geometry::TOLERANCE || t0 > l0.length + geoff_geometry::TOLERANCE || t1 < -geoff_geometry::TOLERANCE || t1 > l1.length + geoff_geometry::TOLERANCE ) + return 0; return 1; } @@ -419,7 +429,8 @@ namespace geoff_geometry { pnear = v * (sp.radius / radiusp) + sp.pc; // check if projected point is on the arc - if(sp.OnSpan(pnear)) return fabs(radiusp - sp.radius); + if(sp.OnSpan(pnear)) + return fabs(radiusp - sp.radius); // double h1 = pnear.x - sp.p0.x ; // double v1 = pnear.y - sp.p0.y ; // double h2 = sp.p1.x - pnear.x ; @@ -455,7 +466,8 @@ namespace geoff_geometry { if(sp.dir) { // arc if(fabs(p.Dist(sp.pc) - sp.radius) > geoff_geometry::TOLERANCE) { - if(!nearPoints) return false; + if(!nearPoints) + return false; } pNear = On(Circle(sp.pc, sp.radius), p); @@ -472,7 +484,8 @@ namespace geoff_geometry { else { // straight if(fabs(CLine(sp.p0, sp.vs).Dist(p)) > geoff_geometry::TOLERANCE) { - if(!nearPoints) return false; + if(!nearPoints) + return false; } Vector2d v(sp.p0, p); double t = v * sp.vs; @@ -513,7 +526,8 @@ namespace geoff_geometry { // function returns true for intersection, false for no intersection // method based on Möller & Trumbore(1997) (Barycentric coordinates) // based on incorrect Pseudo code from "Geometric Tools for Computer Graphics" p.487 - if(box.outside(l.box) == true) return false; + if(box.outside(l.box) == true) + return false; Vector3d line(l.v); line.normalise(); @@ -521,19 +535,23 @@ namespace geoff_geometry { Vector3d p = line ^ v1; // cross product double tmp = p * v0; // dot product - if(FEQZ(tmp)) return false; + if(FEQZ(tmp)) + return false; tmp = 1 / tmp; Vector3d s(vert1, l.p0); double u = tmp * (s * p); // barycentric coordinate - if(u < 0 || u > 1) return false; // not inside triangle + if(u < 0 || u > 1) // not inside triangle + return false; Vector3d q = s ^ v0; double v = tmp * (line * q); // barycentric coordinate - if(v < 0 || v > 1) return false; // not inside triangle + if(v < 0 || v > 1) // not inside triangle + return false; - if( u + v > 1) return false; // not inside triangle + if( u + v > 1) // not inside triangle + return false; double t = tmp * (v1 * q); intof = line * t + l.p0; @@ -544,11 +562,16 @@ namespace geoff_geometry { // box class bool Box::outside(const Box& b)const { // returns true if this box is outside b - if(b.ok == false || this->ok == false) return false; // no box set - if(this->max.x < b.min.x) return true; - if(this->max.y < b.min.y) return true; - if(this->min.x > b.max.x) return true; - if(this->min.y > b.max.y) return true; + if(b.ok == false || this->ok == false) // no box set + return false; + if(this->max.x < b.min.x) + return true; + if(this->max.y < b.min.y) + return true; + if(this->min.x > b.max.x) + return true; + if(this->min.y > b.max.y) + return true; return false; } @@ -570,24 +593,33 @@ namespace geoff_geometry { bool Box3d::outside(const Box3d& b) const{ // returns true if this box is outside b - if(b.ok == false || this->ok == false) return false; // no box set - if(this->max.x < b.min.x) return true; - if(this->max.y < b.min.y) return true; - if(this->max.z < b.min.z) return true; - if(this->min.x > b.max.x) return true; - if(this->min.y > b.max.y) return true; - if(this->min.z > b.max.z) return true; + if(b.ok == false || this->ok == false) // no box set + return false; + if(this->max.x < b.min.x) + return true; + if(this->max.y < b.min.y) + return true; + if(this->max.z < b.min.z) + return true; + if(this->min.x > b.max.x) + return true; + if(this->min.y > b.max.y) + return true; + if(this->min.z > b.max.z) + return true; return false; } #if 0 Span3d IsPtsSpan3d(const double* a, int n, double tolerance, double* deviation) { // returns a span3d if all points are within tolerance int np = n / 3; // number of points - if(np < 2) return Span3d(); // Invalid span3d + if(np < 2) // Invalid span3d + return Span3d(); Point3d sp = Point3d(&a[0]); Point3d ep = Point3d(&a[n-3]); Line line = IsPtsLine(a, n, tolerance, deviation); - if(line.ok) return Span3d(sp, ep); // it's a line + if(line.ok) // it's a line + return Span3d(sp, ep); *deviation = 0; // cumulative deviation Point3d mp = Point3d(&a[np / 2 * 3]); // mid point @@ -632,7 +664,8 @@ double tolerance = 10.0 * 1.0e-6; // deviation is returned as the sum of all deviations of interior points to line(sp,ep) int np = n / 3; // number of points *deviation = 0; // cumulative deviation - if(np < 2) return Line(); // Invalid line + if(np < 2) // Invalid line + return Line(); Point3d sp(&a[0]); Point3d ep(&a[n-3]); diff --git a/src/Mod/Path/libarea/kurve/Matrix.cpp b/src/Mod/Path/libarea/kurve/Matrix.cpp index 1a3ef527ef..25533cb77f 100644 --- a/src/Mod/Path/libarea/kurve/Matrix.cpp +++ b/src/Mod/Path/libarea/kurve/Matrix.cpp @@ -36,9 +36,11 @@ namespace geoff_geometry { bool Matrix::operator==(const Matrix &m)const{ // m1 == m2 - if(this->m_unit != m.m_unit || this->m_mirrored != m.m_mirrored) return false; + if(this->m_unit != m.m_unit || this->m_mirrored != m.m_mirrored) + return false; for(int i = 0; i < 16; i++) - if(FEQ(this->e[i], m.e[i], TIGHT_TOLERANCE) == false) return false; + if(FEQ(this->e[i], m.e[i], TIGHT_TOLERANCE) == false) + return false; return true; } @@ -227,10 +229,12 @@ namespace geoff_geometry { // returns true if unit matrix for(int i = 0; i < 16; i++) { if(i == 0 || i == 5 || i == 10 || i == 15) { - if(e[i] != 1) return m_unit = false; + if(e[i] != 1) + return m_unit = false; } else { - if(e[i] != 0) return m_unit = false; + if(e[i] != 0) + return m_unit = false; } } m_mirrored = false; @@ -343,7 +347,8 @@ namespace geoff_geometry { Matrix a = *this; int l[4], m[4]; - if(a.m_unit) return a; // unit matrix + if(a.m_unit) // unit matrix + return a; // search for largest element nk = - n ; diff --git a/src/Mod/Path/libarea/kurve/kurve.cpp b/src/Mod/Path/libarea/kurve/kurve.cpp index b1d1f98180..29c9515994 100644 --- a/src/Mod/Path/libarea/kurve/kurve.cpp +++ b/src/Mod/Path/libarea/kurve/kurve.cpp @@ -186,7 +186,8 @@ namespace geoff_geometry { } #endif static int Split(double tolerance, double angle, double radius, int dir) { - if(dir == LINEAR) return 0; // straight span + if(dir == LINEAR) // straight span + return 0; double cosa = 1 - tolerance / radius; if(cosa > NEARLY_ONE) cosa = NEARLY_ONE; cosa = 2 * cosa * cosa - 1 ; /* double angle */ @@ -327,7 +328,8 @@ namespace geoff_geometry { return this->vs * t + this->p0; } else { double r = p.Dist(this->pc); - if(r < geoff_geometry::TOLERANCE) return (p.Dist(this->p0) < p.Dist(this->p1))?this->p0 : this->p1; + if(r < geoff_geometry::TOLERANCE) + return (p.Dist(this->p0) < p.Dist(this->p1))?this->p0 : this->p1; return(p.Mid(this->pc, (r - this->radius) / r)); } } @@ -335,7 +337,8 @@ namespace geoff_geometry { // returns the near point to span from p - returned point is always on the span Point pn; pn = Near(p); - if(this->OnSpan(pn) == true) return pn; + if(this->OnSpan(pn) == true) + return pn; // return nearest endpoint return (pn.Dist(p0) < pn.Dist(p1))?p0 : p1; @@ -390,8 +393,10 @@ namespace geoff_geometry { Point Span::MidParam(double param)const { /// returns a point which is 0-1 along span - if(fabs(param) < 0.00000000000001)return p0; - if(fabs(param - 1.0) < 0.00000000000001)return p1; + if(fabs(param) < 0.00000000000001) + return p0; + if(fabs(param - 1.0) < 0.00000000000001) + return p1; return MidPerim(param * this->length); } @@ -589,7 +594,8 @@ return; Point pv, pcc; Get(m_nVertices - 1, pv, pcc); if(pv.Dist(p0) < geoff_geometry::TOLERANCE) { - if(!AddNullSpans)return false; + if(!AddNullSpans) + return false; span_type = LINEAR; // linear span } } @@ -758,7 +764,8 @@ return; int Kurve::Get(int spannumber, Span& sp, bool returnSpanProperties, bool transform) const { // returns span data and optional properties - the function returns as the span type if(spannumber < 1 || spannumber > m_nVertices) FAILURE(getMessage(L"Kurve::Get - vertexNumber out of range")); - if(m_nVertices < 2) return -99; + if(m_nVertices < 2) + return -99; int spanVertexNumber = spannumber - 1; if(m_isReversed) spanVertexNumber = m_nVertices - 1 - spanVertexNumber; @@ -784,7 +791,8 @@ return; int Kurve::Get(int spannumber, Span3d& sp, bool returnSpanProperties, bool transform) const { // returns span data and optional properties - the function returns as the span type if(spannumber < 1 || spannumber > m_nVertices) FAILURE(getMessage(L"Kurve::Get - vertexNumber out of range")); - if(m_nVertices < 2) return -99; + if(m_nVertices < 2) + return -99; int spanVertexNumber = spannumber - 1; SpanVertex* p = (SpanVertex*)m_spans[spanVertexNumber / SPANSTORAGE]; @@ -974,12 +982,14 @@ return; if(startSpanno == 1) { Span spFirst; this->Get(1, spFirst, false, true); - if(spFirst.p0 == *pNewStart) return; + if(spFirst.p0 == *pNewStart) + return; } else if(startSpanno == this->nSpans()) { Span spLast; this->Get(this->nSpans(), spLast, false, true); - if(spLast.p1 == *pNewStart) return; + if(spLast.p1 == *pNewStart) + return; } Kurve temp; @@ -1018,12 +1028,14 @@ return; if(endSpanno == 1) { Span spFirst; this->Get(1, spFirst, false, true); - if(spFirst.p0 == *pNewEnd) return; + if(spFirst.p0 == *pNewEnd) + return; } else if(endSpanno == this->nSpans()) { Span spLast; this->Get(this->nSpans(), spLast, false, true); - if(spLast.p1 == *pNewEnd) return; + if(spLast.p1 == *pNewEnd) + return; } Kurve temp; @@ -1089,12 +1101,14 @@ return; bool Kurve::operator==(const Kurve &k)const{ // k = kk (vertex check) - if(nSpans() != k.nSpans()) return false; + if(nSpans() != k.nSpans()) + return false; spVertex thisvertex, vertex; for(int i = 0; i <= nSpans(); i++) { this->Get(i, thisvertex); k.Get(i, vertex); - if(thisvertex != vertex) return false; + if(thisvertex != vertex) + return false; } return true; } @@ -1250,7 +1264,8 @@ return; void Kurve::Reverse() { // reverse the direction of a kurve int nSwaps = (m_nVertices - 1) / 2; - if(nSwaps == 0) return; + if(nSwaps == 0) + return; Point p0, pc0; // near Point pend, pcend; // far @@ -1313,7 +1328,8 @@ return; int Kurve::Reduce(double tolerance) { // remove spans that lie within tolerance // returns the number of spans removed - if(nSpans() <= 2) return 0; // too few spans for this method + if(nSpans() <= 2) // too few spans for this method + return 0; Kurve kReduced; kReduced = Matrix(*this); diff --git a/src/Mod/Path/libarea/kurve/offset.cpp b/src/Mod/Path/libarea/kurve/offset.cpp index 8ed54252e6..52bc6d0f67 100644 --- a/src/Mod/Path/libarea/kurve/offset.cpp +++ b/src/Mod/Path/libarea/kurve/offset.cpp @@ -273,7 +273,8 @@ namespace geoff_geometry { sp.dir = k.Get(kCheckVertex++, sp.p1, sp.pc); sp.SetProperties(true); // check for interference - if(Dist(sp, pInt, dummy) < offset) return true; + if(Dist(sp, pInt, dummy) < offset) + return true; sp.p0 = sp.p1; } return false; // intersection is ok diff --git a/src/Mod/Path/libarea/pyarea.cpp b/src/Mod/Path/libarea/pyarea.cpp index 1305d348e1..1527c8c595 100644 --- a/src/Mod/Path/libarea/pyarea.cpp +++ b/src/Mod/Path/libarea/pyarea.cpp @@ -165,7 +165,8 @@ py::list getCurveSpans(const CCurve& c) Span getFirstCurveSpan(const CCurve& c) { - if(c.m_vertices.size() < 2)return Span(); + if(c.m_vertices.size() < 2) + return Span(); std::list::const_iterator VIt = c.m_vertices.begin(); const Point &p = (*VIt).m_p; @@ -175,7 +176,8 @@ Span getFirstCurveSpan(const CCurve& c) Span getLastCurveSpan(const CCurve& c) { - if(c.m_vertices.size() < 2)return Span(); + if(c.m_vertices.size() < 2) + return Span(); std::list::const_reverse_iterator VIt = c.m_vertices.rbegin(); const CVertex &v = (*VIt); From bc7891919a3bb4b5f8c5e38c7b00b19aac519f88 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 12:38:24 -0500 Subject: [PATCH 25/39] Points: PR6497 move return statement to new line --- src/Mod/Points/App/PointsPyImp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mod/Points/App/PointsPyImp.cpp b/src/Mod/Points/App/PointsPyImp.cpp index f26f20310d..18f60b36c2 100644 --- a/src/Mod/Points/App/PointsPyImp.cpp +++ b/src/Mod/Points/App/PointsPyImp.cpp @@ -55,7 +55,8 @@ int PointsPy::PyInit(PyObject* args, PyObject* /*kwd*/) return -1; // if no mesh is given - if (!pcObj) return 0; + if (!pcObj) + return 0; if (PyObject_TypeCheck(pcObj, &(PointsPy::Type))) { *getPointKernelPtr() = *(static_cast(pcObj)->getPointKernelPtr()); } From 6e681ffee72825ae2a40a6932f3a1fa1b69bd52f Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 13:23:53 -0500 Subject: [PATCH 26/39] Raytracing: PR6497 move return statement to new line --- src/Mod/Raytracing/Gui/Command.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mod/Raytracing/Gui/Command.cpp b/src/Mod/Raytracing/Gui/Command.cpp index bb29b00cdd..6ea9203158 100644 --- a/src/Mod/Raytracing/Gui/Command.cpp +++ b/src/Mod/Raytracing/Gui/Command.cpp @@ -196,7 +196,8 @@ void CmdRaytracingWritePart::activated(int) // name of the objects in the pov file std::string Name = "Part"; std::vector obj = Gui::Selection().getObjectsOfType(Part::Feature::getClassTypeId()); - if (obj.empty()) return; + if (obj.empty()) + return; std::stringstream out; //Raytracing.writePartFile(App.document().GetActiveFeature().getShape()) From 9081a6364da6e3dc8215828e4f906fa7003b5b9a Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 13:24:17 -0500 Subject: [PATCH 27/39] Robot: PR6497 move return statement to new line --- .../Robot/App/kdl_cp/chainiksolverpos_nr.cpp | 3 +- .../App/kdl_cp/chainiksolvervel_pinv.cpp | 3 +- .../App/kdl_cp/chainiksolvervel_wdls.cpp | 3 +- .../Robot/App/kdl_cp/chainjnttojacsolver.cpp | 3 +- src/Mod/Robot/App/kdl_cp/tree.cpp | 6 ++-- .../App/kdl_cp/treeiksolverpos_nr_jl.cpp | 3 +- .../App/kdl_cp/utilities/svd_eigen_HH.cpp | 33 ++++++++++++------- 7 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/Mod/Robot/App/kdl_cp/chainiksolverpos_nr.cpp b/src/Mod/Robot/App/kdl_cp/chainiksolverpos_nr.cpp index b10dff5ec1..37823f9886 100644 --- a/src/Mod/Robot/App/kdl_cp/chainiksolverpos_nr.cpp +++ b/src/Mod/Robot/App/kdl_cp/chainiksolverpos_nr.cpp @@ -57,7 +57,8 @@ namespace KDL const char* ChainIkSolverPos_NR::strError(const int error) const { - if (E_IKSOLVER_FAILED == error) return "Child IK solver failed"; + if (E_IKSOLVER_FAILED == error) + return "Child IK solver failed"; else return SolverI::strError(error); } } diff --git a/src/Mod/Robot/App/kdl_cp/chainiksolvervel_pinv.cpp b/src/Mod/Robot/App/kdl_cp/chainiksolvervel_pinv.cpp index 979d11b307..8dd23b316d 100644 --- a/src/Mod/Robot/App/kdl_cp/chainiksolvervel_pinv.cpp +++ b/src/Mod/Robot/App/kdl_cp/chainiksolvervel_pinv.cpp @@ -109,7 +109,8 @@ namespace KDL const char* ChainIkSolverVel_pinv::strError(const int error) const { - if (E_SVD_FAILED == error) return "SVD failed"; + if (E_SVD_FAILED == error) + return "SVD failed"; else return SolverI::strError(error); } } diff --git a/src/Mod/Robot/App/kdl_cp/chainiksolvervel_wdls.cpp b/src/Mod/Robot/App/kdl_cp/chainiksolvervel_wdls.cpp index 80bc45022e..119e9268f6 100644 --- a/src/Mod/Robot/App/kdl_cp/chainiksolvervel_wdls.cpp +++ b/src/Mod/Robot/App/kdl_cp/chainiksolvervel_wdls.cpp @@ -175,7 +175,8 @@ namespace KDL const char* ChainIkSolverVel_wdls::strError(const int error) const { - if (E_SVD_FAILED == error) return "SVD failed"; + if (E_SVD_FAILED == error) + return "SVD failed"; else return SolverI::strError(error); } diff --git a/src/Mod/Robot/App/kdl_cp/chainjnttojacsolver.cpp b/src/Mod/Robot/App/kdl_cp/chainjnttojacsolver.cpp index e84bbc7ce7..171e3b5948 100644 --- a/src/Mod/Robot/App/kdl_cp/chainjnttojacsolver.cpp +++ b/src/Mod/Robot/App/kdl_cp/chainjnttojacsolver.cpp @@ -100,7 +100,8 @@ namespace KDL const char* ChainJntToJacSolver::strError(const int error) const { - if (E_JAC_FAILED == error) return "Jac Failed"; + if (E_JAC_FAILED == error) + return "Jac Failed"; else return SolverI::strError(error); } } diff --git a/src/Mod/Robot/App/kdl_cp/tree.cpp b/src/Mod/Robot/App/kdl_cp/tree.cpp index 50425e298c..463e754c13 100644 --- a/src/Mod/Robot/App/kdl_cp/tree.cpp +++ b/src/Mod/Robot/App/kdl_cp/tree.cpp @@ -125,12 +125,14 @@ bool Tree::addTreeRecursive(SegmentMap::const_iterator root, const std::string& parents_chain_root.push_back(s->first); if (s->first == root_name) break; } - if (parents_chain_root.empty() || parents_chain_root.back() != root_name) return false; + if (parents_chain_root.empty() || parents_chain_root.back() != root_name) + return false; for (SegmentMap::const_iterator s=getSegment(chain_tip); s!=segments.end(); s = GetTreeElementParent(s->second)){ parents_chain_tip.push_back(s->first); if (s->first == root_name) break; } - if (parents_chain_tip.empty() || parents_chain_tip.back() != root_name) return false; + if (parents_chain_tip.empty() || parents_chain_tip.back() != root_name) + return false; // remove common part of segment lists SegmentMap::key_type last_segment = root_name; diff --git a/src/Mod/Robot/App/kdl_cp/treeiksolverpos_nr_jl.cpp b/src/Mod/Robot/App/kdl_cp/treeiksolverpos_nr_jl.cpp index 2b0b1a3c8a..ce535b2e5b 100644 --- a/src/Mod/Robot/App/kdl_cp/treeiksolverpos_nr_jl.cpp +++ b/src/Mod/Robot/App/kdl_cp/treeiksolverpos_nr_jl.cpp @@ -58,7 +58,8 @@ namespace KDL { delta_twist->second = diff(f_it->second, f_des_it->second); } double res = iksolver.CartToJnt(q_out, delta_twists, delta_q); - if (res < eps) return res; + if (res < eps) + return res; Add(q_out, delta_q, q_out); diff --git a/src/Mod/Robot/App/kdl_cp/utilities/svd_eigen_HH.cpp b/src/Mod/Robot/App/kdl_cp/utilities/svd_eigen_HH.cpp index 35349039f9..8da1407f6b 100644 --- a/src/Mod/Robot/App/kdl_cp/utilities/svd_eigen_HH.cpp +++ b/src/Mod/Robot/App/kdl_cp/utilities/svd_eigen_HH.cpp @@ -58,14 +58,16 @@ namespace KDL{ s += U(k,i)*U(k,i); } f=U(i,i); // f is the diag elem - if (!(s>=0)) return -3; + if (!(s>=0)) + return -3; g = -SIGN(sqrt(s),f); h=f*g-s; U(i,i)=f-g; for (j=ppi;j=0)) return -5; + if (!(s>=0)) + return -5; g = -SIGN(sqrt(s),f); h=f*g-s; U(i,ppi)=f-g; - if (!(h!=0)) return -6; + if (!(h!=0)) + return -6; for (k=ppi;k=0;i--) { if (iepsilon) { - if (!(U(i,ppi)!=0)) return -7; + if (!(U(i,ppi)!=0)) + return -7; for (j=ppi;j Date: Tue, 29 Mar 2022 13:24:46 -0500 Subject: [PATCH 28/39] Sandbox: PR6497 move return statement to new line --- src/Mod/Sandbox/Gui/Command.cpp | 3 ++- src/Mod/Sandbox/Gui/Workbench.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Mod/Sandbox/Gui/Command.cpp b/src/Mod/Sandbox/Gui/Command.cpp index 64d3cf8d04..6c87a31499 100644 --- a/src/Mod/Sandbox/Gui/Command.cpp +++ b/src/Mod/Sandbox/Gui/Command.cpp @@ -1380,7 +1380,8 @@ void CmdMengerSponge::activated(int) QString::fromLatin1("Menger sponge"), QString::fromLatin1("Recursion depth:"), 3, 1, 5, 1, &ok); - if (!ok) return; + if (!ok) + return; int ret = QMessageBox::question(Gui::getMainWindow(), QString::fromLatin1("Parallel"), QString::fromLatin1("Do you want to run this in a thread pool?"), diff --git a/src/Mod/Sandbox/Gui/Workbench.cpp b/src/Mod/Sandbox/Gui/Workbench.cpp index d205e26746..2aaccb2a1f 100644 --- a/src/Mod/Sandbox/Gui/Workbench.cpp +++ b/src/Mod/Sandbox/Gui/Workbench.cpp @@ -169,7 +169,8 @@ void SoWidgetShape::GLRender(SoGLRenderAction * /*action*/) void SoWidgetShape::computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er) { // ignore if node is empty - if (this->image.isNull()) return; + if (this->image.isNull()) + return; SbVec3f v0, v1, v2, v3; // this will cause a cache dependency on the view volume, @@ -237,7 +238,8 @@ SoWidgetShape::getQuad(SoState * state, SbVec3f & v0, SbVec3f & v1, void SoWidgetShape::generatePrimitives(SoAction *action) { - if (this->image.isNull()) return; + if (this->image.isNull()) + return; SoState *state = action->getState(); state->push(); From 589369a2cc201b90b791df62bf588f1a8c317a9f Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 13:25:06 -0500 Subject: [PATCH 29/39] Sketcher: PR6497 move return statement to new line --- .../App/ExternalGeometryExtension.cpp | 3 +- .../App/ExternalGeometryFacadePyImp.cpp | 3 +- .../Sketcher/App/SketchGeometryExtension.cpp | 6 ++-- src/Mod/Sketcher/App/SketchObject.cpp | 3 +- src/Mod/Sketcher/App/planegcs/Constraints.cpp | 33 ++++++++++++------- src/Mod/Sketcher/Gui/Command.cpp | 3 +- src/Mod/Sketcher/Gui/CommandConstraints.cpp | 3 +- src/Mod/Sketcher/Gui/DrawSketchHandler.cpp | 3 +- src/Mod/Sketcher/Gui/SoDatumLabel.cpp | 3 +- .../Sketcher/Gui/TaskSketcherConstraints.cpp | 12 ++++--- src/Mod/Sketcher/Gui/TaskSketcherElements.cpp | 15 ++++++--- .../Sketcher/Gui/TaskSketcherValidation.cpp | 3 +- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 3 +- 13 files changed, 62 insertions(+), 31 deletions(-) diff --git a/src/Mod/Sketcher/App/ExternalGeometryExtension.cpp b/src/Mod/Sketcher/App/ExternalGeometryExtension.cpp index 5beb6ff770..00934fee9f 100644 --- a/src/Mod/Sketcher/App/ExternalGeometryExtension.cpp +++ b/src/Mod/Sketcher/App/ExternalGeometryExtension.cpp @@ -84,7 +84,8 @@ bool ExternalGeometryExtension::getFlagsFromName(std::string str, ExternalGeomet auto pos = std::find_if( ExternalGeometryExtension::flag2str.begin(), ExternalGeometryExtension::flag2str.end(), [str](const char * val) { - return strcmp(val,str.c_str())==0;} + return strcmp(val,str.c_str())==0; + } ); if( pos != ExternalGeometryExtension::flag2str.end()) { diff --git a/src/Mod/Sketcher/App/ExternalGeometryFacadePyImp.cpp b/src/Mod/Sketcher/App/ExternalGeometryFacadePyImp.cpp index c2375823f1..c71f365c52 100644 --- a/src/Mod/Sketcher/App/ExternalGeometryFacadePyImp.cpp +++ b/src/Mod/Sketcher/App/ExternalGeometryFacadePyImp.cpp @@ -115,7 +115,8 @@ PyObject* ExternalGeometryFacadePy::setFlag(PyObject *args) auto pos = std::find_if(ExternalGeometryExtension::flag2str.begin(), ExternalGeometryExtension::flag2str.end(), [flag](const char * val) { - return strcmp(val,flag)==0;} + return strcmp(val,flag)==0; + } ); if( pos != ExternalGeometryExtension::flag2str.end()) { diff --git a/src/Mod/Sketcher/App/SketchGeometryExtension.cpp b/src/Mod/Sketcher/App/SketchGeometryExtension.cpp index 939203d274..8e8081410d 100644 --- a/src/Mod/Sketcher/App/SketchGeometryExtension.cpp +++ b/src/Mod/Sketcher/App/SketchGeometryExtension.cpp @@ -114,7 +114,8 @@ bool SketchGeometryExtension::getInternalTypeFromName(std::string str, InternalT auto pos = std::find_if( SketchGeometryExtension::internaltype2str.begin(), SketchGeometryExtension::internaltype2str.end(), [str](const char * val) { - return strcmp(val,str.c_str())==0;} + return strcmp(val,str.c_str())==0; + } ); if( pos != SketchGeometryExtension::internaltype2str.end()) { @@ -132,7 +133,8 @@ bool SketchGeometryExtension::getGeometryModeFromName(std::string str, GeometryM auto pos = std::find_if( SketchGeometryExtension::geometrymode2str.begin(), SketchGeometryExtension::geometrymode2str.end(), [str](const char * val) { - return strcmp(val,str.c_str())==0;} + return strcmp(val,str.c_str())==0; + } ); if( pos != SketchGeometryExtension::geometrymode2str.end()) { diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 9f2d2e7991..7f3830c41d 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1807,7 +1807,8 @@ int SketchObject::fillet(int GeoId1, int GeoId2, int filletId; std::unique_ptr arc( Part::createFilletGeometry(lineSeg1, lineSeg2, filletCenter, radius)); - if (!arc) return -1; + if (!arc) + return -1; // calculate intersection and distances before we invalidate lineSeg1 and lineSeg2 if (!find2DLinesIntersection(lineSeg1, lineSeg2, intersection)) { diff --git a/src/Mod/Sketcher/App/planegcs/Constraints.cpp b/src/Mod/Sketcher/App/planegcs/Constraints.cpp index e28c3ad8d7..c1102aac76 100644 --- a/src/Mod/Sketcher/App/planegcs/Constraints.cpp +++ b/src/Mod/Sketcher/App/planegcs/Constraints.cpp @@ -560,7 +560,8 @@ double ConstraintPointOnPerpBisector::error() double ConstraintPointOnPerpBisector::grad(double *param) { //first of all, check that we need to compute anything. - if ( findParamInPvec(param) == -1 ) return 0.0; + if ( findParamInPvec(param) == -1 ) + return 0.0; double deriv; errorgrad(nullptr, &deriv, param); @@ -1102,7 +1103,8 @@ double ConstraintEllipseTangentLine::error() double ConstraintEllipseTangentLine::grad(double *param) { //first of all, check that we need to compute anything. - if ( findParamInPvec(param) == -1 ) return 0.0; + if ( findParamInPvec(param) == -1 ) + return 0.0; double deriv; errorgrad(nullptr, &deriv, param); @@ -1228,7 +1230,8 @@ double ConstraintInternalAlignmentPoint2Ellipse::error() double ConstraintInternalAlignmentPoint2Ellipse::grad(double *param) { //first of all, check that we need to compute anything. - if ( findParamInPvec(param) == -1 ) return 0.0; + if ( findParamInPvec(param) == -1 ) + return 0.0; double deriv; errorgrad(nullptr, &deriv, param); @@ -1361,7 +1364,8 @@ double ConstraintInternalAlignmentPoint2Hyperbola::error() double ConstraintInternalAlignmentPoint2Hyperbola::grad(double *param) { //first of all, check that we need to compute anything. - if ( findParamInPvec(param) == -1 ) return 0.0; + if ( findParamInPvec(param) == -1 ) + return 0.0; double deriv; errorgrad(nullptr, &deriv, param); @@ -1423,7 +1427,8 @@ double ConstraintEqualMajorAxesConic::error() double ConstraintEqualMajorAxesConic::grad(double *param) { //first of all, check that we need to compute anything. - if ( findParamInPvec(param) == -1 ) return 0.0; + if ( findParamInPvec(param) == -1 ) + return 0.0; double deriv; errorgrad(nullptr, &deriv, param); @@ -1499,7 +1504,8 @@ double ConstraintEqualFocalDistance::error() double ConstraintEqualFocalDistance::grad(double *param) { //first of all, check that we need to compute anything. - if ( findParamInPvec(param) == -1 ) return 0.0; + if ( findParamInPvec(param) == -1 ) + return 0.0; double deriv; errorgrad(nullptr, &deriv, param); @@ -1587,7 +1593,8 @@ double ConstraintCurveValue::error() double ConstraintCurveValue::grad(double *param) { //first of all, check that we need to compute anything. - if ( findParamInPvec(param) == -1 ) return 0.0; + if ( findParamInPvec(param) == -1 ) + return 0.0; double deriv; errorgrad(nullptr, &deriv, param); @@ -1814,7 +1821,8 @@ double ConstraintPointOnParabola::error() double ConstraintPointOnParabola::grad(double *param) { //first of all, check that we need to compute anything. - if ( findParamInPvec(param) == -1 ) return 0.0; + if ( findParamInPvec(param) == -1 ) + return 0.0; double deriv; errorgrad(nullptr, &deriv, param); @@ -1884,7 +1892,8 @@ double ConstraintAngleViaPoint::error() double ConstraintAngleViaPoint::grad(double *param) { //first of all, check that we need to compute anything. - if ( findParamInPvec(param) == -1 ) return 0.0; + if ( findParamInPvec(param) == -1 ) + return 0.0; double deriv=0.; @@ -2000,7 +2009,8 @@ double ConstraintSnell::grad(double *param) { //first of all, check that we need to compute anything. - if ( findParamInPvec(param) == -1 ) return 0.0; + if ( findParamInPvec(param) == -1 ) + return 0.0; double deriv; errorgrad(nullptr, &deriv, param); @@ -2117,7 +2127,8 @@ double ConstraintEqualLineLength::error() double ConstraintEqualLineLength::grad(double *param) { - if ( findParamInPvec(param) == -1 ) return 0.0; + if ( findParamInPvec(param) == -1 ) + return 0.0; double deriv; errorgrad(nullptr, &deriv, param); diff --git a/src/Mod/Sketcher/Gui/Command.cpp b/src/Mod/Sketcher/Gui/Command.cpp index d88e826657..ef3221bb9e 100644 --- a/src/Mod/Sketcher/Gui/Command.cpp +++ b/src/Mod/Sketcher/Gui/Command.cpp @@ -181,7 +181,8 @@ void CmdSketcherNewSketch::activated(int iMsg) qApp->translate("Sketcher_NewSketch", "Sketch attachment"), qApp->translate("Sketcher_NewSketch", "Select the method to attach this sketch to selected object"), items, iSugg, false, &ok, Qt::MSWindowsFixedSizeDialogHint); - if (!ok) return; + if (!ok) + return; int index = items.indexOf(text); if (index == 0){ bAttach = false; diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 1dea34d355..ffe9002c73 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -6885,7 +6885,8 @@ void CmdSketcherConstrainSnellsLaw::activated(int iMsg) ui_Datum.labelEdit->setSingleStep(0.05); // Unable to bind, because the constraint does not yet exist - if (dlg.exec() != QDialog::Accepted) return; + if (dlg.exec() != QDialog::Accepted) + return; ui_Datum.labelEdit->pushToHistory(); Base::Quantity newQuant = ui_Datum.labelEdit->value(); diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp index 8349c209c0..3e7d10c233 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp @@ -598,7 +598,8 @@ int DrawSketchHandler::seekAutoConstraint(std::vector &suggested suggestedConstraints.push_back(constr); // Do not seek for tangent if we are actually building a primitive - if (type == AutoConstraint::VERTEX_NO_TANGENCY) return suggestedConstraints.size(); + if (type == AutoConstraint::VERTEX_NO_TANGENCY) + return suggestedConstraints.size(); // Find if there are tangent constraints (currently arcs and circles) diff --git a/src/Mod/Sketcher/Gui/SoDatumLabel.cpp b/src/Mod/Sketcher/Gui/SoDatumLabel.cpp index 944f2819f1..8f0be3b09c 100644 --- a/src/Mod/Sketcher/Gui/SoDatumLabel.cpp +++ b/src/Mod/Sketcher/Gui/SoDatumLabel.cpp @@ -458,7 +458,8 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action) } const unsigned char * dataptr = this->image.getValue(imgsize, nc); - if (dataptr == nullptr) return; // no image + if (dataptr == nullptr) // no image + return; srcw = imgsize[0]; srch = imgsize[1]; diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp index 0046b7a483..2a7d1d8d15 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp @@ -583,7 +583,8 @@ void ConstraintView::centerSelectedItems() void ConstraintView::deleteSelectedItems() { App::Document* doc = App::GetApplication().getActiveDocument(); - if (!doc) return; + if (!doc) + return; doc->openTransaction("Delete constraint"); std::vector sel = Gui::Selection().getSelectionEx(doc->getName()); @@ -1139,7 +1140,8 @@ void TaskSketcherConstraints::on_listWidgetConstraints_itemSelectionChanged(void void TaskSketcherConstraints::on_listWidgetConstraints_itemActivated(QListWidgetItem *item) { ConstraintItem *it = dynamic_cast(item); - if (!it) return; + if (!it) + return; // if its the right constraint if (it->isDimensional()) { @@ -1153,7 +1155,8 @@ void TaskSketcherConstraints::on_listWidgetConstraints_updateDrivingStatus(QList { Q_UNUSED(status); ConstraintItem *citem = dynamic_cast(item); - if (!citem) return; + if (!citem) + return; Gui::Application::Instance->commandManager().runCommandByName("Sketcher_ToggleDrivingConstraint"); slotConstraintsChanged(); @@ -1163,7 +1166,8 @@ void TaskSketcherConstraints::on_listWidgetConstraints_updateActiveStatus(QListW { Q_UNUSED(status); ConstraintItem *citem = dynamic_cast(item); - if (!citem) return; + if (!citem) + return; Gui::Application::Instance->commandManager().runCommandByName("Sketcher_ToggleActiveConstraint"); slotConstraintsChanged(); diff --git a/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp b/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp index 1b3199833e..12cbf987c3 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp @@ -224,7 +224,8 @@ CONTEXT_MEMBER_DEF("Sketcher_SelectVerticalAxis",doSelectVAxis) void ElementView::deleteSelectedItems() { App::Document* doc = App::GetApplication().getActiveDocument(); - if (!doc) return; + if (!doc) + return; doc->openTransaction("Delete element"); std::vector sel = Gui::Selection().getSelectionEx(doc->getName()); @@ -614,7 +615,8 @@ void TaskSketcherElements::on_listWidgetElements_itemSelectionChanged(void) void TaskSketcherElements::on_listWidgetElements_itemEntered(QListWidgetItem *item) { ElementItem *it = dynamic_cast(item); - if (!it) return; + if (!it) + return; Gui::Selection().rmvPreselect(); @@ -1162,9 +1164,12 @@ TaskSketcherElements::MultIcon::MultIcon(const char* name) QIcon TaskSketcherElements::MultIcon::getIcon(bool construction, bool external) const { - if (construction && external) return QIcon(); - if (construction) return Construction; - if (external) return External; + if (construction && external) + return QIcon(); + if (construction) + return Construction; + if (external) + return External; return Normal; } diff --git a/src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp b/src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp index 462b721032..c0cda9f54c 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp @@ -319,7 +319,8 @@ void SketcherValidation::on_delConstrExtr_clicked() tr("Delete constraints to external geom."), tr("You are about to delete ALL constraints that deal with external geometry. This is useful to rescue a sketch with broken/changed links to external geometry. Are you sure you want to delete the constraints?"), QMessageBox::No|QMessageBox::Yes,QMessageBox::No); - if(reply!=QMessageBox::Yes) return; + if(reply!=QMessageBox::Yes) + return; App::Document* doc = sketch->getDocument(); doc->openTransaction("Delete constraints"); diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 1dc00982dc..5d08caf255 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -523,7 +523,8 @@ void ViewProviderSketch::getProjectingLine(const SbVec2s& pnt, const Gui::View3D } SoCamera* pCam = viewer->getSoRenderManager()->getCamera(); - if (!pCam) return; + if (!pCam) + return; SbViewVolume vol = pCam->getViewVolume(); vol.projectPointToLine(SbVec2f(pX,pY), line); From ed75cead6ca1aefc982711540700dc74584e460a Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 13:25:44 -0500 Subject: [PATCH 30/39] Spreadsheet: PR6497 move return statement to new line --- src/Mod/Spreadsheet/App/PropertySheet.cpp | 3 +- src/Mod/Spreadsheet/App/genregexps.cpp | 4 +- src/Mod/Spreadsheet/TestSpreadsheetGui.py | 78 +++++++++++++++++++++++ 3 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 src/Mod/Spreadsheet/TestSpreadsheetGui.py diff --git a/src/Mod/Spreadsheet/App/PropertySheet.cpp b/src/Mod/Spreadsheet/App/PropertySheet.cpp index ee5924457f..f570a98fcb 100644 --- a/src/Mod/Spreadsheet/App/PropertySheet.cpp +++ b/src/Mod/Spreadsheet/App/PropertySheet.cpp @@ -574,7 +574,8 @@ void PropertySheet::setAlignment(CellAddress address, int _alignment) { Cell * cell = nonNullCellAt(address); assert(cell != nullptr); - if (cell->address != address) return; //Reject alignment change for merged cell except top-left one + if (cell->address != address) //Reject alignment change for merged cell except top-left one + return; cell->setAlignment(_alignment); } diff --git a/src/Mod/Spreadsheet/App/genregexps.cpp b/src/Mod/Spreadsheet/App/genregexps.cpp index 7b40890556..995abf02c4 100644 --- a/src/Mod/Spreadsheet/App/genregexps.cpp +++ b/src/Mod/Spreadsheet/App/genregexps.cpp @@ -7,7 +7,9 @@ int genUtf8(int c, unsigned char * b) { - if (c<0x80) { *b++=c, *b++ = '\0'; return 1; } + if (c<0x80) { *b++=c, *b++ = '\0'; + return 1; + } else if (c<0x800) { *b++=192+c/64, *b++=128+c%64, *b++ = '\0'; return 2; } else if (c-0xd800u < 0x800) goto error; else if (c<0x10000) { *b++=224+c/4096, *b++=128+c/64%64, *b++=128+c%64, *b++ = '\0'; return 3; } diff --git a/src/Mod/Spreadsheet/TestSpreadsheetGui.py b/src/Mod/Spreadsheet/TestSpreadsheetGui.py new file mode 100644 index 0000000000..d3d5d835d1 --- /dev/null +++ b/src/Mod/Spreadsheet/TestSpreadsheetGui.py @@ -0,0 +1,78 @@ +# *************************************************************************** +# * Copyright (c) 2021 Chris Hennes * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU General Public License (GPL) * +# * 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 unittest +import FreeCAD + +from PySide import QtCore, QtGui +import FreeCADGui + +# ---------------------------------------------------------------------------------- +# define the functions to test the FreeCAD Spreadsheet GUI +# ---------------------------------------------------------------------------------- + + +class SpreadsheetGuiCases(unittest.TestCase): + def setUp(self): + self.doc = FreeCAD.newDocument() + self.sheet = self.doc.addObject("Spreadsheet::Sheet", "Spreadsheet") + self.view_provider = self.sheet.ViewObject + + def getTableView(self): + return self.view_provider.getView() + + def tearDown(self): + pass + #FreeCAD.closeDocument(self.doc.Name) + + def injectSimpleData(self): + """A utility function to initialize a blank sheet with some known data""" + self.sheet.clearAll() + self.sheet.set("A1", "1") + self.sheet.set("A2", "2") + self.sheet.set("A3", "3") + self.sheet.set("A4", "4") + self.sheet.set("B1", "5") + self.sheet.set("B2", "6") + self.sheet.set("B3", "7") + self.sheet.set("B4", "8") + self.sheet.set("C1", "9") + self.sheet.set("C2", "10") + self.sheet.set("C3", "11") + self.sheet.set("C4", "12") + self.sheet.set("D1", "13") + self.sheet.set("D2", "14") + self.sheet.set("D3", "15") + self.sheet.set("D4", "16") + self.doc.recompute() + + def testCopySingleCell(self): + self.injectSimpleData() + self.view_provider.doubleClicked() + view = self.getTableView() + view.select("A1", QtCore.QItemSelectionModel.SelectCurrent) + view.setCurrentIndex("A1") + FreeCAD.Gui.runCommand("Std_Copy", 0) + view.select("E5", QtCore.QItemSelectionModel.SelectCurrent) + view.setCurrentIndex("E5") + FreeCAD.Gui.runCommand("Std_Paste", 0) + self.doc.recompute() + self.assertEqual(self.sheet.get("A1"), self.sheet.get("E5")) + From 84ae226ec64464f206f9ad56f7535b82ed0170d9 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 13:26:01 -0500 Subject: [PATCH 31/39] TD: PR6497 move return statement to new line --- src/Mod/TechDraw/App/DrawProjGroup.cpp | 3 ++- src/Mod/TechDraw/Gui/QGTracker.cpp | 3 ++- src/Mod/TechDraw/Gui/TaskCosVertex.cpp | 6 ++++-- src/Mod/TechDraw/Gui/TaskDetail.cpp | 6 ++++-- src/Mod/TechDraw/Gui/TaskLeaderLine.cpp | 6 ++++-- src/Mod/TechDraw/Gui/TaskLineDecor.cpp | 6 ++++-- src/Mod/TechDraw/Gui/TaskProjGroup.cpp | 6 ++++-- src/Mod/TechDraw/Gui/TaskRichAnno.cpp | 3 ++- src/Mod/TechDraw/Gui/ViewProviderGeomHatch.cpp | 6 ++++-- src/Mod/TechDraw/Gui/ViewProviderHatch.cpp | 6 ++++-- 10 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawProjGroup.cpp b/src/Mod/TechDraw/App/DrawProjGroup.cpp index 91d52f2b76..442057120f 100644 --- a/src/Mod/TechDraw/App/DrawProjGroup.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroup.cpp @@ -220,7 +220,8 @@ short DrawProjGroup::mustExecute() const spacingX.isTouched() || spacingY.isTouched(); } - if (result) return result; + if (result) + return result; return TechDraw::DrawViewCollection::mustExecute(); } diff --git a/src/Mod/TechDraw/Gui/QGTracker.cpp b/src/Mod/TechDraw/Gui/QGTracker.cpp index de45e5b523..87b79460d0 100644 --- a/src/Mod/TechDraw/Gui/QGTracker.cpp +++ b/src/Mod/TechDraw/Gui/QGTracker.cpp @@ -200,7 +200,8 @@ void QGTracker::sleep(bool b) QPointF QGTracker::snapToAngle(QPointF dumbPt) { // If no point selected yet, snapping has no sense - if (m_points.size() < 1) return dumbPt; + if (m_points.size() < 1) + return dumbPt; QPointF result(dumbPt); double angleIncr = M_PI / 8.0; //15* diff --git a/src/Mod/TechDraw/Gui/TaskCosVertex.cpp b/src/Mod/TechDraw/Gui/TaskCosVertex.cpp index 5c91f29e88..029a3a8cdd 100644 --- a/src/Mod/TechDraw/Gui/TaskCosVertex.cpp +++ b/src/Mod/TechDraw/Gui/TaskCosVertex.cpp @@ -318,7 +318,8 @@ void TaskCosVertex::enableTaskButtons(bool b) bool TaskCosVertex::accept() { Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument()); - if (!doc) return false; + if (!doc) + return false; removeTracker(); double x = ui->dsbX->value().getValue(); @@ -338,7 +339,8 @@ bool TaskCosVertex::accept() bool TaskCosVertex::reject() { Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument()); - if (!doc) return false; + if (!doc) + return false; removeTracker(); m_trackerMode = QGTracker::TrackerMode::None; diff --git a/src/Mod/TechDraw/Gui/TaskDetail.cpp b/src/Mod/TechDraw/Gui/TaskDetail.cpp index 2da087d99d..8be89aedd7 100644 --- a/src/Mod/TechDraw/Gui/TaskDetail.cpp +++ b/src/Mod/TechDraw/Gui/TaskDetail.cpp @@ -620,7 +620,8 @@ bool TaskDetail::accept() // Base::Console().Message("TD::accept()\n"); Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument()); - if (!doc) return false; + if (!doc) + return false; m_ghost->hide(); getDetailFeat()->requestPaint(); @@ -634,7 +635,8 @@ bool TaskDetail::reject() { // Base::Console().Message("TD::reject()\n"); Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument()); - if (!doc) return false; + if (!doc) + return false; m_ghost->hide(); if (m_mode == CREATEMODE) { diff --git a/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp b/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp index b27ec4b9c2..ab1fc28ba7 100644 --- a/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp @@ -807,7 +807,8 @@ bool TaskLeaderLine::accept() } Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument()); - if (!doc) return false; + if (!doc) + return false; if (!getCreateMode()) { // removeTracker(); @@ -838,7 +839,8 @@ bool TaskLeaderLine::reject() } Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument()); - if (!doc) return false; + if (!doc) + return false; if (getCreateMode() && (m_lineFeat != nullptr) ) { diff --git a/src/Mod/TechDraw/Gui/TaskLineDecor.cpp b/src/Mod/TechDraw/Gui/TaskLineDecor.cpp index f12dd1512e..d9599c6a4c 100644 --- a/src/Mod/TechDraw/Gui/TaskLineDecor.cpp +++ b/src/Mod/TechDraw/Gui/TaskLineDecor.cpp @@ -230,7 +230,8 @@ bool TaskLineDecor::accept() { // Base::Console().Message("TLD::accept()\n"); Gui::Document* doc = Gui::Application::Instance->getDocument(m_partFeat->getDocument()); - if (!doc) return false; + if (!doc) + return false; if (apply()) { applyDecorations(); @@ -248,7 +249,8 @@ bool TaskLineDecor::reject() { // Base::Console().Message("TLD::reject()\n"); Gui::Document* doc = Gui::Application::Instance->getDocument(m_partFeat->getDocument()); - if (!doc) return false; + if (!doc) + return false; Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); return false; diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp index cffb499243..be2e31b035 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp @@ -526,7 +526,8 @@ bool TaskProjGroup::accept() { // Base::Console().Message("TPG::accept()\n"); Gui::Document* doc = Gui::Application::Instance->getDocument(multiView->getDocument()); - if (!doc) return false; + if (!doc) + return false; multiView->recomputeChildren(); multiView->recomputeFeature(); @@ -539,7 +540,8 @@ bool TaskProjGroup::accept() bool TaskProjGroup::reject() { Gui::Document* doc = Gui::Application::Instance->getDocument(multiView->getDocument()); - if (!doc) return false; + if (!doc) + return false; if (getCreateMode()) { //remove the object completely from the document diff --git a/src/Mod/TechDraw/Gui/TaskRichAnno.cpp b/src/Mod/TechDraw/Gui/TaskRichAnno.cpp index b0050c51b4..d3207e31e2 100644 --- a/src/Mod/TechDraw/Gui/TaskRichAnno.cpp +++ b/src/Mod/TechDraw/Gui/TaskRichAnno.cpp @@ -530,7 +530,8 @@ bool TaskRichAnno::accept() } Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument()); - if (!doc) return false; + if (!doc) + return false; if (!getCreateMode()) { updateAnnoFeature(); diff --git a/src/Mod/TechDraw/Gui/ViewProviderGeomHatch.cpp b/src/Mod/TechDraw/Gui/ViewProviderGeomHatch.cpp index 4662505fe1..e4ffb68b26 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderGeomHatch.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderGeomHatch.cpp @@ -194,8 +194,10 @@ TechDraw::DrawGeomHatch* ViewProviderGeomHatch::getViewObject() const Gui::MDIView *ViewProviderGeomHatch::getMDIView() const { auto obj = getViewObject(); - if(!obj) return nullptr; + if(!obj) + return nullptr; auto vp = Gui::Application::Instance->getViewProvider(obj->getSourceView()); - if(!vp) return nullptr; + if(!vp) + return nullptr; return vp->getMDIView(); } diff --git a/src/Mod/TechDraw/Gui/ViewProviderHatch.cpp b/src/Mod/TechDraw/Gui/ViewProviderHatch.cpp index fd74b9b2f8..3e7289da34 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderHatch.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderHatch.cpp @@ -163,8 +163,10 @@ bool ViewProviderHatch::canDelete(App::DocumentObject *obj) const Gui::MDIView *ViewProviderHatch::getMDIView() const { auto obj = getViewObject(); - if(!obj) return nullptr; + if(!obj) + return nullptr; auto vp = Gui::Application::Instance->getViewProvider(obj->getSourceView()); - if(!vp) return nullptr; + if(!vp) + return nullptr; return vp->getMDIView(); } From e232c9ebfd96ef8aa48d2b06b88edc8664626b79 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 13:26:16 -0500 Subject: [PATCH 32/39] Web: PR6497 move return statement to new line --- src/Mod/Web/Gui/BrowserView.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Mod/Web/Gui/BrowserView.cpp b/src/Mod/Web/Gui/BrowserView.cpp index 1d400fe34d..6b605d3e93 100644 --- a/src/Mod/Web/Gui/BrowserView.cpp +++ b/src/Mod/Web/Gui/BrowserView.cpp @@ -837,11 +837,16 @@ bool BrowserView::onHasMsg(const char* pMsg) const return view->page()->action(QWebEnginePage::Back)->isEnabled(); if (strcmp(pMsg,"Next")==0) return view->page()->action(QWebEnginePage::Forward)->isEnabled(); - if (strcmp(pMsg,"Refresh")==0) return !isLoading; - if (strcmp(pMsg,"Stop")==0) return isLoading; - if (strcmp(pMsg,"ZoomIn")==0) return true; - if (strcmp(pMsg,"ZoomOut")==0) return true; - if (strcmp(pMsg,"SetURL")==0) return true; + if (strcmp(pMsg,"Refresh")==0) + return !isLoading; + if (strcmp(pMsg,"Stop")==0) + return isLoading; + if (strcmp(pMsg,"ZoomIn")==0) + return true; + if (strcmp(pMsg,"ZoomOut")==0) + return true; + if (strcmp(pMsg,"SetURL")==0) + return true; return false; } From d749e151bdfafa36082727f5847afc2b0ad6ebb5 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 13:41:29 -0500 Subject: [PATCH 33/39] Git: PR6497 Ignore commits in git blame --- .git-blame-ignore-revs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index c75fab2943..1ebcb093bc 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -35,4 +35,24 @@ d38f18af23bfa76138d1c8b5e87672d57f3734eb 0c6786d4bfe1814119c00a2b2816f2770885386d cbdba0b5bb19ffc0ff5450a3ff63281ef03d8bd9 a5135efd879abcfb34868c775f4178124ccd771c -e0399e83c3d48c7d43fa2d1ed2ad1f6d52e68a0a \ No newline at end of file +e0399e83c3d48c7d43fa2d1ed2ad1f6d52e68a0a +3ef6811dae41b0d5aa2343feea37cca12c5d23e3 +c44ccc0ff231b7a91deb4425fa7b484725e98683 +cb21ac7bf8ac998be93849b75c8ff94e9b1c1b54 +1ee046788d50bb2512dfb4454d3e8f6c4aff0f9f +190d64bdae81af46a60241af9b8f4a8e381248fb +ec74d351f0c533da1626b05d1db9e20b678a8f72 +1e9236abd416f998ccc3d052556338d4988ea709 +bac451cc537be8beb4826c89fd4429ca73e69f4d +5f31fb74f6445fda5632b5f2545362f85a379c74 +6f230d740401f914d5340a4b4be1a1c1df7b444a +0a65575c2c1b23fcae6354277fee264df6d163d8 +702238a99c80ff2e6c91b4880f91bb38ab7833ac +35156cdce3b2716071e994467c607e5175693a12 +bb0e2f1c5186ae3008b9aad1f0ba3e35370d18db +b13088664fea77e6ac4779dddfdea7aac3c50b30 +1ea364379f64314ea47549a2f625c34eafdd262d +3b42d4aface8c64feb9c86533f3b847e9aa9c563 +bedf9207023d6d594f2c03d2a8d799b34759a8fb +132a1d7e55eadd0cb5a09760d471780eb5bd9340 + From 70e3b0874b782c22015039aee2b524b0e0e718f3 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 29 Mar 2022 15:47:15 -0500 Subject: [PATCH 34/39] Addon Manager: Fix display of Macro wiki details --- src/Mod/AddonManager/addonmanager_macro.py | 3 +++ src/Mod/AddonManager/package_details.py | 22 +++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Mod/AddonManager/addonmanager_macro.py b/src/Mod/AddonManager/addonmanager_macro.py index 2313d9cb1a..e9579d40bb 100644 --- a/src/Mod/AddonManager/addonmanager_macro.py +++ b/src/Mod/AddonManager/addonmanager_macro.py @@ -63,6 +63,7 @@ class Macro(object): self.comment = "" self.code = "" self.url = "" + self.wiki = "" self.version = "" self.date = "" self.src_filename = "" @@ -112,6 +113,7 @@ class Macro(object): # For now: # __Comment__ # __Web__ + # __Wiki__ # __Version__ # __Files__ # __Author__ @@ -123,6 +125,7 @@ class Macro(object): string_search_mapping = { "__comment__": "comment", "__web__": "url", + "__wiki__": "wiki", "__version__": "version", "__files__": "other_files", "__author__": "author", diff --git a/src/Mod/AddonManager/package_details.py b/src/Mod/AddonManager/package_details.py index 99534e3ca1..4825309383 100644 --- a/src/Mod/AddonManager/package_details.py +++ b/src/Mod/AddonManager/package_details.py @@ -491,15 +491,23 @@ class PackageDetails(QWidget): self.macro_readme_updated() def macro_readme_updated(self): + url = self.repo.macro.wiki + if not url: + url = self.repo.macro.url + if HAS_QTWEBENGINE: - self.ui.webView.load(QUrl(self.repo.macro.url)) - self.ui.urlBar.setText(self.repo.macro.url) + if url: + self.ui.webView.load(QUrl(url)) + self.ui.urlBar.setText(url) + else: + self.ui.urlBar.setText("(" + translate("AddonsInstaller", "No URL or wiki page provided by this macro") + ")") else: - readme_data = NetworkManager.AM_NETWORK_MANAGER.blocking_get( - self.repo.macro.url - ) - text = readme_data.data().decode("utf8") - self.ui.textBrowserReadMe.setHtml(text) + if url: + readme_data = NetworkManager.AM_NETWORK_MANAGER.blocking_get(url) + text = readme_data.data().decode("utf8") + self.ui.textBrowserReadMe.setHtml(text) + else: + self.ui.textBrowserReadMe.setHtml("(" + translate("AddonsInstaller", "No URL or wiki page provided by this macro") + ")") def run_javascript(self): """Modify the page for a README to optimize for viewing in a smaller window""" From a42a932e2297ebb4ddbccd53b3a1992f600a4cb4 Mon Sep 17 00:00:00 2001 From: Wanderer Fan Date: Tue, 29 Mar 2022 14:50:46 -0400 Subject: [PATCH 35/39] [TD]Fix Extension Icons - icons were causing an error msg from Qt --- .../TechDraw_ExtensionAreaAnnotation.svg | 124 +++++------------- .../TechDraw_ExtensionCustomizeFormat.svg | 100 ++++---------- ...echDraw_ExtensionDrawCosmCircle3Points.svg | 102 ++++---------- .../TechDraw_ExtensionRemovePrefixChar.svg | 102 ++++---------- 4 files changed, 117 insertions(+), 311 deletions(-) diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionAreaAnnotation.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionAreaAnnotation.svg index b2ae54992a..67d5e41613 100644 --- a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionAreaAnnotation.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionAreaAnnotation.svg @@ -1,117 +1,61 @@ - - + + - - - - - + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - A - - - - - - 2 - - - - \ No newline at end of file + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCustomizeFormat.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCustomizeFormat.svg index c873ae7ddd..8e27752cab 100644 --- a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCustomizeFormat.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCustomizeFormat.svg @@ -1,89 +1,43 @@ - - + + - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - \ No newline at end of file + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionDrawCosmCircle3Points.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionDrawCosmCircle3Points.svg index 9f3bfe9ff9..ad571067db 100644 --- a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionDrawCosmCircle3Points.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionDrawCosmCircle3Points.svg @@ -1,90 +1,44 @@ - - + + - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - \ No newline at end of file + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionRemovePrefixChar.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionRemovePrefixChar.svg index b70c9d1b82..2287375c2e 100644 --- a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionRemovePrefixChar.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionRemovePrefixChar.svg @@ -1,95 +1,49 @@ - - + + - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - \ No newline at end of file + From f2ebc45a30315d9a98c7f724378e48517aa976a1 Mon Sep 17 00:00:00 2001 From: Uwe Date: Wed, 30 Mar 2022 01:45:59 +0200 Subject: [PATCH 36/39] [FEM] [skip CI] remove superfluous ifs I introduced today --- .../Fem/Gui/ViewProviderFemPostFunction.cpp | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp index 65064d6230..0eb3282079 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp @@ -581,20 +581,16 @@ void ViewProviderFemPostSphereFunction::updateData(const App::Property* p) { if (p == &func->Center || p == &func->Radius) { auto directParents = func->getInList(); // directParents is at the level of the functions container, so we must read the parent of this container - if (!directParents.empty()) { - for (auto obj : directParents) { - if (obj->getTypeId() == Base::Type::fromName("Fem::FemPostFunctionProvider")) { - auto outerParents = obj->getInList(); - if (!outerParents.empty()) { - for (auto objOuter : outerParents) { - if (objOuter->getTypeId() == Base::Type::fromName("Fem::FemPostPipeline") ) { - if (!isDragging()) - // not recursve, otherwise VTK will show an error on initialization - objOuter->recomputeFeature(); - else - objOuter->recomputeFeature(true); - } - } + for (auto obj : directParents) { + if (obj->getTypeId() == Base::Type::fromName("Fem::FemPostFunctionProvider")) { + auto outerParents = obj->getInList(); + for (auto objOuter : outerParents) { + if (objOuter->getTypeId() == Base::Type::fromName("Fem::FemPostPipeline") ) { + if (!isDragging()) + // not recursve, otherwise VTK will show an error on initialization + objOuter->recomputeFeature(); + else + objOuter->recomputeFeature(true); } } } From 573e4cd7724feb322699cd8d11e45b9f98526f90 Mon Sep 17 00:00:00 2001 From: Uwe Date: Wed, 30 Mar 2022 02:57:35 +0200 Subject: [PATCH 37/39] [FEM] fix bug 4 of the cut filter bugs as reported here: https://forum.freecadweb.org/viewtopic.php?p=584217#p584217 --- src/Mod/Fem/Gui/TaskPostBoxes.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Mod/Fem/Gui/TaskPostBoxes.cpp b/src/Mod/Fem/Gui/TaskPostBoxes.cpp index 391e88b9b1..e64adea952 100644 --- a/src/Mod/Fem/Gui/TaskPostBoxes.cpp +++ b/src/Mod/Fem/Gui/TaskPostBoxes.cpp @@ -463,12 +463,17 @@ void TaskPostClip::collectImplicitFunctions() { ui->FunctionBox->clear(); QStringList items; + std::size_t currentItem = 0; + App::DocumentObject* currentFunction = static_cast(getObject())->Function.getValue(); const std::vector& funcs = static_cast( pipeline->Functions.getValue())->Functions.getValues(); - for (std::size_t i = 0; i < funcs.size(); ++i) + for (std::size_t i = 0; i < funcs.size(); ++i) { items.push_back(QString::fromLatin1(funcs[i]->getNameInDocument())); - + if (currentFunction = funcs[i]) + currentItem = i; + } ui->FunctionBox->addItems(items); + ui->FunctionBox->setCurrentIndex(currentItem); } } } From 16ef926fb1f0f5cb0a083aedcae56701b8cb5df9 Mon Sep 17 00:00:00 2001 From: Uwe Date: Wed, 30 Mar 2022 03:35:13 +0200 Subject: [PATCH 38/39] [FEM] improve sphere cut function handling This commit improves https://github.com/FreeCAD/FreeCAD/commit/e22bcb61 it turned out that it is valid to use a sphere being part of a Pipeline A ,a also for filters in a Pipeline B, C etc. Thus we must recompute the whole analysis container --- .../Fem/Gui/ViewProviderFemPostFunction.cpp | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp index 0eb3282079..442a8447b5 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp @@ -51,8 +51,10 @@ #include #include #include +#include #include "ViewProviderFemPostFunction.h" +#include "ActiveAnalysisObserver.h" #include "TaskPostBoxes.h" #include "ui_PlaneWidget.h" @@ -577,24 +579,13 @@ void ViewProviderFemPostSphereFunction::updateData(const App::Property* p) { } Gui::ViewProviderDocumentObject::updateData(p); - // after updating the geometry we must recompute the pipeline the sphere is in + // after updating the geometry we must recompute + // A sphere can be used by filters in other pipelines than the one the sphere is in. + // Therefore we must recompute the analysis, not only a single pipeline if (p == &func->Center || p == &func->Radius) { - auto directParents = func->getInList(); - // directParents is at the level of the functions container, so we must read the parent of this container - for (auto obj : directParents) { - if (obj->getTypeId() == Base::Type::fromName("Fem::FemPostFunctionProvider")) { - auto outerParents = obj->getInList(); - for (auto objOuter : outerParents) { - if (objOuter->getTypeId() == Base::Type::fromName("Fem::FemPostPipeline") ) { - if (!isDragging()) - // not recursve, otherwise VTK will show an error on initialization - objOuter->recomputeFeature(); - else - objOuter->recomputeFeature(true); - } - } - } - } + auto pcAnalysis = FemGui::ActiveAnalysisObserver::instance()->getActiveObject(); + if (pcAnalysis) + pcAnalysis->recomputeFeature(true); } } From 25434ad3c352ac2cb53192415158633e89dff058 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 30 Mar 2022 08:23:55 +0200 Subject: [PATCH 39/39] Fem: [skip ci] issue #6673: selecting a point for the point result filter crashes --- src/Mod/Fem/Gui/TaskPostBoxes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Fem/Gui/TaskPostBoxes.cpp b/src/Mod/Fem/Gui/TaskPostBoxes.cpp index e64adea952..8b0c704393 100644 --- a/src/Mod/Fem/Gui/TaskPostBoxes.cpp +++ b/src/Mod/Fem/Gui/TaskPostBoxes.cpp @@ -781,7 +781,7 @@ void TaskPostDataAtPoint::applyPythonCode() { } static const char* cursor_star[] = { -"32 32 3 1", +"32 17 3 1", " c None", ". c #FFFFFF", "+ c #FF0000",