Draft: re-added recomputes where needed in Draft GUI tools

This commit is contained in:
Yorik van Havre
2019-04-08 18:17:44 -03:00
parent 442ba9e2c1
commit d01ecef12e

View File

@@ -606,7 +606,8 @@ class Line(Creator):
'line.X2 = '+str(p2.x),
'line.Y2 = '+str(p2.y),
'line.Z2 = '+str(p2.z),
'Draft.autogroup(line)'])
'Draft.autogroup(line)',
'FreeCAD.ActiveDocument.recompute()'])
else:
# building command string
rot,sup,pts,fil = self.getStrings()
@@ -617,7 +618,8 @@ class Line(Creator):
'pl.Base = '+DraftVecUtils.toString(self.node[0]),
'points = '+pts,
'line = Draft.makeWire(points,placement=pl,closed='+str(closed)+',face='+fil+',support='+sup+')',
'Draft.autogroup(line)'])
'Draft.autogroup(line)',
'FreeCAD.ActiveDocument.recompute()'])
Creator.finish(self)
if self.ui:
if self.ui.continueMode:
@@ -772,7 +774,8 @@ class Wire(Line):
rems = ["FreeCAD.ActiveDocument.removeObject(\""+o.Name+"\")" for o in FreeCADGui.Selection.getSelection()]
FreeCADGui.addModule("Draft")
todo.delayCommit([(translate("draft","Convert to Wire"),
['wire = Draft.makeWire(['+pts+'])']+rems+['Draft.autogroup(wire)'])])
['wire = Draft.makeWire(['+pts+'])']+rems+['Draft.autogroup(wire)',
'FreeCAD.ActiveDocument.recompute()'])])
return
Line.Activated(self,name=translate("draft","DWire"))
@@ -869,7 +872,8 @@ class BSpline(Line):
self.commit(translate("draft","Create B-spline"),
['points = '+pts,
'spline = Draft.makeBSpline(points,closed='+str(closed)+',face='+fil+',support='+sup+')',
'Draft.autogroup(spline)'])
'Draft.autogroup(spline)',
'FreeCAD.ActiveDocument.recompute()'])
except:
print("Draft: error delaying commit")
Creator.finish(self)
@@ -1150,8 +1154,9 @@ class CubicBezCurve(Line):
FreeCADGui.addModule("Draft")
self.commit(translate("draft","Create BezCurve"),
['points = '+pts,
'bez = Draft.makeBezCurve(points,closed='+str(closed)+',support='+sup+',Degree='+str(self.degree)+')',
'Draft.autogroup(bez)'])
'bez = Draft.makeBezCurve(points,closed='+str(closed)+',support='+sup+')',
'Draft.autogroup(bez)',
'FreeCAD.ActiveDocument.recompute()'])
except:
print("Draft: error delaying commit")
Creator.finish(self)
@@ -1281,7 +1286,8 @@ class Rectangle(Creator):
'pl.Rotation.Q='+rot,
'pl.Base = '+DraftVecUtils.toString(base),
'plane.Placement = pl',
'Draft.autogroup(plane)'])
'Draft.autogroup(plane)',
'FreeCAD.ActiveDocument.recompute()'])
else:
FreeCADGui.addModule("Draft")
self.commit(translate("draft","Create Rectangle"),
@@ -1289,7 +1295,8 @@ class Rectangle(Creator):
'pl.Rotation.Q = '+rot,
'pl.Base = '+DraftVecUtils.toString(base),
'rec = Draft.makeRectangle(length='+str(length)+',height='+str(height)+',placement=pl,face='+fil+',support='+sup+')',
'Draft.autogroup(rec)'])
'Draft.autogroup(rec)',
'FreeCAD.ActiveDocument.recompute()'])
except:
print("Draft: error delaying commit")
self.finish(cont=True)
@@ -1546,7 +1553,8 @@ class Arc(Creator):
'pl.Rotation.Q = '+rot,
'pl.Base = '+DraftVecUtils.toString(self.center),
'circle.Placement = pl',
'Draft.autogroup(circle)'])
'Draft.autogroup(circle)',
'FreeCAD.ActiveDocument.recompute()'])
else:
# building command string
FreeCADGui.addModule("Draft")
@@ -1555,7 +1563,8 @@ class Arc(Creator):
'pl.Rotation.Q='+rot,
'pl.Base='+DraftVecUtils.toString(self.center),
'circle = Draft.makeCircle(radius='+str(self.rad)+',placement=pl,face='+fil+',support='+sup+')',
'Draft.autogroup(circle)'])
'Draft.autogroup(circle)',
'FreeCAD.ActiveDocument.recompute()'])
except:
print("Draft: error delaying commit")
else:
@@ -1581,7 +1590,8 @@ class Arc(Creator):
'pl.Rotation.Q = '+rot,
'pl.Base = '+DraftVecUtils.toString(self.center),
'circle.Placement = pl',
'Draft.autogroup(circle)'])
'Draft.autogroup(circle)',
'FreeCAD.ActiveDocument.recompute()'])
else:
# building command string
FreeCADGui.addModule("Draft")
@@ -1590,7 +1600,8 @@ class Arc(Creator):
'pl.Rotation.Q='+rot,
'pl.Base='+DraftVecUtils.toString(self.center),
'circle = Draft.makeCircle(radius='+str(self.rad)+',placement=pl,face='+fil+',startangle='+str(sta)+',endangle='+str(end)+',support='+sup+')',
'Draft.autogroup(circle)'])
'Draft.autogroup(circle)',
'FreeCAD.ActiveDocument.recompute()'])
except:
print("Draft: error delaying commit")
self.finish(cont=True)
@@ -1817,7 +1828,8 @@ class Polygon(Creator):
'pl.Rotation.Q = ' + rot,
'pl.Base = ' + DraftVecUtils.toString(self.center),
'pol = Draft.makePolygon(' + str(self.ui.numFaces.value()) + ',radius=' + str(self.rad) + ',inscribed=True,placement=pl,face=' + fil + ',support=' + sup + ')',
'Draft.autogroup(pol)'])
'Draft.autogroup(pol)',
'FreeCAD.ActiveDocument.recompute()'])
FreeCAD.ActiveDocument.recompute()
self.finish(cont=True)
@@ -1914,7 +1926,8 @@ class Ellipse(Creator):
'pl.Rotation.Q='+rot,
'pl.Base = '+DraftVecUtils.toString(center),
'ellipse.Placement = pl',
'Draft.autogroup(ellipse)'])
'Draft.autogroup(ellipse)',
'FreeCAD.ActiveDocument.recompute()'])
else:
FreeCADGui.addModule("Draft")
self.commit(translate("draft","Create Ellipse"),
@@ -1922,7 +1935,8 @@ class Ellipse(Creator):
'pl.Rotation.Q = '+rot,
'pl.Base = '+DraftVecUtils.toString(center),
'ellipse = Draft.makeEllipse('+str(r1)+','+str(r2)+',placement=pl,face='+fil+',support='+sup+')',
'Draft.autogroup(ellipse)'])
'Draft.autogroup(ellipse)',
'FreeCAD.ActiveDocument.recompute()'])
except:
print("Draft: Error: Unable to create object.")
self.finish(cont=True)
@@ -2014,7 +2028,8 @@ class Text(Creator):
FreeCADGui.addModule("Draft")
self.commit(translate("draft","Create Text"),
['text = Draft.makeText('+tx+',point='+DraftVecUtils.toString(self.node[0])+')',
'Draft.autogroup(text)'])
'Draft.autogroup(text)',
'FreeCAD.ActiveDocument.recompute()'])
FreeCAD.ActiveDocument.recompute()
self.finish(cont=True)
@@ -2151,7 +2166,8 @@ class Dimension(Creator):
self.commit(translate("draft","Create Dimension"),
['dim = Draft.makeDimension('+DraftVecUtils.toString(p1)+','+DraftVecUtils.toString(p2)+','+DraftVecUtils.toString(p3)+')',
'FreeCAD.ActiveDocument.removeObject("'+o.Name+'")',
'Draft.autogroup(dim)'])
'Draft.autogroup(dim)',
'FreeCAD.ActiveDocument.recompute()'])
def createObject(self):
"creates an object in the current doc"
@@ -2165,29 +2181,35 @@ class Dimension(Creator):
normal = DraftVecUtils.toString((v1.cross(v2)).normalize())
self.commit(translate("draft","Create Dimension"),
['dim = Draft.makeAngularDimension(center='+DraftVecUtils.toString(self.center)+',angles=['+str(self.angledata[0])+','+str(self.angledata[1])+'],p3='+DraftVecUtils.toString(self.node[-1])+',normal='+normal+')',
'Draft.autogroup(dim)'])
'Draft.autogroup(dim)',
'FreeCAD.ActiveDocument.recompute()'])
elif self.link and (not self.arcmode):
ops = []
if self.force == 1:
self.commit(translate("draft","Create Dimension"),
['dim = Draft.makeDimension(FreeCAD.ActiveDocument.'+self.link[0].Name+','+str(self.link[1])+','+str(self.link[2])+','+DraftVecUtils.toString(self.node[2])+')','dim.Direction=FreeCAD.Vector(0,1,0)',
'Draft.autogroup(dim)'])
'Draft.autogroup(dim)',
'FreeCAD.ActiveDocument.recompute()'])
elif self.force == 2:
self.commit(translate("draft","Create Dimension"),
['dim = Draft.makeDimension(FreeCAD.ActiveDocument.'+self.link[0].Name+','+str(self.link[1])+','+str(self.link[2])+','+DraftVecUtils.toString(self.node[2])+')','dim.Direction=FreeCAD.Vector(1,0,0)',
'Draft.autogroup(dim)'])
'Draft.autogroup(dim)',
'FreeCAD.ActiveDocument.recompute()'])
else:
self.commit(translate("draft","Create Dimension"),
['dim = Draft.makeDimension(FreeCAD.ActiveDocument.'+self.link[0].Name+','+str(self.link[1])+','+str(self.link[2])+','+DraftVecUtils.toString(self.node[2])+')',
'Draft.autogroup(dim)'])
'Draft.autogroup(dim)',
'FreeCAD.ActiveDocument.recompute()'])
elif self.arcmode:
self.commit(translate("draft","Create Dimension"),
['dim = Draft.makeDimension(FreeCAD.ActiveDocument.'+self.link[0].Name+','+str(self.link[1])+',"'+str(self.arcmode)+'",'+DraftVecUtils.toString(self.node[2])+')',
'Draft.autogroup(dim)'])
'Draft.autogroup(dim)',
'FreeCAD.ActiveDocument.recompute()'])
else:
self.commit(translate("draft","Create Dimension"),
['dim = Draft.makeDimension('+DraftVecUtils.toString(self.node[0])+','+DraftVecUtils.toString(self.node[1])+','+DraftVecUtils.toString(self.node[2])+')',
'Draft.autogroup(dim)'])
'Draft.autogroup(dim)',
'FreeCAD.ActiveDocument.recompute()'])
if self.ui.continueMode:
self.cont = self.node[2]
if not self.dir:
@@ -2454,7 +2476,8 @@ class ShapeString(Creator):
'plm.Rotation.Q='+qr,
'ss.Placement=plm',
'ss.Support='+sup,
'Draft.autogroup(ss)'])
'Draft.autogroup(ss)',
'FreeCAD.ActiveDocument.recompute()'])
except Exception as e:
msg("Draft_ShapeString: error delaying commit", "error")
self.finish()
@@ -5249,6 +5272,7 @@ class Shape2DView(Modifier):
return
for o in objs:
Draft.makeShape2DView(o,vec)
FreeCAD.ActiveDocument.recompute()
self.finish()
@@ -5467,13 +5491,15 @@ class Point(Creator):
'point.X = '+str(self.stack[0][0]),
'point.Y = '+str(self.stack[0][1]),
'point.Z = '+str(self.stack[0][2]),
'Draft.autogroup(point)']))
'Draft.autogroup(point)',
'FreeCAD.ActiveDocument.recompute()']))
else:
# building command string
FreeCADGui.addModule("Draft")
commitlist.append((translate("draft","Create Point"),
['point = Draft.makePoint('+str(self.stack[0][0])+','+str(self.stack[0][1])+','+str(self.stack[0][2])+')',
'Draft.autogroup(point)']))
'Draft.autogroup(point)',
'FreeCAD.ActiveDocument.recompute()']))
todo.delayCommit(commitlist)
FreeCADGui.Snapper.off()
self.finish()
@@ -5614,6 +5640,7 @@ class Draft_Facebinder(Creator):
FreeCADGui.doCommand("s = FreeCADGui.Selection.getSelectionEx()")
FreeCADGui.doCommand("f = Draft.makeFacebinder(s)")
FreeCADGui.doCommand('Draft.autogroup(f)')
FreeCADGui.doCommand('FreeCAD.ActiveDocument.recompute()')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
self.finish()
@@ -5647,11 +5674,13 @@ class VisGroup():
if s[0].isDerivedFrom("App::DocumentObjectGroup"):
FreeCADGui.doCommand("v = Draft.makeVisGroup(FreeCAD.ActiveDocument."+s[0].Name+")")
FreeCADGui.doCommand('Draft.autogroup(v)')
FreeCADGui.doCommand('FreeCAD.ActiveDocument.recompute()')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
FreeCADGui.doCommand("v = Draft.makeVisGroup()")
FreeCADGui.doCommand('Draft.autogroup(v)')
FreeCADGui.doCommand('FreeCAD.ActiveDocument.recompute()')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()