Arch: Added Centerline display mode to rebars
This commit is contained in:
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user