2011-10-31 20:49:48 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-02-28 16:56:09 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr
|
2017-11-27 15:18:30 +00:00
|
|
|
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
2023-08-06 19:20:53 +00:00
|
|
|
* Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-31 20:49:48 +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
|
|
|
|
*/
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
#ifndef _LIB_ITEM_H_
|
|
|
|
#define _LIB_ITEM_H_
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2020-10-14 01:06:53 +00:00
|
|
|
#include <eda_item.h>
|
2021-07-18 23:08:54 +00:00
|
|
|
#include <eda_shape.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <transform.h>
|
2020-04-14 12:25:00 +00:00
|
|
|
#include <render_settings.h>
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2011-10-31 20:49:48 +00:00
|
|
|
class LINE_READER;
|
2011-11-01 15:06:26 +00:00
|
|
|
class OUTPUTFORMATTER;
|
2021-06-10 18:51:46 +00:00
|
|
|
class LIB_SYMBOL;
|
2010-10-08 20:40:57 +00:00
|
|
|
class PLOTTER;
|
|
|
|
class LIB_PIN;
|
2013-01-12 17:32:24 +00:00
|
|
|
class MSG_PANEL_ITEM;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2023-08-06 19:20:53 +00:00
|
|
|
namespace KIFONT
|
|
|
|
{
|
|
|
|
class FONT;
|
|
|
|
class METRICS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
using KIGFX::RENDER_SETTINGS;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2020-10-15 08:48:02 +00:00
|
|
|
extern const int fill_tab[];
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
|
2011-05-25 10:42:56 +00:00
|
|
|
#define MINIMUM_SELECTION_DISTANCE 2 // Minimum selection distance in internal units
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper for defining a list of pin object pointers. The list does not
|
2011-10-31 20:49:48 +00:00
|
|
|
* use a Boost pointer class so the object pointers do not accidentally get
|
2010-10-08 20:40:57 +00:00
|
|
|
* deleted when the container is deleted.
|
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
typedef std::vector< LIB_PIN* > LIB_PINS;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-06-14 18:00:08 +00:00
|
|
|
* The base class for drawable items used by schematic library symbols.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
class LIB_ITEM : public EDA_ITEM
|
2010-10-08 20:40:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-07-18 23:08:54 +00:00
|
|
|
LIB_ITEM( KICAD_T aType, LIB_SYMBOL* aSymbol = nullptr, int aUnit = 0, int aConvert = 0 );
|
2010-10-08 20:40:57 +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-10-08 20:40:57 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
virtual ~LIB_ITEM() { }
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2024-01-26 16:16:13 +00:00
|
|
|
// Define the enums for basic body styles
|
|
|
|
enum BODY_STYLE : int
|
|
|
|
{
|
|
|
|
BASE = 1,
|
|
|
|
DEMORGAN = 2
|
|
|
|
};
|
2019-04-15 13:59:36 +00:00
|
|
|
|
2020-02-13 13:39:52 +00:00
|
|
|
/**
|
|
|
|
* The list of flags used by the #compare function.
|
|
|
|
*
|
2022-03-03 12:20:30 +00:00
|
|
|
* - UNIT This flag relaxes unit, conversion and pin number constraints. It is used for
|
|
|
|
* #LIB_ITEM object unit comparisons.
|
|
|
|
* - EQUALITY This flag relaxes ordering contstraints so that fields, etc. don't have to
|
|
|
|
* appear in the same order to be considered equal.
|
|
|
|
* - ERC This flag relaxes constraints on data that is settable in the schematic editor. It
|
|
|
|
* compares only symbol-editor-only data.
|
2020-02-13 13:39:52 +00:00
|
|
|
*/
|
2022-03-03 12:20:30 +00:00
|
|
|
enum COMPARE_FLAGS : int
|
|
|
|
{
|
|
|
|
UNIT = 0x01,
|
|
|
|
EQUALITY = 0x02,
|
|
|
|
ERC = 0x04
|
|
|
|
};
|
2020-02-13 13:39:52 +00:00
|
|
|
|
2018-01-25 23:49:04 +00:00
|
|
|
/**
|
|
|
|
* Provide a user-consumable name of the object type. Perform localization when
|
|
|
|
* called so that run-time language selection works.
|
|
|
|
*/
|
2020-10-27 11:03:35 +00:00
|
|
|
virtual wxString GetTypeName() const = 0;
|
2010-10-25 15:43:42 +00:00
|
|
|
|
2023-04-29 00:02:42 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
if( !aItem )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
switch ( aItem->Type() )
|
|
|
|
{
|
|
|
|
case LIB_SHAPE_T:
|
|
|
|
case LIB_TEXT_T:
|
|
|
|
case LIB_TEXTBOX_T:
|
|
|
|
case LIB_PIN_T:
|
|
|
|
case LIB_FIELD_T:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-09-03 18:05:33 +00:00
|
|
|
/**
|
|
|
|
* Create a copy of this #LIB_ITEM (with a new Uuid).
|
|
|
|
*/
|
|
|
|
LIB_ITEM* Duplicate() const;
|
|
|
|
|
2010-10-08 20:40:57 +00:00
|
|
|
/**
|
2021-06-14 18:00:08 +00:00
|
|
|
* Begin drawing a symbol library draw item at \a aPosition.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
|
|
|
* It typically would be called on a left click when a draw tool is selected in
|
2021-06-14 18:00:08 +00:00
|
|
|
* the symbol library editor and one of the graphics tools is selected.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
2019-05-20 10:23:32 +00:00
|
|
|
* @param aPosition The position in drawing coordinates where the drawing was started.
|
|
|
|
* May or may not be required depending on the item being drawn.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual void BeginEdit( const VECTOR2I& aPosition ) {}
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
2010-10-20 20:24:26 +00:00
|
|
|
* Continue an edit in progress at \a aPosition.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
2019-05-20 10:23:32 +00:00
|
|
|
* This is used to perform the next action while drawing an item. This would be
|
2010-10-08 20:40:57 +00:00
|
|
|
* called for each additional left click when the mouse is captured while the item
|
2019-05-20 10:23:32 +00:00
|
|
|
* is being drawn.
|
2010-10-20 20:24:26 +00:00
|
|
|
*
|
2012-03-26 23:47:08 +00:00
|
|
|
* @param aPosition The position of the mouse left click in drawing coordinates.
|
2010-10-20 20:24:26 +00:00
|
|
|
* @return True if additional mouse clicks are required to complete the edit in progress.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual bool ContinueEdit( const VECTOR2I& aPosition ) { return false; }
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* End an object editing action.
|
|
|
|
*
|
2010-10-20 20:24:26 +00:00
|
|
|
* This is used to end or abort an edit action in progress initiated by BeginEdit().
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2023-05-07 13:51:17 +00:00
|
|
|
virtual void EndEdit( bool aClosed = false ) {}
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
/**
|
2021-03-25 14:07:16 +00:00
|
|
|
* Calculate the attributes of an item at \a aPosition when it is being edited.
|
2018-08-03 12:18:26 +00:00
|
|
|
*
|
|
|
|
* This method gets called by the Draw() method when the item is being edited. This
|
|
|
|
* probably should be a pure virtual method but bezier curves are not yet editable in
|
2021-06-14 18:00:08 +00:00
|
|
|
* the symbol library editor. Therefore, the default method does nothing.
|
2018-08-03 12:18:26 +00:00
|
|
|
*
|
|
|
|
* @param aPosition The current mouse position in drawing coordinates.
|
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual void CalcEdit( const VECTOR2I& aPosition ) {}
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2010-10-08 20:40:57 +00:00
|
|
|
/**
|
2010-10-20 20:24:26 +00:00
|
|
|
* Draw an item
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
2012-03-26 23:47:08 +00:00
|
|
|
* @param aDC Device Context (can be null)
|
|
|
|
* @param aOffset Offset to draw
|
|
|
|
* @param aData Value or pointer used to pass others parameters, depending on body items.
|
|
|
|
* Used for some items to force to force no fill mode ( has meaning only for
|
|
|
|
* items what can be filled ). used in printing or moving objects mode or to
|
2021-06-14 18:00:08 +00:00
|
|
|
* pass reference to the lib symbol for pins.
|
2012-03-26 23:47:08 +00:00
|
|
|
* @param aTransform Transform Matrix (rotation, mirror ..)
|
2022-09-16 16:20:36 +00:00
|
|
|
* @param aDimmed Dim the color on the printout
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
|
2022-09-16 16:20:36 +00:00
|
|
|
const TRANSFORM& aTransform, bool aDimmed );
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
virtual int GetPenWidth() const = 0;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2022-01-07 00:47:23 +00:00
|
|
|
const wxString& GetDefaultFont() const;
|
|
|
|
|
2023-08-06 19:20:53 +00:00
|
|
|
const KIFONT::METRICS& GetFontMetrics() const;
|
|
|
|
|
2021-08-17 10:59:04 +00:00
|
|
|
virtual int GetEffectivePenWidth( const RENDER_SETTINGS* aSettings ) const
|
|
|
|
{
|
|
|
|
// For historical reasons, a stored value of 0 means "default width" and negative
|
|
|
|
// numbers meant "don't stroke".
|
|
|
|
|
2022-02-06 18:14:07 +00:00
|
|
|
if( GetPenWidth() < 0 )
|
|
|
|
return 0;
|
|
|
|
else if( GetPenWidth() == 0 )
|
|
|
|
return std::max( aSettings->GetDefaultPenWidth(), aSettings->GetMinPenWidth() );
|
2021-08-17 10:59:04 +00:00
|
|
|
else
|
|
|
|
return std::max( GetPenWidth(), aSettings->GetMinPenWidth() );
|
|
|
|
}
|
|
|
|
|
2023-10-04 20:01:33 +00:00
|
|
|
LIB_SYMBOL* GetParent() const // Replace EDA_ITEM::GetParent() with a more useful return-type
|
2010-10-08 20:40:57 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
return (LIB_SYMBOL*) m_parent;
|
2010-10-08 20:40:57 +00:00
|
|
|
}
|
|
|
|
|
2023-09-14 21:39:42 +00:00
|
|
|
/**
|
|
|
|
* Return a measure of how likely the other object is to represent the same
|
|
|
|
* object. The scale runs from 0.0 (definitely different objects) to 1.0 (same)
|
|
|
|
*
|
|
|
|
* This is a pure virtual function. Derived classes must implement this.
|
|
|
|
*/
|
|
|
|
virtual double Similarity( const LIB_ITEM& aItem ) const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate the boilerplate similarity for all LIB_ITEMs without
|
|
|
|
* preventing the use above of a pure virtual function that catches at compile
|
|
|
|
* time when a new object has not been fully implemented
|
|
|
|
*/
|
|
|
|
double SimilarityBase( const LIB_ITEM& aItem ) const
|
|
|
|
{
|
|
|
|
double similarity = 1.0;
|
|
|
|
|
|
|
|
if( m_unit != aItem.m_unit )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
2024-01-26 16:16:13 +00:00
|
|
|
if( m_bodyStyle != aItem.m_bodyStyle )
|
2023-09-14 21:39:42 +00:00
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( m_private != aItem.m_private )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
return similarity;
|
|
|
|
}
|
|
|
|
|
2018-10-21 12:50:31 +00:00
|
|
|
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override
|
2010-10-08 20:40:57 +00:00
|
|
|
{
|
2019-05-05 10:33:34 +00:00
|
|
|
// This is just here to prevent annoying compiler warnings about hidden overloaded
|
|
|
|
// virtual functions
|
|
|
|
return EDA_ITEM::HitTest( aPosition, aAccuracy );
|
2010-10-08 20:40:57 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 09:33:46 +00:00
|
|
|
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2019-05-07 23:51:37 +00:00
|
|
|
/**
|
2010-10-08 20:40:57 +00:00
|
|
|
* @return the boundary box for this, in library coordinates
|
|
|
|
*/
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I GetBoundingBox() const override { return EDA_ITEM::GetBoundingBox(); }
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2010-11-17 18:41:20 +00:00
|
|
|
/**
|
2017-12-01 16:49:19 +00:00
|
|
|
* Display basic info (type, part and convert) about the current item in message panel.
|
2011-10-31 20:49:48 +00:00
|
|
|
* <p>
|
|
|
|
* This base function is used to display the information common to the
|
|
|
|
* all library items. Call the base class from the derived class or the
|
|
|
|
* common information will not be updated in the message panel.
|
|
|
|
* </p>
|
2013-01-12 17:32:24 +00:00
|
|
|
* @param aList is the list to populate.
|
2010-11-17 18:41:20 +00:00
|
|
|
*/
|
2020-04-24 13:36:10 +00:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
2011-04-27 19:44:32 +00:00
|
|
|
* Test LIB_ITEM objects for equivalence.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
2012-03-26 23:47:08 +00:00
|
|
|
* @param aOther Object to test against.
|
|
|
|
* @return True if object is identical to this object.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2023-09-14 21:39:42 +00:00
|
|
|
virtual bool operator==( const LIB_ITEM& aOther ) const;
|
2011-04-27 19:44:32 +00:00
|
|
|
bool operator==( const LIB_ITEM* aOther ) const
|
2010-10-08 20:40:57 +00:00
|
|
|
{
|
|
|
|
return *this == *aOther;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test if another draw item is less than this draw object.
|
|
|
|
*
|
|
|
|
* @param aOther - Draw item to compare against.
|
|
|
|
* @return - True if object is less than this object.
|
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
bool operator<( const LIB_ITEM& aOther) const;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
2017-12-01 16:49:19 +00:00
|
|
|
* Set the drawing object by \a aOffset from the current position.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
2012-02-27 23:02:08 +00:00
|
|
|
* @param aOffset Coordinates to offset the item position.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual void Offset( const VECTOR2I& aOffset ) = 0;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
2017-12-01 16:49:19 +00:00
|
|
|
* Move a draw object to \a aPosition.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
2012-02-27 23:02:08 +00:00
|
|
|
* @param aPosition Position to move draw item to.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual void MoveTo( const VECTOR2I& aPosition ) = 0;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void SetPosition( const VECTOR2I& aPosition ) override { MoveTo( aPosition ); }
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2010-10-08 20:40:57 +00:00
|
|
|
/**
|
2017-12-01 16:49:19 +00:00
|
|
|
* Mirror the draw object along the horizontal (X) axis about \a aCenter point.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
2012-02-27 23:02:08 +00:00
|
|
|
* @param aCenter Point to mirror around.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual void MirrorHorizontal( const VECTOR2I& aCenter ) = 0;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2011-05-20 18:29:35 +00:00
|
|
|
/**
|
2017-12-01 16:49:19 +00:00
|
|
|
* Mirror the draw object along the MirrorVertical (Y) axis about \a aCenter point.
|
2011-05-20 18:29:35 +00:00
|
|
|
*
|
2012-02-27 23:02:08 +00:00
|
|
|
* @param aCenter Point to mirror around.
|
2011-05-20 18:29:35 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual void MirrorVertical( const VECTOR2I& aCenter ) = 0;
|
2011-05-20 18:29:35 +00:00
|
|
|
|
|
|
|
/**
|
2017-12-01 16:49:19 +00:00
|
|
|
* Rotate the object about \a aCenter point.
|
2011-05-20 18:29:35 +00:00
|
|
|
*
|
2012-02-27 23:02:08 +00:00
|
|
|
* @param aCenter Point to rotate around.
|
|
|
|
* @param aRotateCCW True to rotate counter clockwise. False to rotate clockwise.
|
2011-05-20 18:29:35 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) = 0;
|
2011-05-20 18:29:35 +00:00
|
|
|
|
2010-10-08 20:40:57 +00:00
|
|
|
/**
|
|
|
|
* Plot the draw item using the plot object.
|
|
|
|
*
|
2012-02-27 23:02:08 +00:00
|
|
|
* @param aPlotter The plot object to plot to.
|
2022-02-10 19:49:25 +00:00
|
|
|
* @param aBackground a poor-man's Z-order. The routine will get called twice, first with
|
|
|
|
* aBackground true and then with aBackground false.
|
2012-02-27 23:02:08 +00:00
|
|
|
* @param aOffset Plot offset position.
|
|
|
|
* @param aFill Flag to indicate whether or not the object is filled.
|
|
|
|
* @param aTransform The plot transform.
|
2022-09-16 16:20:36 +00:00
|
|
|
* @param aDimmed if true, reduce color to background
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2022-02-10 19:49:25 +00:00
|
|
|
virtual void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset,
|
2022-09-16 16:20:36 +00:00
|
|
|
const TRANSFORM& aTransform, bool aDimmed ) const = 0;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2021-01-26 22:54:10 +00:00
|
|
|
void SetUnit( int aUnit ) { m_unit = aUnit; }
|
|
|
|
int GetUnit() const { return m_unit; }
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2024-01-26 16:16:13 +00:00
|
|
|
void SetBodyStyle( int aBodyStyle ) { m_bodyStyle = aBodyStyle; }
|
|
|
|
int GetBodyStyle() const { return m_bodyStyle; }
|
2010-10-25 15:43:42 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
void SetPrivate( bool aPrivate ) { m_private = aPrivate; }
|
|
|
|
bool IsPrivate() const { return m_private; }
|
|
|
|
|
2023-03-09 17:41:18 +00:00
|
|
|
struct cmp_items
|
|
|
|
{
|
|
|
|
bool operator()( const LIB_ITEM* aFirst, const LIB_ITEM* aSecond ) const;
|
|
|
|
};
|
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
#if defined(DEBUG)
|
2016-09-25 17:06:49 +00:00
|
|
|
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
2011-12-14 17:25:42 +00:00
|
|
|
#endif
|
|
|
|
|
2020-02-13 13:39:52 +00:00
|
|
|
protected:
|
2010-10-08 20:40:57 +00:00
|
|
|
/**
|
2017-12-01 16:49:19 +00:00
|
|
|
* Provide the draw object specific comparison called by the == and < operators.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
2012-03-26 23:47:08 +00:00
|
|
|
* The base object sort order which always proceeds the derived object sort order
|
|
|
|
* is as follows:
|
2021-06-14 18:00:08 +00:00
|
|
|
* - Symbol alternate part (DeMorgan) number.
|
|
|
|
* - Symbol part number.
|
2010-10-08 20:40:57 +00:00
|
|
|
* - KICAD_T enum value.
|
|
|
|
* - Result of derived classes comparison.
|
2012-03-26 23:47:08 +00:00
|
|
|
*
|
2020-02-13 13:39:52 +00:00
|
|
|
* @note Make sure you call down to #LIB_ITEM::compare before doing any derived object
|
|
|
|
* comparisons or you will break the sorting using the symbol library file format.
|
|
|
|
*
|
2012-03-26 23:47:08 +00:00
|
|
|
* @param aOther A reference to the other #LIB_ITEM to compare the arc against.
|
2020-02-13 13:39:52 +00:00
|
|
|
* @param aCompareFlags The flags used to perform the comparison.
|
|
|
|
*
|
2021-06-09 19:32:58 +00:00
|
|
|
* @return An integer value less than 0 if the object is less than \a aOther object,
|
2012-03-26 23:47:08 +00:00
|
|
|
* zero if the object is equal to \a aOther object, or greater than 0 if the
|
|
|
|
* object is greater than \a aOther object.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2022-03-03 12:20:30 +00:00
|
|
|
virtual int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const;
|
2021-01-26 22:54:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Print the item to \a aDC.
|
|
|
|
*
|
|
|
|
* @param aOffset A reference to a wxPoint object containing the offset where to draw
|
|
|
|
* from the object's current position.
|
|
|
|
* @param aData A pointer to any object specific data required to perform the draw.
|
|
|
|
* @param aTransform A reference to a #TRANSFORM object containing drawing transform.
|
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual void print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
|
2022-09-16 16:20:36 +00:00
|
|
|
const TRANSFORM& aTransform, bool aDimmed ) = 0;
|
2021-01-26 22:54:10 +00:00
|
|
|
|
2021-03-25 14:07:16 +00:00
|
|
|
private:
|
2021-06-10 18:51:46 +00:00
|
|
|
friend class LIB_SYMBOL;
|
2021-03-25 14:07:16 +00:00
|
|
|
|
2021-01-26 22:54:10 +00:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Unit identification for multiple parts per package. Set to 0 if the item is common
|
|
|
|
* to all units.
|
|
|
|
*/
|
|
|
|
int m_unit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shape identification for alternate body styles. Set 0 if the item is common to all
|
|
|
|
* body styles. This is typially used for representing DeMorgan variants in KiCad.
|
|
|
|
*/
|
2024-01-26 16:16:13 +00:00
|
|
|
int m_bodyStyle;
|
2022-01-25 22:33:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Private items are shown only in the Symbol Editor.
|
|
|
|
*/
|
|
|
|
bool m_private;
|
2010-10-08 20:40:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
#endif // _LIB_ITEM_H_
|