Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Fix inaccuracy in Draft Edit command #9202

Merged
merged 1 commit into from
Apr 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Mod/Draft/draftguitools/gui_trackers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ***************************************************************************

Check warning on line 1 in src/Mod/Draft/draftguitools/gui_trackers.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

would reformat src/Mod/Draft/draftguitools/gui_trackers.py
# * Copyright (c) 2011 Yorik van Havre <yorik@uncreated.net> *
# * *
# * This program is free software; you can redistribute it and/or modify *
Expand Down Expand Up @@ -399,7 +399,7 @@
self.bspline = None
c = Part.BSplineCurve()
# DNC: allows to close the curve by placing ends close to each other
if len(self.points) >= 3 and ( (self.points[0] - self.points[-1]).Length < Draft.tolerance() ):

Check warning on line 402 in src/Mod/Draft/draftguitools/gui_trackers.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Line too long (107/100) (line-too-long)
# YVH: Added a try to bypass some hazardous situations
try:
c.interpolate(self.points[:-1], True)
Expand All @@ -422,7 +422,7 @@
except Exception:
# workaround for pivy SoInput.setBuffer() bug
buf = buf.replace("\n", "")
pts = re.findall("point \[(.*?)\]", buf)[0]

Check warning on line 425 in src/Mod/Draft/draftguitools/gui_trackers.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Anomalous backslash in string: '\['. String constant might be missing an r prefix. (anomalous-backslash-in-string)
pts = pts.split(",")
pc = []
for p in pts:
Expand All @@ -443,7 +443,7 @@
self.bspline.removeChild(self.bspline.getChild(0))
self.sep.addChild(self.bspline)
else:
FreeCAD.Console.PrintWarning("bsplineTracker.recompute() failed to read-in Inventor string\n")

Check warning on line 446 in src/Mod/Draft/draftguitools/gui_trackers.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Line too long (114/100) (line-too-long)


class bezcurveTracker(Tracker):
Expand Down Expand Up @@ -475,10 +475,10 @@

self.bezcurve = []

if (len(self.points) >= 2):

Check warning on line 478 in src/Mod/Draft/draftguitools/gui_trackers.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Unnecessary parens after 'if' keyword (superfluous-parens)
if self.degree:
poles = self.points[1:]
segpoleslst = [poles[x:x+self.degree] for x in range(0, len(poles), (self.degree or 1))]

Check warning on line 481 in src/Mod/Draft/draftguitools/gui_trackers.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Line too long (104/100) (line-too-long)
else:
segpoleslst = [self.points]
startpoint = self.points[0]
Expand Down Expand Up @@ -521,7 +521,7 @@
bezcurveseg.removeChild(bezcurveseg.getChild(0))
self.sep.addChild(bezcurveseg)
else:
FreeCAD.Console.PrintWarning("bezcurveTracker.recompute() failed to read-in Inventor string\n")

Check warning on line 524 in src/Mod/Draft/draftguitools/gui_trackers.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Line too long (119/100) (line-too-long)
self.bezcurve.append(bezcurveseg)


Expand Down Expand Up @@ -656,7 +656,7 @@
self.circle.removeChild(self.circle.getChild(0))
self.sep.addChild(self.circle)
else:
FreeCAD.Console.PrintWarning("arcTracker.recompute() failed to read-in Inventor string\n")

Check warning on line 659 in src/Mod/Draft/draftguitools/gui_trackers.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Line too long (106/100) (line-too-long)


class ghostTracker(Tracker):
Expand Down Expand Up @@ -762,7 +762,7 @@

def getMatrix(self):
"""Get matrix of the active view."""
r = FreeCADGui.ActiveDocument.ActiveView.getViewer().getSoRenderManager().getViewportRegion()

Check warning on line 765 in src/Mod/Draft/draftguitools/gui_trackers.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Line too long (101/100) (line-too-long)
v = coin.SoGetMatrixAction(r)
m = self.trans.getMatrix(v)
if m:
Expand Down Expand Up @@ -798,6 +798,7 @@
self.marker.markerIndex = marker
self.coords = coin.SoCoordinate3() # this is the coordinate
self.coords.point.setValue((pos.x, pos.y, pos.z))
self.position = pos
if inactive:
self.selnode = coin.SoSeparator()
else:
Expand All @@ -820,11 +821,11 @@
def set(self, pos):
"""Set the point to the position."""
self.coords.point.setValue((pos.x, pos.y, pos.z))
self.position = pos

def get(self):
"""Get a vector from the point."""
p = self.coords.point.getValues()[0]
return Vector(p[0], p[1], p[2])
return self.position

def get_doc_name(self):
"""Get the document name."""
Expand Down Expand Up @@ -1115,7 +1116,7 @@
if Draft.getParam("gridBorder", True):
# extra border
border = (numlines//2 + self.mainlines/2) * self.space
mpts.extend([[-border, -border, z], [border, -border, z], [border, border, z], [-border, border, z], [-border, -border, z]])

Check warning on line 1119 in src/Mod/Draft/draftguitools/gui_trackers.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Line too long (140/100) (line-too-long)
midx.append(5)
# cursors
mpts.extend(cpts)
Expand All @@ -1123,7 +1124,7 @@
# texts
self.font.size = self.space*(self.mainlines//4) or 1
self.font.name = Draft.getParam("textfont","Sans")
txt = FreeCAD.Units.Quantity(self.space*self.mainlines,FreeCAD.Units.Length).UserString

Check warning on line 1127 in src/Mod/Draft/draftguitools/gui_trackers.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Line too long (103/100) (line-too-long)
self.text1.string = txt
self.text2.string = txt
self.textpos1.translation.setValue((-bound+self.space,-border+self.space,z))
Expand Down