Arch: Wall and Struct tools now set the working plane before drawing

This commit is contained in:
Yorik van Havre 2013-07-18 16:26:00 -03:00
parent 08f031d6ca
commit f43fcd1fb5
4 changed files with 17 additions and 8 deletions

View File

@ -94,6 +94,8 @@ class _CommandStructure:
FreeCAD.ActiveDocument.recompute()
else:
# interactive mode
if hasattr(FreeCAD,"DraftWorkingPlane"):
FreeCAD.DraftWorkingPlane.setup()
import DraftTrackers
self.points = []
self.tracker = DraftTrackers.boxTracker()

View File

@ -157,6 +157,8 @@ class _CommandWall:
import DraftTrackers
self.points = []
self.tracker = DraftTrackers.boxTracker()
if hasattr(FreeCAD,"DraftWorkingPlane"):
FreeCAD.DraftWorkingPlane.setup()
FreeCADGui.Snapper.getPoint(callback=self.getPoint,extradlg=self.taskbox())
def getPoint(self,point=None,obj=None):

View File

@ -232,12 +232,7 @@ class DraftTool:
self.ui.sourceCmd = self
self.ui.setTitle(name)
self.ui.show()
try:
rot = self.view.getCameraNode().getField("orientation").getValue()
upv = Vector(rot.multVec(coin.SbVec3f(0,1,0)).getValue())
plane.setup(DraftVecUtils.neg(self.view.getViewDirection()), Vector(0,0,0), upv)
except:
pass
plane.setup()
self.node = []
self.pos = []
self.constrain = None

View File

@ -187,10 +187,20 @@ class plane:
# len(sex) > 2, look for point and line, three points, etc.
return False
def setup(self, direction, point, upvec=None):
def setup(self, direction=None, point=None, upvec=None):
'''If working plane is undefined, define it!'''
if self.weak:
self.alignToPointAndAxis(point, direction, 0, upvec)
if direction and point:
self.alignToPointAndAxis(point, direction, 0, upvec)
else:
try:
from pivy import coin
rot = FreeCADGui.ActiveDocument.ActiveView.getCameraNode().getField("orientation").getValue()
upvec = Vector(rot.multVec(coin.SbVec3f(0,1,0)).getValue())
vdir = FreeCADGui.ActiveDocument.ActiveView.getViewDirection()
self.alignToPointAndAxis(Vector(0,0,0), DraftVecUtils.neg(vdir), upvec)
except:
print "Draft: Unable to align the working plane to the current view"
self.weak = True
def reset(self):