Commit 706b267f authored by Dick Hollenbeck's avatar Dick Hollenbeck

zone properties dialog was not showing previously selected net

parent d7fd8f17
...@@ -502,7 +502,7 @@ void DIALOG_COPPER_ZONE::OnRunFiltersButtonClick( wxCommandEvent& event ) ...@@ -502,7 +502,7 @@ void DIALOG_COPPER_ZONE::OnRunFiltersButtonClick( wxCommandEvent& event )
void DIALOG_COPPER_ZONE::buildAvailableListOfNets() void DIALOG_COPPER_ZONE::buildAvailableListOfNets()
{ {
wxArrayString listNetName; wxArrayString listNetName;
m_Parent->GetBoard()->ReturnSortedNetnamesList( listNetName, m_NetSortingByPadCount ); m_Parent->GetBoard()->ReturnSortedNetnamesList( listNetName, m_NetSortingByPadCount );
...@@ -510,6 +510,7 @@ void DIALOG_COPPER_ZONE::buildAvailableListOfNets() ...@@ -510,6 +510,7 @@ void DIALOG_COPPER_ZONE::buildAvailableListOfNets()
{ {
wxString doNotShowFilter = m_DoNotShowNetNameFilter->GetValue(); wxString doNotShowFilter = m_DoNotShowNetNameFilter->GetValue();
wxString ShowFilter = m_ShowNetNameFilter->GetValue(); wxString ShowFilter = m_ShowNetNameFilter->GetValue();
for( unsigned ii = 0; ii < listNetName.GetCount(); ii++ ) for( unsigned ii = 0; ii < listNetName.GetCount(); ii++ )
{ {
if( listNetName[ii].Matches( doNotShowFilter ) ) if( listNetName[ii].Matches( doNotShowFilter ) )
...@@ -524,29 +525,44 @@ void DIALOG_COPPER_ZONE::buildAvailableListOfNets() ...@@ -524,29 +525,44 @@ void DIALOG_COPPER_ZONE::buildAvailableListOfNets()
} }
} }
} }
m_ListNetNameSelection->Clear();
listNetName.Insert( wxT( "<no net>" ), 0 ); listNetName.Insert( wxT( "<no net>" ), 0 );
m_ListNetNameSelection->InsertItems( listNetName, 0 );
m_ListNetNameSelection->SetSelection( 0 );
// Ensure current select net for the zone is visible: // Ensure currently selected net for the zone is visible, regardless of filters
int selectedNetListNdx = -1;
int net_select = m_Zone_Setting->m_NetcodeSelection; int net_select = m_Zone_Setting->m_NetcodeSelection;
if( net_select > 0 ) if( net_select > 0 )
{ {
NETINFO_ITEM* equipot = m_Parent->GetBoard()->FindNet( net_select ); NETINFO_ITEM* equipot = m_Parent->GetBoard()->FindNet( net_select );
if( equipot ) // Search net in list and select it if( equipot )
{ {
for( unsigned ii = 0; ii < listNetName.GetCount(); ii++ ) selectedNetListNdx = listNetName.Index( equipot->GetNetname() );
if( wxNOT_FOUND == selectedNetListNdx )
{ {
if( listNetName[ii] == equipot->GetNetname() ) // the currently selected net must *always* be visible.
{ listNetName.Insert( equipot->GetNetname(), 0 );
m_ListNetNameSelection->SetSelection( ii ); selectedNetListNdx = 0;
m_ListNetNameSelection->EnsureVisible( ii );
break;
}
} }
} }
} }
else if( net_select == 0 )
selectedNetListNdx = 0; // SetSelection() on "<no net>"
else
{
// selectedNetListNdx remains -1, no net selected.
}
m_ListNetNameSelection->Clear();
m_ListNetNameSelection->InsertItems( listNetName, 0 );
m_ListNetNameSelection->SetSelection( 0 );
if( selectedNetListNdx >= 0 )
{
m_ListNetNameSelection->SetSelection( selectedNetListNdx );
m_ListNetNameSelection->EnsureVisible( selectedNetListNdx );
}
} }
......
/* dialog_copper_zones.h */ /* dialog_copper_zones.h */
#ifndef DIALOG_COPPER_ZONES #ifndef DIALOG_COPPER_ZONES_
#define DIALOG_COPPER_ZONES #define DIALOG_COPPER_ZONES_
#include <wx/wx.h> #include <wx/wx.h>
#include <wx/listctrl.h> #include <wx/listctrl.h>
#include "dialog_copper_zones_base.h" #include "dialog_copper_zones_base.h"
/* here is the derivated class from dialog_copper_zone_frame created by wxFormBuilder /**
* Class DIALOG_COPPER_ZONE
* is the derivated class from dialog_copper_zone_frame created by wxFormBuilder
*/ */
class DIALOG_COPPER_ZONE : public DIALOG_COPPER_ZONE_BASE class DIALOG_COPPER_ZONE : public DIALOG_COPPER_ZONE_BASE
{ {
private: private:
PCB_EDIT_FRAME* m_Parent; PCB_EDIT_FRAME* m_Parent;
wxConfig* m_Config; // Current config wxConfig* m_Config; ///< Current config
int m_OnExitCode; /* exit code: ZONE_ABORT if no change,
* ZONE_OK if new values accepted int m_OnExitCode; ///< exit code: ZONE_ABORT if no change,
* ZONE_EXPORT_VALUES if values are exported to others zones ///< ZONE_OK if new values accepted
*/ ///< ZONE_EXPORT_VALUES if values are exported to others zones
ZONE_SETTING* m_Zone_Setting; ZONE_SETTING* m_Zone_Setting;
bool m_NetSortingByPadCount; /* false = alphabetic sort.
* true = pad count sort. bool m_NetSortingByPadCount; ///< false = alphabetic sort.
*/ ///< true = pad count sort.
long m_NetFiltering; long m_NetFiltering;
std::vector<int> m_LayerId; // Handle the real layer number from layer std::vector<int> m_LayerId; ///< Handle the real layer number from layer
// name position in m_LayerSelectionCtrl ///< name position in m_LayerSelectionCtrl
static wxString m_netNameShowFilter; /* the filter to show nets (default * "*").
* static to keep this pattern for an entire pcbnew session static wxString m_netNameShowFilter; ///< the filter to show nets (default * "*").
*/ ///< static to keep this pattern for an entire pcbnew session
wxListView* m_LayerSelectionCtrl; wxListView* m_LayerSelectionCtrl;
static wxPoint prevPosition; // Dialog position & size static wxPoint prevPosition; ///< Dialog position & size
static wxSize prevSize; static wxSize prevSize;
public: public:
DIALOG_COPPER_ZONE( PCB_EDIT_FRAME* parent, ZONE_SETTING* zone_setting ); DIALOG_COPPER_ZONE( PCB_EDIT_FRAME* parent, ZONE_SETTING* zone_setting );
private: private:
/** Function initDialog /**
* Function initDialog
* fills in the dialog controls using the current settings. * fills in the dialog controls using the current settings.
*/ */
void initDialog(); void initDialog();
void OnButtonOkClick( wxCommandEvent& event ); void OnButtonOkClick( wxCommandEvent& event );
void OnButtonCancelClick( wxCommandEvent& event ); void OnButtonCancelClick( wxCommandEvent& event );
void OnClose( wxCloseEvent& event ); void OnClose( wxCloseEvent& event );
...@@ -55,13 +61,17 @@ private: ...@@ -55,13 +61,17 @@ private:
* @return bool - false if incorrect options, true if ok. * @return bool - false if incorrect options, true if ok.
*/ */
bool AcceptOptions( bool aPromptForErrors, bool aUseExportableSetupOnly = false ); bool AcceptOptions( bool aPromptForErrors, bool aUseExportableSetupOnly = false );
void OnNetSortingOptionSelected( wxCommandEvent& event ); void OnNetSortingOptionSelected( wxCommandEvent& event );
void ExportSetupToOtherCopperZones( wxCommandEvent& event ); void ExportSetupToOtherCopperZones( wxCommandEvent& event );
void OnPadsInZoneClick( wxCommandEvent& event ); void OnPadsInZoneClick( wxCommandEvent& event );
void OnRunFiltersButtonClick( wxCommandEvent& event ); void OnRunFiltersButtonClick( wxCommandEvent& event );
void buildAvailableListOfNets(); void buildAvailableListOfNets();
/** Function initListNetsParams /**
* Function initListNetsParams
* initializes m_NetSortingByPadCount and m_NetFiltering values * initializes m_NetSortingByPadCount and m_NetFiltering values
* according to m_NetDisplayOption selection. * according to m_NetDisplayOption selection.
*/ */
...@@ -74,4 +84,5 @@ private: ...@@ -74,4 +84,5 @@ private:
*/ */
wxBitmap makeLayerBitmap( int aColor ); wxBitmap makeLayerBitmap( int aColor );
}; };
#endif // #ifndef DIALOG_COPPER_ZONES
#endif // DIALOG_COPPER_ZONES_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment