Skip to content

Commit

Permalink
Arch: Removed Floor dependency of Site
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed May 8, 2019
1 parent 2177f44 commit af0cb40
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/Mod/Arch/ArchFloor.py
Expand Up @@ -143,7 +143,7 @@ def setProperties(self,obj):
# obj can be a Part Feature and already has a placement
obj.addProperty("App::PropertyPlacement","Placement","Base",QT_TRANSLATE_NOOP("App::Property","The placement of this object"))
if not "IfcType" in pl:
obj.addProperty("App::PropertyEnumeration","IfcType","Component",QT_TRANSLATE_NOOP("App::Property","The type of this object"))
obj.addProperty("App::PropertyEnumeration","IfcType","IFC",QT_TRANSLATE_NOOP("App::Property","The type of this object"))
import ArchIFC
obj.IfcType = ArchIFC.IfcTypes
self.Type = "Floor"
Expand Down
78 changes: 45 additions & 33 deletions src/Mod/Arch/ArchSite.py
Expand Up @@ -23,7 +23,7 @@
#* *
#***************************************************************************

import FreeCAD,Draft,ArchCommands,ArchFloor,math,re,datetime,ArchIFC
import FreeCAD,Draft,ArchCommands,math,re,datetime,ArchIFC
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore, QtGui
Expand Down Expand Up @@ -449,18 +449,18 @@ def Activated(self):



class _Site(ArchFloor._Floor):
class _Site:

"The Site object"

def __init__(self,obj):

ArchFloor._Floor.__init__(self,obj)
self.setProperties(obj)
obj.IfcType = "Site"

def setProperties(self,obj):

import ArchIFC
ArchIFC.setProperties(obj)

pl = obj.PropertiesList
Expand Down Expand Up @@ -511,26 +511,23 @@ def setProperties(self,obj):
if not hasattr(obj,"Group"):
obj.addExtension("App::GroupExtensionPython", self)
if not "Compass" in pl:
obj.addProperty("App::PropertyBool", "Compass", "Compass", QT_TRANSLATE_NOOP(
"App::Property", "Show compass or not"))
obj.addProperty("App::PropertyBool", "Compass", "Compass", QT_TRANSLATE_NOOP("App::Property", "Show compass or not"))
if not "CompassRotation" in pl:
obj.addProperty("App::PropertyAngle", "CompassRotation", "Compass", QT_TRANSLATE_NOOP(
"App::Property", "The rotation of the Compass relative to the Site"))
obj.addProperty("App::PropertyAngle", "CompassRotation", "Compass", QT_TRANSLATE_NOOP("App::Property", "The rotation of the Compass relative to the Site"))
if not "UpdateDeclination" in pl:
obj.addProperty("App::PropertyBool", "UpdateDeclination", "Compass", QT_TRANSLATE_NOOP(
"App::Property", "Update the Declination value based on the compass rotation"))
obj.addProperty("App::PropertyBool", "UpdateDeclination", "Compass", QT_TRANSLATE_NOOP("App::Property", "Update the Declination value based on the compass rotation"))
if not "IfcType" in pl:
obj.addProperty("App::PropertyEnumeration","IfcType","IFC",QT_TRANSLATE_NOOP("App::Property","The type of this object"))
obj.IfcType = ArchIFC.IfcTypes
obj.IcfType = "Site"
self.Type = "Site"
obj.setEditorMode('Height',2)

def onDocumentRestored(self,obj):

ArchFloor._Floor.onDocumentRestored(self,obj)
self.setProperties(obj)

def execute(self,obj):

ArchFloor._Floor.execute(self,obj)

if not obj.isDerivedFrom("Part::Feature"): # old-style Site
return

Expand Down Expand Up @@ -571,25 +568,23 @@ def execute(self,obj):
self.computeAreas(obj)

def onChanged(self,obj,prop):
ArchIFC.onChanged(obj, prop)

ArchFloor._Floor.onChanged(self,obj,prop)
ArchIFC.onChanged(obj, prop)
if prop == "Terrain":
if obj.Terrain:
if FreeCAD.GuiUp:
obj.Terrain.ViewObject.hide()
self.execute(obj)
if prop in ["UpdateDeclination", "CompassRotation", "Placement"]:
self.updateDeclination()

def updateDeclination(self):
if not hasattr(self.Object, 'UpdateDeclination') or not self.Object.UpdateDeclination:
return
self.updateDeclination(obj)

