From 609d497870dcf534eb7a316952a61ff9674ea218 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 10 Oct 2018 18:42:27 +0100 Subject: [PATCH] Remember settings in Global Track & Via Properties dialog. --- common/widgets/net_selector.cpp | 27 ++++++++++ include/widgets/net_selector.h | 2 + .../dialog_global_edit_tracks_and_vias.cpp | 52 +++++++++++++++++-- 3 files changed, 77 insertions(+), 4 deletions(-) diff --git a/common/widgets/net_selector.cpp b/common/widgets/net_selector.cpp index 420a901f8d..d305154cbe 100644 --- a/common/widgets/net_selector.cpp +++ b/common/widgets/net_selector.cpp @@ -122,6 +122,20 @@ public: void SetSelectedNetcode( int aNetcode ) { m_selectedNetcode = aNetcode; } 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 { // 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() { m_netSelectorPopup->SetIndeterminate(); diff --git a/include/widgets/net_selector.h b/include/widgets/net_selector.h index de0a085f67..f3d3463f84 100644 --- a/include/widgets/net_selector.h +++ b/include/widgets/net_selector.h @@ -50,10 +50,12 @@ public: void SetNetInfo( NETINFO_LIST* aNetInfoList ); void SetSelectedNetcode( int aNetcode ); + void SetSelectedNet( const wxString& aNetname ); void SetIndeterminate(); bool IsIndeterminate(); int GetSelectedNetcode(); + wxString GetSelectedNetname(); protected: void onKeyDown( wxKeyEvent& aEvt ); diff --git a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp index 7dc838b57c..4a024e5096 100644 --- a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp +++ b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp @@ -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 { 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() { + 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 ); delete[] m_originalColWidths; @@ -196,12 +220,32 @@ bool DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow() { auto item = dynamic_cast( 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( item->GetNet()->GetClassName() ); - m_layerFilter->SetLayerSelection( item->GetLayer() ); + m_netclassFilter->SetStringSelection( g_netclassFilter ); + m_netclassFilterOpt->SetValue( true ); } + 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; }