Arch: misc improvements

+ Further work on snap tracking dims
+ Better snap for structures
+ Corrected initial temp shape of structures
+ Added a box with wall length (still readonly)
This commit is contained in:
Yorik van Havre 2013-06-16 20:06:14 -03:00
parent a63e18f170
commit d26ffbe9aa
4 changed files with 43 additions and 4 deletions

View File

@ -97,6 +97,9 @@ class _CommandStructure:
import DraftTrackers
self.points = []
self.tracker = DraftTrackers.boxTracker()
self.tracker.width(self.Width)
self.tracker.height(self.Height)
self.tracker.length(self.Length)
self.tracker.on()
FreeCADGui.Snapper.getPoint(callback=self.getPoint,movecallback=self.update,extradlg=self.taskbox())

View File

@ -136,6 +136,7 @@ class _CommandWall:
self.Width = 0.1
self.Height = 1
self.Align = "Center"
self.Length = None
self.continueCmd = False
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
self.JOIN_WALLS = p.GetBool("joinWallSketches")
@ -223,12 +224,24 @@ class _CommandWall:
else:
dv = DraftVecUtils.neg(dv)
self.tracker.update([b.add(dv),point.add(dv)])
if self.Length:
self.Length.setValue(bv.Length)
def taskbox(self):
"sets up a taskbox widget"
w = QtGui.QWidget()
w.setWindowTitle(str(translate("Arch","Wall options")))
lay0 = QtGui.QVBoxLayout(w)
lay5 = QtGui.QHBoxLayout()
lay0.addLayout(lay5)
label5 = QtGui.QLabel(str(translate("Arch","Length")))
lay5.addWidget(label5)
self.Length = QtGui.QDoubleSpinBox()
self.Length.setDecimals(2)
self.Length.setValue(0.00)
lay5.addWidget(self.Length)
lay1 = QtGui.QHBoxLayout()
lay0.addLayout(lay1)
label1 = QtGui.QLabel(str(translate("Arch","Width")))
@ -237,6 +250,7 @@ class _CommandWall:
value1.setDecimals(2)
value1.setValue(self.Width)
lay1.addWidget(value1)
lay2 = QtGui.QHBoxLayout()
lay0.addLayout(lay2)
label2 = QtGui.QLabel(str(translate("Arch","Height")))
@ -245,6 +259,7 @@ class _CommandWall:
value2.setDecimals(2)
value2.setValue(self.Height)
lay2.addWidget(value2)
lay3 = QtGui.QHBoxLayout()
lay0.addLayout(lay3)
label3 = QtGui.QLabel(str(translate("Arch","Alignment")))
@ -254,6 +269,7 @@ class _CommandWall:
value3.addItems(items)
value3.setCurrentIndex(items.index(self.Align))
lay3.addWidget(value3)
value4 = QtGui.QCheckBox(str(translate("Arch","Continue")))
lay0.addWidget(value4)
QtCore.QObject.connect(value1,QtCore.SIGNAL("valueChanged(double)"),self.setWidth)

View File

@ -242,6 +242,7 @@ class Snapper:
comp = self.snapInfo['Component']
if (Draft.getType(obj) == "Wall") and not oldActive:
# special snapping for wall: only to its base shape (except when CTRL is pressed)
edges = []
for o in [obj]+obj.Additions:
if Draft.getType(o) == "Wall":
@ -253,6 +254,19 @@ class Snapper:
snaps.extend(self.snapToPerpendicular(edge,lastpoint))
snaps.extend(self.snapToIntersection(edge))
snaps.extend(self.snapToElines(edge,eline))
elif (Draft.getType(obj) == "Structure") and not oldActive:
# special snapping for struct: only to its base point (except when CTRL is pressed)
if obj.Base:
for edge in o.Base.Shape.Edges:
snaps.extend(self.snapToEndpoints(edge))
snaps.extend(self.snapToMidpoint(edge))
snaps.extend(self.snapToPerpendicular(edge,lastpoint))
snaps.extend(self.snapToIntersection(edge))
snaps.extend(self.snapToElines(edge,eline))
else:
b = obj.Placement.Base
snaps.append([b,'endpoint',b])
elif obj.isDerivedFrom("Part::Feature"):
if (not self.maxEdges) or (len(obj.Edges) <= self.maxEdges):
@ -341,9 +355,8 @@ class Snapper:
# set the arch point tracking
if self.lastArchPoint:
self.setArchDims(self.lastArchPoint,fp)
if Draft.getType(obj) == "Wall":
if self.lastArchPoint != fp:
self.lastArchPoint = fp
if Draft.getType(obj) in ["Wall","Structure"]:
self.lastArchPoint = winner[2]
else:
self.lastArchPoint = None
@ -734,6 +747,7 @@ class Snapper:
if Draft.getParam("hideSnapBar"):
self.toolbar.hide()
self.mask = None
self.lastArchPoint = None
def constrain(self,point,basepoint=None,axis=None):
'''constrain(point,basepoint=None,axis=None: Returns a

View File

@ -805,7 +805,13 @@ class archDimTracker(Tracker):
self.dimnode.param1.setValue(.5)
p1 = Vector(self.dimnode.pnts.getValues()[0].getValue())
p2 = Vector(self.dimnode.pnts.getValues()[-1].getValue())
self.Distance = p2.sub(p1).Length
m = self.dimnode.datumtype.getValue()
if m == 2:
self.Distance = (DraftVecUtils.project(p2.sub(p1),Vector(1,0,0))).Length
elif m == 3:
self.Distance = (DraftVecUtils.project(p2.sub(p1),Vector(0,1,0))).Length
else:
self.Distance = (p2.sub(p1)).Length
if not text:
text = Draft.getParam("dimPrecision")
text = "%."+str(text)+"f"