Fold LIB_ITEM into SCH_ITEM.

This commit is contained in:
Jeff Young 2024-04-06 14:14:44 +01:00
parent 494001ed4c
commit 5abc7145da
81 changed files with 843 additions and 1257 deletions

View File

@ -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 ) )

View File

@ -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

View File

@ -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 );

View File

@ -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() )
{

View File

@ -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;

View File

@ -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>

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 )

View File

@ -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() );
}

View File

@ -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" ),

View File

@ -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.

View File

@ -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;

View File

@ -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_

View File

@ -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 ) );

View File

@ -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.

View File

@ -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" ) );

View File

@ -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;
};

View File

@ -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 );

View File

@ -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.

View File

@ -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" ) );

View File

@ -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;
};

View File

@ -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;

View File

@ -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;

View File

@ -181,7 +181,7 @@ void NETLIST_EXPORTER_ALLEGRO::extractComponentsInfo()
continue;
}
LIB_PINS pinList;
std::vector<LIB_PIN*> pinList;
pinList.clear();
symbol->GetLibPins(pinList);
@ -450,7 +450,7 @@ void NETLIST_EXPORTER_ALLEGRO::toAllegroPackages()
fprintf( d, "PACKAGE '%s'\n", TO_UTF8( formatDevice( footprintText ) ) );
fprintf( d, "CLASS IC\n" );
LIB_PINS pinList;
std::vector<LIB_PIN*> pinList;
sym->GetLibSymbolRef()->GetPins( pinList, 0, 0 );
/*
@ -592,7 +592,7 @@ wxString NETLIST_EXPORTER_ALLEGRO::formatPin( const LIB_PIN& aPin )
}
wxString NETLIST_EXPORTER_ALLEGRO::formatFunction( wxString aName, LIB_PINS aPinList )
wxString NETLIST_EXPORTER_ALLEGRO::formatFunction( wxString aName, std::vector<LIB_PIN*> aPinList )
{
aName.MakeUpper();
std::list<wxString> pinNameList;

View File

@ -142,7 +142,7 @@ private:
* @param aPinList
* @return wxString
*/
wxString formatFunction( wxString aName, LIB_PINS aPinList );
wxString formatFunction( wxString aName, std::vector<LIB_PIN*> aPinList );
/**
* Look up a field for a component group, which may have mismatched case, or

View File

@ -571,7 +571,7 @@ XNODE* NETLIST_EXPORTER_XML::makeLibParts()
{
XNODE* xlibparts = node( wxT( "libparts" ) ); // auto_ptr
LIB_PINS pinList;
std::vector<LIB_PIN*> pinList;
std::vector<LIB_FIELD*> fieldList;
m_libraries.clear();

View File

@ -151,8 +151,8 @@ void SCH_EDIT_FRAME::FlipBodyStyle( SCH_SYMBOL* aSymbol )
// 2 = shape 2 = second (DeMorgan conversion) alternate body style
// > 2 is not currently supported
// When m_bodyStyle = val max, return to the first shape
if( aSymbol->GetBodyStyle() > LIB_ITEM::BODY_STYLE::DEMORGAN )
aSymbol->SetBodyStyle( LIB_ITEM::BODY_STYLE::BASE );
if( aSymbol->GetBodyStyle() > BODY_STYLE::DEMORGAN )
aSymbol->SetBodyStyle( BODY_STYLE::BASE );
// If selected make sure all the now-included pins are selected
if( aSymbol->IsSelected() )

View File

@ -25,7 +25,6 @@
#include <tool/tool_manager.h>
#include <tools/ee_tool_base.h>
#include <lib_item.h>
#include <lib_symbol.h>
#include <sch_screen.h>
@ -133,8 +132,8 @@ void SCH_COMMIT::pushLibEdit( const wxString& aMessage, int aCommitFlags )
{
view->Update( symbol );
symbol->RunOnLibChildren(
[&]( LIB_ITEM* aChild )
symbol->RunOnChildren(
[&]( SCH_ITEM* aChild )
{
view->Update( aChild );
} );
@ -424,7 +423,7 @@ EDA_ITEM* SCH_COMMIT::makeImage( EDA_ITEM* aItem ) const
LIB_SYMBOL* symbol = frame->GetCurSymbol();
std::vector<KIID> selected;
for( const LIB_ITEM& item : symbol->GetDrawItems() )
for( const SCH_ITEM& item : symbol->GetDrawItems() )
{
if( item.IsSelected() )
selected.push_back( item.m_Uuid );
@ -432,7 +431,7 @@ EDA_ITEM* SCH_COMMIT::makeImage( EDA_ITEM* aItem ) const
symbol = new LIB_SYMBOL( *symbol );
for( LIB_ITEM& item : symbol->GetDrawItems() )
for( SCH_ITEM& item : symbol->GetDrawItems() )
{
if( alg::contains( selected, item.m_Uuid ) )
item.SetSelected();

View File

@ -285,13 +285,13 @@ void CADSTAR_SCH_ARCHIVE_LOADER::copySymbolItems( std::unique_ptr<LIB_SYMBOL>& a
int aDestUnit, bool aOverrideFields )
{
// Ensure there are no items on the unit we want to load onto
for( LIB_ITEM* item : aDestSym->GetUnitDrawItems( aDestUnit, 0 /*aConvert*/ ) )
for( SCH_ITEM* item : aDestSym->GetUnitDrawItems( aDestUnit, 0 /*aConvert*/ ) )
aDestSym->RemoveDrawItem( item );
// Copy all draw items
for( LIB_ITEM* newItem : aSourceSym->GetUnitDrawItems( 1, 0 /*aConvert*/ ) )
for( SCH_ITEM* newItem : aSourceSym->GetUnitDrawItems( 1, 0 /*aConvert*/ ) )
{
LIB_ITEM* itemCopy = static_cast<LIB_ITEM*>( newItem->Clone() );
SCH_ITEM* itemCopy = static_cast<SCH_ITEM*>( newItem->Clone() );
itemCopy->SetParent( aDestSym.get() );
itemCopy->SetUnit( aDestUnit );
aDestSym->AddDrawItem( itemCopy );
@ -880,7 +880,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
kiPart->SetShowPinNames( false );
kiPart->SetShowPinNumbers( false );
LIB_PINS pins = kiPart->GetAllLibPins();
std::vector<LIB_PIN*> pins = kiPart->GetAllLibPins();
wxCHECK( pins.size() == 1, /*void*/ );
pins.at( 0 )->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
@ -3232,7 +3232,7 @@ LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart( const LIB_SYMBOL* aSym
LIB_ITEMS_CONTAINER& items = retval->GetDrawItems();
for( LIB_ITEM& item : items )
for( SCH_ITEM& item : items )
{
switch( item.Type() )
{
@ -3326,7 +3326,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins( LIB_SYMBOL* aSymbolToFix, int
}
}
LIB_PINS pins;
std::vector<LIB_PIN*> pins;
aSymbolToFix->GetPins( pins, aGateNumber );
for( auto& pin : pins )

View File

@ -2137,7 +2137,7 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBO
EDEVICE* aDevice, int aGateNumber, const wxString& aGateName )
{
wxString symbolName = aSymbolNode->GetAttribute( wxT( "name" ) );
std::vector<LIB_ITEM*> items;
std::vector<SCH_ITEM*> items;
wxXmlNode* currentNode = aSymbolNode->GetChildren();
@ -2256,11 +2256,11 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBO
}
else if( nodeName == wxT( "frame" ) )
{
std::vector<LIB_ITEM*> frameItems;
std::vector<SCH_ITEM*> frameItems;
loadFrame( currentNode, frameItems );
loadSymbolFrame( currentNode, frameItems );
for( LIB_ITEM* item : frameItems )
for( SCH_ITEM* item : frameItems )
{
item->SetParent( aSymbol.get() );
item->SetUnit( aGateNumber );
@ -2338,7 +2338,7 @@ LIB_SHAPE* SCH_IO_EAGLE::loadSymbolRectangle( std::unique_ptr<LIB_SYMBOL>& aSymb
}
LIB_ITEM* SCH_IO_EAGLE::loadSymbolWire( std::unique_ptr<LIB_SYMBOL>& aSymbol,
SCH_ITEM* SCH_IO_EAGLE::loadSymbolWire( std::unique_ptr<LIB_SYMBOL>& aSymbol,
wxXmlNode* aWireNode, int aGateNumber )
{
EWIRE ewire = EWIRE( aWireNode );
@ -2546,7 +2546,7 @@ LIB_TEXT* SCH_IO_EAGLE::loadSymbolText( std::unique_ptr<LIB_SYMBOL>& aSymbol,
}
void SCH_IO_EAGLE::loadFrame( wxXmlNode* aFrameNode, std::vector<LIB_ITEM*>& aItems )
void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*>& aItems )
{
EFRAME eframe( aFrameNode );

View File

@ -29,7 +29,6 @@
#include <sch_io/sch_io.h>
#include <sch_io/sch_io_mgr.h>
#include <io/eagle/eagle_parser.h>
#include <lib_item.h>
#include <geometry/seg.h>
#include <boost/ptr_container/ptr_map.hpp>
@ -164,13 +163,13 @@ private:
int aGateNumber );
LIB_SHAPE* loadSymbolPolyLine( std::unique_ptr<LIB_SYMBOL>& aSymbol,
wxXmlNode* aPolygonNode, int aGateNumber );
LIB_ITEM* loadSymbolWire( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aWireNode,
SCH_ITEM* loadSymbolWire( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aWireNode,
int aGateNumber );
LIB_PIN* loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode*, EPIN* epin,
int aGateNumber );
LIB_TEXT* loadSymbolText( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aLibText,
int aGateNumber );
void loadFrame( wxXmlNode* aFrameNode, std::vector<LIB_ITEM*>& aLines );
void loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*>& aLines );
void loadTextAttributes( EDA_TEXT* aText, const ETEXT& aAttribs ) const;
void loadFieldAttributes( LIB_FIELD* aField, const LIB_TEXT* aText ) const;

View File

@ -522,7 +522,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol
svgImportPlugin.Import();
for( std::unique_ptr<EDA_ITEM>& item : libsymImporter.GetItems() )
aSymbol->AddDrawItem( static_cast<LIB_ITEM*>( item.release() ) );
aSymbol->AddDrawItem( static_cast<SCH_ITEM*>( item.release() ) );
}
else
{
@ -948,7 +948,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol
TransformTextToBaseline( textItem, baselineAlign, true );
if( added )
aSymbol->AddDrawItem( dynamic_cast<LIB_ITEM*>( textItem ) );
aSymbol->AddDrawItem( dynamic_cast<SCH_ITEM*>( textItem ) );
}
}
}

View File

@ -601,7 +601,7 @@ EASYEDAPRO::SYM_INFO SCH_EASYEDAPRO_PARSER::ParseSymbol( const std::vector<nlohm
// TODO: rotation
for( std::unique_ptr<EDA_ITEM>& item : libsymImporter.GetItems() )
ksymbol->AddDrawItem( static_cast<LIB_ITEM*>( item.release() ) );
ksymbol->AddDrawItem( static_cast<SCH_ITEM*>( item.release() ) );
}
else
{

View File

@ -56,6 +56,9 @@
( LIB_VERSION( major, minor ) <= LIB_VERSION( 2, 4 ) )
const int fill_tab[3] = { 'N', 'F', 'f' };
SCH_IO_KICAD_LEGACY_LIB_CACHE::SCH_IO_KICAD_LEGACY_LIB_CACHE( const wxString& aFullPathAndFileName ) :
SCH_IO_LIB_CACHE( aFullPathAndFileName )
{
@ -1573,7 +1576,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMA
aFormatter.Print( 0, "DRAW\n" );
for( LIB_ITEM& item : aSymbol->GetDrawItems() )
for( SCH_ITEM& item : aSymbol->GetDrawItems() )
{
switch( item.Type() )
{

View File

@ -724,7 +724,7 @@ void SCH_IO_KICAD_SEXPR::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSche
m_out->Print( 0, " (unit %d)", unit );
if( aSymbol->GetBodyStyle() == LIB_ITEM::BODY_STYLE::DEMORGAN )
if( aSymbol->GetBodyStyle() == BODY_STYLE::DEMORGAN )
m_out->Print( 0, " (convert %d)", aSymbol->GetBodyStyle() );
m_out->Print( 0, "\n" );

View File

@ -246,17 +246,17 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMAT
}
// Enforce item ordering
auto cmp =
[]( const LIB_ITEM* a, const LIB_ITEM* b )
[]( const SCH_ITEM* a, const SCH_ITEM* b )
{
return *a < *b;
};
std::multiset<LIB_ITEM*, decltype( cmp )> save_map( cmp );
std::multiset<SCH_ITEM*, decltype( cmp )> save_map( cmp );
for( LIB_ITEM* item : unit.m_items )
for( SCH_ITEM* item : unit.m_items )
save_map.insert( item );
for( LIB_ITEM* item : save_map )
for( SCH_ITEM* item : save_map )
saveSymbolDrawItem( item, aFormatter, aNestLevel + 2 );
aFormatter.Print( aNestLevel + 1, ")\n" );
@ -327,10 +327,10 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveDcmInfoAsFields( LIB_SYMBOL* aSymbol,
}
void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveSymbolDrawItem( LIB_ITEM* aItem, OUTPUTFORMATTER& aFormatter,
void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveSymbolDrawItem( SCH_ITEM* aItem, OUTPUTFORMATTER& aFormatter,
int aNestLevel )
{
wxCHECK_RET( aItem, "Invalid LIB_ITEM pointer." );
wxCHECK_RET( aItem, "Invalid SCH_ITEM pointer." );
switch( aItem->Type() )
{

View File

@ -26,7 +26,6 @@
class FILE_LINE_READER;
class LIB_FIELD;
class LIB_ITEM;
class LIB_PIN;
class LIB_TEXT;
class LIB_TEXTBOX;
@ -64,7 +63,7 @@ private:
int m_fileFormatVersionAtLoad;
static void saveSymbolDrawItem( LIB_ITEM* aItem, OUTPUTFORMATTER& aFormatter,
static void saveSymbolDrawItem( SCH_ITEM* aItem, OUTPUTFORMATTER& aFormatter,
int aNestLevel );
static void saveField( LIB_FIELD* aField, OUTPUTFORMATTER& aFormatter, int aNestLevel );
static void savePin( LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 );

View File

@ -290,7 +290,7 @@ LIB_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLi
wxString name;
wxString error;
wxString unitDisplayName;
LIB_ITEM* item;
SCH_ITEM* item;
std::unique_ptr<LIB_SYMBOL> symbol = std::make_unique<LIB_SYMBOL>( wxEmptyString );
symbol->SetUnitCount( 1 );
@ -548,7 +548,7 @@ LIB_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLi
}
LIB_ITEM* SCH_IO_KICAD_SEXPR_PARSER::ParseDrawItem()
SCH_ITEM* SCH_IO_KICAD_SEXPR_PARSER::ParseDrawItem()
{
switch( CurTok() )
{

View File

@ -38,7 +38,6 @@
class LIB_SHAPE;
class LIB_ITEM;
class LIB_PIN;
class LIB_TEXT;
class PAGE_INFO;
@ -90,7 +89,7 @@ public:
LIB_SYMBOL* ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap,
int aFileVersion = SEXPR_SYMBOL_LIB_FILE_VERSION );
LIB_ITEM* ParseDrawItem();
SCH_ITEM* ParseDrawItem();
/**
* Parse the internal #LINE_READER object into \a aSheet.

View File

@ -123,7 +123,7 @@ LIB_SYMBOL* SCH_IO_LIB_CACHE::removeSymbol( LIB_SYMBOL* aSymbol )
if( firstChild )
{
for( LIB_ITEM& drawItem : aSymbol->GetDrawItems() )
for( SCH_ITEM& drawItem : aSymbol->GetDrawItems() )
{
if( drawItem.Type() == LIB_FIELD_T )
{
@ -133,7 +133,7 @@ LIB_SYMBOL* SCH_IO_LIB_CACHE::removeSymbol( LIB_SYMBOL* aSymbol )
continue;
}
LIB_ITEM* newItem = (LIB_ITEM*) drawItem.Clone();
SCH_ITEM* newItem = (SCH_ITEM*) drawItem.Clone();
drawItem.SetParent( firstChild );
firstChild->AddDrawItem( newItem );
}

View File

@ -48,11 +48,36 @@
#define BITMAP_FONT_SIZE_THRESHOLD 3
wxString SCH_ITEM::GetUnitDescription( int aUnit )
{
if( aUnit == 0 )
return _( "All" );
else
return LIB_SYMBOL::LetterSubReference( aUnit, 'A' );
}
wxString SCH_ITEM::GetBodyStyleDescription( int aBodyStyle )
{
if( aBodyStyle == 0 )
return _( "All" );
else if( aBodyStyle == BODY_STYLE::DEMORGAN )
return _( "Alternate" );
else if( aBodyStyle == BODY_STYLE::BASE )
return _( "Standard" );
else
return wxT( "?" );
}
/* Constructor and destructor for SCH_ITEM */
/* They are not inline because this creates problems with gcc at linking time in debug mode */
SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ) :
EDA_ITEM( aParent, aType )
SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType, int aUnit, int aBodyStyle ) :
EDA_ITEM( aParent, aType ),
m_unit( aUnit ),
m_bodyStyle( aBodyStyle ),
m_private( false )
{
m_layer = LAYER_WIRE; // It's only a default, in fact
m_fieldsAutoplaced = FIELDS_AUTOPLACED_NO;
@ -64,6 +89,9 @@ SCH_ITEM::SCH_ITEM( const SCH_ITEM& aItem ) :
EDA_ITEM( aItem )
{
m_layer = aItem.m_layer;
m_unit = aItem.m_unit;
m_bodyStyle = aItem.m_bodyStyle;
m_private = aItem.m_private;
m_fieldsAutoplaced = aItem.m_fieldsAutoplaced;
m_connectivity_dirty = aItem.m_connectivity_dirty;
}
@ -72,6 +100,9 @@ SCH_ITEM::SCH_ITEM( const SCH_ITEM& aItem ) :
SCH_ITEM& SCH_ITEM::operator=( const SCH_ITEM& aItem )
{
m_layer = aItem.m_layer;
m_unit = aItem.m_unit;
m_bodyStyle = aItem.m_bodyStyle;
m_private = aItem.m_private;
m_fieldsAutoplaced = aItem.m_fieldsAutoplaced;
m_connectivity_dirty = aItem.m_connectivity_dirty;
@ -123,26 +154,47 @@ SCHEMATIC* SCH_ITEM::Schematic() const
const SYMBOL* SCH_ITEM::GetParentSymbol() const
{
wxCHECK( m_parent->Type() == SCH_SYMBOL_T, nullptr );
const EDA_ITEM* parent = GetParent();
return static_cast<const SCH_SYMBOL*>( m_parent );
while( parent )
{
if( parent->Type() == SCH_SYMBOL_T )
return static_cast<const SCH_SYMBOL*>( parent );
else if( parent->Type() == LIB_SYMBOL_T )
return static_cast<const LIB_SYMBOL*>( parent );
else
parent = parent->GetParent();
}
return nullptr;
}
SYMBOL* SCH_ITEM::GetParentSymbol()
{
wxCHECK( m_parent->Type() == SCH_SYMBOL_T, nullptr );
EDA_ITEM* parent = GetParent();
return static_cast<SCH_SYMBOL*>( m_parent );
while( parent )
{
if( parent->Type() == SCH_SYMBOL_T )
return static_cast<SCH_SYMBOL*>( parent );
else if( parent->Type() == LIB_SYMBOL_T )
return static_cast<LIB_SYMBOL*>( parent );
else
parent = parent->GetParent();
}
return nullptr;
}
void SCH_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
{
// Basic fallback
aCount = 2;
aLayers[0] = LAYER_DEVICE;
aLayers[1] = LAYER_SELECTION_SHADOWS;
aCount = 3;
aLayers[0] = LAYER_DEVICE;
aLayers[1] = LAYER_DEVICE_BACKGROUND;
aLayers[2] = LAYER_SELECTION_SHADOWS;
}
@ -316,18 +368,54 @@ void SCH_ITEM::ClearCaches()
}
bool SCH_ITEM::operator < ( const SCH_ITEM& aItem ) const
bool SCH_ITEM::operator==( const SCH_ITEM& aOther ) const
{
if( Type() != aItem.Type() )
return Type() < aItem.Type();
if( Type() != aOther.Type() )
return false;
if( GetPosition().x != aItem.GetPosition().x )
return GetPosition().x < aItem.GetPosition().x;
return compare( aOther, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) == 0;
}
if( GetPosition().y != aItem.GetPosition().y )
return GetPosition().y < aItem.GetPosition().y;
return m_Uuid < aItem.m_Uuid;
bool SCH_ITEM::operator<( const SCH_ITEM& aOther ) const
{
if( Type() != aOther.Type() )
return Type() < aOther.Type();
return ( compare( aOther ) < 0 );
}
bool SCH_ITEM::cmp_items::operator()( const SCH_ITEM* aFirst, const SCH_ITEM* aSecond ) const
{
return aFirst->compare( *aSecond, COMPARE_FLAGS::EQUALITY ) < 0;
}
int SCH_ITEM::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
{
if( Type() != aOther.Type() )
return Type() - aOther.Type();
if( !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::UNIT ) && m_unit != aOther.m_unit )
return m_unit - aOther.m_unit;
if( !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::UNIT ) && m_bodyStyle != aOther.m_bodyStyle )
return m_bodyStyle - aOther.m_bodyStyle;
if( IsPrivate() != aOther.IsPrivate() )
return IsPrivate() < aOther.IsPrivate();
if( GetPosition().x != aOther.GetPosition().x )
return GetPosition().x < aOther.GetPosition().x;
if( GetPosition().y != aOther.GetPosition().y )
return GetPosition().y < aOther.GetPosition().y;
if( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY )
return 0;
return m_Uuid < aOther.m_Uuid;
}
@ -348,6 +436,20 @@ const KIFONT::METRICS& SCH_ITEM::GetFontMetrics() const
}
int SCH_ITEM::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() );
}
bool SCH_ITEM::RenderAsBitmap( double aWorldScale ) const
{
if( IsHypertext() )
@ -360,38 +462,78 @@ bool SCH_ITEM::RenderAsBitmap( double aWorldScale ) const
}
void SCH_ITEM::getSymbolEditorMsgPanelInfo( 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 );
}
static struct SCH_ITEM_DESC
{
SCH_ITEM_DESC()
{
#ifdef NOTYET
ENUM_MAP<SCH_LAYER_ID>& layerEnum = ENUM_MAP<SCH_LAYER_ID>::Instance();
if( layerEnum.Choices().GetCount() == 0 )
{
layerEnum.Undefined( SCH_LAYER_ID_END );
for( SCH_LAYER_ID value : magic_enum::enum_values<SCH_LAYER_ID>() )
layerEnum.Map( value, LayerName( value ) );
}
#endif
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( SCH_ITEM );
propMgr.InheritsAfter( TYPE_HASH( SCH_ITEM ), TYPE_HASH( EDA_ITEM ) );
#ifdef NOTYET
// Not sure if this will ever be needed
propMgr.AddProperty( new PROPERTY_ENUM<SCH_ITEM, SCH_LAYER_ID>( _HKI( "Layer" ),
&SCH_ITEM::SetLayer, &SCH_ITEM::GetLayer ) )
.SetIsHiddenFromPropertiesManager();
#endif
#ifdef NOTYET
// Not yet functional in UI
propMgr.AddProperty( new PROPERTY<SCH_ITEM, bool>( _HKI( "Locked" ),
&SCH_ITEM::SetLocked, &SCH_ITEM::IsLocked ) );
#endif
auto multiUnit =
[=]( INSPECTABLE* aItem ) -> bool
{
if( SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( aItem ) )
{
if( const SYMBOL* symbol = schItem->GetParentSymbol() )
return symbol->IsMulti();
}
return false;
};
auto multiBodyStyle =
[=]( INSPECTABLE* aItem ) -> bool
{
if( SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( aItem ) )
{
if( const SYMBOL* symbol = schItem->GetParentSymbol() )
return symbol->HasAlternateBodyStyle();
}
return false;
};
propMgr.AddProperty( new PROPERTY<SCH_ITEM, int>( _HKI( "Unit" ),
&SCH_ITEM::SetUnit, &SCH_ITEM::GetUnit ) )
.SetAvailableFunc( multiUnit )
.SetIsHiddenFromDesignEditors();
propMgr.AddProperty( new PROPERTY<SCH_ITEM, int>( _HKI( "Body Style" ),
&SCH_ITEM::SetBodyStyle, &SCH_ITEM::GetBodyStyle ) )
.SetAvailableFunc( multiBodyStyle )
.SetIsHiddenFromDesignEditors();
propMgr.AddProperty( new PROPERTY<SCH_ITEM, bool>( _HKI( "Private" ),
&SCH_ITEM::SetPrivate, &SCH_ITEM::IsPrivate ) )
.SetIsHiddenFromDesignEditors();
}
} _SCH_ITEM_DESC;

View File

@ -52,6 +52,16 @@ class METRICS;
}
enum BODY_STYLE : int
{
BASE = 1,
DEMORGAN = 2
};
#define MINIMUM_SELECTION_DISTANCE 2 // Minimum selection distance in mils
enum FIELDS_AUTOPLACED
{
FIELDS_AUTOPLACED_NO = 0,
@ -161,7 +171,7 @@ typedef std::vector<SCH_ITEM*> SCH_ITEM_SET;
class SCH_ITEM : public EDA_ITEM
{
public:
SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType );
SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType, int aUnit = 0, int aBodyStyle = 0 );
SCH_ITEM( const SCH_ITEM& aItem );
@ -218,6 +228,18 @@ public:
*/
SCH_ITEM* Duplicate( bool doClone = false ) const;
static wxString GetUnitDescription( int aUnit );
static wxString GetBodyStyleDescription( int aBodyStyle );
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; }
virtual void SetExcludedFromSim( bool aExclude ) { }
virtual bool GetExcludedFromSim() const { return false; }
@ -275,6 +297,8 @@ public:
*/
virtual int GetPenWidth() const { return 0; }
int GetEffectivePenWidth( const SCH_RENDER_SETTINGS* aSettings ) const;
const wxString& GetDefaultFont() const;
const KIFONT::METRICS& GetFontMetrics() const;
@ -290,9 +314,25 @@ public:
wxCHECK_MSG( false, 0.0, wxT( "Similarity not implemented in " ) + GetClass() );
}
virtual bool operator==( const SCH_ITEM& aOtherItem ) const
/**
* 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 SCH_ITEM& aItem ) const
{
wxCHECK_MSG( false, false, wxT( "operator== not implemented in " ) + GetClass() );
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;
}
/**
@ -327,6 +367,47 @@ public:
wxCHECK_MSG( false, /*void*/, wxT( "Rotate not implemented in " ) + GetClass() );
}
/**
* 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 ) {}
/**
* Add the schematic item end points to \a aItemList if the item has end points.
*
@ -542,7 +623,28 @@ public:
wxCHECK_MSG( false, /*void*/, wxT( "Plot not implemented in " ) + GetClass() );
}
virtual bool operator <( const SCH_ITEM& aItem ) const;
/**
* The list of flags used by the #compare function.
*
* UNIT This flag relaxes unit, body-style and pin-number constraints. It is used for
* #SCH_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
};
virtual bool operator==( const SCH_ITEM& aOther ) const;
virtual bool operator<( const SCH_ITEM& aItem ) const;
protected:
SCH_RENDER_SETTINGS* getRenderSettings( PLOTTER* aPlotter ) const
@ -550,6 +652,35 @@ protected:
return static_cast<SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
}
struct cmp_items
{
bool operator()( const SCH_ITEM* aFirst, const SCH_ITEM* aSecond ) const;
};
void getSymbolEditorMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList );
/**
* 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 #SCH_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 #SCH_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 SCH_ITEM& aOther, int aCompareFlags = 0 ) const;
private:
friend class CONNECTION_GRAPH;
@ -570,6 +701,9 @@ private:
protected:
SCH_LAYER_ID m_layer;
int m_unit; // set to 0 if common to all units
int m_bodyStyle; // set to 0 if common to all body styles
bool m_private; // only shown in Symbol Editor
FIELDS_AUTOPLACED m_fieldsAutoplaced; // indicates status of field autoplacement
VECTOR2I m_storedPos; // temp variable used in some move commands to store
// an initial position of the item or mouse cursor
@ -581,6 +715,9 @@ protected:
std::unordered_map<SCH_SHEET_PATH, SCH_CONNECTION*> m_connection_map;
bool m_connectivity_dirty;
private:
friend class LIB_SYMBOL;
};
#ifndef SWIG

View File

@ -1416,7 +1416,7 @@ void SCH_LABEL_BASE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int
wxDC* DC = aSettings->GetPrintDC();
COLOR4D color = aSettings->GetLayerColor( layer );
bool blackAndWhiteMode = GetGRForceBlackPenState();
int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
int penWidth = GetEffectivePenWidth( aSettings );
VECTOR2I text_offset = aOffset + GetSchematicTextOffset( aSettings );
if( !blackAndWhiteMode && GetTextColor() != COLOR4D::UNSPECIFIED )

View File

@ -371,7 +371,7 @@ void SCH_LINE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBody
VECTOR2I start = m_start;
VECTOR2I end = m_end;
LINE_STYLE lineStyle = GetEffectiveLineStyle();
int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
int penWidth = GetEffectivePenWidth( aSettings );
if( lineStyle <= LINE_STYLE::FIRST_TYPE )
{
@ -905,7 +905,7 @@ void SCH_LINE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& a
return;
SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
int penWidth = std::max( GetPenWidth(), renderSettings->GetMinPenWidth() );
int penWidth = GetEffectivePenWidth( renderSettings );
COLOR4D color = GetLineColor();
if( color == COLOR4D::UNSPECIFIED )
@ -924,7 +924,7 @@ void SCH_LINE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& a
// Plot attributes to a hypertext menu
std::vector<wxString> properties;
BOX2I bbox = GetBoundingBox();
bbox.Inflate( GetPenWidth() * 3 );
bbox.Inflate( penWidth * 3 );
if( aPlotOpts.m_PDFPropertyPopups )
{

View File

@ -107,7 +107,7 @@ void SCH_NO_CONNECT::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int
{
wxDC* DC = aSettings->GetPrintDC();
int half = GetSize() / 2;
int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
int penWidth = GetEffectivePenWidth( aSettings );
int pX = m_pos.x + aOffset.x;
int pY = m_pos.y + aOffset.y;
COLOR4D color = aSettings->GetLayerColor( LAYER_NOCONNECT );
@ -198,7 +198,7 @@ void SCH_NO_CONNECT::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_O
int delta = GetSize() / 2;
int pX = m_pos.x;
int pY = m_pos.y;
int penWidth = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetDefaultPenWidth() );
int penWidth = GetEffectivePenWidth( getRenderSettings( aPlotter ) );
aPlotter->SetCurrentLineWidth( penWidth );
aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_NOCONNECT ) );

View File

@ -36,7 +36,6 @@
#include <gr_text.h>
#include <lib_shape.h>
#include <lib_field.h>
#include <lib_item.h>
#include <lib_pin.h>
#include <lib_text.h>
#include <lib_textbox.h>
@ -123,7 +122,7 @@ static LIB_SYMBOL* dummy()
LIB_SHAPE* square = new LIB_SHAPE( symbol, SHAPE_T::RECTANGLE );
square->MoveTo( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) );
square->SetPosition( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) );
square->SetEnd( VECTOR2I( schIUScale.MilsToIU( 200 ), schIUScale.MilsToIU( -200 ) ) );
LIB_TEXT* text = new LIB_TEXT( symbol );
@ -294,7 +293,7 @@ bool SCH_PAINTER::nonCached( const EDA_ITEM* aItem )
}
bool SCH_PAINTER::isUnitAndConversionShown( const LIB_ITEM* aItem ) const
bool SCH_PAINTER::isUnitAndConversionShown( const SCH_ITEM* aItem ) const
{
if( m_schSettings.m_ShowUnit // showing a specific unit
&& aItem->GetUnit() // item is unit-specific
@ -478,10 +477,8 @@ float SCH_PAINTER::getLineWidth( const EDA_ITEM* aItem, bool aDrawingShadows ) c
int pen = 0;
if( dynamic_cast<const LIB_ITEM*>( aItem ) )
pen = static_cast<const LIB_ITEM*>( aItem )->GetEffectivePenWidth( &m_schSettings );
else if( dynamic_cast<const SCH_ITEM*>( aItem ) )
pen = static_cast<const SCH_ITEM*>( aItem )->GetPenWidth();
if( const SCH_ITEM* item = dynamic_cast<const SCH_ITEM*>( aItem ) )
pen = item->GetEffectivePenWidth( &m_schSettings );
else
UNIMPLEMENTED_FOR( aItem->GetClass() );
@ -724,7 +721,7 @@ void SCH_PAINTER::draw( const LIB_SYMBOL* aSymbol, int aLayer, bool aDrawFields,
// The parent must exist on the union of all its children's draw layers. But that doesn't
// mean we want to draw each child on the union.
auto childOnLayer =
[]( const LIB_ITEM& item, int layer )
[]( const SCH_ITEM& item, int layer )
{
int layers[512], layers_count;
item.ViewGetLayers( layers, layers_count );
@ -738,7 +735,7 @@ void SCH_PAINTER::draw( const LIB_SYMBOL* aSymbol, int aLayer, bool aDrawFields,
return false;
};
for( const LIB_ITEM& item : drawnSymbol->GetDrawItems() )
for( const SCH_ITEM& item : drawnSymbol->GetDrawItems() )
{
if( !aDrawFields && item.Type() == LIB_FIELD_T )
continue;
@ -757,7 +754,7 @@ void SCH_PAINTER::draw( const LIB_SYMBOL* aSymbol, int aLayer, bool aDrawFields,
}
bool SCH_PAINTER::setDeviceColors( const LIB_ITEM* aItem, int aLayer, bool aDimmed )
bool SCH_PAINTER::setDeviceColors( const SCH_ITEM* aItem, int aLayer, bool aDimmed )
{
COLOR4D bg = m_schSettings.GetLayerColor( LAYER_SCHEMATIC_BACKGROUND );
const EDA_SHAPE* shape = dynamic_cast<const EDA_SHAPE*>( aItem );
@ -2577,7 +2574,7 @@ static void orientSymbol( LIB_SYMBOL* symbol, int orientation )
}
}
for( LIB_ITEM& item : symbol->GetDrawItems() )
for( SCH_ITEM& item : symbol->GetDrawItems() )
{
for( int i = 0; i < o.n_rots; i++ )
item.Rotate( VECTOR2I(0, 0 ), true );
@ -2630,24 +2627,24 @@ void SCH_PAINTER::draw( const SCH_SYMBOL* aSymbol, int aLayer )
int bodyStyle = aSymbol->GetBodyStyle();
// Use dummy symbol if the actual couldn't be found (or couldn't be locked).
LIB_SYMBOL* originalSymbol = aSymbol->GetLibSymbolRef() ?
aSymbol->GetLibSymbolRef().get() : dummy();
LIB_PINS originalPins;
LIB_SYMBOL* originalSymbol = aSymbol->GetLibSymbolRef() ? aSymbol->GetLibSymbolRef().get()
: dummy();
std::vector<LIB_PIN*> originalPins;
originalSymbol->GetPins( originalPins, unit, bodyStyle );
// Copy the source so we can re-orient and translate it.
LIB_SYMBOL tempSymbol( *originalSymbol );
LIB_PINS tempPins;
std::vector<LIB_PIN*> tempPins;
tempSymbol.GetPins( tempPins, unit, bodyStyle );
tempSymbol.SetFlags( aSymbol->GetFlags() );
orientSymbol( &tempSymbol, aSymbol->GetOrientation() );
for( LIB_ITEM& tempItem : tempSymbol.GetDrawItems() )
for( SCH_ITEM& tempItem : tempSymbol.GetDrawItems() )
{
tempItem.SetFlags( aSymbol->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED,
tempItem.MoveTo( tempItem.GetPosition() + (VECTOR2I) mapCoords( aSymbol->GetPosition() ) );
tempItem.Move( (VECTOR2I) mapCoords( aSymbol->GetPosition() ) );
if( tempItem.Type() == LIB_TEXT_T )
{

View File

@ -35,7 +35,6 @@
class LIB_PIN;
class LIB_SHAPE;
class LIB_ITEM;
class LIB_SYMBOL;
class LIB_FIELD;
class LIB_TEXT;
@ -121,7 +120,7 @@ private:
// Indicates the item is drawn on a non-cached layer in OpenGL
bool nonCached( const EDA_ITEM* aItem );
bool isUnitAndConversionShown( const LIB_ITEM* aItem ) const;
bool isUnitAndConversionShown( const SCH_ITEM* aItem ) const;
float getShadowWidth( bool aForHighlight ) const;
COLOR4D getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows,
@ -132,7 +131,7 @@ private:
int getOperatingPointTextSize() const;
bool setDeviceColors( const LIB_ITEM* aItem, int aLayer, bool aDimmed );
bool setDeviceColors( const SCH_ITEM* aItem, int aLayer, bool aDimmed );
void triLine( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c );
void strokeText( const wxString& aText, const VECTOR2D& aPosition,

View File

@ -235,14 +235,14 @@ void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITE
if( symbol->GetUnitCount() )
{
msg = m_libPin ? LIB_ITEM::GetUnitDescription( m_libPin->GetUnit() ) :
msg = m_libPin ? GetUnitDescription( m_libPin->GetUnit() ) :
wxString( "Undefined library pin." );
aList.emplace_back( _( "Unit" ), msg );
}
if( symbol->HasAlternateBodyStyle() )
{
msg = m_libPin ? LIB_ITEM::GetBodyStyleDescription( m_libPin->GetBodyStyle() ) :
msg = m_libPin ? GetBodyStyleDescription( m_libPin->GetBodyStyle() ) :
wxString( "Undefined library pin." );
aList.emplace_back( _( "Body Style" ), msg );
}

View File

@ -1155,7 +1155,7 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter, const SCH_PLOT_OPTS& aPlotOpts ) const
return a->Type() > b->Type();
} );
int defaultPenWidth = aPlotter->RenderSettings()->GetDefaultPenWidth();
auto* renderSettings = static_cast<const SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
constexpr bool background = true;
// Bitmaps are drawn first to ensure they are in the background
@ -1163,21 +1163,21 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter, const SCH_PLOT_OPTS& aPlotOpts ) const
// the bitmap PS command clears the screen
for( SCH_ITEM* item : bitmaps )
{
aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) );
aPlotter->SetCurrentLineWidth( item->GetEffectivePenWidth( renderSettings ) );
item->Plot( aPlotter, background, aPlotOpts, 0, 0, { 0, 0 }, false );
}
// Plot the background items
for( SCH_ITEM* item : other )
{
aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) );
aPlotter->SetCurrentLineWidth( item->GetEffectivePenWidth( renderSettings ) );
item->Plot( aPlotter, background, aPlotOpts, 0, 0, { 0, 0 }, false );
}
// Plot the foreground items
for( SCH_ITEM* item : other )
{
aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) );
aPlotter->SetCurrentLineWidth( item->GetEffectivePenWidth( renderSettings ) );
item->Plot( aPlotter, !background, aPlotOpts, 0, 0, { 0, 0 }, false );
}
@ -1185,7 +1185,7 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter, const SCH_PLOT_OPTS& aPlotOpts ) const
// and symbols to ensure that they are always visible
for( const SCH_SYMBOL* sym :symbols )
{
aPlotter->SetCurrentLineWidth( std::max( sym->GetPenWidth(), defaultPenWidth ) );
aPlotter->SetCurrentLineWidth( sym->GetEffectivePenWidth( renderSettings ) );
for( SCH_FIELD field : sym->GetFields() )
{
@ -1202,7 +1202,7 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter, const SCH_PLOT_OPTS& aPlotOpts ) const
for( SCH_ITEM* item : junctions )
{
aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) );
aPlotter->SetCurrentLineWidth( item->GetEffectivePenWidth( renderSettings ) );
item->Plot( aPlotter, !background, aPlotOpts, 0, 0, { 0, 0 }, false );
}
}

View File

@ -114,10 +114,7 @@ void SCH_SHAPE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
{
int pen_size = GetPenWidth();
if( pen_size > 0 )
pen_size = std::max( pen_size, aPlotter->RenderSettings()->GetMinPenWidth() );
int pen_size = GetEffectivePenWidth( getRenderSettings( aPlotter ) );
static std::vector<VECTOR2I> cornerList;
@ -296,7 +293,7 @@ void SCH_SHAPE::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUnit
void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed )
{
int penWidth = GetPenWidth();
int penWidth = GetEffectivePenWidth( aSettings );
wxDC* DC = aSettings->GetPrintDC();
COLOR4D color = GetStroke().GetColor();
@ -365,10 +362,6 @@ void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBod
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
}
}
else
{
penWidth = std::max( penWidth, aSettings->GetMinPenWidth() );
}
if( penWidth > 0 )
{

View File

@ -80,11 +80,11 @@ public:
VECTOR2I GetCenter() const { return getCenter(); }
void BeginEdit( const VECTOR2I& aStartPoint ) { beginEdit( aStartPoint ); }
bool ContinueEdit( const VECTOR2I& aPosition ) { return continueEdit( aPosition ); }
void CalcEdit( const VECTOR2I& aPosition ) { calcEdit( aPosition ); }
void EndEdit() { endEdit(); }
void SetEditState( int aState ) { setEditState( aState ); }
void BeginEdit( const VECTOR2I& aStartPoint ) override { beginEdit( aStartPoint ); }
bool ContinueEdit( const VECTOR2I& aPosition ) override { return continueEdit( aPosition ); }
void CalcEdit( const VECTOR2I& aPosition ) override { calcEdit( aPosition ); }
void EndEdit( bool aClosed = false ) override { endEdit(); }
void SetEditState( int aState ) { setEditState( aState ); }
void Move( const VECTOR2I& aOffset ) override;

View File

@ -1166,7 +1166,7 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS&
{
aPlotter->SetColor( borderColor );
int penWidth = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetMinPenWidth() );
int penWidth = GetEffectivePenWidth( getRenderSettings( aPlotter ) );
aPlotter->Rect( m_pos, m_pos + m_size, FILL_T::NO_FILL, penWidth );
}
@ -1199,7 +1199,7 @@ void SCH_SHEET::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBod
{
wxDC* DC = aSettings->GetPrintDC();
VECTOR2I pos = m_pos + aOffset;
int lineWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
int lineWidth = GetEffectivePenWidth( aSettings );
COLOR4D border = GetBorderColor();
COLOR4D background = GetBackgroundColor();

View File

@ -83,7 +83,7 @@ static LIB_SYMBOL* dummy()
LIB_SHAPE* square = new LIB_SHAPE( symbol, SHAPE_T::RECTANGLE );
square->MoveTo( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) );
square->SetPosition( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) );
square->SetEnd( VECTOR2I( schIUScale.MilsToIU( 200 ), schIUScale.MilsToIU( -200 ) ) );
LIB_TEXT* text = new LIB_TEXT( symbol );
@ -207,7 +207,7 @@ void SCH_SYMBOL::Init( const VECTOR2I& pos )
m_layer = LAYER_DEVICE;
m_pos = pos;
m_unit = 1; // In multi unit chip - which unit to draw.
m_bodyStyle = LIB_ITEM::BODY_STYLE::BASE; // De Morgan Handling
m_bodyStyle = BODY_STYLE::BASE; // De Morgan Handling
// The rotation/mirror transformation matrix. pos normal
m_transform = TRANSFORM();
@ -516,11 +516,11 @@ void SCH_SYMBOL::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBo
if( m_part )
{
LIB_PINS libPins;
std::vector<LIB_PIN*> libPins;
m_part->GetPins( libPins, m_unit, m_bodyStyle );
LIB_SYMBOL tempSymbol( *m_part );
LIB_PINS tempPins;
std::vector<LIB_PIN*> tempPins;
tempSymbol.GetPins( tempPins, m_unit, m_bodyStyle );
// Copy the pin info from the symbol to the temp pins
@ -534,7 +534,7 @@ void SCH_SYMBOL::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBo
tempPin->SetShape( symbolPin->GetShape() );
}
for( LIB_ITEM& item : tempSymbol.GetDrawItems() )
for( SCH_ITEM& item : tempSymbol.GetDrawItems() )
{
if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( &item ) )
{
@ -2215,7 +2215,7 @@ std::vector<VECTOR2I> SCH_SYMBOL::GetConnectionPoints() const
}
LIB_ITEM* SCH_SYMBOL::GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType )
SCH_ITEM* SCH_SYMBOL::GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType )
{
if( m_part )
{
@ -2463,12 +2463,12 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS&
if( m_part )
{
LIB_PINS libPins;
std::vector<LIB_PIN*> libPins;
m_part->GetPins( libPins, GetUnit(), GetBodyStyle() );
// Copy the source so we can re-orient and translate it.
LIB_SYMBOL tempSymbol( *m_part );
LIB_PINS tempPins;
std::vector<LIB_PIN*> tempPins;
tempSymbol.GetPins( tempPins, GetUnit(), GetBodyStyle() );
// Copy the pin info from the symbol to the temp pins
@ -2485,7 +2485,7 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS&
tempPin->SetFlags( IS_DANGLING );
}
for( LIB_ITEM& item : tempSymbol.GetDrawItems() )
for( SCH_ITEM& item : tempSymbol.GetDrawItems() )
{
if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( &item ) )
{
@ -2575,12 +2575,12 @@ void SCH_SYMBOL::PlotPins( PLOTTER* aPlotter ) const
{
if( m_part )
{
LIB_PINS libPins;
std::vector<LIB_PIN*> libPins;
m_part->GetPins( libPins, GetUnit(), GetBodyStyle() );
// Copy the source to stay const
LIB_SYMBOL tempSymbol( *m_part );
LIB_PINS tempPins;
std::vector<LIB_PIN*> tempPins;
tempSymbol.GetPins( tempPins, GetUnit(), GetBodyStyle() );
SCH_PLOT_OPTS plotOpts;

View File

@ -55,7 +55,6 @@
struct PICKED_SYMBOL;
class KIID_PATH;
class SCH_SCREEN;
class LIB_ITEM;
class LIB_PIN;
class LIB_SYMBOL;
class NETLIST_OBJECT_LIST;
@ -762,7 +761,7 @@ public:
* @param aType is the type of symbol library object to find or any if set to TYPE_NOT_INIT.
* @return is the symbol library object if found otherwise NULL.
*/
LIB_ITEM* GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType = TYPE_NOT_INIT );
SCH_ITEM* GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType = TYPE_NOT_INIT );
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;

