ADDED: Allow creation of nets in pcbnew
When editing pcb items, the creation of a new net to connect existing pads or traces can be a useful shortcut. This inserts the ability to optionally create a new net from the Net Selector dropdown menu.
This commit is contained in:
parent
2359d19cf4
commit
ecbfea68dd
|
@ -46,6 +46,7 @@ wxDEFINE_EVENT( NET_SELECTED, wxCommandEvent );
|
|||
#endif
|
||||
|
||||
#define NO_NET _( "<no net>" )
|
||||
#define CREATE_NET _( "<create net>" )
|
||||
|
||||
|
||||
class NET_SELECTOR_COMBOPOPUP : public wxPanel, public wxComboPopup
|
||||
|
@ -58,6 +59,7 @@ public:
|
|||
m_minPopupWidth( -1 ),
|
||||
m_maxPopupHeight( 1000 ),
|
||||
m_netinfoList( nullptr ),
|
||||
m_board( nullptr ),
|
||||
m_selectedNetcode( 0 ),
|
||||
m_focusHandler( nullptr )
|
||||
{ }
|
||||
|
@ -122,6 +124,11 @@ public:
|
|||
rebuildList();
|
||||
}
|
||||
|
||||
void SetBoard( BOARD* aBoard )
|
||||
{
|
||||
m_board = aBoard;
|
||||
}
|
||||
|
||||
void SetIndeterminate() { m_selectedNetcode = -1; }
|
||||
bool IsIndeterminate() { return m_selectedNetcode == -1; }
|
||||
|
||||
|
@ -172,7 +179,9 @@ public:
|
|||
void Accept()
|
||||
{
|
||||
wxString selectedNetName;
|
||||
wxString remainingName;
|
||||
int selection = m_listBox->GetSelection();
|
||||
wxString prefix = CREATE_NET;
|
||||
|
||||
if( selection >= 0 )
|
||||
selectedNetName = m_listBox->GetString( (unsigned) selection );
|
||||
|
@ -187,6 +196,28 @@ public:
|
|||
m_selectedNetcode = 0;
|
||||
GetComboCtrl()->SetValue( NO_NET );
|
||||
}
|
||||
else if( selectedNetName.StartsWith( CREATE_NET, &remainingName ) &&
|
||||
!remainingName.IsEmpty() )
|
||||
{
|
||||
// Remove the first character ':' and all whitespace
|
||||
remainingName = remainingName.Mid( 1 ).Trim().Trim( false );
|
||||
NETINFO_ITEM *newnet = new NETINFO_ITEM( m_board, remainingName, 0 );
|
||||
|
||||
m_netinfoList->AppendNet( newnet );
|
||||
rebuildList();
|
||||
|
||||
if( newnet->GetNet() > 0 )
|
||||
{
|
||||
m_selectedNetcode = newnet->GetNet();
|
||||
GetComboCtrl()->SetValue( remainingName );
|
||||
}
|
||||
else
|
||||
{
|
||||
// This indicates that the NETINFO_ITEM was not successfully appended
|
||||
// to the list for unknown reasons
|
||||
delete newnet;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NETINFO_ITEM* netInfo = m_netinfoList->GetNetItem( selectedNetName );
|
||||
|
@ -242,7 +273,8 @@ protected:
|
|||
void rebuildList()
|
||||
{
|
||||
wxArrayString netNames;
|
||||
wxString filter = m_filterCtrl->GetValue().MakeLower();
|
||||
wxString netstring = m_filterCtrl->GetValue().MakeLower();
|
||||
wxString filter = netstring;
|
||||
|
||||
if( !filter.IsEmpty() )
|
||||
filter = wxT( "*" ) + filter + wxT( "*" );
|
||||
|
@ -263,6 +295,12 @@ protected:
|
|||
if( filter.IsEmpty() || wxString( NO_NET ).MakeLower().Matches( filter ) )
|
||||
netNames.insert( netNames.begin(), NO_NET );
|
||||
|
||||
if( !filter.IsEmpty() && netNames.IsEmpty() )
|
||||
{
|
||||
wxString newnet = wxString::Format( "%s: %s", CREATE_NET, netstring );
|
||||
netNames.insert( netNames.begin(), newnet );
|
||||
}
|
||||
|
||||
m_listBox->Set( netNames );
|
||||
}
|
||||
|
||||
|
@ -453,6 +491,7 @@ protected:
|
|||
int m_maxPopupHeight;
|
||||
|
||||
NETINFO_LIST* m_netinfoList;
|
||||
BOARD* m_board;
|
||||
|
||||
int m_selectedNetcode;
|
||||
|
||||
|
@ -522,6 +561,12 @@ void NET_SELECTOR::SetNetInfo( NETINFO_LIST* aNetInfoList )
|
|||
}
|
||||
|
||||
|
||||
void NET_SELECTOR::SetBoard( BOARD* aBoard )
|
||||
{
|
||||
m_netSelectorPopup->SetBoard( aBoard );
|
||||
}
|
||||
|
||||
|
||||
void NET_SELECTOR::SetSelectedNetcode( int aNetcode )
|
||||
{
|
||||
m_netSelectorPopup->SetSelectedNetcode( aNetcode );
|
||||
|
|
|
@ -49,6 +49,8 @@ public:
|
|||
|
||||
void SetNetInfo( NETINFO_LIST* aNetInfoList );
|
||||
|
||||
void SetBoard( BOARD* aBoard );
|
||||
|
||||
void SetSelectedNetcode( int aNetcode );
|
||||
void SetSelectedNet( const wxString& aNetname );
|
||||
void SetIndeterminate();
|
||||
|
|
|
@ -159,6 +159,7 @@ DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::~DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS()
|
|||
void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildFilterLists()
|
||||
{
|
||||
// Populate the net filter list with net names
|
||||
m_netFilter->SetBoard( m_brd );
|
||||
m_netFilter->SetNetInfo( &m_brd->GetNetInfo() );
|
||||
m_netFilter->SetSelectedNetcode( m_brd->GetHighLightNetCode() );
|
||||
|
||||
|
|
|
@ -134,6 +134,7 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aP
|
|||
m_choiceFabProperty->Show( false );
|
||||
}
|
||||
|
||||
m_PadNetSelector->SetBoard( m_board );
|
||||
m_PadNetSelector->SetNetInfo( &m_board->GetNetInfo() );
|
||||
|
||||
m_OrientValidator.SetRange( -360.0, 360.0 );
|
||||
|
|
|
@ -55,6 +55,7 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
|
|||
|
||||
VIATYPE viaType = VIATYPE::NOT_DEFINED;
|
||||
|
||||
m_netSelector->SetBoard( aParent->GetBoard() );
|
||||
m_netSelector->SetNetInfo( &aParent->GetBoard()->GetNetInfo() );
|
||||
|
||||
m_TrackLayerCtrl->SetLayersHotkeys( false );
|
||||
|
|
Loading…
Reference in New Issue