2011-10-11 09:38:13 -04:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-11 09:38:13 -04: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
|
|
|
|
*/
|
|
|
|
|
2022-03-16 10:54:30 +00:00
|
|
|
#ifndef SCH_JUNCTION_H
|
|
|
|
#define SCH_JUNCTION_H
|
2009-01-02 17:07:50 +00:00
|
|
|
|
|
|
|
|
2019-05-10 20:57:24 +01:00
|
|
|
#include <sch_item.h>
|
2020-06-24 13:35:33 -04:00
|
|
|
#include <gal/color4d.h>
|
2020-11-10 18:07:35 +00:00
|
|
|
#include <geometry/shape_circle.h>
|
2020-06-24 13:35:33 -04:00
|
|
|
|
2013-09-25 21:09:57 +02:00
|
|
|
class NETLIST_OBJECT_LIST;
|
2009-01-02 17:07:50 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
class SCH_JUNCTION : public SCH_ITEM
|
2009-01-02 17:07:50 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-01-01 01:04:08 -05:00
|
|
|
SCH_JUNCTION( const VECTOR2I& aPosition = VECTOR2I( 0, 0 ), int aDiameter = 0,
|
2020-06-24 13:35:33 -04:00
|
|
|
SCH_LAYER_ID aLayer = LAYER_JUNCTION );
|
2010-12-21 10:13:09 -05:00
|
|
|
|
2012-01-09 15:26:55 -05:00
|
|
|
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
2010-12-21 10:13:09 -05:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
~SCH_JUNCTION() { }
|
2009-01-02 17:07:50 +00:00
|
|
|
|
2019-08-29 07:59:36 -07:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return aItem && SCH_JUNCTION_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
2016-09-25 19:06:49 +02:00
|
|
|
wxString GetClass() const override
|
2009-01-02 17:07:50 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
return wxT( "SCH_JUNCTION" );
|
2009-01-02 17:07:50 +00:00
|
|
|
}
|
|
|
|
|
2025-03-26 10:13:47 -04:00
|
|
|
void swapData( SCH_ITEM* aItem ) override;
|
2011-10-19 16:32:21 -04:00
|
|
|
|
2021-11-28 17:08:30 +00:00
|
|
|
void SetLastResolvedState( const SCH_ITEM* aItem ) override
|
|
|
|
{
|
|
|
|
const SCH_JUNCTION* aJunction = dynamic_cast<const SCH_JUNCTION*>( aItem );
|
|
|
|
|
|
|
|
if( aJunction )
|
|
|
|
{
|
|
|
|
m_lastResolvedDiameter = aJunction->m_lastResolvedDiameter;
|
|
|
|
m_lastResolvedColor = aJunction->m_lastResolvedColor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-21 13:18:36 -08:00
|
|
|
std::vector<int> ViewGetLayers() const override;
|
2018-10-21 13:50:31 +01:00
|
|
|
|
2022-08-31 10:15:42 +01:00
|
|
|
const BOX2I GetBoundingBox() const override;
|
2009-01-02 17:07:50 +00:00
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
void Move( const VECTOR2I& aMoveVector ) override
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
2011-12-07 15:19:29 -05:00
|
|
|
m_pos += aMoveVector;
|
2009-07-27 14:32:40 +00:00
|
|
|
}
|
|
|
|
|
2021-02-16 20:45:25 +00:00
|
|
|
void MirrorHorizontally( int aCenter ) override;
|
|
|
|
void MirrorVertically( int aCenter ) override;
|
2024-04-04 23:51:22 +01:00
|
|
|
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
|
2009-07-27 14:32:40 +00:00
|
|
|
|
2016-09-24 14:53:15 -04:00
|
|
|
void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;
|
2010-11-03 10:13:15 -04:00
|
|
|
|
2016-09-25 19:06:49 +02:00
|
|
|
bool IsConnectable() const override { return true; }
|
2011-01-07 14:24:24 -05:00
|
|
|
|
2024-03-09 08:50:26 -05:00
|
|
|
bool HasConnectivityChanges( const SCH_ITEM* aItem,
|
|
|
|
const SCH_SHEET_PATH* aInstance = nullptr ) const override;
|
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
std::vector<VECTOR2I> GetConnectionPoints() const override;
|
2010-11-03 10:13:15 -04:00
|
|
|
|
2017-12-19 09:45:56 -08:00
|
|
|
bool CanConnect( const SCH_ITEM* aItem ) const override
|
|
|
|
{
|
2022-03-16 10:54:30 +00:00
|
|
|
return aItem->IsConnectable() && ( aItem->Type() == SCH_LINE_T
|
2023-08-26 15:59:06 +01:00
|
|
|
|| aItem->Type() == SCH_SYMBOL_T
|
|
|
|
|| aItem->Type() == SCH_LABEL_T
|
|
|
|
|| aItem->Type() == SCH_GLOBAL_LABEL_T
|
|
|
|
|| aItem->Type() == SCH_HIER_LABEL_T
|
|
|
|
|| aItem->Type() == SCH_DIRECTIVE_LABEL_T );
|
2017-12-19 09:45:56 -08:00
|
|
|
}
|
|
|
|
|
2024-06-27 10:11:55 +01:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override
|
2018-04-10 11:52:12 +01:00
|
|
|
{
|
|
|
|
return wxString( _( "Junction" ) );
|
|
|
|
}
|
2011-03-25 15:16:05 -04:00
|
|
|
|
2021-03-07 21:59:07 -05:00
|
|
|
BITMAPS GetMenuImage() const override;
|
2011-03-25 15:16:05 -04:00
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
VECTOR2I GetPosition() const override { return m_pos; }
|
|
|
|
void SetPosition( const VECTOR2I& aPosition ) override { m_pos = aPosition; }
|
2012-03-15 10:31:16 -04:00
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override { return false; }
|
2020-10-01 23:53:47 +00:00
|
|
|
|
2021-08-31 11:48:45 +01:00
|
|
|
int GetEffectiveDiameter() const;
|
|
|
|
|
|
|
|
int GetDiameter() const { return m_diameter; }
|
2022-03-16 13:43:19 +00:00
|
|
|
void SetDiameter( int aDiameter );
|
2020-06-24 13:35:33 -04:00
|
|
|
|
2020-11-03 13:39:31 +00:00
|
|
|
COLOR4D GetJunctionColor() const;
|
|
|
|
|
|
|
|
COLOR4D GetColor() const { return m_color; }
|
2022-03-16 13:43:19 +00:00
|
|
|
void SetColor( const COLOR4D& aColor );
|
2020-06-24 13:35:33 -04:00
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
|
2022-08-31 10:33:46 +01:00
|
|
|
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2025-09-03 06:45:49 -07:00
|
|
|
bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
|
2012-03-15 10:31:16 -04:00
|
|
|
|
2024-04-05 22:35:32 +01:00
|
|
|
void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
|
|
|
|
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
|
2012-03-15 10:31:16 -04:00
|
|
|
|
2016-09-24 14:53:15 -04:00
|
|
|
EDA_ITEM* Clone() const override;
|
2012-03-17 10:39:27 -04:00
|
|
|
|
2020-05-08 16:01:14 -04:00
|
|
|
virtual bool operator <( const SCH_ITEM& aItem ) const override;
|
|
|
|
|
2023-04-24 12:25:10 +02:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
|
|
|
|
2023-09-14 14:39:42 -07:00
|
|
|
double Similarity( const SCH_ITEM& aOther ) const override;
|
|
|
|
|
|
|
|
bool operator==( const SCH_ITEM& aOther ) const override;
|
|
|
|
|
2009-01-02 17:07:50 +00:00
|
|
|
#if defined(DEBUG)
|
2016-09-25 19:06:49 +02:00
|
|
|
void Show( int nestLevel, std::ostream& os ) const override;
|
2009-01-02 17:07:50 +00:00
|
|
|
#endif
|
2010-12-10 14:47:44 -05:00
|
|
|
|
|
|
|
private:
|
2022-01-01 01:04:08 -05:00
|
|
|
bool doIsConnected( const VECTOR2I& aPosition ) const override;
|
2020-11-10 18:07:35 +00:00
|
|
|
|
|
|
|
SHAPE_CIRCLE getEffectiveShape() const;
|
2021-03-25 10:07:16 -04:00
|
|
|
|
2022-03-16 10:54:30 +00:00
|
|
|
private:
|
|
|
|
VECTOR2I m_pos;
|
|
|
|
int m_diameter; ///< Zero is user default.
|
|
|
|
COLOR4D m_color; ///< #COLOR4D::UNSPECIFIED is user default.
|
|
|
|
|
|
|
|
// If real-time connectivity gets disabled (due to being too slow on a particular design),
|
|
|
|
// we can no longer rely on getting the NetClass to find netclass-specific linestyles,
|
|
|
|
// linewidths and colors.
|
|
|
|
mutable int m_lastResolvedDiameter;
|
|
|
|
mutable COLOR4D m_lastResolvedColor;
|
2009-01-02 17:07:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-03-16 10:54:30 +00:00
|
|
|
#endif // SCH_JUNCTION_H
|