bitmap2component: update format of all generated files.
Especially, the .kicad_sym is now used. Fixes #8937 https://gitlab.com/kicad/code/kicad/issues/8937
This commit is contained in:
parent
a208dac8d8
commit
c327768a93
|
@ -724,7 +724,7 @@ void BM2CMP_FRAME::exportBitmap( OUTPUT_FMT_ID aFormat )
|
||||||
exportPostScriptFormat();
|
exportPostScriptFormat();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KICAD_LOGO:
|
case KICAD_WKS_LOGO:
|
||||||
OnExportLogo();
|
OnExportLogo();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -762,7 +762,7 @@ void BM2CMP_FRAME::OnExportLogo()
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
ExportToBuffer( buffer, KICAD_LOGO );
|
ExportToBuffer( buffer, KICAD_WKS_LOGO );
|
||||||
fputs( buffer.c_str(), outfile );
|
fputs( buffer.c_str(), outfile );
|
||||||
fclose( outfile );
|
fclose( outfile );
|
||||||
}
|
}
|
||||||
|
@ -818,7 +818,7 @@ void BM2CMP_FRAME::exportEeschemaFormat()
|
||||||
|
|
||||||
wxFileDialog fileDlg( this, _( "Create Symbol Library" ),
|
wxFileDialog fileDlg( this, _( "Create Symbol Library" ),
|
||||||
path, wxEmptyString,
|
path, wxEmptyString,
|
||||||
LegacySymbolLibFileWildcard(),
|
KiCadSymbolLibFileWildcard(),
|
||||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
||||||
|
|
||||||
int diag = fileDlg.ShowModal();
|
int diag = fileDlg.ShowModal();
|
||||||
|
@ -827,7 +827,7 @@ void BM2CMP_FRAME::exportEeschemaFormat()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fn = fileDlg.GetPath();
|
fn = fileDlg.GetPath();
|
||||||
fn.SetExt( LegacySymbolLibFileExtension );
|
fn.SetExt( KiCadSymbolLibFileExtension );
|
||||||
m_ConvertedFileName = fn.GetFullPath();
|
m_ConvertedFileName = fn.GetFullPath();
|
||||||
|
|
||||||
FILE* outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) );
|
FILE* outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) );
|
||||||
|
|
|
@ -118,8 +118,8 @@ int BITMAPCONV_INFO::ConvertBitmap( potrace_bitmap_t* aPotrace_bitmap, OUTPUT_FM
|
||||||
|
|
||||||
switch( aFormat )
|
switch( aFormat )
|
||||||
{
|
{
|
||||||
case KICAD_LOGO:
|
case KICAD_WKS_LOGO:
|
||||||
m_Format = KICAD_LOGO;
|
m_Format = KICAD_WKS_LOGO;
|
||||||
m_ScaleX = PL_IU_PER_MM * 25.4 / aDpi_X; // the conversion scale from PPI to micron
|
m_ScaleX = PL_IU_PER_MM * 25.4 / aDpi_X; // the conversion scale from PPI to micron
|
||||||
m_ScaleY = PL_IU_PER_MM * 25.4 / aDpi_Y; // Y axis is top to bottom
|
m_ScaleY = PL_IU_PER_MM * 25.4 / aDpi_Y; // Y axis is top to bottom
|
||||||
createOutputData();
|
createOutputData();
|
||||||
|
@ -136,8 +136,8 @@ int BITMAPCONV_INFO::ConvertBitmap( potrace_bitmap_t* aPotrace_bitmap, OUTPUT_FM
|
||||||
|
|
||||||
case EESCHEMA_FMT:
|
case EESCHEMA_FMT:
|
||||||
m_Format = EESCHEMA_FMT;
|
m_Format = EESCHEMA_FMT;
|
||||||
m_ScaleX = 1000.0 / aDpi_X; // the conversion scale from PPI to legacy IU (mil)
|
m_ScaleX = SCH_IU_PER_MM * 25.4 / aDpi_X; // the conversion scale from PPI to eeschema iu
|
||||||
m_ScaleY = -1000.0 / aDpi_Y; // Y axis is bottom to Top for components in libs
|
m_ScaleY = -SCH_IU_PER_MM * 25.4 / aDpi_Y; // Y axis is bottom to Top for components in libs
|
||||||
createOutputData();
|
createOutputData();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -190,8 +190,8 @@ const char* BITMAPCONV_INFO::getBoardLayerName( BMP2CMP_MOD_LAYER aChoice )
|
||||||
|
|
||||||
void BITMAPCONV_INFO::outputDataHeader( const char * aBrdLayerName )
|
void BITMAPCONV_INFO::outputDataHeader( const char * aBrdLayerName )
|
||||||
{
|
{
|
||||||
int Ypos = (int) ( m_PixmapHeight / 2 * m_ScaleY );
|
double Ypos = ( m_PixmapHeight / 2 * m_ScaleY ); // fields Y position in mm
|
||||||
int fieldSize; // fields text size = 60 mils
|
double fieldSize; // fields text size in mm
|
||||||
char strbuf[1024];
|
char strbuf[1024];
|
||||||
|
|
||||||
switch( m_Format )
|
switch( m_Format )
|
||||||
|
@ -207,7 +207,8 @@ void BITMAPCONV_INFO::outputDataHeader( const char * aBrdLayerName )
|
||||||
case PCBNEW_KICAD_MOD:
|
case PCBNEW_KICAD_MOD:
|
||||||
// fields text size = 1.5 mm
|
// fields text size = 1.5 mm
|
||||||
// fields text thickness = 1.5 / 5 = 0.3mm
|
// fields text thickness = 1.5 / 5 = 0.3mm
|
||||||
sprintf( strbuf, "(module %s (layer F.Cu)\n (at 0 0)\n", m_CmpName.c_str() );
|
sprintf( strbuf, "(footprint \"%s\" (version 20210606) (generator bitmap2component) "
|
||||||
|
"(layer \"F.Cu\")\n (at 0 0)\n", m_CmpName.c_str() );
|
||||||
m_Data += strbuf;
|
m_Data += strbuf;
|
||||||
sprintf( strbuf, "(attr board_only exclude_from_pos_files exclude_from_bom)\n");
|
sprintf( strbuf, "(attr board_only exclude_from_pos_files exclude_from_bom)\n");
|
||||||
m_Data += strbuf;
|
m_Data += strbuf;
|
||||||
|
@ -219,28 +220,43 @@ void BITMAPCONV_INFO::outputDataHeader( const char * aBrdLayerName )
|
||||||
m_Data += strbuf;
|
m_Data += strbuf;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KICAD_LOGO:
|
case KICAD_WKS_LOGO:
|
||||||
m_Data += "(polygon (pos 0 0 rbcorner) (rotate 0) (linewidth 0.01)\n";
|
m_Data += "(kicad_wks (version 20210606) (generator bitmap2component)\n";
|
||||||
|
m_Data += " (polygon (pos 0 0 rbcorner) (rotate 0) (linewidth 0.01)\n";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EESCHEMA_FMT:
|
case EESCHEMA_FMT:
|
||||||
sprintf( strbuf, "EESchema-LIBRARY Version 2.3\n" );
|
fieldSize = 1.27; // fields text size in mm (= 50 mils)
|
||||||
m_Data += strbuf;
|
Ypos /= SCH_IU_PER_MM;
|
||||||
sprintf( strbuf, "#\n# %s\n", m_CmpName.c_str() );
|
Ypos += fieldSize / 2;
|
||||||
m_Data += strbuf;
|
// sprintf( strbuf, "# pixmap size w = %d, h = %d\n#\n", m_PixmapWidth, m_PixmapHeight );
|
||||||
sprintf( strbuf, "# pixmap size w = %d, h = %d\n#\n", m_PixmapWidth, m_PixmapHeight );
|
sprintf( strbuf, "(kicad_symbol_lib (version 20210619) (generator bitmap2component)\n"
|
||||||
|
" (symbol \"%s\" (pin_names (offset 1.016)) (in_bom yes) (on_board yes)\n",
|
||||||
|
m_CmpName.c_str() );
|
||||||
m_Data += strbuf;
|
m_Data += strbuf;
|
||||||
|
|
||||||
// print reference and value
|
sprintf( strbuf, " (property \"Reference\" \"#G\" (id 0) (at 0 %g 0)\n"
|
||||||
fieldSize = 50; // fields text size = 50 mils
|
" (effects (font (size %g %g)) hide)\n )\n",
|
||||||
Ypos += fieldSize / 2;
|
-Ypos, fieldSize, fieldSize );
|
||||||
sprintf( strbuf, "DEF %s G 0 40 Y Y 1 F N\n", m_CmpName.c_str() );
|
|
||||||
m_Data += strbuf;
|
m_Data += strbuf;
|
||||||
sprintf( strbuf, "F0 \"#G\" 0 %d %d H I C CNN\n", Ypos, fieldSize );
|
|
||||||
|
sprintf( strbuf, " (property \"Value\" \"%s\" (id 1) (at 0 %g 0)\n"
|
||||||
|
" (effects (font (size %g %g)) hide)\n )\n",
|
||||||
|
m_CmpName.c_str(), Ypos, fieldSize, fieldSize );
|
||||||
m_Data += strbuf;
|
m_Data += strbuf;
|
||||||
sprintf( strbuf, "F1 \"%s\" 0 %d %d H I C CNN\n", m_CmpName.c_str(), -Ypos, fieldSize );
|
|
||||||
|
sprintf( strbuf, " (property \"Footprint\" \"\" (id 2) (at 0 0 0)\n"
|
||||||
|
" (effects (font (size %g %g)) hide)\n )\n",
|
||||||
|
fieldSize, fieldSize );
|
||||||
|
m_Data += strbuf;
|
||||||
|
|
||||||
|
sprintf( strbuf, " (property \"Datasheet\" \"\" (id 3) (at 0 0 0)\n"
|
||||||
|
" (effects (font (size %g %g)) hide)\n )\n",
|
||||||
|
fieldSize, fieldSize );
|
||||||
|
m_Data += strbuf;
|
||||||
|
|
||||||
|
sprintf( strbuf, " (symbol \"%s_0_0\"\n", m_CmpName.c_str() );
|
||||||
m_Data += strbuf;
|
m_Data += strbuf;
|
||||||
m_Data += "DRAW\n";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,13 +275,14 @@ void BITMAPCONV_INFO::outputDataEnd()
|
||||||
m_Data += ")\n";
|
m_Data += ")\n";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KICAD_LOGO:
|
case KICAD_WKS_LOGO:
|
||||||
m_Data += ")\n";
|
m_Data += " )\n)\n";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EESCHEMA_FMT:
|
case EESCHEMA_FMT:
|
||||||
m_Data += "ENDDRAW\n";
|
m_Data += " )\n"; // end symbol_0_0
|
||||||
m_Data += "ENDDEF\n";
|
m_Data += " )\n"; // end symbol
|
||||||
|
m_Data += ")\n"; // end lib
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,7 +354,7 @@ void BITMAPCONV_INFO::outputOnePolygon( SHAPE_LINE_CHAIN& aPolygon, const char*
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KICAD_LOGO:
|
case KICAD_WKS_LOGO:
|
||||||
m_Data += " (pts";
|
m_Data += " (pts";
|
||||||
|
|
||||||
// Internal units = micron, file unit = mm
|
// Internal units = micron, file unit = mm
|
||||||
|
@ -366,24 +383,31 @@ void BITMAPCONV_INFO::outputOnePolygon( SHAPE_LINE_CHAIN& aPolygon, const char*
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EESCHEMA_FMT:
|
case EESCHEMA_FMT:
|
||||||
// The polygon outline thickness is fixed here to 1 mil, the minimal
|
// The polygon outline thickness is fixed here to 0.01 ( 0.0 is the default thickness)
|
||||||
// value in Eeschema (0 means use default thickness for graphics)
|
#define SCH_LINE_THICKNESS_MM 0.01
|
||||||
#define EE_LINE_THICKNESS 1
|
//sprintf( strbuf, "P %d 0 0 %d", (int) aPolygon.PointCount() + 1, EE_LINE_THICKNESS );
|
||||||
sprintf( strbuf, "P %d 0 0 %d", (int) aPolygon.PointCount() + 1, EE_LINE_THICKNESS );
|
m_Data += " (polyline\n (pts\n";
|
||||||
m_Data += strbuf;
|
|
||||||
|
|
||||||
for( ii = 0; ii < aPolygon.PointCount(); ii++ )
|
for( ii = 0; ii < aPolygon.PointCount(); ii++ )
|
||||||
{
|
{
|
||||||
currpoint = aPolygon.CPoint( ii );
|
currpoint = aPolygon.CPoint( ii );
|
||||||
sprintf( strbuf, " %d %d", currpoint.x - offsetX, currpoint.y - offsetY );
|
sprintf( strbuf, " (xy %f %f)\n",
|
||||||
|
( currpoint.x - offsetX ) / SCH_IU_PER_MM,
|
||||||
|
( currpoint.y - offsetY ) / SCH_IU_PER_MM );
|
||||||
m_Data += strbuf;
|
m_Data += strbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close polygon
|
// Close polygon
|
||||||
sprintf( strbuf, " %d %d", startpoint.x - offsetX, startpoint.y - offsetY );
|
sprintf( strbuf, " (xy %f %f)\n",
|
||||||
|
( startpoint.x - offsetX ) / SCH_IU_PER_MM,
|
||||||
|
( startpoint.y - offsetY ) / SCH_IU_PER_MM );
|
||||||
m_Data += strbuf;
|
m_Data += strbuf;
|
||||||
|
m_Data += " )\n"; // end pts
|
||||||
|
|
||||||
m_Data += " F\n";
|
sprintf( strbuf, " (stroke (width %g)) (fill (type outline))\n",
|
||||||
|
SCH_LINE_THICKNESS_MM );
|
||||||
|
m_Data += strbuf;
|
||||||
|
m_Data += " )\n"; // end polyline
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@ enum OUTPUT_FMT_ID
|
||||||
EESCHEMA_FMT = 0,
|
EESCHEMA_FMT = 0,
|
||||||
PCBNEW_KICAD_MOD,
|
PCBNEW_KICAD_MOD,
|
||||||
POSTSCRIPT_FMT,
|
POSTSCRIPT_FMT,
|
||||||
KICAD_LOGO,
|
KICAD_WKS_LOGO,
|
||||||
FINAL_FMT = KICAD_LOGO
|
FINAL_FMT = KICAD_WKS_LOGO
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BMP2CMP_MOD_LAYER
|
enum BMP2CMP_MOD_LAYER
|
||||||
|
|
Loading…
Reference in New Issue