minor
This commit is contained in:
parent
74ccc4b558
commit
d5a1736346
|
@ -388,7 +388,6 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
|
||||||
bool saveok = true;
|
bool saveok = true;
|
||||||
FILE* dest;
|
|
||||||
|
|
||||||
if( aFileName == wxEmptyString )
|
if( aFileName == wxEmptyString )
|
||||||
{
|
{
|
||||||
|
@ -447,7 +446,10 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the file */
|
#if !defined(USE_NEW_PCBNEW_SAVE)
|
||||||
|
|
||||||
|
// Create the file
|
||||||
|
FILE* dest;
|
||||||
dest = wxFopen( pcbFileName.GetFullPath(), wxT( "wt" ) );
|
dest = wxFopen( pcbFileName.GetFullPath(), wxT( "wt" ) );
|
||||||
|
|
||||||
if( dest == 0 )
|
if( dest == 0 )
|
||||||
|
@ -466,6 +468,24 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
|
||||||
fclose( dest );
|
fclose( dest );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IO_MGR::Save( IO_MGR::KICAD, pcbFileName.GetFullPath(), GetBoard(), NULL ); // overload
|
||||||
|
}
|
||||||
|
catch( IO_ERROR ioe )
|
||||||
|
{
|
||||||
|
wxString msg = wxString::Format( _( "Error loading board.\n%s" ),
|
||||||
|
ioe.errorText.GetData() );
|
||||||
|
|
||||||
|
wxMessageBox( msg, _( "Save Board File" ), wxICON_ERROR );
|
||||||
|
|
||||||
|
saveok = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Display the file names: */
|
/* Display the file names: */
|
||||||
m_messagePanel->EraseMsgBox();
|
m_messagePanel->EraseMsgBox();
|
||||||
|
|
||||||
|
@ -481,7 +501,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
|
||||||
upperTxt = _( "Backup file: " ) + backupFileName.GetFullPath();
|
upperTxt = _( "Backup file: " ) + backupFileName.GetFullPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( dest )
|
if( saveok )
|
||||||
lowerTxt = _( "Wrote board file: " );
|
lowerTxt = _( "Wrote board file: " );
|
||||||
else
|
else
|
||||||
lowerTxt = _( "Failed to create " );
|
lowerTxt = _( "Failed to create " );
|
||||||
|
|
|
@ -1160,7 +1160,7 @@ int PCB_EDIT_FRAME::SavePcbFormatAscii( FILE* aFile )
|
||||||
|
|
||||||
// Switch the locale to standard C (needed to print floating point numbers
|
// Switch the locale to standard C (needed to print floating point numbers
|
||||||
// like 1.3)
|
// like 1.3)
|
||||||
SetLocaleTo_C_standard();
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
/* Writing file header. */
|
/* Writing file header. */
|
||||||
fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", BOARD_FILE_VERSION,
|
fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", BOARD_FILE_VERSION,
|
||||||
|
@ -1179,7 +1179,6 @@ int PCB_EDIT_FRAME::SavePcbFormatAscii( FILE* aFile )
|
||||||
|
|
||||||
rc = GetBoard()->Save( aFile );
|
rc = GetBoard()->Save( aFile );
|
||||||
|
|
||||||
SetLocaleTo_Default(); // revert to the current locale
|
|
||||||
wxEndBusyCursor();
|
wxEndBusyCursor();
|
||||||
|
|
||||||
if( !rc )
|
if( !rc )
|
||||||
|
|
|
@ -1695,7 +1695,7 @@ void KICAD_PLUGIN::loadPCB_TEXT()
|
||||||
size.x = biuParse( data, &data );
|
size.x = biuParse( data, &data );
|
||||||
size.y = biuParse( data, &data );
|
size.y = biuParse( data, &data );
|
||||||
BIU thickn = biuParse( data, &data );
|
BIU thickn = biuParse( data, &data );
|
||||||
int orient = intParse( data );
|
double angle = degParse( data );
|
||||||
|
|
||||||
// Ensure the text has minimal size to see this text on screen:
|
// Ensure the text has minimal size to see this text on screen:
|
||||||
|
|
||||||
|
@ -1715,7 +1715,7 @@ void KICAD_PLUGIN::loadPCB_TEXT()
|
||||||
pcbtxt->SetSize( size );
|
pcbtxt->SetSize( size );
|
||||||
|
|
||||||
pcbtxt->SetThickness( thickn );
|
pcbtxt->SetThickness( thickn );
|
||||||
pcbtxt->SetOrientation( orient );
|
pcbtxt->SetOrientation( angle );
|
||||||
|
|
||||||
pcbtxt->SetPosition( wxPoint( pos_x, pos_y ) );
|
pcbtxt->SetPosition( wxPoint( pos_x, pos_y ) );
|
||||||
}
|
}
|
||||||
|
@ -2667,7 +2667,7 @@ void KICAD_PLUGIN::saveBOARD() const
|
||||||
savePCB_TEXT( (TEXTE_PCB*) gr );
|
savePCB_TEXT( (TEXTE_PCB*) gr );
|
||||||
break;
|
break;
|
||||||
case PCB_LINE_T:
|
case PCB_LINE_T:
|
||||||
saveMODULE_EDGE( (EDGE_MODULE*) gr );
|
savePCB_LINE( (DRAWSEGMENT*) gr );
|
||||||
break;
|
break;
|
||||||
case PCB_TARGET_T:
|
case PCB_TARGET_T:
|
||||||
savePCB_TARGET( (PCB_TARGET*) gr );
|
savePCB_TARGET( (PCB_TARGET*) gr );
|
||||||
|
@ -2717,8 +2717,7 @@ void KICAD_PLUGIN::saveNETINFO_ITEM( const NETINFO_ITEM* aNet ) const
|
||||||
|
|
||||||
void KICAD_PLUGIN::saveNETCLASSES() const
|
void KICAD_PLUGIN::saveNETCLASSES() const
|
||||||
{
|
{
|
||||||
// @todo make m_NetClasses private
|
const NETCLASSES& nc = m_board->m_NetClasses;
|
||||||
NETCLASSES nc = m_board->m_NetClasses;
|
|
||||||
|
|
||||||
// save the default first.
|
// save the default first.
|
||||||
saveNETCLASS( nc.GetDefault() );
|
saveNETCLASS( nc.GetDefault() );
|
||||||
|
@ -2768,17 +2767,23 @@ void KICAD_PLUGIN::saveMODULE_TEXT( const TEXTE_MODULE* me ) const
|
||||||
if( parent )
|
if( parent )
|
||||||
orient += parent->GetOrientation();
|
orient += parent->GetOrientation();
|
||||||
|
|
||||||
|
wxString txt = me->GetText();
|
||||||
|
|
||||||
fprintf( m_fp, "T%d %s %s %g %s %c %c %d %c %s\n",
|
fprintf( m_fp, "T%d %s %s %g %s %c %c %d %c %s\n",
|
||||||
me->GetType(),
|
me->GetType(),
|
||||||
fmtBIUPoint( me->GetPos0() ).c_str(), // m_Pos0.x, m_Pos0.y,
|
fmtBIUPoint( me->GetPos0() ).c_str(), // m_Pos0.x, m_Pos0.y,
|
||||||
|
#if 0
|
||||||
fmtBIUSize( me->GetSize() ).c_str(), // m_Size.y, m_Size.x,
|
fmtBIUSize( me->GetSize() ).c_str(), // m_Size.y, m_Size.x,
|
||||||
|
#else
|
||||||
|
fmtBIUPair( me->GetSize().y, me->GetSize().x ).c_str(), // m_Size.y, m_Size.x,
|
||||||
|
#endif
|
||||||
orient,
|
orient,
|
||||||
fmtBIU( me->GetThickness() ).c_str(), // m_Thickness,
|
fmtBIU( me->GetThickness() ).c_str(), // m_Thickness,
|
||||||
me->IsMirrored() ? 'M' : 'N',
|
me->IsMirrored() ? 'M' : 'N',
|
||||||
me->IsVisible() ? 'V' : 'I',
|
me->IsVisible() ? 'V' : 'I',
|
||||||
me->GetLayer(),
|
me->GetLayer(),
|
||||||
me->IsItalic() ? 'I' : 'N',
|
me->IsItalic() ? 'I' : 'N',
|
||||||
EscapedUTF8( me->GetText() ).c_str()
|
EscapedUTF8( txt ).c_str()
|
||||||
);
|
);
|
||||||
|
|
||||||
CHECK_WRITE_ERROR();
|
CHECK_WRITE_ERROR();
|
||||||
|
@ -2806,16 +2811,12 @@ void KICAD_PLUGIN::saveMODULE_EDGE( const EDGE_MODULE* me ) const
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_ARC:
|
case S_ARC:
|
||||||
{
|
|
||||||
double angle = me->GetAngle();
|
|
||||||
|
|
||||||
fprintf( m_fp, "DA %s %s %g %s %d\n",
|
fprintf( m_fp, "DA %s %s %g %s %d\n",
|
||||||
fmtBIUPoint( me->m_Start0 ).c_str(),
|
fmtBIUPoint( me->m_Start0 ).c_str(),
|
||||||
fmtBIUPoint( me->m_End0 ).c_str(),
|
fmtBIUPoint( me->m_End0 ).c_str(),
|
||||||
angle,
|
me->GetAngle(),
|
||||||
fmtBIU( me->GetWidth() ).c_str(),
|
fmtBIU( me->GetWidth() ).c_str(),
|
||||||
me->GetLayer() );
|
me->GetLayer() );
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_POLYGON:
|
case S_POLYGON:
|
||||||
|
@ -2868,8 +2869,7 @@ void KICAD_PLUGIN::savePAD( const D_PAD* me ) const
|
||||||
|
|
||||||
fprintf( m_fp, "Dr %s %s",
|
fprintf( m_fp, "Dr %s %s",
|
||||||
fmtBIU( me->GetDrillSize().x ).c_str(),
|
fmtBIU( me->GetDrillSize().x ).c_str(),
|
||||||
fmtBIUSize( me->GetOffset() ).c_str()
|
fmtBIUSize( me->GetOffset() ).c_str() );
|
||||||
);
|
|
||||||
|
|
||||||
if( me->GetDrillShape() == PAD_OVAL )
|
if( me->GetDrillShape() == PAD_OVAL )
|
||||||
{
|
{
|
||||||
|
@ -2891,7 +2891,7 @@ void KICAD_PLUGIN::savePAD( const D_PAD* me ) const
|
||||||
THROW_IO_ERROR( wxString::Format( UNKNOWN_PAD_ATTRIBUTE, me->GetAttribute() ) );
|
THROW_IO_ERROR( wxString::Format( UNKNOWN_PAD_ATTRIBUTE, me->GetAttribute() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( m_fp, "At %s N %8.8X\n", texttype, me->GetLayerMask() );
|
fprintf( m_fp, "At %s N %X\n", texttype, me->GetLayerMask() );
|
||||||
|
|
||||||
fprintf( m_fp, "Ne %d %s\n", me->GetNet(), EscapedUTF8( me->GetNetname() ).c_str() );
|
fprintf( m_fp, "Ne %d %s\n", me->GetNet(), EscapedUTF8( me->GetNetname() ).c_str() );
|
||||||
|
|
||||||
|
@ -2925,19 +2925,11 @@ void KICAD_PLUGIN::saveMODULE( const MODULE* me ) const
|
||||||
|
|
||||||
fprintf( m_fp, "$MODULE %s\n", TO_UTF8( me->GetLibRef() ) );
|
fprintf( m_fp, "$MODULE %s\n", TO_UTF8( me->GetLibRef() ) );
|
||||||
|
|
||||||
if( me->IsLocked() )
|
statusTxt[0] = me->IsLocked() ? 'F' : '~';
|
||||||
statusTxt[0] = 'F';
|
statusTxt[1] = me->IsPlaced() ? 'P' : '~';
|
||||||
else
|
|
||||||
statusTxt[0] = '~';
|
|
||||||
|
|
||||||
if( me->IsPlaced() )
|
|
||||||
statusTxt[1] = 'P';
|
|
||||||
else
|
|
||||||
statusTxt[1] = '~';
|
|
||||||
|
|
||||||
statusTxt[2] = '\0';
|
statusTxt[2] = '\0';
|
||||||
|
|
||||||
fprintf( m_fp, "Po %s %g %d %8lX %8lX %s\n",
|
fprintf( m_fp, "Po %s %g %d %lX %lX %s\n",
|
||||||
fmtBIUPoint( me->GetPosition() ).c_str(), // m_Pos.x, m_Pos.y,
|
fmtBIUPoint( me->GetPosition() ).c_str(), // m_Pos.x, m_Pos.y,
|
||||||
orient,
|
orient,
|
||||||
me->GetLayer(),
|
me->GetLayer(),
|
||||||
|
@ -2957,7 +2949,7 @@ void KICAD_PLUGIN::saveMODULE( const MODULE* me ) const
|
||||||
fprintf( m_fp, "Kw %s\n", TO_UTF8( me->GetKeywords() ) );
|
fprintf( m_fp, "Kw %s\n", TO_UTF8( me->GetKeywords() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( m_fp, "Sc %8lX\n", me->GetTimeStamp() );
|
fprintf( m_fp, "Sc %lX\n", me->GetTimeStamp() );
|
||||||
fprintf( m_fp, "AR %s\n", TO_UTF8( me->GetPath() ) );
|
fprintf( m_fp, "AR %s\n", TO_UTF8( me->GetPath() ) );
|
||||||
fprintf( m_fp, "Op %X %X 0\n", me->m_CntRot90, me->m_CntRot180 );
|
fprintf( m_fp, "Op %X %X 0\n", me->m_CntRot90, me->m_CntRot180 );
|
||||||
|
|
||||||
|
@ -2987,23 +2979,23 @@ void KICAD_PLUGIN::saveMODULE( const MODULE* me ) const
|
||||||
fprintf( m_fp, "\n" );
|
fprintf( m_fp, "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
saveMODULE_TEXT( (TEXTE_MODULE*) &me->m_Reference );
|
saveMODULE_TEXT( me->m_Reference );
|
||||||
|
|
||||||
saveMODULE_TEXT( (TEXTE_MODULE*) &me->m_Value );
|
saveMODULE_TEXT( me->m_Value );
|
||||||
|
|
||||||
// save drawing elements
|
// save drawing elements
|
||||||
for( BOARD_ITEM* item = me->m_Drawings; item; item = item->Next() )
|
for( BOARD_ITEM* gr = me->m_Drawings; gr; gr = gr->Next() )
|
||||||
{
|
{
|
||||||
switch( item->Type() )
|
switch( gr->Type() )
|
||||||
{
|
{
|
||||||
case PCB_MODULE_TEXT_T:
|
case PCB_MODULE_TEXT_T:
|
||||||
saveMODULE_TEXT( (TEXTE_MODULE*) item );
|
saveMODULE_TEXT( (TEXTE_MODULE*) gr );
|
||||||
break;
|
break;
|
||||||
case PCB_MODULE_EDGE_T:
|
case PCB_MODULE_EDGE_T:
|
||||||
saveMODULE_EDGE( (EDGE_MODULE*) item );
|
saveMODULE_EDGE( (EDGE_MODULE*) gr );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
THROW_IO_ERROR( wxString::Format( UNKNOWN_GRAPHIC_FORMAT, item->Type() ) );
|
THROW_IO_ERROR( wxString::Format( UNKNOWN_GRAPHIC_FORMAT, gr->Type() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3053,7 +3045,7 @@ void KICAD_PLUGIN::savePCB_TARGET( const PCB_TARGET* me ) const
|
||||||
{
|
{
|
||||||
fprintf( m_fp, "$PCB_TARGET\n" );
|
fprintf( m_fp, "$PCB_TARGET\n" );
|
||||||
|
|
||||||
fprintf( m_fp, "Po %X %d %s %s %s %8lX\n",
|
fprintf( m_fp, "Po %X %d %s %s %s %lX\n",
|
||||||
me->GetShape(),
|
me->GetShape(),
|
||||||
me->GetLayer(),
|
me->GetLayer(),
|
||||||
fmtBIUPoint( me->GetPosition() ).c_str(),
|
fmtBIUPoint( me->GetPosition() ).c_str(),
|
||||||
|
@ -3081,7 +3073,7 @@ void KICAD_PLUGIN::savePCB_LINE( const DRAWSEGMENT* me ) const
|
||||||
|
|
||||||
if( me->GetType() != S_CURVE )
|
if( me->GetType() != S_CURVE )
|
||||||
{
|
{
|
||||||
fprintf( m_fp, "De %d %d %g %8lX %X\n",
|
fprintf( m_fp, "De %d %d %g %lX %X\n",
|
||||||
me->GetLayer(),
|
me->GetLayer(),
|
||||||
me->GetType(),
|
me->GetType(),
|
||||||
me->GetAngle(),
|
me->GetAngle(),
|
||||||
|
@ -3091,7 +3083,7 @@ void KICAD_PLUGIN::savePCB_LINE( const DRAWSEGMENT* me ) const
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf( m_fp, "De %d %d %g %8lX %X %s %s\n",
|
fprintf( m_fp, "De %d %d %g %lX %X %s %s\n",
|
||||||
me->GetLayer(),
|
me->GetLayer(),
|
||||||
me->GetType(),
|
me->GetType(),
|
||||||
me->GetAngle(),
|
me->GetAngle(),
|
||||||
|
@ -3120,7 +3112,7 @@ void KICAD_PLUGIN::saveTRACK( const TRACK* me ) const
|
||||||
fmtBIU( me->GetWidth() ).c_str(),
|
fmtBIU( me->GetWidth() ).c_str(),
|
||||||
fmtBIU( me->GetDrill() ).c_str() );
|
fmtBIU( me->GetDrill() ).c_str() );
|
||||||
|
|
||||||
fprintf(m_fp, "De %d %d %d %8lX %X\n",
|
fprintf(m_fp, "De %d %d %d %lX %X\n",
|
||||||
me->GetLayer(), type, me->GetNet(),
|
me->GetLayer(), type, me->GetNet(),
|
||||||
me->GetTimeStamp(), me->GetStatus() );
|
me->GetTimeStamp(), me->GetStatus() );
|
||||||
}
|
}
|
||||||
|
@ -3131,7 +3123,7 @@ void KICAD_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const
|
||||||
fprintf( m_fp, "$CZONE_OUTLINE\n" );
|
fprintf( m_fp, "$CZONE_OUTLINE\n" );
|
||||||
|
|
||||||
// Save the outline main info
|
// Save the outline main info
|
||||||
fprintf( m_fp, "ZInfo %8lX %d %s\n",
|
fprintf( m_fp, "ZInfo %lX %d %s\n",
|
||||||
me->GetTimeStamp(), me->GetNet(),
|
me->GetTimeStamp(), me->GetNet(),
|
||||||
EscapedUTF8( me->GetNetName() ).c_str() );
|
EscapedUTF8( me->GetNetName() ).c_str() );
|
||||||
|
|
||||||
|
@ -3237,7 +3229,7 @@ void KICAD_PLUGIN::saveDIMENTION( const DIMENSION* me ) const
|
||||||
// this old keyword is used here for compatibility
|
// this old keyword is used here for compatibility
|
||||||
fprintf( m_fp, "$COTATION\n" );
|
fprintf( m_fp, "$COTATION\n" );
|
||||||
|
|
||||||
fprintf( m_fp, "Ge %d %d %8lX\n", me->GetShape(), me->GetLayer(), me->GetTimeStamp() );
|
fprintf( m_fp, "Ge %d %d %lX\n", me->GetShape(), me->GetLayer(), me->GetTimeStamp() );
|
||||||
|
|
||||||
fprintf( m_fp, "Va %d\n", me->m_Value );
|
fprintf( m_fp, "Va %d\n", me->m_Value );
|
||||||
|
|
||||||
|
@ -3332,7 +3324,7 @@ void KICAD_PLUGIN::savePCB_TEXT( const TEXTE_PCB* me ) const
|
||||||
case GR_TEXT_HJUSTIFY_RIGHT: hJustify = 'R'; break;
|
case GR_TEXT_HJUSTIFY_RIGHT: hJustify = 'R'; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( m_fp, "De %d %d %8lX %s %c\n",
|
fprintf( m_fp, "De %d %d %lX %s %c\n",
|
||||||
me->GetLayer(),
|
me->GetLayer(),
|
||||||
!me->IsMirrored(),
|
!me->IsMirrored(),
|
||||||
me->GetTimeStamp(),
|
me->GetTimeStamp(),
|
||||||
|
|
Loading…
Reference in New Issue