2011-10-19 20:32:21 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2021-03-25 14:07:16 +00:00
|
|
|
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-19 20:32:21 +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
|
|
|
|
*/
|
|
|
|
|
2019-05-10 19:57:24 +00:00
|
|
|
#ifndef SCH_ITEM_H
|
|
|
|
#define SCH_ITEM_H
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
#include <unordered_map>
|
2019-04-20 01:45:33 +00:00
|
|
|
#include <unordered_set>
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2020-10-14 01:06:53 +00:00
|
|
|
#include <eda_item.h>
|
2021-07-17 19:56:18 +00:00
|
|
|
#include <plotters/plotter.h>
|
2020-06-17 19:59:27 +00:00
|
|
|
#include <default_values.h>
|
2019-03-11 21:32:05 +00:00
|
|
|
#include <sch_sheet_path.h>
|
2020-07-08 18:29:16 +00:00
|
|
|
#include <netclass.h>
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2020-06-30 00:27:08 +00:00
|
|
|
class CONNECTION_GRAPH;
|
2019-04-20 01:45:33 +00:00
|
|
|
class SCH_CONNECTION;
|
2019-06-25 23:39:58 +00:00
|
|
|
class SCH_SHEET_PATH;
|
2020-05-13 02:00:37 +00:00
|
|
|
class SCHEMATIC;
|
2010-11-10 15:30:12 +00:00
|
|
|
class LINE_READER;
|
2010-12-08 20:12:46 +00:00
|
|
|
class SCH_EDIT_FRAME;
|
2010-03-16 18:22:59 +00:00
|
|
|
class wxFindReplaceData;
|
2011-06-17 13:24:22 +00:00
|
|
|
class PLOTTER;
|
2011-10-11 13:38:13 +00:00
|
|
|
class NETLIST_OBJECT;
|
2013-09-25 19:09:57 +00:00
|
|
|
class NETLIST_OBJECT_LIST;
|
2019-05-31 12:15:25 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
using KIGFX::RENDER_SETTINGS;
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2020-03-06 20:02:58 +00:00
|
|
|
enum FIELDS_AUTOPLACED
|
|
|
|
{
|
|
|
|
FIELDS_AUTOPLACED_NO = 0,
|
|
|
|
FIELDS_AUTOPLACED_AUTO,
|
|
|
|
FIELDS_AUTOPLACED_MANUAL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum DANGLING_END_T
|
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
UNKNOWN = 0,
|
2021-09-24 11:18:54 +00:00
|
|
|
WIRE_END,
|
|
|
|
BUS_END,
|
2010-11-03 14:13:15 +00:00
|
|
|
JUNCTION_END,
|
|
|
|
PIN_END,
|
|
|
|
LABEL_END,
|
2017-12-01 01:21:23 +00:00
|
|
|
BUS_ENTRY_END,
|
|
|
|
WIRE_ENTRY_END,
|
2015-06-08 00:07:42 +00:00
|
|
|
SHEET_LABEL_END,
|
|
|
|
NO_CONNECT_END,
|
2010-11-03 14:13:15 +00:00
|
|
|
};
|
|
|
|
|
2011-12-06 21:02:21 +00:00
|
|
|
|
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Helper class used to store the state of schematic items that can be connected to
|
2011-12-06 21:02:21 +00:00
|
|
|
* other schematic items.
|
|
|
|
*/
|
2010-11-03 14:13:15 +00:00
|
|
|
class DANGLING_END_ITEM
|
|
|
|
{
|
2011-12-06 21:02:21 +00:00
|
|
|
public:
|
2019-03-11 21:32:05 +00:00
|
|
|
DANGLING_END_ITEM( DANGLING_END_T aType, EDA_ITEM* aItem, const wxPoint& aPosition )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2011-12-06 21:02:21 +00:00
|
|
|
m_item = aItem;
|
|
|
|
m_type = aType;
|
|
|
|
m_pos = aPosition;
|
2017-12-07 20:23:02 +00:00
|
|
|
m_parent = aItem;
|
|
|
|
}
|
|
|
|
|
2021-09-24 11:18:54 +00:00
|
|
|
DANGLING_END_ITEM( DANGLING_END_T aType, EDA_ITEM* aItem, const wxPoint& aPosition,
|
|
|
|
const EDA_ITEM* aParent )
|
2017-12-07 20:23:02 +00:00
|
|
|
{
|
|
|
|
m_item = aItem;
|
|
|
|
m_type = aType;
|
|
|
|
m_pos = aPosition;
|
|
|
|
m_parent = aParent;
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
2011-12-06 21:02:21 +00:00
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
bool operator==( const DANGLING_END_ITEM& aB ) const
|
2020-01-03 13:36:13 +00:00
|
|
|
{
|
|
|
|
return GetItem() == aB.GetItem()
|
|
|
|
&& GetPosition() == aB.GetPosition()
|
|
|
|
&& GetType() == aB.GetType()
|
|
|
|
&& GetParent() == aB.GetParent();
|
|
|
|
}
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
bool operator!=( const DANGLING_END_ITEM& aB ) const
|
2020-01-03 13:36:13 +00:00
|
|
|
{
|
|
|
|
return GetItem() != aB.GetItem()
|
|
|
|
|| GetPosition() != aB.GetPosition()
|
|
|
|
|| GetType() != aB.GetType()
|
|
|
|
|| GetParent() != aB.GetParent();;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator<( const DANGLING_END_ITEM& rhs ) const
|
|
|
|
{
|
|
|
|
return( m_pos.x < rhs.m_pos.x || ( m_pos.x == rhs.m_pos.x && m_pos.y < rhs.m_pos.y )
|
|
|
|
|| ( m_pos == rhs.m_pos && m_item < rhs.m_item ) );
|
|
|
|
}
|
|
|
|
|
2020-05-27 14:01:07 +00:00
|
|
|
wxPoint GetPosition() const { return m_pos; }
|
2019-03-11 21:32:05 +00:00
|
|
|
EDA_ITEM* GetItem() const { return m_item; }
|
2017-12-07 20:23:02 +00:00
|
|
|
const EDA_ITEM* GetParent() const { return m_parent; }
|
2011-12-06 21:02:21 +00:00
|
|
|
DANGLING_END_T GetType() const { return m_type; }
|
2021-03-25 14:07:16 +00:00
|
|
|
|
|
|
|
private:
|
2021-09-24 11:18:54 +00:00
|
|
|
EDA_ITEM* m_item; /// A pointer to the connectable object.
|
|
|
|
wxPoint m_pos; /// The position of the connection point.
|
|
|
|
DANGLING_END_T m_type; /// The type of connection of #m_item.
|
|
|
|
const EDA_ITEM* m_parent; /// A pointer to the parent object (in the case of pins)
|
2010-11-03 14:13:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-09-16 00:59:12 +00:00
|
|
|
typedef std::unordered_set<SCH_ITEM*> SCH_ITEM_SET;
|
2020-01-17 02:33:16 +00:00
|
|
|
|
2020-06-17 19:59:27 +00:00
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Base class for any item which can be embedded within the #SCHEMATIC container class,
|
|
|
|
* and therefore instances of derived classes should only be found in EESCHEMA or other
|
|
|
|
* programs that use class SCHEMATIC and its contents.
|
|
|
|
*
|
|
|
|
* The corresponding class in Pcbnew is #BOARD_ITEM.
|
2008-04-14 19:22:48 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
class SCH_ITEM : public EDA_ITEM
|
2008-04-14 19:22:48 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType );
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
SCH_ITEM( const SCH_ITEM& aItem );
|
|
|
|
|
2021-11-21 16:54:00 +00:00
|
|
|
SCH_ITEM& operator=( const SCH_ITEM& aPin );
|
|
|
|
|
2021-01-19 03:40:58 +00:00
|
|
|
virtual ~SCH_ITEM();
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
virtual wxString GetClass() const override
|
2008-04-14 19:22:48 +00:00
|
|
|
{
|
|
|
|
return wxT( "SCH_ITEM" );
|
|
|
|
}
|
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
bool IsType( const KICAD_T aScanTypes[] ) const override
|
|
|
|
{
|
|
|
|
if( EDA_ITEM::IsType( aScanTypes ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
|
|
|
{
|
|
|
|
if( *p == SCH_ITEM_LOCATE_WIRE_T && m_layer == LAYER_WIRE )
|
|
|
|
return true;
|
|
|
|
else if ( *p == SCH_ITEM_LOCATE_BUS_T && m_layer == LAYER_BUS )
|
|
|
|
return true;
|
|
|
|
else if ( *p == SCH_ITEM_LOCATE_GRAPHIC_LINE_T && m_layer == LAYER_NOTES )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-04-05 14:46:51 +00:00
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Swap the internal data structures \a aItem with the schematic item.
|
2021-03-25 14:07:16 +00:00
|
|
|
* Obviously, aItem must have the same type than me.
|
2011-04-05 14:46:51 +00:00
|
|
|
* @param aItem The item to swap the data structures with.
|
|
|
|
*/
|
|
|
|
virtual void SwapData( SCH_ITEM* aItem );
|
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
/**
|
|
|
|
* Routine to create a new copy of given item.
|
|
|
|
* The new object is not put in draw list (not linked).
|
|
|
|
*
|
|
|
|
* @param doClone (default = false) indicates unique values (such as timestamp and
|
2021-03-25 14:07:16 +00:00
|
|
|
* sheet name) should be duplicated. Use only for undo/redo operations.
|
2019-05-04 13:02:05 +00:00
|
|
|
*/
|
2020-02-20 12:11:04 +00:00
|
|
|
SCH_ITEM* Duplicate( bool doClone = false ) const;
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2015-02-28 16:56:09 +00:00
|
|
|
/**
|
|
|
|
* @return true for items which are moved with the anchor point at mouse cursor
|
|
|
|
* and false for items moved with no reference to anchor
|
|
|
|
* Usually return true for small items (labels, junctions) and false for
|
2020-11-15 17:03:27 +00:00
|
|
|
* items which can be large (hierarchical sheets, symbols)
|
2015-02-28 16:56:09 +00:00
|
|
|
*/
|
2020-12-20 18:44:13 +00:00
|
|
|
virtual bool IsMovableFromAnchorPoint() const { return true; }
|
2015-02-28 16:56:09 +00:00
|
|
|
|
|
|
|
wxPoint& GetStoredPos() { return m_storedPos; }
|
2021-06-08 14:09:24 +00:00
|
|
|
void SetStoredPos( const wxPoint& aPos ) { m_storedPos = aPos; }
|
2015-02-28 16:56:09 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
/**
|
2021-03-25 14:07:16 +00:00
|
|
|
* Searches the item hierarchy to find a SCHEMATIC.
|
2020-05-13 02:00:37 +00:00
|
|
|
*
|
|
|
|
* Every SCH_ITEM that lives on a SCH_SCREEN should be parented to either that screen
|
2020-11-15 17:03:27 +00:00
|
|
|
* or another SCH_ITEM on the same screen (for example, pins to their symbols).
|
2020-05-13 02:00:37 +00:00
|
|
|
*
|
|
|
|
* Every SCH_SCREEN should be parented to the SCHEMATIC.
|
|
|
|
*
|
2021-03-25 14:07:16 +00:00
|
|
|
* @note This hierarchy is not the same as the sheet hierarchy!
|
|
|
|
*
|
|
|
|
* @return the parent schematic this item lives on, or nullptr.
|
2020-05-13 02:00:37 +00:00
|
|
|
*/
|
|
|
|
SCHEMATIC* Schematic() const;
|
|
|
|
|
2019-04-21 23:45:34 +00:00
|
|
|
/**
|
2021-03-25 14:07:16 +00:00
|
|
|
* @return true if the object is locked, else false.
|
2019-04-21 23:45:34 +00:00
|
|
|
*/
|
|
|
|
virtual bool IsLocked() const { return false; }
|
|
|
|
|
|
|
|
/**
|
2021-03-25 14:07:16 +00:00
|
|
|
* Set the 'lock' status to \a aLocked for of this item.
|
2019-04-21 23:45:34 +00:00
|
|
|
*/
|
|
|
|
virtual void SetLocked( bool aLocked ) {}
|
2015-02-28 16:56:09 +00:00
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
/**
|
2021-03-25 14:07:16 +00:00
|
|
|
* Allow items to support hypertext actions when hovered/clicked.
|
2020-11-17 16:02:47 +00:00
|
|
|
*/
|
|
|
|
virtual bool IsHypertext() const { return false; }
|
|
|
|
|
|
|
|
virtual void DoHypertextMenu( EDA_DRAW_FRAME* aFrame ) { }
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Return the layer this item is on.
|
2008-04-14 19:22:48 +00:00
|
|
|
*/
|
2020-11-14 14:29:11 +00:00
|
|
|
SCH_LAYER_ID GetLayer() const { return m_layer; }
|
2008-04-14 19:22:48 +00:00
|
|
|
|
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Set the layer this item is on.
|
|
|
|
*
|
2008-04-14 19:22:48 +00:00
|
|
|
* @param aLayer The layer number.
|
|
|
|
*/
|
2020-12-20 18:50:45 +00:00
|
|
|
void SetLayer( SCH_LAYER_ID aLayer ) { m_layer = aLayer; }
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2018-10-21 12:50:31 +00:00
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Return the layers the item is drawn on (which may be more than its "home" layer)
|
2018-10-21 12:50:31 +00:00
|
|
|
*/
|
|
|
|
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2009-06-30 19:21:41 +00:00
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
2020-04-14 12:25:00 +00:00
|
|
|
virtual int GetPenWidth() const { return 0; }
|
2009-06-30 19:21:41 +00:00
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Print a schematic item.
|
|
|
|
*
|
|
|
|
* Each schematic item should have its own method
|
|
|
|
*
|
2021-03-25 14:07:16 +00:00
|
|
|
* @param aOffset is the drawing offset (usually {0,0} but can be different when moving an
|
|
|
|
* object).
|
2008-04-14 19:22:48 +00:00
|
|
|
*/
|
2020-12-20 18:18:54 +00:00
|
|
|
virtual void Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) = 0;
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Move the item by \a aMoveVector to a new position.
|
2009-07-27 14:32:40 +00:00
|
|
|
*/
|
2010-11-03 14:13:15 +00:00
|
|
|
virtual void Move( const wxPoint& aMoveVector ) = 0;
|
2009-07-27 14:32:40 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
/**
|
2021-02-16 20:45:25 +00:00
|
|
|
* Mirror item horizontally about \a aCenter.
|
2009-07-27 14:32:40 +00:00
|
|
|
*/
|
2021-02-16 20:45:25 +00:00
|
|
|
virtual void MirrorHorizontally( int aCenter ) = 0;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
/**
|
2021-02-16 20:45:25 +00:00
|
|
|
* Mirror item vertically about \a aCenter.
|
2012-03-15 14:31:16 +00:00
|
|
|
*/
|
2021-02-16 20:45:25 +00:00
|
|
|
virtual void MirrorVertically( int aCenter ) = 0;
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
/**
|
2021-03-19 19:33:06 +00:00
|
|
|
* Rotate the item around \a aCenter 90 degrees in the clockwise direction.
|
2012-03-15 14:31:16 +00:00
|
|
|
*/
|
2021-06-08 14:09:24 +00:00
|
|
|
virtual void Rotate( const wxPoint& aCenter ) = 0;
|
2009-07-27 14:32:40 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Add the schematic item end points to \a aItemList if the item has end points.
|
2010-11-03 14:13:15 +00:00
|
|
|
*
|
|
|
|
* The default version doesn't do anything since many of the schematic object cannot
|
|
|
|
* be tested for dangling ends. If you add a new schematic item that can have a
|
|
|
|
* dangling end ( no connect ), override this method to provide the correct end
|
|
|
|
* points.
|
|
|
|
*
|
2021-03-25 14:07:16 +00:00
|
|
|
* @param aItemList is the list of DANGLING_END_ITEMS to add to.
|
2010-11-03 14:13:15 +00:00
|
|
|
*/
|
2013-12-13 16:27:30 +00:00
|
|
|
virtual void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) {}
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Test the schematic item to \a aItemList to check if it's dangling state has changed.
|
2010-11-03 14:13:15 +00:00
|
|
|
*
|
|
|
|
* Note that the return value only true when the state of the test has changed. Use
|
|
|
|
* the IsDangling() method to get the current dangling state of the item. Some of
|
|
|
|
* the schematic objects cannot be tested for a dangling state, the default method
|
|
|
|
* always returns false. Only override the method if the item can be tested for a
|
|
|
|
* dangling state.
|
|
|
|
*
|
2021-03-25 14:07:16 +00:00
|
|
|
* If aSheet is passed a non-null pointer to a SCH_SHEET_PATH, the overridden method can
|
2020-01-17 02:33:16 +00:00
|
|
|
* optionally use it to update sheet-local connectivity information
|
|
|
|
*
|
2021-03-25 14:07:16 +00:00
|
|
|
* @param aItemList is the list of items to test item against.
|
|
|
|
* @param aSheet is the sheet path to update connections for.
|
2010-11-03 14:13:15 +00:00
|
|
|
* @return True if the dangling state has changed from it's current setting.
|
|
|
|
*/
|
2020-01-17 02:33:16 +00:00
|
|
|
virtual bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
|
|
|
|
const SCH_SHEET_PATH* aPath = nullptr )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
virtual bool IsDangling() const { return false; }
|
|
|
|
|
2020-11-14 14:29:11 +00:00
|
|
|
virtual bool CanConnect( const SCH_ITEM* aItem ) const { return m_layer == aItem->GetLayer(); }
|
2017-12-01 01:21:23 +00:00
|
|
|
|
2011-01-07 19:24:24 +00:00
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* @return true if the schematic item can connect to another schematic item.
|
2011-01-07 19:24:24 +00:00
|
|
|
*/
|
|
|
|
virtual bool IsConnectable() const { return false; }
|
|
|
|
|
2020-10-01 23:53:47 +00:00
|
|
|
/**
|
2021-03-25 14:07:16 +00:00
|
|
|
* @return true if the given point can start drawing (usually means the anchor is
|
|
|
|
* unused/free/dangling).
|
2020-10-01 23:53:47 +00:00
|
|
|
*/
|
|
|
|
virtual bool IsPointClickableAnchor( const wxPoint& aPos ) const { return false; }
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Add all the connection points for this item to \a aPoints.
|
2010-11-03 14:13:15 +00:00
|
|
|
*
|
|
|
|
* Not all schematic items have connection points so the default method does nothing.
|
|
|
|
*
|
2021-03-25 14:07:16 +00:00
|
|
|
* @param aPoints is the list of connection points to add to.
|
2010-11-03 14:13:15 +00:00
|
|
|
*/
|
2020-09-08 13:27:13 +00:00
|
|
|
virtual std::vector<wxPoint> GetConnectionPoints() const { return {}; }
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Clears all of the connection items from the list.
|
2010-11-03 14:13:15 +00:00
|
|
|
*
|
|
|
|
* The vector release method is used to prevent the item pointers from being deleted.
|
|
|
|
* Do not use the vector erase method on the connection list.
|
|
|
|
*/
|
2011-03-25 19:16:05 +00:00
|
|
|
void ClearConnections() { m_connections.clear(); }
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2010-12-13 15:59:00 +00:00
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Test the item to see if it is connected to \a aPoint.
|
2010-12-13 15:59:00 +00:00
|
|
|
*
|
2021-03-25 14:07:16 +00:00
|
|
|
* @param aPoint is a reference to a wxPoint object containing the coordinates to test.
|
2010-12-14 15:56:30 +00:00
|
|
|
* @return True if connection to \a aPoint exists.
|
2010-12-13 15:59:00 +00:00
|
|
|
*/
|
|
|
|
bool IsConnected( const wxPoint& aPoint ) const;
|
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
/**
|
2021-03-25 14:07:16 +00:00
|
|
|
* Retrieve the connection associated with this object in the given sheet.
|
2020-06-17 19:59:27 +00:00
|
|
|
*
|
|
|
|
* @note The returned value can be nullptr.
|
2019-03-11 21:32:05 +00:00
|
|
|
*/
|
2020-10-07 14:40:12 +00:00
|
|
|
SCH_CONNECTION* Connection( const SCH_SHEET_PATH* aSheet = nullptr ) const;
|
2019-03-11 21:32:05 +00:00
|
|
|
|
|
|
|
/**
|
2021-03-25 14:07:16 +00:00
|
|
|
* Retrieve the set of items connected to this item on the given sheet.
|
2019-03-11 21:32:05 +00:00
|
|
|
*/
|
2020-09-16 00:59:12 +00:00
|
|
|
SCH_ITEM_SET& ConnectedItems( const SCH_SHEET_PATH& aPath );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
|
|
|
/**
|
2021-03-25 14:07:16 +00:00
|
|
|
* Add a connection link between this item and another.
|
2019-03-11 21:32:05 +00:00
|
|
|
*/
|
2020-01-17 02:33:16 +00:00
|
|
|
void AddConnectionTo( const SCH_SHEET_PATH& aPath, SCH_ITEM* aItem );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
|
|
|
/**
|
2021-03-25 14:07:16 +00:00
|
|
|
* Create a new connection object associated with this object.
|
2019-03-11 21:32:05 +00:00
|
|
|
*
|
2021-03-25 14:07:16 +00:00
|
|
|
* @param aPath is the sheet path to initialize.
|
2019-03-11 21:32:05 +00:00
|
|
|
*/
|
2020-06-30 00:27:08 +00:00
|
|
|
SCH_CONNECTION* InitializeConnection( const SCH_SHEET_PATH& aPath, CONNECTION_GRAPH* aGraph );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2021-11-24 13:19:50 +00:00
|
|
|
SCH_CONNECTION* GetOrInitConnection( const SCH_SHEET_PATH& aPath, CONNECTION_GRAPH* aGraph );
|
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
/**
|
2021-03-25 14:07:16 +00:00
|
|
|
* Return true if this item should propagate connection info to \a aItem.
|
2019-03-11 21:32:05 +00:00
|
|
|
*/
|
|
|
|
virtual bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const { return true; }
|
|
|
|
|
2021-11-24 13:19:50 +00:00
|
|
|
bool IsConnectivityDirty() const { return m_connectivity_dirty; }
|
2019-03-30 15:57:30 +00:00
|
|
|
|
|
|
|
void SetConnectivityDirty( bool aDirty = true ) { m_connectivity_dirty = aDirty; }
|
|
|
|
|
2021-11-28 17:08:30 +00:00
|
|
|
virtual void SetLastResolvedState( const SCH_ITEM* aItem ) { }
|
|
|
|
|
2020-10-07 14:40:12 +00:00
|
|
|
NETCLASSPTR NetClass( const SCH_SHEET_PATH* aSheet = nullptr ) const;
|
2020-07-08 18:29:16 +00:00
|
|
|
|
2020-03-06 20:02:58 +00:00
|
|
|
/**
|
|
|
|
* Return whether the fields have been automatically placed.
|
|
|
|
*/
|
|
|
|
FIELDS_AUTOPLACED GetFieldsAutoplaced() const { return m_fieldsAutoplaced; }
|
|
|
|
|
2021-04-02 16:08:13 +00:00
|
|
|
void SetFieldsAutoplaced() { m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO; }
|
2020-03-06 20:02:58 +00:00
|
|
|
void ClearFieldsAutoplaced() { m_fieldsAutoplaced = FIELDS_AUTOPLACED_NO; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Autoplace fields only if correct to do so automatically.
|
|
|
|
*
|
|
|
|
* Fields that have been moved by hand are not automatically placed.
|
|
|
|
*
|
2020-11-15 17:03:27 +00:00
|
|
|
* @param aScreen is the SCH_SCREEN associated with the current instance of the symbol.
|
2020-03-06 20:02:58 +00:00
|
|
|
*/
|
|
|
|
void AutoAutoplaceFields( SCH_SCREEN* aScreen )
|
|
|
|
{
|
|
|
|
if( GetFieldsAutoplaced() )
|
|
|
|
AutoplaceFields( aScreen, GetFieldsAutoplaced() == FIELDS_AUTOPLACED_MANUAL );
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) { }
|
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
virtual void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) { }
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Check if this schematic item has line stoke properties.
|
|
|
|
*
|
|
|
|
* @see #STROKE_PARAMS
|
|
|
|
*
|
|
|
|
* @return true if this schematic item support line stroke properties. Otherwise, false.
|
|
|
|
*/
|
|
|
|
virtual bool HasLineStroke() const { return false; }
|
|
|
|
|
2020-06-19 11:48:00 +00:00
|
|
|
virtual STROKE_PARAMS GetStroke() const { wxCHECK( false, STROKE_PARAMS() ); }
|
|
|
|
|
|
|
|
virtual void SetStroke( const STROKE_PARAMS& aStroke ) { wxCHECK( false, /* void */ ); }
|
|
|
|
|
2020-06-17 19:59:27 +00:00
|
|
|
/**
|
|
|
|
* Plot the schematic item to \a aPlotter.
|
2012-03-15 14:31:16 +00:00
|
|
|
*
|
2021-03-25 14:07:16 +00:00
|
|
|
* @param aPlotter is the #PLOTTER object to plot to.
|
2012-03-15 14:31:16 +00:00
|
|
|
*/
|
2021-03-06 09:27:41 +00:00
|
|
|
virtual void Plot( PLOTTER* aPlotter ) const;
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
virtual bool operator <( const SCH_ITEM& aItem ) const;
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
private:
|
2021-03-25 14:07:16 +00:00
|
|
|
friend class CONNECTION_GRAPH;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Provide the object specific test to see if it is connected to \a aPosition.
|
2012-03-15 14:31:16 +00:00
|
|
|
*
|
|
|
|
* @note Override this function if the derived object can be connect to another
|
|
|
|
* object such as a wire, bus, or junction. Do not override this function
|
|
|
|
* for objects that cannot have connections. The default will always return
|
|
|
|
* false. This functions is call through the public function IsConnected()
|
|
|
|
* which performs tests common to all schematic items before calling the
|
|
|
|
* item specific connection testing.
|
|
|
|
*
|
2021-03-25 14:07:16 +00:00
|
|
|
* @param aPosition is a reference to a wxPoint object containing the test position.
|
2012-03-15 14:31:16 +00:00
|
|
|
* @return True if connection to \a aPosition exists.
|
2010-12-10 19:47:44 +00:00
|
|
|
*/
|
2010-12-21 15:13:09 +00:00
|
|
|
virtual bool doIsConnected( const wxPoint& aPosition ) const { return false; }
|
2021-03-25 14:07:16 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
SCH_LAYER_ID m_layer;
|
|
|
|
EDA_ITEMS m_connections; // List of items connected to this item.
|
|
|
|
FIELDS_AUTOPLACED m_fieldsAutoplaced; // indicates status of field autoplacement
|
|
|
|
wxPoint m_storedPos; // a temporary variable used in some move commands
|
|
|
|
// to store a initial pos of the item or mouse cursor
|
|
|
|
|
|
|
|
/// Store pointers to other items that are connected to this one, per sheet.
|
|
|
|
std::unordered_map<SCH_SHEET_PATH, SCH_ITEM_SET> m_connected_items;
|
|
|
|
|
|
|
|
/// Store connectivity information, per sheet.
|
|
|
|
std::unordered_map<SCH_SHEET_PATH, SCH_CONNECTION*> m_connection_map;
|
|
|
|
|
|
|
|
bool m_connectivity_dirty;
|
2008-04-14 19:22:48 +00:00
|
|
|
};
|
|
|
|
|
2019-05-10 19:57:24 +00:00
|
|
|
#endif /* SCH_ITEM_H */
|