From 8ceafabb02abda4b27072530b9378b31afcc8473 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 24 Jul 2017 17:53:59 -0300 Subject: [PATCH 1/3] Arch: Fixed Space Area errors and added boundaries edition in task panel - fixes #3112 --- src/Mod/Arch/ArchSpace.py | 72 ++++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 13 deletions(-) diff --git a/src/Mod/Arch/ArchSpace.py b/src/Mod/Arch/ArchSpace.py index dd69c75571..dc0dc7b596 100644 --- a/src/Mod/Arch/ArchSpace.py +++ b/src/Mod/Arch/ArchSpace.py @@ -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()) From 6f38b5999c3a62c2f4dc8220e6abfa24b7471eed Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 24 Jul 2017 17:54:21 -0300 Subject: [PATCH 2/3] Arch: Added Centerline display mode to rebars --- src/Mod/Arch/ArchRebar.py | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/Mod/Arch/ArchRebar.py b/src/Mod/Arch/ArchRebar.py index 34395dbf4b..d3c6be5697 100644 --- a/src/Mod/Arch/ArchRebar.py +++ b/src/Mod/Arch/ArchRebar.py @@ -404,6 +404,63 @@ class _ViewProviderRebar(ArchComponent.ViewProviderComponent): return module.editDialog(vobj) + def updateData(self,obj,prop): + if prop == "Shape": + if hasattr(self,"centerline"): + if self.centerline: + self.centerlinegroup.removeChild(self.centerline) + if hasattr(obj.Proxy,"wires"): + if obj.Proxy.wires: + from pivy import coin + import re,Part + self.centerline = coin.SoSeparator() + comp = Part.makeCompound(obj.Proxy.wires) + pts = re.findall("point \[(.*?)\]",comp.writeInventor().replace("\n","")) + pts = [p.split(",") for p in pts] + for pt in pts: + ps = coin.SoSeparator() + plist = [] + for p in pt: + c = [] + for pstr in p.split(" "): + if pstr: + c.append(float(pstr)) + plist.append(c) + coords = coin.SoCoordinate3() + coords.point.setValues(plist) + ps.addChild(coords) + ls = coin.SoLineSet() + ls.numVertices = -1 + ps.addChild(ls) + self.centerline.addChild(ps) + self.centerlinegroup.addChild(self.centerline) + ArchComponent.ViewProviderComponent.updateData(self,obj,prop) + + def attach(self,vobj): + from pivy import coin + self.centerlinegroup = coin.SoSeparator() + self.centerlinegroup.setName("Centerline") + self.centerlinecolor = coin.SoBaseColor() + self.centerlinestyle = coin.SoDrawStyle() + self.centerlinegroup.addChild(self.centerlinecolor) + self.centerlinegroup.addChild(self.centerlinestyle) + vobj.addDisplayMode(self.centerlinegroup,"Centerline") + ArchComponent.ViewProviderComponent.attach(self,vobj) + + def onChanged(self,vobj,prop): + if (prop == "LineColor") and hasattr(vobj,"LineColor"): + if hasattr(self,"centerlinecolor"): + c = vobj.LineColor + self.centerlinecolor.rgb.setValue(c[0],c[1],c[2]) + elif (prop == "LineWidth") and hasattr(vobj,"LineWidth"): + if hasattr(self,"centerlinestyle"): + self.centerlinestyle.lineWidth = vobj.LineWidth + ArchComponent.ViewProviderComponent.onChanged(self,vobj,prop) + + def getDisplayModes(self,vobj): + modes=["Centerline"] + return modes+ArchComponent.ViewProviderComponent.getDisplayModes(self,vobj) + def CalculatePlacement(baramount, barnumber, size, axis, rotation, offsetstart, offsetend): """ CalculatePlacement([baramount, barnumber, size, axis, rotation, offsetstart, offsetend]): Calculate the placement of the bar from given values.""" From bcda03b1dabf1f448cadc5386b9c8037a1ac256f Mon Sep 17 00:00:00 2001 From: luzpaz Date: Mon, 24 Jul 2017 14:47:59 -0400 Subject: [PATCH 3/3] Sketcher: typo fix --- src/Mod/Sketcher/Gui/CommandConstraints.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index e1d750b2e5..9270f61a9a 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -6826,7 +6826,7 @@ void CmdSketcherToggleDrivingConstraint::activated(int iMsg) // undo command open openCommand("Toggle driving from/to non-driving"); - int succesful=SubNames.size(); + int successful=SubNames.size(); // go through the selected subelements for (std::vector::const_iterator it=SubNames.begin();it!=SubNames.end();++it){ // only handle constraints @@ -6837,12 +6837,12 @@ void CmdSketcherToggleDrivingConstraint::activated(int iMsg) doCommand(Doc,"App.ActiveDocument.%s.toggleDriving(%d) ",selection[0].getFeatName(),ConstrId); } catch(const Base::Exception&) { - succesful--; + successful--; } } } - if (succesful > 0) + if (successful > 0) commitCommand(); else abortCommand();