diff --git a/src/Mod/CAM/Path/Dressup/Gui/LeadInOut.py b/src/Mod/CAM/Path/Dressup/Gui/LeadInOut.py index 3411cc3a2d..7137c232a7 100644 --- a/src/Mod/CAM/Path/Dressup/Gui/LeadInOut.py +++ b/src/Mod/CAM/Path/Dressup/Gui/LeadInOut.py @@ -80,7 +80,7 @@ class ObjectDressup: ) obj.addProperty( "App::PropertyDistance", - "Length", + "LengthIn", "Path", QT_TRANSLATE_NOOP("App::Property", "Length or Radius of the approach"), ) @@ -92,18 +92,18 @@ class ObjectDressup: ) obj.addProperty( "App::PropertyEnumeration", - "StyleOn", + "StyleIn", "Path", QT_TRANSLATE_NOOP("App::Property", "The Style of motion into the toolpath"), ) - obj.StyleOn = lead_styles + obj.StyleIn = lead_styles obj.addProperty( "App::PropertyEnumeration", - "StyleOff", + "StyleOut", "Path", QT_TRANSLATE_NOOP("App::Property", "The Style of motion out of the toolpath"), ) - obj.StyleOff = lead_styles + obj.StyleOut = lead_styles obj.addProperty( "App::PropertyDistance", "ExtendLeadIn", @@ -140,13 +140,13 @@ class ObjectDressup: return None def setup(self, obj): - obj.Length = PathDressup.toolController(obj.Base).Tool.Diameter * 0.75 + obj.LengthIn = PathDressup.toolController(obj.Base).Tool.Diameter * 0.75 obj.LengthOut = PathDressup.toolController(obj.Base).Tool.Diameter * 0.75 obj.LeadIn = True obj.LeadOut = True obj.KeepToolDown = False - obj.StyleOn = "Arc" - obj.StyleOff = "Arc" + obj.StyleIn = "Arc" + obj.StyleOut = "Arc" obj.ExtendLeadIn = 0 obj.ExtendLeadOut = 0 obj.RapidPlunge = False @@ -160,11 +160,11 @@ class ObjectDressup: if not obj.Base.Path: return - if obj.Length <= 0: + if obj.LengthIn <= 0: Path.Log.error( translate("CAM_DressupLeadInOut", "Length/Radius positive not Null") + "\n" ) - obj.Length = 0.1 + obj.LengthIn = 0.1 if obj.LengthOut <= 0: Path.Log.error( @@ -175,6 +175,46 @@ class ObjectDressup: self.wire, self.rapids = wireForPath(PathUtils.getPathWithPlacement(obj.Base)) obj.Path = self.generateLeadInOutCurve(obj) + def onDocumentRestored(self, obj): + """onDocumentRestored(obj) ... Called automatically when document is restored.""" + lead_styles = [ + QT_TRANSLATE_NOOP("CAM_DressupLeadInOut", "Arc"), + QT_TRANSLATE_NOOP("CAM_DressupLeadInOut", "Tangent"), + QT_TRANSLATE_NOOP("CAM_DressupLeadInOut", "Perpendicular"), + ] + if hasattr(obj, "StyleOn"): + # Replace StyleOn by StyleIn + obj.addProperty( + "App::PropertyEnumeration", + "StyleIn", + "Path", + QT_TRANSLATE_NOOP("App::Property", "The Style of motion into the toolpath"), + ) + obj.StyleIn = lead_styles + obj.StyleIn = obj.StyleOn + obj.removeProperty("StyleOn") + if hasattr(obj, "StyleOff"): + # Replace StyleOff by StyleOut + obj.addProperty( + "App::PropertyEnumeration", + "StyleOut", + "Path", + QT_TRANSLATE_NOOP("App::Property", "The Style of motion out of the toolpath"), + ) + obj.StyleOut = lead_styles + obj.StyleOut = obj.StyleOff + obj.removeProperty("StyleOff") + if hasattr(obj, "Length"): + # Replace Length by LengthIn + obj.addProperty( + "App::PropertyDistance", + "LengthIn", + "Path", + QT_TRANSLATE_NOOP("App::Property", "Length or Radius of the approach"), + ) + obj.LengthIn = obj.Length + obj.removeProperty("Length") + def getDirectionOfPath(self, obj): op = PathDressup.baseOp(obj.Base) side = op.Side if hasattr(op, "Side") else "Inside" @@ -260,18 +300,18 @@ class ObjectDressup: # x v if obj.LeadIn: - length = obj.Length.Value + length = obj.LengthIn.Value angle = move.anglesOfTangents()[0] tangent = -self.angleToVector(angle) * length normal = self.angleToVector(angle + self.getArcDirection(obj)) * length # prepend the selected lead-in - if obj.StyleOn == "Arc": + if obj.StyleIn == "Arc": arcbegin = begin + tangent + normal prepend(self.createArcMove(obj, arcbegin, begin, -tangent)) - elif obj.StyleOn == "Tangent": + elif obj.StyleIn == "Tangent": prepend(self.createStraightMove(obj, begin + tangent, begin)) - else: # obj.StyleOn == "Perpendicular" + else: # obj.StyleIn == "Perpendicular" prepend(self.createStraightMove(obj, begin + normal, begin)) extend = obj.ExtendLeadIn.Value @@ -309,12 +349,12 @@ class ObjectDressup: normal = self.angleToVector(angle + self.getArcDirection(obj)) * length # append the selected lead-out - if obj.StyleOff == "Arc": + if obj.StyleOut == "Arc": arcend = end + tangent + normal append(self.createArcMove(obj, end, arcend, normal)) - elif obj.StyleOff == "Tangent": + elif obj.StyleOut == "Tangent": append(self.createStraightMove(obj, end, end + tangent)) - else: # obj.StyleOff == "Perpendicular" + else: # obj.StyleOut == "Perpendicular" append(self.createStraightMove(obj, end, end + normal)) extend = obj.ExtendLeadOut.Value @@ -384,12 +424,12 @@ class TaskDressupLeadInOut(SimpleEditPanel): def setupUi(self): self.connectWidget("LeadIn", self.form.chkLeadIn) self.connectWidget("LeadOut", self.form.chkLeadOut) - self.connectWidget("Length", self.form.dspLenIn) + self.connectWidget("LengthIn", self.form.dspLenIn) self.connectWidget("LengthOut", self.form.dspLenOut) self.connectWidget("ExtendLeadIn", self.form.dspExtendIn) self.connectWidget("ExtendLeadOut", self.form.dspExtendOut) - self.connectWidget("StyleOn", self.form.cboStyleIn) - self.connectWidget("StyleOff", self.form.cboStyleOut) + self.connectWidget("StyleIn", self.form.cboStyleIn) + self.connectWidget("StyleOut", self.form.cboStyleOut) self.connectWidget("RapidPlunge", self.form.chkRapidPlunge) self.connectWidget("IncludeLayers", self.form.chkLayers) self.connectWidget("KeepToolDown", self.form.chkKeepToolDown)