Arch: Allow the hi-res version of Equipment objects to be a shape too

This commit is contained in:
Yorik van Havre 2017-02-10 12:41:41 -02:00
parent 819b3e8e96
commit e1110bbec9
2 changed files with 11 additions and 19 deletions

View File

@ -764,7 +764,7 @@ class ViewProviderComponent:
if hasattr(self.Object,link):
objlink = getattr(self.Object,link)
c.extend(objlink)
for link in ["Tool","Subvolume","Mesh"]:
for link in ["Tool","Subvolume","Mesh","Hires"]:
if hasattr(self.Object,link):
objlink = getattr(self.Object,link)
if objlink:

View File

@ -264,23 +264,15 @@ 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","Mesh","Arch",QT_TRANSLATE_NOOP("App::Property","An optional higher-resolution mesh representation for this object"))
#obj.addProperty("App::PropertyPlacement","MeshDelta","Arch",QT_TRANSLATE_NOOP("App::Property","Stores the delta between the object placement and the mesh placement"))
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
obj.setEditorMode("VerticalArea",2)
obj.setEditorMode("HorizontalArea",2)
obj.setEditorMode("PerimeterLength",2)
#obj.setEditorMode("MeshDelta",2)
def onChanged(self,obj,prop):
#if prop == "Mesh":
# if obj.Mesh:
# delta = FreeCAD.Placement()
# delta.Base = obj.Mesh.Placement.Base.sub(obj.Placement.Base)
# delta.Rotation = FreeCAD.Rotation(obj.Placement.Rotation.multVec(FreeCAD.Vector(0,0,1)),obj.Mesh.Placement.Rotation.multVec(FreeCAD.Vector(0,0,1)))
# obj.MeshDelta = delta
self.hideSubobjects(obj,prop)
ArchComponent.Component.onChanged(self,obj,prop)
@ -330,7 +322,7 @@ class _ViewProviderEquipment(ArchComponent.ViewProviderComponent):
self.hiresgroup = coin.SoGroup()
self.meshcolor = coin.SoBaseColor()
self.hiresgroup.addChild(self.meshcolor)
vobj.addDisplayMode(self.hiresgroup,"Mesh");
vobj.addDisplayMode(self.hiresgroup,"Hires");
ArchComponent.ViewProviderComponent.attach(self,vobj)
def updateData(self, obj, prop):
@ -342,22 +334,22 @@ class _ViewProviderEquipment(ArchComponent.ViewProviderComponent):
self.coords.point.deleteValues(0)
def getDisplayModes(self,vobj):
modes=["Mesh"]
modes=["Hires"]
return modes
def setDisplayMode(self,mode):
if mode == "Mesh":
if mode == "Hires":
m = None
if hasattr(self,"Object"):
if hasattr(self.Object,"Mesh"):
if self.Object.Mesh:
m = self.Object.Mesh.ViewObject.RootNode
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,"Mesh"):
if self.Object.CloneOf.Mesh:
m = self.Object.CloneOf.Mesh.ViewObject.RootNode
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