View File

@ -418,18 +418,16 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS
return;
}
SCH_SHEET_PATH* sheet = &Schematic()->CurrentSheet();
RENDER_SETTINGS* settings = aPlotter->RenderSettings();
int penWidth = GetPenWidth();
COLOR4D color = GetStroke().GetColor();
LINE_STYLE lineStyle = GetStroke().GetLineStyle();
SCH_SHEET_PATH* sheet = &Schematic()->CurrentSheet();
SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
int penWidth = GetEffectivePenWidth( renderSettings );
COLOR4D color = GetStroke().GetColor();
LINE_STYLE lineStyle = GetStroke().GetLineStyle();
if( penWidth > 0 )
{
penWidth = std::max( penWidth, settings->GetMinPenWidth() );
if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
color = settings->GetLayerColor( m_layer );
color = renderSettings->GetLayerColor( m_layer );
if( lineStyle == LINE_STYLE::DEFAULT )
lineStyle = LINE_STYLE::SOLID;
@ -443,15 +441,15 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS
KIFONT::FONT* font = GetFont();
if( !font )
font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), IsBold(), IsItalic() );
font = KIFONT::FONT::GetFont( renderSettings->GetDefaultFont(), IsBold(), IsItalic() );
color = GetTextColor();
if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
color = settings->GetLayerColor( m_layer );
color = renderSettings->GetLayerColor( m_layer );
penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
penWidth = std::max( penWidth, settings->GetMinPenWidth() );
penWidth = GetEffectiveTextPenWidth( renderSettings->GetDefaultPenWidth() );
penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() );
aPlotter->SetCurrentLineWidth( penWidth );
std::vector<VECTOR2I> positions;

