This patch fixes a problem with GAL where zones are ignored in ratsnest 
calculation.
The problem is that calling RN_DATA::Update on a zone with no polygons (an 
unfilled zone) will remove the zone successfully, but then RN_DATA::Add is a 
no-op.
From this point on, because ::Update refuses to work on items that have not 
been ::Add'ed, the zone is removed entirely from ratsnest calculation and will 
only be reconsidered once it is explicitly ::Add'ed again.
The fix is to explicitly create an empty RN_ZONE_DATA object for every zone 
that is ::Add'ed.

A second problem is that the point editor forgot to call RN_DATA::Recalculate 
after calling Fill_Zone.

This patch fixes lp:1537120 and is a slightly updated version of a patch I 
attached there.

aiju

---
 pcbnew/ratsnest_data.cpp      | 2 ++
 pcbnew/tools/point_editor.cpp | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/pcbnew/ratsnest_data.cpp b/pcbnew/ratsnest_data.cpp
index ea90550..9aacf19 100644
--- a/pcbnew/ratsnest_data.cpp
+++ b/pcbnew/ratsnest_data.cpp
@@ -499,6 +499,8 @@ bool RN_NET::AddItem( const ZONE_CONTAINER* aZone )
     // Prepare a list of polygons (every zone can contain one or more polygons)
     const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList();

+    // This ensures that we record aZone as added even if it contains no 
polygons.
+    (void) m_zones[aZone];
+
     for( int i = 0; i < polySet.OutlineCount(); ++i )
     {
         const SHAPE_LINE_CHAIN& path = polySet.COutline( i );
diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp
index dcb5848..40088e9 100644
--- a/pcbnew/tools/point_editor.cpp
+++ b/pcbnew/tools/point_editor.cpp
@@ -42,6 +42,7 @@ using namespace std::placeholders;
 #include <class_zone.h>
 #include <class_board.h>
 #include <class_module.h>
+#include <ratsnest_data.h>

 // Few constants to avoid using bare numbers for point indices
 enum SEG_POINTS
@@ -523,7 +524,10 @@ void POINT_EDITOR::finishItem() const
         ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );

         if( zone->IsFilled() )
+        {
             getEditFrame<PCB_EDIT_FRAME>()->Fill_Zone( zone );
+            zone->GetBoard()->GetRatsnest()->Recalculate( zone->GetNetCode() );
+        }
     }
 }

--
2.1.4

_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to