0001092: Draft local/global coordinates
The draft X,Y,Z coordinates are now displayed as global, or local if the current working plane is different from the world axes.
This commit is contained in:
parent
827a716814
commit
7f216323ff
|
@ -559,7 +559,12 @@ class DraftToolBar:
|
|||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
return True
|
||||
todo.delay(FreeCADGui.Control.showDialog,dummy())
|
||||
self.setTitle(title)
|
||||
self.setTitle(title)
|
||||
|
||||
def redraw(self):
|
||||
"utility function that is performed after each clicked point"
|
||||
print "redrawing"
|
||||
self.checkLocal()
|
||||
|
||||
def selectPlaneUi(self):
|
||||
self.taskUi(translate("draft", "Select Plane"))
|
||||
|
@ -623,7 +628,7 @@ class DraftToolBar:
|
|||
self.taskUi(title,extra,icon)
|
||||
self.xValue.setEnabled(True)
|
||||
self.yValue.setEnabled(True)
|
||||
self.labelx.setText(translate("draft", "X"))
|
||||
self.checkLocal()
|
||||
self.labelx.show()
|
||||
self.labely.show()
|
||||
self.labelz.show()
|
||||
|
@ -805,6 +810,17 @@ class DraftToolBar:
|
|||
def vertUi(self,addmode=True):
|
||||
self.addButton.setChecked(addmode)
|
||||
self.delButton.setChecked(not(addmode))
|
||||
|
||||
def checkLocal(self):
|
||||
"checks if x,y,z coords must be displayed as local or global"
|
||||
self.labelx.setText(translate("draft", "Global X"))
|
||||
self.labely.setText(translate("draft", "Global Y"))
|
||||
self.labelz.setText(translate("draft", "Global Z"))
|
||||
if hasattr(FreeCAD,"DraftWorkingPlane"):
|
||||
if not FreeCAD.DraftWorkingPlane.isGlobal():
|
||||
self.labelx.setText(translate("draft", "Local X"))
|
||||
self.labely.setText(translate("draft", "Local Y"))
|
||||
self.labelz.setText(translate("draft", "Local Z"))
|
||||
|
||||
def setEditButtons(self,mode):
|
||||
self.addButton.setEnabled(mode)
|
||||
|
@ -1191,6 +1207,8 @@ class DraftToolBar:
|
|||
dp = plane.getLocalRot(FreeCAD.Vector(point.x-last.x, point.y-last.y, point.z-last.z))
|
||||
else:
|
||||
dp = FreeCAD.Vector(point.x-last.x, point.y-last.y, point.z-last.z)
|
||||
elif plane:
|
||||
dp = plane.getLocalCoords(point)
|
||||
|
||||
# set widgets
|
||||
if self.mask in ['y','z']:
|
||||
|
|
|
@ -507,6 +507,7 @@ class Line(Creator):
|
|||
if (not self.node) and (not self.support):
|
||||
self.support = getSupport(arg)
|
||||
if self.point:
|
||||
self.ui.redraw()
|
||||
self.pos = arg["Position"]
|
||||
self.node.append(self.point)
|
||||
self.drawSegment(self.point)
|
||||
|
@ -620,6 +621,7 @@ class BSpline(Line):
|
|||
if (not self.node) and (not self.support):
|
||||
self.support = getSupport(arg)
|
||||
if self.point:
|
||||
self.ui.redraw()
|
||||
self.pos = arg["Position"]
|
||||
self.node.append(self.point)
|
||||
self.drawUpdate(self.point)
|
||||
|
@ -827,6 +829,7 @@ class Rectangle(Creator):
|
|||
if (not self.node) and (not self.support):
|
||||
self.support = getSupport(arg)
|
||||
if self.point:
|
||||
self.ui.redraw()
|
||||
self.appendPoint(self.point)
|
||||
|
||||
def numericInput(self,numx,numy,numz):
|
||||
|
@ -1419,6 +1422,7 @@ class Ellipse(Creator):
|
|||
if (not self.node) and (not self.support):
|
||||
self.support = getSupport(arg)
|
||||
if self.point:
|
||||
self.ui.redraw()
|
||||
self.appendPoint(self.point)
|
||||
|
||||
def numericInput(self,numx,numy,numz):
|
||||
|
@ -1703,6 +1707,7 @@ class Dimension(Creator):
|
|||
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
|
||||
import DraftGeomUtils
|
||||
if self.point:
|
||||
self.ui.redraw()
|
||||
if (not self.node) and (not self.support):
|
||||
self.support = getSupport(arg)
|
||||
if hasMod(arg,MODALT) and (len(self.node)<3):
|
||||
|
@ -2001,6 +2006,7 @@ class Move(Modifier):
|
|||
elif arg["Type"] == "SoMouseButtonEvent":
|
||||
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
|
||||
if self.point:
|
||||
self.ui.redraw()
|
||||
if (self.node == []):
|
||||
self.node.append(self.point)
|
||||
self.ui.isRelative.show()
|
||||
|
@ -2713,7 +2719,7 @@ class Trimex(Modifier):
|
|||
ghost.setRadius(edge.Curve.Radius)
|
||||
if real: newedges.append(edge)
|
||||
ghost.on()
|
||||
|
||||
|
||||
# finishing
|
||||
if real: return newedges
|
||||
else: return dist
|
||||
|
@ -2751,7 +2757,7 @@ class Trimex(Modifier):
|
|||
self.doc.commitTransaction()
|
||||
for g in self.ghost: g.off()
|
||||
|
||||
def finish(self,closed=False):
|
||||
def finish(self,closed=False):
|
||||
Modifier.finish(self)
|
||||
self.force = None
|
||||
if self.ui:
|
||||
|
@ -2855,6 +2861,7 @@ class Scale(Modifier):
|
|||
elif arg["Type"] == "SoMouseButtonEvent":
|
||||
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
|
||||
if self.point:
|
||||
self.ui.redraw()
|
||||
if (self.node == []):
|
||||
self.node.append(self.point)
|
||||
self.ui.isRelative.show()
|
||||
|
@ -3115,6 +3122,7 @@ class Edit(Modifier):
|
|||
self.update(self.trackers[self.editing].get())
|
||||
elif arg["Type"] == "SoMouseButtonEvent":
|
||||
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
|
||||
self.ui.redraw()
|
||||
if self.editing == None:
|
||||
sel = FreeCADGui.Selection.getSelectionEx()
|
||||
if sel:
|
||||
|
|
|
@ -298,6 +298,16 @@ class plane:
|
|||
return "z"
|
||||
else:
|
||||
return None
|
||||
|
||||
def isGlobal(self):
|
||||
"returns True if the plane axes are equal to the global axes"
|
||||
if self.u != Vector(1,0,0):
|
||||
return False
|
||||
if self.v != Vector(0,1,0):
|
||||
return False
|
||||
if self.axis != Vector(0,0,1):
|
||||
return False
|
||||
return True
|
||||
|
||||
def getPlacementFromPoints(points):
|
||||
"returns a placement from a list of 3 or 4 vectors"
|
||||
|
|
Loading…
Reference in New Issue
Block a user