2012-06-08 09:56:42 +00:00
|
|
|
/**
|
|
|
|
* @brief NETINFO_ITEM class, to handle info on nets: netnames, net constraints
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2021-07-19 23:56:05 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-06-08 09:56:42 +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
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2018-01-29 15:39:40 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2020-10-25 04:49:02 +00:00
|
|
|
#include <widgets/msgpanel.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <base_units.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2022-03-10 23:12:30 +00:00
|
|
|
#include <connectivity/connectivity_data.h>
|
2021-06-03 18:05:43 +00:00
|
|
|
#include <footprint.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2021-06-03 18:05:43 +00:00
|
|
|
#include <pad.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2016-01-29 10:21:13 +00:00
|
|
|
NETINFO_ITEM::NETINFO_ITEM( BOARD* aParent, const wxString& aNetName, int aNetCode ) :
|
2020-12-08 12:28:26 +00:00
|
|
|
BOARD_ITEM( aParent, PCB_NETINFO_T ),
|
|
|
|
m_netCode( aNetCode ),
|
|
|
|
m_netname( aNetName ),
|
2020-12-08 17:28:03 +00:00
|
|
|
m_shortNetname( m_netname.AfterLast( '/' ) ),
|
2023-01-27 16:35:23 +00:00
|
|
|
m_unescapedShortNetname( UnescapeString( m_shortNetname ) ),
|
2020-12-08 17:28:03 +00:00
|
|
|
m_isCurrent( true )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2017-07-28 14:03:15 +00:00
|
|
|
m_parent = aParent;
|
|
|
|
|
|
|
|
if( aParent )
|
2022-08-14 11:03:18 +00:00
|
|
|
m_netClass = aParent->GetDesignSettings().m_NetSettings->m_DefaultNetClass;
|
2017-07-28 14:03:15 +00:00
|
|
|
else
|
2022-02-04 22:44:59 +00:00
|
|
|
m_netClass = std::make_shared<NETCLASS>( wxT( "<invalid>" ) );
|
2009-08-17 02:59:38 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2009-05-24 18:28:36 +00:00
|
|
|
NETINFO_ITEM::~NETINFO_ITEM()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-08-17 02:59:38 +00:00
|
|
|
// m_NetClass is not owned by me.
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2022-08-14 11:03:18 +00:00
|
|
|
void NETINFO_ITEM::Clear()
|
|
|
|
{
|
2023-12-11 03:59:36 +00:00
|
|
|
wxCHECK( m_parent, /* void */ );
|
2022-08-14 11:03:18 +00:00
|
|
|
m_netClass = m_parent->GetDesignSettings().m_NetSettings->m_DefaultNetClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void NETINFO_ITEM::SetNetClass( const std::shared_ptr<NETCLASS>& aNetClass )
|
2017-07-28 14:03:15 +00:00
|
|
|
{
|
|
|
|
wxCHECK( m_parent, /* void */ );
|
2022-08-14 11:03:18 +00:00
|
|
|
|
|
|
|
if( aNetClass )
|
|
|
|
m_netClass = aNetClass;
|
|
|
|
else
|
|
|
|
m_netClass = m_parent->GetDesignSettings().m_NetSettings->m_DefaultNetClass;
|
2017-07-28 14:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
void NETINFO_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
2009-05-21 14:59:54 +00:00
|
|
|
{
|
2020-11-30 14:35:48 +00:00
|
|
|
wxString msg;
|
2009-05-21 14:59:54 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Net Name" ), UnescapeString( GetNetname() ) );
|
2009-05-21 14:59:54 +00:00
|
|
|
|
2022-02-04 22:44:59 +00:00
|
|
|
aList.emplace_back( _( "Net Code" ), wxString::Format( wxT( "%d" ), GetNetCode() ) );
|
2009-05-21 14:59:54 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
// Warning: for netcode == NETINFO_LIST::ORPHANED, the parent or the board can be NULL
|
2021-07-19 23:56:05 +00:00
|
|
|
BOARD * board = m_parent ? m_parent->GetBoard() : nullptr;
|
2015-01-23 11:24:32 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
if( board )
|
2009-05-21 14:59:54 +00:00
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
int count = 0;
|
|
|
|
PCB_TRACK* startTrack = nullptr;
|
2020-11-30 14:35:48 +00:00
|
|
|
|
|
|
|
for( FOOTPRINT* footprint : board->Footprints() )
|
2009-05-21 14:59:54 +00:00
|
|
|
{
|
2020-11-30 14:35:48 +00:00
|
|
|
for( PAD* pad : footprint->Pads() )
|
2011-06-30 06:02:07 +00:00
|
|
|
{
|
2020-12-08 13:02:08 +00:00
|
|
|
if( pad->GetNetCode() == GetNetCode() )
|
2020-11-30 14:35:48 +00:00
|
|
|
count++;
|
2011-06-30 06:02:07 +00:00
|
|
|
}
|
2009-05-21 14:59:54 +00:00
|
|
|
}
|
|
|
|
|
2022-02-04 22:44:59 +00:00
|
|
|
aList.emplace_back( _( "Pads" ), wxString::Format( wxT( "%d" ), count ) );
|
2009-05-21 14:59:54 +00:00
|
|
|
|
2021-04-04 16:27:09 +00:00
|
|
|
count = 0;
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
for( PCB_TRACK* track : board->Tracks() )
|
2011-10-01 19:24:27 +00:00
|
|
|
{
|
2021-04-04 16:27:09 +00:00
|
|
|
if( track->GetNetCode() == GetNetCode() )
|
2020-11-30 14:35:48 +00:00
|
|
|
{
|
2021-04-04 16:27:09 +00:00
|
|
|
if( track->Type() == PCB_VIA_T )
|
2020-11-30 14:35:48 +00:00
|
|
|
count++;
|
2021-04-04 16:27:09 +00:00
|
|
|
else if( !startTrack )
|
|
|
|
startTrack = track;
|
2020-11-30 14:35:48 +00:00
|
|
|
}
|
2011-10-01 19:24:27 +00:00
|
|
|
}
|
2009-05-21 14:59:54 +00:00
|
|
|
|
2022-02-04 22:44:59 +00:00
|
|
|
aList.emplace_back( _( "Vias" ), wxString::Format( wxT( "%d" ), count ) );
|
2009-05-21 14:59:54 +00:00
|
|
|
|
2021-04-04 16:27:09 +00:00
|
|
|
if( startTrack )
|
|
|
|
{
|
|
|
|
double lengthNet = 0.0; // This is the length of tracks on pcb
|
|
|
|
double lengthPadToDie = 0.0; // this is the length of internal ICs connections
|
2011-06-30 06:02:07 +00:00
|
|
|
|
2021-04-04 16:27:09 +00:00
|
|
|
std::tie( count, lengthNet, lengthPadToDie ) = board->GetTrackLength( *startTrack );
|
2011-06-30 06:02:07 +00:00
|
|
|
|
2021-04-04 16:27:09 +00:00
|
|
|
// Displays the full net length (tracks on pcb + internal ICs connections ):
|
2022-09-19 09:25:20 +00:00
|
|
|
aList.emplace_back( _( "Net Length" ),
|
|
|
|
aFrame->MessageTextFromValue( lengthNet + lengthPadToDie ) );
|
2021-04-04 16:27:09 +00:00
|
|
|
|
|
|
|
// Displays the net length of tracks only:
|
2022-09-19 09:25:20 +00:00
|
|
|
aList.emplace_back( _( "On Board" ), aFrame->MessageTextFromValue( lengthNet ) );
|
2021-04-04 16:27:09 +00:00
|
|
|
|
|
|
|
// Displays the net length of internal ICs connections (wires inside ICs):
|
2022-09-19 09:25:20 +00:00
|
|
|
aList.emplace_back( _( "In Package" ), aFrame->MessageTextFromValue( lengthPadToDie ) );
|
2021-04-04 16:27:09 +00:00
|
|
|
}
|
2020-11-30 14:35:48 +00:00
|
|
|
}
|
2017-04-25 09:06:24 +00:00
|
|
|
}
|
2022-03-10 23:12:30 +00:00
|
|
|
|
|
|
|
|
2022-08-05 02:40:38 +00:00
|
|
|
bool NETINFO_ITEM::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
|
2022-03-10 23:12:30 +00:00
|
|
|
{
|
|
|
|
return BOARD_ITEM::Matches( GetNetname(), aSearchData );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I NETINFO_ITEM::GetBoundingBox() const
|
2022-03-10 23:12:30 +00:00
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
std::shared_ptr<CONNECTIVITY_DATA> conn = GetBoard()->GetConnectivity();
|
2022-08-31 09:15:42 +00:00
|
|
|
BOX2I bbox;
|
2022-03-10 23:12:30 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
for( BOARD_ITEM* item : conn->GetNetItems( m_netCode, { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T,
|
|
|
|
PCB_ZONE_T, PCB_PAD_T } ) )
|
2022-03-10 23:12:30 +00:00
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
bbox.Merge( item->GetBoundingBox() );
|
2022-03-10 23:12:30 +00:00
|
|
|
}
|
2022-08-20 09:27:35 +00:00
|
|
|
|
2022-03-10 23:12:30 +00:00
|
|
|
return bbox;
|
2023-12-11 03:59:36 +00:00
|
|
|
}
|