← Back to team overview

kicad-developers team mailing list archive

[PATCH]

 

As per the TODO.txt file, there was a bug with CvPCB that would prevent an
already assigned footprint from being shown in the preview window when the
selected component changed :

CvPCB
-----
* Preview of the already assigned footprint.


This is fixed with the attached patch.

What was done:

Whenever the selection in the components listbox is changed
(CVPCB_MAINFRAME::OnSelectComponent), the list of footprints is searched
for the actual footprint previously selected, and if found, that footprint
is selected in the listbox.

The effect of this is that when the preview frame is opened, the selected
footprint is now shown. Because this was done in the OnSelectComponent
function, it also work when the next component is automatically selected
after double clicking a footprint for the current component.


To write the patch, I mostly used code as-is from CvPCB, so the notation
should respect the convention.

As this is my first patch, I hope all of this has been done properly, and
any suggestions would be welcomed.

Regards,
Guillaume Simard
=== modified file 'cvpcb/cvframe.cpp'
--- cvpcb/cvframe.cpp	2011-10-13 20:13:11 +0000
+++ cvpcb/cvframe.cpp	2011-12-11 04:44:07 +0000
@@ -525,6 +525,24 @@
     }
 
     m_FootprintList->SetFootprintFilteredList( &m_components[ selection ], m_footprints );
+
+    // * Preview of the already assigned footprint.
+    // Find the footprint that was already choosen for this component and select it.
+    wxString module = *(&m_components[ selection ].m_Module);
+    for (int ii = 0 ; ii < m_FootprintList->GetCount() ; ii++)
+      {
+	wxString FootprintName;
+	wxString msg = (*m_FootprintList->m_ActiveFootprintList)[ii];
+	msg.Trim( true );
+	msg.Trim( false );
+	FootprintName = msg.AfterFirst( wxChar( ' ' ) );
+
+	if (module.Cmp(FootprintName) == 0)
+	  m_FootprintList->SetSelection(ii, TRUE);
+	else
+	  m_FootprintList->SetSelection(ii, FALSE);
+      }
+
     SendMessageToEESCHEMA();
     DisplayStatus();
 }


Follow ups