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
|
2020-01-03 13:36:13 +00:00
|
|
|
* Copyright (C) 2004-2020 KiCad Developers, see change_log.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>
|
2010-11-03 14:13:15 +00:00
|
|
|
#include <vector>
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <base_struct.h>
|
2020-06-17 19:59:27 +00:00
|
|
|
#include <plotter.h>
|
|
|
|
|
|
|
|
#include <gal/color4d.h>
|
|
|
|
|
|
|
|
#include <default_values.h>
|
2019-03-11 21:32:05 +00:00
|
|
|
#include <sch_sheet_path.h>
|
2020-04-14 12:25:00 +00:00
|
|
|
#include <render_settings.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,
|
|
|
|
WIRE_START_END,
|
|
|
|
WIRE_END_END,
|
|
|
|
BUS_START_END,
|
|
|
|
BUS_END_END,
|
|
|
|
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
|
|
|
|
{
|
2013-03-31 13:27:46 +00:00
|
|
|
private:
|
2012-03-15 14:31:16 +00:00
|
|
|
/// A pointer to the connectable object.
|
2020-01-03 13:36:13 +00:00
|
|
|
EDA_ITEM* m_item;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2011-12-06 21:02:21 +00:00
|
|
|
/// The position of the connection point.
|
2020-01-03 13:36:13 +00:00
|
|
|
wxPoint m_pos;
|
2011-12-06 21:02:21 +00:00
|
|
|
|
|
|
|
/// The type of connection of #m_item.
|
2020-01-03 13:36:13 +00:00
|
|
|
DANGLING_END_T m_type;
|
2011-12-06 21:02:21 +00:00
|
|
|
|
2017-12-07 20:23:02 +00:00
|
|
|
/// A pointer to the parent object (in the case of pins)
|
|
|
|
const EDA_ITEM* m_parent;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
DANGLING_END_ITEM( DANGLING_END_T aType, EDA_ITEM* aItem,
|
2017-12-07 20:23:02 +00:00
|
|
|
const wxPoint& aPosition, const EDA_ITEM* aParent )
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2020-01-03 13:36:13 +00:00
|
|
|
bool operator==( const DANGLING_END_ITEM& aB )
|
|
|
|
{
|
|
|
|
return GetItem() == aB.GetItem()
|
|
|
|
&& GetPosition() == aB.GetPosition()
|
|
|
|
&& GetType() == aB.GetType()
|
|
|
|
&& GetParent() == aB.GetParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=( const DANGLING_END_ITEM& aB )
|
|
|
|
{
|
|
|
|
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; }
|
2010-11-03 14:13:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-01-17 02:33:16 +00:00
|
|
|
typedef std::unordered_set<SCH_ITEM*> ITEM_SET;
|
|
|
|
|
2020-06-17 19:59:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple container to manage line stroke parameters.
|
|
|
|
*/
|
|
|
|
class STROKE_PARAMS
|
|
|
|
{
|
|
|
|
int m_width;
|
|
|
|
PLOT_DASH_TYPE m_type;
|
|
|
|
COLOR4D m_color;
|
|
|
|
|
|
|
|
public:
|
|
|
|
STROKE_PARAMS( int aWidth = Mils2iu( DEFAULT_LINE_THICKNESS ),
|
|
|
|
PLOT_DASH_TYPE aType = PLOT_DASH_TYPE::DEFAULT,
|
|
|
|
const COLOR4D& aColor = COLOR4D::UNSPECIFIED ) :
|
|
|
|
m_width( aWidth ),
|
|
|
|
m_type( aType ),
|
|
|
|
m_color( aColor )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetWidth() const { return m_width; }
|
|
|
|
void SetWidth( int aWidth ) { m_width = aWidth; }
|
|
|
|
|
|
|
|
PLOT_DASH_TYPE GetType() const { return m_type; }
|
|
|
|
void SetType( PLOT_DASH_TYPE aType ) { m_type = aType; }
|
|
|
|
|
|
|
|
COLOR4D GetColor() const { return m_color; }
|
|
|
|
void SetColor( const COLOR4D& aColor ) { m_color = aColor; }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2019-03-11 21:32:05 +00:00
|
|
|
friend class CONNECTION_GRAPH;
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
protected:
|
2020-03-06 20:02:58 +00:00
|
|
|
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
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2020-01-17 02:33:16 +00:00
|
|
|
/// Stores pointers to other items that are connected to this one, per sheet
|
|
|
|
std::unordered_map<SCH_SHEET_PATH, ITEM_SET> m_connected_items;
|
2019-03-11 21:32:05 +00:00
|
|
|
|
|
|
|
/// Stores connectivity information, per sheet
|
|
|
|
std::unordered_map<SCH_SHEET_PATH, SCH_CONNECTION*> m_connection_map;
|
|
|
|
|
2019-03-30 15:57:30 +00:00
|
|
|
/// True if connectivity info might be out of date
|
|
|
|
bool m_connectivity_dirty;
|
|
|
|
|
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 );
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
~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" );
|
|
|
|
}
|
|
|
|
|
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.
|
2011-06-09 13:30:46 +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
|
|
|
|
* sheet name) should be duplicated. Use only for undo/redo operations.
|
|
|
|
*/
|
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
|
|
|
|
* items which can be large (hierarchical sheets, compoments)
|
|
|
|
*/
|
|
|
|
virtual bool IsMovableFromAnchorPoint() { return true; }
|
|
|
|
|
|
|
|
wxPoint& GetStoredPos() { return m_storedPos; }
|
|
|
|
void SetStoredPos( wxPoint aPos ) { m_storedPos = aPos; }
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
/**
|
|
|
|
* Searches the item hierarchy to find a SCHEMATIC
|
|
|
|
*
|
|
|
|
* Every SCH_ITEM that lives on a SCH_SCREEN should be parented to either that screen
|
|
|
|
* or another SCH_ITEM on the same screen (for example, pins to their components).
|
|
|
|
*
|
|
|
|
* Every SCH_SCREEN should be parented to the SCHEMATIC.
|
|
|
|
* Note that this hierarchy is not the same as the sheet hierarchy!
|
|
|
|
*
|
|
|
|
* @return the parent schematic this item lives on, or nullptr
|
|
|
|
*/
|
|
|
|
SCHEMATIC* Schematic() const;
|
|
|
|
|
2019-04-21 23:45:34 +00:00
|
|
|
/**
|
|
|
|
* @return bool - true if the object is locked, else false
|
|
|
|
*/
|
|
|
|
virtual bool IsLocked() const { return false; }
|
|
|
|
|
|
|
|
/**
|
2020-06-17 19:59:27 +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
|
|
|
|
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
|
|
|
*/
|
2017-03-13 03:19:33 +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.
|
|
|
|
*/
|
2017-03-13 03:19:33 +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
|
|
|
|
*
|
2020-04-14 12:25:00 +00:00
|
|
|
* @param aOffset drawing offset (usually {0,0} but can be different when moving an object)
|
2008-04-14 19:22:48 +00:00
|
|
|
*/
|
2020-04-14 12:25:00 +00:00
|
|
|
virtual void Print( 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.
|
|
|
|
*
|
2011-03-25 19:16:05 +00:00
|
|
|
* @param aMoveVector = the displacement vector
|
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
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Mirror item relative to the Y axis about \a aYaxis_position.
|
|
|
|
*
|
2010-12-21 15:13:09 +00:00
|
|
|
* @param aYaxis_position The Y axis position to mirror around.
|
2009-07-27 14:32:40 +00:00
|
|
|
*/
|
2012-03-15 14:31:16 +00:00
|
|
|
virtual void MirrorY( int aYaxis_position ) = 0;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Mirror item relative to the X axis about \a aXaxis_position.
|
|
|
|
*
|
2012-03-15 14:31:16 +00:00
|
|
|
* @param aXaxis_position The X axis position to mirror around.
|
|
|
|
*/
|
|
|
|
virtual void MirrorX( int aXaxis_position ) = 0;
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Rotate the item around \a aPosition 90 degrees in the clockwise direction.
|
|
|
|
*
|
2012-03-15 14:31:16 +00:00
|
|
|
* @param aPosition A reference to a wxPoint object containing the coordinates to
|
|
|
|
* rotate around.
|
|
|
|
*/
|
|
|
|
virtual void Rotate( wxPoint aPosition ) = 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.
|
|
|
|
*
|
|
|
|
* @param aItemList - List of DANGLING_END_ITEMS to add to.
|
|
|
|
*/
|
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.
|
|
|
|
*
|
2020-01-17 02:33:16 +00:00
|
|
|
* If aSheet is passed a non-null pointer to a SCH_SHEET_PATH, the overrided method can
|
|
|
|
* optionally use it to update sheet-local connectivity information
|
|
|
|
*
|
2010-11-03 14:13:15 +00:00
|
|
|
* @param aItemList - List of items to test item against.
|
2020-01-17 02:33:16 +00:00
|
|
|
* @param aSheet - 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; }
|
|
|
|
|
2017-12-19 17:45:56 +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; }
|
|
|
|
|
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.
|
|
|
|
*
|
2010-12-21 15:13:09 +00:00
|
|
|
* @param aPoints List of connection points to add to.
|
2010-11-03 14:13:15 +00:00
|
|
|
*/
|
2013-12-13 16:27:30 +00:00
|
|
|
virtual void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { }
|
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
|
|
|
*
|
2012-03-15 14:31:16 +00:00
|
|
|
* @param aPoint 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
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Retrieve the connection associated with this object in the given sheet
|
|
|
|
*
|
|
|
|
* @note The returned value can be nullptr.
|
2019-03-11 21:32:05 +00:00
|
|
|
*/
|
|
|
|
SCH_CONNECTION* Connection( const SCH_SHEET_PATH& aPath ) const;
|
|
|
|
|
|
|
|
/**
|
2020-01-17 02:33:16 +00:00
|
|
|
* Retrieves the set of items connected to this item on the given sheet
|
2019-03-11 21:32:05 +00:00
|
|
|
*/
|
2020-01-17 02:33:16 +00:00
|
|
|
ITEM_SET& ConnectedItems( const SCH_SHEET_PATH& aPath );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a connection link between this item and another
|
|
|
|
*/
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new connection object associated with this object
|
|
|
|
*
|
|
|
|
* @param aPath is the sheet path to initialize
|
|
|
|
*/
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if this item should propagate connection info to aItem
|
|
|
|
*/
|
|
|
|
virtual bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const { return true; }
|
|
|
|
|
2019-03-30 15:57:30 +00:00
|
|
|
bool IsConnectivityDirty() { return m_connectivity_dirty; }
|
|
|
|
|
|
|
|
void SetConnectivityDirty( bool aDirty = true ) { m_connectivity_dirty = aDirty; }
|
|
|
|
|
2020-03-06 20:02:58 +00:00
|
|
|
/**
|
|
|
|
* Return whether the fields have been automatically placed.
|
|
|
|
*/
|
|
|
|
FIELDS_AUTOPLACED GetFieldsAutoplaced() const { return m_fieldsAutoplaced; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set fields automatically placed flag false.
|
|
|
|
*/
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* @param aScreen is the SCH_SCREEN associated with the current instance of the
|
|
|
|
* component.
|
|
|
|
*/
|
|
|
|
void AutoAutoplaceFields( SCH_SCREEN* aScreen )
|
|
|
|
{
|
|
|
|
if( GetFieldsAutoplaced() )
|
|
|
|
AutoplaceFields( aScreen, GetFieldsAutoplaced() == FIELDS_AUTOPLACED_MANUAL );
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) { }
|
|
|
|
|
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
|
|
|
*
|
|
|
|
* @param aPlotter A pointer to a #PLOTTER object.
|
|
|
|
*/
|
|
|
|
virtual void Plot( PLOTTER* aPlotter );
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2011-10-11 13:38:13 +00:00
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Create a new #NETLIST_OBJECT for the schematic object and adds it to \a aNetListItems.
|
|
|
|
*
|
2011-10-11 13:38:13 +00:00
|
|
|
* <p>
|
|
|
|
* Not all schematic objects have net list items associated with them. This
|
|
|
|
* method only needs to be overridden for those schematic objects that have
|
|
|
|
* net list objects associated with them.
|
2012-03-15 14:31:16 +00:00
|
|
|
* </p>
|
2011-10-11 13:38:13 +00:00
|
|
|
*/
|
2013-09-25 19:09:57 +00:00
|
|
|
virtual void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
|
|
|
|
SCH_SHEET_PATH* aSheetPath ) { }
|
2011-10-11 13:38:13 +00:00
|
|
|
|
2011-10-19 20:32:21 +00:00
|
|
|
/**
|
2020-06-17 19:59:27 +00:00
|
|
|
* Set the schematic item position to \a aPosition.
|
2011-10-19 20:32:21 +00:00
|
|
|
*
|
|
|
|
* @param aPosition A reference to a wxPoint object containing the new position.
|
|
|
|
*/
|
2012-03-15 14:31:16 +00:00
|
|
|
virtual void SetPosition( const wxPoint& aPosition ) = 0;
|
2011-10-19 20:32:21 +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:
|
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.
|
|
|
|
*
|
|
|
|
* @param aPosition A reference to a wxPoint object containing the test position.
|
|
|
|
* @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; }
|
2008-04-14 19:22:48 +00:00
|
|
|
};
|
|
|
|
|
2019-05-10 19:57:24 +00:00
|
|
|
#endif /* SCH_ITEM_H */
|