FOOTPRINT: add a method to auto-position Reference and Value.
This commit is contained in:
parent
040fd327ab
commit
e498f1b9a0
|
@ -2179,6 +2179,26 @@ wxString FOOTPRINT::GetNextPadNumber( const wxString& aLastPadNumber ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FOOTPRINT::AutoPositionFields()
|
||||||
|
{
|
||||||
|
// Auto-position reference and value
|
||||||
|
BOX2I bbox = GetBoundingBox( false, false );
|
||||||
|
bbox.Inflate( pcbIUScale.mmToIU( 0.2 ) ); // Gap between graphics and text
|
||||||
|
|
||||||
|
if( Reference().GetPosition() == VECTOR2I( 0, 0 ) )
|
||||||
|
{
|
||||||
|
Reference().SetX( bbox.GetCenter().x );
|
||||||
|
Reference().SetY( bbox.GetTop() - Reference().GetTextSize().y / 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( Value().GetPosition() == VECTOR2I( 0, 0 ) )
|
||||||
|
{
|
||||||
|
Value().SetX( bbox.GetCenter().x );
|
||||||
|
Value().SetY( bbox.GetBottom() + Value().GetTextSize().y / 2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void FOOTPRINT::IncrementReference( int aDelta )
|
void FOOTPRINT::IncrementReference( int aDelta )
|
||||||
{
|
{
|
||||||
const wxString& refdes = GetReference();
|
const wxString& refdes = GetReference();
|
||||||
|
|
|
@ -775,6 +775,11 @@ public:
|
||||||
*/
|
*/
|
||||||
wxString GetNextPadNumber( const wxString& aLastPadName ) const;
|
wxString GetNextPadNumber( const wxString& aLastPadName ) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Position Reference and Value fields at the top and bottom of footprint's bounding box.
|
||||||
|
*/
|
||||||
|
void AutoPositionFields();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type of footprint
|
* Get the type of footprint
|
||||||
* @return "SMD"/"Through hole"/"Other" based on attributes
|
* @return "SMD"/"Through hole"/"Other" based on attributes
|
||||||
|
|
|
@ -761,20 +761,7 @@ FOOTPRINT* ALTIUM_PCB::ParseFootprint( const ALTIUM_COMPOUND_FILE& altiumLibFile
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto-position reference and value
|
// Auto-position reference and value
|
||||||
BOX2I bbox = footprint.get()->GetBoundingBox( false, false );
|
footprint->AutoPositionFields();
|
||||||
bbox.Inflate( pcbIUScale.mmToIU( 0.2 ) ); // Gap between graphics and text
|
|
||||||
|
|
||||||
if( footprint->Reference().GetPosition() == VECTOR2I( 0, 0 ) )
|
|
||||||
{
|
|
||||||
footprint->Reference().SetX( bbox.GetCenter().x );
|
|
||||||
footprint->Reference().SetY( bbox.GetTop() - footprint->Reference().GetTextSize().y / 2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( footprint->Value().GetPosition() == VECTOR2I( 0, 0 ) )
|
|
||||||
{
|
|
||||||
footprint->Value().SetX( bbox.GetCenter().x );
|
|
||||||
footprint->Value().SetY( bbox.GetBottom() + footprint->Value().GetTextSize().y / 2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( parser.HasParsingError() )
|
if( parser.HasParsingError() )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue