From e8df845b3fcac19ca4990a4424cba4e1adb6292c Mon Sep 17 00:00:00 2001
From: jean-pierre charras <jp.charras@wanadoo.fr>
Date: Wed, 14 Mar 2018 18:48:55 +0100
Subject: [PATCH] Minor fix in zones_by_polygon.cpp: When editing a non copper
 zone, some settings were not those of the edited zone. trigo.h: Add a useful
 double NormalizeAngleDegrees( double Angle, double aMin, double aMax ).

---
 include/trigo.h             | 13 ++++++++++++-
 pcbnew/zones_by_polygon.cpp |  6 ++++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/include/trigo.h b/include/trigo.h
index f8da175bf7..e3e87e6c01 100644
--- a/include/trigo.h
+++ b/include/trigo.h
@@ -1,7 +1,7 @@
 /*
  * This program source code file is part of KiCad, a free EDA CAD application.
  *
- * Copyright (C) 2013 KiCad Developers, see change_log.txt for contributors.
+ * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -271,6 +271,17 @@ inline double NormalizeAngleRadiansPos( double Angle )
     return Angle;
 }
 
+/// Normalize angle to be aMin < angle <= aMax
+/// angle is in degrees
+inline double NormalizeAngleDegrees( double Angle, double aMin, double aMax )
+{
+    while( Angle < aMin )
+        Angle += 360.0;
+    while( Angle >= aMax )
+        Angle -= 360.0;
+    return Angle;
+}
+
 /// Add two angles (keeping the result normalized). T2 is here
 // because most of the time it's an int (and templates don't promote in
 // that way)
diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp
index 6ee19f686e..598d6f7439 100644
--- a/pcbnew/zones_by_polygon.cpp
+++ b/pcbnew/zones_by_polygon.cpp
@@ -894,13 +894,12 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* aZone )
     else if( IsCopperLayer( aZone->GetLayer() ) )
     {
         // edit a zone on a copper layer
-
         zoneInfo << *aZone;
-
         edited = InvokeCopperZonesEditor( this, &zoneInfo );
     }
     else
     {
+        zoneInfo << *aZone;
         edited = InvokeNonCopperZonesEditor( this, aZone, &zoneInfo );
     }
 
@@ -989,6 +988,9 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* aZone )
     GetBoard()->GetConnectivity()->RecalculateRatsnest();
 
     s_PickedList.ClearItemsList();  // s_ItemsListPicker is no longer owner of picked items
+
+    if( !IsGalCanvasActive() )
+        m_canvas->Refresh();
 }