compassRotation = self.Object.CompassRotation.Value
siteRotation = math.degrees(self.Object.Placement.Rotation.Angle)
def updateDeclination(self,obj):

self.Object.Declination = compassRotation + siteRotation
if not hasattr(obj, 'UpdateDeclination') or not obj.UpdateDeclination:
return
compassRotation = obj.CompassRotation.Value
siteRotation = math.degrees(obj.Placement.Rotation.Angle)
obj.Declination = compassRotation + siteRotation

def computeAreas(self,obj):

Expand Down Expand Up @@ -660,13 +655,13 @@ def computeAreas(self,obj):



class _ViewProviderSite(ArchFloor._ViewProviderFloor):
class _ViewProviderSite:

"A View Provider for the Site object"

def __init__(self,vobj):

ArchFloor._ViewProviderFloor.__init__(self,vobj)
vobj.Proxy = self
vobj.addExtension("Gui::ViewProviderGroupExtensionPython", self)
self.setProperties(vobj)

Expand Down Expand Up @@ -701,17 +696,19 @@ def getIcon(self):

def claimChildren(self):

objs = self.Object.Group+[self.Object.Terrain]
prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
if hasattr(self.Object,"Additions") and prefs.GetBool("swallowAdditions",True):
objs.extend(self.Object.Additions)
if hasattr(self.Object,"Subtractions") and prefs.GetBool("swallowSubtractions",True):
objs.extend(self.Object.Subtractions)
objs = []
if hasattr(self,"Object"):
objs = self.Object.Group+[self.Object.Terrain]
prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
if hasattr(self.Object,"Additions") and prefs.GetBool("swallowAdditions",True):
objs.extend(self.Object.Additions)
if hasattr(self.Object,"Subtractions") and prefs.GetBool("swallowSubtractions",True):
objs.extend(self.Object.Subtractions)
return objs

def setEdit(self,vobj,mode):

if mode == 0:
if (mode == 0) and hasattr(self,"Object"):
import ArchComponent
taskd = ArchComponent.ComponentTaskPanel()
taskd.obj = self.Object
Expand All @@ -727,7 +724,7 @@ def unsetEdit(self,vobj,mode):

def attach(self,vobj):

ArchFloor._ViewProviderFloor.attach(self,vobj)
self.Object = vobj.Object
from pivy import coin
self.diagramsep = coin.SoSeparator()
self.color = coin.SoBaseColor()
Expand Down Expand Up @@ -801,6 +798,7 @@ def onChanged(self,vobj,prop):
self.removeTrueNorthRotation()

def addTrueNorthRotation(self):

if hasattr(self, 'trueNorthRotation') and self.trueNorthRotation is not None:
return

Expand All @@ -814,13 +812,15 @@ def addTrueNorthRotation(self):
self.updateTrueNorthRotation()

def removeTrueNorthRotation(self):

if hasattr(self, 'trueNorthRotation') and self.trueNorthRotation is not None:
sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()

sg.removeChild(self.trueNorthRotation)
self.trueNorthRotation = None

def updateTrueNorthRotation(self):

if hasattr(self, 'trueNorthRotation') and self.trueNorthRotation is not None:
from pivy import coin

Expand All @@ -829,6 +829,7 @@ def updateTrueNorthRotation(self):
self.trueNorthRotation.rotation.setValue(coin.SbVec3f(0, 0, 1), math.radians(-angle))

def updateCompassVisibility(self, obj):

if not hasattr(self, 'compass'):
return

Expand All @@ -840,13 +841,15 @@ def updateCompassVisibility(self, obj):
self.compass.hide()

def rotateCompass(self, obj):

if not hasattr(self, 'compass'):
return

if hasattr(obj, 'CompassRotation'):
self.compass.rotate(obj.CompassRotation.Value)

def updateCompassLocation(self, obj):

if not hasattr(self, 'compass'):
return

Expand All @@ -858,11 +861,20 @@ def updateCompassLocation(self, obj):
self.compass.setZOffset(zOffset + 1000)

def updateCompassScale(self, obj):

if not hasattr(self, 'compass'):
return

self.compass.scale(obj.ProjectedArea)

def __getstate__(self):

return None

def __setstate__(self,state):

return None


if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Site',_CommandSite())

0 comments on commit af0cb40

Please sign in to comment.