Pcbnew s-expression file format changes.
* Save dialog now supports saving boards to new file format. * Add CMake option to build s-expression file save. * Add check to main CMakeList.txt file to make sure nanometers are enables when the new file format is built. * Minor tweaks to object format functions for improved output. * Rename kicad_plugin.h/cpp to legacy_plugin.h/cpp.
This commit is contained in:
parent
6976d2538f
commit
9c16a218c0
|
@ -20,6 +20,9 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
|
|||
# reports.
|
||||
#
|
||||
|
||||
option(USE_PCBNEW_SEXPR_FILE_FORMAT
|
||||
"Use s-expression Pcbnew file format support (default OFF)." )
|
||||
|
||||
option(USE_NEW_PCBNEW_LOAD "use new plugin support for legacy file format" ON)
|
||||
option(USE_NEW_PCBNEW_SAVE "use new plugin support for legacy file format" ON)
|
||||
option(USE_PCBNEW_NANOMETRES
|
||||
|
@ -68,7 +71,12 @@ else (KICAD_STABLE_VERSION )
|
|||
endif(KICAD_TESTING_VERSION )
|
||||
endif(KICAD_STABLE_VERSION )
|
||||
|
||||
|
||||
# Nanometers must be enabled when USE_PCBNEW_SEXPR_FILE_FORMAT=ON.
|
||||
if( USE_PCBNEW_SEXPR_FILE_FORMAT AND NOT USE_PCBNEW_NANOMETRES )
|
||||
set( TMP "The Pcbnew s-expression file format requires nano-meter internal units to be " )
|
||||
set( TMP "${TMP} enabled using -DUSE_PCBNEW_NANOMETRES=ON." )
|
||||
message( FATAL_ERROR ${TMP} )
|
||||
endif( USE_PCBNEW_SEXPR_FILE_FORMAT AND NOT USE_PCBNEW_NANOMETRES )
|
||||
|
||||
#================================================
|
||||
# Set flags for GCC.
|
||||
|
|
|
@ -57,13 +57,14 @@
|
|||
|
||||
#cmakedefine USE_NEW_PCBNEW_LOAD
|
||||
#cmakedefine USE_NEW_PCBNEW_SAVE
|
||||
#cmakedefine USE_PCBNEW_NANAMETERS
|
||||
#cmakedefine USE_PCBNEW_NANOMETRES
|
||||
#cmakedefine USE_PCBNEW_SEXPR_FILE_FORMAT
|
||||
|
||||
/// The file format revision of the *.brd file created by this build
|
||||
#if defined(KICAD_NANOMETRE)
|
||||
#define BOARD_FILE_VERSION 2
|
||||
/// The legacy file format revision of the *.brd file created by this build
|
||||
#if defined(USE_PCBNEW_NANOMETRES)
|
||||
#define LEGACY_BOARD_FILE_VERSION 2
|
||||
#else
|
||||
#define BOARD_FILE_VERSION 1
|
||||
#define LEGACY_BOARD_FILE_VERSION 1
|
||||
#endif
|
||||
|
||||
#endif // CONFIG_H_
|
||||
|
|
|
@ -119,7 +119,13 @@ set(PCB_COMMON_SRCS
|
|||
)
|
||||
|
||||
if( USE_NEW_PCBNEW_LOAD OR USE_NEW_PCBNEW_SAVE )
|
||||
set( PCB_COMMON_SRCS ${PCB_COMMON_SRCS} ../pcbnew/item_io.cpp ../pcbnew/io_mgr.cpp ../pcbnew/kicad_plugin.cpp )
|
||||
set( PCB_COMMON_SRCS
|
||||
${PCB_COMMON_SRCS}
|
||||
../pcbnew/item_io.cpp
|
||||
../pcbnew/io_mgr.cpp
|
||||
../pcbnew/legacy_plugin.cpp
|
||||
../pcbnew/kicad_plugin.cpp
|
||||
)
|
||||
else()
|
||||
set( PCB_COMMON_SRCS ${PCB_COMMON_SRCS} ../pcbnew/item_io.cpp )
|
||||
endif()
|
||||
|
|
|
@ -574,12 +574,12 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
|
|||
throw( IO_ERROR )
|
||||
{
|
||||
aFormatter->Print( aNestLevel, "(text %s (at %s",
|
||||
EscapedUTF8( m_Text ).c_str(), FormatBIU( m_Pos ).c_str() );
|
||||
aFormatter->Quotew( m_Text ).c_str(), FormatBIU( m_Pos ).c_str() );
|
||||
|
||||
if( m_Orient != 0.0 )
|
||||
aFormatter->Print( aNestLevel, "%0.1f", m_Orient );
|
||||
aFormatter->Print( 0, " %0.1f", m_Orient );
|
||||
|
||||
aFormatter->Print( aNestLevel, ")\n" );
|
||||
aFormatter->Print( 0, ")\n" );
|
||||
|
||||
if( !IsDefaultFormatting() )
|
||||
{
|
||||
|
@ -593,15 +593,15 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
|
|||
// Add font support here at some point in the future.
|
||||
|
||||
if( ( m_Size.x != DEFAULT_SIZE_TEXT ) || ( m_Size.y != DEFAULT_SIZE_TEXT ) )
|
||||
aFormatter->Print( aNestLevel+2, " (size %s)", FormatBIU( m_Size ).c_str() );
|
||||
aFormatter->Print( 0, " (size %s)", FormatBIU( m_Size ).c_str() );
|
||||
|
||||
if( m_Bold )
|
||||
aFormatter->Print( aNestLevel+2, " bold" );
|
||||
aFormatter->Print( 0, " bold" );
|
||||
|
||||
if( m_Bold )
|
||||
aFormatter->Print( aNestLevel+2, " italic" );
|
||||
aFormatter->Print( 0, " italic" );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, ")\n");
|
||||
aFormatter->Print( 0, ")\n");
|
||||
}
|
||||
|
||||
if( m_Mirror || ( m_HJustify != GR_TEXT_HJUSTIFY_CENTER )
|
||||
|
@ -610,24 +610,22 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
|
|||
aFormatter->Print( aNestLevel+2, "(justify");
|
||||
|
||||
if( m_HJustify != GR_TEXT_HJUSTIFY_CENTER )
|
||||
aFormatter->Print( aNestLevel+2,
|
||||
(m_HJustify == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
|
||||
aFormatter->Print( 0, (m_HJustify == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
|
||||
|
||||
if( m_VJustify != GR_TEXT_VJUSTIFY_CENTER )
|
||||
aFormatter->Print( aNestLevel+2,
|
||||
(m_VJustify == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
|
||||
aFormatter->Print( 0, (m_VJustify == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
|
||||
|
||||
if( m_Mirror )
|
||||
aFormatter->Print( aNestLevel+2, " mirror" );
|
||||
aFormatter->Print( 0, " mirror" );
|
||||
|
||||
aFormatter->Print( aNestLevel+2, ")\n" );
|
||||
aFormatter->Print( 0, ")\n" );
|
||||
}
|
||||
|
||||
// As of now the only place this is used is in Eeschema to hide or show the text.
|
||||
if( m_Attributs )
|
||||
aFormatter->Print( aNestLevel+2, "hide" );
|
||||
aFormatter->Print( aNestLevel+2, "hide\n" );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "\n)\n" );
|
||||
aFormatter->Print( aNestLevel+1, ")\n" );
|
||||
}
|
||||
|
||||
aFormatter->Print( aNestLevel, ")\n" );
|
||||
|
|
|
@ -54,7 +54,8 @@ const wxString ProjectFileWildcard( _( "KiCad project files (*.pro)|*.pro" ) );
|
|||
const wxString SchematicFileWildcard( _( "KiCad schematic files (*.sch)|*.sch" ) );
|
||||
const wxString NetlistFileWildcard( _( "KiCad netlist files (*.net)|*.net" ) );
|
||||
const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) );
|
||||
const wxString PcbFileWildcard( _( "KiCad printed circuit board files (*.brd)|*.brd" ) );
|
||||
const wxString LegacyPcbFileWildcard( _( "KiCad printed circuit board files (*.brd)|*.brd" ) );
|
||||
const wxString PcbFileWildcard( _( "KiCad s-expr printed circuit board files (*.kicad_brd)|*.kicad_brd" ) );
|
||||
const wxString FootprintLibFileWildcard( _( "KiCad footprint library file (*.mod)|*.mod" ) );
|
||||
const wxString PdfFileWildcard( _( "Portable document format files (*.pdf)|*.pdf" ) );
|
||||
const wxString MacrosFileWildcard( _( "KiCad recorded macros (*.mcr)|*.mcr" ) );
|
||||
|
|
|
@ -1671,32 +1671,32 @@ void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aCont
|
|||
|| !m_company.IsEmpty() || !m_comment1.IsEmpty() || !m_comment2.IsEmpty()
|
||||
|| !m_comment3.IsEmpty() || !m_comment4.IsEmpty() )
|
||||
{
|
||||
aFormatter->Print( aNestLevel, "(title-block\n" );
|
||||
aFormatter->Print( aNestLevel, "(title_block\n" );
|
||||
|
||||
if( !m_title.IsEmpty() )
|
||||
aFormatter->Print( aNestLevel+1, "\n(title %s)", EscapedUTF8( m_title ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(title %s)\n", EscapedUTF8( m_title ).c_str() );
|
||||
|
||||
if( !m_date.IsEmpty() )
|
||||
aFormatter->Print( aNestLevel+1, "\n(date %s)", EscapedUTF8( m_date ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(date %s)\n", EscapedUTF8( m_date ).c_str() );
|
||||
|
||||
if( !m_revision.IsEmpty() )
|
||||
aFormatter->Print( aNestLevel+1, "\n(rev %s)", EscapedUTF8( m_revision ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(rev %s)\n", EscapedUTF8( m_revision ).c_str() );
|
||||
|
||||
if( !m_company.IsEmpty() )
|
||||
aFormatter->Print( aNestLevel+1, "\n(company %s)", EscapedUTF8( m_company ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(company %s)\n", EscapedUTF8( m_company ).c_str() );
|
||||
|
||||
if( !m_comment1.IsEmpty() )
|
||||
aFormatter->Print( aNestLevel+1, "\n(comment1 %s)", EscapedUTF8( m_comment1 ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(comment1 %s)\n", EscapedUTF8( m_comment1 ).c_str() );
|
||||
|
||||
if( !m_comment2.IsEmpty() )
|
||||
aFormatter->Print( aNestLevel+1, "\n(comment2 %s)", EscapedUTF8( m_comment2 ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(comment2 %s)\n", EscapedUTF8( m_comment2 ).c_str() );
|
||||
|
||||
if( !m_comment3.IsEmpty() )
|
||||
aFormatter->Print( aNestLevel+1, "\n(comment3 %s)", EscapedUTF8( m_comment3 ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(comment3 %s)\n", EscapedUTF8( m_comment3 ).c_str() );
|
||||
|
||||
if( !m_comment4.IsEmpty() )
|
||||
aFormatter->Print( aNestLevel+1, "\n(comment4 %s)", EscapedUTF8( m_comment4 ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(comment4 %s)\n", EscapedUTF8( m_comment4 ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel, "\n)\n" );
|
||||
aFormatter->Print( aNestLevel, ")\n\n" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -239,7 +239,7 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
|
|||
SetLocaleTo_C_standard();
|
||||
|
||||
// write PCB header
|
||||
fprintf( m_file, "PCBNEW-BOARD Version %d date %s\n\n", BOARD_FILE_VERSION,
|
||||
fprintf( m_file, "PCBNEW-BOARD Version %d date %s\n\n", LEGACY_BOARD_FILE_VERSION,
|
||||
TO_UTF8( DateAndTime() ) );
|
||||
WriteGeneralDescrPcb( );
|
||||
WriteSetup( );
|
||||
|
|
|
@ -61,6 +61,7 @@ extern const wxString SchematicFileWildcard;
|
|||
extern const wxString BoardFileWildcard;
|
||||
extern const wxString NetlistFileWildcard;
|
||||
extern const wxString GerberFileWildcard;
|
||||
extern const wxString LegacyPcbFileWildcard;
|
||||
extern const wxString PcbFileWildcard;
|
||||
extern const wxString PdfFileWildcard;
|
||||
extern const wxString MacrosFileWildcard;
|
||||
|
|
|
@ -35,7 +35,7 @@ BOARD::BOARD() :
|
|||
m_NetClasses( this )
|
||||
{
|
||||
// we have not loaded a board yet, assume latest until then.
|
||||
m_fileFormatVersionAtLoad = BOARD_FILE_VERSION;
|
||||
m_fileFormatVersionAtLoad = LEGACY_BOARD_FILE_VERSION;
|
||||
|
||||
m_Status_Pcb = 0; // Status word: bit 1 = calculate.
|
||||
SetColorsSettings( &g_ColorsSettings );
|
||||
|
@ -2154,7 +2154,7 @@ void BOARD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
|
|||
{
|
||||
aFormatter->Print( aNestLevel, "(general\n" );
|
||||
aFormatter->Print( aNestLevel+1, "(links %d)\n", GetRatsnestsCount() );
|
||||
aFormatter->Print( aNestLevel+1, "(no-connects %d)\n", m_NbNoconnect );
|
||||
aFormatter->Print( aNestLevel+1, "(no_connects %d)\n", m_NbNoconnect );
|
||||
|
||||
// Write Bounding box info
|
||||
aFormatter->Print( aNestLevel+1, "(area %s %s %s %s)\n",
|
||||
|
@ -2179,7 +2179,9 @@ void BOARD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
|
|||
aFormatter->Print( aNestLevel, "(layers %d %08X", GetCopperLayerCount(), GetEnabledLayers() );
|
||||
|
||||
if( GetEnabledLayers() != GetVisibleLayers() )
|
||||
aFormatter->Print( aNestLevel+1, " %08X", GetVisibleLayers() );
|
||||
aFormatter->Print( 0, " %08X", GetVisibleLayers() );
|
||||
|
||||
aFormatter->Print( 0, "\n" );
|
||||
|
||||
unsigned layerMask = ALL_CU_LAYERS & GetEnabledLayers();
|
||||
|
||||
|
@ -2187,7 +2189,7 @@ void BOARD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
|
|||
{
|
||||
if( layerMask & 1 )
|
||||
{
|
||||
aFormatter->Print( aNestLevel+1, "(layer%d %s %s\n", layer,
|
||||
aFormatter->Print( aNestLevel+1, "(layer%d %s %s)\n", layer,
|
||||
TO_UTF8( GetLayerName( layer ) ),
|
||||
LAYER::ShowType( GetLayerType( layer ) ) );
|
||||
}
|
||||
|
@ -2199,36 +2201,36 @@ void BOARD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
|
|||
aFormatter->Print( aNestLevel, "(setup\n" );
|
||||
|
||||
// Save current default track width, for compatibility with older Pcbnew version;
|
||||
aFormatter->Print( aNestLevel+1, "(last-trace-width %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(last_trace_width %s)\n",
|
||||
FormatBIU( m_TrackWidthList[m_TrackWidthSelector] ).c_str() );
|
||||
|
||||
// Save custom tracks width list (the first is not saved here: this is the netclass value
|
||||
for( unsigned ii = 1; ii < m_TrackWidthList.size(); ii++ )
|
||||
aFormatter->Print( aNestLevel+1, "(user-trace-width%d %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(user_trace_width%d %s)\n",
|
||||
ii+1, FormatBIU( m_TrackWidthList[ii] ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(trace-clearance %s)\n)",
|
||||
aFormatter->Print( aNestLevel+1, "(trace_clearance %s)\n",
|
||||
FormatBIU( m_NetClasses.GetDefault()->GetClearance() ).c_str() );
|
||||
|
||||
// ZONE_SETTINGS
|
||||
aFormatter->Print( aNestLevel+1, "(zone-clearance %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(zone_clearance %s)\n",
|
||||
FormatBIU( GetZoneSettings().m_ZoneClearance ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(zone-45-only %d)\n", GetZoneSettings().m_Zone_45_Only );
|
||||
aFormatter->Print( aNestLevel+1, "(zone_45_only %d)\n", GetZoneSettings().m_Zone_45_Only );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(trace-min %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(trace_min %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_TrackMinWidth ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(segment-width %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(segment_width %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_DrawSegmentWidth ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(edge-width %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(edge_width %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_EdgeSegmentWidth ).c_str() );
|
||||
|
||||
// Save current default via size, for compatibility with older Pcbnew version;
|
||||
aFormatter->Print( aNestLevel+1, "(via-size %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(via_size %s)\n",
|
||||
FormatBIU( m_NetClasses.GetDefault()->GetViaDiameter() ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(via-drill %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(via_drill %s)\n",
|
||||
FormatBIU( m_NetClasses.GetDefault()->GetViaDrill() ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(via-min-size %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(via_min_size %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_ViasMinSize ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(via_min_drill %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_ViasMinDrill ).c_str() );
|
||||
|
@ -2236,58 +2238,58 @@ void BOARD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
|
|||
// Save custom vias diameters list (the first is not saved here: this is
|
||||
// the netclass value
|
||||
for( unsigned ii = 1; ii < m_ViasDimensionsList.size(); ii++ )
|
||||
aFormatter->Print( aNestLevel+1, "(user-via%d %s %s)\n", ii,
|
||||
aFormatter->Print( aNestLevel+1, "(user_via%d %s %s)\n", ii,
|
||||
FormatBIU( m_ViasDimensionsList[ii].m_Diameter ).c_str(),
|
||||
FormatBIU( m_ViasDimensionsList[ii].m_Drill ).c_str() );
|
||||
|
||||
// for old versions compatibility:
|
||||
aFormatter->Print( aNestLevel+1, "(uvia-size %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(uvia_size %s)\n",
|
||||
FormatBIU( m_NetClasses.GetDefault()->GetuViaDiameter() ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(uvia-drill %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(uvia_drill %s)\n",
|
||||
FormatBIU( m_NetClasses.GetDefault()->GetuViaDrill() ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(uvias_allow %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_MicroViasAllowed ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(uvia-min-size %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(uvia_min_size %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_MicroViasMinSize ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(uvia-min-drill %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(uvia_min_drill %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_MicroViasMinDrill ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(pcb-text-width %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(pcb_text_width %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_PcbTextWidth ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(pcb-text-size %s %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(pcb_text_size %s %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_PcbTextSize.x ).c_str(),
|
||||
FormatBIU( GetDesignSettings().m_PcbTextSize.y ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(mod-edge-width %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(mod_edge_width %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_ModuleSegmentWidth ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(mod-text-size %s %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(mod_text_size %s %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_ModuleTextSize.x ).c_str(),
|
||||
FormatBIU( GetDesignSettings().m_ModuleTextSize.y ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(mod-text-width %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(mod_text_width %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_ModuleTextWidth ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(pad-size %s %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(pad_size %s %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_Pad_Master.GetSize().x ).c_str(),
|
||||
FormatBIU( GetDesignSettings().m_Pad_Master.GetSize().x ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(pad-drill %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(pad_drill %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_Pad_Master.GetDrillSize().x ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(pad-to-mask-clearance %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(pad_to_mask_clearance %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_SolderMaskMargin ).c_str() );
|
||||
|
||||
if( GetDesignSettings().m_SolderPasteMargin != 0 )
|
||||
aFormatter->Print( aNestLevel+1, "(pad-to-paste-clearance %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(pad_to_paste_clearance %s)\n",
|
||||
FormatBIU( GetDesignSettings().m_SolderPasteMargin ).c_str() );
|
||||
|
||||
if( GetDesignSettings().m_SolderPasteMarginRatio != 0 )
|
||||
aFormatter->Print( aNestLevel+1, "(pad-to-paste-clearance-ratio %g)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(pad_to_paste_clearance_ratio %g)\n",
|
||||
GetDesignSettings().m_SolderPasteMarginRatio );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(aux-axis-origin %s %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n",
|
||||
FormatBIU( GetOriginAxisPosition().x ).c_str(),
|
||||
FormatBIU( GetOriginAxisPosition().y ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(visible-elements %X)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(visible_elements %X)\n",
|
||||
GetDesignSettings().GetVisibleElements() );
|
||||
|
||||
aFormatter->Print( aNestLevel, ")\n\n" );
|
||||
|
@ -2298,7 +2300,9 @@ void BOARD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
|
|||
for( int i = 0; i < netcount; ++i )
|
||||
aFormatter->Print( aNestLevel, "(net %d %s)\n",
|
||||
FindNet( i )->GetNet(),
|
||||
EscapedUTF8( FindNet( i )->GetNetname() ).c_str() );
|
||||
aFormatter->Quotew( FindNet( i )->GetNetname() ).c_str() );
|
||||
|
||||
aFormatter->Print( 0, "\n" );
|
||||
|
||||
// Save the default net class first.
|
||||
m_NetClasses.GetDefault()->Format( aFormatter, aNestLevel, aControlBits );
|
||||
|
@ -2310,14 +2314,17 @@ void BOARD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
|
|||
netclass->Format( aFormatter, aNestLevel, aControlBits );
|
||||
}
|
||||
|
||||
// Save the modules.
|
||||
for( MODULE* module = m_Modules; module; module = (MODULE*) module->Next() )
|
||||
module->Format( aFormatter, aNestLevel, aControlBits );
|
||||
|
||||
// Save the graphical items on the board (not owned by a module)
|
||||
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
|
||||
{
|
||||
item->Format( aFormatter, aNestLevel, aControlBits );
|
||||
|
||||
aFormatter->Print( 0, "\n" );
|
||||
|
||||
// Save the modules.
|
||||
for( MODULE* module = m_Modules; module; module = (MODULE*) module->Next() )
|
||||
{
|
||||
module->Format( aFormatter, aNestLevel, aControlBits );
|
||||
aFormatter->Print( 0, "\n" );
|
||||
}
|
||||
|
||||
// Do not save MARKER_PCBs, they can be regenerated easily.
|
||||
|
@ -2326,15 +2333,14 @@ void BOARD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
|
|||
for( TRACK* track = m_Track; track; track = track->Next() )
|
||||
track->Format( aFormatter, aNestLevel, aControlBits );
|
||||
|
||||
// Save the old obsolete zones which were done by segments (tracks).
|
||||
for( SEGZONE* zone = m_Zone; zone; zone = zone->Next() )
|
||||
zone->Format( aFormatter, aNestLevel, aControlBits );
|
||||
/// @todo Add warning here that the old segment filed zones are no longer supported and
|
||||
/// will not be saved.
|
||||
|
||||
aFormatter->Print( 0, "\n" );
|
||||
|
||||
// Save the polygon (which are the newer technology) zones.
|
||||
for( int i=0; i < GetAreaCount(); ++i )
|
||||
GetArea( i )->Format( aFormatter, aNestLevel, aControlBits );
|
||||
|
||||
aFormatter->Print( aNestLevel, "\n)\n" );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ wxString BOARD_ITEM::GetLayerName() const
|
|||
/** @todo Move Pcbnew version of FormatBIU() where ever the common DSO/DSL code ends up. */
|
||||
std::string FormatBIU( int aValue )
|
||||
{
|
||||
#if !defined( USE_PCBNEW_NANOMETERS )
|
||||
#if !defined( USE_PCBNEW_NANOMETRES )
|
||||
wxFAIL_MSG( wxT( "Cannot use FormatBIU() unless Pcbnew is build with PCBNEW_NANOMETERS=ON." ) );
|
||||
#endif
|
||||
|
||||
|
|
|
@ -554,35 +554,35 @@ void DRAWSEGMENT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aCont
|
|||
switch( m_Shape )
|
||||
{
|
||||
case S_SEGMENT: // Line
|
||||
aFormatter->Print( aNestLevel, "line (pts xy(%s) xy(%s))",
|
||||
aFormatter->Print( 0, "line (pts xy(%s) xy(%s))",
|
||||
FormatBIU( m_Start ).c_str(),
|
||||
FormatBIU( m_End ).c_str() );
|
||||
break;
|
||||
|
||||
case S_CIRCLE: // Circle
|
||||
aFormatter->Print( aNestLevel, "circle (center (xy %s)) (end (xy %s))",
|
||||
aFormatter->Print( 0, "circle (center (xy %s)) (end (xy %s))",
|
||||
FormatBIU( m_Start ).c_str(),
|
||||
FormatBIU( m_End ).c_str() );
|
||||
break;
|
||||
|
||||
case S_ARC: // Arc
|
||||
aFormatter->Print( aNestLevel, "arc (start (xy %s)) (end (xy %s)) (angle %0.1f)",
|
||||
aFormatter->Print( 0, "arc (start (xy %s)) (end (xy %s)) (angle %0.1f)",
|
||||
FormatBIU( m_Start ).c_str(),
|
||||
FormatBIU( m_End ).c_str(),
|
||||
m_Angle );
|
||||
break;
|
||||
|
||||
case S_POLYGON: // Polygon
|
||||
aFormatter->Print( aNestLevel, "line (pts" );
|
||||
aFormatter->Print( 0, "line (pts" );
|
||||
|
||||
for( i = 0; i<m_PolyPoints.size(); ++i )
|
||||
aFormatter->Print( aNestLevel, " (xy %s)", FormatBIU( m_PolyPoints[i] ).c_str() );
|
||||
aFormatter->Print( 0, " (xy %s)", FormatBIU( m_PolyPoints[i] ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel, ")" );
|
||||
aFormatter->Print( 0, ")" );
|
||||
break;
|
||||
|
||||
case S_CURVE: // Bezier curve
|
||||
aFormatter->Print( aNestLevel, "curve pts(xy(%s) xy(%s) xy(%s) xy(%s))",
|
||||
aFormatter->Print( 0, "curve pts(xy(%s) xy(%s) xy(%s) xy(%s))",
|
||||
FormatBIU( m_Start ).c_str(),
|
||||
FormatBIU( m_BezierC1 ).c_str(),
|
||||
FormatBIU( m_BezierC2 ).c_str(),
|
||||
|
@ -593,18 +593,18 @@ void DRAWSEGMENT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aCont
|
|||
wxFAIL_MSG( wxT( "Cannot format invalid DRAWSEGMENT type." ) );
|
||||
};
|
||||
|
||||
aFormatter->Print( aNestLevel, " (layer %d)", GetLayer() );
|
||||
aFormatter->Print( 0, " (layer %d)", GetLayer() );
|
||||
|
||||
if( m_Width != 0 )
|
||||
aFormatter->Print( aNestLevel, " (width %s)", FormatBIU( m_Width ).c_str() );
|
||||
aFormatter->Print( 0, " (width %s)", FormatBIU( m_Width ).c_str() );
|
||||
|
||||
if( GetTimeStamp() )
|
||||
aFormatter->Print( aNestLevel, " (tstamp %lX)", GetTimeStamp() );
|
||||
aFormatter->Print( 0, " (tstamp %lX)", GetTimeStamp() );
|
||||
|
||||
if( GetStatus() )
|
||||
aFormatter->Print( aNestLevel, " (status %X)", GetStatus() );
|
||||
aFormatter->Print( 0, " (status %X)", GetStatus() );
|
||||
|
||||
aFormatter->Print( aNestLevel, ")\n" );
|
||||
aFormatter->Print( 0, ")\n" );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -666,7 +666,7 @@ EDA_ITEM* MODULE::Clone() const
|
|||
void MODULE::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
|
||||
throw( IO_ERROR )
|
||||
{
|
||||
aFormatter->Print( aNestLevel, "(module %s" , EscapedUTF8( m_LibRef ).c_str() );
|
||||
aFormatter->Print( aNestLevel, "(module %s" , aFormatter->Quotew( m_LibRef ).c_str() );
|
||||
|
||||
if( IsLocked() )
|
||||
aFormatter->Print( aNestLevel, " locked" );
|
||||
|
@ -674,41 +674,41 @@ void MODULE::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBi
|
|||
if( IsPlaced() )
|
||||
aFormatter->Print( aNestLevel, " placed" );
|
||||
|
||||
aFormatter->Print( aNestLevel, " (tedit %lX) (tstamp %lX)\n",
|
||||
aFormatter->Print( 0, " (tedit %lX) (tstamp %lX)\n",
|
||||
GetLastEditTime(), GetTimeStamp() );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(at %s", FormatBIU( m_Pos ).c_str() );
|
||||
|
||||
if( m_Orient != 0.0 )
|
||||
aFormatter->Print( aNestLevel+1, " %0.1f", m_Orient );
|
||||
aFormatter->Print( 0, " %0.1f", m_Orient );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, ")\n" );
|
||||
aFormatter->Print( 0, ")\n" );
|
||||
|
||||
if( !m_Doc.IsEmpty() )
|
||||
aFormatter->Print( aNestLevel+1, "(descr %s)\n", EscapedUTF8( m_Doc ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(descr %s)\n", aFormatter->Quotew( m_Doc ).c_str() );
|
||||
|
||||
if( !m_KeyWord.IsEmpty() )
|
||||
aFormatter->Print( aNestLevel+1, "(tags %s)\n", EscapedUTF8( m_KeyWord ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(tags %s)\n", aFormatter->Quotew( m_KeyWord ).c_str() );
|
||||
|
||||
if( !m_Path.IsEmpty() )
|
||||
aFormatter->Print( aNestLevel+1, "(path %s)\n", EscapedUTF8( m_Path ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(path %s)\n", aFormatter->Quotew( m_Path ).c_str() );
|
||||
|
||||
if( m_CntRot90 != 0 )
|
||||
aFormatter->Print( aNestLevel+1, "(autoplace-cost90 %d)\n", m_CntRot90 );
|
||||
aFormatter->Print( aNestLevel+1, "(autoplace_cost90 %d)\n", m_CntRot90 );
|
||||
|
||||
if( m_CntRot180 != 0 )
|
||||
aFormatter->Print( aNestLevel+1, "(autoplace-cost180 %d)\n", m_CntRot180 );
|
||||
aFormatter->Print( aNestLevel+1, "(autoplace_cost180 %d)\n", m_CntRot180 );
|
||||
|
||||
if( m_LocalSolderMaskMargin != 0 )
|
||||
aFormatter->Print( aNestLevel+1, "(solder-mask-margin %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(solder_mask_margin %s)\n",
|
||||
FormatBIU( m_LocalSolderMaskMargin ).c_str() );
|
||||
|
||||
if( m_LocalSolderPasteMargin != 0 )
|
||||
aFormatter->Print( aNestLevel+1, "(solder-paste-margin %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(solder_paste_margin %s)\n",
|
||||
FormatBIU( m_LocalSolderPasteMargin ).c_str() );
|
||||
|
||||
if( m_LocalSolderPasteMarginRatio != 0 )
|
||||
aFormatter->Print( aNestLevel+1, "(solder-paste-ratio %g)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(solder_paste_ratio %g)\n",
|
||||
m_LocalSolderPasteMarginRatio );
|
||||
|
||||
if( m_LocalClearance != 0 )
|
||||
|
@ -716,14 +716,14 @@ void MODULE::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBi
|
|||
FormatBIU( m_LocalClearance ).c_str() );
|
||||
|
||||
if( m_ZoneConnection != UNDEFINED_CONNECTION )
|
||||
aFormatter->Print( aNestLevel+1, "(zone-connect %d)\n", m_ZoneConnection );
|
||||
aFormatter->Print( aNestLevel+1, "(zone_connect %d)\n", m_ZoneConnection );
|
||||
|
||||
if( m_ThermalWidth != 0 )
|
||||
aFormatter->Print( aNestLevel+1, "(thermal-width %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(thermal_width %s)\n",
|
||||
FormatBIU( m_ThermalWidth ).c_str() );
|
||||
|
||||
if( m_ThermalGap != 0 )
|
||||
aFormatter->Print( aNestLevel+1, "(thermal-gap %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(thermal_gap %s)\n",
|
||||
FormatBIU( m_ThermalGap ).c_str() );
|
||||
|
||||
// Attributes
|
||||
|
@ -732,12 +732,12 @@ void MODULE::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBi
|
|||
aFormatter->Print( aNestLevel+1, "(attr " );
|
||||
|
||||
if( m_Attributs & MOD_CMS )
|
||||
aFormatter->Print( aNestLevel+1, " smd" );
|
||||
aFormatter->Print( 0, " smd" );
|
||||
|
||||
if( m_Attributs & MOD_VIRTUAL )
|
||||
aFormatter->Print( aNestLevel+1, " virtual" );
|
||||
aFormatter->Print( 0, " virtual" );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, ")\n" );
|
||||
aFormatter->Print( 0, ")\n" );
|
||||
}
|
||||
|
||||
m_Reference->Format( aFormatter, aNestLevel+1, aControlBits );
|
||||
|
@ -745,26 +745,26 @@ void MODULE::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBi
|
|||
|
||||
// Save drawing elements.
|
||||
for( BOARD_ITEM* gr = m_Drawings; gr; gr = gr->Next() )
|
||||
gr->Format( aFormatter+1, aNestLevel, aControlBits );
|
||||
gr->Format( aFormatter, aNestLevel+1, aControlBits );
|
||||
|
||||
// Save pads.
|
||||
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
|
||||
pad->Format( aFormatter+1, aNestLevel, aControlBits );
|
||||
pad->Format( aFormatter, aNestLevel+1, aControlBits );
|
||||
|
||||
// Save 3D info.
|
||||
for( S3D_MASTER* t3D = m_3D_Drawings; t3D; t3D = t3D->Next() )
|
||||
{
|
||||
if( !t3D->m_Shape3DName.IsEmpty() )
|
||||
{
|
||||
aFormatter->Print( aNestLevel+1, "(3d-shape %s\n",
|
||||
EscapedUTF8( t3D->m_Shape3DName ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(3d_shape %s\n",
|
||||
aFormatter->Quotew( t3D->m_Shape3DName ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel+2, "(at (xyz %.16g %.16g %.16g))\n",
|
||||
t3D->m_MatPosition.x,
|
||||
t3D->m_MatPosition.y,
|
||||
t3D->m_MatPosition.z );
|
||||
|
||||
aFormatter->Print( aNestLevel+2, "(scale (xyz %lf %lf %lf))\n",
|
||||
aFormatter->Print( aNestLevel+2, "(scale (xyz %.16g %.16g %.16g))\n",
|
||||
t3D->m_MatScale.x,
|
||||
t3D->m_MatScale.y,
|
||||
t3D->m_MatScale.z );
|
||||
|
|
|
@ -324,21 +324,21 @@ int NETCLASS::GetuViaMinDrill() const
|
|||
void NETCLASS::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
|
||||
throw( IO_ERROR )
|
||||
{
|
||||
aFormatter->Print( aNestLevel, "(net-class %s %s\n",
|
||||
EscapedUTF8( GetName() ).c_str(),
|
||||
EscapedUTF8( GetDescription() ).c_str() );
|
||||
aFormatter->Print( aNestLevel, "(net_class %s %s\n",
|
||||
aFormatter->Quotew( GetName() ).c_str(),
|
||||
aFormatter->Quotew( GetDescription() ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(clearance %d)\n", GetClearance() );
|
||||
aFormatter->Print( aNestLevel+1, "(trace-width %d)\n", GetTrackWidth() );
|
||||
aFormatter->Print( aNestLevel+1, "(clearance %s)\n", FormatBIU( GetClearance() ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(trace_width %s)\n", FormatBIU( GetTrackWidth() ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(via-dia %d)\n", GetViaDiameter() );
|
||||
aFormatter->Print( aNestLevel+1, "(via-drill %d)\n", GetViaDrill() );
|
||||
aFormatter->Print( aNestLevel+1, "(via_dia %s)\n", FormatBIU( GetViaDiameter() ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(via_drill %s)\n", FormatBIU( GetViaDrill() ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(uvia-dia %d)\n", GetuViaDiameter() );
|
||||
aFormatter->Print( aNestLevel+1, "(uvia-drill %d)\n", GetuViaDrill() );
|
||||
aFormatter->Print( aNestLevel+1, "(uvia_dia %s)\n", FormatBIU( GetuViaDiameter() ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(uvia_drill %s)\n", FormatBIU( GetuViaDrill() ).c_str() );
|
||||
|
||||
for( NETCLASS::const_iterator it = begin(); it!= end(); ++it )
|
||||
aFormatter->Print( aNestLevel+1, "(add-net %s)\n", EscapedUTF8( *it ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(add_net %s)\n", aFormatter->Quotew( *it ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel, ")\n" );
|
||||
aFormatter->Print( aNestLevel, ")\n\n" );
|
||||
}
|
||||
|
|
|
@ -849,59 +849,60 @@ void D_PAD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
|
|||
|
||||
switch( m_Attribute )
|
||||
{
|
||||
case PAD_STANDARD: type = "thru-hole"; break;
|
||||
case PAD_STANDARD: type = "thru_hole"; break;
|
||||
case PAD_SMD: type = "smd"; break;
|
||||
case PAD_CONN: type = "connect"; break;
|
||||
case PAD_HOLE_NOT_PLATED: type = "np-thru-hole"; break;
|
||||
case PAD_HOLE_NOT_PLATED: type = "np_thru_hole"; break;
|
||||
|
||||
default:
|
||||
THROW_IO_ERROR( wxString::Format( _( "unknown pad attribute: %d" ), m_Attribute ) );
|
||||
}
|
||||
|
||||
aFormatter->Print( aNestLevel, "(pad %s %s %s (size %s)\n",
|
||||
EscapedUTF8( GetPadName() ).c_str(), type.c_str(), shape.c_str(),
|
||||
aFormatter->Quotew( GetPadName() ).c_str(), type.c_str(), shape.c_str(),
|
||||
FormatBIU( m_Size ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(at %s", FormatBIU( m_Pos0 ).c_str() );
|
||||
|
||||
if( m_Orient != 0.0 )
|
||||
aFormatter->Print( aNestLevel+1, " %0.1f", m_Orient );
|
||||
aFormatter->Print( 0, " %0.1f", m_Orient );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, ")\n" );
|
||||
aFormatter->Print( 0, ")\n" );
|
||||
|
||||
if( (m_Drill.GetWidth() > 0) || (m_Drill.GetHeight() > 0) )
|
||||
{
|
||||
std::string drill = (m_Drill.GetHeight() > 0) ? FormatBIU( m_Drill ).c_str() :
|
||||
FormatBIU( m_Drill.GetWidth() ).c_str();
|
||||
aFormatter->Print( aNestLevel+1, "(drill %s\n", drill.c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(drill %s", drill.c_str() );
|
||||
|
||||
if( (m_Offset.x > 0) || (m_Offset.y > 0) )
|
||||
{
|
||||
std::string drillOffset = ( m_Offset.x > 0 ) ?
|
||||
FormatBIU( m_Offset ).c_str() :
|
||||
FormatBIU( m_Offset.x ).c_str();
|
||||
aFormatter->Print( aNestLevel+1, " (offset %s)", drillOffset.c_str() );
|
||||
aFormatter->Print( 0, " (offset %s)", drillOffset.c_str() );
|
||||
}
|
||||
|
||||
aFormatter->Print( aNestLevel+1, ")\n" );
|
||||
aFormatter->Print( 0, ")\n" );
|
||||
}
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(layers %08X)\n", GetLayerMask() );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(net %d %s)\n", GetNet(), EscapedUTF8( m_Netname ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(net %d %s)\n",
|
||||
GetNet(), aFormatter->Quotew( m_Netname ).c_str() );
|
||||
|
||||
if( m_LengthDie != 0 )
|
||||
aFormatter->Print( aNestLevel+1, "(die-length %s)\n", FormatBIU( m_LengthDie ).c_str() );
|
||||
aFormatter->Print( aNestLevel+1, "(die_length %s)\n", FormatBIU( m_LengthDie ).c_str() );
|
||||
|
||||
if( m_LocalSolderMaskMargin != 0 )
|
||||
aFormatter->Print( aNestLevel+1, "(solder-mask-margin %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(solder_mask_margin %s)\n",
|
||||
FormatBIU( m_LocalSolderMaskMargin ).c_str() );
|
||||
|
||||
if( m_LocalSolderPasteMargin != 0 )
|
||||
aFormatter->Print( aNestLevel+1, "(solder-paste-margin %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(solder_paste_margin %s)\n",
|
||||
FormatBIU( m_LocalSolderPasteMargin ).c_str() );
|
||||
|
||||
if( m_LocalSolderPasteMarginRatio != 0 )
|
||||
aFormatter->Print( aNestLevel+1, "(solder-paste-margin-ratio %g)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(solder_paste_margin_ratio %g)\n",
|
||||
m_LocalSolderPasteMarginRatio );
|
||||
|
||||
if( m_LocalClearance != 0 )
|
||||
|
@ -909,14 +910,14 @@ void D_PAD::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
|
|||
FormatBIU( m_LocalClearance ).c_str() );
|
||||
|
||||
if( GetZoneConnection() != UNDEFINED_CONNECTION )
|
||||
aFormatter->Print( aNestLevel+1, "(zone-connect %d)\n", GetZoneConnection() );
|
||||
aFormatter->Print( aNestLevel+1, "(zone_connect %d)\n", GetZoneConnection() );
|
||||
|
||||
if( GetThermalWidth() != 0 )
|
||||
aFormatter->Print( aNestLevel+1, "(thermal-width %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(thermal_width %s)\n",
|
||||
FormatBIU( GetThermalWidth() ).c_str() );
|
||||
|
||||
if( GetThermalGap() != 0 )
|
||||
aFormatter->Print( aNestLevel+1, "(thermal-gap %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(thermal_gap %s)\n",
|
||||
FormatBIU( GetThermalGap() ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel, ")\n" );
|
||||
|
|
|
@ -194,12 +194,12 @@ EDA_ITEM* TEXTE_PCB::Clone() const
|
|||
void TEXTE_PCB::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
|
||||
throw( IO_ERROR )
|
||||
{
|
||||
aFormatter->Print( aNestLevel, "(pcb-text (layer %d)", GetLayer() );
|
||||
aFormatter->Print( aNestLevel, "(pcb_text (layer %d)", GetLayer() );
|
||||
|
||||
if( GetTimeStamp() )
|
||||
aFormatter->Print( aNestLevel, " (tstamp %lX)", GetTimeStamp() );
|
||||
aFormatter->Print( 0, " (tstamp %lX)", GetTimeStamp() );
|
||||
|
||||
aFormatter->Print( aNestLevel, "\n" );
|
||||
aFormatter->Print( 0, "\n" );
|
||||
|
||||
EDA_TEXT::Format( aFormatter, aNestLevel+1, aControlBits );
|
||||
|
||||
|
|
|
@ -491,10 +491,10 @@ void TEXTE_MODULE::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aCon
|
|||
if( parent )
|
||||
orient += parent->GetOrientation();
|
||||
|
||||
aFormatter->Print( aNestLevel, "(module-text %d (at %s %0.1f)%s)\n", m_Type,
|
||||
aFormatter->Print( aNestLevel, "(module_text %d (at %s %0.1f)%s\n", m_Type,
|
||||
FormatBIU( m_Pos0 ).c_str(), orient, (m_NoShow) ? "hide" : "" );
|
||||
|
||||
EDA_TEXT::Format( aFormatter+1, aNestLevel, aControlBits );
|
||||
EDA_TEXT::Format( aFormatter, aNestLevel+1, aControlBits );
|
||||
|
||||
aFormatter->Print( aNestLevel, ")\n" );
|
||||
}
|
||||
|
|
|
@ -1579,7 +1579,7 @@ void TRACK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
|
|||
FormatBIU( m_Start ).c_str(), FormatBIU( m_Width ).c_str() );
|
||||
|
||||
if( m_Drill != UNDEFINED_DRILL_DIAMETER )
|
||||
aFormatter->Print( aNestLevel, " (drill %s)", FormatBIU( m_Drill ).c_str() );
|
||||
aFormatter->Print( 0, " (drill %s)", FormatBIU( m_Drill ).c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1588,15 +1588,15 @@ void TRACK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBit
|
|||
FormatBIU( m_Width ).c_str() );
|
||||
}
|
||||
|
||||
aFormatter->Print( aNestLevel, " (layer %d) (net %d)", GetLayer(), GetNet() );
|
||||
aFormatter->Print( 0, " (layer %d) (net %d)", GetLayer(), GetNet() );
|
||||
|
||||
if( GetTimeStamp() != 0 )
|
||||
aFormatter->Print( aNestLevel, " (tstamp %lX)", GetTimeStamp() );
|
||||
aFormatter->Print( 0, " (tstamp %lX)", GetTimeStamp() );
|
||||
|
||||
if( GetStatus() != 0 )
|
||||
aFormatter->Print( aNestLevel, " (status %X)", GetStatus() );
|
||||
aFormatter->Print( 0, " (status %X)", GetStatus() );
|
||||
|
||||
aFormatter->Print( aNestLevel, ")\n" );
|
||||
aFormatter->Print( 0, ")\n" );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -960,7 +960,8 @@ void ZONE_CONTAINER::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aC
|
|||
throw( IO_ERROR )
|
||||
{
|
||||
aFormatter->Print( aNestLevel, "(zone (net %d %s) (layer %d) (tstamp %lX)\n",
|
||||
GetNet(), EscapedUTF8( m_Netname ).c_str(), GetLayer(), GetTimeStamp() );
|
||||
GetNet(), aFormatter->Quotew( m_Netname ).c_str(),
|
||||
GetLayer(), GetTimeStamp() );
|
||||
|
||||
|
||||
// Save the outline aux info
|
||||
|
@ -986,18 +987,18 @@ void ZONE_CONTAINER::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aC
|
|||
{
|
||||
default:
|
||||
case PAD_IN_ZONE: padoption = "yes"; break;
|
||||
case THERMAL_PAD: padoption = "use-thermal"; break;
|
||||
case THERMAL_PAD: padoption = "use_thermal"; break;
|
||||
case PAD_NOT_IN_ZONE: padoption = "no"; break;
|
||||
}
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(connect-pads %s (clearance %s))\n",
|
||||
aFormatter->Print( aNestLevel+1, "(connect_pads %s (clearance %s))\n",
|
||||
padoption.c_str(), FormatBIU( m_ZoneClearance ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel+1, "(min-thickness %s)\n",
|
||||
aFormatter->Print( aNestLevel+1, "(min_thickness %s)\n",
|
||||
FormatBIU( m_ZoneMinThickness ).c_str() );
|
||||
|
||||
aFormatter->Print( aNestLevel+1,
|
||||
"(fill %s (mode %s) (arc-segments %d) (thermal-gap %s) (thermal-bridge-width %s)\n",
|
||||
"(fill %s (mode %s) (arc_segments %d) (thermal_gap %s) (thermal_bridge_width %s)\n",
|
||||
(m_IsFilled) ? "yes" : "no",
|
||||
(m_FillMode) ? "segment" : "polygon",
|
||||
m_ArcToSegmentsCount,
|
||||
|
@ -1023,15 +1024,25 @@ void ZONE_CONTAINER::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aC
|
|||
|
||||
if( cv.size() )
|
||||
{
|
||||
aFormatter->Print( aNestLevel+1, "(polygon (pts" );
|
||||
aFormatter->Print( aNestLevel+1, "(polygon\n");
|
||||
aFormatter->Print( aNestLevel+2, "(pts\n" );
|
||||
|
||||
for( std::vector< CPolyPt >::const_iterator it = cv.begin(); it != cv.end(); ++it )
|
||||
{
|
||||
aFormatter->Print( aNestLevel+1, " (xy %s %s)",
|
||||
aFormatter->Print( aNestLevel+3, "(xy %s %s)\n",
|
||||
FormatBIU( it->x ).c_str(), FormatBIU( it->y ).c_str() );
|
||||
|
||||
if( it->end_contour )
|
||||
aFormatter->Print( aNestLevel+1, ")\n(polygon (pts" );
|
||||
{
|
||||
aFormatter->Print( aNestLevel+2, ")\n" );
|
||||
|
||||
if( it+1 != cv.end() )
|
||||
{
|
||||
aFormatter->Print( aNestLevel+1, ")\n" );
|
||||
aFormatter->Print( aNestLevel+1, "(polygon\n" );
|
||||
aFormatter->Print( aNestLevel+2, "(pts\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aFormatter->Print( aNestLevel+1, ")\n" );
|
||||
|
@ -1042,15 +1053,25 @@ void ZONE_CONTAINER::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aC
|
|||
|
||||
if( fv.size() )
|
||||
{
|
||||
aFormatter->Print( aNestLevel+1, "(filled-polygon (pts" );
|
||||
aFormatter->Print( aNestLevel+1, "(filled_polygon\n" );
|
||||
aFormatter->Print( aNestLevel+2, "(pts\n" );
|
||||
|
||||
for( std::vector< CPolyPt >::const_iterator it = fv.begin(); it != fv.end(); ++it )
|
||||
{
|
||||
aFormatter->Print( aNestLevel+1, " (xy %s %s)",
|
||||
aFormatter->Print( aNestLevel+3, "(xy %s %s)\n",
|
||||
FormatBIU( it->x ).c_str(), FormatBIU( it->y ).c_str() );
|
||||
|
||||
if( it->end_contour )
|
||||
aFormatter->Print( aNestLevel+1, ")\n(filled-polygon (pts" );
|
||||
{
|
||||
aFormatter->Print( aNestLevel+2, ")\n" );
|
||||
|
||||
if( it+1 != fv.end() )
|
||||
{
|
||||
aFormatter->Print( aNestLevel+1, ")\n" );
|
||||
aFormatter->Print( aNestLevel+1, "(filled_polygon\n" );
|
||||
aFormatter->Print( aNestLevel+2, "(pts\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aFormatter->Print( aNestLevel+1, ")\n" );
|
||||
|
@ -1061,7 +1082,7 @@ void ZONE_CONTAINER::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aC
|
|||
|
||||
if( segs.size() )
|
||||
{
|
||||
aFormatter->Print( aNestLevel+1, "(fill-segments\n" );
|
||||
aFormatter->Print( aNestLevel+1, "(fill_segments\n" );
|
||||
|
||||
for( std::vector< SEGMENT >::const_iterator it = segs.begin(); it != segs.end(); ++it )
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
#include <class_board.h>
|
||||
#include <build_version.h> // BOARD_FILE_VERSION
|
||||
#include <build_version.h> // LEGACY_BOARD_FILE_VERSION
|
||||
|
||||
|
||||
static const wxString pcbBackupFileExtension( wxT( "000" ) );
|
||||
|
@ -183,7 +183,7 @@ the changes?" ) ) )
|
|||
name = fileName.GetFullName();
|
||||
}
|
||||
|
||||
wxFileDialog dlg( this, _( "Open Board File" ), path, name, PcbFileWildcard,
|
||||
wxFileDialog dlg( this, _( "Open Board File" ), path, name, LegacyPcbFileWildcard,
|
||||
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
|
@ -230,12 +230,12 @@ the changes?" ) ) )
|
|||
int ver;
|
||||
sscanf( reader.Line() , "PCBNEW-BOARD Version %d date", &ver );
|
||||
|
||||
if ( ver > BOARD_FILE_VERSION )
|
||||
if ( ver > LEGACY_BOARD_FILE_VERSION )
|
||||
{
|
||||
DisplayInfoMessage( this, _( "This file was created by a more recent \
|
||||
version of Pcbnew and may not load correctly. Please consider updating!" ) );
|
||||
}
|
||||
else if ( ver < BOARD_FILE_VERSION )
|
||||
else if ( ver < LEGACY_BOARD_FILE_VERSION )
|
||||
{
|
||||
DisplayInfoMessage( this, _( "This file was created by an older \
|
||||
version of Pcbnew. It will be stored in the new file format when you save \
|
||||
|
@ -288,13 +288,13 @@ this file again." ) );
|
|||
try
|
||||
{
|
||||
// load or append either:
|
||||
loadedBoard = IO_MGR::Load( IO_MGR::KICAD, GetScreen()->GetFileName(),
|
||||
loadedBoard = IO_MGR::Load( IO_MGR::LEGACY, GetScreen()->GetFileName(),
|
||||
aAppend ? GetBoard() : NULL,
|
||||
NULL );
|
||||
|
||||
if( !aAppend )
|
||||
{
|
||||
if( loadedBoard->GetFileFormatVersionAtLoad() < BOARD_FILE_VERSION )
|
||||
if( loadedBoard->GetFileFormatVersionAtLoad() < LEGACY_BOARD_FILE_VERSION )
|
||||
{
|
||||
DisplayInfoMessage( this, _( "This file was created by an older \
|
||||
version of Pcbnew. It will be stored in the new file format when you save \
|
||||
|
@ -418,19 +418,27 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
|
|||
wxString upperTxt;
|
||||
wxString lowerTxt;
|
||||
wxString msg;
|
||||
wxString wildcard;
|
||||
|
||||
int wildcardIndex = 0;
|
||||
bool saveok = true;
|
||||
|
||||
wildcard = LegacyPcbFileWildcard;
|
||||
|
||||
#if defined( USE_PCBNEW_SEXPR_FILE_FORMAT )
|
||||
wildcard += wxT( "|" ) + PcbFileWildcard;
|
||||
#endif
|
||||
|
||||
if( aFileName == wxEmptyString )
|
||||
{
|
||||
wxFileDialog dlg( this, _( "Save Board File" ), wxEmptyString,
|
||||
GetScreen()->GetFileName(), PcbFileWildcard,
|
||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
||||
wxFileDialog dlg( this, _( "Save Board File" ), wxEmptyString, GetScreen()->GetFileName(),
|
||||
wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
return false;
|
||||
|
||||
GetScreen()->SetFileName( dlg.GetPath() );
|
||||
wildcardIndex = dlg.GetFilterIndex(); // Legacy or s-expression file format.
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -448,6 +456,9 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
|
|||
|
||||
pcbFileName = GetScreen()->GetFileName();
|
||||
|
||||
if( pcbFileName.GetExt().IsEmpty() )
|
||||
pcbFileName.SetExt( IO_MGR::GetFileExtension( (IO_MGR::PCB_FILE_T) wildcardIndex ) );
|
||||
|
||||
if( !IsWritable( pcbFileName ) )
|
||||
return false;
|
||||
|
||||
|
@ -493,16 +504,21 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
|
|||
|
||||
try
|
||||
{
|
||||
PROPERTIES props;
|
||||
PLUGIN* plugin = IO_MGR::PluginFind( ( IO_MGR::PCB_FILE_T ) wildcardIndex );
|
||||
|
||||
if( plugin == NULL )
|
||||
THROW_IO_ERROR( wxString::Format( _( "cannot find file plug in for file format '%s'" ),
|
||||
GetChars( pcbFileName.GetExt() ) ) );
|
||||
|
||||
wxString header = wxString::Format(
|
||||
wxT( "PCBNEW-BOARD Version %d date %s\n\n# Created by Pcbnew%s\n\n" ),
|
||||
BOARD_FILE_VERSION, DateAndTime().GetData(),
|
||||
LEGACY_BOARD_FILE_VERSION, DateAndTime().GetData(),
|
||||
GetBuildVersion().GetData() );
|
||||
|
||||
PROPERTIES props;
|
||||
|
||||
props["header"] = header;
|
||||
|
||||
IO_MGR::Save( IO_MGR::KICAD, pcbFileName.GetFullPath(), GetBoard(), &props );
|
||||
plugin->Save( pcbFileName.GetFullPath(), GetBoard(), &props );
|
||||
}
|
||||
catch( IO_ERROR ioe )
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
|
||||
#include <io_mgr.h>
|
||||
#include <legacy_plugin.h>
|
||||
#include <kicad_plugin.h>
|
||||
|
||||
|
||||
|
@ -39,7 +40,7 @@
|
|||
// plugins coexisting.
|
||||
|
||||
|
||||
// static KICAD_PLUGIN kicad_plugin; // a secret
|
||||
// static LEGACY_PLUGIN kicad_plugin; // a secret
|
||||
//static EAGLE_PLUGIN eagle_plugin;
|
||||
|
||||
PLUGIN* IO_MGR::PluginFind( PCB_FILE_T aFileType )
|
||||
|
@ -49,10 +50,12 @@ PLUGIN* IO_MGR::PluginFind( PCB_FILE_T aFileType )
|
|||
|
||||
switch( aFileType )
|
||||
{
|
||||
case LEGACY:
|
||||
return new LEGACY_PLUGIN();
|
||||
|
||||
case KICAD:
|
||||
return new KICAD_PLUGIN();
|
||||
|
||||
|
||||
/*
|
||||
case EAGLE:
|
||||
return &eagle_plugin;
|
||||
|
@ -80,12 +83,30 @@ const wxString IO_MGR::ShowType( PCB_FILE_T aFileType )
|
|||
default:
|
||||
return wxString::Format( _( "Unknown PCB_FILE_T value: %d" ), aFileType );
|
||||
|
||||
case LEGACY:
|
||||
return wxString( wxT( "KiCad Legacy" ) );
|
||||
|
||||
case KICAD:
|
||||
return wxString( wxT( "KiCad" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const wxString IO_MGR::GetFileExtension( PCB_FILE_T aFileType )
|
||||
{
|
||||
wxString ext = wxEmptyString;
|
||||
PLUGIN* plugin = PluginFind( aFileType );
|
||||
|
||||
if( plugin != NULL )
|
||||
{
|
||||
ext = plugin->GetFileExtension();
|
||||
PluginRelease( plugin );
|
||||
}
|
||||
|
||||
return ext;
|
||||
}
|
||||
|
||||
|
||||
BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName,
|
||||
BOARD* aAppendToMe, PROPERTIES* aProperties )
|
||||
{
|
||||
|
|
|
@ -47,7 +47,8 @@ public:
|
|||
*/
|
||||
enum PCB_FILE_T
|
||||
{
|
||||
KICAD,
|
||||
LEGACY, //< Legacy Pcbnew file formats prior to s-expression.
|
||||
KICAD, //< S-expression Pcbnew file format.
|
||||
// add your type here.
|
||||
|
||||
// EAGLE,
|
||||
|
@ -84,6 +85,16 @@ public:
|
|||
*/
|
||||
static const wxString ShowType( PCB_FILE_T aFileType );
|
||||
|
||||
/**
|
||||
* Function GetFileExtension
|
||||
* returns the file extension for \a aFileType.
|
||||
*
|
||||
* @param aFileType The #PCB_FILE_T type.
|
||||
* @return A wxString object containing the file extension for \a aFileType or an empty
|
||||
* string if \a aFileType is invalid.
|
||||
*/
|
||||
static const wxString GetFileExtension( PCB_FILE_T aFileType );
|
||||
|
||||
/**
|
||||
* Function Load
|
||||
* finds the requested PLUGIN and if found, calls the PLUGIN->Load(..) funtion
|
||||
|
@ -166,7 +177,13 @@ public:
|
|||
* Function PluginName
|
||||
* returns a brief hard coded name for this PLUGIN.
|
||||
*/
|
||||
virtual const wxString& PluginName() = 0;
|
||||
virtual const wxString& PluginName() const = 0;
|
||||
|
||||
/**
|
||||
* Function GetFileExtension
|
||||
* returns the file extension for the PLUGIN.
|
||||
*/
|
||||
virtual const wxString& GetFileExtension() const = 0;
|
||||
|
||||
/**
|
||||
* Function Load
|
||||
|
|
|
@ -1231,7 +1231,7 @@ int PCB_EDIT_FRAME::SavePcbFormatAscii( FILE* aFile )
|
|||
LOCALE_IO toggle;
|
||||
|
||||
// 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", LEGACY_BOARD_FILE_VERSION,
|
||||
TO_UTF8( DateAndTime() ) );
|
||||
fprintf( aFile, "# Created by Pcbnew%s\n\n", TO_UTF8( GetBuildVersion() ) );
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,10 +1,7 @@
|
|||
#ifndef KICAD_PLUGIN_H_
|
||||
#define KICAD_PLUGIN_H_
|
||||
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) CERN.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -24,50 +21,40 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef KICAD_PLUGIN_H_
|
||||
#define KICAD_PLUGIN_H_
|
||||
|
||||
#include <io_mgr.h>
|
||||
#include <string>
|
||||
|
||||
typedef int BIU;
|
||||
/** Current s-expression file format version. 2 was the last legacy format version. */
|
||||
#define SEXPR_BOARD_FILE_VERSION 3
|
||||
|
||||
class PCB_TARGET;
|
||||
class MODULE;
|
||||
class DRAWSEGMENT;
|
||||
class NETINFO;
|
||||
class TEXTE_PCB;
|
||||
class TRACK;
|
||||
class NETCLASS;
|
||||
class ZONE_CONTAINER;
|
||||
class DIMENSION;
|
||||
class NETINFO_ITEM;
|
||||
class TEXTE_MODULE;
|
||||
class EDGE_MODULE;
|
||||
class TRACK;
|
||||
class SEGZONE;
|
||||
class D_PAD;
|
||||
|
||||
/**
|
||||
* Class KICAD_PLUGIN
|
||||
* is a PLUGIN derivation which could possibly be put into a DLL/DSO.
|
||||
* It is not thread safe, but it is re-entrant multiple times in sequence.
|
||||
* is a PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
|
||||
*
|
||||
* @note This class is not thread safe, but it is re-entrant multiple times in sequence.
|
||||
*/
|
||||
class KICAD_PLUGIN : public PLUGIN
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//-----<PLUGIN>-------------------------------------------------------------
|
||||
|
||||
const wxString& PluginName()
|
||||
const wxString& PluginName() const
|
||||
{
|
||||
static const wxString name = wxT( "KiCad" );
|
||||
return name;
|
||||
}
|
||||
|
||||
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties = NULL ); // overload
|
||||
const wxString& GetFileExtension() const
|
||||
{
|
||||
static const wxString extension = wxT( "kicad_brd" );
|
||||
return extension;
|
||||
}
|
||||
|
||||
void Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties = NULL ); // overload
|
||||
|
||||
//-----</PLUGIN>------------------------------------------------------------
|
||||
void Save( const wxString& aFileName, BOARD* aBoard,
|
||||
PROPERTIES* aProperties = NULL ); // overload
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -76,159 +63,9 @@ protected:
|
|||
PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL.
|
||||
|
||||
LINE_READER* m_reader; ///< no ownership here.
|
||||
FILE* m_fp; ///< no ownership here.
|
||||
wxString m_filename; ///< for saves only, name is in m_reader for loads
|
||||
|
||||
wxString m_field; ///< reused to stuff MODULE fields.
|
||||
int m_loading_format_version; ///< which BOARD_FORMAT_VERSION am I Load()ing?
|
||||
|
||||
/// initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
|
||||
void init( PROPERTIES* aProperties );
|
||||
|
||||
double biuToDisk; ///< convert from BIUs to disk engineering units with this scale factor
|
||||
double diskToBiu; ///< convert from disk engineering units to BIUs with this scale factor
|
||||
|
||||
/**
|
||||
* Function biuParse
|
||||
* parses an ASCII decimal floating point value and scales it into a BIU
|
||||
* according to the current value of diskToBui. This fuction is the complement of
|
||||
* fmtBIU(). One has to know what the other is doing.
|
||||
*
|
||||
* @param aValue is the ASCII value in C locale form with possible leading whitespace
|
||||
*
|
||||
* @param nptrptr may be NULL, but if not, then it tells where to put a
|
||||
* pointer to the next unconsumed input text. See "man strtod" for more information.
|
||||
*
|
||||
* @return BIU - the converted Board Internal Unit.
|
||||
*/
|
||||
BIU biuParse( const char* aValue, const char** nptrptr = NULL );
|
||||
|
||||
/**
|
||||
* Function degParse
|
||||
* parses an ASCII decimal floating point value which is certainly an angle. This
|
||||
* is a dedicated function for encapsulating support for the migration from
|
||||
* tenths of degrees to degrees in floating point. This function is the complement of
|
||||
* fmtDEG(). One has to know what the other is doing.
|
||||
*
|
||||
* @param aValue is the ASCII value in C locale form with possible leading whitespace
|
||||
*
|
||||
* @param nptrptr may be NULL, but if not, then it tells where to put a
|
||||
* pointer to the next unconsumed input text. See "man strtod" for more information.
|
||||
*
|
||||
* @return double - the string converted to a primitive double type
|
||||
*/
|
||||
double degParse( const char* aValue, const char** nptrptr = NULL );
|
||||
|
||||
//-----<load/parse functions>-----------------------------------------------
|
||||
|
||||
void checkVersion();
|
||||
|
||||
void loadAllSections( bool doAppend );
|
||||
|
||||
void loadGENERAL();
|
||||
void loadSETUP();
|
||||
void loadSHEET();
|
||||
|
||||
void loadMODULE();
|
||||
void load3D( MODULE* aModule );
|
||||
void loadPAD( MODULE* aModule );
|
||||
void loadMODULE_TEXT( TEXTE_MODULE* aText );
|
||||
void loadMODULE_EDGE( MODULE* aModule );
|
||||
|
||||
void loadPCB_LINE();
|
||||
void loadNETINFO_ITEM();
|
||||
void loadPCB_TEXT();
|
||||
void loadNETCLASS();
|
||||
|
||||
/**
|
||||
* Function loadTrackList
|
||||
* reads a list of segments (Tracks and Vias, or Segzones)
|
||||
*
|
||||
* @param aInsertBeforeMe may be either NULL indicating append, or it may
|
||||
* be an insertion point before which all the segments are inserted.
|
||||
*
|
||||
* @param aStructType is either PCB_TRACE_T to indicate tracks and vias, or
|
||||
* PCB_ZONE_T to indicate oldschool zone segments (before polygons came to be).
|
||||
*/
|
||||
void loadTrackList( TRACK* aInsertBeforeMe, int aStructType );
|
||||
|
||||
void loadZONE_CONTAINER(); // "$CZONE_OUTLINE"
|
||||
void loadDIMENSION(); // "$COTATION"
|
||||
void loadPCB_TARGET(); // "$PCB_TARGET"
|
||||
|
||||
//-----</ load/parse functions>---------------------------------------------
|
||||
|
||||
|
||||
//-----<save functions>-----------------------------------------------------
|
||||
|
||||
/**
|
||||
* Function writeError
|
||||
* returns an error message wxString containing the filename being
|
||||
* currently written.
|
||||
*/
|
||||
wxString writeError() const;
|
||||
|
||||
/// encapsulate the BIU formatting tricks in one place.
|
||||
int biuSprintf( char* buf, BIU aValue ) const;
|
||||
|
||||
/**
|
||||
* Function fmtBIU
|
||||
* converts a BIU to engineering units by scaling and formatting to ASCII.
|
||||
* This function is the complement of biuParse(). One has to know what the
|
||||
* other is doing.
|
||||
*/
|
||||
std::string fmtBIU( BIU aValue ) const;
|
||||
|
||||
std::string fmtBIUPair( BIU first, BIU second ) const;
|
||||
|
||||
std::string fmtBIUPoint( const wxPoint& aPoint ) const
|
||||
{
|
||||
return fmtBIUPair( aPoint.x, aPoint.y );
|
||||
}
|
||||
|
||||
std::string fmtBIUSize( const wxSize& aSize ) const
|
||||
{
|
||||
return fmtBIUPair( aSize.x, aSize.y );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function fmtDEG
|
||||
* formats an angle in a way particular to a board file format. This function
|
||||
* is the opposite or complement of degParse(). One has to know what the
|
||||
* other is doing.
|
||||
*/
|
||||
std::string fmtDEG( double aAngle ) const;
|
||||
|
||||
void saveAllSections() const;
|
||||
void saveGENERAL() const;
|
||||
void saveSHEET() const;
|
||||
void saveSETUP() const;
|
||||
void saveBOARD() const;
|
||||
|
||||
void saveMODULE( const MODULE* aModule ) const;
|
||||
void saveMODULE_TEXT( const TEXTE_MODULE* aText ) const;
|
||||
void saveMODULE_EDGE( const EDGE_MODULE* aGraphic ) const;
|
||||
void savePAD( const D_PAD* aPad ) const;
|
||||
void save3D( const MODULE* aModule ) const;
|
||||
|
||||
void saveNETINFO_ITEM( const NETINFO_ITEM* aNet ) const;
|
||||
void saveNETCLASSES() const;
|
||||
void saveNETCLASS( const NETCLASS* aNetclass ) const;
|
||||
|
||||
void savePCB_TEXT( const TEXTE_PCB* aText ) const;
|
||||
void savePCB_TARGET( const PCB_TARGET* aTarget ) const;
|
||||
void savePCB_LINE( const DRAWSEGMENT* aStroke ) const;
|
||||
void saveDIMENTION( const DIMENSION* aDimension ) const;
|
||||
void saveTRACK( const TRACK* aTrack ) const;
|
||||
|
||||
/**
|
||||
* Function saveZONE_CONTAINER
|
||||
* saves the new polygon zones.
|
||||
*/
|
||||
void saveZONE_CONTAINER( const ZONE_CONTAINER* aZone ) const;
|
||||
|
||||
//-----</save functions>----------------------------------------------------
|
||||
|
||||
};
|
||||
|
||||
#endif // KICAD_PLUGIN_H_
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,240 @@
|
|||
#ifndef LEGACY_PLUGIN_H_
|
||||
#define LEGACY_PLUGIN_H_
|
||||
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <io_mgr.h>
|
||||
#include <string>
|
||||
|
||||
typedef int BIU;
|
||||
|
||||
class PCB_TARGET;
|
||||
class MODULE;
|
||||
class DRAWSEGMENT;
|
||||
class NETINFO;
|
||||
class TEXTE_PCB;
|
||||
class TRACK;
|
||||
class NETCLASS;
|
||||
class ZONE_CONTAINER;
|
||||
class DIMENSION;
|
||||
class NETINFO_ITEM;
|
||||
class TEXTE_MODULE;
|
||||
class EDGE_MODULE;
|
||||
class TRACK;
|
||||
class SEGZONE;
|
||||
class D_PAD;
|
||||
|
||||
/**
|
||||
* Class LEGACY_PLUGIN
|
||||
* is a PLUGIN derivation which could possibly be put into a DLL/DSO.
|
||||
* It is not thread safe, but it is re-entrant multiple times in sequence.
|
||||
*/
|
||||
class LEGACY_PLUGIN : public PLUGIN
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//-----<PLUGIN>-------------------------------------------------------------
|
||||
|
||||
const wxString& PluginName() const
|
||||
{
|
||||
static const wxString name = wxT( "KiCad-Legacy" );
|
||||
return name;
|
||||
}
|
||||
|
||||
const wxString& GetFileExtension() const
|
||||
{
|
||||
static const wxString extension = wxT( "brd" );
|
||||
return extension;
|
||||
}
|
||||
|
||||
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties = NULL ); // overload
|
||||
|
||||
void Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties = NULL ); // overload
|
||||
|
||||
//-----</PLUGIN>------------------------------------------------------------
|
||||
|
||||
protected:
|
||||
|
||||
wxString m_error; ///< for throwing exceptions
|
||||
BOARD* m_board; ///< which BOARD, no ownership here
|
||||
PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL.
|
||||
|
||||
LINE_READER* m_reader; ///< no ownership here.
|
||||
FILE* m_fp; ///< no ownership here.
|
||||
wxString m_filename; ///< for saves only, name is in m_reader for loads
|
||||
|
||||
wxString m_field; ///< reused to stuff MODULE fields.
|
||||
int m_loading_format_version; ///< which BOARD_FORMAT_VERSION am I Load()ing?
|
||||
|
||||
/// initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
|
||||
void init( PROPERTIES* aProperties );
|
||||
|
||||
double biuToDisk; ///< convert from BIUs to disk engineering units with this scale factor
|
||||
double diskToBiu; ///< convert from disk engineering units to BIUs with this scale factor
|
||||
|
||||
/**
|
||||
* Function biuParse
|
||||
* parses an ASCII decimal floating point value and scales it into a BIU
|
||||
* according to the current value of diskToBui. This fuction is the complement of
|
||||
* fmtBIU(). One has to know what the other is doing.
|
||||
*
|
||||
* @param aValue is the ASCII value in C locale form with possible leading whitespace
|
||||
*
|
||||
* @param nptrptr may be NULL, but if not, then it tells where to put a
|
||||
* pointer to the next unconsumed input text. See "man strtod" for more information.
|
||||
*
|
||||
* @return BIU - the converted Board Internal Unit.
|
||||
*/
|
||||
BIU biuParse( const char* aValue, const char** nptrptr = NULL );
|
||||
|
||||
/**
|
||||
* Function degParse
|
||||
* parses an ASCII decimal floating point value which is certainly an angle. This
|
||||
* is a dedicated function for encapsulating support for the migration from
|
||||
* tenths of degrees to degrees in floating point. This function is the complement of
|
||||
* fmtDEG(). One has to know what the other is doing.
|
||||
*
|
||||
* @param aValue is the ASCII value in C locale form with possible leading whitespace
|
||||
*
|
||||
* @param nptrptr may be NULL, but if not, then it tells where to put a
|
||||
* pointer to the next unconsumed input text. See "man strtod" for more information.
|
||||
*
|
||||
* @return double - the string converted to a primitive double type
|
||||
*/
|
||||
double degParse( const char* aValue, const char** nptrptr = NULL );
|
||||
|
||||
//-----<load/parse functions>-----------------------------------------------
|
||||
|
||||
void checkVersion();
|
||||
|
||||
void loadAllSections( bool doAppend );
|
||||
|
||||
void loadGENERAL();
|
||||
void loadSETUP();
|
||||
void loadSHEET();
|
||||
|
||||
void loadMODULE();
|
||||
void load3D( MODULE* aModule );
|
||||
void loadPAD( MODULE* aModule );
|
||||
void loadMODULE_TEXT( TEXTE_MODULE* aText );
|
||||
void loadMODULE_EDGE( MODULE* aModule );
|
||||
|
||||
void loadPCB_LINE();
|
||||
void loadNETINFO_ITEM();
|
||||
void loadPCB_TEXT();
|
||||
void loadNETCLASS();
|
||||
|
||||
/**
|
||||
* Function loadTrackList
|
||||
* reads a list of segments (Tracks and Vias, or Segzones)
|
||||
*
|
||||
* @param aInsertBeforeMe may be either NULL indicating append, or it may
|
||||
* be an insertion point before which all the segments are inserted.
|
||||
*
|
||||
* @param aStructType is either PCB_TRACE_T to indicate tracks and vias, or
|
||||
* PCB_ZONE_T to indicate oldschool zone segments (before polygons came to be).
|
||||
*/
|
||||
void loadTrackList( TRACK* aInsertBeforeMe, int aStructType );
|
||||
|
||||
void loadZONE_CONTAINER(); // "$CZONE_OUTLINE"
|
||||
void loadDIMENSION(); // "$COTATION"
|
||||
void loadPCB_TARGET(); // "$PCB_TARGET"
|
||||
|
||||
//-----</ load/parse functions>---------------------------------------------
|
||||
|
||||
|
||||
//-----<save functions>-----------------------------------------------------
|
||||
|
||||
/**
|
||||
* Function writeError
|
||||
* returns an error message wxString containing the filename being
|
||||
* currently written.
|
||||
*/
|
||||
wxString writeError() const;
|
||||
|
||||
/// encapsulate the BIU formatting tricks in one place.
|
||||
int biuSprintf( char* buf, BIU aValue ) const;
|
||||
|
||||
/**
|
||||
* Function fmtBIU
|
||||
* converts a BIU to engineering units by scaling and formatting to ASCII.
|
||||
* This function is the complement of biuParse(). One has to know what the
|
||||
* other is doing.
|
||||
*/
|
||||
std::string fmtBIU( BIU aValue ) const;
|
||||
|
||||
std::string fmtBIUPair( BIU first, BIU second ) const;
|
||||
|
||||
std::string fmtBIUPoint( const wxPoint& aPoint ) const
|
||||
{
|
||||
return fmtBIUPair( aPoint.x, aPoint.y );
|
||||
}
|
||||
|
||||
std::string fmtBIUSize( const wxSize& aSize ) const
|
||||
{
|
||||
return fmtBIUPair( aSize.x, aSize.y );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function fmtDEG
|
||||
* formats an angle in a way particular to a board file format. This function
|
||||
* is the opposite or complement of degParse(). One has to know what the
|
||||
* other is doing.
|
||||
*/
|
||||
std::string fmtDEG( double aAngle ) const;
|
||||
|
||||
void saveAllSections() const;
|
||||
void saveGENERAL() const;
|
||||
void saveSHEET() const;
|
||||
void saveSETUP() const;
|
||||
void saveBOARD() const;
|
||||
|
||||
void saveMODULE( const MODULE* aModule ) const;
|
||||
void saveMODULE_TEXT( const TEXTE_MODULE* aText ) const;
|
||||
void saveMODULE_EDGE( const EDGE_MODULE* aGraphic ) const;
|
||||
void savePAD( const D_PAD* aPad ) const;
|
||||
void save3D( const MODULE* aModule ) const;
|
||||
|
||||
void saveNETINFO_ITEM( const NETINFO_ITEM* aNet ) const;
|
||||
void saveNETCLASSES() const;
|
||||
void saveNETCLASS( const NETCLASS* aNetclass ) const;
|
||||
|
||||
void savePCB_TEXT( const TEXTE_PCB* aText ) const;
|
||||
void savePCB_TARGET( const PCB_TARGET* aTarget ) const;
|
||||
void savePCB_LINE( const DRAWSEGMENT* aStroke ) const;
|
||||
void saveDIMENTION( const DIMENSION* aDimension ) const;
|
||||
void saveTRACK( const TRACK* aTrack ) const;
|
||||
|
||||
/**
|
||||
* Function saveZONE_CONTAINER
|
||||
* saves the new polygon zones.
|
||||
*/
|
||||
void saveZONE_CONTAINER( const ZONE_CONTAINER* aZone ) const;
|
||||
|
||||
//-----</save functions>----------------------------------------------------
|
||||
|
||||
};
|
||||
|
||||
#endif // LEGACY_PLUGIN_H_
|
Loading…
Reference in New Issue