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>
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <kicad_string.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>
|
|
|
|
#include <track.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
/*********************************************************/
|
2009-05-25 11:53:55 +00:00
|
|
|
/* class NETINFO_ITEM: handle data relative to a given net */
|
2007-08-08 03:50:44 +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 ) :
|
|
|
|
BOARD_ITEM( aParent, PCB_NETINFO_T ),
|
2018-10-18 09:35:59 +00:00
|
|
|
m_NetCode( aNetCode ),
|
|
|
|
m_isCurrent( true ),
|
|
|
|
m_Netname( aNetName ),
|
|
|
|
m_ShortNetname( m_Netname.AfterLast( '/' ) )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2017-07-28 14:03:15 +00:00
|
|
|
m_parent = aParent;
|
|
|
|
|
|
|
|
if( aParent )
|
2020-05-31 21:42:04 +00:00
|
|
|
m_NetClass = aParent->GetDesignSettings().GetNetClasses().GetDefault();
|
2017-07-28 14:03:15 +00:00
|
|
|
else
|
|
|
|
m_NetClass = std::make_shared<NETCLASS>( "<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
|
|
|
|
2017-09-23 09:20:10 +00:00
|
|
|
void NETINFO_ITEM::SetClass( const NETCLASSPTR& aNetClass )
|
2017-07-28 14:03:15 +00:00
|
|
|
{
|
|
|
|
wxCHECK( m_parent, /* void */ );
|
2020-05-31 21:42:04 +00:00
|
|
|
m_NetClass = aNetClass ? aNetClass : m_parent->GetDesignSettings().GetNetClasses().GetDefault();
|
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
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Net Code" ), wxString::Format( "%d", GetNet() ) );
|
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
|
2015-01-23 11:24:32 +00:00
|
|
|
BOARD * board = m_parent ? m_parent->GetBoard() : NULL;
|
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
if( board )
|
2009-05-21 14:59:54 +00:00
|
|
|
{
|
2020-11-30 14:35:48 +00:00
|
|
|
int count = 0;
|
|
|
|
double lengthNet = 0.0; // This is the length of tracks on pcb
|
|
|
|
double lengthPadToDie = 0.0; // this is the length of internal ICs connections
|
|
|
|
|
|
|
|
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-11-30 14:35:48 +00:00
|
|
|
if( pad->GetNetCode() == GetNet() )
|
|
|
|
{
|
|
|
|
count++;
|
|
|
|
lengthPadToDie += pad->GetPadToDieLength();
|
|
|
|
}
|
2011-06-30 06:02:07 +00:00
|
|
|
}
|
2009-05-21 14:59:54 +00:00
|
|
|
}
|
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Pads" ), wxString::Format( "%d", count ) );
|
2009-05-21 14:59:54 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
count = 0;
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
for( TRACK* track : board->Tracks() )
|
2011-10-01 19:24:27 +00:00
|
|
|
{
|
2020-11-30 14:35:48 +00:00
|
|
|
if( track->Type() == PCB_VIA_T )
|
|
|
|
{
|
|
|
|
if( track->GetNetCode() == GetNet() )
|
|
|
|
count++;
|
|
|
|
}
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
if( track->Type() == PCB_TRACE_T )
|
|
|
|
{
|
|
|
|
if( track->GetNetCode() == GetNet() )
|
|
|
|
lengthNet += track->GetLength();
|
|
|
|
}
|
2011-10-01 19:24:27 +00:00
|
|
|
}
|
2009-05-21 14:59:54 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Vias" ), wxString::Format( "%d", count ) );
|
2009-05-21 14:59:54 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
// Displays the full net length (tracks on pcb + internal ICs connections ):
|
|
|
|
msg = MessageTextFromValue( aFrame->GetUserUnits(), lengthNet + lengthPadToDie );
|
|
|
|
aList.emplace_back( _( "Net Length" ), msg );
|
2011-06-30 06:02:07 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
// Displays the net length of tracks only:
|
|
|
|
msg = MessageTextFromValue( aFrame->GetUserUnits(), lengthNet );
|
|
|
|
aList.emplace_back( _( "On Board" ), msg );
|
2011-06-30 06:02:07 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
// Displays the net length of internal ICs connections (wires inside ICs):
|
|
|
|
msg = MessageTextFromValue( aFrame->GetUserUnits(), lengthPadToDie );
|
|
|
|
aList.emplace_back( _( "In Package" ), msg );
|
|
|
|
}
|
2017-04-25 09:06:24 +00:00
|
|
|
}
|