Arch: Added Hires property + display mode to all Arch objects
This commit is contained in:
parent
84ac526f62
commit
5625bab170
|
@ -323,6 +323,7 @@ class Component:
|
|||
obj.addProperty("App::PropertyArea","VerticalArea","Arch",QT_TRANSLATE_NOOP("App::Property","The area of all vertical faces of this object"))
|
||||
obj.addProperty("App::PropertyArea","HorizontalArea","Arch",QT_TRANSLATE_NOOP("App::Property","The area of the projection of this object onto the XY plane"))
|
||||
obj.addProperty("App::PropertyLength","PerimeterLength","Arch",QT_TRANSLATE_NOOP("App::Property","The perimeter length of the horizontal area"))
|
||||
obj.addProperty("App::PropertyLink","Hires","Arch",QT_TRANSLATE_NOOP("App::Property","An optional higher-resolution mesh or shape for this object"))
|
||||
obj.Proxy = self
|
||||
self.Type = "Component"
|
||||
self.Subvolume = None
|
||||
|
@ -720,13 +721,58 @@ class ViewProviderComponent:
|
|||
return
|
||||
|
||||
def attach(self,vobj):
|
||||
from pivy import coin
|
||||
self.Object = vobj.Object
|
||||
self.hiresgroup = coin.SoSeparator()
|
||||
self.meshcolor = coin.SoBaseColor()
|
||||
self.hiresgroup.addChild(self.meshcolor)
|
||||
self.hiresgroup.setName("Hires")
|
||||
vobj.addDisplayMode(self.hiresgroup,"Hires");
|
||||
return
|
||||
|
||||
def getDisplayModes(self,vobj):
|
||||
return []
|
||||
modes=["Hires"]
|
||||
return modes
|
||||
|
||||
def setDisplayMode(self,mode):
|
||||
if hasattr(self,"meshnode"):
|
||||
if self.meshnode:
|
||||
self.hiresgroup.removeChild(self.meshnode)
|
||||
del self.meshnode
|
||||
if mode == "Hires":
|
||||
from pivy import coin
|
||||
m = None
|
||||
if hasattr(self,"Object"):
|
||||
if hasattr(self.Object,"Hires"):
|
||||
if self.Object.Hires:
|
||||
# if the file was recently loaded, the node is not present yet
|
||||
self.Object.Hires.ViewObject.show()
|
||||
self.Object.Hires.ViewObject.hide()
|
||||
m = self.Object.Hires.ViewObject.RootNode
|
||||
if not m:
|
||||
if hasattr(self.Object,"CloneOf"):
|
||||
if self.Object.CloneOf:
|
||||
if hasattr(self.Object.CloneOf,"Hires"):
|
||||
if self.Object.CloneOf.Hires:
|
||||
# if the file was recently loaded, the node is not present yet
|
||||
self.Object.CloneOf.Hires.ViewObject.show()
|
||||
self.Object.CloneOf.Hires.ViewObject.hide()
|
||||
m = self.Object.CloneOf.Hires.ViewObject.RootNode
|
||||
if m:
|
||||
self.meshnode = m.copy()
|
||||
for c in self.meshnode.getChildren():
|
||||
# switch the first found SoSwitch on
|
||||
if isinstance(c,coin.SoSwitch):
|
||||
num = 0
|
||||
if c.getNumChildren() > 0:
|
||||
if c.getChild(0).getName() == "Hires":
|
||||
num = 1
|
||||
print "getting node ",num," for ",self.Object.Label
|
||||
c.whichChild = num
|
||||
break
|
||||
self.hiresgroup.addChild(self.meshnode)
|
||||
else:
|
||||
return "Flat Lines"
|
||||
return mode
|
||||
|
||||
def __getstate__(self):
|
||||
|
|
|
@ -264,7 +264,6 @@ class _Equipment(ArchComponent.Component):
|
|||
obj.addProperty("App::PropertyString","Url","Arch",QT_TRANSLATE_NOOP("App::Property","The url of the product page of this equipment"))
|
||||
obj.addProperty("App::PropertyVectorList","SnapPoints","Arch",QT_TRANSLATE_NOOP("App::Property","Additional snap points for this equipment"))
|
||||
obj.addProperty("App::PropertyFloat","EquipmentPower","Arch",QT_TRANSLATE_NOOP("App::Property","The electric power needed by this equipment in Watts"))
|
||||
obj.addProperty("App::PropertyLink","Hires","Arch",QT_TRANSLATE_NOOP("App::Property","An optional higher-resolution mesh or shape for this object"))
|
||||
self.Type = "Equipment"
|
||||
obj.Role = Roles
|
||||
obj.Proxy = self
|
||||
|
@ -319,10 +318,6 @@ class _ViewProviderEquipment(ArchComponent.ViewProviderComponent):
|
|||
sep.addChild(symbol)
|
||||
rn = vobj.RootNode
|
||||
rn.addChild(sep)
|
||||
self.hiresgroup = coin.SoGroup()
|
||||
self.meshcolor = coin.SoBaseColor()
|
||||
self.hiresgroup.addChild(self.meshcolor)
|
||||
vobj.addDisplayMode(self.hiresgroup,"Hires");
|
||||
ArchComponent.ViewProviderComponent.attach(self,vobj)
|
||||
|
||||
def updateData(self, obj, prop):
|
||||
|
@ -333,34 +328,6 @@ class _ViewProviderEquipment(ArchComponent.ViewProviderComponent):
|
|||
else:
|
||||
self.coords.point.deleteValues(0)
|
||||
|
||||
def getDisplayModes(self,vobj):
|
||||
modes=["Hires"]
|
||||
return modes
|
||||
|
||||
def setDisplayMode(self,mode):
|
||||
if mode == "Hires":
|
||||
m = None
|
||||
if hasattr(self,"Object"):
|
||||
if hasattr(self.Object,"Hires"):
|
||||
if self.Object.Hires:
|
||||
m = self.Object.Hires.ViewObject.RootNode
|
||||
if not m:
|
||||
if hasattr(self.Object,"CloneOf"):
|
||||
if self.Object.CloneOf:
|
||||
if hasattr(self.Object.CloneOf,"Hires"):
|
||||
if self.Object.CloneOf.Hires:
|
||||
m = self.Object.CloneOf.Hires.ViewObject.RootNode
|
||||
if m:
|
||||
self.meshnode = m.copy()
|
||||
self.meshnode.getChild(1).whichChild = 0
|
||||
self.hiresgroup.addChild(self.meshnode)
|
||||
else:
|
||||
if hasattr(self,"meshnode"):
|
||||
if self.meshnode:
|
||||
self.hiresgroup.removeChild(self.meshnode)
|
||||
del self.meshnode
|
||||
return mode
|
||||
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
FreeCADGui.addCommand('Arch_Equipment',_CommandEquipment())
|
||||
|
|
|
@ -644,18 +644,21 @@ class _ViewProviderWall(ArchComponent.ViewProviderComponent):
|
|||
sep.addChild(self.fcoords)
|
||||
sep.addChild(self.fset)
|
||||
vobj.RootNode.addChild(sep)
|
||||
return
|
||||
ArchComponent.ViewProviderComponent.attach(self,vobj)
|
||||
|
||||
def updateData(self,obj,prop):
|
||||
if prop in ["Placement","Shape"]:
|
||||
if obj.ViewObject.DisplayMode == "Footprint":
|
||||
obj.ViewObject.Proxy.setDisplayMode("Footprint")
|
||||
ArchComponent.ViewProviderComponent.updateData(self,obj,prop)
|
||||
|
||||
def getDisplayModes(self,vobj):
|
||||
modes=["Footprint"]
|
||||
modes = ArchComponent.ViewProviderComponent.getDisplayModes(self,vobj)+["Footprint"]
|
||||
return modes
|
||||
|
||||
def setDisplayMode(self,mode):
|
||||
self.fset.coordIndex.deleteValues(0)
|
||||
self.fcoords.point.deleteValues(0)
|
||||
if mode == "Footprint":
|
||||
if hasattr(self,"Object"):
|
||||
faces = self.Object.Proxy.getFootprint(self.Object)
|
||||
|
@ -673,10 +676,7 @@ class _ViewProviderWall(ArchComponent.ViewProviderComponent):
|
|||
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
|
||||
return ArchComponent.ViewProviderComponent.setDisplayMode(self,mode)
|
||||
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
|
|
Loading…
Reference in New Issue
Block a user