mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 08:41:41 +00:00
Push more functionality to SYMBOL.
(This will allow us to run the fields autoplacer on SYMBOLs, including LIB_SYMBOLs.) Fixes https://gitlab.com/kicad/code/kicad/-/issues/19247
This commit is contained in:
parent
0612270f1e
commit
7da8b42206
eeschema
autoplace_fields.cpp
dialogs
dialog_lib_edit_pin_table.cppdialog_lib_symbol_properties.cppdialog_sim_model.cppdialog_update_symbol_fields.cpp
lib_symbol.cpplib_symbol.hnetlist_exporters
sch_io
sch_pin.cppsch_pin.hsch_symbol.cppsch_symbol.hsim
symbol.hsymbol_editor
tools
ee_point_editor.cppsymbol_editor_drawing_tools.cppsymbol_editor_edit_tool.cppsymbol_editor_move_tool.cppsymbol_editor_pin_tool.cpp
widgets
qa/tests/eeschema
@ -53,7 +53,7 @@
|
||||
#include <boost/range/adaptor/reversed.hpp>
|
||||
|
||||
#include <sch_edit_frame.h>
|
||||
#include <sch_symbol.h>
|
||||
#include <symbol.h>
|
||||
#include <sch_line.h>
|
||||
#include <sch_pin.h>
|
||||
#include <kiface_base.h>
|
||||
@ -99,9 +99,10 @@ public:
|
||||
COLLISION collision;
|
||||
};
|
||||
|
||||
AUTOPLACER( SCH_SYMBOL* aSymbol, SCH_SCREEN* aScreen ) :
|
||||
AUTOPLACER( SYMBOL* aSymbol, SCH_SCREEN* aScreen ) :
|
||||
m_screen( aScreen ),
|
||||
m_symbol( aSymbol )
|
||||
m_symbol( aSymbol ),
|
||||
m_is_power_symbol( false )
|
||||
{
|
||||
m_symbol->GetFields( m_fields, /* aVisibleOnly */ true );
|
||||
|
||||
@ -120,7 +121,8 @@ public:
|
||||
m_symbol_bbox = m_symbol->GetBodyBoundingBox();
|
||||
m_fbox_size = computeFBoxSize( /* aDynamic */ true );
|
||||
|
||||
m_is_power_symbol = !m_symbol->IsInNetlist();
|
||||
if( SCH_SYMBOL* schSymbol = dynamic_cast<SCH_SYMBOL*>( m_symbol ) )
|
||||
m_is_power_symbol = !schSymbol->IsInNetlist();
|
||||
|
||||
if( aScreen )
|
||||
getPossibleCollisions( m_colliders );
|
||||
@ -708,7 +710,7 @@ protected:
|
||||
|
||||
private:
|
||||
SCH_SCREEN* m_screen;
|
||||
SCH_SYMBOL* m_symbol;
|
||||
SYMBOL* m_symbol;
|
||||
std::vector<SCH_FIELD*> m_fields;
|
||||
std::vector<SCH_ITEM*> m_colliders;
|
||||
BOX2I m_symbol_bbox;
|
||||
|
@ -880,7 +880,7 @@ DIALOG_LIB_EDIT_PIN_TABLE::~DIALOG_LIB_EDIT_PIN_TABLE()
|
||||
bool DIALOG_LIB_EDIT_PIN_TABLE::TransferDataToWindow()
|
||||
{
|
||||
// Make a copy of the pins for editing
|
||||
std::vector<SCH_PIN*> pins = m_symbol->GetAllLibPins();
|
||||
std::vector<SCH_PIN*> pins = m_symbol->GetPins();
|
||||
|
||||
for( SCH_PIN* pin : pins )
|
||||
m_pins.push_back( new SCH_PIN( *pin ) );
|
||||
@ -909,7 +909,7 @@ bool DIALOG_LIB_EDIT_PIN_TABLE::TransferDataFromWindow()
|
||||
return false;
|
||||
|
||||
// Delete the part's pins
|
||||
std::vector<SCH_PIN*> pins = m_symbol->GetAllLibPins();
|
||||
std::vector<SCH_PIN*> pins = m_symbol->GetPins();
|
||||
|
||||
for( SCH_PIN* pin : pins )
|
||||
m_symbol->RemoveDrawItem( pin );
|
||||
@ -1049,7 +1049,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnCellSelected( wxGridEvent& event )
|
||||
|
||||
if( pins.size() == 1 && m_editFrame->GetCurSymbol() )
|
||||
{
|
||||
for( SCH_PIN* candidate : m_editFrame->GetCurSymbol()->GetAllLibPins() )
|
||||
for( SCH_PIN* candidate : m_editFrame->GetCurSymbol()->GetPins() )
|
||||
{
|
||||
if( candidate->GetNumber() == pins.at( 0 )->GetNumber() )
|
||||
{
|
||||
|
@ -178,7 +178,7 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow()
|
||||
return false;
|
||||
|
||||
// Push a copy of each field into m_updateFields
|
||||
m_libEntry->GetFields( *m_fields );
|
||||
m_libEntry->CopyFields( *m_fields );
|
||||
|
||||
std::set<wxString> defined;
|
||||
|
||||
|
@ -80,7 +80,7 @@ DIALOG_SIM_MODEL<T>::DIALOG_SIM_MODEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame
|
||||
m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
|
||||
m_infoBar->AddCloseButton();
|
||||
|
||||
for( SCH_PIN* pin : aSymbol.GetAllLibPins() )
|
||||
for( SCH_PIN* pin : aSymbol.GetPins() )
|
||||
{
|
||||
// De Morgan conversions are equivalences, not additional items to simulate
|
||||
if( !pin->GetParentSymbol()->HasAlternateBodyStyle() || pin->GetBodyStyle() < 2 )
|
||||
|
@ -145,7 +145,7 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked( wxCommandEvent& aEvent )
|
||||
|
||||
std::vector<SCH_FIELD> fields;
|
||||
std::vector<SCH_FIELD> result;
|
||||
m_symbol->GetFields( fields );
|
||||
m_symbol->CopyFields( fields );
|
||||
|
||||
for( SCH_FIELD& field : fields )
|
||||
{
|
||||
|
@ -851,7 +851,7 @@ std::vector<SCH_PIN*> LIB_SYMBOL::GetPins( int aUnit, int aBodyStyle ) const
|
||||
}
|
||||
|
||||
|
||||
std::vector<SCH_PIN*> LIB_SYMBOL::GetAllLibPins() const
|
||||
std::vector<SCH_PIN*> LIB_SYMBOL::GetPins() const
|
||||
{
|
||||
return GetPins( 0, 0 );
|
||||
}
|
||||
@ -878,49 +878,46 @@ SCH_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
|
||||
{
|
||||
std::vector<SCH_PIN*> thisPinList = GetAllLibPins();
|
||||
|
||||
for( const SCH_PIN* eachThisPin : thisPinList )
|
||||
for( const SCH_PIN* pin : GetPins() )
|
||||
{
|
||||
wxASSERT( eachThisPin );
|
||||
std::vector<SCH_PIN*> otherPinList = aOtherPart.GetAllLibPins();
|
||||
wxASSERT( pin );
|
||||
bool foundMatch = false;
|
||||
|
||||
for( const SCH_PIN* eachOtherPin : otherPinList )
|
||||
for( const SCH_PIN* otherPin : aOtherPart.GetPins() )
|
||||
{
|
||||
wxASSERT( eachOtherPin );
|
||||
wxASSERT( otherPin );
|
||||
|
||||
// Same unit?
|
||||
if( eachThisPin->GetUnit() != eachOtherPin->GetUnit() )
|
||||
if( pin->GetUnit() != otherPin->GetUnit() )
|
||||
continue;
|
||||
|
||||
// Same body stype?
|
||||
if( eachThisPin->GetBodyStyle() != eachOtherPin->GetBodyStyle() )
|
||||
if( pin->GetBodyStyle() != otherPin->GetBodyStyle() )
|
||||
continue;
|
||||
|
||||
// Same position?
|
||||
if( eachThisPin->GetPosition() != eachOtherPin->GetPosition() )
|
||||
if( pin->GetPosition() != otherPin->GetPosition() )
|
||||
continue;
|
||||
|
||||
// Same number?
|
||||
if( aTestNums && ( eachThisPin->GetNumber() != eachOtherPin->GetNumber() ) )
|
||||
if( aTestNums && ( pin->GetNumber() != otherPin->GetNumber() ) )
|
||||
continue;
|
||||
|
||||
// Same name?
|
||||
if( aTestNames && ( eachThisPin->GetName() != eachOtherPin->GetName() ) )
|
||||
if( aTestNames && ( pin->GetName() != otherPin->GetName() ) )
|
||||
continue;
|
||||
|
||||
// Same electrical type?
|
||||
if( aTestType && ( eachThisPin->GetType() != eachOtherPin->GetType() ) )
|
||||
if( aTestType && ( pin->GetType() != otherPin->GetType() ) )
|
||||
continue;
|
||||
|
||||
// Same orientation?
|
||||
if( aTestOrientation
|
||||
&& ( eachThisPin->GetOrientation() != eachOtherPin->GetOrientation() ) )
|
||||
&& ( pin->GetOrientation() != otherPin->GetOrientation() ) )
|
||||
continue;
|
||||
|
||||
// Same length?
|
||||
if( aTestLength && ( eachThisPin->GetLength() != eachOtherPin->GetLength() ) )
|
||||
if( aTestLength && ( pin->GetLength() != otherPin->GetLength() ) )
|
||||
continue;
|
||||
|
||||
foundMatch = true;
|
||||
@ -1039,24 +1036,40 @@ void LIB_SYMBOL::SetFields( const std::vector<SCH_FIELD>& aFieldsList )
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::GetFields( std::vector<SCH_FIELD*>& aList )
|
||||
void LIB_SYMBOL::GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly )
|
||||
{
|
||||
// Grab the MANDATORY_FIELDS first, in expected order given by enum MANDATORY_FIELD_T
|
||||
for( int id = 0; id < MANDATORY_FIELDS; ++id )
|
||||
aList.push_back( GetFieldById( id ) );
|
||||
{
|
||||
SCH_FIELD* field = GetFieldById( id );
|
||||
|
||||
if( aVisibleOnly )
|
||||
{
|
||||
if( !field->IsVisible() || field->GetText().IsEmpty() )
|
||||
continue;
|
||||
}
|
||||
|
||||
aList.push_back( field );
|
||||
}
|
||||
|
||||
// Now grab all the rest of fields.
|
||||
for( SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
|
||||
{
|
||||
SCH_FIELD* field = static_cast<SCH_FIELD*>( &item );
|
||||
|
||||
if( aVisibleOnly )
|
||||
{
|
||||
if( !field->IsVisible() || field->GetText().IsEmpty() )
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !field->IsMandatory() )
|
||||
aList.push_back( field );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::GetFields( std::vector<SCH_FIELD>& aList )
|
||||
void LIB_SYMBOL::CopyFields( std::vector<SCH_FIELD>& aList )
|
||||
{
|
||||
// Grab the MANDATORY_FIELDS first, in expected order given by enum MANDATORY_FIELD_T
|
||||
for( int id = 0; id < MANDATORY_FIELDS; ++id )
|
||||
@ -1836,12 +1849,12 @@ double LIB_SYMBOL::Similarity( const SCH_ITEM& aOther ) const
|
||||
similarity += max_similarity;
|
||||
}
|
||||
|
||||
for( const SCH_PIN* pin : GetAllLibPins() )
|
||||
for( const SCH_PIN* pin : GetPins() )
|
||||
{
|
||||
totalItems += 1;
|
||||
double max_similarity = 0.0;
|
||||
|
||||
for( const SCH_PIN* otherPin : other.GetAllLibPins() )
|
||||
for( const SCH_PIN* otherPin : other.GetPins() )
|
||||
{
|
||||
double temp_similarity = pin->Similarity( *otherPin );
|
||||
max_similarity = std::max( max_similarity, temp_similarity );
|
||||
|
@ -227,6 +227,11 @@ public:
|
||||
const BOX2I GetUnitBoundingBox( int aUnit, int aBodyStyle,
|
||||
bool aIgnoreHiddenFields = true ) const;
|
||||
|
||||
const BOX2I GetBoundingBox() const override
|
||||
{
|
||||
return GetUnitBoundingBox( 0, 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the symbol bounding box excluding fields.
|
||||
*
|
||||
@ -240,9 +245,14 @@ public:
|
||||
const BOX2I GetBodyBoundingBox( int aUnit, int aBodyStyle, bool aIncludePins,
|
||||
bool aIncludePrivateItems ) const;
|
||||
|
||||
const BOX2I GetBoundingBox() const override
|
||||
BOX2I GetBodyBoundingBox() const override
|
||||
{
|
||||
return GetUnitBoundingBox( 0, 0 );
|
||||
return GetBodyBoundingBox( m_previewUnit, m_previewBodyStyle, false, false );
|
||||
}
|
||||
|
||||
BOX2I GetBodyAndPinsBoundingBox() const override
|
||||
{
|
||||
return GetBodyBoundingBox( m_previewUnit, m_previewBodyStyle, true, false );
|
||||
}
|
||||
|
||||
bool IsPower() const override;
|
||||
@ -275,8 +285,9 @@ public:
|
||||
*
|
||||
* @param aList - List to add fields to
|
||||
*/
|
||||
void GetFields( std::vector<SCH_FIELD*>& aList );
|
||||
void GetFields( std::vector<SCH_FIELD>& aList );
|
||||
void GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly = false ) override;
|
||||
|
||||
void CopyFields( std::vector<SCH_FIELD>& aList );
|
||||
|
||||
/**
|
||||
* Add a field. Takes ownership of the pointer.
|
||||
@ -403,13 +414,13 @@ public:
|
||||
* @param aBodyStyle - Symbol alternate body style of pins to collect. Set to 0 to get pins
|
||||
* from any DeMorgan variant of symbol.
|
||||
*/
|
||||
std::vector<SCH_PIN*> GetPins( int aUnit = 0, int aBodyStyle = 0 ) const;
|
||||
std::vector<SCH_PIN*> GetPins( int aUnit, int aBodyStyle ) const;
|
||||
|
||||
/**
|
||||
* Return a list of pin pointers for all units / converts. Used primarily for SPICE where
|
||||
* we want to treat all unit as a single part.
|
||||
*/
|
||||
std::vector<SCH_PIN*> GetAllLibPins() const;
|
||||
std::vector<SCH_PIN*> GetPins() const override;
|
||||
|
||||
/**
|
||||
* @return a count of pins for all units / converts.
|
||||
|
@ -440,7 +440,7 @@ void NETLIST_EXPORTER_ALLEGRO::toAllegroPackages()
|
||||
fprintf( d, "PACKAGE '%s'\n", TO_UTF8( formatDevice( footprintText ) ) );
|
||||
fprintf( d, "CLASS IC\n" );
|
||||
|
||||
std::vector<SCH_PIN*> pinList = sym->GetLibSymbolRef()->GetAllLibPins();
|
||||
std::vector<SCH_PIN*> pinList = sym->GetLibSymbolRef()->GetPins();
|
||||
|
||||
/*
|
||||
* We must erase redundant Pins references in pinList
|
||||
|
@ -310,14 +310,7 @@ bool SCH_IO_ALTIUM::CanReadLibrary( const wxString& aFileName ) const
|
||||
|
||||
void SCH_IO_ALTIUM::fixupSymbolPinNameNumbers( SYMBOL* aSymbol )
|
||||
{
|
||||
std::vector<SCH_PIN*> pins;
|
||||
|
||||
if( LIB_SYMBOL* lib_sym = dyn_cast<LIB_SYMBOL*>( aSymbol ) )
|
||||
pins = lib_sym->GetAllLibPins();
|
||||
|
||||
if( SCH_SYMBOL* sch_sym = dyn_cast<SCH_SYMBOL*>( aSymbol ) )
|
||||
pins = sch_sym->GetPins();
|
||||
|
||||
std::vector<SCH_PIN*> pins = aSymbol->GetPins();
|
||||
|
||||
bool names_visible = false;
|
||||
bool numbers_visible = false;
|
||||
|
@ -901,7 +901,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
|
||||
kiPart->SetShowPinNames( false );
|
||||
kiPart->SetShowPinNumbers( false );
|
||||
|
||||
std::vector<SCH_PIN*> pins = kiPart->GetAllLibPins();
|
||||
std::vector<SCH_PIN*> pins = kiPart->GetPins();
|
||||
wxCHECK( pins.size() == 1, /*void*/ );
|
||||
|
||||
pins.at( 0 )->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
|
||||
@ -3318,7 +3318,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins( LIB_SYMBOL* aSymbolToFix, int
|
||||
}
|
||||
}
|
||||
|
||||
for( SCH_PIN* pin : aSymbolToFix->GetPins( aGateNumber ) )
|
||||
for( SCH_PIN* pin : aSymbolToFix->GetPins( aGateNumber, 0 ) )
|
||||
{
|
||||
auto setPinOrientation =
|
||||
[&]( const EDA_ANGLE& aAngle )
|
||||
|
@ -3324,7 +3324,7 @@ void SCH_IO_EAGLE::addImplicitConnections( SCH_SYMBOL* aSymbol, SCH_SCREEN* aScr
|
||||
|
||||
int unit = aSymbol->GetUnit();
|
||||
const wxString reference = aSymbol->GetField( REFERENCE_FIELD )->GetText();
|
||||
std::vector<SCH_PIN*> pins = aSymbol->GetLibSymbolRef()->GetAllLibPins();
|
||||
std::vector<SCH_PIN*> pins = aSymbol->GetLibSymbolRef()->GetPins();
|
||||
std::set<int> missingUnits;
|
||||
|
||||
// Search all units for pins creating implicit connections
|
||||
|
@ -364,6 +364,13 @@ wxString SCH_PIN::GetElectricalTypeName() const
|
||||
}
|
||||
|
||||
|
||||
bool SCH_PIN::IsGlobalPower() const
|
||||
{
|
||||
return GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN
|
||||
&& ( !IsVisible() || GetParentSymbol()->IsPower() );
|
||||
}
|
||||
|
||||
|
||||
bool SCH_PIN::IsVisible() const
|
||||
{
|
||||
if( !m_hidden.has_value() )
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include <pin_type.h>
|
||||
#include <sch_item.h>
|
||||
#include <symbol.h>
|
||||
|
||||
class LIB_SYMBOL;
|
||||
class SCH_SYMBOL;
|
||||
@ -188,11 +187,7 @@ public:
|
||||
* Return whether this pin forms a global power connection: i.e., is part of a power symbol
|
||||
* and of type POWER_IN, or is a legacy invisible global power pin on a symbol.
|
||||
*/
|
||||
bool IsGlobalPower() const
|
||||
{
|
||||
return GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN
|
||||
&& ( !IsVisible() || GetParentSymbol()->IsPower() );
|
||||
}
|
||||
bool IsGlobalPower() const;
|
||||
|
||||
int GetPenWidth() const override { return 0; }
|
||||
|
||||
|
@ -336,7 +336,7 @@ void SCH_SYMBOL::UpdatePins()
|
||||
if( !m_part )
|
||||
return;
|
||||
|
||||
for( SCH_PIN* libPin : m_part->GetAllLibPins() )
|
||||
for( SCH_PIN* libPin : m_part->GetPins() )
|
||||
{
|
||||
// NW: Don't filter by unit: this data-structure is used for all instances,
|
||||
// some of which might have different units.
|
||||
@ -459,12 +459,6 @@ bool SCH_SYMBOL::HasAlternateBodyStyle() const
|
||||
}
|
||||
|
||||
|
||||
void SCH_SYMBOL::SetTransform( const TRANSFORM& aTransform )
|
||||
{
|
||||
m_transform = aTransform;
|
||||
}
|
||||
|
||||
|
||||
int SCH_SYMBOL::GetUnitCount() const
|
||||
{
|
||||
if( m_part )
|
||||
@ -1278,7 +1272,7 @@ std::vector<SCH_PIN*> SCH_SYMBOL::GetLibPins() const
|
||||
std::vector<SCH_PIN*> SCH_SYMBOL::GetAllLibPins() const
|
||||
{
|
||||
if( m_part )
|
||||
return m_part->GetAllLibPins();
|
||||
return m_part->GetPins();
|
||||
|
||||
return std::vector<SCH_PIN*>();
|
||||
}
|
||||
@ -1330,6 +1324,12 @@ std::vector<SCH_PIN*> SCH_SYMBOL::GetPins( const SCH_SHEET_PATH* aSheet ) const
|
||||
}
|
||||
|
||||
|
||||
std::vector<SCH_PIN*> SCH_SYMBOL::GetPins() const
|
||||
{
|
||||
return GetPins( nullptr );
|
||||
}
|
||||
|
||||
|
||||
void SCH_SYMBOL::SwapData( SCH_ITEM* aItem )
|
||||
{
|
||||
SCH_ITEM::SwapFlags( aItem );
|
||||
|
@ -70,33 +70,6 @@ typedef std::weak_ptr<LIB_SYMBOL> PART_REF;
|
||||
extern std::string toUTFTildaText( const wxString& txt );
|
||||
|
||||
|
||||
// @todo Move this to transform alone with all of the transform manipulation code.
|
||||
/// enum used in RotationMiroir()
|
||||
enum SYMBOL_ORIENTATION_T
|
||||
{
|
||||
SYM_NORMAL, // Normal orientation, no rotation or mirror
|
||||
SYM_ROTATE_CLOCKWISE, // Rotate -90
|
||||
SYM_ROTATE_COUNTERCLOCKWISE, // Rotate +90
|
||||
SYM_ORIENT_0, // No rotation and no mirror id SYM_NORMAL
|
||||
SYM_ORIENT_90, // Rotate 90, no mirror
|
||||
SYM_ORIENT_180, // Rotate 180, no mirror
|
||||
SYM_ORIENT_270, // Rotate -90, no mirror
|
||||
SYM_MIRROR_X = 0x100, // Mirror around X axis
|
||||
SYM_MIRROR_Y = 0x200 // Mirror around Y axis
|
||||
};
|
||||
|
||||
|
||||
// Cover for SYMBOL_ORIENTATION_T for property manager (in order to expose only a subset of
|
||||
// SYMBOL_ORIENTATION_T's values).
|
||||
enum SYMBOL_ORIENTATION_PROP
|
||||
{
|
||||
SYMBOL_ANGLE_0 = SYMBOL_ORIENTATION_T::SYM_ORIENT_0,
|
||||
SYMBOL_ANGLE_90 = SYMBOL_ORIENTATION_T::SYM_ORIENT_90,
|
||||
SYMBOL_ANGLE_180 = SYMBOL_ORIENTATION_T::SYM_ORIENT_180,
|
||||
SYMBOL_ANGLE_270 = SYMBOL_ORIENTATION_T::SYM_ORIENT_270
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Schematic symbol object.
|
||||
*/
|
||||
@ -285,11 +258,6 @@ public:
|
||||
|
||||
wxString SubReference( int aUnit, bool aAddSeparator = true ) const;
|
||||
|
||||
TRANSFORM& GetTransform() { return m_transform; }
|
||||
const TRANSFORM& GetTransform() const { return m_transform; }
|
||||
|
||||
void SetTransform( const TRANSFORM& aTransform );
|
||||
|
||||
/**
|
||||
* Return the number of units per package of the symbol.
|
||||
*
|
||||
@ -322,7 +290,7 @@ public:
|
||||
*
|
||||
* @return the orientation and mirror of the symbol.
|
||||
*/
|
||||
int GetOrientation() const;
|
||||
int GetOrientation() const override;
|
||||
|
||||
/**
|
||||
* Orientation/mirroring access for property manager.
|
||||
@ -432,12 +400,12 @@ public:
|
||||
/**
|
||||
* Return a bounding box for the symbol body but not the pins or fields.
|
||||
*/
|
||||
BOX2I GetBodyBoundingBox() const;
|
||||
BOX2I GetBodyBoundingBox() const override;
|
||||
|
||||
/**
|
||||
* Return a bounding box for the symbol body and pins but not the fields.
|
||||
*/
|
||||
BOX2I GetBodyAndPinsBoundingBox() const;
|
||||
BOX2I GetBodyAndPinsBoundingBox() const override;
|
||||
|
||||
|
||||
//-----<Fields>-----------------------------------------------------------
|
||||
@ -479,7 +447,7 @@ public:
|
||||
* @param aVector is the vector to populate.
|
||||
* @param aVisibleOnly is used to add only the fields that are visible and contain text.
|
||||
*/
|
||||
void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly );
|
||||
void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly ) override;
|
||||
|
||||
/**
|
||||
* Return a vector of fields from the symbol
|
||||
@ -671,7 +639,9 @@ public:
|
||||
*
|
||||
* @return a vector of pointers (non-owning) to SCH_PINs
|
||||
*/
|
||||
std::vector<SCH_PIN*> GetPins( const SCH_SHEET_PATH* aSheet = nullptr ) const;
|
||||
std::vector<SCH_PIN*> GetPins( const SCH_SHEET_PATH* aSheet ) const;
|
||||
|
||||
std::vector<SCH_PIN*> GetPins() const override;
|
||||
|
||||
|
||||
std::vector<std::unique_ptr<SCH_PIN>>& GetRawPins() { return m_pins; }
|
||||
@ -915,7 +885,6 @@ private:
|
||||
*/
|
||||
wxString m_schLibSymbolName;
|
||||
|
||||
TRANSFORM m_transform; ///< The rotation/mirror transformation.
|
||||
std::vector<SCH_FIELD> m_fields; ///< Variable length list of fields.
|
||||
|
||||
std::unique_ptr<LIB_SYMBOL> m_part; ///< A flattened copy of the LIB_SYMBOL from the
|
||||
|
@ -1244,7 +1244,7 @@ bool SIM_MODEL::InferSimModel( T& aSymbol, std::vector<SCH_FIELD>* aFields, bool
|
||||
wxString library = GetFieldValue( aFields, SIM_LIBRARY_FIELD, aResolve );
|
||||
wxString modelName = GetFieldValue( aFields, SIM_NAME_FIELD, aResolve );
|
||||
wxString value = GetFieldValue( aFields, SIM_VALUE_FIELD, aResolve );
|
||||
std::vector<SCH_PIN*> pins = aSymbol.GetAllLibPins();
|
||||
std::vector<SCH_PIN*> pins = aSymbol.GetPins();
|
||||
|
||||
*aDeviceType = GetFieldValue( aFields, SIM_DEVICE_FIELD, aResolve );
|
||||
*aModelType = GetFieldValue( aFields, SIM_DEVICE_SUBTYPE_FIELD, aResolve );
|
||||
@ -1568,7 +1568,7 @@ void SIM_MODEL::MigrateSimModel( T& aSymbol, const PROJECT* aProject )
|
||||
|
||||
wxString prefix = aSymbol.GetPrefix();
|
||||
SCH_FIELD* valueField = aSymbol.FindField( wxT( "Value" ) );
|
||||
std::vector<SCH_PIN*> sourcePins = aSymbol.GetAllLibPins();
|
||||
std::vector<SCH_PIN*> sourcePins = aSymbol.GetPins();
|
||||
bool sourcePinsSorted = false;
|
||||
|
||||
auto lazySortSourcePins =
|
||||
|
@ -26,6 +26,35 @@
|
||||
|
||||
#include <lib_id.h>
|
||||
#include <sch_item.h>
|
||||
#include <sch_field.h>
|
||||
#include <sch_pin.h>
|
||||
|
||||
// @todo Move this to transform alone with all of the transform manipulation code.
|
||||
/// enum used in RotationMiroir()
|
||||
enum SYMBOL_ORIENTATION_T
|
||||
{
|
||||
SYM_NORMAL, // Normal orientation, no rotation or mirror
|
||||
SYM_ROTATE_CLOCKWISE, // Rotate -90
|
||||
SYM_ROTATE_COUNTERCLOCKWISE, // Rotate +90
|
||||
SYM_ORIENT_0, // No rotation and no mirror id SYM_NORMAL
|
||||
SYM_ORIENT_90, // Rotate 90, no mirror
|
||||
SYM_ORIENT_180, // Rotate 180, no mirror
|
||||
SYM_ORIENT_270, // Rotate -90, no mirror
|
||||
SYM_MIRROR_X = 0x100, // Mirror around X axis
|
||||
SYM_MIRROR_Y = 0x200 // Mirror around Y axis
|
||||
};
|
||||
|
||||
|
||||
// Cover for SYMBOL_ORIENTATION_T for property manager (in order to expose only a subset of
|
||||
// SYMBOL_ORIENTATION_T's values).
|
||||
enum SYMBOL_ORIENTATION_PROP
|
||||
{
|
||||
SYMBOL_ANGLE_0 = SYMBOL_ORIENTATION_T::SYM_ORIENT_0,
|
||||
SYMBOL_ANGLE_90 = SYMBOL_ORIENTATION_T::SYM_ORIENT_90,
|
||||
SYMBOL_ANGLE_180 = SYMBOL_ORIENTATION_T::SYM_ORIENT_180,
|
||||
SYMBOL_ANGLE_270 = SYMBOL_ORIENTATION_T::SYM_ORIENT_270
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A base class for LIB_SYMBOL and SCH_SYMBOL.
|
||||
@ -107,6 +136,10 @@ public:
|
||||
virtual const wxString GetValue( bool aResolve, const SCH_SHEET_PATH* aPath,
|
||||
bool aAllowExtraText ) const = 0;
|
||||
|
||||
virtual void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly ) = 0;
|
||||
|
||||
virtual std::vector<SCH_PIN*> GetPins() const = 0;
|
||||
|
||||
/**
|
||||
* Set the offset in mils of the pin name text from the pin symbol.
|
||||
*
|
||||
@ -153,9 +186,30 @@ public:
|
||||
bool GetDNP() const { return m_DNP; }
|
||||
void SetDNP( bool aDNP ) { m_DNP = aDNP; }
|
||||
|
||||
virtual int GetOrientation() const { return SYM_NORMAL; }
|
||||
|
||||
const TRANSFORM& GetTransform() const { return m_transform; }
|
||||
TRANSFORM& GetTransform() { return m_transform; }
|
||||
void SetTransform( const TRANSFORM& aTransform ) { m_transform = aTransform; }
|
||||
|
||||
void SetPreviewUnit( int aUnit ) { m_previewUnit = aUnit; }
|
||||
void SetPreviewBodyStyle( int aBodyStyle ) { m_previewBodyStyle = aBodyStyle; }
|
||||
|
||||
/**
|
||||
* Return a bounding box for the symbol body but not the pins or fields.
|
||||
*/
|
||||
virtual BOX2I GetBodyBoundingBox() const = 0;
|
||||
|
||||
/**
|
||||
* Return a bounding box for the symbol body and pins but not the fields.
|
||||
*/
|
||||
virtual BOX2I GetBodyAndPinsBoundingBox() const = 0;
|
||||
|
||||
std::vector<int> ViewGetLayers() const override;
|
||||
|
||||
protected:
|
||||
TRANSFORM m_transform; ///< The rotation/mirror transformation.
|
||||
|
||||
int m_pinNameOffset; ///< The offset in mils to draw the pin name. Set to
|
||||
///< 0 to draw the pin name above the pin.
|
||||
bool m_showPinNames;
|
||||
@ -165,6 +219,9 @@ protected:
|
||||
bool m_excludedFromBOM;
|
||||
bool m_excludedFromBoard;
|
||||
bool m_DNP; ///< True if symbol is set to 'Do Not Populate'.
|
||||
|
||||
int m_previewUnit = 1;
|
||||
int m_previewBodyStyle = 1;
|
||||
};
|
||||
|
||||
#endif // SYMBOL_H
|
||||
|
@ -1477,7 +1477,7 @@ void SYMBOL_EDIT_FRAME::FocusOnItem( SCH_ITEM* aItem )
|
||||
|
||||
if( m_symbol )
|
||||
{
|
||||
for( SCH_PIN* pin : m_symbol->GetAllLibPins() )
|
||||
for( SCH_PIN* pin : m_symbol->GetPins() )
|
||||
{
|
||||
if( pin->m_Uuid == lastBrightenedItemID )
|
||||
lastItem = pin;
|
||||
|
@ -691,30 +691,28 @@ private:
|
||||
/*
|
||||
* Get a list of pins on a line segment
|
||||
*/
|
||||
const auto getPinsOnSeg = []( LIB_SYMBOL& aSymbol, int aUnit, const SEG& aSeg,
|
||||
bool aIncludeEnds ) -> std::vector<SCH_PIN*>
|
||||
{
|
||||
// const BOX2I segBox = BOX2I::ByCorners( aSeg.A, aSeg.B ).GetInflated( 1 );
|
||||
// const EE_RTREE& rtree = m_frame->GetScreen()->Items().Overlapping( SCH_PIN_T, segBox );
|
||||
|
||||
std::vector<SCH_PIN*> pins;
|
||||
|
||||
for( SCH_PIN* pin : aSymbol.GetPins( aUnit ) )
|
||||
{
|
||||
// Figure out if the pin "connects" to the line
|
||||
const VECTOR2I pinRootPos = pin->GetPinRoot();
|
||||
|
||||
if( aSeg.Contains( pinRootPos ) )
|
||||
const auto getPinsOnSeg =
|
||||
[]( LIB_SYMBOL& aSymbol, int aUnit, const SEG& aSeg,
|
||||
bool aIncludeEnds ) -> std::vector<SCH_PIN*>
|
||||
{
|
||||
if( aIncludeEnds || ( pinRootPos != aSeg.A && pinRootPos != aSeg.B ) )
|
||||
{
|
||||
pins.push_back( pin );
|
||||
}
|
||||
}
|
||||
}
|
||||
std::vector<SCH_PIN*> pins;
|
||||
|
||||
return pins;
|
||||
};
|
||||
for( SCH_PIN* pin : aSymbol.GetPins( aUnit, 0 ) )
|
||||
{
|
||||
// Figure out if the pin "connects" to the line
|
||||
const VECTOR2I pinRootPos = pin->GetPinRoot();
|
||||
|
||||
if( aSeg.Contains( pinRootPos ) )
|
||||
{
|
||||
if( aIncludeEnds || ( pinRootPos != aSeg.A && pinRootPos != aSeg.B ) )
|
||||
{
|
||||
pins.push_back( pin );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pins;
|
||||
};
|
||||
|
||||
LIB_SYMBOL* const symbol = editor.GetCurSymbol();
|
||||
|
||||
@ -723,8 +721,8 @@ private:
|
||||
if( aMoveVecs[i] == VECTOR2I( 0, 0 ) || !symbol )
|
||||
continue;
|
||||
|
||||
const std::vector<SCH_PIN*> pins =
|
||||
getPinsOnSeg( *symbol, aEdgeUnit, aOldEdges[i], false );
|
||||
const std::vector<SCH_PIN*> pins = getPinsOnSeg( *symbol, aEdgeUnit, aOldEdges[i],
|
||||
false );
|
||||
|
||||
for( SCH_PIN* pin : pins )
|
||||
{
|
||||
@ -737,6 +735,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SCH_SHAPE& m_rect;
|
||||
EDA_DRAW_FRAME& m_frame;
|
||||
};
|
||||
|
@ -838,7 +838,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem( const TOOL_EVENT& aEvent )
|
||||
if( !symbol )
|
||||
return 0;
|
||||
|
||||
for( SCH_PIN* test : symbol->GetAllLibPins() )
|
||||
for( SCH_PIN* test : symbol->GetPins() )
|
||||
{
|
||||
if( test->m_Uuid == g_lastPin )
|
||||
{
|
||||
|
@ -416,7 +416,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
|
||||
|
||||
got_unit[curr_pin->GetUnit()] = true;
|
||||
|
||||
for( SCH_PIN* pin : symbol->GetAllLibPins() )
|
||||
for( SCH_PIN* pin : symbol->GetPins() )
|
||||
{
|
||||
if( got_unit[pin->GetUnit()] )
|
||||
continue;
|
||||
|
@ -195,7 +195,7 @@ bool SYMBOL_EDITOR_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COM
|
||||
|
||||
got_unit[cur_pin->GetUnit()] = true;
|
||||
|
||||
for( SCH_PIN* pin : symbol->GetAllLibPins() )
|
||||
for( SCH_PIN* pin : symbol->GetPins() )
|
||||
{
|
||||
if( !got_unit[pin->GetUnit()]
|
||||
&& pin->GetPosition() == cur_pin->GetPosition()
|
||||
|
@ -218,7 +218,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::PlacePin( SCH_PIN* aPin )
|
||||
LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
|
||||
bool ask_for_pin = true; // Test for another pin in same position in other units
|
||||
|
||||
std::vector<SCH_PIN*> pins = symbol->GetAllLibPins();
|
||||
std::vector<SCH_PIN*> pins = symbol->GetPins();
|
||||
|
||||
for( SCH_PIN* test : pins )
|
||||
{
|
||||
@ -384,7 +384,7 @@ int SYMBOL_EDITOR_PIN_TOOL::PushPinProperties( const TOOL_EVENT& aEvent )
|
||||
|
||||
saveCopyInUndoList( symbol, UNDO_REDO::LIBEDIT );
|
||||
|
||||
for( SCH_PIN* pin : symbol->GetAllLibPins() )
|
||||
for( SCH_PIN* pin : symbol->GetPins() )
|
||||
{
|
||||
if( pin == sourcePin )
|
||||
continue;
|
||||
|
@ -221,18 +221,6 @@ void SYMBOL_PREVIEW_WIDGET::DisplaySymbol( const LIB_ID& aSymbolID, int aUnit, i
|
||||
// This will flatten derived parts so that the correct final symbol can be shown.
|
||||
m_previewItem = symbol.release();
|
||||
|
||||
// Hide fields that were added automatically by the library (for example, when using
|
||||
// database libraries) as they don't have a valid position yet, and we don't support
|
||||
// autoplacing fields on library symbols yet.
|
||||
std::vector<SCH_FIELD*> previewFields;
|
||||
m_previewItem->GetFields( previewFields );
|
||||
|
||||
for( SCH_FIELD* field : previewFields )
|
||||
{
|
||||
if( field->IsAutoAdded() )
|
||||
field->SetVisible( false );
|
||||
}
|
||||
|
||||
// If unit isn't specified for a multi-unit part, pick the first. (Otherwise we'll
|
||||
// draw all of them.)
|
||||
settings->m_ShowUnit = ( m_previewItem->IsMulti() && aUnit == 0 ) ? 1 : aUnit;
|
||||
@ -241,6 +229,10 @@ void SYMBOL_PREVIEW_WIDGET::DisplaySymbol( const LIB_ID& aSymbolID, int aUnit, i
|
||||
settings->m_ShowBodyStyle =
|
||||
( m_previewItem->HasAlternateBodyStyle() && aBodyStyle == 0 ) ? 1 : aBodyStyle;
|
||||
|
||||
m_previewItem->SetPreviewUnit( settings->m_ShowUnit );
|
||||
m_previewItem->SetPreviewBodyStyle( settings->m_ShowBodyStyle );
|
||||
m_previewItem->AutoAutoplaceFields( nullptr );
|
||||
|
||||
view->Add( m_previewItem );
|
||||
|
||||
// Get the symbol size, in internal units
|
||||
@ -290,6 +282,10 @@ void SYMBOL_PREVIEW_WIDGET::DisplayPart( LIB_SYMBOL* aSymbol, int aUnit, int aBo
|
||||
settings->m_ShowBodyStyle =
|
||||
( m_previewItem->HasAlternateBodyStyle() && aBodyStyle == 0 ) ? 1 : aBodyStyle;
|
||||
|
||||
m_previewItem->SetPreviewUnit( settings->m_ShowUnit );
|
||||
m_previewItem->SetPreviewBodyStyle( settings->m_ShowBodyStyle );
|
||||
m_previewItem->AutoAutoplaceFields( nullptr );
|
||||
|
||||
view->Add( m_previewItem );
|
||||
|
||||
// Get the symbol size, in internal units
|
||||
|
@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE( DefaultDrawings )
|
||||
{
|
||||
// default drawings exist
|
||||
BOOST_CHECK_EQUAL( m_part_no_data.GetDrawItems().size(), MANDATORY_FIELDS );
|
||||
BOOST_CHECK_EQUAL( m_part_no_data.GetAllLibPins().size(), 0 );
|
||||
BOOST_CHECK_EQUAL( m_part_no_data.GetPins().size(), 0 );
|
||||
}
|
||||
|
||||
|
||||
@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE( DefaultDrawings )
|
||||
BOOST_AUTO_TEST_CASE( DefaultFields )
|
||||
{
|
||||
std::vector<SCH_FIELD> fields;
|
||||
m_part_no_data.GetFields( fields );
|
||||
m_part_no_data.CopyFields( fields );
|
||||
|
||||
// Should get the 4 default fields
|
||||
BOOST_CHECK_PREDICATE( KI_TEST::AreDefaultFieldsCorrect, ( fields ) );
|
||||
@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE( DefaultFields )
|
||||
BOOST_AUTO_TEST_CASE( AddedFields )
|
||||
{
|
||||
std::vector<SCH_FIELD> fields;
|
||||
m_part_no_data.GetFields( fields );
|
||||
m_part_no_data.CopyFields( fields );
|
||||
|
||||
// Ctor takes non-const ref (?!)
|
||||
const std::string newFieldName = "new_field";
|
||||
|
Loading…
Reference in New Issue
Block a user