From 792e4a6c6c23c85be1843b2e1cfb04c873d6505e Mon Sep 17 00:00:00 2001 From: furti Date: Fri, 8 Mar 2019 19:18:49 +0100 Subject: [PATCH] Add property to calculate declination When enabled, the declination will be calculated based on the compass and site rotation. --- src/Mod/Arch/ArchSite.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Mod/Arch/ArchSite.py b/src/Mod/Arch/ArchSite.py index 396082d9b5..9df2de2c70 100644 --- a/src/Mod/Arch/ArchSite.py +++ b/src/Mod/Arch/ArchSite.py @@ -519,6 +519,9 @@ class _Site(ArchFloor._Floor): 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")) + if not "UpdateDeclination" in pl: + obj.addProperty("App::PropertyBool", "UpdateDeclination", "Compass", QT_TRANSLATE_NOOP( + "App::Property", "Update the Declination value based on the compass roation")) self.Type = "Site" obj.setEditorMode('Height',2) @@ -579,6 +582,17 @@ class _Site(ArchFloor._Floor): 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 + + compassRotation = self.Object.CompassRotation.Value + siteRotation = math.degrees(self.Object.Placement.Rotation.Angle) + + self.Object.Declination = compassRotation + siteRotation def computeAreas(self,obj):