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>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <kicad_device_context.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-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
|
|
|
|
2018-10-06 02:58:25 +00:00
|
|
|
m_Collector->Collect( GetBoard(), GENERAL_COLLECTOR::PadsOrTracks,
|
2013-08-03 05:15:23 +00:00
|
|
|
RefPos( true ), guide );
|
2007-12-13 06:24:09 +00:00
|
|
|
|
2018-10-06 02:58:25 +00:00
|
|
|
if( m_Collector->GetCount() == 0 )
|
|
|
|
m_Collector->Collect( GetBoard(), GENERAL_COLLECTOR::Zones,
|
|
|
|
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:
|
2014-02-25 10:40:34 +00:00
|
|
|
netcode = ( (D_PAD*) item )->GetNetCode();
|
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:
|
2018-09-29 17:58:31 +00:00
|
|
|
case PCB_SEGZONE_T:
|
2007-12-13 14:21:50 +00:00
|
|
|
// since these classes are all derived from TRACK, use a common
|
|
|
|
// GetNet() function:
|
2014-02-25 10:40:34 +00:00
|
|
|
netcode = ( (TRACK*) item )->GetNetCode();
|
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_ZONE_AREA_T:
|
2014-02-25 10:40:34 +00:00
|
|
|
netcode = ( (ZONE_CONTAINER*) item )->GetNetCode();
|
2011-04-05 17:49:14 +00:00
|
|
|
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
|
|
|
}
|