Skip to content

Commit

Permalink
Arch: Added Hires property + display mode to all Arch objects
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Mar 7, 2017
1 parent 84ac526 commit 5625bab
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 40 deletions.
48 changes: 47 additions & 1 deletion src/Mod/Arch/ArchComponent.py
Expand Up @@ -323,6 +323,7 @@ def __init__(self,obj):
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
Expand Down Expand Up @@ -720,13 +721,58 @@ def onChanged(self,vobj,prop):
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):
Expand Down
33 changes: 0 additions & 33 deletions src/Mod/Arch/ArchEquipment.py
Expand Up @@ -264,7 +264,6 @@ def __init__(self,obj):
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
Expand Down Expand Up @@ -319,10 +318,6 @@ def attach(self, vobj):
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):
Expand All @@ -333,34 +328,6 @@ def updateData(self, obj, prop):
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())
Expand Down
12 changes: 6 additions & 6 deletions src/Mod/Arch/ArchWall.py
Expand Up @@ -644,18 +644,21 @@ def attach(self,vobj):
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)
Expand All @@ -673,10 +676,7 @@ def setDisplayMode(self,mode):
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:
Expand Down

0 comments on commit 5625bab

Please sign in to comment.