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
|
2023-02-09 17:18:56 +00:00
|
|
|
* Copyright (C) 2019-2023 KiCad Developers, see AUTHOR.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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SCH_PIN_CONNECTION_H
|
|
|
|
#define _SCH_PIN_CONNECTION_H
|
|
|
|
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <lib_pin.h>
|
2019-05-10 19:57:24 +00:00
|
|
|
#include <sch_item.h>
|
2019-03-11 21:32:05 +00:00
|
|
|
#include <sch_sheet_path.h>
|
|
|
|
|
2019-04-10 05:29:00 +00:00
|
|
|
#include <mutex>
|
|
|
|
#include <map>
|
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
class SCH_SYMBOL;
|
2021-09-26 23:22:32 +00:00
|
|
|
class MSG_PANEL_ITEM;
|
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-04-03 09:14:36 +00:00
|
|
|
class SCH_PIN : public SCH_ITEM
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_PIN( LIB_PIN* aLibPin, SCH_SYMBOL* aParentSymbol );
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_PIN( SCH_SYMBOL* aParentSymbol, const wxString& aNumber, const wxString& aAlt );
|
2020-10-28 12:59:59 +00:00
|
|
|
|
2019-04-03 09:14:36 +00:00
|
|
|
SCH_PIN( const SCH_PIN& aPin );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-04-22 10:14:47 +00:00
|
|
|
SCH_PIN& operator=( const SCH_PIN& aPin );
|
|
|
|
|
2019-08-29 14:59:36 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return aItem && SCH_PIN_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
wxString GetClass() const override
|
|
|
|
{
|
2019-04-03 09:14:36 +00:00
|
|
|
return wxT( "SCH_PIN" );
|
2019-03-11 21:32:05 +00:00
|
|
|
}
|
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* GetParentSymbol() const;
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2019-04-22 10:14:47 +00:00
|
|
|
LIB_PIN* GetLibPin() const { return m_libPin; }
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2020-08-13 21:30:30 +00:00
|
|
|
void ClearDefaultNetName( const SCH_SHEET_PATH* aPath );
|
2021-01-15 01:55:39 +00:00
|
|
|
wxString GetDefaultNetName( const SCH_SHEET_PATH& aPath, bool aForceNoConnect = false );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2020-08-21 15:54:24 +00:00
|
|
|
wxString GetAlt() const { return m_alt; }
|
|
|
|
void SetAlt( const wxString& aAlt ) { m_alt = aAlt; }
|
|
|
|
|
2022-07-23 22:26:03 +00:00
|
|
|
const BOX2I ViewBBox() const override;
|
|
|
|
|
2021-12-06 18:50:00 +00:00
|
|
|
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
|
|
|
|
2023-01-12 03:27:44 +00:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
|
2021-09-26 23:22:32 +00:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override {}
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void Move( const VECTOR2I& aMoveVector ) override {}
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2021-02-16 20:45:25 +00:00
|
|
|
void MirrorHorizontally( int aCenter ) override {}
|
|
|
|
void MirrorVertically( int aCenter ) override {}
|
2022-01-01 06:04:08 +00:00
|
|
|
void Rotate( const VECTOR2I& aCenter ) override {}
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetPosition() const override { return GetTransformedPosition(); }
|
|
|
|
const VECTOR2I GetLocalPosition() const { return m_position; }
|
|
|
|
void SetPosition( const VECTOR2I& aPosition ) override { m_position = aPosition; }
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2022-07-03 17:21:59 +00:00
|
|
|
/* Cannot use a default parameter here as it will not be compatible with the virtual. */
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I GetBoundingBox() const override { return GetBoundingBox( false, true, false ); }
|
2022-07-03 17:21:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aIncludeInvisibles - if false, do not include labels for invisible pins
|
|
|
|
* in the calculation.
|
|
|
|
*/
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNameAndNumber,
|
|
|
|
bool aIncludeElectricalType ) const;
|
2022-07-03 17:21:59 +00:00
|
|
|
|
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
|
2022-08-31 09:33:46 +00:00
|
|
|
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2021-11-28 18:37:13 +00:00
|
|
|
EDA_ITEM* Clone() const override;
|
|
|
|
|
2021-11-24 13:19:50 +00:00
|
|
|
bool IsConnectable() const override { return true; }
|
|
|
|
|
2021-12-12 21:37:06 +00:00
|
|
|
bool IsDangling() const override
|
|
|
|
{
|
|
|
|
if( GetType() == ELECTRICAL_PINTYPE::PT_NC || GetType() == ELECTRICAL_PINTYPE::PT_NIC )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return m_isDangling;
|
|
|
|
}
|
|
|
|
|
2019-04-03 09:14:36 +00:00
|
|
|
void SetIsDangling( bool isDangling ) { m_isDangling = isDangling; }
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2023-09-22 18:25:53 +00:00
|
|
|
void SetLibPin( LIB_PIN* aLibPin ) { m_libPin = aLibPin; }
|
|
|
|
|
2022-09-10 00:17:42 +00:00
|
|
|
/**
|
|
|
|
* @param aPin Comparison Pin
|
|
|
|
* @return True if aPin is stacked with this pin
|
|
|
|
*/
|
|
|
|
bool IsStacked( const SCH_PIN* aPin ) const;
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
|
2021-03-25 21:13:01 +00:00
|
|
|
{
|
|
|
|
return m_isDangling && GetPosition() == aPos;
|
|
|
|
}
|
2020-10-01 23:53:47 +00:00
|
|
|
|
2021-03-25 21:13:01 +00:00
|
|
|
/// @return the pin's position in global coordinates.
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetTransformedPosition() const;
|
2019-04-04 02:40:14 +00:00
|
|
|
|
2022-08-05 02:40:38 +00:00
|
|
|
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2022-08-05 02:40:38 +00:00
|
|
|
bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override;
|
2020-08-03 21:12:29 +00:00
|
|
|
|
2019-04-03 09:14:36 +00:00
|
|
|
/*
|
|
|
|
* While many of these are currently simply covers for the equivalent LIB_PIN methods,
|
2021-03-25 21:13:01 +00:00
|
|
|
* the new Eeschema file format will soon allow us to override them at the schematic level.
|
2019-04-03 09:14:36 +00:00
|
|
|
*/
|
2019-04-22 10:14:47 +00:00
|
|
|
bool IsVisible() const { return m_libPin->IsVisible(); }
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2020-08-21 15:54:24 +00:00
|
|
|
wxString GetName() const;
|
2021-06-12 18:54:34 +00:00
|
|
|
wxString GetShownName() const;
|
2020-08-21 15:54:24 +00:00
|
|
|
|
2020-08-31 19:09:07 +00:00
|
|
|
wxString GetNumber() const { return m_number; }
|
2021-06-17 09:37:13 +00:00
|
|
|
wxString GetShownNumber() const;
|
2021-06-12 18:54:34 +00:00
|
|
|
|
2020-08-21 15:54:24 +00:00
|
|
|
void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
|
|
|
|
|
|
|
|
ELECTRICAL_PINTYPE GetType() const;
|
|
|
|
|
2021-01-21 21:46:03 +00:00
|
|
|
wxString GetCanonicalElectricalTypeName() const
|
|
|
|
{
|
|
|
|
return LIB_PIN::GetCanonicalElectricalTypeName( GetType() );
|
|
|
|
}
|
|
|
|
|
2020-08-21 15:54:24 +00:00
|
|
|
GRAPHIC_PINSHAPE GetShape() const;
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
PIN_ORIENTATION GetOrientation() const;
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2020-08-21 15:54:24 +00:00
|
|
|
int GetLength() const;
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2023-01-18 15:06:46 +00:00
|
|
|
bool IsGlobalPower() const { return m_libPin->IsGlobalPower(); }
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2020-07-07 00:10:08 +00:00
|
|
|
bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const override;
|
|
|
|
|
2023-02-09 17:18:56 +00:00
|
|
|
const wxString& GetOperatingPoint() const { return m_operatingPoint; }
|
|
|
|
void SetOperatingPoint( const wxString& aText ) { m_operatingPoint = aText; }
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2023-09-14 21:39:42 +00:00
|
|
|
double Similarity( const SCH_ITEM& aItem ) const override;
|
|
|
|
|
|
|
|
bool operator==( const SCH_ITEM& aItem ) const override;
|
|
|
|
|
2019-04-03 09:14:36 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
void Show( int nestLevel, std::ostream& os ) const override {}
|
|
|
|
#endif
|
2021-03-25 21:13:01 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
LIB_PIN* m_libPin;
|
|
|
|
|
|
|
|
wxString m_number;
|
|
|
|
wxString m_alt;
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I m_position;
|
2021-03-25 21:13:01 +00:00
|
|
|
bool m_isDangling;
|
|
|
|
|
|
|
|
/// The name that this pin connection will drive onto a net.
|
|
|
|
std::recursive_mutex m_netmap_mutex;
|
|
|
|
std::map<const SCH_SHEET_PATH, std::pair<wxString, bool>> m_net_name_map;
|
2023-02-09 17:18:56 +00:00
|
|
|
|
|
|
|
wxString m_operatingPoint;
|
2019-03-11 21:32:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|