Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Draft: use viewer.redraw() in interactive operations
improves responsiveness of Draft on Windows dramatically
  • Loading branch information
DeepSOIC authored and yorikvanhavre committed May 8, 2017
1 parent 1137d5e commit 164b8c7
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/Mod/Draft/DraftTools.py
Expand Up @@ -447,6 +447,13 @@ def display(self,arg):
# Geometry constructors
#---------------------------------------------------------------------------

def redraw3DView():
"""redraw3DView(): forces a redraw of 3d view."""
try:
FreeCADGui.ActiveDocument.ActiveView.redraw()
except AttributeError as err:
pass

class Creator(DraftTool):
"A generic Draft Creator Tool used by creation tools such as line or arc"

Expand Down Expand Up @@ -527,6 +534,7 @@ def action(self,arg):
elif arg["Type"] == "SoLocation2Event":
# mouse movement detection
self.point,ctrlPoint,info = getPoint(self,arg)
redraw3DView()
elif arg["Type"] == "SoMouseButtonEvent":
# mouse button detection
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
Expand Down Expand Up @@ -670,6 +678,7 @@ def action(self,arg):
elif arg["Type"] == "SoLocation2Event": #mouse movement detection
self.point,ctrlPoint,info = getPoint(self,arg,noTracker=True)
self.bsplinetrack.update(self.node + [self.point])
redraw3DView()
elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
if (arg["Position"] == self.pos):
Expand Down Expand Up @@ -768,6 +777,7 @@ def action(self,arg):
elif arg["Type"] == "SoLocation2Event": #mouse movement detection
self.point,ctrlPoint,info = getPoint(self,arg,noTracker=True)
self.bezcurvetrack.update(self.node + [self.point]) #existing points + this pointer position
redraw3DView()
elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"): #left click
if (arg["Position"] == self.pos): #double click?
Expand Down Expand Up @@ -989,6 +999,7 @@ def action(self,arg):
elif arg["Type"] == "SoLocation2Event": #mouse movement detection
self.point,ctrlPoint,info = getPoint(self,arg,mobile=True,noTracker=True)
self.rect.update(self.point)
redraw3DView()
elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
if (arg["Position"] == self.pos):
Expand Down Expand Up @@ -1157,6 +1168,8 @@ def action(self,arg):
self.ui.setRadiusValue(math.degrees(self.angle),unit="Angle")
self.arctrack.setApertureAngle(self.angle)

redraw3DView()

elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
if self.point:
Expand Down Expand Up @@ -1439,6 +1452,8 @@ def action(self,arg):
self.ui.setRadiusValue(self.rad,'Length')
self.arctrack.setRadius(self.rad)

redraw3DView()

elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
if self.point:
Expand Down Expand Up @@ -1615,6 +1630,7 @@ def action(self,arg):
elif arg["Type"] == "SoLocation2Event": #mouse movement detection
self.point,ctrlPoint,info = getPoint(self,arg,mobile=True,noTracker=True)
self.rect.update(self.point)
redraw3DView()
elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
if (arg["Position"] == self.pos):
Expand Down Expand Up @@ -1701,6 +1717,7 @@ def action(self,arg):
elif arg["Type"] == "SoLocation2Event": #mouse movement detection
if self.active:
self.point,ctrlPoint,info = getPoint(self,arg)
redraw3DView()
elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
if self.point:
Expand Down Expand Up @@ -1965,6 +1982,7 @@ def action(self,arg):
# update the dimline
if self.node and (not self.arcmode):
self.dimtrack.update(self.node+[self.point]+[self.cont])
redraw3DView()
elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
import DraftGeomUtils
Expand Down Expand Up @@ -2128,6 +2146,7 @@ def action(self,arg):
elif arg["Type"] == "SoLocation2Event": #mouse movement detection
if self.active:
self.point,ctrlPoint,info = getPoint(self,arg,noTracker=True)
redraw3DView()
elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
if not self.ssBase:
Expand Down Expand Up @@ -2269,6 +2288,7 @@ def action(self,arg):
self.ghost.on()
if self.extendedCopy:
if not hasMod(arg,MODALT): self.finish()
redraw3DView()
elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
if self.point:
Expand Down Expand Up @@ -2457,6 +2477,7 @@ def action(self,arg):
self.ui.setRadiusValue(math.degrees(sweep), 'Angle')
self.ui.radiusValue.setFocus()
self.ui.radiusValue.selectAll()
redraw3DView()

elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
Expand Down Expand Up @@ -2656,6 +2677,7 @@ def action(self,arg):
self.ui.radiusValue.selectAll()
if self.extendedCopy:
if not hasMod(arg,MODALT): self.finish()
redraw3DView()

elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
Expand Down Expand Up @@ -2764,6 +2786,7 @@ def action(self,arg):
point,ctrlPoint,info = getPoint(self,arg) #,mobile=True) #,noTracker=(self.step < 3))
if self.step == 2:
self.rectracker.update(point)
redraw3DView()
elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
if (arg["Position"] == self.pos):
Expand Down Expand Up @@ -3163,6 +3186,7 @@ def action(self,arg):
self.ui.setRadiusValue(dist,unit="Length")
self.ui.radiusValue.setFocus()
self.ui.radiusValue.selectAll()
redraw3DView()

elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
Expand Down Expand Up @@ -3547,6 +3571,7 @@ def action(self,arg):
self.ui.zValue.setText("1")
if self.extendedCopy:
if not hasMod(arg,MODALT): self.finish()
redraw3DView()
elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
if self.point:
Expand Down Expand Up @@ -3937,6 +3962,7 @@ def action(self,arg):
# commented out the following line to disable updating
# the object during edit, otherwise it confuses the snapper
#self.update(self.trackers[self.editing].get())
redraw3DView()
elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
self.ui.redraw()
Expand Down Expand Up @@ -4106,6 +4132,10 @@ def update(self,v):
self.obj.TagPosition = self.invpl.multVec(v)
else:
self.obj.Group[self.editing-1].Placement.Base = self.invpl.multVec(v)
try:
FreeCADGui.ActiveDocument.ActiveView.redraw()
except AttributeError as err:
pass

def numericInput(self,v,numy=None,numz=None):
'''this function gets called by the toolbar
Expand Down Expand Up @@ -4968,6 +4998,7 @@ def action(self,arg):
self.ghost.setMatrix(m)
if self.extendedCopy:
if not hasMod(arg,MODALT): self.finish()
redraw3DView()
elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
if self.point:
Expand Down

0 comments on commit 164b8c7

Please sign in to comment.