← Back to team overview

kicad-developers team mailing list archive

[PATCH] BuildConnectivity and re-DisplayBoard in python Refresh

 

Refresh is used in the python domain to refresh the display with the current
design. If something has changed, board connectivity likely needs
rebuilding.
If using GAL canvas, update its display db.



I am still looking at board_commit. This patch is to help those who already
have working python code. Also, as I mentioned in my board_commit thread,
<https://lists.launchpad.net/kicad-developers/msg32063.html> there will be
some scripts for which undo functionality is not needed.

also, in the same thread, some suggestions were made on getting GAL to
redraw. They all seem to require doing something before changes begin and
then calling something else. This patch enables the catch all of "just
rebuild whatever needs to be rebuilt"

Miles

for my personal reference: this is my fifth patch.
From 383c7f5b3dff417125992fbbdd8a14ae00c82d93 Mon Sep 17 00:00:00 2001
From: Miles McCoo <mail@xxxxxxxxxx>
Date: Sun, 3 Dec 2017 11:19:42 +0100
Subject: [PATCH] BuildConnectivity and re-DisplayBoard in python Refresh
 function
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.7.4"

This is a multi-part message in MIME format.
--------------2.7.4
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit


Refresh is used in the python domain to refresh the display with the current
design. If something has changed, board connectivity likely needs rebuilding.
If using GAL canvas, update its display db.
---
 pcbnew/swig/pcbnew_scripting_helpers.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)


--------------2.7.4
Content-Type: text/x-patch; name="0001-BuildConnectivity-and-re-DisplayBoard-in-python-Refr.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-BuildConnectivity-and-re-DisplayBoard-in-python-Refr.patch"

diff --git a/pcbnew/swig/pcbnew_scripting_helpers.cpp b/pcbnew/swig/pcbnew_scripting_helpers.cpp
index a5af6cd..3dbedc3 100644
--- a/pcbnew/swig/pcbnew_scripting_helpers.cpp
+++ b/pcbnew/swig/pcbnew_scripting_helpers.cpp
@@ -39,6 +39,7 @@
 #include <io_mgr.h>
 #include <macros.h>
 #include <stdlib.h>
+#include <pcb_draw_panel_gal.h>
 
 static PCB_EDIT_FRAME* s_PcbEditFrame = NULL;
 
@@ -103,8 +104,15 @@ void Refresh()
 {
     if( s_PcbEditFrame )
     {
+        auto board = s_PcbEditFrame->GetBoard();
+        board->BuildConnectivity();
+
         if( s_PcbEditFrame->IsGalCanvasActive() )
+        {
+            auto panel = static_cast<PCB_DRAW_PANEL_GAL*>( s_PcbEditFrame->GetGalCanvas() );
+            panel->DisplayBoard(board);
             s_PcbEditFrame->GetGalCanvas()->Refresh();
+        }
         else
             // first argument is erase background, second is a wxRect that
             // defines a reftresh area (all canvas if null)

--------------2.7.4--



Follow ups