← Back to team overview

kicad-developers team mailing list archive

[PATCH] User Grid dimensions don't update in GAL footprint editor

 

The User Grid dimension dialog in the footprint editor is missing the calls to update the grid in GAL, so the user grid doesn't update until you switch to a different grid and back. Here's a patch.

Chris Pavlina

(Ref. bug #1426098: https://bugs.launchpad.net/kicad/+bug/1426098)

diff --git a/pcbnew/dialogs/dialog_set_grid.cpp b/pcbnew/dialogs/dialog_set_grid.cpp
index 689b803..4821654 100644
--- a/pcbnew/dialogs/dialog_set_grid.cpp
+++ b/pcbnew/dialogs/dialog_set_grid.cpp
@@ -34,6 +34,8 @@
 #include <pcbnew_id.h>
 #include <dialog_set_grid_base.h>
 #include <invoke_pcb_dialog.h>
+#include <gal/graphics_abstraction_layer.h>
+#include <class_draw_panel_gal.h>
 
 
 class DIALOG_SET_GRID : public DIALOG_SET_GRID_BASE
@@ -216,12 +218,21 @@ bool PCB_BASE_FRAME::InvokeDialogGrid()
 
         SetGridOrigin( grid_origin );
 
-        GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
+        BASE_SCREEN* screen = GetScreen();
+
+        screen->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
 
         // If the user grid is the current option, recall SetGrid()
         // to force new values put in list as current grid value
-        if( GetScreen()->GetGridId() == ID_POPUP_GRID_USER )
-            GetScreen()->SetGrid( ID_POPUP_GRID_USER  );
+        if( screen->GetGridId() == ID_POPUP_GRID_USER )
+            screen->SetGrid( ID_POPUP_GRID_USER  );
+
+        if( IsGalCanvasActive() )
+        {
+            GetGalCanvas()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGrid().m_Size.x,
+                                                            screen->GetGrid().m_Size.y ) );
+            GetGalCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
+        }
 
         m_canvas->Refresh();
 
diff --git a/pcbnew/dialogs/dialog_set_grid_base.cpp b/pcbnew/dialogs/dialog_set_grid_base.cpp
index 3530f39..9f12078 100644
--- a/pcbnew/dialogs/dialog_set_grid_base.cpp
+++ b/pcbnew/dialogs/dialog_set_grid_base.cpp
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version Oct  8 2012)
+// C++ code generated with wxFormBuilder (version Mar 13 2015)
 // http://www.wxformbuilder.org/
 //
 // PLEASE DO "NOT" EDIT THIS FILE!
diff --git a/pcbnew/dialogs/dialog_set_grid_base.fbp b/pcbnew/dialogs/dialog_set_grid_base.fbp
index ac115f7..0679f75 100644
--- a/pcbnew/dialogs/dialog_set_grid_base.fbp
+++ b/pcbnew/dialogs/dialog_set_grid_base.fbp
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
 <wxFormBuilder_Project>
-    <FileVersion major="1" minor="11" />
+    <FileVersion major="1" minor="13" />
     <object class="Project" expanded="1">
         <property name="class_decoration"></property>
         <property name="code_generation">C++</property>
@@ -20,8 +20,10 @@
         <property name="path">.</property>
         <property name="precompiled_header"></property>
         <property name="relative_path">1</property>
+        <property name="skip_lua_events">1</property>
         <property name="skip_php_events">1</property>
         <property name="skip_python_events">1</property>
+        <property name="ui_table">UI</property>
         <property name="use_enum">0</property>
         <property name="use_microsoft_bom">0</property>
         <object class="Dialog" expanded="1">
diff --git a/pcbnew/dialogs/dialog_set_grid_base.h b/pcbnew/dialogs/dialog_set_grid_base.h
index 9bb3e86..32a92c2 100644
--- a/pcbnew/dialogs/dialog_set_grid_base.h
+++ b/pcbnew/dialogs/dialog_set_grid_base.h
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version Oct  8 2012)
+// C++ code generated with wxFormBuilder (version Mar 13 2015)
 // http://www.wxformbuilder.org/
 //
 // PLEASE DO "NOT" EDIT THIS FILE!

Follow ups