Enable long names for pin numbers and pads

- pad names are stored as wxString instead of a char[4] & integer union
- removed pad name to string conversion functions
- fixed pad & pin properties dialog restrictions regarding the name
length
This commit is contained in:
Maciej Suminski 2017-08-10 17:00:28 +02:00
parent dddaa7e69c
commit 85be485c34
19 changed files with 88 additions and 284 deletions

View File

@ -643,7 +643,6 @@ void LIB_PART::GetPins( LIB_PINS& aList, int aUnit, int aConvert )
LIB_PIN* LIB_PART::GetPin( const wxString& aNumber, int aUnit, int aConvert )
{
wxString pNumber;
LIB_PINS pinList;
GetPins( pinList, aUnit, aConvert );
@ -652,9 +651,7 @@ LIB_PIN* LIB_PART::GetPin( const wxString& aNumber, int aUnit, int aConvert )
{
wxASSERT( pinList[i]->Type() == LIB_PIN_T );
pinList[i]->PinStringNum( pNumber );
if( aNumber == pNumber )
if( aNumber == pinList[i]->GetNumber() )
return pinList[i];
}
@ -683,10 +680,7 @@ bool LIB_PART::PinsConflictWith( LIB_PART& aOtherPart, bool aTestNums, bool aTes
continue;
// Same number?
wxString eachThisPinNumber, eachOtherPinNumber;
eachThisPin->PinStringNum( eachThisPinNumber );
eachOtherPin->PinStringNum( eachOtherPinNumber );
if( aTestNums && ( eachThisPinNumber != eachOtherPinNumber ))
if( aTestNums && ( eachThisPin->GetNumber() != eachOtherPin->GetNumber() ))
continue;
// Same name?

View File

@ -184,7 +184,6 @@ NETLIST_OBJECT::NETLIST_OBJECT()
* from the BUS label ) member number
*/
m_ConnectionType = UNCONNECTED;
m_PinNum = 0; /* pin number ( 1 long = 4 bytes -> 4 ascii codes) */
m_netNameCandidate = NULL; /* a pointer to a NETLIST_OBJECT type label connected to this
* object used to give a name to the net
*/
@ -389,9 +388,7 @@ wxString NETLIST_OBJECT::GetShortNetName( bool adoptTimestamp ) const
if( adoptTimestamp && netName.Last() == '?' )
netName << link->GetTimeStamp();
netName << wxT("-Pad")
<< LIB_PIN::PinStringNum( m_netNameCandidate->m_PinNum )
<< wxT(")");
netName << wxT("-Pad") << m_netNameCandidate->m_PinNum << wxT(")");
}
}
else

View File

