mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 13:31:42 +00:00
Fold LIB_ITEM into SCH_ITEM.
This commit is contained in:
parent
494001ed4c
commit
5abc7145da
common/widgets
eeschema
CMakeLists.txtsch_item.cppsch_item.hsch_label.cppsch_line.cppsch_no_connect.cppsch_painter.cppsch_painter.hsch_pin.cppsch_screen.cppsch_shape.cppsch_shape.hsch_sheet.cppsch_symbol.cppsch_symbol.hsch_textbox.cppsch_view.cpp
api
dialogs
dialog_lib_edit_pin_table.cppdialog_lib_edit_pin_table.hdialog_lib_shape_properties.cppdialog_symbol_properties.cpp
ee_collectors.cppeeschema_jobs_handler.cpperc.cppgfx_import_utils.cpplib_field.cpplib_field.hlib_item.cpplib_item.hlib_pin.cpplib_pin.hlib_shape.cpplib_shape.hlib_symbol.cpplib_symbol.hlib_text.cpplib_text.hlib_textbox.cpplib_textbox.hnetlist_exporters
picksymbol.cppsch_commit.cppsch_io
cadstar
eagle
easyeda
easyedapro
kicad_legacy
kicad_sexpr
sch_io_kicad_sexpr.cppsch_io_kicad_sexpr_lib_cache.cppsch_io_kicad_sexpr_lib_cache.hsch_io_kicad_sexpr_parser.cppsch_io_kicad_sexpr_parser.h
sch_io_lib_cache.cppsim
symbol_checker.cppsymbol_editor
symbol_viewer_frame.cpptools
ee_grid_helper.hee_inspection_tool.cppee_selection_tool.cppsch_edit_tool.cppsch_editor_control.cppsymbol_editor_control.cppsymbol_editor_drawing_tools.cppsymbol_editor_edit_tool.cppsymbol_editor_edit_tool.hsymbol_editor_move_tool.cppsymbol_editor_pin_tool.cpp
widgets
include
qa/tests/eeschema
@ -245,7 +245,12 @@ void PROPERTIES_PANEL::rebuildProperties( const SELECTION& aSelection )
|
||||
}
|
||||
|
||||
EDA_ITEM* firstItem = aSelection.Front();
|
||||
bool isFootprintEditor = m_frame->IsType( FRAME_FOOTPRINT_EDITOR );
|
||||
|
||||
bool isLibraryEditor = m_frame->IsType( FRAME_FOOTPRINT_EDITOR )
|
||||
|| m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR );
|
||||
|
||||
bool isDesignEditor = m_frame->IsType( FRAME_PCB_EDITOR )
|
||||
|| m_frame->IsType( FRAME_SCH );
|
||||
|
||||
// Find a set of properties that is common to all selected items
|
||||
for( PROPERTY_BASE* property : commonProps )
|
||||
@ -253,7 +258,10 @@ void PROPERTIES_PANEL::rebuildProperties( const SELECTION& aSelection )
|
||||
if( property->IsHiddenFromPropertiesManager() )
|
||||
continue;
|
||||
|
||||
if( isFootprintEditor && property->IsHiddenFromLibraryEditors() )
|
||||
if( isLibraryEditor && property->IsHiddenFromLibraryEditors() )
|
||||
continue;
|
||||
|
||||
if( isDesignEditor && property->IsHiddenFromDesignEditors() )
|
||||
continue;
|
||||
|
||||
if( propMgr.IsAvailableFor( TYPE_HASH( *firstItem ), property, firstItem ) )
|
||||
|
@ -362,8 +362,7 @@ set( EESCHEMA_SRCS
|
||||
gfx_import_utils.cpp
|
||||
picksymbol.cpp
|
||||
lib_field.cpp
|
||||
lib_item.cpp
|
||||
lib_pin.cpp
|
||||
lib_pin.cpp
|
||||
lib_shape.cpp
|
||||
lib_symbol.cpp
|
||||
lib_text.cpp
|
||||
|
@ -265,10 +265,6 @@ HANDLER_RESULT<ItemRequestStatus> API_HANDLER_SCH::handleCreateUpdateItemsIntern
|
||||
schItem->Serialize( newItem );
|
||||
commit->Modify( schItem );
|
||||
}
|
||||
else if( LIB_ITEM* libItem = dynamic_cast<LIB_ITEM*>( edaItem ) )
|
||||
{
|
||||
// TODO: there is not currently a way to do this, haha
|
||||
}
|
||||
else
|
||||
{
|
||||
wxASSERT( false );
|
||||
|
@ -155,7 +155,8 @@ public:
|
||||
return GetValue( m_rows[ aRow ], aCol, m_frame );
|
||||
}
|
||||
|
||||
static wxString GetValue( const LIB_PINS& pins, int aCol, EDA_DRAW_FRAME* aParentFrame )
|
||||
static wxString GetValue( const std::vector<LIB_PIN*>& pins, int aCol,
|
||||
EDA_DRAW_FRAME* aParentFrame )
|
||||
{
|
||||
wxString fieldValue;
|
||||
|
||||
@ -228,10 +229,10 @@ public:
|
||||
case COL_DEMORGAN:
|
||||
switch( pin->GetBodyStyle() )
|
||||
{
|
||||
case LIB_ITEM::BODY_STYLE::BASE:
|
||||
case BODY_STYLE::BASE:
|
||||
val = DEMORGAN_STD;
|
||||
break;
|
||||
case LIB_ITEM::BODY_STYLE::DEMORGAN:
|
||||
case BODY_STYLE::DEMORGAN:
|
||||
val = DEMORGAN_ALT;
|
||||
break;
|
||||
default:
|
||||
@ -291,7 +292,7 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
LIB_PINS pins = m_rows[ aRow ];
|
||||
std::vector<LIB_PIN*> pins = m_rows[ aRow ];
|
||||
|
||||
// If the NUMBER column is edited and the pins are grouped, renumber, and add or
|
||||
// remove pins based on the comma separated list of pins.
|
||||
@ -453,7 +454,7 @@ public:
|
||||
m_edited = true;
|
||||
}
|
||||
|
||||
static int findRow( const std::vector<LIB_PINS>& aRowSet, const wxString& aName )
|
||||
static int findRow( const std::vector<std::vector<LIB_PIN*>>& aRowSet, const wxString& aName )
|
||||
{
|
||||
for( size_t i = 0; i < aRowSet.size(); ++i )
|
||||
{
|
||||
@ -464,8 +465,8 @@ public:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static bool compare( const LIB_PINS& lhs, const LIB_PINS& rhs, int sortCol, bool ascending,
|
||||
EDA_DRAW_FRAME* parentFrame )
|
||||
static bool compare( const std::vector<LIB_PIN*>& lhs, const std::vector<LIB_PIN*>& rhs,
|
||||
int sortCol, bool ascending, EDA_DRAW_FRAME* parentFrame )
|
||||
{
|
||||
wxString lhStr = GetValue( lhs, sortCol, parentFrame );
|
||||
wxString rhStr = GetValue( rhs, sortCol, parentFrame );
|
||||
@ -517,7 +518,7 @@ public:
|
||||
return res;
|
||||
}
|
||||
|
||||
void RebuildRows( const LIB_PINS& aPins, bool groupByName, bool groupBySelection )
|
||||
void RebuildRows( const std::vector<LIB_PIN*>& aPins, bool groupByName, bool groupBySelection )
|
||||
{
|
||||
WX_GRID* grid = dynamic_cast<WX_GRID*>( GetView() );
|
||||
std::vector<LIB_PIN*> clear_flags;
|
||||
@ -557,7 +558,7 @@ public:
|
||||
m_rows.clear();
|
||||
|
||||
if( groupBySelection )
|
||||
m_rows.emplace_back( LIB_PINS() );
|
||||
m_rows.emplace_back( std::vector<LIB_PIN*>() );
|
||||
|
||||
for( LIB_PIN* pin : aPins )
|
||||
{
|
||||
@ -572,7 +573,7 @@ public:
|
||||
|
||||
if( rowIndex < 0 )
|
||||
{
|
||||
m_rows.emplace_back( LIB_PINS() );
|
||||
m_rows.emplace_back( std::vector<LIB_PIN*>() );
|
||||
rowIndex = m_rows.size() - 1;
|
||||
}
|
||||
|
||||
@ -589,7 +590,7 @@ public:
|
||||
ascending = GetView()->IsSortOrderAscending();
|
||||
}
|
||||
|
||||
for( LIB_PINS& row : m_rows )
|
||||
for( std::vector<LIB_PIN*>& row : m_rows )
|
||||
SortPins( row );
|
||||
|
||||
if( !groupBySelection )
|
||||
@ -597,7 +598,7 @@ public:
|
||||
|
||||
if ( GetView() )
|
||||
{
|
||||
wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_rows.size() );
|
||||
wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, (int) m_rows.size() );
|
||||
GetView()->ProcessTableMessage( msg );
|
||||
|
||||
if( groupBySelection )
|
||||
@ -611,13 +612,14 @@ public:
|
||||
void SortRows( int aSortCol, bool ascending )
|
||||
{
|
||||
std::sort( m_rows.begin(), m_rows.end(),
|
||||
[ aSortCol, ascending, this ]( const LIB_PINS& lhs, const LIB_PINS& rhs ) -> bool
|
||||
[ aSortCol, ascending, this ]( const std::vector<LIB_PIN*>& lhs,
|
||||
const std::vector<LIB_PIN*>& rhs ) -> bool
|
||||
{
|
||||
return compare( lhs, rhs, aSortCol, ascending, m_frame );
|
||||
} );
|
||||
}
|
||||
|
||||
void SortPins( LIB_PINS& aRow )
|
||||
void SortPins( std::vector<LIB_PIN*>& aRow )
|
||||
{
|
||||
std::sort( aRow.begin(), aRow.end(),
|
||||
[]( LIB_PIN* lhs, LIB_PIN* rhs ) -> bool
|
||||
@ -628,7 +630,7 @@ public:
|
||||
|
||||
void AppendRow( LIB_PIN* aPin )
|
||||
{
|
||||
LIB_PINS row;
|
||||
std::vector<LIB_PIN*> row;
|
||||
row.push_back( aPin );
|
||||
m_rows.push_back( row );
|
||||
|
||||
@ -639,9 +641,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
LIB_PINS RemoveRow( int aRow )
|
||||
std::vector<LIB_PIN*> RemoveRow( int aRow )
|
||||
{
|
||||
LIB_PINS removedRow = m_rows[ aRow ];
|
||||
std::vector<LIB_PIN*> removedRow = m_rows[ aRow ];
|
||||
|
||||
m_rows.erase( m_rows.begin() + aRow );
|
||||
|
||||
@ -654,7 +656,7 @@ public:
|
||||
return removedRow;
|
||||
}
|
||||
|
||||
LIB_PINS GetRowPins( int aRow )
|
||||
std::vector<LIB_PIN*> GetRowPins( int aRow )
|
||||
{
|
||||
return m_rows[ aRow ];
|
||||
}
|
||||
@ -693,21 +695,21 @@ private:
|
||||
}
|
||||
|
||||
private:
|
||||
SYMBOL_EDIT_FRAME* m_frame;
|
||||
SYMBOL_EDIT_FRAME* m_frame;
|
||||
|
||||
// Because the rows of the grid can either be a single pin or a group of pins, the
|
||||
// data model is a 2D vector. If we're in the single pin case, each row's LIB_PINS
|
||||
// data model is a 2D vector. If we're in the single pin case, each row's LIB_PINs
|
||||
// contains only a single pin.
|
||||
std::vector<LIB_PINS> m_rows;
|
||||
int m_unitFilter; // 0 to show pins for all units
|
||||
std::vector<std::vector<LIB_PIN*>> m_rows;
|
||||
int m_unitFilter; // 0 to show pins for all units
|
||||
|
||||
bool m_edited;
|
||||
bool m_edited;
|
||||
|
||||
DIALOG_LIB_EDIT_PIN_TABLE* m_pinTable;
|
||||
LIB_SYMBOL* m_symbol; // Parent symbol that the pins belong to.
|
||||
DIALOG_LIB_EDIT_PIN_TABLE* m_pinTable;
|
||||
LIB_SYMBOL* m_symbol; // Parent symbol that the pins belong to.
|
||||
|
||||
std::unique_ptr<NUMERIC_EVALUATOR> m_eval;
|
||||
std::map< std::pair<LIB_PINS, int>, wxString > m_evalOriginal;
|
||||
std::unique_ptr<NUMERIC_EVALUATOR> m_eval;
|
||||
std::map< std::pair<std::vector<LIB_PIN*>, int>, wxString > m_evalOriginal;
|
||||
};
|
||||
|
||||
|
||||
@ -1016,7 +1018,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnDeleteRow( wxCommandEvent& event )
|
||||
m_grid->SetGridCursor( nextSelRow, m_grid->GetGridCursorCol() );
|
||||
m_grid->SelectRow( nextSelRow );
|
||||
|
||||
LIB_PINS removedRow = m_dataModel->RemoveRow( curRow );
|
||||
std::vector<LIB_PIN*> removedRow = m_dataModel->RemoveRow( curRow );
|
||||
|
||||
for( LIB_PIN* pin : removedRow )
|
||||
m_pins.erase( std::find( m_pins.begin(), m_pins.end(), pin ) );
|
||||
@ -1044,7 +1046,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnCellSelected( wxGridEvent& event )
|
||||
|
||||
if( event.GetRow() >= 0 && event.GetRow() < m_dataModel->GetNumberRows() )
|
||||
{
|
||||
const LIB_PINS& pins = m_dataModel->GetRowPins( event.GetRow() );
|
||||
const std::vector<LIB_PIN*>& pins = m_dataModel->GetRowPins( event.GetRow() );
|
||||
|
||||
if( pins.size() == 1 && m_editFrame->GetCurSymbol() )
|
||||
{
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#include "dialog_lib_edit_pin_table_base.h"
|
||||
|
||||
#include <lib_item.h>
|
||||
#include <lib_pin.h>
|
||||
#include <symbol_library.h>
|
||||
|
||||
enum COL_ORDER
|
||||
@ -87,7 +87,7 @@ protected:
|
||||
int m_originalColWidths[ COL_COUNT ];
|
||||
std::bitset<64> m_columnsShown;
|
||||
LIB_SYMBOL* m_symbol;
|
||||
LIB_PINS m_pins; // a copy of the pins owned by me
|
||||
std::vector<LIB_PIN*> m_pins; // a copy of the pins owned by me
|
||||
bool m_modified; ///< true when there are unsaved changes
|
||||
wxSize m_size;
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <lib_item.h>
|
||||
#include <dialog_lib_shape_properties.h>
|
||||
#include <symbol_edit_frame.h>
|
||||
#include <symbol_editor_settings.h>
|
||||
|
@ -501,7 +501,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow()
|
||||
|
||||
if( m_part && m_part->HasAlternateBodyStyle() )
|
||||
{
|
||||
if( m_symbol->GetBodyStyle() > LIB_ITEM::BODY_STYLE::BASE )
|
||||
if( m_symbol->GetBodyStyle() > BODY_STYLE::BASE )
|
||||
m_cbAlternateSymbol->SetValue( true );
|
||||
}
|
||||
else
|
||||
@ -696,9 +696,9 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow()
|
||||
|
||||
// For symbols with multiple shapes (De Morgan representation) Set the selected shape:
|
||||
if( m_cbAlternateSymbol->IsEnabled() && m_cbAlternateSymbol->GetValue() )
|
||||
m_symbol->SetBodyStyle( LIB_ITEM::BODY_STYLE::DEMORGAN );
|
||||
m_symbol->SetBodyStyle( BODY_STYLE::DEMORGAN );
|
||||
else
|
||||
m_symbol->SetBodyStyle( LIB_ITEM::BODY_STYLE::BASE );
|
||||
m_symbol->SetBodyStyle( BODY_STYLE::BASE );
|
||||
|
||||
//Set the part selection in multiple part per package
|
||||
int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include <macros.h>
|
||||
#include <trace_helpers.h>
|
||||
#include <ee_collectors.h>
|
||||
#include <lib_item.h>
|
||||
#include <sch_bus_entry.h>
|
||||
#include <sch_symbol.h>
|
||||
#include <sch_line.h>
|
||||
@ -92,17 +91,17 @@ INSPECT_RESULT EE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
|
||||
{
|
||||
if( m_Unit || m_BodyStyle )
|
||||
{
|
||||
LIB_ITEM* lib_item = dynamic_cast<LIB_ITEM*>( aItem );
|
||||
SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( aItem );
|
||||
|
||||
// Special selection rules apply to pins of different units when edited in synchronized
|
||||
// pins mode. Leave it to EE_SELECTION_TOOL::Selectable() to decide what to do with them.
|
||||
|
||||
if( lib_item && lib_item->Type() != LIB_PIN_T )
|
||||
if( schItem && schItem->Type() != LIB_PIN_T )
|
||||
{
|
||||
if( m_Unit && lib_item->GetUnit() && lib_item->GetUnit() != m_Unit )
|
||||
if( m_Unit && schItem->GetUnit() && schItem->GetUnit() != m_Unit )
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
|
||||
if( m_BodyStyle && lib_item->GetBodyStyle() && lib_item->GetBodyStyle() != m_BodyStyle )
|
||||
if( m_BodyStyle && schItem->GetBodyStyle() && schItem->GetBodyStyle() != m_BodyStyle )
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
}
|
||||
}
|
||||
@ -151,7 +150,7 @@ void EE_COLLECTOR::Collect( LIB_ITEMS_CONTAINER& aItems, const std::vector<KICAD
|
||||
// remember where the snapshot was taken from and pass refPos to the Inspect() function.
|
||||
SetRefPos( aPos );
|
||||
|
||||
for( LIB_ITEM& item : aItems )
|
||||
for( SCH_ITEM& item : aItems )
|
||||
{
|
||||
if( item.Visit( m_inspector, nullptr, m_scanTypes ) == INSPECT_RESULT::QUIT )
|
||||
break;
|
||||
|
@ -687,7 +687,7 @@ int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob,
|
||||
if( aSvgJob->m_includeHiddenPins )
|
||||
{
|
||||
// horrible hack, TODO overhaul the Plot method to handle this
|
||||
for( LIB_ITEM& item : symbolToPlot->GetDrawItems() )
|
||||
for( SCH_ITEM& item : symbolToPlot->GetDrawItems() )
|
||||
{
|
||||
if( item.Type() != LIB_PIN_T )
|
||||
continue;
|
||||
|
@ -493,21 +493,21 @@ int ERC_TESTER::TestMissingUnits()
|
||||
|
||||
for( int missing_unit : missing_units )
|
||||
{
|
||||
LIB_PINS pins;
|
||||
int convert = 0;
|
||||
std::vector<LIB_PIN*> pins;
|
||||
int bodyStyle = 0;
|
||||
|
||||
for( size_t ii = 0; ii < refList.GetCount(); ++ii )
|
||||
{
|
||||
if( refList.GetItem( ii ).GetUnit() == missing_unit )
|
||||
{
|
||||
convert = refList.GetItem( ii ).GetSymbol()->GetBodyStyle();
|
||||
bodyStyle = refList.GetItem( ii ).GetSymbol()->GetBodyStyle();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
libSymbol->GetPins( pins, missing_unit, convert );
|
||||
libSymbol->GetPins( pins, missing_unit, bodyStyle );
|
||||
|
||||
for( auto pin : pins )
|
||||
for( LIB_PIN* pin : pins )
|
||||
{
|
||||
switch( pin->GetType() )
|
||||
{
|
||||
@ -1012,7 +1012,7 @@ int ERC_TESTER::TestLibSymbolIssues()
|
||||
}
|
||||
|
||||
std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->Flatten();
|
||||
constexpr int flags = LIB_ITEM::COMPARE_FLAGS::EQUALITY | LIB_ITEM::COMPARE_FLAGS::ERC;
|
||||
constexpr int flags = SCH_ITEM::COMPARE_FLAGS::EQUALITY | SCH_ITEM::COMPARE_FLAGS::ERC;
|
||||
|
||||
if( settings.IsTestEnabled( ERCE_LIB_SYMBOL_MISMATCH )
|
||||
&& flattenedSymbol->Compare( *libSymbolInSchematic, flags ) != 0 )
|
||||
|
@ -134,7 +134,7 @@ void ConvertImageToLibShapes( LIB_SYMBOL* aSymbol, int unit, wxImage img, VECTOR
|
||||
|
||||
shape->SetUnit( unit );
|
||||
|
||||
shape->Offset( offset );
|
||||
shape->Move( offset );
|
||||
|
||||
aSymbol->AddDrawItem( shape.release() );
|
||||
}
|
||||
|
@ -39,8 +39,8 @@
|
||||
#include <settings/color_settings.h>
|
||||
|
||||
|
||||
LIB_FIELD::LIB_FIELD( LIB_SYMBOL* aParent, int aId, const wxString& aName ) :
|
||||
LIB_ITEM( LIB_FIELD_T, aParent ),
|
||||
LIB_FIELD::LIB_FIELD( SCH_ITEM* aParent, int aId, const wxString& aName ) :
|
||||
SCH_ITEM( aParent, LIB_FIELD_T ),
|
||||
EDA_TEXT( schIUScale )
|
||||
{
|
||||
Init( aId );
|
||||
@ -49,7 +49,7 @@ LIB_FIELD::LIB_FIELD( LIB_SYMBOL* aParent, int aId, const wxString& aName ) :
|
||||
|
||||
|
||||
LIB_FIELD::LIB_FIELD( int aId ) :
|
||||
LIB_ITEM( LIB_FIELD_T, nullptr ),
|
||||
SCH_ITEM( nullptr, LIB_FIELD_T ),
|
||||
EDA_TEXT( schIUScale )
|
||||
{
|
||||
Init( aId );
|
||||
@ -57,7 +57,7 @@ LIB_FIELD::LIB_FIELD( int aId ) :
|
||||
|
||||
|
||||
LIB_FIELD::LIB_FIELD( int aId, const wxString& aName ) :
|
||||
LIB_ITEM( LIB_FIELD_T, nullptr ),
|
||||
SCH_ITEM( nullptr, LIB_FIELD_T ),
|
||||
EDA_TEXT( schIUScale )
|
||||
{
|
||||
Init( aId );
|
||||
@ -193,6 +193,23 @@ bool LIB_FIELD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
|
||||
}
|
||||
|
||||
|
||||
bool LIB_FIELD::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
|
||||
{
|
||||
if( m_flags & (STRUCT_DELETED | SKIP_STRUCT ) )
|
||||
return false;
|
||||
|
||||
BOX2I sel = aRect;
|
||||
|
||||
if ( aAccuracy )
|
||||
sel.Inflate( aAccuracy );
|
||||
|
||||
if( aContained )
|
||||
return sel.Contains( GetBoundingBox() );
|
||||
|
||||
return sel.Intersects( GetBoundingBox() );
|
||||
}
|
||||
|
||||
|
||||
EDA_ITEM* LIB_FIELD::Clone() const
|
||||
{
|
||||
return new LIB_FIELD( *this );
|
||||
@ -213,11 +230,11 @@ void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const
|
||||
}
|
||||
|
||||
|
||||
int LIB_FIELD::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
|
||||
int LIB_FIELD::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
|
||||
{
|
||||
wxASSERT( aOther.Type() == LIB_FIELD_T );
|
||||
|
||||
int retv = LIB_ITEM::compare( aOther, aCompareFlags );
|
||||
int retv = SCH_ITEM::compare( aOther, aCompareFlags );
|
||||
|
||||
if( retv )
|
||||
return retv;
|
||||
@ -226,7 +243,7 @@ int LIB_FIELD::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
|
||||
|
||||
// Equality test will vary depending whether or not the field is mandatory. Otherwise,
|
||||
// sorting is done by ordinal.
|
||||
if( aCompareFlags & LIB_ITEM::COMPARE_FLAGS::EQUALITY )
|
||||
if( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY )
|
||||
{
|
||||
// Mandatory fields have fixed ordinals and their names can vary due to translated field
|
||||
// names. Optional fields have fixed names and their ordinals can vary.
|
||||
@ -251,10 +268,10 @@ int LIB_FIELD::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
|
||||
|
||||
bool ignoreFieldText = false;
|
||||
|
||||
if( m_id == REFERENCE_FIELD && !( aCompareFlags & COMPARE_FLAGS::EQUALITY ) )
|
||||
if( m_id == REFERENCE_FIELD && !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY ) )
|
||||
ignoreFieldText = true;
|
||||
|
||||
if( m_id == VALUE_FIELD && ( aCompareFlags & COMPARE_FLAGS::ERC ) )
|
||||
if( m_id == VALUE_FIELD && ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) )
|
||||
ignoreFieldText = true;
|
||||
|
||||
if( !ignoreFieldText )
|
||||
@ -265,7 +282,7 @@ int LIB_FIELD::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
|
||||
return retv;
|
||||
}
|
||||
|
||||
if( aCompareFlags & LIB_ITEM::COMPARE_FLAGS::EQUALITY )
|
||||
if( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY )
|
||||
{
|
||||
if( GetTextPos().x != tmp->GetTextPos().x )
|
||||
return GetTextPos().x - tmp->GetTextPos().x;
|
||||
@ -284,13 +301,13 @@ int LIB_FIELD::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
|
||||
}
|
||||
|
||||
|
||||
void LIB_FIELD::Offset( const VECTOR2I& aOffset )
|
||||
void LIB_FIELD::Move( const VECTOR2I& aOffset )
|
||||
{
|
||||
EDA_TEXT::Offset( aOffset );
|
||||
}
|
||||
|
||||
|
||||
void LIB_FIELD::MoveTo( const VECTOR2I& newPosition )
|
||||
void LIB_FIELD::SetPosition( const VECTOR2I& newPosition )
|
||||
{
|
||||
EDA_TEXT::SetTextPos( newPosition );
|
||||
}
|
||||
@ -534,7 +551,7 @@ void LIB_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
LIB_ITEM::GetMsgPanelInfo( aFrame, aList );
|
||||
getSymbolEditorMsgPanelInfo( aFrame, aList );
|
||||
|
||||
// Don't use GetShownText(); we want to see the variable references here
|
||||
aList.emplace_back( _( "Field" ), UnescapeString( GetName() ) );
|
||||
@ -584,7 +601,7 @@ bool LIB_FIELD::IsMandatory() const
|
||||
}
|
||||
|
||||
|
||||
bool LIB_FIELD::operator==( const LIB_ITEM& aItem ) const
|
||||
bool LIB_FIELD::operator==( const SCH_ITEM& aItem ) const
|
||||
{
|
||||
if( aItem.Type() != LIB_FIELD_T )
|
||||
return false;
|
||||
@ -613,7 +630,7 @@ bool LIB_FIELD::operator==( const LIB_ITEM& aItem ) const
|
||||
}
|
||||
|
||||
|
||||
double LIB_FIELD::Similarity( const LIB_ITEM& aItem ) const
|
||||
double LIB_FIELD::Similarity( const SCH_ITEM& aItem ) const
|
||||
{
|
||||
if( aItem.Type() != LIB_FIELD_T )
|
||||
return 0.0;
|
||||
@ -648,9 +665,9 @@ static struct LIB_FIELD_DESC
|
||||
{
|
||||
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
||||
REGISTER_TYPE( LIB_FIELD );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<LIB_FIELD, LIB_ITEM> );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<LIB_FIELD, SCH_ITEM> );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<LIB_FIELD, EDA_TEXT> );
|
||||
propMgr.InheritsAfter( TYPE_HASH( LIB_FIELD ), TYPE_HASH( LIB_ITEM ) );
|
||||
propMgr.InheritsAfter( TYPE_HASH( LIB_FIELD ), TYPE_HASH( SCH_ITEM ) );
|
||||
propMgr.InheritsAfter( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ) );
|
||||
|
||||
propMgr.AddProperty( new PROPERTY<LIB_FIELD, bool>( _HKI( "Show Field Name" ),
|
||||
|
@ -31,7 +31,7 @@
|
||||
#define CLASS_LIBENTRY_FIELDS_H
|
||||
|
||||
#include <eda_text.h>
|
||||
#include <lib_item.h>
|
||||
#include <sch_item.h>
|
||||
|
||||
|
||||
class SCH_IO_KICAD_LEGACY_LIB_CACHE;
|
||||
@ -58,14 +58,14 @@ class SCH_IO_KICAD_LEGACY_LIB_CACHE;
|
||||
*
|
||||
* @see enum MANDATORY_FIELD_T
|
||||
*/
|
||||
class LIB_FIELD : public LIB_ITEM, public EDA_TEXT
|
||||
class LIB_FIELD : public SCH_ITEM, public EDA_TEXT
|
||||
{
|
||||
public:
|
||||
LIB_FIELD( int aId = 2 );
|
||||
|
||||
LIB_FIELD( int aId, const wxString& aName );
|
||||
|
||||
LIB_FIELD( LIB_SYMBOL* aParent, int aId = 2, const wxString& aName = wxEmptyString );
|
||||
LIB_FIELD( SCH_ITEM* aParent, int aId = 2, const wxString& aName = wxEmptyString );
|
||||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
|
||||
@ -144,6 +144,7 @@ public:
|
||||
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
||||
|
||||
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
|
||||
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const override;
|
||||
|
||||
LIB_FIELD& operator=( const LIB_FIELD& field );
|
||||
|
||||
@ -165,9 +166,9 @@ public:
|
||||
|
||||
void BeginEdit( const VECTOR2I& aStartPoint ) override;
|
||||
|
||||
void Offset( const VECTOR2I& aOffset ) override;
|
||||
void Move( const VECTOR2I& aOffset ) override;
|
||||
|
||||
void MoveTo( const VECTOR2I& aPosition ) override;
|
||||
void SetPosition( const VECTOR2I& aPosition ) override;
|
||||
|
||||
VECTOR2I GetPosition() const override { return EDA_TEXT::GetTextPos(); }
|
||||
|
||||
@ -201,14 +202,14 @@ public:
|
||||
bool ShowInChooser() const { return m_showInChooser; }
|
||||
void SetShowInChooser( bool aShow = true ) { m_showInChooser = aShow; }
|
||||
|
||||
double Similarity( const LIB_ITEM& aItem ) const override;
|
||||
double Similarity( const SCH_ITEM& aItem ) const override;
|
||||
|
||||
bool operator==( const LIB_ITEM& aItem ) const override;
|
||||
bool operator==( const SCH_ITEM& aItem ) const override;
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* @copydoc LIB_ITEM::compare()
|
||||
* @copydoc SCH_ITEM::compare()
|
||||
*
|
||||
* The field specific sort order is as follows:
|
||||
*
|
||||
@ -219,7 +220,7 @@ private:
|
||||
* - Field width.
|
||||
* - Field height.
|
||||
*/
|
||||
int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override;
|
||||
int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
|
||||
|
||||
/**
|
||||
* Calculate the new circle at \a aPosition when editing.
|
||||
|
@ -1,225 +0,0 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr
|
||||
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2023 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <i18n_utility.h>
|
||||
#include <pgm_base.h>
|
||||
#include <font/font.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <eeschema_settings.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <widgets/msgpanel.h>
|
||||
#include <lib_symbol.h>
|
||||
|
||||
const int fill_tab[3] = { 'N', 'F', 'f' };
|
||||
|
||||
|
||||
LIB_ITEM::LIB_ITEM( KICAD_T aType, LIB_SYMBOL* aSymbol, int aUnit, int aConvert ) :
|
||||
EDA_ITEM( aSymbol, aType ),
|
||||
m_unit( aUnit ),
|
||||
m_bodyStyle( aConvert ),
|
||||
m_private( false )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
wxString LIB_ITEM::GetUnitDescription( int aUnit )
|
||||
{
|
||||
if( aUnit == 0 )
|
||||
return _( "All" );
|
||||
else
|
||||
return LIB_SYMBOL::LetterSubReference( aUnit, 'A' );
|
||||
}
|
||||
|
||||
|
||||
wxString LIB_ITEM::GetBodyStyleDescription( int aBodyStyle )
|
||||
{
|
||||
if( aBodyStyle == 0 )
|
||||
return _( "All" );
|
||||
else if( aBodyStyle == LIB_ITEM::BODY_STYLE::DEMORGAN )
|
||||
return _( "Alternate" );
|
||||
else if( aBodyStyle == LIB_ITEM::BODY_STYLE::BASE )
|
||||
return _( "Standard" );
|
||||
else
|
||||
return wxT( "?" );
|
||||
}
|
||||
|
||||
|
||||
void LIB_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
aList.emplace_back( _( "Type" ), GetFriendlyName() );
|
||||
|
||||
if( const SYMBOL* parent = GetParentSymbol() )
|
||||
{
|
||||
if( parent->GetUnitCount() )
|
||||
aList.emplace_back( _( "Unit" ), GetUnitDescription( m_unit ) );
|
||||
|
||||
if( parent->HasAlternateBodyStyle() )
|
||||
aList.emplace_back( _( "Body Style" ), GetBodyStyleDescription( m_bodyStyle ) );
|
||||
}
|
||||
|
||||
if( IsPrivate() )
|
||||
aList.emplace_back( _( "Private" ), wxEmptyString );
|
||||
}
|
||||
|
||||
|
||||
int LIB_ITEM::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
|
||||
{
|
||||
if( Type() != aOther.Type() )
|
||||
return Type() - aOther.Type();
|
||||
|
||||
// When comparing unit LIB_ITEM objects, we ignore the unit number.
|
||||
if( !( aCompareFlags & COMPARE_FLAGS::UNIT ) && m_unit != aOther.m_unit )
|
||||
return m_unit - aOther.m_unit;
|
||||
|
||||
if( !( aCompareFlags & COMPARE_FLAGS::UNIT ) && m_bodyStyle != aOther.m_bodyStyle )
|
||||
return m_bodyStyle - aOther.m_bodyStyle;
|
||||
|
||||
if( IsPrivate() != aOther.IsPrivate() )
|
||||
return IsPrivate() < aOther.IsPrivate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool LIB_ITEM::cmp_items::operator()( const LIB_ITEM* aFirst, const LIB_ITEM* aSecond ) const
|
||||
{
|
||||
return aFirst->compare( *aSecond, LIB_ITEM::COMPARE_FLAGS::EQUALITY ) < 0;
|
||||
}
|
||||
|
||||
|
||||
bool LIB_ITEM::operator==( const LIB_ITEM& aOther ) const
|
||||
{
|
||||
if( Type() != aOther.Type() )
|
||||
return false;
|
||||
|
||||
return compare( aOther, LIB_ITEM::COMPARE_FLAGS::EQUALITY ) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool LIB_ITEM::operator<( const LIB_ITEM& aOther ) const
|
||||
{
|
||||
if( Type() != aOther.Type() )
|
||||
return Type() < aOther.Type();
|
||||
|
||||
return ( compare( aOther ) < 0 );
|
||||
}
|
||||
|
||||
|
||||
LIB_ITEM* LIB_ITEM::Duplicate() const
|
||||
{
|
||||
LIB_ITEM* dupe = static_cast<LIB_ITEM*>( Clone() );
|
||||
const_cast<KIID&>( dupe->m_Uuid ) = KIID();
|
||||
|
||||
return dupe;
|
||||
}
|
||||
|
||||
|
||||
bool LIB_ITEM::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
|
||||
{
|
||||
if( m_flags & (STRUCT_DELETED | SKIP_STRUCT ) )
|
||||
return false;
|
||||
|
||||
BOX2I sel = aRect;
|
||||
|
||||
if ( aAccuracy )
|
||||
sel.Inflate( aAccuracy );
|
||||
|
||||
if( aContained )
|
||||
return sel.Contains( GetBoundingBox() );
|
||||
|
||||
return sel.Intersects( GetBoundingBox() );
|
||||
}
|
||||
|
||||
|
||||
const wxString& LIB_ITEM::GetDefaultFont() const
|
||||
{
|
||||
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
||||
|
||||
return cfg->m_Appearance.default_font;
|
||||
}
|
||||
|
||||
|
||||
const KIFONT::METRICS& LIB_ITEM::GetFontMetrics() const
|
||||
{
|
||||
return KIFONT::METRICS::Default();
|
||||
}
|
||||
|
||||
|
||||
void LIB_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
// Basic fallback
|
||||
aCount = 3;
|
||||
aLayers[0] = LAYER_DEVICE;
|
||||
aLayers[1] = LAYER_DEVICE_BACKGROUND;
|
||||
aLayers[2] = LAYER_SELECTION_SHADOWS;
|
||||
}
|
||||
|
||||
|
||||
static struct LIB_ITEM_DESC
|
||||
{
|
||||
LIB_ITEM_DESC()
|
||||
{
|
||||
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
||||
REGISTER_TYPE( LIB_ITEM );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<LIB_ITEM, EDA_ITEM> );
|
||||
propMgr.InheritsAfter( TYPE_HASH( LIB_ITEM ), TYPE_HASH( EDA_ITEM ) );
|
||||
|
||||
auto multiUnit =
|
||||
[=]( INSPECTABLE* aItem ) -> bool
|
||||
{
|
||||
if( LIB_ITEM* libItem = dynamic_cast<LIB_ITEM*>( aItem ) )
|
||||
{
|
||||
if( const SYMBOL* symbol = libItem->GetParentSymbol() )
|
||||
return symbol->IsMulti();
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
auto multiBodyStyle =
|
||||
[=]( INSPECTABLE* aItem ) -> bool
|
||||
{
|
||||
if( LIB_ITEM* libItem = dynamic_cast<LIB_ITEM*>( aItem ) )
|
||||
{
|
||||
if( const SYMBOL* symbol = libItem->GetParentSymbol() )
|
||||
return symbol->HasAlternateBodyStyle();
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
propMgr.AddProperty( new PROPERTY<LIB_ITEM, int>( _HKI( "Unit" ),
|
||||
&LIB_ITEM::SetUnit, &LIB_ITEM::GetUnit ) )
|
||||
.SetAvailableFunc( multiUnit );
|
||||
propMgr.AddProperty( new PROPERTY<LIB_ITEM, int>( _HKI( "Body Style" ),
|
||||
&LIB_ITEM::SetBodyStyle, &LIB_ITEM::GetBodyStyle ) )
|
||||
.SetAvailableFunc( multiBodyStyle );
|
||||
|
||||
propMgr.AddProperty( new PROPERTY<LIB_ITEM, bool>( _HKI( "Private" ),
|
||||
&LIB_ITEM::SetPrivate, &LIB_ITEM::IsPrivate ) );
|
||||
}
|
||||
} _LIB_ITEM_DESC;
|
@ -1,409 +0,0 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr
|
||||
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef _LIB_ITEM_H_
|
||||
#define _LIB_ITEM_H_
|
||||
|
||||
#include <eda_item.h>
|
||||
#include <eda_shape.h>
|
||||
#include <symbol.h>
|
||||
#include <transform.h>
|
||||
#include <render_settings.h>
|
||||
|
||||
class LINE_READER;
|
||||
class OUTPUTFORMATTER;
|
||||
class LIB_SYMBOL;
|
||||
class PLOTTER;
|
||||
class LIB_PIN;
|
||||
class MSG_PANEL_ITEM;
|
||||
|
||||
namespace KIFONT
|
||||
{
|
||||
class FONT;
|
||||
class METRICS;
|
||||
}
|
||||
|
||||
|
||||
using KIGFX::RENDER_SETTINGS;
|
||||
|
||||
extern const int fill_tab[];
|
||||
|
||||
|
||||
#define MINIMUM_SELECTION_DISTANCE 2 // Minimum selection distance in internal units
|
||||
|
||||
|
||||
/**
|
||||
* Helper for defining a list of pin object pointers. The list does not
|
||||
* use a Boost pointer class so the object pointers do not accidentally get
|
||||
* deleted when the container is deleted.
|
||||
*/
|
||||
typedef std::vector< LIB_PIN* > LIB_PINS;
|
||||
|
||||
|
||||
/**
|
||||
* The base class for drawable items used by schematic library symbols.
|
||||
*/
|
||||
class LIB_ITEM : public EDA_ITEM
|
||||
{
|
||||
public:
|
||||
LIB_ITEM( KICAD_T aType, LIB_SYMBOL* aSymbol = nullptr, int aUnit = 0, int aConvert = 0 );
|
||||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
|
||||
virtual ~LIB_ITEM() { }
|
||||
|
||||
// Define the enums for basic body styles
|
||||
enum BODY_STYLE : int
|
||||
{
|
||||
BASE = 1,
|
||||
DEMORGAN = 2
|
||||
};
|
||||
|
||||
/**
|
||||
* The list of flags used by the #compare function.
|
||||
*
|
||||
* - 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.
|
||||
*/
|
||||
enum COMPARE_FLAGS : int
|
||||
{
|
||||
UNIT = 0x01,
|
||||
EQUALITY = 0x02,
|
||||
ERC = 0x04
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static wxString GetUnitDescription( int aUnit );
|
||||
static wxString GetBodyStyleDescription( int aBodyStyle );
|
||||
|
||||
/**
|
||||
* Create a copy of this #LIB_ITEM (with a new Uuid).
|
||||
*/
|
||||
LIB_ITEM* Duplicate() const;
|
||||
|
||||
/**
|
||||
* Begin drawing a symbol library draw item at \a aPosition.
|
||||
*
|
||||
* It typically would be called on a left click when a draw tool is selected in
|
||||
* the symbol library editor and one of the graphics tools is selected.
|
||||
*
|
||||
* @param aPosition The position in drawing coordinates where the drawing was started.
|
||||
* May or may not be required depending on the item being drawn.
|
||||
*/
|
||||
virtual void BeginEdit( const VECTOR2I& aPosition ) {}
|
||||
|
||||
/**
|
||||
* Continue an edit in progress at \a aPosition.
|
||||
*
|
||||
* This is used to perform the next action while drawing an item. This would be
|
||||
* called for each additional left click when the mouse is captured while the item
|
||||
* is being drawn.
|
||||
*
|
||||
* @param aPosition The position of the mouse left click in drawing coordinates.
|
||||
* @return True if additional mouse clicks are required to complete the edit in progress.
|
||||
*/
|
||||
virtual bool ContinueEdit( const VECTOR2I& aPosition ) { return false; }
|
||||
|
||||
/**
|
||||
* End an object editing action.
|
||||
*
|
||||
* This is used to end or abort an edit action in progress initiated by BeginEdit().
|
||||
*/
|
||||
virtual void EndEdit( bool aClosed = false ) {}
|
||||
|
||||
/**
|
||||
* Calculate the attributes of an item at \a aPosition when it is being edited.
|
||||
*
|
||||
* 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
|
||||
* the symbol library editor. Therefore, the default method does nothing.
|
||||
*
|
||||
* @param aPosition The current mouse position in drawing coordinates.
|
||||
*/
|
||||
virtual void CalcEdit( const VECTOR2I& aPosition ) {}
|
||||
|
||||
virtual int GetPenWidth() const = 0;
|
||||
|
||||
const wxString& GetDefaultFont() const;
|
||||
|
||||
const KIFONT::METRICS& GetFontMetrics() const;
|
||||
|
||||
virtual int GetEffectivePenWidth( const SCH_RENDER_SETTINGS* aSettings ) const
|
||||
{
|
||||
// For historical reasons, a stored value of 0 means "default width" and negative
|
||||
// numbers meant "don't stroke".
|
||||
|
||||
if( GetPenWidth() < 0 )
|
||||
return 0;
|
||||
else if( GetPenWidth() == 0 )
|
||||
return std::max( aSettings->GetDefaultPenWidth(), aSettings->GetMinPenWidth() );
|
||||
else
|
||||
return std::max( GetPenWidth(), aSettings->GetMinPenWidth() );
|
||||
}
|
||||
|
||||
const SYMBOL* GetParentSymbol() const
|
||||
{
|
||||
wxCHECK( m_parent->Type() == LIB_SYMBOL_T, nullptr );
|
||||
return static_cast<const SYMBOL*>( m_parent );
|
||||
}
|
||||
|
||||
SYMBOL* GetParentSymbol()
|
||||
{
|
||||
wxCHECK( m_parent->Type() == LIB_SYMBOL_T, nullptr );
|
||||
return static_cast<SYMBOL*>( m_parent );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
if( m_bodyStyle != aItem.m_bodyStyle )
|
||||
similarity *= 0.9;
|
||||
|
||||
if( m_private != aItem.m_private )
|
||||
similarity *= 0.9;
|
||||
|
||||
return similarity;
|
||||
}
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override
|
||||
{
|
||||
// This is just here to prevent annoying compiler warnings about hidden overloaded
|
||||
// virtual functions
|
||||
return EDA_ITEM::HitTest( aPosition, aAccuracy );
|
||||
}
|
||||
|
||||
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
||||
|
||||
/**
|
||||
* @return the boundary box for this, in library coordinates
|
||||
*/
|
||||
const BOX2I GetBoundingBox() const override { return EDA_ITEM::GetBoundingBox(); }
|
||||
|
||||
/**
|
||||
* Display basic info (type, part and convert) about the current item in message panel.
|
||||
* <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>
|
||||
* @param aList is the list to populate.
|
||||
*/
|
||||
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
||||
|
||||
/**
|
||||
* Test LIB_ITEM objects for equivalence.
|
||||
*
|
||||
* @param aOther Object to test against.
|
||||
* @return True if object is identical to this object.
|
||||
*/
|
||||
virtual bool operator==( const LIB_ITEM& aOther ) const;
|
||||
bool operator==( const LIB_ITEM* aOther ) const
|
||||
{
|
||||
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.
|
||||
*/
|
||||
bool operator<( const LIB_ITEM& aOther) const;
|
||||
|
||||
/**
|
||||
* Set the drawing object by \a aOffset from the current position.
|
||||
*
|
||||
* @param aOffset Coordinates to offset the item position.
|
||||
*/
|
||||
virtual void Offset( const VECTOR2I& aOffset ) = 0;
|
||||
|
||||
/**
|
||||
* Move a draw object to \a aPosition.
|
||||
*
|
||||
* @param aPosition Position to move draw item to.
|
||||
*/
|
||||
virtual void MoveTo( const VECTOR2I& aPosition ) = 0;
|
||||
|
||||
void SetPosition( const VECTOR2I& aPosition ) override { MoveTo( aPosition ); }
|
||||
|
||||
/**
|
||||
* Mirror the draw object along the horizontal (X) axis about \a aCenter point.
|
||||
*
|
||||
* @param aCenter Point to mirror around.
|
||||
*/
|
||||
virtual void MirrorHorizontally( int aCenter ) = 0;
|
||||
|
||||
/**
|
||||
* Mirror the draw object along the MirrorVertical (Y) axis about \a aCenter point.
|
||||
*
|
||||
* @param aCenter Point to mirror around.
|
||||
*/
|
||||
virtual void MirrorVertically( int aCenter ) = 0;
|
||||
|
||||
/**
|
||||
* Rotate the object about \a aCenter point.
|
||||
*
|
||||
* @param aCenter Point to rotate around.
|
||||
* @param aRotateCCW True to rotate counter clockwise. False to rotate clockwise.
|
||||
*/
|
||||
virtual void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) = 0;
|
||||
|
||||
/**
|
||||
* Print an item.
|
||||
*
|
||||
* @param aUnit - which unit to print.
|
||||
* @param aBodyStyle - which body style to print.
|
||||
* @param aOffset - relative offset.
|
||||
* @param aForceNoFill - disable printing of fills.
|
||||
* @param aDimmed - reduce brightness of item.
|
||||
*/
|
||||
virtual void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
|
||||
const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) = 0;
|
||||
|
||||
/**
|
||||
* Plot the item to \a aPlotter.
|
||||
*
|
||||
* @param aBackground a poor-man's Z-order. The routine will get called twice, first with
|
||||
* aBackground true and then with aBackground false.
|
||||
* @param aUnit - which unit to print.
|
||||
* @param aBodyStyle - which body style to print.
|
||||
* @param aOffset relative offset.
|
||||
* @param aDimmed reduce brightness of item.
|
||||
*/
|
||||
virtual void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
|
||||
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) = 0;
|
||||
|
||||
void SetUnit( int aUnit ) { m_unit = aUnit; }
|
||||
int GetUnit() const { return m_unit; }
|
||||
|
||||
void SetBodyStyle( int aBodyStyle ) { m_bodyStyle = aBodyStyle; }
|
||||
int GetBodyStyle() const { return m_bodyStyle; }
|
||||
|
||||
void SetPrivate( bool aPrivate ) { m_private = aPrivate; }
|
||||
bool IsPrivate() const { return m_private; }
|
||||
|
||||
struct cmp_items
|
||||
{
|
||||
bool operator()( const LIB_ITEM* aFirst, const LIB_ITEM* aSecond ) const;
|
||||
};
|
||||
|
||||
#if defined(DEBUG)
|
||||
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
SCH_RENDER_SETTINGS* getRenderSettings( PLOTTER* aPlotter ) const
|
||||
{
|
||||
return static_cast<SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the draw object specific comparison called by the == and < operators.
|
||||
*
|
||||
* The base object sort order which always proceeds the derived object sort order
|
||||
* is as follows:
|
||||
* - Symbol alternate part (DeMorgan) number.
|
||||
* - Symbol part number.
|
||||
* - KICAD_T enum value.
|
||||
* - Result of derived classes comparison.
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* @param aOther A reference to the other #LIB_ITEM to compare the arc against.
|
||||
* @param aCompareFlags The flags used to perform the comparison.
|
||||
*
|
||||
* @return An integer value less than 0 if the object is less than \a aOther object,
|
||||
* zero if the object is equal to \a aOther object, or greater than 0 if the
|
||||
* object is greater than \a aOther object.
|
||||
*/
|
||||
virtual int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const;
|
||||
|
||||
private:
|
||||
friend class LIB_SYMBOL;
|
||||
|
||||
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.
|
||||
*/
|
||||
int m_bodyStyle;
|
||||
|
||||
/**
|
||||
* Private items are shown only in the Symbol Editor.
|
||||
*/
|
||||
bool m_private;
|
||||
};
|
||||
|
||||
|
||||
#endif // _LIB_ITEM_H_
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -94,8 +94,8 @@ static int externalPinDecoSize( const RENDER_SETTINGS* aSettings, const LIB_PIN
|
||||
}
|
||||
|
||||
|
||||
LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent ) :
|
||||
LIB_ITEM( LIB_PIN_T, aParent ),
|
||||
LIB_PIN::LIB_PIN( SCH_ITEM* aParent ) :
|
||||
SCH_ITEM( aParent, LIB_PIN_T, 0, 0 ),
|
||||
m_orientation( PIN_ORIENTATION::PIN_RIGHT ),
|
||||
m_shape( GRAPHIC_PINSHAPE::LINE ),
|
||||
m_type( ELECTRICAL_PINTYPE::PT_UNSPECIFIED ),
|
||||
@ -121,11 +121,11 @@ LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent ) :
|
||||
}
|
||||
|
||||
|
||||
LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent, const wxString& aName, const wxString& aNumber,
|
||||
LIB_PIN::LIB_PIN( SCH_ITEM* aParent, const wxString& aName, const wxString& aNumber,
|
||||
PIN_ORIENTATION aOrientation, ELECTRICAL_PINTYPE aPinType, int aLength,
|
||||
int aNameTextSize, int aNumTextSize, int aBodyStyle, const VECTOR2I& aPos,
|
||||
int aUnit ) :
|
||||
LIB_ITEM( LIB_PIN_T, aParent ),
|
||||
SCH_ITEM( aParent, LIB_PIN_T, aUnit, aBodyStyle ),
|
||||
m_position( aPos ),
|
||||
m_length( aLength ),
|
||||
m_orientation( aOrientation ),
|
||||
@ -137,8 +137,6 @@ LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent, const wxString& aName, const wxString& aN
|
||||
{
|
||||
SetName( aName );
|
||||
SetNumber( aNumber );
|
||||
SetUnit( aUnit );
|
||||
SetBodyStyle( aBodyStyle );
|
||||
}
|
||||
|
||||
|
||||
@ -988,15 +986,18 @@ PIN_ORIENTATION LIB_PIN::PinDrawOrient( const TRANSFORM& aTransform ) const
|
||||
|
||||
EDA_ITEM* LIB_PIN::Clone() const
|
||||
{
|
||||
return new LIB_PIN( *this );
|
||||
//return new LIB_PIN( *this );
|
||||
SCH_ITEM* newPin = new LIB_PIN( *this );
|
||||
wxASSERT( newPin->GetUnit() == m_unit && newPin->GetBodyStyle() == m_bodyStyle );
|
||||
return newPin;
|
||||
}
|
||||
|
||||
|
||||
int LIB_PIN::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
|
||||
int LIB_PIN::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
|
||||
{
|
||||
wxASSERT( aOther.Type() == LIB_PIN_T );
|
||||
|
||||
int retv = LIB_ITEM::compare( aOther, aCompareFlags );
|
||||
int retv = SCH_ITEM::compare( aOther, aCompareFlags );
|
||||
|
||||
if( retv )
|
||||
return retv;
|
||||
@ -1005,7 +1006,7 @@ int LIB_PIN::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
|
||||
|
||||
// When comparing units, we do not compare the part numbers. If everything else is
|
||||
// identical, then we can just renumber the parts for the inherited symbol.
|
||||
if( !( aCompareFlags & COMPARE_FLAGS::UNIT ) && m_number != tmp->m_number )
|
||||
if( !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::UNIT ) && m_number != tmp->m_number )
|
||||
return m_number.Cmp( tmp->m_number );
|
||||
|
||||
int result = m_name.Cmp( tmp->m_name );
|
||||
@ -1092,23 +1093,17 @@ void LIB_PIN::ChangeLength( int aLength )
|
||||
}
|
||||
|
||||
VECTOR2I offset = VECTOR2I( offsetX, offsetY );
|
||||
Offset( offset );
|
||||
Move( offset );
|
||||
|
||||
m_length = aLength;
|
||||
}
|
||||
|
||||
void LIB_PIN::Offset( const VECTOR2I& aOffset )
|
||||
void LIB_PIN::Move( const VECTOR2I& aOffset )
|
||||
{
|
||||
m_position += aOffset;
|
||||
}
|
||||
|
||||
|
||||
void LIB_PIN::MoveTo( const VECTOR2I& aNewPosition )
|
||||
{
|
||||
m_position = aNewPosition;
|
||||
}
|
||||
|
||||
|
||||
void LIB_PIN::MirrorHorizontally( int aCenter )
|
||||
{
|
||||
m_position.x -= aCenter;
|
||||
@ -1184,7 +1179,7 @@ void LIB_PIN::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aP
|
||||
|
||||
void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
||||
{
|
||||
LIB_ITEM::GetMsgPanelInfo( aFrame, aList );
|
||||
getSymbolEditorMsgPanelInfo( aFrame, aList );
|
||||
|
||||
aList.emplace_back( _( "Name" ), UnescapeString( GetShownName() ) );
|
||||
aList.emplace_back( _( "Number" ), GetShownNumber() );
|
||||
@ -1456,7 +1451,7 @@ wxString LIB_PIN::getItemDescription( ALT* aAlt ) const
|
||||
}
|
||||
|
||||
|
||||
bool LIB_PIN::operator==( const LIB_ITEM& aOther ) const
|
||||
bool LIB_PIN::operator==( const SCH_ITEM& aOther ) const
|
||||
{
|
||||
if( aOther.Type() != LIB_PIN_T )
|
||||
return false;
|
||||
@ -1524,7 +1519,7 @@ bool LIB_PIN::operator==( const LIB_ITEM& aOther ) const
|
||||
}
|
||||
|
||||
|
||||
double LIB_PIN::Similarity( const LIB_ITEM& aOther ) const
|
||||
double LIB_PIN::Similarity( const SCH_ITEM& aOther ) const
|
||||
{
|
||||
if( aOther.m_Uuid == m_Uuid )
|
||||
return 1.0;
|
||||
@ -1606,7 +1601,7 @@ void LIB_PIN::Show( int nestLevel, std::ostream& os ) const
|
||||
void LIB_PIN::CalcEdit( const VECTOR2I& aPosition )
|
||||
{
|
||||
if( IsMoving() )
|
||||
MoveTo( aPosition );
|
||||
SetPosition( aPosition );
|
||||
}
|
||||
|
||||
|
||||
@ -1659,8 +1654,8 @@ static struct LIB_PIN_DESC
|
||||
|
||||
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
||||
REGISTER_TYPE( LIB_PIN );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<LIB_PIN, LIB_ITEM> );
|
||||
propMgr.InheritsAfter( TYPE_HASH( LIB_PIN ), TYPE_HASH( LIB_ITEM ) );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<LIB_PIN, SCH_ITEM> );
|
||||
propMgr.InheritsAfter( TYPE_HASH( LIB_PIN ), TYPE_HASH( SCH_ITEM ) );
|
||||
|
||||
propMgr.AddProperty( new PROPERTY<LIB_PIN, wxString>( _HKI( "Pin Name" ),
|
||||
&LIB_PIN::SetName, &LIB_PIN::GetName ) );
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr
|
||||
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -38,7 +38,7 @@
|
||||
#define PIN_INVISIBLE 1 // Set makes pin invisible
|
||||
|
||||
|
||||
class LIB_PIN : public LIB_ITEM
|
||||
class LIB_PIN : public SCH_ITEM
|
||||
{
|
||||
public:
|
||||
struct ALT
|
||||
@ -48,6 +48,14 @@ public:
|
||||
ELECTRICAL_PINTYPE m_Type; // Electrical type of the pin.
|
||||
};
|
||||
|
||||
LIB_PIN( SCH_ITEM* aParent );
|
||||
|
||||
LIB_PIN( SCH_ITEM* aParent, const wxString& aName, const wxString& aNumber,
|
||||
PIN_ORIENTATION aOrientation, ELECTRICAL_PINTYPE aPinType, int aLength,
|
||||
int aNameTextSize, int aNumTextSize, int aConvert, const VECTOR2I& aPos, int aUnit );
|
||||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
|
||||
~LIB_PIN() { }
|
||||
|
||||
wxString GetClass() const override
|
||||
@ -154,14 +162,6 @@ public:
|
||||
*/
|
||||
PIN_ORIENTATION PinDrawOrient( const TRANSFORM& aTransform ) const;
|
||||
|
||||
LIB_PIN( LIB_SYMBOL* aParent );
|
||||
|
||||
LIB_PIN( LIB_SYMBOL* aParent, const wxString& aName, const wxString& aNumber,
|
||||
PIN_ORIENTATION aOrientation, ELECTRICAL_PINTYPE aPinType, int aLength,
|
||||
int aNameTextSize, int aNumTextSize, int aConvert, const VECTOR2I& aPos, int aUnit );
|
||||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
|
||||
// No, LIB_PINs don't really have operating poinst. But we draw SCH_PINs through their LIB_PIN
|
||||
// counterparts, so here we are....
|
||||
const wxString& GetOperatingPoint() const { return m_operatingPoint; }
|
||||
@ -204,9 +204,7 @@ public:
|
||||
|
||||
int GetPenWidth() const override;
|
||||
|
||||
void Offset( const VECTOR2I& aOffset ) override;
|
||||
|
||||
void MoveTo( const VECTOR2I& aNewPosition ) override;
|
||||
void Move( const VECTOR2I& aOffset ) override;
|
||||
|
||||
VECTOR2I GetPosition() const override { return m_position; }
|
||||
void SetPosition( const VECTOR2I& aPos ) override { m_position = aPos; }
|
||||
@ -258,10 +256,10 @@ public:
|
||||
*/
|
||||
static const wxString GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType );
|
||||
|
||||
double Similarity( const LIB_ITEM& aItem ) const override;
|
||||
double Similarity( const SCH_ITEM& aItem ) const override;
|
||||
|
||||
bool operator==( const LIB_ITEM& aItem ) const override;
|
||||
bool operator!=( const LIB_ITEM& aItem ) const { return !operator==( aItem ); }
|
||||
bool operator==( const SCH_ITEM& aItem ) const override;
|
||||
bool operator!=( const SCH_ITEM& aItem ) const { return !operator==( aItem ); }
|
||||
bool operator<( const LIB_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) < 0; }
|
||||
bool operator>( const LIB_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) > 0; }
|
||||
|
||||
@ -306,7 +304,7 @@ protected:
|
||||
|
||||
private:
|
||||
/**
|
||||
* @copydoc LIB_ITEM::compare()
|
||||
* @copydoc SCH_ITEM::compare()
|
||||
*
|
||||
* The pin specific sort order is as follows:
|
||||
* - Pin number.
|
||||
@ -314,7 +312,7 @@ private:
|
||||
* - Pin horizontal (X) position.
|
||||
* - Pin vertical (Y) position.
|
||||
*/
|
||||
int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override;
|
||||
int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
|
||||
|
||||
protected:
|
||||
VECTOR2I m_position; // Position of the pin.
|
||||
|
@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -31,12 +31,11 @@
|
||||
#include <eda_draw_frame.h>
|
||||
#include <general.h>
|
||||
#include <lib_shape.h>
|
||||
#include "plotters/plotter.h"
|
||||
|
||||
|
||||
LIB_SHAPE::LIB_SHAPE( LIB_SYMBOL* aParent, SHAPE_T aShape, int aLineWidth, FILL_T aFillType,
|
||||
LIB_SHAPE::LIB_SHAPE( SCH_ITEM* aParent, SHAPE_T aShape, int aLineWidth, FILL_T aFillType,
|
||||
KICAD_T aType ) :
|
||||
LIB_ITEM( aType, aParent ),
|
||||
SCH_ITEM( aParent, aType ),
|
||||
EDA_SHAPE( aShape, aLineWidth, aFillType )
|
||||
{
|
||||
m_editState = 0;
|
||||
@ -67,9 +66,9 @@ EDA_ITEM* LIB_SHAPE::Clone() const
|
||||
}
|
||||
|
||||
|
||||
int LIB_SHAPE::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
|
||||
int LIB_SHAPE::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
|
||||
{
|
||||
int retv = LIB_ITEM::compare( aOther, aCompareFlags );
|
||||
int retv = SCH_ITEM::compare( aOther, aCompareFlags );
|
||||
|
||||
if( retv )
|
||||
return retv;
|
||||
@ -78,18 +77,12 @@ int LIB_SHAPE::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
|
||||
}
|
||||
|
||||
|
||||
void LIB_SHAPE::Offset( const VECTOR2I& aOffset )
|
||||
void LIB_SHAPE::Move( const VECTOR2I& aOffset )
|
||||
{
|
||||
move( aOffset );
|
||||
}
|
||||
|
||||
|
||||
void LIB_SHAPE::MoveTo( const VECTOR2I& aPosition )
|
||||
{
|
||||
setPosition( aPosition );
|
||||
}
|
||||
|
||||
|
||||
void LIB_SHAPE::Normalize()
|
||||
{
|
||||
if( GetShape() == SHAPE_T::RECTANGLE )
|
||||
@ -448,7 +441,7 @@ const BOX2I LIB_SHAPE::GetBoundingBox() const
|
||||
|
||||
void LIB_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
||||
{
|
||||
LIB_ITEM::GetMsgPanelInfo( aFrame, aList );
|
||||
getSymbolEditorMsgPanelInfo( aFrame, aList );
|
||||
|
||||
ShapeGetMsgPanelInfo( aFrame, aList );
|
||||
}
|
||||
@ -520,18 +513,18 @@ void LIB_SHAPE::AddPoint( const VECTOR2I& aPosition )
|
||||
}
|
||||
|
||||
|
||||
bool LIB_SHAPE::operator==( const LIB_ITEM& aOther ) const
|
||||
bool LIB_SHAPE::operator==( const SCH_ITEM& aOther ) const
|
||||
{
|
||||
if( aOther.Type() != Type() )
|
||||
return false;
|
||||
|
||||
const LIB_SHAPE& other = static_cast<const LIB_SHAPE&>( aOther );
|
||||
|
||||
return LIB_ITEM::operator==( aOther ) && EDA_SHAPE::operator==( other );
|
||||
return SCH_ITEM::operator==( aOther ) && EDA_SHAPE::operator==( other );
|
||||
}
|
||||
|
||||
|
||||
double LIB_SHAPE::Similarity( const LIB_ITEM& aOther ) const
|
||||
double LIB_SHAPE::Similarity( const SCH_ITEM& aOther ) const
|
||||
{
|
||||
if( m_Uuid == aOther.m_Uuid )
|
||||
return 1.0;
|
||||
@ -564,9 +557,9 @@ static struct LIB_SHAPE_DESC
|
||||
{
|
||||
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
||||
REGISTER_TYPE( LIB_SHAPE );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<LIB_SHAPE, LIB_ITEM> );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<LIB_SHAPE, SCH_ITEM> );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<LIB_SHAPE, EDA_SHAPE> );
|
||||
propMgr.InheritsAfter( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( LIB_ITEM ) );
|
||||
propMgr.InheritsAfter( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( SCH_ITEM ) );
|
||||
propMgr.InheritsAfter( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( EDA_SHAPE ) );
|
||||
|
||||
// Only polygons have meaningful Position properties.
|
||||
@ -580,9 +573,9 @@ static struct LIB_SHAPE_DESC
|
||||
return false;
|
||||
};
|
||||
|
||||
propMgr.OverrideAvailability( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( LIB_ITEM ),
|
||||
propMgr.OverrideAvailability( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( SCH_ITEM ),
|
||||
_HKI( "Position X" ), isPolygon );
|
||||
propMgr.OverrideAvailability( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( LIB_ITEM ),
|
||||
propMgr.OverrideAvailability( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( SCH_ITEM ),
|
||||
_HKI( "Position Y" ), isPolygon );
|
||||
|
||||
propMgr.Mask( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Filled" ) );
|
||||
|
@ -2,7 +2,7 @@
|
||||
* 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
|
||||
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -25,14 +25,14 @@
|
||||
#ifndef LIB_SHAPE_H
|
||||
#define LIB_SHAPE_H
|
||||
|
||||
#include <lib_item.h>
|
||||
#include <sch_item.h>
|
||||
#include <eda_shape.h>
|
||||
|
||||
|
||||
class LIB_SHAPE : public LIB_ITEM, public EDA_SHAPE
|
||||
class LIB_SHAPE : public SCH_ITEM, public EDA_SHAPE
|
||||
{
|
||||
public:
|
||||
LIB_SHAPE( LIB_SYMBOL* aParent, SHAPE_T aShape = SHAPE_T::UNDEFINED, int aLineWidth = 0,
|
||||
LIB_SHAPE( SCH_ITEM* aParent, SHAPE_T aShape = SHAPE_T::UNDEFINED, int aLineWidth = 0,
|
||||
FILL_T aFillType = FILL_T::NO_FILL, KICAD_T aType = LIB_SHAPE_T );
|
||||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
@ -54,8 +54,8 @@ public:
|
||||
return ShowShape();
|
||||
}
|
||||
|
||||
STROKE_PARAMS GetStroke() const { return m_stroke; }
|
||||
void SetStroke( const STROKE_PARAMS& aStroke ) { m_stroke = aStroke; }
|
||||
STROKE_PARAMS GetStroke() const override { return m_stroke; }
|
||||
void SetStroke( const STROKE_PARAMS& aStroke ) override { m_stroke = aStroke; }
|
||||
|
||||
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
|
||||
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
||||
@ -83,9 +83,7 @@ public:
|
||||
|
||||
void AddPoint( const VECTOR2I& aPosition );
|
||||
|
||||
void Offset( const VECTOR2I& aOffset ) override;
|
||||
|
||||
void MoveTo( const VECTOR2I& aPosition ) override;
|
||||
void Move( const VECTOR2I& aOffset ) override;
|
||||
|
||||
VECTOR2I GetPosition() const override { return getPosition(); }
|
||||
void SetPosition( const VECTOR2I& aPosition ) override { setPosition( aPosition ); }
|
||||
@ -123,20 +121,20 @@ public:
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
double Similarity( const LIB_ITEM& aOther ) const override;
|
||||
double Similarity( const SCH_ITEM& aOther ) const override;
|
||||
|
||||
bool operator==( const LIB_ITEM& aOther ) const override;
|
||||
bool operator==( const SCH_ITEM& aOther ) const override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @copydoc LIB_ITEM::compare()
|
||||
* @copydoc SCH_ITEM::compare()
|
||||
*
|
||||
* The circle specific sort order is as follows:
|
||||
* - Circle horizontal (X) position.
|
||||
* - Circle vertical (Y) position.
|
||||
* - Circle radius.
|
||||
*/
|
||||
int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override;
|
||||
int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -70,7 +70,7 @@ std::vector<SEARCH_TERM> LIB_SYMBOL::GetSearchTerms()
|
||||
|
||||
void LIB_SYMBOL::GetChooserFields( std::map<wxString, wxString>& aColumnMap )
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
||||
for( SCH_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
||||
{
|
||||
LIB_FIELD* field = static_cast<LIB_FIELD*>( &item );
|
||||
|
||||
@ -124,8 +124,6 @@ LIB_SYMBOL::LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary ) :
|
||||
SYMBOL( aSymbol ),
|
||||
m_me( this, null_deleter() )
|
||||
{
|
||||
LIB_ITEM* newItem;
|
||||
|
||||
m_library = aLibrary;
|
||||
m_name = aSymbol.m_name;
|
||||
m_fpFilters = wxArrayString( aSymbol.m_fpFilters );
|
||||
@ -140,21 +138,21 @@ LIB_SYMBOL::LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary ) :
|
||||
|
||||
ClearSelected();
|
||||
|
||||
for( const LIB_ITEM& oldItem : aSymbol.m_drawings )
|
||||
for( const SCH_ITEM& oldItem : aSymbol.m_drawings )
|
||||
{
|
||||
if( ( oldItem.GetFlags() & ( IS_NEW | STRUCT_DELETED ) ) != 0 )
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
newItem = (LIB_ITEM*) oldItem.Clone();
|
||||
SCH_ITEM* newItem = (SCH_ITEM*) oldItem.Clone();
|
||||
newItem->ClearSelected();
|
||||
newItem->SetParent( this );
|
||||
m_drawings.push_back( newItem );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
wxFAIL_MSG( "Failed to clone LIB_ITEM." );
|
||||
wxFAIL_MSG( "Failed to clone SCH_ITEM." );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -171,7 +169,7 @@ const LIB_SYMBOL& LIB_SYMBOL::operator=( const LIB_SYMBOL& aSymbol )
|
||||
if( &aSymbol == this )
|
||||
return aSymbol;
|
||||
|
||||
LIB_ITEM* newItem;
|
||||
SCH_ITEM* newItem;
|
||||
|
||||
m_library = aSymbol.m_library;
|
||||
m_name = aSymbol.m_name;
|
||||
@ -194,12 +192,12 @@ const LIB_SYMBOL& LIB_SYMBOL::operator=( const LIB_SYMBOL& aSymbol )
|
||||
|
||||
m_drawings.clear();
|
||||
|
||||
for( const LIB_ITEM& oldItem : aSymbol.m_drawings )
|
||||
for( const SCH_ITEM& oldItem : aSymbol.m_drawings )
|
||||
{
|
||||
if( ( oldItem.GetFlags() & ( IS_NEW | STRUCT_DELETED ) ) != 0 )
|
||||
continue;
|
||||
|
||||
newItem = (LIB_ITEM*) oldItem.Clone();
|
||||
newItem = (SCH_ITEM*) oldItem.Clone();
|
||||
newItem->SetParent( this );
|
||||
m_drawings.push_back( newItem );
|
||||
}
|
||||
@ -241,7 +239,7 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
|
||||
if( m_me == aRhs.m_me )
|
||||
return 0;
|
||||
|
||||
if( !aReporter && ( aCompareFlags & LIB_ITEM::COMPARE_FLAGS::ERC ) == 0 )
|
||||
if( !aReporter && ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) == 0 )
|
||||
{
|
||||
if( int tmp = m_name.Cmp( aRhs.m_name ) )
|
||||
return tmp;
|
||||
@ -279,9 +277,9 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
|
||||
// Make sure shapes and pins are sorted. No need with fields as those are
|
||||
// matched by id/name.
|
||||
|
||||
std::set<const LIB_ITEM*, LIB_ITEM::cmp_items> aShapes;
|
||||
std::set<const LIB_ITEM*> aFields;
|
||||
std::set<const LIB_ITEM*, LIB_ITEM::cmp_items> aPins;
|
||||
std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> aShapes;
|
||||
std::set<const SCH_ITEM*> aFields;
|
||||
std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> aPins;
|
||||
|
||||
for( auto it = m_drawings.begin(); it != m_drawings.end(); ++it )
|
||||
{
|
||||
@ -293,9 +291,9 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
|
||||
aPins.insert( &(*it) );
|
||||
}
|
||||
|
||||
std::set<const LIB_ITEM*, LIB_ITEM::cmp_items> bShapes;
|
||||
std::set<const LIB_ITEM*> bFields;
|
||||
std::set<const LIB_ITEM*, LIB_ITEM::cmp_items> bPins;
|
||||
std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> bShapes;
|
||||
std::set<const SCH_ITEM*> bFields;
|
||||
std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> bPins;
|
||||
|
||||
for( auto it = aRhs.m_drawings.begin(); it != aRhs.m_drawings.end(); ++it )
|
||||
{
|
||||
@ -340,7 +338,7 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
|
||||
}
|
||||
else
|
||||
{
|
||||
for( const LIB_ITEM* aPinItem : aPins )
|
||||
for( const SCH_ITEM* aPinItem : aPins )
|
||||
{
|
||||
const LIB_PIN* aPin = static_cast<const LIB_PIN*>( aPinItem );
|
||||
const LIB_PIN* bPin = aRhs.GetPin( aPin->GetNumber(), aPin->GetUnit(),
|
||||
@ -365,7 +363,7 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
|
||||
}
|
||||
}
|
||||
|
||||
for( const LIB_ITEM* aFieldItem : aFields )
|
||||
for( const SCH_ITEM* aFieldItem : aFields )
|
||||
{
|
||||
const LIB_FIELD* aField = static_cast<const LIB_FIELD*>( aFieldItem );
|
||||
const LIB_FIELD* bField = nullptr;
|
||||
@ -441,7 +439,7 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
|
||||
return retv;
|
||||
}
|
||||
|
||||
if( ( aCompareFlags & LIB_ITEM::COMPARE_FLAGS::ERC ) == 0 )
|
||||
if( ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) == 0 )
|
||||
{
|
||||
if( m_showPinNames != aRhs.m_showPinNames )
|
||||
{
|
||||
@ -606,7 +604,7 @@ std::unique_ptr< LIB_SYMBOL > LIB_SYMBOL::Flatten() const
|
||||
}
|
||||
|
||||
// Grab all the rest of derived symbol fields.
|
||||
for( const LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
||||
for( const SCH_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
||||
{
|
||||
const LIB_FIELD* aliasField = dynamic_cast<const LIB_FIELD*>( &item );
|
||||
|
||||
@ -737,7 +735,7 @@ wxString LIB_SYMBOL::LetterSubReference( int aUnit, int aFirstId )
|
||||
void LIB_SYMBOL::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
|
||||
const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed )
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
for( SCH_ITEM& item : m_drawings )
|
||||
{
|
||||
// Do not print private items
|
||||
if( item.IsPrivate() )
|
||||
@ -795,7 +793,7 @@ void LIB_SYMBOL::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUni
|
||||
*/
|
||||
if( !GetGRForceBlackPenState() )
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
for( SCH_ITEM& item : m_drawings )
|
||||
{
|
||||
// Do not print private items
|
||||
if( item.IsPrivate() )
|
||||
@ -840,7 +838,7 @@ void LIB_SYMBOL::Plot( PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS&
|
||||
|
||||
aPlotter->SetColor( color );
|
||||
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
for( SCH_ITEM& item : m_drawings )
|
||||
{
|
||||
// Do not plot private items
|
||||
if( item.IsPrivate() )
|
||||
@ -883,7 +881,7 @@ void LIB_SYMBOL::PlotFields( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT
|
||||
|
||||
aPlotter->SetColor( color );
|
||||
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
for( SCH_ITEM& item : m_drawings )
|
||||
{
|
||||
if( item.Type() != LIB_FIELD_T )
|
||||
continue;
|
||||
@ -912,9 +910,9 @@ void LIB_SYMBOL::PlotFields( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT
|
||||
void LIB_SYMBOL::FixupDrawItems()
|
||||
{
|
||||
std::vector<LIB_SHAPE*> potential_top_items;
|
||||
std::vector<LIB_ITEM*> bottom_items;
|
||||
std::vector<SCH_ITEM*> bottom_items;
|
||||
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
for( SCH_ITEM& item : m_drawings )
|
||||
{
|
||||
if( item.Type() == LIB_SHAPE_T )
|
||||
{
|
||||
@ -932,14 +930,14 @@ void LIB_SYMBOL::FixupDrawItems()
|
||||
}
|
||||
|
||||
std::sort( potential_top_items.begin(), potential_top_items.end(),
|
||||
[]( LIB_ITEM* a, LIB_ITEM* b )
|
||||
[]( SCH_ITEM* a, SCH_ITEM* b )
|
||||
{
|
||||
return a->GetBoundingBox().GetArea() > b->GetBoundingBox().GetArea();
|
||||
} );
|
||||
|
||||
for( LIB_SHAPE* item : potential_top_items )
|
||||
{
|
||||
for( LIB_ITEM* bottom_item : bottom_items )
|
||||
for( SCH_ITEM* bottom_item : bottom_items )
|
||||
{
|
||||
if( item->GetBoundingBox().Contains( bottom_item->GetBoundingBox() ) )
|
||||
{
|
||||
@ -951,7 +949,7 @@ void LIB_SYMBOL::FixupDrawItems()
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::RemoveDrawItem( LIB_ITEM* aItem )
|
||||
void LIB_SYMBOL::RemoveDrawItem( SCH_ITEM* aItem )
|
||||
{
|
||||
wxASSERT( aItem != nullptr );
|
||||
|
||||
@ -976,7 +974,7 @@ void LIB_SYMBOL::RemoveDrawItem( LIB_ITEM* aItem )
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::AddDrawItem( LIB_ITEM* aItem, bool aSort )
|
||||
void LIB_SYMBOL::AddDrawItem( SCH_ITEM* aItem, bool aSort )
|
||||
{
|
||||
wxCHECK( aItem, /* void */ );
|
||||
|
||||
@ -987,7 +985,7 @@ void LIB_SYMBOL::AddDrawItem( LIB_ITEM* aItem, bool aSort )
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::GetPins( LIB_PINS& aList, int aUnit, int aBodyStyle ) const
|
||||
void LIB_SYMBOL::GetPins( std::vector<LIB_PIN*>& aList, int aUnit, int aBodyStyle ) const
|
||||
{
|
||||
/* Notes:
|
||||
* when aUnit == 0: no unit filtering
|
||||
@ -999,7 +997,7 @@ void LIB_SYMBOL::GetPins( LIB_PINS& aList, int aUnit, int aBodyStyle ) const
|
||||
LIB_SYMBOL_SPTR parent = m_parent.lock();
|
||||
const LIB_ITEMS_CONTAINER& drawItems = parent ? parent->m_drawings : m_drawings;
|
||||
|
||||
for( const LIB_ITEM& item : drawItems[LIB_PIN_T] )
|
||||
for( const SCH_ITEM& item : drawItems[LIB_PIN_T] )
|
||||
{
|
||||
// Unit filtering:
|
||||
if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
|
||||
@ -1034,7 +1032,7 @@ int LIB_SYMBOL::GetPinCount()
|
||||
|
||||
LIB_PIN* LIB_SYMBOL::GetPin( const wxString& aNumber, int aUnit, int aBodyStyle ) const
|
||||
{
|
||||
LIB_PINS pinList;
|
||||
std::vector<LIB_PIN*> pinList;
|
||||
|
||||
GetPins( pinList, aUnit, aBodyStyle );
|
||||
|
||||
@ -1053,13 +1051,13 @@ LIB_PIN* LIB_SYMBOL::GetPin( const wxString& aNumber, int aUnit, int aBodyStyle
|
||||
bool LIB_SYMBOL::PinsConflictWith( const LIB_SYMBOL& aOtherPart, bool aTestNums, bool aTestNames,
|
||||
bool aTestType, bool aTestOrientation, bool aTestLength ) const
|
||||
{
|
||||
LIB_PINS thisPinList;
|
||||
std::vector<LIB_PIN*> thisPinList;
|
||||
GetPins( thisPinList, /* aUnit */ 0, /* aBodyStyle */ 0 );
|
||||
|
||||
for( const LIB_PIN* eachThisPin : thisPinList )
|
||||
{
|
||||
wxASSERT( eachThisPin );
|
||||
LIB_PINS otherPinList;
|
||||
std::vector<LIB_PIN*> otherPinList;
|
||||
aOtherPart.GetPins( otherPinList, /* aUnit */ 0, /* aBodyStyle */ 0 );
|
||||
bool foundMatch = false;
|
||||
|
||||
@ -1122,7 +1120,7 @@ const BOX2I LIB_SYMBOL::GetUnitBoundingBox( int aUnit, int aBodyStyle,
|
||||
{
|
||||
BOX2I bBox; // Start with a fresh BOX2I so the Merge algorithm works
|
||||
|
||||
for( const LIB_ITEM& item : m_drawings )
|
||||
for( const SCH_ITEM& item : m_drawings )
|
||||
{
|
||||
if( item.m_unit > 0 && m_unitCount > 1 && aUnit > 0 && aUnit != item.m_unit )
|
||||
continue;
|
||||
@ -1148,7 +1146,7 @@ const BOX2I LIB_SYMBOL::GetBodyBoundingBox( int aUnit, int aBodyStyle, bool aInc
|
||||
{
|
||||
BOX2I bbox;
|
||||
|
||||
for( const LIB_ITEM& item : m_drawings )
|
||||
for( const SCH_ITEM& item : m_drawings )
|
||||
{
|
||||
if( item.m_unit > 0 && aUnit > 0 && aUnit != item.m_unit )
|
||||
continue;
|
||||
@ -1223,7 +1221,7 @@ void LIB_SYMBOL::GetFields( std::vector<LIB_FIELD*>& aList )
|
||||
aList.push_back( GetFieldById( id ) );
|
||||
|
||||
// Now grab all the rest of fields.
|
||||
for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
||||
for( SCH_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
||||
{
|
||||
LIB_FIELD* field = static_cast<LIB_FIELD*>( &item );
|
||||
|
||||
@ -1240,7 +1238,7 @@ void LIB_SYMBOL::GetFields( std::vector<LIB_FIELD>& aList )
|
||||
aList.push_back( *GetFieldById( id ) );
|
||||
|
||||
// Now grab all the rest of fields.
|
||||
for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
||||
for( SCH_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
||||
{
|
||||
LIB_FIELD* field = static_cast<LIB_FIELD*>( &item );
|
||||
|
||||
@ -1252,7 +1250,7 @@ void LIB_SYMBOL::GetFields( std::vector<LIB_FIELD>& aList )
|
||||
|
||||
LIB_FIELD* LIB_SYMBOL::GetFieldById( int aId ) const
|
||||
{
|
||||
for( const LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
||||
for( const SCH_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
||||
{
|
||||
LIB_FIELD* field = ( LIB_FIELD* ) &item;
|
||||
|
||||
@ -1266,7 +1264,7 @@ LIB_FIELD* LIB_SYMBOL::GetFieldById( int aId ) const
|
||||
|
||||
LIB_FIELD* LIB_SYMBOL::FindField( const wxString& aFieldName, bool aCaseInsensitive )
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
||||
for( SCH_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
||||
{
|
||||
if( aCaseInsensitive )
|
||||
{
|
||||
@ -1287,7 +1285,7 @@ LIB_FIELD* LIB_SYMBOL::FindField( const wxString& aFieldName, bool aCaseInsensit
|
||||
const LIB_FIELD* LIB_SYMBOL::FindField( const wxString& aFieldName,
|
||||
bool aCaseInsensitive ) const
|
||||
{
|
||||
for( const LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
||||
for( const SCH_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
||||
{
|
||||
const LIB_FIELD& field = static_cast<const LIB_FIELD&>( item );
|
||||
|
||||
@ -1373,9 +1371,9 @@ wxString LIB_SYMBOL::GetPrefix()
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::RunOnLibChildren( const std::function<void( LIB_ITEM* )>& aFunction )
|
||||
void LIB_SYMBOL::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction )
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
for( SCH_ITEM& item : m_drawings )
|
||||
aFunction( &item );
|
||||
}
|
||||
|
||||
@ -1385,7 +1383,7 @@ int LIB_SYMBOL::UpdateFieldOrdinals()
|
||||
int retv = 0;
|
||||
int lastOrdinal = MANDATORY_FIELDS;
|
||||
|
||||
for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
||||
for( SCH_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
||||
{
|
||||
LIB_FIELD* field = static_cast<LIB_FIELD*>( &item );
|
||||
|
||||
@ -1419,24 +1417,24 @@ int LIB_SYMBOL::GetNextAvailableFieldId() const
|
||||
|
||||
void LIB_SYMBOL::Move( const VECTOR2I& aOffset )
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
item.Offset( aOffset );
|
||||
for( SCH_ITEM& item : m_drawings )
|
||||
item.Move( aOffset );
|
||||
}
|
||||
|
||||
|
||||
bool LIB_SYMBOL::HasAlternateBodyStyle() const
|
||||
{
|
||||
for( const LIB_ITEM& item : m_drawings )
|
||||
for( const SCH_ITEM& item : m_drawings )
|
||||
{
|
||||
if( item.m_bodyStyle > LIB_ITEM::BODY_STYLE::BASE )
|
||||
if( item.m_bodyStyle > BODY_STYLE::BASE )
|
||||
return true;
|
||||
}
|
||||
|
||||
if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
|
||||
{
|
||||
for( const LIB_ITEM& item : parent->GetDrawItems() )
|
||||
for( const SCH_ITEM& item : parent->GetDrawItems() )
|
||||
{
|
||||
if( item.m_bodyStyle > LIB_ITEM::BODY_STYLE::BASE )
|
||||
if( item.m_bodyStyle > BODY_STYLE::BASE )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1451,7 +1449,7 @@ int LIB_SYMBOL::GetMaxPinNumber() const
|
||||
LIB_SYMBOL_SPTR parent = m_parent.lock();
|
||||
const LIB_ITEMS_CONTAINER& drawItems = parent ? parent->m_drawings : m_drawings;
|
||||
|
||||
for( const LIB_ITEM& item : drawItems[LIB_PIN_T] )
|
||||
for( const SCH_ITEM& item : drawItems[LIB_PIN_T] )
|
||||
{
|
||||
const LIB_PIN* pin = static_cast<const LIB_PIN*>( &item );
|
||||
long currentPinNumber = 0;
|
||||
@ -1466,22 +1464,26 @@ int LIB_SYMBOL::GetMaxPinNumber() const
|
||||
|
||||
void LIB_SYMBOL::ClearTempFlags()
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
SCH_ITEM::ClearTempFlags();
|
||||
|
||||
for( SCH_ITEM& item : m_drawings )
|
||||
item.ClearTempFlags();
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::ClearEditFlags()
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
SCH_ITEM::ClearEditFlags();
|
||||
|
||||
for( SCH_ITEM& item : m_drawings )
|
||||
item.ClearEditFlags();
|
||||
}
|
||||
|
||||
|
||||
LIB_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType,
|
||||
SCH_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType,
|
||||
const VECTOR2I& aPoint )
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
for( SCH_ITEM& item : m_drawings )
|
||||
{
|
||||
if( ( aUnit && item.m_unit && aUnit != item.m_unit )
|
||||
|| ( aBodyStyle && item.m_bodyStyle && aBodyStyle != item.m_bodyStyle )
|
||||
@ -1498,7 +1500,7 @@ LIB_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType,
|
||||
}
|
||||
|
||||
|
||||
LIB_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType,
|
||||
SCH_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType,
|
||||
const VECTOR2I& aPoint, const TRANSFORM& aTransform )
|
||||
{
|
||||
/* we use LocateDrawItem( int aUnit, int convert, KICAD_T type, const
|
||||
@ -1506,7 +1508,7 @@ LIB_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType,
|
||||
* because this function uses DefaultTransform as orient/mirror matrix
|
||||
* we temporary copy aTransform in DefaultTransform
|
||||
*/
|
||||
LIB_ITEM* item;
|
||||
SCH_ITEM* item;
|
||||
TRANSFORM transform = DefaultTransform;
|
||||
DefaultTransform = aTransform;
|
||||
|
||||
@ -1523,7 +1525,7 @@ INSPECT_RESULT LIB_SYMBOL::Visit( INSPECTOR aInspector, void* aTestData,
|
||||
const std::vector<KICAD_T>& aScanTypes )
|
||||
{
|
||||
// The part itself is never inspected, only its children
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
for( SCH_ITEM& item : m_drawings )
|
||||
{
|
||||
if( item.IsType( aScanTypes ) )
|
||||
{
|
||||
@ -1560,22 +1562,22 @@ void LIB_SYMBOL::SetUnitCount( int aCount, bool aDuplicateDrawItems )
|
||||
// Temporary storage for new items, as adding new items directly to
|
||||
// m_drawings may cause the buffer reallocation which invalidates the
|
||||
// iterators
|
||||
std::vector< LIB_ITEM* > tmp;
|
||||
std::vector<SCH_ITEM*> tmp;
|
||||
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
for( SCH_ITEM& item : m_drawings )
|
||||
{
|
||||
if( item.m_unit != 1 )
|
||||
continue;
|
||||
|
||||
for( int j = prevCount + 1; j <= aCount; j++ )
|
||||
{
|
||||
LIB_ITEM* newItem = (LIB_ITEM*) item.Duplicate();
|
||||
SCH_ITEM* newItem = item.Duplicate();
|
||||
newItem->m_unit = j;
|
||||
tmp.push_back( newItem );
|
||||
}
|
||||
}
|
||||
|
||||
for( LIB_ITEM* item : tmp )
|
||||
for( SCH_ITEM* item : tmp )
|
||||
m_drawings.push_back( item );
|
||||
}
|
||||
|
||||
@ -1603,9 +1605,9 @@ void LIB_SYMBOL::SetHasAlternateBodyStyle( bool aHasAlternate, bool aDuplicatePi
|
||||
{
|
||||
if( aDuplicatePins )
|
||||
{
|
||||
std::vector<LIB_ITEM*> tmp; // Temporarily store the duplicated pins here.
|
||||
std::vector<SCH_ITEM*> tmp; // Temporarily store the duplicated pins here.
|
||||
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
for( SCH_ITEM& item : m_drawings )
|
||||
{
|
||||
// Only pins are duplicated.
|
||||
if( item.Type() != LIB_PIN_T )
|
||||
@ -1613,14 +1615,14 @@ void LIB_SYMBOL::SetHasAlternateBodyStyle( bool aHasAlternate, bool aDuplicatePi
|
||||
|
||||
if( item.m_bodyStyle == 1 )
|
||||
{
|
||||
LIB_ITEM* newItem = static_cast<LIB_ITEM*>( item.Duplicate() );
|
||||
SCH_ITEM* newItem = item.Duplicate();
|
||||
newItem->m_bodyStyle = 2;
|
||||
tmp.push_back( newItem );
|
||||
}
|
||||
}
|
||||
|
||||
// Transfer the new pins to the LIB_SYMBOL.
|
||||
for( LIB_ITEM* item : tmp )
|
||||
for( SCH_ITEM* item : tmp )
|
||||
m_drawings.push_back( item );
|
||||
}
|
||||
}
|
||||
@ -1642,11 +1644,11 @@ void LIB_SYMBOL::SetHasAlternateBodyStyle( bool aHasAlternate, bool aDuplicatePi
|
||||
}
|
||||
|
||||
|
||||
std::vector<LIB_ITEM*> LIB_SYMBOL::GetUnitDrawItems( int aUnit, int aBodyStyle )
|
||||
std::vector<SCH_ITEM*> LIB_SYMBOL::GetUnitDrawItems( int aUnit, int aBodyStyle )
|
||||
{
|
||||
std::vector<LIB_ITEM*> unitItems;
|
||||
std::vector<SCH_ITEM*> unitItems;
|
||||
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
for( SCH_ITEM& item : m_drawings )
|
||||
{
|
||||
if( item.Type() == LIB_FIELD_T )
|
||||
continue;
|
||||
@ -1667,7 +1669,7 @@ std::vector<struct LIB_SYMBOL_UNIT> LIB_SYMBOL::GetUnitDrawItems()
|
||||
{
|
||||
std::vector<struct LIB_SYMBOL_UNIT> units;
|
||||
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
for( SCH_ITEM& item : m_drawings )
|
||||
{
|
||||
if( item.Type() == LIB_FIELD_T )
|
||||
continue;
|
||||
@ -1738,8 +1740,8 @@ bool LIB_SYMBOL::operator==( const LIB_SYMBOL& aOther ) const
|
||||
return false;
|
||||
}
|
||||
|
||||
const LIB_PINS thisPinList = GetAllLibPins();
|
||||
const LIB_PINS otherPinList = aOther.GetAllLibPins();
|
||||
const std::vector<LIB_PIN*> thisPinList = GetAllLibPins();
|
||||
const std::vector<LIB_PIN*> otherPinList = aOther.GetAllLibPins();
|
||||
|
||||
if( thisPinList.size() != otherPinList.size() )
|
||||
return false;
|
||||
@ -1771,12 +1773,12 @@ double LIB_SYMBOL::Similarity( const SCH_ITEM& aOther ) const
|
||||
if( m_Uuid == aOther.m_Uuid )
|
||||
return 1.0;
|
||||
|
||||
for( const LIB_ITEM& item : m_drawings )
|
||||
for( const SCH_ITEM& item : m_drawings )
|
||||
{
|
||||
totalItems += 1;
|
||||
double max_similarity = 0.0;
|
||||
|
||||
for( const LIB_ITEM& otherItem : other.m_drawings )
|
||||
for( const SCH_ITEM& otherItem : other.m_drawings )
|
||||
{
|
||||
double temp_similarity = item.Similarity( otherItem );
|
||||
max_similarity = std::max( max_similarity, temp_similarity );
|
||||
|
@ -40,12 +40,13 @@ class REPORTER;
|
||||
class SYMBOL_LIB;
|
||||
class LIB_SYMBOL;
|
||||
class LIB_FIELD;
|
||||
class LIB_PIN;
|
||||
class TEST_LIB_SYMBOL_FIXTURE;
|
||||
|
||||
|
||||
typedef std::shared_ptr<LIB_SYMBOL> LIB_SYMBOL_SPTR; ///< shared pointer to LIB_SYMBOL
|
||||
typedef std::weak_ptr<LIB_SYMBOL> LIB_SYMBOL_REF; ///< weak pointer to LIB_SYMBOL
|
||||
typedef MULTIVECTOR<LIB_ITEM, LIB_SHAPE_T, LIB_FIELD_T> LIB_ITEMS_CONTAINER;
|
||||
typedef MULTIVECTOR<SCH_ITEM, LIB_SHAPE_T, LIB_FIELD_T> LIB_ITEMS_CONTAINER;
|
||||
typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS;
|
||||
|
||||
|
||||
@ -64,7 +65,7 @@ struct LIB_SYMBOL_UNIT
|
||||
{
|
||||
int m_unit; ///< The unit number.
|
||||
int m_bodyStyle; ///< The alternate body style of the unit.
|
||||
std::vector<LIB_ITEM*> m_items; ///< The items unique to this unit and alternate body style.
|
||||
std::vector<SCH_ITEM*> m_items; ///< The items unique to this unit and alternate body style.
|
||||
};
|
||||
|
||||
|
||||
@ -96,7 +97,7 @@ public:
|
||||
LIB_SYMBOL* dupe = new LIB_SYMBOL( *this, m_library );
|
||||
const_cast<KIID&>( dupe->m_Uuid ) = KIID();
|
||||
|
||||
for( LIB_ITEM& item : dupe->m_drawings )
|
||||
for( SCH_ITEM& item : dupe->m_drawings )
|
||||
const_cast<KIID&>( item.m_Uuid ) = KIID();
|
||||
|
||||
return dupe;
|
||||
@ -337,8 +338,7 @@ public:
|
||||
int GetUnit() const override { return 0; }
|
||||
int GetBodyStyle() const override { return 0; }
|
||||
|
||||
// JEY TODO: reconcile with RunOnChildren when LIB_ITEM collapses to SCH_ITEM
|
||||
void RunOnLibChildren( const std::function<void( LIB_ITEM* )>& aFunction );
|
||||
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
|
||||
|
||||
/**
|
||||
* Order optional field indices.
|
||||
@ -373,14 +373,14 @@ public:
|
||||
* @param aItem is the new draw object to add to the symbol.
|
||||
* @param aSort is the flag to determine if the newly added item should be sorted.
|
||||
*/
|
||||
void AddDrawItem( LIB_ITEM* aItem, bool aSort = true );
|
||||
void AddDrawItem( SCH_ITEM* aItem, bool aSort = true );
|
||||
|
||||
/**
|
||||
* Remove draw \a aItem from list.
|
||||
*
|
||||
* @param aItem - Draw item to remove from list.
|
||||
*/
|
||||
void RemoveDrawItem( LIB_ITEM* aItem );
|
||||
void RemoveDrawItem( SCH_ITEM* aItem );
|
||||
|
||||
void RemoveField( LIB_FIELD* aField ) { RemoveDrawItem( aField ); }
|
||||
|
||||
@ -397,7 +397,7 @@ public:
|
||||
* @param aBodyStyle - Symbol alternate body style of pins to collect. Set to 0 to get pins
|
||||
* from any DeMorgan variant of symbol.
|
||||
*/
|
||||
void GetPins( LIB_PINS& aList, int aUnit = 0, int aBodyStyle = 0 ) const;
|
||||
void GetPins( std::vector<LIB_PIN*>& aList, int aUnit = 0, int aBodyStyle = 0 ) const;
|
||||
|
||||
/**
|
||||
* Return a list of pin pointers for all units / converts. Used primarily for SPICE where
|
||||
@ -458,8 +458,8 @@ public:
|
||||
/**
|
||||
* Clears the status flag all draw objects in this symbol.
|
||||
*/
|
||||
void ClearTempFlags();
|
||||
void ClearEditFlags();
|
||||
void ClearTempFlags() override;
|
||||
void ClearEditFlags() override;
|
||||
|
||||
/**
|
||||
* Locate a draw object.
|
||||
@ -470,7 +470,7 @@ public:
|
||||
* @param aPoint - Coordinate for hit testing.
|
||||
* @return The draw object if found. Otherwise NULL.
|
||||
*/
|
||||
LIB_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint );
|
||||
SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint );
|
||||
|
||||
/**
|
||||
* Locate a draw object (overlaid)
|
||||
@ -482,7 +482,7 @@ public:
|
||||
* @param aTransform = the transform matrix
|
||||
* @return The draw object if found. Otherwise NULL.
|
||||
*/
|
||||
LIB_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint,
|
||||
SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint,
|
||||
const TRANSFORM& aTransform );
|
||||
|
||||
/**
|
||||
@ -578,7 +578,7 @@ public:
|
||||
bool operator==( const LIB_SYMBOL& aSymbol ) const;
|
||||
bool operator!=( const LIB_SYMBOL& aSymbol ) const
|
||||
{
|
||||
return Compare( aSymbol, LIB_ITEM::COMPARE_FLAGS::EQUALITY ) != 0;
|
||||
return Compare( aSymbol, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) != 0;
|
||||
}
|
||||
|
||||
const LIB_SYMBOL& operator=( const LIB_SYMBOL& aSymbol );
|
||||
@ -593,7 +593,7 @@ public:
|
||||
std::unique_ptr< LIB_SYMBOL > Flatten() const;
|
||||
|
||||
/**
|
||||
* Return a list of LIB_ITEM objects separated by unit and convert number.
|
||||
* Return a list of SCH_ITEM objects separated by unit and convert number.
|
||||
*
|
||||
* @note This does not include LIB_FIELD objects since they are not associated with
|
||||
* unit and/or convert numbers.
|
||||
@ -610,7 +610,7 @@ public:
|
||||
*
|
||||
* @return a list of unit items.
|
||||
*/
|
||||
std::vector<LIB_ITEM*> GetUnitDrawItems( int aUnit, int aBodyStyle );
|
||||
std::vector<SCH_ITEM*> GetUnitDrawItems( int aUnit, int aBodyStyle );
|
||||
|
||||
/**
|
||||
* Return a measure of similarity between this symbol and \a aSymbol.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -30,7 +30,6 @@
|
||||
#include <widgets/msgpanel.h>
|
||||
#include <bitmaps.h>
|
||||
#include <eda_draw_frame.h>
|
||||
#include <lib_item.h>
|
||||
#include <general.h>
|
||||
#include <transform.h>
|
||||
#include <settings/color_settings.h>
|
||||
@ -38,8 +37,8 @@
|
||||
#include <default_values.h> // For some default values
|
||||
#include <string_utils.h>
|
||||
|
||||
LIB_TEXT::LIB_TEXT( LIB_SYMBOL* aParent ) :
|
||||
LIB_ITEM( LIB_TEXT_T, aParent ),
|
||||
LIB_TEXT::LIB_TEXT( SCH_ITEM* aParent ) :
|
||||
SCH_ITEM( aParent, LIB_TEXT_T ),
|
||||
EDA_TEXT( schIUScale, wxEmptyString )
|
||||
{
|
||||
SetTextSize( VECTOR2I( schIUScale.MilsToIU( DEFAULT_TEXT_SIZE ),
|
||||
@ -77,11 +76,11 @@ EDA_ITEM* LIB_TEXT::Clone() const
|
||||
}
|
||||
|
||||
|
||||
int LIB_TEXT::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
|
||||
int LIB_TEXT::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
|
||||
{
|
||||
wxASSERT( aOther.Type() == LIB_TEXT_T );
|
||||
|
||||
int retv = LIB_ITEM::compare( aOther, aCompareFlags );
|
||||
int retv = SCH_ITEM::compare( aOther, aCompareFlags );
|
||||
|
||||
if( retv )
|
||||
return retv;
|
||||
@ -109,18 +108,12 @@ int LIB_TEXT::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
|
||||
}
|
||||
|
||||
|
||||
void LIB_TEXT::Offset( const VECTOR2I& aOffset )
|
||||
void LIB_TEXT::Move( const VECTOR2I& aOffset )
|
||||
{
|
||||
EDA_TEXT::Offset( aOffset );
|
||||
}
|
||||
|
||||
|
||||
void LIB_TEXT::MoveTo( const VECTOR2I& newPosition )
|
||||
{
|
||||
SetTextPos( newPosition );
|
||||
}
|
||||
|
||||
|
||||
void LIB_TEXT::NormalizeJustification( bool inverse )
|
||||
{
|
||||
if( GetHorizJustify() == GR_TEXT_H_ALIGN_CENTER && GetVertJustify() == GR_TEXT_V_ALIGN_CENTER )
|
||||
@ -409,7 +402,7 @@ void LIB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
LIB_ITEM::GetMsgPanelInfo( aFrame, aList );
|
||||
getSymbolEditorMsgPanelInfo( aFrame, aList );
|
||||
|
||||
// Don't use GetShownText() here; we want to show the user the variable references
|
||||
aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
|
||||
@ -491,18 +484,18 @@ void LIB_TEXT::CalcEdit( const VECTOR2I& aPosition )
|
||||
}
|
||||
|
||||
|
||||
bool LIB_TEXT::operator==( const LIB_ITEM& aOther ) const
|
||||
bool LIB_TEXT::operator==( const SCH_ITEM& aOther ) const
|
||||
{
|
||||
if( Type() != aOther.Type() )
|
||||
return false;
|
||||
|
||||
const LIB_TEXT& other = static_cast<const LIB_TEXT&>( aOther );
|
||||
|
||||
return LIB_ITEM::operator==( aOther ) && EDA_TEXT::operator==( other );
|
||||
return SCH_ITEM::operator==( aOther ) && EDA_TEXT::operator==( other );
|
||||
}
|
||||
|
||||
|
||||
double LIB_TEXT::Similarity( const LIB_ITEM& aOther ) const
|
||||
double LIB_TEXT::Similarity( const SCH_ITEM& aOther ) const
|
||||
{
|
||||
if( m_Uuid == aOther.m_Uuid )
|
||||
return 1.0;
|
||||
@ -524,9 +517,9 @@ static struct LIB_TEXT_DESC
|
||||
{
|
||||
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
||||
REGISTER_TYPE( LIB_TEXT );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<LIB_TEXT, LIB_ITEM> );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<LIB_TEXT, SCH_ITEM> );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<LIB_TEXT, EDA_TEXT> );
|
||||
propMgr.InheritsAfter( TYPE_HASH( LIB_TEXT ), TYPE_HASH( LIB_ITEM ) );
|
||||
propMgr.InheritsAfter( TYPE_HASH( LIB_TEXT ), TYPE_HASH( SCH_ITEM ) );
|
||||
propMgr.InheritsAfter( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ) );
|
||||
|
||||
propMgr.Mask( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Mirrored" ) );
|
||||
|
@ -2,7 +2,7 @@
|
||||
* 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
|
||||
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -26,7 +26,7 @@
|
||||
#define LIB_TEXT_H
|
||||
|
||||
#include <eda_text.h>
|
||||
#include <lib_item.h>
|
||||
#include <sch_item.h>
|
||||
|
||||
|
||||
/**
|
||||
@ -36,10 +36,10 @@
|
||||
* symbol value, etc. are not LIB_TEXT items. See the #LIB_FIELD class for the
|
||||
* field item definition.
|
||||
*/
|
||||
class LIB_TEXT : public LIB_ITEM, public EDA_TEXT
|
||||
class LIB_TEXT : public SCH_ITEM, public EDA_TEXT
|
||||
{
|
||||
public:
|
||||
LIB_TEXT( LIB_SYMBOL* aParent );
|
||||
LIB_TEXT( SCH_ITEM* aParent );
|
||||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
|
||||
@ -91,11 +91,10 @@ public:
|
||||
void BeginEdit( const VECTOR2I& aStartPoint ) override;
|
||||
void CalcEdit( const VECTOR2I& aPosition ) override;
|
||||
|
||||
void Offset( const VECTOR2I& aOffset ) override;
|
||||
|
||||
void MoveTo( const VECTOR2I& aPosition ) override;
|
||||
void Move( const VECTOR2I& aOffset ) override;
|
||||
|
||||
VECTOR2I GetPosition() const override { return EDA_TEXT::GetTextPos(); }
|
||||
void SetPosition( const VECTOR2I& aPos ) override { EDA_TEXT::SetTextPos( aPos ); }
|
||||
|
||||
void MirrorHorizontally( int aCenter ) override;
|
||||
void MirrorVertically( int aCenter ) override;
|
||||
@ -116,13 +115,13 @@ public:
|
||||
|
||||
EDA_ITEM* Clone() const override;
|
||||
|
||||
double Similarity( const LIB_ITEM& aOther ) const override;
|
||||
double Similarity( const SCH_ITEM& aOther ) const override;
|
||||
|
||||
bool operator==( const LIB_ITEM& aOther ) const override;
|
||||
bool operator==( const SCH_ITEM& aOther ) const override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @copydoc LIB_ITEM::compare()
|
||||
* @copydoc SCH_ITEM::compare()
|
||||
*
|
||||
* The text specific sort order is as follows:
|
||||
* - Text string, case insensitive compare.
|
||||
@ -131,7 +130,7 @@ private:
|
||||
* - Text width.
|
||||
* - Text height.
|
||||
*/
|
||||
int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override;
|
||||
int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include <lib_textbox.h>
|
||||
|
||||
|
||||
LIB_TEXTBOX::LIB_TEXTBOX( LIB_SYMBOL* aParent, int aLineWidth, FILL_T aFillType,
|
||||
LIB_TEXTBOX::LIB_TEXTBOX( SCH_ITEM* aParent, int aLineWidth, FILL_T aFillType,
|
||||
const wxString& text ) :
|
||||
LIB_SHAPE( aParent, SHAPE_T::RECTANGLE, aLineWidth, aFillType, LIB_TEXTBOX_T ),
|
||||
EDA_TEXT( schIUScale, text )
|
||||
@ -188,11 +188,11 @@ VECTOR2I LIB_TEXTBOX::GetDrawPos() const
|
||||
}
|
||||
|
||||
|
||||
int LIB_TEXTBOX::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
|
||||
int LIB_TEXTBOX::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
|
||||
{
|
||||
wxASSERT( aOther.Type() == LIB_TEXTBOX_T );
|
||||
|
||||
int retv = LIB_ITEM::compare( aOther, aCompareFlags );
|
||||
int retv = SCH_ITEM::compare( aOther, aCompareFlags );
|
||||
|
||||
if( retv )
|
||||
return retv;
|
||||
@ -531,7 +531,7 @@ void LIB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL
|
||||
}
|
||||
|
||||
|
||||
bool LIB_TEXTBOX::operator==( const LIB_ITEM& aOther ) const
|
||||
bool LIB_TEXTBOX::operator==( const SCH_ITEM& aOther ) const
|
||||
{
|
||||
if( aOther.Type() != LIB_TEXTBOX_T )
|
||||
return false;
|
||||
@ -542,7 +542,7 @@ bool LIB_TEXTBOX::operator==( const LIB_ITEM& aOther ) const
|
||||
}
|
||||
|
||||
|
||||
double LIB_TEXTBOX::Similarity( const LIB_ITEM& aOther ) const
|
||||
double LIB_TEXTBOX::Similarity( const SCH_ITEM& aOther ) const
|
||||
{
|
||||
if( m_Uuid == aOther.m_Uuid )
|
||||
return 1.0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2022-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -34,7 +34,7 @@ class HTML_MESSAGE_BOX;
|
||||
class LIB_TEXTBOX : public LIB_SHAPE, public EDA_TEXT
|
||||
{
|
||||
public:
|
||||
LIB_TEXTBOX( LIB_SYMBOL* aParent, int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL,
|
||||
LIB_TEXTBOX( SCH_ITEM* aParent, int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL,
|
||||
const wxString& aText = wxEmptyString );
|
||||
|
||||
LIB_TEXTBOX( const LIB_TEXTBOX& aText );
|
||||
@ -80,7 +80,7 @@ public:
|
||||
|
||||
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
|
||||
{
|
||||
return LIB_ITEM::Matches( GetText(), aSearchData );
|
||||
return SCH_ITEM::Matches( GetText(), aSearchData );
|
||||
}
|
||||
|
||||
bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override
|
||||
@ -109,15 +109,15 @@ public:
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
double Similarity( const LIB_ITEM& aOther ) const override;
|
||||
double Similarity( const SCH_ITEM& aOther ) const override;
|
||||
|
||||
bool operator==( const LIB_ITEM& aOther ) const override;
|
||||
bool operator==( const SCH_ITEM& aOther ) const override;
|
||||
|
||||
protected:
|
||||
KIFONT::FONT* getDrawFont() const override;
|
||||
|
||||
private:
|
||||
int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override;
|
||||
int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
|
||||
|
||||
private:
|
||||
int m_marginLeft;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user