Remember settings in Global Track & Via Properties dialog.

This commit is contained in:
Jeff Young 2018-10-10 18:42:27 +01:00
parent 0090bea24e
commit 609d497870
3 changed files with 77 additions and 4 deletions

View File

@ -122,6 +122,20 @@ public:
void SetSelectedNetcode( int aNetcode ) { m_selectedNetcode = aNetcode; } void SetSelectedNetcode( int aNetcode ) { m_selectedNetcode = aNetcode; }
int GetSelectedNetcode() { return m_selectedNetcode; } int GetSelectedNetcode() { return m_selectedNetcode; }
void SetSelectedNet( const wxString& aNetname )
{
if( m_netinfoList && m_netinfoList->GetNetItem( aNetname ) )
m_selectedNetcode = m_netinfoList->GetNetItem( aNetname )->GetNet();
}
wxString GetSelectedNetname()
{
if( m_netinfoList && m_netinfoList->GetNetItem( m_selectedNetcode ) )
return m_netinfoList->GetNetItem( m_selectedNetcode )->GetNetname();
else
return wxEmptyString;
}
wxSize GetAdjustedSize( int aMinWidth, int aPrefHeight, int aMaxHeight ) override wxSize GetAdjustedSize( int aMinWidth, int aPrefHeight, int aMaxHeight ) override
{ {
// Called when the popup is first shown. Stash the minWidth and maxHeight so we // Called when the popup is first shown. Stash the minWidth and maxHeight so we
@ -493,6 +507,19 @@ void NET_SELECTOR::SetSelectedNetcode( int aNetcode )
} }
void NET_SELECTOR::SetSelectedNet( const wxString& aNetname )
{
m_netSelectorPopup->SetSelectedNet( aNetname );
SetValue( m_netSelectorPopup->GetStringValue() );
}
wxString NET_SELECTOR::GetSelectedNetname()
{
return m_netSelectorPopup->GetSelectedNetname();
}
void NET_SELECTOR::SetIndeterminate() void NET_SELECTOR::SetIndeterminate()
{ {
m_netSelectorPopup->SetIndeterminate(); m_netSelectorPopup->SetIndeterminate();

View File

@ -50,10 +50,12 @@ public:
void SetNetInfo( NETINFO_LIST* aNetInfoList ); void SetNetInfo( NETINFO_LIST* aNetInfoList );
void SetSelectedNetcode( int aNetcode ); void SetSelectedNetcode( int aNetcode );
void SetSelectedNet( const wxString& aNetname );
void SetIndeterminate(); void SetIndeterminate();
bool IsIndeterminate(); bool IsIndeterminate();
int GetSelectedNetcode(); int GetSelectedNetcode();
wxString GetSelectedNetname();
protected: protected:
void onKeyDown( wxKeyEvent& aEvt ); void onKeyDown( wxKeyEvent& aEvt );

View File

@ -46,6 +46,20 @@ enum {
}; };
// Globals to remember control settings during a session
static bool g_modifyTracks = true;
static bool g_modifyVias = true;
// These settings go with a particular board, so we save the boardID.
static timestamp_t g_boardID;
static bool g_filterByNetclass;
static wxString g_netclassFilter;
static bool g_filterByNet;
static wxString g_netFilter;
static bool g_filterByLayer;
static LAYER_NUM g_layerFilter;
class DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS : public DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS_BASE class DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS : public DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS_BASE
{ {
private: private:
@ -123,6 +137,16 @@ DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS( PCB_EDIT
DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::~DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS() DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::~DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS()
{ {
g_boardID = m_brd->GetTimeStamp();
g_modifyTracks = m_tracks->GetValue();
g_modifyVias = m_vias->GetValue();
g_filterByNetclass = m_netclassFilterOpt->GetValue();
g_netclassFilter = m_netclassFilter->GetStringSelection();
g_filterByNet = m_netFilterOpt->GetValue();
g_netFilter = m_netFilter->GetSelectedNetname();
g_filterByLayer = m_layerFilterOpt->GetValue();
g_layerFilter = m_layerFilter->GetLayerSelection();
m_netFilter->Disconnect( NET_SELECTED, wxCommandEventHandler( DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnNetFilterSelect ), NULL, this ); m_netFilter->Disconnect( NET_SELECTED, wxCommandEventHandler( DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnNetFilterSelect ), NULL, this );
delete[] m_originalColWidths; delete[] m_originalColWidths;
@ -196,12 +220,32 @@ bool DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow()
{ {
auto item = dynamic_cast<BOARD_CONNECTED_ITEM*>( m_parent->GetCurItem() ); auto item = dynamic_cast<BOARD_CONNECTED_ITEM*>( m_parent->GetCurItem() );
if( item ) m_tracks->SetValue( g_modifyTracks );
m_vias->SetValue( g_modifyVias );
if( g_filterByNetclass && g_boardID == m_brd->GetTimeStamp() )
{ {
m_netFilter->SetSelectedNetcode( item->GetNetCode() ); m_netclassFilter->SetStringSelection( g_netclassFilter );
m_netclassFilter->SetStringSelection( item->GetNet()->GetClassName() ); m_netclassFilterOpt->SetValue( true );
m_layerFilter->SetLayerSelection( item->GetLayer() );
} }
else if( item )
m_netclassFilter->SetStringSelection( item->GetNet()->GetClassName() );
if( g_filterByNet && g_boardID == m_brd->GetTimeStamp() )
{
m_netFilter->SetSelectedNet( g_netFilter );
m_netFilterOpt->SetValue( true );
}
else if( item )
m_netFilter->SetSelectedNetcode( item->GetNetCode() );
if( g_filterByLayer && g_boardID == m_brd->GetTimeStamp() )
{
m_layerFilter->SetLayerSelection( g_layerFilter );
m_layerFilterOpt->SetValue( true );
}
else if( item )
m_layerFilter->SetLayerSelection( item->GetLayer() );
return true; return true;
} }