2011-10-17 20:01:27 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-17 20:01:27 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
2011-10-17 20:01:27 +00:00
|
|
|
* @file highlight.cpp
|
2011-09-23 13:57:12 +00:00
|
|
|
* @brief Highlight nets.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <kicad_device_context.h>
|
|
|
|
#include <macros.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_zone.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <collectors.h>
|
2007-12-13 06:24:09 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
#define Pad_fill ( Pad_Fill_Item.State == RUN )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::ListNetsAndSelect( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-05-28 08:42:24 +00:00
|
|
|
NETINFO_ITEM* net;
|
|
|
|
wxString netFilter;
|
2011-04-19 14:28:34 +00:00
|
|
|
wxArrayString list;
|
2009-05-28 08:42:24 +00:00
|
|
|
|
|
|
|
netFilter = wxT( "*" );
|
2011-04-19 14:28:34 +00:00
|
|
|
wxTextEntryDialog dlg( this, _( "Filter Net Names" ), _( "Net Filter" ), netFilter );
|
|
|
|
|
2010-07-20 10:30:40 +00:00
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return; // cancelled by user
|
|
|
|
|
|
|
|
netFilter = dlg.GetValue( );
|
2011-04-19 14:28:34 +00:00
|
|
|
|
2009-05-28 08:42:24 +00:00
|
|
|
if( netFilter.IsEmpty() )
|
2007-08-10 19:14:51 +00:00
|
|
|
return;
|
|
|
|
|
2011-09-09 19:30:59 +00:00
|
|
|
wxString Line;
|
2011-12-10 05:33:24 +00:00
|
|
|
for( unsigned ii = 0; ii < GetBoard()->GetNetCount(); ii++ )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2011-12-10 05:33:24 +00:00
|
|
|
net = GetBoard()->m_NetInfo.GetNetItem( ii );
|
2011-04-19 14:28:34 +00:00
|
|
|
|
2009-05-28 08:42:24 +00:00
|
|
|
if( !WildCompareString( netFilter, net->GetNetname(), false ) )
|
2007-08-10 19:14:51 +00:00
|
|
|
continue;
|
|
|
|
|
2011-09-09 19:30:59 +00:00
|
|
|
Line.Printf( wxT( "net %3.3d: %s" ), net->GetNet(),
|
2009-11-20 14:55:20 +00:00
|
|
|
GetChars( net->GetNetname() ) );
|
2011-04-19 14:28:34 +00:00
|
|
|
list.Add( Line );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
2012-02-26 19:57:48 +00:00
|
|
|
#if wxCHECK_VERSION( 2, 9, 4 )
|
|
|
|
wxSingleChoiceDialog choiceDlg( this, wxEmptyString, _( "Select Net" ), list, (void**) NULL );
|
|
|
|
#else
|
|
|
|
wxSingleChoiceDialog choiceDlg( this, wxEmptyString, _( "Select Net" ), list, (char**) NULL );
|
|
|
|
#endif
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2011-04-19 14:28:34 +00:00
|
|
|
if( (choiceDlg.ShowModal() == wxID_CANCEL) || (choiceDlg.GetSelection() == wxNOT_FOUND) )
|
2007-08-10 19:14:51 +00:00
|
|
|
return;
|
|
|
|
|
2009-05-28 08:42:24 +00:00
|
|
|
bool found = false;
|
2011-04-19 14:28:34 +00:00
|
|
|
unsigned netcode = (unsigned) choiceDlg.GetSelection();
|
2009-05-28 08:42:24 +00:00
|
|
|
|
|
|
|
// Search for the net selected.
|
2011-12-10 05:33:24 +00:00
|
|
|
for( unsigned ii = 0; ii < GetBoard()->GetNetCount(); ii++ )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2011-12-10 05:33:24 +00:00
|
|
|
net = GetBoard()->FindNet( ii );
|
2011-04-19 14:28:34 +00:00
|
|
|
|
2009-05-28 08:42:24 +00:00
|
|
|
if( !WildCompareString( netFilter, net->GetNetname(), false ) )
|
2007-08-10 19:14:51 +00:00
|
|
|
continue;
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2009-05-28 08:42:24 +00:00
|
|
|
if( ii == netcode )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-05-28 08:42:24 +00:00
|
|
|
netcode = net->GetNet();
|
|
|
|
found = true;
|
2007-08-10 19:14:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-28 08:42:24 +00:00
|
|
|
if( found )
|
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2011-09-14 20:04:58 +00:00
|
|
|
if( GetBoard()->IsHighLightNetON() )
|
2011-10-17 20:01:27 +00:00
|
|
|
HighLight( &dc );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2011-09-14 20:04:58 +00:00
|
|
|
GetBoard()->SetHighLightNet( netcode );
|
2011-10-17 20:01:27 +00:00
|
|
|
HighLight( &dc );
|
2009-05-28 08:42:24 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
int PCB_EDIT_FRAME::SelectHighLight( wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-04-05 17:49:14 +00:00
|
|
|
int netcode = -1;
|
2011-09-14 20:04:58 +00:00
|
|
|
|
|
|
|
if( GetBoard()->IsHighLightNetON() )
|
2011-10-17 20:01:27 +00:00
|
|
|
HighLight( DC );
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2009-02-25 16:35:47 +00:00
|
|
|
// use this scheme because a pad is a higher priority than a track in the
|
2007-12-13 06:24:09 +00:00
|
|
|
// search, and finding a pad, instead of a track on a pad,
|
2011-09-30 18:15:37 +00:00
|
|
|
// allows us to fire a message to Eeschema.
|
2007-12-13 06:24:09 +00:00
|
|
|
|
|
|
|
GENERAL_COLLECTORS_GUIDE guide = GetCollectorsGuide();
|
|
|
|
|
2007-12-13 14:23:50 +00:00
|
|
|
// optionally, modify the "guide" here as needed using its member functions
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
m_Collector->Collect( GetBoard(), GENERAL_COLLECTOR::PadsTracksOrZones,
|
2013-08-03 05:15:23 +00:00
|
|
|
RefPos( true ), guide );
|
2007-12-13 06:24:09 +00:00
|
|
|
|
|
|
|
BOARD_ITEM* item = (*m_Collector)[0];
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-12-13 06:24:09 +00:00
|
|
|
if( item )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2007-12-13 06:24:09 +00:00
|
|
|
switch( item->Type() )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_PAD_T:
|
2011-04-05 17:49:14 +00:00
|
|
|
netcode = ( (D_PAD*) item )->GetNet();
|
2007-12-13 06:24:09 +00:00
|
|
|
SendMessageToEESCHEMA( item );
|
2011-04-05 17:49:14 +00:00
|
|
|
break;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TRACE_T:
|
|
|
|
case PCB_VIA_T:
|
|
|
|
case PCB_ZONE_T:
|
2007-12-13 14:21:50 +00:00
|
|
|
// since these classes are all derived from TRACK, use a common
|
|
|
|
// GetNet() function:
|
2011-04-05 17:49:14 +00:00
|
|
|
netcode = ( (TRACK*) item )->GetNet();
|
|
|
|
break;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_ZONE_AREA_T:
|
2011-04-05 17:49:14 +00:00
|
|
|
netcode = ( (ZONE_CONTAINER*) item )->GetNet();
|
|
|
|
break;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-12-13 14:21:50 +00:00
|
|
|
default:
|
|
|
|
; // until somebody changes GENERAL_COLLECTOR::PadsOrTracks,
|
|
|
|
// this should not happen.
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2011-04-05 17:49:14 +00:00
|
|
|
if( netcode >= 0 )
|
|
|
|
{
|
2011-09-14 20:04:58 +00:00
|
|
|
GetBoard()->SetHighLightNet( netcode );
|
2011-10-17 20:01:27 +00:00
|
|
|
HighLight( DC );
|
2011-04-05 17:49:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return netcode; // HitTest() failed.
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
void PCB_EDIT_FRAME::HighLight( wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-09-14 20:04:58 +00:00
|
|
|
if( GetBoard()->IsHighLightNetON() )
|
|
|
|
GetBoard()->HighLightOFF();
|
2011-04-05 17:49:14 +00:00
|
|
|
else
|
2011-09-14 20:04:58 +00:00
|
|
|
GetBoard()->HighLightON();
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
GetBoard()->DrawHighLight( m_canvas, DC, GetBoard()->GetHighLightNetCode() );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2014-01-08 14:18:51 +00:00
|
|
|
|
|
|
|
void PCB_EDIT_FRAME::HighlightUnconnectedPads( wxDC* DC )
|
|
|
|
{
|
|
|
|
for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ )
|
|
|
|
{
|
|
|
|
RATSNEST_ITEM* net = &GetBoard()->m_FullRatsnest[ii];
|
|
|
|
|
|
|
|
if( (net->m_Status & CH_ACTIF) == 0 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
net->m_PadStart->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT );
|
|
|
|
net->m_PadEnd->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT );
|
|
|
|
}
|
|
|
|
}
|