@ -33,7 +33,7 @@
#include <sch_sheet_path.h>
#include <lib_pin.h> // LIB_PIN::PinStringNum( m_PinNum )
#include <lib_pin.h>
#include <sch_item_struct.h>
class NETLIST_OBJECT_LIST;
@ -111,7 +111,7 @@ public:
* created from the BUS label ) member number.
*/
NET_CONNECTION_T m_ConnectionType; // Used to store the connection type
long m_PinNum; // pin number ( 1 long = 4 bytes -> 4 ascii codes)
wxString m_PinNum; // pin number
wxString m_Label; // Label text (for labels) or Pin name (for pins)
wxPoint m_Start; // Position of object or for segments: starting point
wxPoint m_End; // For segments (wire and buses): ending point
@ -182,10 +182,9 @@ public:
* returns a pin number in wxString form. Pin numbers are not always
* numbers. \"A23\" would be a valid pin number.
*/
wxString GetPinNumText()
const wxString& GetPinNumText() const
{
// hide the ugliness in here, but do it inline.
return LIB_PIN::PinStringNum( m_PinNum );
return m_PinNum;
}
/** For Pins (NET_PINS):

View File

@ -141,13 +141,9 @@ std::string FormatProbeItem( EDA_ITEM* aItem, SCH_COMPONENT* aPart )
LIB_PIN* pin = (LIB_PIN*) aItem;
if( pin->GetNumber() )
if( !pin->GetNumber().IsEmpty() )
{
wxString pinnum;
pin->PinStringNum( pinnum );
return StrPrintf( "$PIN: %s $PART: %s", TO_UTF8( pinnum ),
return StrPrintf( "$PIN: %s $PART: %s", TO_UTF8( pin->GetNumber() ),
TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
}
else

View File

@ -530,7 +530,7 @@ wxString DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Pin::GetString( unsigned int
switch( aCol )
{
case PIN_NUMBER:
return m_Backing->GetNumberString();
return m_Backing->GetNumber();
case PIN_NAME:
if( m_Model.m_UnitCount > 1 )

View File

@ -149,7 +149,6 @@ LIB_PIN::LIB_PIN( LIB_PART* aParent ) :
m_orientation = PIN_RIGHT; // Pin orient: Up, Down, Left, Right
m_type = PIN_UNSPECIFIED; // electrical type of pin
m_attributes = 0; // bit 0 != 0: pin invisible
m_number = 0; // pin number (i.e. 4 ASCII chars)
m_numTextSize = LIB_EDIT_FRAME::GetPinNumDefaultSize();
m_nameTextSize = LIB_EDIT_FRAME::GetPinNameDefaultSize();
m_width = 0;
@ -211,23 +210,6 @@ void LIB_PIN::SetNameTextSize( int size )
}
void LIB_PIN::SetNumber( const wxString& number )
{
wxString tmp = ( number.IsEmpty() ) ? wxT( "~" ) : number;
tmp.Replace( wxT( " " ), wxT( "_" ) );
long oldNumber = m_number;
SetPinNumFromString( tmp );
if( m_number != oldNumber )
SetFlags( IS_CHANGED );
/* Others pin numbers marked by EnableEditMode() are not modified
* because each pin has its own number
*/
}
void LIB_PIN::SetNumberTextSize( int size )
{
if( size != m_numTextSize )
@ -541,7 +523,6 @@ bool LIB_PIN::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM
bool LIB_PIN::Save( OUTPUTFORMATTER& aFormatter )
{
wxString StringPinNum;
int Etype;
switch( m_type )
@ -592,11 +573,6 @@ bool LIB_PIN::Save( OUTPUTFORMATTER& aFormatter )
break;
}
PinStringNum( StringPinNum );
if( StringPinNum.IsEmpty() )
StringPinNum = wxT( "~" );
if( !m_name.IsEmpty() )
{
if( aFormatter.Print( 0, "X %s", TO_UTF8( m_name ) ) < 0 )
@ -609,7 +585,8 @@ bool LIB_PIN::Save( OUTPUTFORMATTER& aFormatter )
}
if( aFormatter.Print( 0, " %s %d %d %d %c %d %d %d %d %c",
TO_UTF8( StringPinNum ), m_position.x, m_position.y,
TO_UTF8( m_number.IsEmpty() ? wxT( "~" ) : m_number ),
m_position.x, m_position.y,
(int) m_length, (int) m_orientation, m_numTextSize, m_nameTextSize,
m_Unit, m_Convert, Etype ) < 0 )
return false;
@ -716,7 +693,7 @@ bool LIB_PIN::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
// Extract the pinName (UTF8 encoded accepted, but should be only ASCII8.)
tmp = tokenizer.GetNextToken();
SetPinNumFromString( tmp );
SetNumber( tmp );
// Read other parameters, in pure ASCII
char line[1024];
@ -1190,7 +1167,6 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
return;
int x, y;
wxString StringPinNum;
wxSize PinNameSize( m_nameTextSize, m_nameTextSize );
wxSize PinNumSize( m_numTextSize, m_numTextSize );
@ -1218,9 +1194,6 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
COLOR4D NumColor = Color == COLOR4D::UNSPECIFIED ?
GetLayerColor( LAYER_PINNUM ) : Color;
/* Create the pin num string */
PinStringNum( StringPinNum );
int x1 = pin_pos.x;
int y1 = pin_pos.y;
@ -1282,7 +1255,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
DrawGraphicText( clipbox, DC,
wxPoint( (x1 + pin_pos.x) / 2,
y1 - num_offset ), NumColor,
StringPinNum,
m_number,
TEXT_ANGLE_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
@ -1308,7 +1281,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
DrawGraphicText( clipbox, DC,
wxPoint( x1 - num_offset,
(y1 + pin_pos.y) / 2 ), NumColor,
StringPinNum,
m_number,
TEXT_ANGLE_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
@ -1330,7 +1303,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
DrawGraphicText( clipbox, DC,
wxPoint( x1 - num_offset,
(y1 + pin_pos.y) / 2 ), NumColor,
StringPinNum,
m_number,
TEXT_ANGLE_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
@ -1357,7 +1330,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
{
x = (x1 + pin_pos.x) / 2;
DrawGraphicText( clipbox, DC, wxPoint( x, y1 + num_offset ),
NumColor, StringPinNum,
NumColor, m_number,
TEXT_ANGLE_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP, numLineWidth,
@ -1382,7 +1355,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
DrawGraphicText( clipbox, DC,
wxPoint( x1 + num_offset, (y1 + pin_pos.y)
/ 2 ),
NumColor, StringPinNum,
NumColor, m_number,
TEXT_ANGLE_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP, numLineWidth,
@ -1614,11 +1587,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
if( m_name.IsEmpty() || m_name == wxT( "~" ) )
DrawPinName = false;
/* Create the pin num string */
wxString StringPinNum;
PinStringNum( StringPinNum );
if( StringPinNum.IsEmpty() )
if( m_number.IsEmpty() )
DrawPinNum = false;
if( !DrawPinNum && !DrawPinName )
@ -1699,7 +1668,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
{
plotter->Text( wxPoint( (x1 + pin_pos.x) / 2,
y1 - num_offset ),
NumColor, StringPinNum,
NumColor, m_number,
TEXT_ANGLE_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM,
@ -1724,7 +1693,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
{
plotter->Text( wxPoint( x1 - num_offset,
(y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
NumColor, m_number,
TEXT_ANGLE_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM,
@ -1747,7 +1716,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
{
plotter->Text( wxPoint( x1 - num_offset,
(y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
NumColor, m_number,
TEXT_ANGLE_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM,
@ -1776,7 +1745,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
{
x = ( x1 + pin_pos.x ) / 2;
plotter->Text( wxPoint( x, y1 + num_offset ),
NumColor, StringPinNum,
NumColor, m_number,
TEXT_ANGLE_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP,
@ -1800,7 +1769,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
{
plotter->Text( wxPoint( x1 + num_offset,
( y1 + pin_pos.y ) / 2 ),
NumColor, StringPinNum,
NumColor, m_number,
TEXT_ANGLE_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP,
@ -1883,45 +1852,6 @@ int LIB_PIN::PinDrawOrient( const TRANSFORM& aTransform ) const
}
void LIB_PIN::PinStringNum( wxString& aStringBuffer ) const
{
aStringBuffer = PinStringNum( m_number );
}
wxString LIB_PIN::PinStringNum( long aPinNum )
{
char ascii_buf[5];
memcpy( ascii_buf, &aPinNum, 4 );
ascii_buf[4] = 0;
wxString buffer = FROM_UTF8( ascii_buf );
return buffer;
}
void LIB_PIN::SetPinNumFromString( wxString& buffer )
{
char ascii_buf[4];
unsigned ii, len = buffer.Len();
ascii_buf[0] = ascii_buf[1] = ascii_buf[2] = ascii_buf[3] = 0;
if( len > 4 )
len = 4;
for( ii = 0; ii < len; ii++ )
{
ascii_buf[ii] = buffer.GetChar( ii );
ascii_buf[ii] &= 0xFF;
}
strncpy( (char*) &m_number, ascii_buf, 4 );
}
EDA_ITEM* LIB_PIN::Clone() const
{
return new LIB_PIN( *this );
@ -1935,7 +1865,7 @@ int LIB_PIN::compare( const LIB_ITEM& other ) const
const LIB_PIN* tmp = (LIB_PIN*) &other;
if( m_number != tmp->m_number )
return m_number - tmp->m_number;
return m_number.Cmp( tmp->m_number );
int result = m_name.CmpNoCase( tmp->m_name );
@ -2078,17 +2008,12 @@ void LIB_PIN::SetWidth( int aWidth )
void LIB_PIN::getMsgPanelInfoBase( MSG_PANEL_ITEMS& aList )
{
wxString text;
wxString text = m_number.IsEmpty() ? wxT( "?" ) : m_number;
LIB_ITEM::GetMsgPanelInfo( aList );
aList.push_back( MSG_PANEL_ITEM( _( "Name" ), m_name, DARKCYAN ) );
if( m_number == 0 )
text = wxT( "?" );
else
PinStringNum( text );
aList.push_back( MSG_PANEL_ITEM( _( "Number" ), text, DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Type" ),
@ -2161,7 +2086,7 @@ const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles ) const
wxPoint end;
int nameTextOffset = 0;
bool showName = !m_name.IsEmpty() && (m_name != wxT( "~" ));
bool showNum = m_number != 0;
bool showNum = !m_number.IsEmpty();
int minsizeV = TARGET_PIN_RADIUS;
if( !aIncludeInvisibles && !IsVisible() )
@ -2178,7 +2103,7 @@ const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles ) const
}
// First, calculate boundary box corners position
int numberTextLength = showNum ? m_numTextSize * GetNumberString().Len() : 0;
int numberTextLength = showNum ? m_numTextSize * m_number.Len() : 0;
// Actual text height is bigger than text size
int numberTextHeight = showNum ? KiROUND( m_numTextSize * 1.1 ) : 0;
@ -2348,10 +2273,8 @@ wxString LIB_PIN::GetSelectMenuText() const
style = GetText( m_shape );
tmp.Printf( _( "Pin %s, %s, %s" ),
GetChars( GetNumberString() ),
GetChars( GetElectricalTypeName() ),
GetChars( style )
);
GetChars( m_number ), GetChars( GetElectricalTypeName() ), GetChars( style ));
return tmp;
}
@ -2368,11 +2291,10 @@ bool LIB_PIN::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint*
wxLogTrace( traceFindItem, wxT( " child item " ) + GetSelectMenuText() );
if( EDA_ITEM::Matches( GetName(), aSearchData )
|| EDA_ITEM::Matches( GetNumberString(), aSearchData ) )
if( EDA_ITEM::Matches( GetName(), aSearchData ) || EDA_ITEM::Matches( m_number, aSearchData ) )
{
if( aFindLocation )
*aFindLocation = GetBoundingBox().Centre();
*aFindLocation = GetBoundingBox().Centre();
return true;
}
@ -2386,7 +2308,7 @@ bool LIB_PIN::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint*
void LIB_PIN::Show( int nestLevel, std::ostream& os ) const
{
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
<< " num=\"" << GetNumberString().mb_str()
<< " num=\"" << m_number.mb_str()
<< '"' << "/>\n";
// NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";

View File

@ -74,9 +74,7 @@ class LIB_PIN : public LIB_ITEM
ELECTRICAL_PINTYPE m_type; ///< Electrical type of the pin. See enum ELECTRICAL_PINTYPE.
int m_attributes; ///< Set bit 0 to indicate pin is invisible.
wxString m_name;
long m_number; ///< Pin number defined as 4 ASCII characters like "12", "anod",
///< "G6", or "12". It is stored as "12\0\0" and does not
///< depend on endian type.
wxString m_number;
int m_numTextSize;
int m_nameTextSize; ///< Pin num and Pin name sizes
@ -161,36 +159,10 @@ public:
*/
int PinDrawOrient( const TRANSFORM& aTransform ) const;
/**
* Fill a string buffer with pin number.
*
* Pin numbers are coded as a long or 4 ASCII characters. Used to print
* or draw the pin number.
*
* @param aStringBuffer - the wxString to store the pin num as an unicode string
*/
void PinStringNum( wxString& aStringBuffer ) const;
long GetNumber() const { return m_number; }
wxString GetNumberString() const { return PinStringNum( m_number ); }
/**
* Function PinStringNum (static function)
* Pin num is coded as a long or 4 ascii chars
* @param aPinNum = a long containing a pin num
* @return aStringBuffer = the wxString to store the pin num as an
* unicode string
*/
static wxString PinStringNum( long aPinNum );
/**
* Function SetPinNumFromString
* fill the pin number buffer with \a aBuffer.
*/
void SetPinNumFromString( wxString& aBuffer );
wxString GetName() const { return m_name; }
const wxString& GetName() const
{
return m_name;
}
/**
* Set the pin name.
@ -213,6 +185,11 @@ public:
int GetNameTextSize() const { return m_nameTextSize; }
const wxString& GetNumber() const
{
return m_number;
}
/**
* Set the pin number.
*
@ -220,7 +197,10 @@ public:
* because each pin has its own number
* @param aNumber New pin number.
*/
void SetNumber( const wxString& aNumber );
void SetNumber( const wxString& aNumber )
{
m_number = aNumber;
}
/**
* Set the size of the pin number text.

View File

@ -454,7 +454,7 @@ XNODE* NETLIST_EXPORTER_GENERIC::makeLibParts()
XNODE* pin;
pins->AddChild( pin = node( "pin" ) );
pin->AddAttribute( "num", pinList[i]->GetNumberString() );
pin->AddAttribute( "num", pinList[i]->GetNumber() );
pin->AddAttribute( "name", pinList[i]->GetName() );
pin->AddAttribute( "type", pinList[i]->GetCanonicalElectricalTypeName() );
@ -547,5 +547,5 @@ XNODE* NETLIST_EXPORTER_GENERIC::node( const wxString& aName, const wxString& aT
static bool sortPinsByNumber( LIB_PIN* aPin1, LIB_PIN* aPin2 )
{
// return "lhs < rhs"
return RefDesStringCompare( aPin1->GetNumberString(), aPin2->GetNumberString() ) < 0;
return RefDesStringCompare( aPin1->GetNumber(), aPin2->GetNumber() ) < 0;
}

View File

@ -212,7 +212,7 @@ wxString NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal( SPICE_FIELD aField,
aComponent->GetPins( pins );
for( auto pin : pins )
nodeSeq += pin->GetNumberString() + " ";
nodeSeq += pin->GetNumber() + " ";
nodeSeq.Trim();

View File

@ -113,7 +113,7 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
dlg.SetPinNameTextSize( StringFromValue( g_UserUnit, pin->GetNameTextSize() ) );
dlg.SetPinPositionX( StringFromValue( g_UserUnit, pin->GetPosition().x ) );
dlg.SetPinPositionY( StringFromValue( g_UserUnit, -pin->GetPosition().y ) );
dlg.SetPadName( pin->GetNumberString() );
dlg.SetPadName( pin->GetNumber() );
dlg.SetPadNameTextSize( StringFromValue( g_UserUnit, pin->GetNumberTextSize() ) );
dlg.SetLength( StringFromValue( g_UserUnit, pin->GetLength() ) );
@ -520,7 +520,7 @@ void LIB_EDIT_FRAME::CreateImagePins( LIB_PIN* aPin, int aUnit, int aConvert, bo
// it does no have the save pin number as the master pin
// Because we do not know the actual number, give it '??'
wxString unknownNum( wxT( "??" ) );
NewPin->SetPinNumFromString( unknownNum );
NewPin->SetNumber( unknownNum );
if( aConvert != 0 )
NewPin->SetConvert( 1 );
@ -535,7 +535,7 @@ void LIB_EDIT_FRAME::CreateImagePins( LIB_PIN* aPin, int aUnit, int aConvert, bo
NewPin->SetConvert( 2 );
// Gives this pin a new pin number
// Because we do not know the actual number, give it '??'
NewPin->SetPinNumFromString( unknownNum );
NewPin->SetNumber( unknownNum );
if( aPin->GetUnit() != 0 )
NewPin->SetUnit( ii );
@ -643,9 +643,9 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin )
IncrementLabelMember( nextName, GetRepeatDeltaLabel() );
pin->SetName( nextName );
pin->PinStringNum( msg );
msg = pin->GetNumber();
IncrementLabelMember( msg, GetRepeatDeltaLabel() );
pin->SetPinNumFromString( msg );
pin->SetNumber( msg );
m_drawItem = pin;
@ -676,7 +676,7 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin )
// helper function to sort pins by pin num
bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst )
{
int test = ref->GetNumber() - tst->GetNumber();
int test = ref->GetNumber().Cmp( tst->GetNumber() );
if( test == 0 )
{
@ -725,8 +725,6 @@ void LIB_EDIT_FRAME::OnCheckComponent( wxCommandEvent& event )
for( unsigned ii = 1; ii < pinList.size(); ii++ )
{
wxString stringPinNum, stringCurrPinNum;
LIB_PIN* curr_pin = pinList[ii];
LIB_PIN* pin = pinList[ii - 1];
@ -736,20 +734,18 @@ void LIB_EDIT_FRAME::OnCheckComponent( wxCommandEvent& event )
continue;
dup_error++;
pin->PinStringNum( stringPinNum );
/* TODO I dare someone to find a way to make happy translators on
this thing! Lorenzo */
curr_pin->PinStringNum( stringCurrPinNum );
wxString msg = wxString::Format( _(
"<b>Duplicate pin %s</b> \"%s\" at location <b>(%.3f, %.3f)</b>"
" conflicts with pin %s \"%s\" at location <b>(%.3f, %.3f)</b>" ),
GetChars( stringCurrPinNum ),
GetChars( curr_pin->GetNumber() ),
GetChars( curr_pin->GetName() ),
curr_pin->GetPosition().x / 1000.0,
-curr_pin->GetPosition().y / 1000.0,
GetChars( stringPinNum ),
GetChars( pin->GetNumber() ),
GetChars( pin->GetName() ),
pin->GetPosition().x / 1000.0,
-pin->GetPosition().y / 1000.0
@ -786,12 +782,10 @@ void LIB_EDIT_FRAME::OnCheckComponent( wxCommandEvent& event )
// "pin" is off grid here.
offgrid_error++;
wxString stringPinNum;
pin->PinStringNum( stringPinNum );
wxString msg = wxString::Format( _(
"<b>Off grid pin %s</b> \"%s\" at location <b>(%.3f, %.3f)</b>" ),
GetChars( stringPinNum ),
GetChars( pin->GetNumber() ),
GetChars( pin->GetName() ),
pin->GetPosition().x / 1000.0,
-pin->GetPosition().y / 1000.0

View File

@ -3022,7 +3022,7 @@ LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr< LIB_PART >& aPart,
parseUnquotedString( number, aReader, line, &line );
pin->SetName( name );
pin->SetPinNumFromString( number );
pin->SetNumber( number );
wxPoint pos;

View File

@ -642,16 +642,9 @@ bool MODULE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) co
D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const
{
wxString buf;
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
pad->StringPadName( buf );
#if 1
if( buf.CmpNoCase( aPadName ) == 0 ) // why case insensitive?
#else
if( buf == aPadName )
#endif
if( pad->GetPadName().CmpNoCase( aPadName ) == 0 ) // why case insensitive?
return pad;
}
@ -716,7 +709,7 @@ unsigned MODULE::GetPadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
unsigned MODULE::GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
{
std::set<wxUint32> usedNames;
std::set<wxString> usedNames;
// Create a set of used pad numbers
for( D_PAD* pad = PadsList(); pad; pad = pad->Next() )
@ -740,7 +733,7 @@ unsigned MODULE::GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
}
}
usedNames.insert( pad->GetPackedPadName() );
usedNames.insert( pad->GetPadName() );
}
return usedNames.size();

View File

@ -59,7 +59,6 @@ int D_PAD::m_PadSketchModePenSize = 0; // Pen size used to draw pads in ske
D_PAD::D_PAD( MODULE* parent ) :
BOARD_CONNECTED_ITEM( parent, PCB_PAD_T )
{
m_NumPadName = 0;
m_Size.x = m_Size.y = Mils2iu( 60 ); // Default pad size 60 mils.
m_Drill.x = m_Drill.y = Mils2iu( 30 ); // Default drill size 30 mils.
m_Orient = 0; // Pad rotation in 1/10 degrees.
@ -513,48 +512,6 @@ wxPoint D_PAD::ShapePos() const
}
wxString D_PAD::GetPadName() const
{
wxString name;
StringPadName( name );
return name;
}
void D_PAD::StringPadName( wxString& text ) const
{
text.Empty();
for( int ii = 0; ii < PADNAMEZ && m_Padname[ii]; ii++ )
{
// m_Padname is 8 bit KiCad font junk, do not sign extend
text.Append( (unsigned char) m_Padname[ii] );
}
}
// Change pad name
void D_PAD::SetPadName( const wxString& name )
{
int ii, len;
len = name.Length();
if( len > PADNAMEZ )
len = PADNAMEZ;
// m_Padname[] is not UTF8, it is an 8 bit character that matches the KiCad font,
// so only copy the lower 8 bits of each character.
for( ii = 0; ii < len; ii++ )
m_Padname[ii] = (char) name.GetChar( ii );
for( ii = len; ii < PADNAMEZ; ii++ )
m_Padname[ii] = '\0';
}
bool D_PAD::IncrementPadName( bool aSkipUnconnectable, bool aFillSequenceGaps )
{
bool skip = aSkipUnconnectable && ( GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED );
@ -733,10 +690,8 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList )
if( module )
{
wxString msg = module->GetReference();
aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), msg, DARKCYAN ) );
StringPadName( Line );
aList.push_back( MSG_PANEL_ITEM( _( "Pad" ), Line, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), module->GetReference(), DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Pad" ), m_name, BROWN ) );
}
aList.push_back( MSG_PANEL_ITEM( _( "Net" ), GetNetname(), DARKCYAN ) );

View File

@ -162,24 +162,20 @@ public:
/**
* Set the pad name (sometimes called pad number, although
* it can be an array ref like AA12
* the pad name is limited to 4 ASCII chars
* it can be an array reference like AA12).
*/
void SetPadName( const wxString& name ); // Change pad name
void SetPadName( const wxString& aName )
{
m_name = aName;
}
/**
* @return the pad name
* the pad name is limited to 4 ASCII chars
*/
wxString GetPadName() const;
/**
* @return the pad name in a wxUint32 which is possible
* because the pad name is limited to 4 ASCII chars
* The packed pad name should be used only to compare 2
* pad names, not to try to print this name
*/
wxUint32 GetPackedPadName() const { return m_NumPadName; }
const wxString& GetPadName() const
{
return m_name;
}
/**
* Function IncrementPadName
@ -195,7 +191,7 @@ public:
bool PadNameEqual( const D_PAD* other ) const
{
return m_NumPadName == other->m_NumPadName; // hide tricks behind sensible API
return m_name == other->m_name; // hide tricks behind sensible API
}
/**
@ -564,8 +560,6 @@ public:
int BuildSegmentFromOvalShape( wxPoint& aSegStart, wxPoint& aSegEnd,
double aRotation, const wxSize& aMargin ) const;
void StringPadName( wxString& text ) const; // Return pad name as string in a buffer
/**
* Function GetBoundingRadius
* returns the radius of a minimum sized circle which fully encloses this pad.
@ -736,16 +730,7 @@ private: // Private variable members:
// Actually computed and cached on demand by the accessor
mutable int m_boundingRadius; ///< radius of the circle containing the pad shape
#ifndef SWIG
/// Pad name (4 char) or a long identifier (used in pad name
/// comparisons because this is faster than string comparison)
union
{
#define PADNAMEZ 4
char m_Padname[PADNAMEZ]; // zero padded at end to full size
wxUint32 m_NumPadName; // same number of bytes as m_Padname[]
};
#endif
wxString m_name;
wxPoint m_Pos; ///< pad Position on board

View File

@ -669,20 +669,16 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
* chars. Of course, pads numbers and nets names can have less than 3
* chars. but after some tries, i found this is gives the best look
*/
#define MIN_CHAR_COUNT 3
wxString buffer;
constexpr int MIN_CHAR_COUNT = 3;
int tsize;
unsigned int tsize;
EDA_RECT* clipBox = aDrawInfo.m_DrawPanel?
aDrawInfo.m_DrawPanel->GetClipBox() : NULL;
if( aDrawInfo.m_Display_padnum )
{
StringPadName( buffer );
int numpad_len = buffer.Len();
numpad_len = std::max( numpad_len, MIN_CHAR_COUNT );
tsize = std::min( AreaSize.y, AreaSize.x / numpad_len );
int numpad_len = std::max( (int) m_name.Length(), MIN_CHAR_COUNT );
tsize = std::min( (int) AreaSize.y, AreaSize.x / numpad_len );
if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE ) // Not drawable when size too small.
{
@ -690,7 +686,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
tsize = ( tsize * 7 ) / 10;
DrawGraphicHaloText( clipBox, aDC, tpos,
aDrawInfo.m_Color, BLACK, WHITE,
buffer, t_angle,
m_name, t_angle,
wxSize( tsize , tsize ), GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false );

View File

@ -1513,9 +1513,7 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad )
aPad->SetOffset( wxPoint( x, y ) );
aPad->SetOrientation( m_OrientValue * 10.0 );
msg = m_PadNumCtrl->GetValue().Left( 4 );
aPad->SetPadName( msg );
aPad->SetPadName( m_PadNumCtrl->GetValue() );
// Check if user has set an existing net name
const NETINFO_ITEM* netinfo = m_board->FindNet( m_PadNetNameCtrl->GetValue() );

View File

@ -128,8 +128,8 @@ static void build_pad_testpoints( BOARD *aPcb,
if( rk.access != -1 )
{
rk.netname = pad->GetNetname();
rk.pin = pad->GetPadName();
rk.refdes = module->GetReference();
pad->StringPadName( rk.pin );
rk.midpoint = false; // XXX MAYBE need to be computed (how?)
const wxSize& drill = pad->GetDrillSize();
rk.drill = std::min( drill.x, drill.y );

View File

@ -660,7 +660,7 @@ static void CreateShapesSection( FILE* aFile, BOARD* aPcb )
layer = module->GetFlag() ? "BOTTOM" : "TOP";
}
pad->StringPadName( pinname );
pinname = pad->GetPadName();
if( pinname.IsEmpty() )
pinname = wxT( "none" );
@ -796,15 +796,12 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb )
{
for( pad = module->PadsList(); pad; pad = pad->Next() )
{
wxString padname;
if( pad->GetNetCode() != net->GetNet() )
continue;
pad->StringPadName( padname );
msg.Printf( wxT( "NODE %s %s" ),
GetChars( module->GetReference() ),
GetChars( padname ) );
GetChars( pad->GetPadName() ) );
fputs( TO_UTF8( msg ), aFile );
fputs( "\n", aFile );

View File

@ -548,7 +548,6 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
PAD_SHAPE_T shape;
double m, n;
double orientation = aPad->GetOrientation();
wxString buffer;
// Draw description layer
if( IsNetnameLayer( aLayer ) )
@ -624,10 +623,9 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
if( m_pcbSettings.m_padNumbers )
{
const wxString& padName = aPad->GetPadName();
textpos.y = -textpos.y;
aPad->StringPadName( buffer );
int len = buffer.Length();
double tsize = 1.5 * padsize.x / len;
double tsize = 1.5 * padsize.x / padName.Length();
tsize = std::min( tsize, size );
// Use a smaller text size to handle interline, pen size..
tsize *= 0.7;
@ -636,7 +634,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
m_gal->SetGlyphSize( numsize );
m_gal->SetLineWidth( numsize.x / 12.0 );
m_gal->BitmapText( aPad->GetPadName(), textpos, 0.0 );
m_gal->BitmapText( padName, textpos, 0.0 );
}
m_gal->Restore();