Draft: Grid now checks preferences settings when redrawn - fixes #1671
This commit is contained in:
parent
749abc5ed7
commit
f796cacf65
|
@ -3371,7 +3371,7 @@ class _ViewProviderDimension(_ViewProviderDraft):
|
||||||
# setting text
|
# setting text
|
||||||
try:
|
try:
|
||||||
m = obj.ViewObject.DisplayMode
|
m = obj.ViewObject.DisplayMode
|
||||||
except AttributeError:
|
except: # swallow all exceptions here since it always fails on first run (Displaymode enum no set yet)
|
||||||
m = ["2D","3D"][getParam("dimstyle",0)]
|
m = ["2D","3D"][getParam("dimstyle",0)]
|
||||||
if m== "3D":
|
if m== "3D":
|
||||||
offset = offset.negative()
|
offset = offset.negative()
|
||||||
|
@ -3684,7 +3684,7 @@ class _ViewProviderAngularDimension(_ViewProviderDraft):
|
||||||
# check display mode
|
# check display mode
|
||||||
try:
|
try:
|
||||||
m = obj.ViewObject.DisplayMode
|
m = obj.ViewObject.DisplayMode
|
||||||
except AttributeError:
|
except: # swallow all exceptions here since it always fails on first run (Displaymode enum no set yet)
|
||||||
m = ["2D","3D"][getParam("dimstyle",0)]
|
m = ["2D","3D"][getParam("dimstyle",0)]
|
||||||
|
|
||||||
# set the arc
|
# set the arc
|
||||||
|
|
|
@ -4198,6 +4198,7 @@ class ToggleGrid():
|
||||||
FreeCADGui.Snapper.grid.off()
|
FreeCADGui.Snapper.grid.off()
|
||||||
FreeCADGui.Snapper.forceGridOff=True
|
FreeCADGui.Snapper.forceGridOff=True
|
||||||
else:
|
else:
|
||||||
|
FreeCADGui.Snapper.grid.reset()
|
||||||
FreeCADGui.Snapper.grid.on()
|
FreeCADGui.Snapper.grid.on()
|
||||||
FreeCADGui.Snapper.forceGridOff=False
|
FreeCADGui.Snapper.forceGridOff=False
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -716,19 +716,43 @@ class wireTracker(Tracker):
|
||||||
class gridTracker(Tracker):
|
class gridTracker(Tracker):
|
||||||
"A grid tracker"
|
"A grid tracker"
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# self.space = 1
|
|
||||||
self.space = Draft.getParam("gridSpacing",1)
|
|
||||||
# self.mainlines = 10
|
|
||||||
self.mainlines = Draft.getParam("gridEvery",10)
|
|
||||||
self.numlines = Draft.getParam("gridSize",100)
|
|
||||||
col = [0.2,0.2,0.3]
|
col = [0.2,0.2,0.3]
|
||||||
|
|
||||||
pick = coin.SoPickStyle()
|
pick = coin.SoPickStyle()
|
||||||
pick.style.setValue(coin.SoPickStyle.UNPICKABLE)
|
pick.style.setValue(coin.SoPickStyle.UNPICKABLE)
|
||||||
|
|
||||||
self.trans = coin.SoTransform()
|
self.trans = coin.SoTransform()
|
||||||
self.trans.translation.setValue([0,0,0])
|
self.trans.translation.setValue([0,0,0])
|
||||||
|
mat1 = coin.SoMaterial()
|
||||||
|
mat1.transparency.setValue(0.7)
|
||||||
|
mat1.diffuseColor.setValue(col)
|
||||||
|
self.coords1 = coin.SoCoordinate3()
|
||||||
|
self.lines1 = coin.SoLineSet()
|
||||||
|
mat2 = coin.SoMaterial()
|
||||||
|
mat2.transparency.setValue(0.3)
|
||||||
|
mat2.diffuseColor.setValue(col)
|
||||||
|
self.coords2 = coin.SoCoordinate3()
|
||||||
|
self.lines2 = coin.SoLineSet()
|
||||||
|
mat3 = coin.SoMaterial()
|
||||||
|
mat3.transparency.setValue(0)
|
||||||
|
mat3.diffuseColor.setValue(col)
|
||||||
|
self.coords3 = coin.SoCoordinate3()
|
||||||
|
self.lines3 = coin.SoLineSet()
|
||||||
|
s = coin.SoSeparator()
|
||||||
|
s.addChild(pick)
|
||||||
|
s.addChild(self.trans)
|
||||||
|
s.addChild(mat1)
|
||||||
|
s.addChild(self.coords1)
|
||||||
|
s.addChild(self.lines1)
|
||||||
|
s.addChild(mat2)
|
||||||
|
s.addChild(self.coords2)
|
||||||
|
s.addChild(self.lines2)
|
||||||
|
s.addChild(mat3)
|
||||||
|
s.addChild(self.coords3)
|
||||||
|
s.addChild(self.lines3)
|
||||||
|
Tracker.__init__(self,children=[s])
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
"redraws the grid"
|
||||||
bound = (self.numlines/2)*self.space
|
bound = (self.numlines/2)*self.space
|
||||||
pts = []
|
pts = []
|
||||||
mpts = []
|
mpts = []
|
||||||
|
@ -755,57 +779,12 @@ class gridTracker(Tracker):
|
||||||
midx.append(2)
|
midx.append(2)
|
||||||
for ap in range(0,len(apts),2):
|
for ap in range(0,len(apts),2):
|
||||||
aidx.append(2)
|
aidx.append(2)
|
||||||
|
|
||||||
mat1 = coin.SoMaterial()
|
|
||||||
mat1.transparency.setValue(0.7)
|
|
||||||
mat1.diffuseColor.setValue(col)
|
|
||||||
self.coords1 = coin.SoCoordinate3()
|
|
||||||
self.coords1.point.setValues(pts)
|
self.coords1.point.setValues(pts)
|
||||||
lines1 = coin.SoLineSet()
|
self.lines1.numVertices.setValues(idx)
|
||||||
lines1.numVertices.setValues(idx)
|
|
||||||
mat2 = coin.SoMaterial()
|
|
||||||
mat2.transparency.setValue(0.3)
|
|
||||||
mat2.diffuseColor.setValue(col)
|
|
||||||
self.coords2 = coin.SoCoordinate3()
|
|
||||||
self.coords2.point.setValues(mpts)
|
self.coords2.point.setValues(mpts)
|
||||||
lines2 = coin.SoLineSet()
|
self.lines2.numVertices.setValues(midx)
|
||||||
lines2.numVertices.setValues(midx)
|
|
||||||
mat3 = coin.SoMaterial()
|
|
||||||
mat3.transparency.setValue(0)
|
|
||||||
mat3.diffuseColor.setValue(col)
|
|
||||||
self.coords3 = coin.SoCoordinate3()
|
|
||||||
self.coords3.point.setValues(apts)
|
self.coords3.point.setValues(apts)
|
||||||
lines3 = coin.SoLineSet()
|
self.lines3.numVertices.setValues(aidx)
|
||||||
lines3.numVertices.setValues(aidx)
|
|
||||||
s = coin.SoSeparator()
|
|
||||||
s.addChild(pick)
|
|
||||||
s.addChild(self.trans)
|
|
||||||
s.addChild(mat1)
|
|
||||||
s.addChild(self.coords1)
|
|
||||||
s.addChild(lines1)
|
|
||||||
s.addChild(mat2)
|
|
||||||
s.addChild(self.coords2)
|
|
||||||
s.addChild(lines2)
|
|
||||||
s.addChild(mat3)
|
|
||||||
s.addChild(self.coords3)
|
|
||||||
s.addChild(lines3)
|
|
||||||
Tracker.__init__(self,children=[s])
|
|
||||||
self.update()
|
|
||||||
|
|
||||||
def update(self):
|
|
||||||
bound = (self.numlines/2)*self.space
|
|
||||||
pts = []
|
|
||||||
mpts = []
|
|
||||||
for i in range(self.numlines+1):
|
|
||||||
curr = -bound + i*self.space
|
|
||||||
if i/float(self.mainlines) == i/self.mainlines:
|
|
||||||
mpts.extend([[-bound,curr,0],[bound,curr,0]])
|
|
||||||
mpts.extend([[curr,-bound,0],[curr,bound,0]])
|
|
||||||
else:
|
|
||||||
pts.extend([[-bound,curr,0],[bound,curr,0]])
|
|
||||||
pts.extend([[curr,-bound,0],[curr,bound,0]])
|
|
||||||
self.coords1.point.setValues(pts)
|
|
||||||
self.coords2.point.setValues(mpts)
|
|
||||||
|
|
||||||
def setSize(self,size):
|
def setSize(self,size):
|
||||||
self.numlines = size
|
self.numlines = size
|
||||||
|
@ -818,8 +797,17 @@ class gridTracker(Tracker):
|
||||||
def setMainlines(self,ml):
|
def setMainlines(self,ml):
|
||||||
self.mainlines = ml
|
self.mainlines = ml
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
"resets the grid according to preferences settings"
|
||||||
|
self.space = Draft.getParam("gridSpacing",1)
|
||||||
|
self.mainlines = Draft.getParam("gridEvery",10)
|
||||||
|
self.numlines = Draft.getParam("gridSize",100)
|
||||||
|
self.update()
|
||||||
|
|
||||||
def set(self):
|
def set(self):
|
||||||
|
"moves and rotates the grid according to the current WP"
|
||||||
|
self.reset()
|
||||||
Q = FreeCAD.DraftWorkingPlane.getRotation().Rotation.Q
|
Q = FreeCAD.DraftWorkingPlane.getRotation().Rotation.Q
|
||||||
P = FreeCAD.DraftWorkingPlane.position
|
P = FreeCAD.DraftWorkingPlane.position
|
||||||
self.trans.rotation.setValue([Q[0],Q[1],Q[2],Q[3]])
|
self.trans.rotation.setValue([Q[0],Q[1],Q[2],Q[3]])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user