Arch: Added new Footprint display mode to walls
This commit is contained in:
parent
4bb97c71ea
commit
1efd9a4b4f
|
@ -505,6 +505,15 @@ class _Wall(ArchComponent.Component):
|
||||||
def onChanged(self,obj,prop):
|
def onChanged(self,obj,prop):
|
||||||
self.hideSubobjects(obj,prop)
|
self.hideSubobjects(obj,prop)
|
||||||
ArchComponent.Component.onChanged(self,obj,prop)
|
ArchComponent.Component.onChanged(self,obj,prop)
|
||||||
|
|
||||||
|
def getFootprint(self,obj):
|
||||||
|
faces = []
|
||||||
|
if obj.Shape:
|
||||||
|
for f in obj.Shape.Faces:
|
||||||
|
if f.normalAt(0,0).getAngle(FreeCAD.Vector(0,0,-1)) < 0.01:
|
||||||
|
if abs(abs(f.CenterOfMass.z) - abs(obj.Shape.BoundBox.ZMin)) < 0.001:
|
||||||
|
faces.append(f)
|
||||||
|
return faces
|
||||||
|
|
||||||
|
|
||||||
class _ViewProviderWall(ArchComponent.ViewProviderComponent):
|
class _ViewProviderWall(ArchComponent.ViewProviderComponent):
|
||||||
|
@ -524,8 +533,56 @@ class _ViewProviderWall(ArchComponent.ViewProviderComponent):
|
||||||
|
|
||||||
def attach(self,vobj):
|
def attach(self,vobj):
|
||||||
self.Object = vobj.Object
|
self.Object = vobj.Object
|
||||||
|
from pivy import coin
|
||||||
|
tex = coin.SoTexture2()
|
||||||
|
tex.image = Draft.loadTexture(Draft.svgpatterns()['simple'][1], 128)
|
||||||
|
texcoords = coin.SoTextureCoordinatePlane()
|
||||||
|
s = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetFloat("PatternScale",0.01)
|
||||||
|
texcoords.directionS.setValue(s,0,0)
|
||||||
|
texcoords.directionT.setValue(0,s,0)
|
||||||
|
self.fcoords = coin.SoCoordinate3()
|
||||||
|
self.fset = coin.SoIndexedFaceSet()
|
||||||
|
sep = coin.SoSeparator()
|
||||||
|
sep.addChild(tex)
|
||||||
|
sep.addChild(texcoords)
|
||||||
|
sep.addChild(self.fcoords)
|
||||||
|
sep.addChild(self.fset)
|
||||||
|
vobj.RootNode.addChild(sep)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def updateData(self,obj,prop):
|
||||||
|
if prop in ["Placement","Shape"]:
|
||||||
|
if obj.ViewObject.DisplayMode == "Footprint":
|
||||||
|
obj.ViewObject.Proxy.setDisplayMode("Footprint")
|
||||||
|
|
||||||
|
def getDisplayModes(self,vobj):
|
||||||
|
modes=["Footprint"]
|
||||||
|
return modes
|
||||||
|
|
||||||
|
def setDisplayMode(self,mode):
|
||||||
|
if mode == "Footprint":
|
||||||
|
if hasattr(self,"Object"):
|
||||||
|
faces = self.Object.Proxy.getFootprint(self.Object)
|
||||||
|
if faces:
|
||||||
|
verts = []
|
||||||
|
fdata = []
|
||||||
|
idx = 0
|
||||||
|
for face in faces:
|
||||||
|
tri = face.tessellate(1)
|
||||||
|
for v in tri[0]:
|
||||||
|
verts.append([v.x,v.y,v.z])
|
||||||
|
for f in tri[1]:
|
||||||
|
fdata.extend([f[0]+idx,f[1]+idx,f[2]+idx,-1])
|
||||||
|
idx += len(tri[0])
|
||||||
|
self.fcoords.point.setValues(verts)
|
||||||
|
self.fset.coordIndex.setValues(0,len(fdata),fdata)
|
||||||
|
return "Wireframe"
|
||||||
|
else:
|
||||||
|
self.fset.coordIndex.deleteValues(0)
|
||||||
|
self.fcoords.point.deleteValues(0)
|
||||||
|
return mode
|
||||||
|
|
||||||
|
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
FreeCADGui.addCommand('Arch_Wall',_CommandWall())
|
FreeCADGui.addCommand('Arch_Wall',_CommandWall())
|
||||||
FreeCADGui.addCommand('Arch_MergeWalls',_CommandMergeWalls())
|
FreeCADGui.addCommand('Arch_MergeWalls',_CommandMergeWalls())
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>396</width>
|
<width>396</width>
|
||||||
<height>638</height>
|
<height>694</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -425,6 +425,68 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_15">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_5">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Preferred</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Pattern scale</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_6">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Gui::PrefDoubleSpinBox" name="doubleSpinBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Scaling factor for patterns used by object that have a Footprint display mode</string>
|
||||||
|
</property>
|
||||||
|
<property name="decimals">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>9999.989999999999782</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>0.010000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="prefEntry" stdset="0">
|
||||||
|
<cstring>patternScale</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="prefPath" stdset="0">
|
||||||
|
<cstring>Mod/Arch</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user