2011-10-11 13:38:13 +00: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
|
2024-03-09 13:50:26 +00:00
|
|
|
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-11 13:38:13 +00: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 19:57:24 +00:00
|
|
|
#include <sch_item.h>
|
2020-06-24 17:35:33 +00:00
|
|
|
#include <gal/color4d.h>
|
2020-11-10 18:07:35 +00:00
|
|
|
#include <geometry/shape_circle.h>
|
2020-06-24 17:35:33 +00:00
|
|
|
|
2013-09-25 19:09:57 +00: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 06:04:08 +00:00
|
|
|
SCH_JUNCTION( const VECTOR2I& aPosition = VECTOR2I( 0, 0 ), int aDiameter = 0,
|
2020-06-24 17:35:33 +00:00
|
|
|
SCH_LAYER_ID aLayer = LAYER_JUNCTION );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2012-01-09 20:26:55 +00:00
|
|
|
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
~SCH_JUNCTION() { }
|
2009-01-02 17:07:50 +00:00
|
|
|
|
2019-08-29 14:59:36 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return aItem && SCH_JUNCTION_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
2016-09-25 17:06:49 +00: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
|
|
|
}
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void SwapData( SCH_ITEM* aItem ) override;
|
2011-10-19 20:32:21 +00: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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-21 12:50:31 +00:00
|
|
|
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I GetBoundingBox() const override;
|
2009-01-02 17:07:50 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void Move( const VECTOR2I& aMoveVector ) override
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
2011-12-07 20:19:29 +00: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 22:51:22 +00:00
|
|
|
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
|
2009-07-27 14:32:40 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
bool IsConnectable() const override { return true; }
|
2011-01-07 19:24:24 +00:00
|
|
|
|
2024-03-09 13:50:26 +00:00
|
|
|
bool HasConnectivityChanges( const SCH_ITEM* aItem,
|
|
|
|
const SCH_SHEET_PATH* aInstance = nullptr ) const override;
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
std::vector<VECTOR2I> GetConnectionPoints() const override;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2017-12-19 17:45:56 +00: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 14:59:06 +00: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 17:45:56 +00:00
|
|
|
}
|
|
|
|
|
2023-01-12 03:27:44 +00:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override
|
2018-04-10 10:52:12 +00:00
|
|
|
{
|
|
|
|
return wxString( _( "Junction" ) );
|
|
|
|
}
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS GetMenuImage() const override;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetPosition() const override { return m_pos; }
|
|
|
|
void SetPosition( const VECTOR2I& aPosition ) override { m_pos = aPosition; }
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override { return false; }
|
2020-10-01 23:53:47 +00:00
|
|
|
|
2021-08-31 10:48:45 +00: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 17:35:33 +00: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 17:35:33 +00:00
|
|
|
|
2022-01-01 06:04:08 +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;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2024-04-05 21:35:32 +00:00
|
|
|
void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
|
|
|
|
const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) override;
|
|
|
|
|
|
|
|
void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
|
|
|
|
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
EDA_ITEM* Clone() const override;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2020-05-08 20:01:14 +00:00
|
|
|
virtual bool operator <( const SCH_ITEM& aItem ) const override;
|
|
|
|
|
2023-04-24 10:25:10 +00:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
|
|
|
|
2023-09-14 21:39:42 +00: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 17:06:49 +00:00
|
|
|
void Show( int nestLevel, std::ostream& os ) const override;
|
2009-01-02 17:07:50 +00:00
|
|
|
#endif
|
2010-12-10 19:47:44 +00:00
|
|
|
|
|
|
|
private:
|
2022-01-01 06:04:08 +00:00
|
|
|
bool doIsConnected( const VECTOR2I& aPosition ) const override;
|
2020-11-10 18:07:35 +00:00
|
|
|
|
|
|
|
SHAPE_CIRCLE getEffectiveShape() const;
|
2021-03-25 14:07:16 +00: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
|