Fixed bug 666 - Draft grid

This commit is contained in:
Yorik van Havre 2012-04-08 12:10:24 -03:00
parent 605d567cc4
commit 4d1df2bcba
5 changed files with 3111 additions and 314 deletions

View File

@ -107,7 +107,7 @@ def getParamType(param):
elif param in ["textheight","tolerance","gridSpacing"]: elif param in ["textheight","tolerance","gridSpacing"]:
return "float" return "float"
elif param in ["selectBaseObjects","alwaysSnap","grid","fillmode","saveonexit","maxSnap", elif param in ["selectBaseObjects","alwaysSnap","grid","fillmode","saveonexit","maxSnap",
"SvgLinesBlack","dxfStdSize","showSnapBar","hideSnapBar"]: "SvgLinesBlack","dxfStdSize","showSnapBar","hideSnapBar","alwaysShowGrid"]:
return "bool" return "bool"
elif param in ["color","constructioncolor","snapcolor"]: elif param in ["color","constructioncolor","snapcolor"]:
return "unsigned" return "unsigned"

View File

@ -605,7 +605,8 @@ class Snapper:
if self.extLine: if self.extLine:
self.extLine.off() self.extLine.off()
if self.grid: if self.grid:
self.grid.off() if not Draft.getParam("alwaysShowGrid"):
self.grid.off()
self.unconstrain() self.unconstrain()
self.radius = 0 self.radius = 0
self.setCursor() self.setCursor()
@ -830,5 +831,11 @@ class Snapper:
mw.addToolBar(self.toolbar) mw.addToolBar(self.toolbar)
self.toolbar.show() self.toolbar.show()
def setGrid(self):
"sets the grid, if visible"
if self.grid:
if self.grid.Visible:
self.grid.set()
if not hasattr(FreeCADGui,"Snapper"): if not hasattr(FreeCADGui,"Snapper"):
FreeCADGui.Snapper = Snapper() FreeCADGui.Snapper = Snapper()

View File

@ -301,6 +301,7 @@ class SelectPlane:
elif type(arg).__name__ == 'Vector': elif type(arg).__name__ == 'Vector':
plv = 'd('+str(arg.x)+','+str(arg.y)+','+str(arg.z)+')' plv = 'd('+str(arg.x)+','+str(arg.y)+','+str(arg.z)+')'
self.ui.wplabel.setText(plv+suffix) self.ui.wplabel.setText(plv+suffix)
FreeCADGui.Snapper.setGrid()
def finish(self): def finish(self):
if self.call: if self.call:
@ -1538,6 +1539,7 @@ class Dimension(Creator):
if not self.node: self.support = getSupport(arg) if not self.node: self.support = getSupport(arg)
if hasMod(arg,MODALT) and (len(self.node)<3): if hasMod(arg,MODALT) and (len(self.node)<3):
snapped = self.view.getObjectInfo((arg["Position"][0],arg["Position"][1])) snapped = self.view.getObjectInfo((arg["Position"][0],arg["Position"][1]))
print "snapped: ",snapped
if snapped: if snapped:
ob = self.doc.getObject(snapped['Object']) ob = self.doc.getObject(snapped['Object'])
if 'Edge' in snapped['Component']: if 'Edge' in snapped['Component']:
@ -1587,6 +1589,7 @@ class Dimension(Creator):
if self.dir: if self.dir:
point = self.node[0].add(fcvec.project(point.sub(self.node[0]),self.dir)) point = self.node[0].add(fcvec.project(point.sub(self.node[0]),self.dir))
self.node.append(point) self.node.append(point)
print "node",self.node
self.dimtrack.update(self.node) self.dimtrack.update(self.node)
if (len(self.node) == 2): if (len(self.node) == 2):
self.point2 = self.node[1] self.point2 = self.node[1]

File diff suppressed because it is too large Load Diff

View File

@ -657,6 +657,25 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_10">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>If checked, the Draft grid will always be visible when the Draft workbench is active. Otherwise only when using a command</string>
</property>
<property name="text">
<string>Always show</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>alwaysShowGrid</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="label_15"> <widget class="QLabel" name="label_15">
<property name="enabled"> <property name="enabled">
@ -1300,5 +1319,21 @@ such as &quot;Arial:Bold&quot;</string>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>gui::prefcheckbox_2</sender>
<signal>clicked(bool)</signal>
<receiver>gui::prefcheckbox_10</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>72</x>
<y>375</y>
</hint>
<hint type="destinationlabel">
<x>226</x>
<y>373</y>
</hint>
</hints>
</connection>
</connections> </connections>
</ui> </ui>