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
|
2019-04-22 10:14:47 +00:00
|
|
|
* Copyright (C) 2019 KiCad Developers, see change_log.txt for contributors.
|
2019-03-11 21:32:05 +00:00
|
|
|
* @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 ) :
|
2019-04-22 10:14:47 +00:00
|
|
|
SCH_ITEM( aParentComponent, SCH_PIN_T ),
|
|
|
|
m_libPin( aLibPin )
|
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 ) :
|
2019-04-22 10:14:47 +00:00
|
|
|
SCH_ITEM( aPin )
|
2019-04-03 09:14:36 +00:00
|
|
|
{
|
2019-04-22 10:14:47 +00:00
|
|
|
m_libPin = aPin.m_libPin;
|
2019-04-03 09:14:36 +00:00
|
|
|
m_position = aPin.m_position;
|
|
|
|
m_isDangling = aPin.m_isDangling;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-22 10:14:47 +00:00
|
|
|
SCH_PIN& SCH_PIN::operator=( const SCH_PIN& aPin )
|
|
|
|
{
|
|
|
|
SCH_ITEM::operator=( aPin );
|
|
|
|
|
|
|
|
m_libPin = aPin.m_libPin;
|
|
|
|
m_position = aPin.m_position;
|
|
|
|
m_isDangling = aPin.m_isDangling;
|
2019-04-22 23:27:59 +00:00
|
|
|
|
|
|
|
return *this;
|
2019-04-22 10:14:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-30 13:39:31 +00:00
|
|
|
bool SCH_PIN::Matches( wxFindReplaceData& aSearchData, void* aAuxData )
|
|
|
|
{
|
|
|
|
return m_libPin->Matches( aSearchData, aAuxData );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-22 10:14:47 +00:00
|
|
|
SCH_COMPONENT* SCH_PIN::GetParentComponent() const
|
|
|
|
{
|
|
|
|
return static_cast<SCH_COMPONENT*>( GetParent() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-03 09:14:36 +00:00
|
|
|
wxString SCH_PIN::GetSelectMenuText( EDA_UNITS_T aUnits ) const
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
2019-04-22 10:14:47 +00:00
|
|
|
return wxString::Format( "%s %s",
|
|
|
|
GetParentComponent()->GetSelectMenuText( aUnits ),
|
|
|
|
m_libPin->GetSelectMenuText( aUnits ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_PIN::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList )
|
|
|
|
{
|
|
|
|
m_libPin->GetMsgPanelInfo( aUnits, aList, GetParentComponent() );
|
2019-03-11 21:32:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2019-04-22 10:14:47 +00:00
|
|
|
if( m_libPin->IsPowerConnection() )
|
|
|
|
return m_libPin->GetName();
|
2019-03-11 21:32:05 +00:00
|
|
|
|
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-04-22 10:14:47 +00:00
|
|
|
name << GetParentComponent()->GetRef( &aPath );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-05-19 15:40:14 +00:00
|
|
|
bool annotated = true;
|
|
|
|
|
|
|
|
// Add timestamp for uninitialized components
|
|
|
|
if( name.Last() == '?' )
|
|
|
|
{
|
2019-04-22 10:14:47 +00:00
|
|
|
name << GetParentComponent()->GetTimeStamp();
|
2019-05-19 15:40:14 +00:00
|
|
|
annotated = false;
|
|
|
|
}
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-04-22 10:14:47 +00:00
|
|
|
name << "-Pad" << m_libPin->GetNumber() << ")";
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-05-19 15:40:14 +00:00
|
|
|
if( annotated )
|
|
|
|
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
|
|
|
|
{
|
2019-04-22 10:14:47 +00:00
|
|
|
TRANSFORM t = GetParentComponent()->GetTransform();
|
|
|
|
return ( t.TransformCoordinate( GetPosition() ) + GetParentComponent()->GetPosition() );
|
2019-04-04 02:40:14 +00:00
|
|
|
}
|
2019-04-22 10:14:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
const EDA_RECT SCH_PIN::GetBoundingBox() const
|
|
|
|
{
|
2019-04-23 17:40:29 +00:00
|
|
|
TRANSFORM t = GetParentComponent()->GetTransform();
|
|
|
|
EDA_RECT r = m_libPin->GetBoundingBox();
|
|
|
|
|
2019-09-08 21:54:13 +00:00
|
|
|
r.RevertYAxis();
|
|
|
|
|
2019-04-23 17:40:29 +00:00
|
|
|
r = t.TransformCoordinate( r );
|
|
|
|
r.Offset( GetParentComponent()->GetPosition() );
|
2019-04-22 10:14:47 +00:00
|
|
|
|
2019-04-23 17:40:29 +00:00
|
|
|
return r;
|
2019-04-22 10:14:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-05 10:33:34 +00:00
|
|
|
bool SCH_PIN::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
2019-04-22 10:14:47 +00:00
|
|
|
{
|
2019-05-05 10:33:34 +00:00
|
|
|
EDA_RECT rect = GetBoundingBox();
|
|
|
|
return rect.Inflate( aAccuracy ).Contains( aPosition );
|
2019-04-22 10:14:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|