pcad2kicadpcb_plugin: prepend numerical Ref with '.'

Kicad (EESchema) doesn't support only numerical references (like '1').
Prepend with '.' same references (convert reference '1' to '.1').
This commit is contained in:
Eldar Khayrullin 2017-12-10 11:12:10 +03:00 committed by Maciej Suminski
parent 21ddb2d989
commit 897702b2dc
3 changed files with 15 additions and 1 deletions

View File

@ -29,6 +29,7 @@
#include <wx/wx.h>
#include <wx/config.h>
#include <wx/regex.h>
#include <common.h>
#include <convert_to_biu.h>
@ -225,6 +226,18 @@ wxString ValidateName( wxString aName )
}
wxString ValidateReference( wxString aRef )
{
wxRegEx reRef;
reRef.Compile( wxT( "^[[:digit:]][[:digit:]]*$" ) );
if( reRef.Matches( aRef ) )
aRef.Prepend( wxT( '.' ) );
return aRef;
}
void SetWidth( wxString aStr,
wxString aDefaultMeasurementUnit,
int* aWidth,

View File

@ -71,6 +71,7 @@ extern wxString GetAndCutWordWithMeasureUnits( wxString* aStr,
wxString aDefaultMeasurementUnit );
extern int StrToInt1Units( wxString aStr );
extern wxString ValidateName( wxString aName );
extern wxString ValidateReference( wxString aRef );
extern void SetWidth( wxString aStr,
wxString aDefaultMeasurementUnit,
int* aWidth,

View File

@ -526,7 +526,7 @@ void PCB_MODULE::AddToBoard()
// reference text
TEXTE_MODULE* ref_text = &module->Reference();
ref_text->SetText( m_name.text );
ref_text->SetText( ValidateReference( m_name.text ) );
ref_text->SetType( TEXTE_MODULE::TEXT_is_REFERENCE );
ref_text->SetPos0( wxPoint( m_name.correctedPositionX, m_name.correctedPositionY ) );