View File

@ -143,7 +143,7 @@ void SCH_VIEW::DisplaySymbol( LIB_SYMBOL* aSymbol )
return;
// Draw the fields.
for( LIB_ITEM& item : aSymbol->GetDrawItems() )
for( SCH_ITEM& item : aSymbol->GetDrawItems() )
{
if( item.Type() == LIB_FIELD_T )
{
@ -168,7 +168,7 @@ void SCH_VIEW::DisplaySymbol( LIB_SYMBOL* aSymbol )
}
}
for( LIB_ITEM& item : drawnSymbol->GetDrawItems() )
for( SCH_ITEM& item : drawnSymbol->GetDrawItems() )
{
// Fields already drawn above. (Besides, we don't want to show parent symbol fields as
// users may be confused by shown fields that can not be edited.)

View File

@ -33,6 +33,7 @@
#include <reporter.h>
#include <sch_field.h>
#include <lib_field.h>
#include <lib_pin.h>
// Must be included after sch_field.h (exactly eda_shape.h) to avoid a colliding
// declaration with a window header (under msys2)

View File

@ -70,7 +70,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
aMessages.push_back( msg );
}
LIB_PINS pinList;
std::vector<LIB_PIN*> pinList;
aSymbol->GetPins( pinList );
// Test for duplicates:
@ -126,7 +126,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
pin->GetName(),
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
}
else
{
@ -143,7 +143,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
aSymbol->GetUnitReference( next->GetUnit() ),
aSymbol->GetUnitReference( pin->GetUnit() ),
LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
}
}
else
@ -250,7 +250,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
pinName,
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
}
else
{
@ -261,7 +261,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
'A' + pin->GetUnit() - 1,
LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
}
}
else
@ -308,7 +308,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
pinName,
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
}
else
{
@ -319,7 +319,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
'A' + pin->GetUnit() - 1,
LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
}
}
else
@ -361,7 +361,7 @@ void CheckLibSymbolGraphics( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessag
wxString msg;
for( const LIB_ITEM& item : aSymbol->GetDrawItems() )
for( const SCH_ITEM& item : aSymbol->GetDrawItems() )
{
if( item.Type() != LIB_SHAPE_T )
continue;

View File

@ -534,13 +534,13 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
auto demorganStandardCond =
[this]( const SELECTION& )
{
return m_bodyStyle == LIB_ITEM::BODY_STYLE::BASE;
return m_bodyStyle == BODY_STYLE::BASE;
};
auto demorganAlternateCond =
[this]( const SELECTION& )
{
return m_bodyStyle == LIB_ITEM::BODY_STYLE::DEMORGAN;
return m_bodyStyle == BODY_STYLE::DEMORGAN;
};
auto multiUnitModeCond =
@ -1345,7 +1345,7 @@ void SYMBOL_EDIT_FRAME::HardRedraw()
EE_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
EE_SELECTION& selection = selectionTool->GetSelection();
for( LIB_ITEM& item : m_symbol->GetDrawItems() )
for( SCH_ITEM& item : m_symbol->GetDrawItems() )
{
if( !alg::contains( selection, &item ) )
item.ClearSelected();
@ -1378,11 +1378,11 @@ const BOX2I SYMBOL_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) con
}
void SYMBOL_EDIT_FRAME::FocusOnItem( LIB_ITEM* aItem )
void SYMBOL_EDIT_FRAME::FocusOnItem( SCH_ITEM* aItem )
{
static KIID lastBrightenedItemID( niluuid );
LIB_ITEM* lastItem = nullptr;
SCH_ITEM* lastItem = nullptr;
if( m_symbol )
{

View File

@ -30,7 +30,6 @@
#include <sch_base_frame.h>
#include <sch_screen.h>
#include <lib_item.h>
#include <ee_collectors.h>
#include <optional>
@ -389,7 +388,7 @@ public:
void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
void FocusOnItem( LIB_ITEM* aItem );
void FocusOnItem( SCH_ITEM* aItem );
/**
* Load a symbol from the schematic to edit in place.

View File

@ -1277,9 +1277,9 @@ void SYMBOL_EDIT_FRAME::UpdateSymbolMsgPanelInfo()
AppendMsgPanel( _( "Unit" ), msg, 8 );
if( m_bodyStyle == LIB_ITEM::BODY_STYLE::DEMORGAN )
if( m_bodyStyle == BODY_STYLE::DEMORGAN )
msg = _( "Alternate" );
else if( m_bodyStyle == LIB_ITEM::BODY_STYLE::BASE )
else if( m_bodyStyle == BODY_STYLE::BASE )
msg = _( "Standard" );
else
msg = wxT( "?" );

View File

@ -377,13 +377,13 @@ void SYMBOL_VIEWER_FRAME::setupUIConditions()
auto demorganStandardCond =
[]( const SELECTION& )
{
return m_bodyStyle == LIB_ITEM::BODY_STYLE::BASE;
return m_bodyStyle == BODY_STYLE::BASE;
};
auto demorganAlternateCond =
[]( const SELECTION& )
{
return m_bodyStyle == LIB_ITEM::BODY_STYLE::DEMORGAN;
return m_bodyStyle == BODY_STYLE::DEMORGAN;
};
auto haveDatasheetCond =
@ -410,7 +410,7 @@ void SYMBOL_VIEWER_FRAME::setupUIConditions()
void SYMBOL_VIEWER_FRAME::SetUnitAndBodyStyle( int aUnit, int aBodyStyle )
{
m_unit = aUnit > 0 ? aUnit : 1;
m_bodyStyle = aBodyStyle > 0 ? aBodyStyle : LIB_ITEM::BODY_STYLE::BASE;
m_bodyStyle = aBodyStyle > 0 ? aBodyStyle : BODY_STYLE::BASE;
m_selection_changed = false;
updatePreviewSymbol();
@ -640,7 +640,7 @@ bool SYMBOL_VIEWER_FRAME::ReCreateLibList()
? m_libList->GetBaseString( 0 ) : wxString( wxT( "" ) ) );
m_currentSymbol.SetLibItemName( wxEmptyString );
m_unit = 1;
m_bodyStyle = LIB_ITEM::BODY_STYLE::BASE;
m_bodyStyle = BODY_STYLE::BASE;
}
bool cmp_changed = ReCreateSymbolList();
@ -715,7 +715,7 @@ bool SYMBOL_VIEWER_FRAME::ReCreateSymbolList()
if( m_symbolList->IsEmpty() )
{
SetSelectedSymbol( wxEmptyString );
m_bodyStyle = LIB_ITEM::BODY_STYLE::BASE;
m_bodyStyle = BODY_STYLE::BASE;
m_unit = 1;
return true;
}
@ -727,7 +727,7 @@ bool SYMBOL_VIEWER_FRAME::ReCreateSymbolList()
{
// Select the first library entry when the previous entry name does not exist in
// the current library.
m_bodyStyle = LIB_ITEM::BODY_STYLE::BASE;
m_bodyStyle = BODY_STYLE::BASE;
m_unit = 1;
index = -1;
changed = true;
@ -827,7 +827,7 @@ void SYMBOL_VIEWER_FRAME::SetSelectedSymbol( const wxString& aSymbolName )
if( m_selection_changed )
{
m_unit = 1;
m_bodyStyle = LIB_ITEM::BODY_STYLE::BASE;
m_bodyStyle = BODY_STYLE::BASE;
m_selection_changed = false;
}

View File

@ -32,7 +32,6 @@
#include <ee_selection.h>
class SCH_ITEM;
class LIB_ITEM;
class EE_GRID_HELPER : public GRID_HELPER

View File

@ -430,12 +430,12 @@ void EE_INSPECTION_TOOL::DiffSymbol( SCH_SYMBOL* symbol )
field.GetName( false ) ) );
fields.back().CopyText( field );
fields.back().SetAttributes( field );
fields.back().Offset( -symbol->GetPosition() );
fields.back().Move( -symbol->GetPosition() );
}
flattenedSchSymbol->SetFields( fields );
if( flattenedSchSymbol->Compare( *flattenedLibSymbol, LIB_ITEM::COMPARE_FLAGS::ERC,
if( flattenedSchSymbol->Compare( *flattenedLibSymbol, SCH_ITEM::COMPARE_FLAGS::ERC,
r ) == 0 )
{
r->Report( _( "No relevant differences detected." ) );

View File

@ -32,7 +32,6 @@
#include <ee_selection_tool.h>
#include <eeschema_id.h>
#include <symbol_edit_frame.h>
#include <lib_item.h>
#include <symbol_viewer_frame.h>
#include <math/util.h>
#include <geometry/shape_rect.h>
@ -1686,12 +1685,7 @@ void EE_SELECTION_TOOL::updateReferencePoint()
VECTOR2I refP( 0, 0 );
if( m_selection.Size() > 0 )
{
if( m_isSymbolEditor )
refP = static_cast<LIB_ITEM*>( m_selection.GetTopLeftItem() )->GetPosition();
else
refP = static_cast<SCH_ITEM*>( m_selection.GetTopLeftItem() )->GetPosition();
}
refP = static_cast<SCH_ITEM*>( m_selection.GetTopLeftItem() )->GetPosition();
m_selection.SetReferencePoint( refP );
}
@ -2405,7 +2399,7 @@ void EE_SELECTION_TOOL::RebuildSelection()
{
LIB_SYMBOL* start = static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->GetCurSymbol();
for( LIB_ITEM& item : start->GetDrawItems() )
for( SCH_ITEM& item : start->GetDrawItems() )
{
if( item.IsSelected() )
select( &item );
@ -2495,12 +2489,12 @@ bool EE_SELECTION_TOOL::Selectable( const EDA_ITEM* aItem, const VECTOR2I* aPos,
case LIB_PIN_T:
if( symEditFrame )
{
const LIB_ITEM* lib_item = static_cast<const LIB_ITEM*>( aItem );
const SCH_ITEM* sch_item = static_cast<const SCH_ITEM*>( aItem );
if( lib_item->GetUnit() && lib_item->GetUnit() != symEditFrame->GetUnit() )
if( sch_item->GetUnit() && sch_item->GetUnit() != symEditFrame->GetUnit() )
return false;
if( lib_item->GetBodyStyle() && lib_item->GetBodyStyle() != symEditFrame->GetBodyStyle() )
if( sch_item->GetBodyStyle() && sch_item->GetBodyStyle() != symEditFrame->GetBodyStyle() )
return false;
}

View File

@ -1712,13 +1712,13 @@ int SCH_EDIT_TOOL::ChangeBodyStyle( const TOOL_EVENT& aEvent )
SCH_SYMBOL* symbol = (SCH_SYMBOL*) selection.Front();
if( aEvent.IsAction( &EE_ACTIONS::showDeMorganStandard )
&& symbol->GetBodyStyle() == LIB_ITEM::BODY_STYLE::BASE )
&& symbol->GetBodyStyle() == BODY_STYLE::BASE )
{
return 0;
}
if( aEvent.IsAction( &EE_ACTIONS::showDeMorganAlternate )
&& symbol->GetBodyStyle() == LIB_ITEM::BODY_STYLE::DEMORGAN )
&& symbol->GetBodyStyle() == BODY_STYLE::DEMORGAN )
{
return 0;
}

View File

@ -370,7 +370,7 @@ int SCH_EDITOR_CONTROL::ExportSymbolsToLibrary( const TOOL_EVENT& aEvent )
if( libSymbols.count( id ) )
{
wxASSERT_MSG( libSymbols[id]->Compare( *libSymbol, LIB_ITEM::COMPARE_FLAGS::ERC ) == 0,
wxASSERT_MSG( libSymbols[id]->Compare( *libSymbol, SCH_ITEM::COMPARE_FLAGS::ERC ) == 0,
"Two symbols have the same LIB_ID but are different!" );
}
else

View File

@ -483,8 +483,8 @@ int SYMBOL_EDITOR_CONTROL::RenameSymbol( const TOOL_EVENT& aEvent )
int SYMBOL_EDITOR_CONTROL::OnDeMorgan( const TOOL_EVENT& aEvent )
{
int convert = aEvent.IsAction( &EE_ACTIONS::showDeMorganStandard ) ?
LIB_ITEM::BODY_STYLE::BASE : LIB_ITEM::BODY_STYLE::DEMORGAN;
int bodyStyle = aEvent.IsAction( &EE_ACTIONS::showDeMorganStandard ) ? BODY_STYLE::BASE
: BODY_STYLE::DEMORGAN;
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
{
@ -492,7 +492,7 @@ int SYMBOL_EDITOR_CONTROL::OnDeMorgan( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection );
SYMBOL_EDIT_FRAME* symbolEditor = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
symbolEditor->SetBodyStyle( convert );
symbolEditor->SetBodyStyle( bodyStyle );
m_toolMgr->ResetTools( TOOL_BASE::MODEL_RELOAD );
symbolEditor->RebuildView();
@ -500,7 +500,7 @@ int SYMBOL_EDITOR_CONTROL::OnDeMorgan( const TOOL_EVENT& aEvent )
else if( m_frame->IsType( FRAME_SCH_VIEWER ) )
{
SYMBOL_VIEWER_FRAME* symbolViewer = static_cast<SYMBOL_VIEWER_FRAME*>( m_frame );
symbolViewer->SetUnitAndBodyStyle( symbolViewer->GetUnit(), convert );
symbolViewer->SetUnitAndBodyStyle( symbolViewer->GetUnit(), bodyStyle );
}
return 0;

View File

@ -70,7 +70,7 @@ bool SYMBOL_EDITOR_DRAWING_TOOLS::Init()
auto isDrawingCondition =
[] ( const SELECTION& aSel )
{
LIB_ITEM* item = (LIB_ITEM*) aSel.Front();
SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aSel.Front() );
return item && item->IsNew();
};
@ -95,7 +95,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
EE_GRID_HELPER grid( m_toolMgr );
VECTOR2I cursorPos;
bool ignorePrimePosition = false;
LIB_ITEM* item = nullptr;
SCH_ITEM* item = nullptr;
bool isText = aEvent.IsAction( &EE_ACTIONS::placeSymbolText );
COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
@ -685,14 +685,14 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::ImportGraphics( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( ACTIONS::cancelInteractive );
KIGFX::VIEW_CONTROLS* controls = getViewControls();
std::vector<LIB_ITEM*> newItems; // all new items, including group
std::vector<LIB_ITEM*> selectedItems; // the group, or newItems if no group
std::vector<SCH_ITEM*> newItems; // all new items, including group
std::vector<SCH_ITEM*> selectedItems; // the group, or newItems if no group
EE_SELECTION preview;
SCH_COMMIT commit( m_toolMgr );
for( std::unique_ptr<EDA_ITEM>& ptr : list )
{
LIB_ITEM* item = dynamic_cast<LIB_ITEM*>( ptr.get() );
SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( ptr.get() );
wxCHECK2( item, continue );
newItems.push_back( item );
@ -707,7 +707,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::ImportGraphics( const TOOL_EVENT& aEvent )
commit.Modify( symbol, m_frame->GetScreen() );
// Place the imported drawings
for( LIB_ITEM* item : newItems )
for( SCH_ITEM* item : newItems )
{
symbol->AddDrawItem( item );
item->ClearEditFlags();
@ -749,8 +749,8 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::ImportGraphics( const TOOL_EVENT& aEvent )
VECTOR2I delta = cursorPos;
VECTOR2I currentOffset;
for( LIB_ITEM* item : selectedItems )
item->Offset( delta );
for( SCH_ITEM* item : selectedItems )
item->Move( delta );
currentOffset += delta;
@ -771,7 +771,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::ImportGraphics( const TOOL_EVENT& aEvent )
{
m_toolMgr->RunAction( EE_ACTIONS::clearSelection );
for( LIB_ITEM* item : newItems )
for( SCH_ITEM* item : newItems )
delete item;
break;
@ -780,8 +780,8 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::ImportGraphics( const TOOL_EVENT& aEvent )
{
delta = VECTOR2I( cursorPos.x, -cursorPos.y ) - currentOffset;
for( LIB_ITEM* item : selectedItems )
item->Offset( delta );
for( SCH_ITEM* item : selectedItems )
item->Move( delta );
currentOffset += delta;
@ -796,7 +796,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::ImportGraphics( const TOOL_EVENT& aEvent )
commit.Modify( symbol, m_frame->GetScreen() );
// Place the imported drawings
for( LIB_ITEM* item : newItems )
for( SCH_ITEM* item : newItems )
{
symbol->AddDrawItem( item );
item->ClearEditFlags();

View File

@ -158,7 +158,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
VECTOR2I rotPoint;
bool ccw = ( aEvent.Matches( EE_ACTIONS::rotateCCW.MakeEvent() ) );
LIB_ITEM* item = static_cast<LIB_ITEM*>( selection.Front() );
SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
SCH_COMMIT localCommit( m_toolMgr );
SCH_COMMIT* commit = dynamic_cast<SCH_COMMIT*>( aEvent.Commit() );
@ -175,7 +175,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
{
item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
item->Rotate( rotPoint, ccw );
m_frame->UpdateItem( item, false, true );
}
@ -207,7 +207,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
VECTOR2I mirrorPoint;
bool xAxis = ( aEvent.Matches( EE_ACTIONS::mirrorV.MakeEvent() ) );
LIB_ITEM* item = static_cast<LIB_ITEM*>( selection.Front() );
SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
if( !item->IsMoving() )
saveCopyInUndoList( m_frame->GetCurSymbol(), UNDO_REDO::LIBEDIT );
@ -248,7 +248,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
{
item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
if( xAxis )
item->MirrorVertically( mirrorPoint.y );
@ -299,7 +299,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
commit.Modify( symbol, m_frame->GetScreen() );
std::set<LIB_ITEM*> toDelete;
std::set<SCH_ITEM*> toDelete;
for( EDA_ITEM* item : items )
{
@ -347,11 +347,11 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
}
else
{
toDelete.insert( (LIB_ITEM*) item );
toDelete.insert( (SCH_ITEM*) item );
}
}
for( LIB_ITEM* item : toDelete )
for( SCH_ITEM* item : toDelete )
symbol->RemoveDrawItem( item );
commit.Push( _( "Delete" ) );
@ -449,7 +449,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
}
else if( selection.Size() == 1 )
{
LIB_ITEM* item = (LIB_ITEM*) selection.Front();
SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
// Save copy for undo if not in edit (edit command already handle the save copy)
if( item->GetEditFlags() == 0 )
@ -513,7 +513,7 @@ void SYMBOL_EDITOR_EDIT_TOOL::editShapeProperties( LIB_SHAPE* aShape )
}
void SYMBOL_EDITOR_EDIT_TOOL::editTextProperties( LIB_ITEM* aItem )
void SYMBOL_EDITOR_EDIT_TOOL::editTextProperties( SCH_ITEM* aItem )
{
if ( aItem->Type() != LIB_TEXT_T )
return;
@ -529,7 +529,7 @@ void SYMBOL_EDITOR_EDIT_TOOL::editTextProperties( LIB_ITEM* aItem )
}
void SYMBOL_EDITOR_EDIT_TOOL::editTextBoxProperties( LIB_ITEM* aItem )
void SYMBOL_EDITOR_EDIT_TOOL::editTextBoxProperties( SCH_ITEM* aItem )
{
if ( aItem->Type() != LIB_TEXTBOX_T )
return;
@ -765,7 +765,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
if( !symbol || !selection.GetSize() )
return 0;
for( LIB_ITEM& item : symbol->GetDrawItems() )
for( SCH_ITEM& item : symbol->GetDrawItems() )
{
if( item.Type() == LIB_FIELD_T )
continue;
@ -783,7 +783,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
delete partCopy;
for( LIB_ITEM& item : symbol->GetDrawItems() )
for( SCH_ITEM& item : symbol->GetDrawItems() )
item.ClearFlags( STRUCT_DELETED );
if( m_toolMgr->SaveClipboard( formatter.GetString() ) )
@ -826,15 +826,15 @@ int SYMBOL_EDITOR_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent )
commit.Modify( symbol );
m_selectionTool->ClearSelection();
for( LIB_ITEM& item : symbol->GetDrawItems() )
for( SCH_ITEM& item : symbol->GetDrawItems() )
item.ClearFlags( IS_NEW | IS_PASTED | SELECTED );
for( LIB_ITEM& item : newPart->GetDrawItems() )
for( SCH_ITEM& item : newPart->GetDrawItems() )
{
if( item.Type() == LIB_FIELD_T )
continue;
LIB_ITEM* newItem = (LIB_ITEM*) item.Duplicate();
SCH_ITEM* newItem = item.Duplicate();
newItem->SetParent( symbol );
newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
@ -880,8 +880,8 @@ int SYMBOL_EDITOR_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
for( unsigned ii = 0; ii < selection.GetSize(); ++ii )
{
LIB_ITEM* oldItem = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
LIB_ITEM* newItem = static_cast<LIB_ITEM*>( oldItem->Duplicate() );
SCH_ITEM* oldItem = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
SCH_ITEM* newItem = oldItem->Duplicate();
if( newItem->Type() == LIB_PIN_T )
{

View File

@ -66,8 +66,8 @@ public:
private:
void editShapeProperties( LIB_SHAPE* aShape );
void editTextProperties( LIB_ITEM* aItem );
void editTextBoxProperties( LIB_ITEM* aItem );
void editTextProperties( SCH_ITEM* aItem );
void editTextBoxProperties( SCH_ITEM* aItem );
void editFieldProperties( LIB_FIELD* aField );
void editSymbolProperties();
void handlePinDuplication(LIB_PIN* aOldPin, LIB_PIN* aNewPin, int &aSymbolLastPinNumber );

View File

@ -170,7 +170,7 @@ bool SYMBOL_EDITOR_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COM
{
if( !m_moveInProgress ) // Prepare to start moving/dragging
{
LIB_ITEM* lib_item = static_cast<LIB_ITEM*>( selection.Front() );
SCH_ITEM* lib_item = static_cast<SCH_ITEM*>( selection.Front() );
// Pick up any synchronized pins
//
@ -183,7 +183,7 @@ bool SYMBOL_EDITOR_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COM
for( EDA_ITEM* sel_item : selection )
{
lib_item = static_cast<LIB_ITEM*>( sel_item );
lib_item = static_cast<SCH_ITEM*>( sel_item );
if( lib_item->Type() == LIB_PIN_T )
{
@ -387,7 +387,7 @@ int SYMBOL_EDITOR_MOVE_TOOL::AlignElements( const TOOL_EVENT& aEvent )
[&]( EDA_ITEM* item, const VECTOR2I& delta )
{
commit.Modify( item, m_frame->GetScreen() );
static_cast<LIB_ITEM*>( item )->Offset( mapCoords( delta ) );
static_cast<SCH_ITEM*>( item )->Move( mapCoords( delta ) );
updateItem( item, true );
};
@ -513,7 +513,7 @@ int SYMBOL_EDITOR_MOVE_TOOL::AlignElements( const TOOL_EVENT& aEvent )
void SYMBOL_EDITOR_MOVE_TOOL::moveItem( EDA_ITEM* aItem, const VECTOR2I& aDelta )
{
static_cast<LIB_ITEM*>( aItem )->Offset( mapCoords( aDelta ) );
static_cast<SCH_ITEM*>( aItem )->Move( mapCoords( aDelta ) );
aItem->SetFlags( IS_MOVING );
}

View File

@ -131,7 +131,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin )
if( !aPin->IsNew() && m_frame->SynchronizePins() && parentSymbol )
{
LIB_PINS pinList;
std::vector<LIB_PIN*> pinList;
parentSymbol->GetPins( pinList );
// a pin can have a unit id = 0 (common to all units) to unit count
@ -270,7 +270,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::PlacePin( LIB_PIN* aPin )
if( ( pin->GetEditFlags() & IS_LINKED ) == 0 )
continue;
pin->MoveTo( aPin->GetPosition() );
pin->SetPosition( aPin->GetPosition() );
pin->ClearFlags();
}
@ -296,7 +296,7 @@ LIB_PIN* SYMBOL_EDITOR_PIN_TOOL::CreatePin( const VECTOR2I& aPosition, LIB_SYMBO
if( m_frame->SynchronizePins() )
pin->SetFlags( IS_LINKED );
pin->MoveTo( aPosition );
pin->SetPosition( aPosition );
pin->SetLength( GetLastPinLength() );
pin->SetOrientation( g_LastPinOrient );
pin->SetType( g_LastPinType );
@ -427,7 +427,7 @@ LIB_PIN* SYMBOL_EDITOR_PIN_TOOL::RepeatPin( const LIB_PIN* aSourcePin )
case PIN_ORIENTATION::PIN_RIGHT: step.y = schIUScale.MilsToIU(-settings->m_Repeat.pin_step); break;
}
pin->Offset( step );
pin->Move( step );
wxString nextName = pin->GetName();
IncrementLabelMember( nextName, settings->m_Repeat.label_delta );

View File

@ -604,9 +604,9 @@ void PANEL_SYMBOL_CHOOSER::populateFootprintSelector( LIB_ID const& aLibId )
if( symbol != nullptr )
{
LIB_PINS temp_pins;
LIB_FIELD* fp_field = symbol->GetFieldById( FOOTPRINT_FIELD );
wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" );
std::vector<LIB_PIN*> temp_pins;
LIB_FIELD* fp_field = symbol->GetFieldById( FOOTPRINT_FIELD );
wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" );
// All units, but only a single De Morgan variant.
if( symbol->HasAlternateBodyStyle() )

View File

@ -133,7 +133,7 @@ void SYMBOL_DIFF_WIDGET::onSlider( wxScrollEvent& aEvent )
m_previewItem->SetForcedTransparency( val );
view->Update( m_previewItem );
for( LIB_ITEM& child : m_previewItem->GetDrawItems() )
for( SCH_ITEM& child : m_previewItem->GetDrawItems() )
{
child.SetForcedTransparency( val );
view->Update( &child );
@ -152,7 +152,7 @@ void SYMBOL_DIFF_WIDGET::onSlider( wxScrollEvent& aEvent )
m_libraryItem->SetForcedTransparency( val );
view->Update( m_libraryItem );
for( LIB_ITEM& child : m_libraryItem->GetDrawItems() )
for( SCH_ITEM& child : m_libraryItem->GetDrawItems() )
{
child.SetForcedTransparency( val );
view->Update( &child );

View File

@ -137,7 +137,7 @@ public:
return m_flags & mask;
}
void ClearEditFlags()
virtual void ClearEditFlags()
{
ClearFlags( GetEditFlags() );
}
@ -149,7 +149,7 @@ public:
return m_flags & mask;
}
void ClearTempFlags()
virtual void ClearTempFlags()
{
ClearFlags( GetTempFlags() );
}
@ -450,7 +450,7 @@ public:
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
virtual void Show( int nestLevel, std::ostream& os ) const = 0;
virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); };
void ShowDummy( std::ostream& os ) const; ///< call this if you are a lazy developer

View File

@ -201,8 +201,9 @@ PROPERTY_BASE( const wxString& aName, PROPERTY_DISPLAY aDisplay = PT_DEFAULT,
m_display( aDisplay ),
m_coordType( aCoordType ),
m_hideFromPropertiesManager( false ),
m_hideFromRulesEditor( false ),
m_hideFromLibraryEditors( false ),
m_hideFromDesignEditors( false ),
m_hideFromRulesEditor( false ),
m_availFunc( [](INSPECTABLE*)->bool { return true; } ),
m_writeableFunc( [](INSPECTABLE*)->bool { return true; } ),
m_validator( NullValidator )
@ -316,6 +317,13 @@ PROPERTY_BASE( const wxString& aName, PROPERTY_DISPLAY aDisplay = PT_DEFAULT,
return *this;
}
bool IsHiddenFromDesignEditors() const { return m_hideFromDesignEditors; }
PROPERTY_BASE& SetIsHiddenFromDesignEditors( bool aIsHidden = true )
{
m_hideFromDesignEditors = aIsHidden;
return *this;
}
wxString Group() const { return m_group; }
PROPERTY_BASE& SetGroup( const wxString& aGroup ) { m_group = aGroup; return *this; }
@ -411,14 +419,12 @@ private:
/// The coordinate type controls how distances are mapped to the user coordinate system
ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType;
/// Some properties should not be shown in the Properties Manager GUI
bool m_hideFromPropertiesManager;
/// Some properties should not be shown in the Custom Rules editor autocomplete
bool m_hideFromRulesEditor;
/// This property should only be shown in the design editor, not the library editor
bool m_hideFromLibraryEditors;
bool m_hideFromPropertiesManager; // Do not show in Properties Manager
bool m_hideFromLibraryEditors; // Do not show in Properties Manager of symbol or
// footprint editors
bool m_hideFromDesignEditors; // Do not show in Properties Manager of schematic or
// board editors
bool m_hideFromRulesEditor; // Do not show in Custom Rules editor autocomplete
/// Optional group identifier
wxString m_group;

View File

@ -27,7 +27,6 @@
#include <eda_item.h>
#include <sch_item.h>
#include <lib_item.h>
#include <sch_marker.h>
#include <sch_junction.h>
@ -175,7 +174,6 @@ BOOST_AUTO_TEST_CASE( Move )
VECTOR2I originalPos = item->GetPosition();
SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( item.get() );
LIB_ITEM* libItem = dynamic_cast<LIB_ITEM*>( item.get() );
// Move to a point, then go back.
// This has to be an identity transformation.
@ -188,14 +186,6 @@ BOOST_AUTO_TEST_CASE( Move )
schItem->Move( -aRef );
}
if( libItem != nullptr )
{
libItem->MoveTo( libItem->GetPosition() + aRef );
BOOST_CHECK_EQUAL( libItem->GetPosition(), originalPos + aRef );
libItem->MoveTo( libItem->GetPosition() - aRef );
}
CompareItems( item.get(), aOriginalItem );
} );
}
@ -224,7 +214,6 @@ BOOST_AUTO_TEST_CASE( Rotate )
auto newItem = std::unique_ptr<EDA_ITEM>( item->Clone() );
SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( newItem.get() );
LIB_ITEM* libItem = dynamic_cast<LIB_ITEM*>( newItem.get() );
if( schItem != nullptr )
{
@ -236,14 +225,6 @@ BOOST_AUTO_TEST_CASE( Rotate )
schItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false );
}
if( libItem != nullptr )
{
libItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false );
libItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false );
libItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false );
libItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false );
}
CompareItems( newItem.get(), item.get() );
}
else
@ -255,7 +236,6 @@ BOOST_AUTO_TEST_CASE( Rotate )
auto item = std::unique_ptr<EDA_ITEM>( aOriginalItem->Clone() );
SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( item.get() );
LIB_ITEM* libItem = dynamic_cast<LIB_ITEM*>( item.get() );
if( schItem != nullptr )
{
@ -266,14 +246,6 @@ BOOST_AUTO_TEST_CASE( Rotate )
schItem->Rotate( aRef, false );
}
if( libItem != nullptr )
{
libItem->Rotate( aRef, false );
libItem->Rotate( aRef, false );
libItem->Rotate( aRef, false );
libItem->Rotate( aRef, false );
}
CompareItems( item.get(), aOriginalItem );
} );
}
@ -302,7 +274,6 @@ BOOST_AUTO_TEST_CASE( MirrorHorizontally )
auto item = std::unique_ptr<EDA_ITEM>( aOriginalItem->Clone() );
SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( item.get() );
LIB_ITEM* libItem = dynamic_cast<LIB_ITEM*>( item.get() );
// Two mirrorings are an identity
// (warning: only for text items having no autoplaced fields).
@ -313,12 +284,6 @@ BOOST_AUTO_TEST_CASE( MirrorHorizontally )
schItem->MirrorHorizontally( aRef.x );
}
if( libItem != nullptr )
{
libItem->MirrorHorizontally( aRef.x );
libItem->MirrorHorizontally( aRef.x );
}
CompareItems( item.get(), aOriginalItem );
} );
}
@ -346,7 +311,6 @@ BOOST_AUTO_TEST_CASE( MirrorVertically )
auto item = std::unique_ptr<EDA_ITEM>( aOriginalItem->Clone() );
SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( item.get() );
LIB_ITEM* libItem = dynamic_cast<LIB_ITEM*>( item.get() );
// Two mirrorings are an identity
// (warning only for text items having no autoplaced fields).
@ -358,12 +322,6 @@ BOOST_AUTO_TEST_CASE( MirrorVertically )
schItem->MirrorVertically( aRef.y );
}
if( libItem != nullptr )
{
libItem->MirrorVertically( aRef.y );
libItem->MirrorVertically( aRef.y );
}
CompareItems( item.get(), aOriginalItem );
} );
}

View File

@ -372,7 +372,7 @@ BOOST_AUTO_TEST_CASE( Compare )
BOOST_CHECK_EQUAL( m_part_no_data.Compare( m_part_no_data ), 0 );
// Test for identical LIB_SYMBOL.
BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart ), 0 );
BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ), 0 );
// Test name.
testPart.SetName( "tart_name" );
@ -411,22 +411,22 @@ BOOST_AUTO_TEST_CASE( Compare )
// Draw item list size comparison tests.
testPart.AddDrawItem( new LIB_SHAPE( &testPart, SHAPE_T::RECTANGLE ) );
m_part_no_data.AddDrawItem( new LIB_SHAPE( &m_part_no_data, SHAPE_T::RECTANGLE ) );
BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart ), 0 );
BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ), 0 );
m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[LIB_SHAPE_T].front() );
BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 );
testPart.RemoveDrawItem( &testPart.GetDrawItems()[LIB_SHAPE_T].front() );
m_part_no_data.AddDrawItem( new LIB_SHAPE( &m_part_no_data, SHAPE_T::RECTANGLE ) );
BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 );
m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[LIB_SHAPE_T].front() );
// Draw item list contents comparison tests.
testPart.AddDrawItem( new LIB_SHAPE( &testPart, SHAPE_T::RECTANGLE ) );
m_part_no_data.AddDrawItem( new LIB_SHAPE( &m_part_no_data, SHAPE_T::ARC ) );
BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 );
m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[LIB_SHAPE_T].front() );
testPart.RemoveDrawItem( &testPart.GetDrawItems()[LIB_SHAPE_T].front() );
m_part_no_data.AddDrawItem( new LIB_PIN( &m_part_no_data ) );
BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 );
m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[LIB_PIN_T].front() );
// Footprint filter array comparison tests.
@ -434,11 +434,11 @@ BOOST_AUTO_TEST_CASE( Compare )
BOOST_CHECK( m_part_no_data.GetFPFilters() == footPrintFilters );
footPrintFilters.Add( "b" );
testPart.SetFPFilters( footPrintFilters );
BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 );
m_part_no_data.SetFPFilters( footPrintFilters );
footPrintFilters.Clear();
testPart.SetFPFilters( footPrintFilters );
BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 );
footPrintFilters.Clear();
m_part_no_data.SetFPFilters( footPrintFilters );
testPart.SetFPFilters( footPrintFilters );
@ -446,70 +446,70 @@ BOOST_AUTO_TEST_CASE( Compare )
// Description string tests.
m_part_no_data.SetDescription( "b" );
testPart.SetDescription( "b" );
BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart ), 0 );
BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ), 0 );
m_part_no_data.SetDescription( "a" );
BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 );
m_part_no_data.SetDescription( "c" );
BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 );
m_part_no_data.SetDescription( wxEmptyString );
testPart.SetDescription( wxEmptyString );
// Key word string tests.
m_part_no_data.SetKeyWords( "b" );
testPart.SetKeyWords( "b" );
BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart ), 0 );
BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ), 0 );
m_part_no_data.SetKeyWords( "a" );
BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 );
m_part_no_data.SetKeyWords( "c" );
BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 );
m_part_no_data.SetKeyWords( wxEmptyString );
testPart.SetKeyWords( wxEmptyString );
// Pin name offset comparison tests.
testPart.SetPinNameOffset( testPart.GetPinNameOffset() + 1 );
BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 );
testPart.SetPinNameOffset( testPart.GetPinNameOffset() - 2 );
BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 );
testPart.SetPinNameOffset( testPart.GetPinNameOffset() + 1 );
// Units locked flag comparison tests.
testPart.LockUnits( true );
BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 );
testPart.LockUnits( false );
m_part_no_data.LockUnits( true );
BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 );
m_part_no_data.LockUnits( false );
// Include in BOM support tests.
testPart.SetExcludedFromBOM( true );
BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 );
testPart.SetExcludedFromBOM( false );
m_part_no_data.SetExcludedFromBOM( true );
BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 );
m_part_no_data.SetExcludedFromBOM( false );
// Include on board support tests.
testPart.SetExcludedFromBoard( true );
BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 );
testPart.SetExcludedFromBoard( false );
m_part_no_data.SetExcludedFromBoard( true );
BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 );
m_part_no_data.SetExcludedFromBoard( false );
// Show pin names flag comparison tests.
m_part_no_data.SetShowPinNames( false );
BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 );
m_part_no_data.SetShowPinNames( true );
testPart.SetShowPinNames( false );
BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 );
testPart.SetShowPinNames( true );
// Show pin numbers flag comparison tests.
m_part_no_data.SetShowPinNumbers( false );
BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 );
m_part_no_data.SetShowPinNumbers( true );
testPart.SetShowPinNumbers( false );
BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 );
testPart.SetShowPinNumbers( true );
// Time stamp comparison tests.