Arch: Fixed Space Area errors and added boundaries edition in task panel - fixes #3112
This commit is contained in:
@@ -272,17 +272,10 @@ class _Space(ArchComponent.Component):
|
||||
|
||||
if self.clone(obj):
|
||||
return
|
||||
|
||||
self.getShape(obj)
|
||||
|
||||
def onChanged(self,obj,prop):
|
||||
if prop in ["Boundaries","Base"]:
|
||||
self.getShape(obj)
|
||||
if hasattr(obj.Area,"Value"):
|
||||
a = self.getArea(obj)
|
||||
if obj.Area.Value != a:
|
||||
obj.Area = a
|
||||
elif prop == "Group":
|
||||
if prop == "Group":
|
||||
if hasattr(obj,"EquipmentPower"):
|
||||
if obj.AutoPower:
|
||||
p = 0
|
||||
@@ -347,10 +340,11 @@ class _Space(ArchComponent.Component):
|
||||
goodfaces = []
|
||||
for b in obj.Boundaries:
|
||||
if b[0].isDerivedFrom("Part::Feature"):
|
||||
if "Face" in b[1]:
|
||||
fn = int(b[1][4:])-1
|
||||
faces.append(b[0].Shape.Faces[fn])
|
||||
#print("adding face ",fn," of object ",b[0].Name)
|
||||
for sub in b[1]:
|
||||
if "Face" in sub:
|
||||
fn = int(sub[4:])-1
|
||||
faces.append(b[0].Shape.Faces[fn])
|
||||
#print("adding face ",fn," of object ",b[0].Name)
|
||||
|
||||
#print("total: ", len(faces), " faces")
|
||||
|
||||
@@ -376,6 +370,10 @@ class _Space(ArchComponent.Component):
|
||||
obj.Shape = shape
|
||||
pl = pl.multiply(obj.Placement)
|
||||
obj.Placement = pl
|
||||
if hasattr(obj.Area,"Value"):
|
||||
a = self.getArea(obj)
|
||||
if obj.Area.Value != a:
|
||||
obj.Area = a
|
||||
return
|
||||
|
||||
print("Arch: error computing space boundary")
|
||||
@@ -408,6 +406,7 @@ class _Space(ArchComponent.Component):
|
||||
a += f.Area
|
||||
if a != obj.VerticalArea.Value:
|
||||
obj.VerticalArea = a
|
||||
#print "area of ",obj.Label," : ",f.Area
|
||||
return f.Area
|
||||
|
||||
|
||||
@@ -477,7 +476,7 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
|
||||
self.onChanged(vobj,"FontName")
|
||||
|
||||
def updateData(self,obj,prop):
|
||||
if prop in ["Shape","Label","Tag"]:
|
||||
if prop in ["Shape","Label","Tag","Area"]:
|
||||
self.onChanged(obj.ViewObject,"Text")
|
||||
self.onChanged(obj.ViewObject,"TextPosition")
|
||||
|
||||
@@ -595,6 +594,7 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
|
||||
taskd = SpaceTaskPanel()
|
||||
taskd.obj = self.Object
|
||||
taskd.update()
|
||||
taskd.updateBoundaries()
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
@@ -610,10 +610,56 @@ class SpaceTaskPanel(ArchComponent.ComponentTaskPanel):
|
||||
self.grid.addWidget(self.editButton, 4, 0, 1, 2)
|
||||
self.editButton.setText(QtGui.QApplication.translate("Arch", "Set text position", None))
|
||||
QtCore.QObject.connect(self.editButton, QtCore.SIGNAL("clicked()"), self.setTextPos)
|
||||
boundLabel = QtGui.QLabel(self.form)
|
||||
self.grid.addWidget(boundLabel, 5, 0, 1, 2)
|
||||
boundLabel.setText(QtGui.QApplication.translate("Arch", "Space boundaries", None))
|
||||
self.boundList = QtGui.QListWidget(self.form)
|
||||
self.grid.addWidget(self.boundList, 6, 0, 1, 2)
|
||||
self.addCompButton = QtGui.QPushButton(self.form)
|
||||
self.addCompButton.setObjectName("addCompButton")
|
||||
self.addCompButton.setIcon(QtGui.QIcon(":/icons/Arch_Add.svg"))
|
||||
self.grid.addWidget(self.addCompButton, 7, 0, 1, 1)
|
||||
self.addCompButton.setText(QtGui.QApplication.translate("Arch", "Add", None))
|
||||
QtCore.QObject.connect(self.addCompButton, QtCore.SIGNAL("clicked()"), self.addBoundary)
|
||||
self.delCompButton = QtGui.QPushButton(self.form)
|
||||
self.delCompButton.setObjectName("delCompButton")
|
||||
self.delCompButton.setIcon(QtGui.QIcon(":/icons/Arch_Remove.svg"))
|
||||
self.grid.addWidget(self.delCompButton, 7, 1, 1, 1)
|
||||
self.delCompButton.setText(QtGui.QApplication.translate("Arch", "Remove", None))
|
||||
QtCore.QObject.connect(self.delCompButton, QtCore.SIGNAL("clicked()"), self.delBoundary)
|
||||
|
||||
def updateBoundaries(self):
|
||||
self.boundList.clear()
|
||||
if self.obj:
|
||||
for b in self.obj.Boundaries:
|
||||
s = b[0].Label
|
||||
for n in b[1]:
|
||||
s += ", " + n
|
||||
it = QtGui.QListWidgetItem(s)
|
||||
it.setToolTip(b[0].Name)
|
||||
self.boundList.addItem(it)
|
||||
|
||||
def setTextPos(self):
|
||||
FreeCADGui.runCommand("Draft_Edit")
|
||||
|
||||
def addBoundary(self):
|
||||
if self.obj:
|
||||
if FreeCADGui.Selection.getSelectionEx():
|
||||
self.obj.Proxy.addSubobjects(self.obj,FreeCADGui.Selection.getSelectionEx())
|
||||
self.updateBoundaries()
|
||||
|
||||
def delBoundary(self):
|
||||
if self.boundList.currentRow() >= 0:
|
||||
it = self.boundList.item(self.boundList.currentRow())
|
||||
if it and self.obj:
|
||||
on = it.toolTip()
|
||||
bounds = self.obj.Boundaries
|
||||
for b in bounds:
|
||||
if b[0].Name == on:
|
||||
bounds.remove(b)
|
||||
break
|
||||
self.obj.Boundaries = bounds
|
||||
self.updateBoundaries()
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
FreeCADGui.addCommand('Arch_Space',_CommandSpace())
|
||||
|
||||
Reference in New Issue
Block a user