2019-03-11 21:32:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 CERN
|
|
|
|
* @author Jon Evans <jon@craftyjon.com>
|
|
|
|
*
|
|
|
|
* 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <lib_pin.h>
|
|
|
|
#include <sch_component.h>
|
2019-04-03 09:14:36 +00:00
|
|
|
#include <sch_pin.h>
|
2019-03-11 21:32:05 +00:00
|
|
|
#include <sch_sheet_path.h>
|
|
|
|
|
|
|
|
|
2019-04-03 09:14:36 +00:00
|
|
|
SCH_PIN::SCH_PIN( LIB_PIN* aLibPin, SCH_COMPONENT* aParentComponent ) :
|
|
|
|
SCH_ITEM( nullptr, SCH_PIN_T ),
|
|
|
|
m_pin( aLibPin ),
|
|
|
|
m_comp( aParentComponent )
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
2019-04-03 09:14:36 +00:00
|
|
|
SetPosition( aLibPin->GetPosition() );
|
|
|
|
m_isDangling = true;
|
2019-03-11 21:32:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-03 09:14:36 +00:00
|
|
|
SCH_PIN::SCH_PIN( const SCH_PIN& aPin ) :
|
|
|
|
SCH_ITEM( aPin )
|
|
|
|
{
|
|
|
|
m_pin = aPin.m_pin;
|
|
|
|
m_comp = aPin.m_comp;
|
|
|
|
m_position = aPin.m_position;
|
|
|
|
m_isDangling = aPin.m_isDangling;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString SCH_PIN::GetSelectMenuText( EDA_UNITS_T aUnits ) const
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
|
|
|
wxString tmp;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2019-04-13 08:12:24 +00:00
|
|
|
tmp.Printf( "SCH_PIN for %s %s",
|
|
|
|
m_comp->GetSelectMenuText( aUnits ),
|
|
|
|
m_pin->GetSelectMenuText( aUnits ) );
|
2019-03-11 21:32:05 +00:00
|
|
|
#else
|
2019-04-13 08:12:24 +00:00
|
|
|
tmp.Printf( "%s %s",
|
|
|
|
m_comp->GetSelectMenuText( aUnits ),
|
|
|
|
m_pin->GetSelectMenuText( aUnits ) );
|
2019-03-11 21:32:05 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-03 09:14:36 +00:00
|
|
|
wxString SCH_PIN::GetDefaultNetName( const SCH_SHEET_PATH aPath )
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
|
|
|
if( m_pin->IsPowerConnection() )
|
|
|
|
return m_pin->GetName();
|
|
|
|
|
2019-04-10 05:29:00 +00:00
|
|
|
std::lock_guard<std::mutex> lock( m_netmap_mutex );
|
|
|
|
|
2019-03-08 00:16:59 +00:00
|
|
|
if( m_net_name_map.count( aPath ) > 0 )
|
|
|
|
return m_net_name_map.at( aPath );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-04-13 08:12:24 +00:00
|
|
|
wxString name = "Net-(";
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-03-08 00:16:59 +00:00
|
|
|
name << m_comp->GetRef( &aPath );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-03-08 00:16:59 +00:00
|
|
|
// TODO(JE) do we need adoptTimestamp?
|
|
|
|
if( /* adoptTimestamp && */ name.Last() == '?' )
|
|
|
|
name << m_comp->GetTimeStamp();
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-04-13 08:12:24 +00:00
|
|
|
name << "-Pad" << m_pin->GetNumber() << ")";
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-03-08 00:16:59 +00:00
|
|
|
m_net_name_map[ aPath ] = name;
|
2019-03-11 21:32:05 +00:00
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-04 02:40:14 +00:00
|
|
|
wxPoint SCH_PIN::GetTransformedPosition() const
|
|
|
|
{
|
|
|
|
auto t = m_comp->GetTransform();
|
|
|
|
return ( t.TransformCoordinate( GetPosition() ) +
|
|
|
|
m_comp->GetPosition() );
|
|
|
|
}
|