ADDED: polygon newlines every point
By default KiCad will now print each polygon point on its own line. This adds to the vertical distance for large polygons but makes revision control much cleaner as single point addition to a polygon does not propagate to a diff over the full polygon. Users/developers who want to save the files using the 4-points per line have the ADVANCED_CONFIG setting 'CompactSave' which will provide the original save method
This commit is contained in:
parent
b0c6a0f9ef
commit
0a4ce183a4
|
@ -85,6 +85,12 @@ static const wxChar CoroutineStackSize[] = wxT( "CoroutineStackSize" );
|
|||
*/
|
||||
static const wxChar ShowRouterDebugGraphics[] = wxT( "ShowRouterDebugGraphics" );
|
||||
|
||||
/**
|
||||
* When set to true, this will wrap polygon point sets at 4 points per line rather
|
||||
* than a single point per line. Single point per line helps with version control systems
|
||||
*/
|
||||
static const wxChar CompactFileSave[] = wxT( "CompactSave" );
|
||||
|
||||
} // namespace KEYS
|
||||
|
||||
|
||||
|
@ -211,6 +217,9 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
|
|||
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::ShowRouterDebugGraphics,
|
||||
&m_ShowRouterDebugGraphics, false ) );
|
||||
|
||||
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::CompactFileSave,
|
||||
&m_CompactSave, false ) );
|
||||
|
||||
wxConfigLoadSetups( &aCfg, configParams );
|
||||
|
||||
for( auto param : configParams )
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <wx/filename.h>
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
#include <advanced_config.h>
|
||||
#include <build_version.h>
|
||||
#include <gal/color4d.h>
|
||||
#include <pgm_base.h>
|
||||
|
@ -1860,10 +1861,10 @@ void SCH_SEXPR_PLUGIN_CACHE::savePolyLine( LIB_POLYLINE* aPolyLine,
|
|||
|
||||
for( const auto& pt : aPolyLine->GetPolyPoints() )
|
||||
{
|
||||
if( newLine == 4 )
|
||||
if( newLine == 4 || !ADVANCED_CFG::GetCfg().m_CompactSave )
|
||||
{
|
||||
aFormatter.Print( 0, "\n" );
|
||||
aFormatter.Print( aNestLevel + 3, " (xy %s %s)",
|
||||
aFormatter.Print( aNestLevel + 2, "(xy %s %s)",
|
||||
FormatInternalUnits( pt.x ).c_str(),
|
||||
FormatInternalUnits( pt.y ).c_str() );
|
||||
newLine = 0;
|
||||
|
|
|
@ -88,6 +88,12 @@ public:
|
|||
*/
|
||||
bool m_ShowRouterDebugGraphics;
|
||||
|
||||
/**
|
||||
* Save files in compact display mode
|
||||
* When is is not specified, points are written one per line
|
||||
*/
|
||||
bool m_CompactSave;
|
||||
|
||||
|
||||
private:
|
||||
ADVANCED_CFG();
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include <build_version.h> // LEGACY_BOARD_FILE_VERSION
|
||||
#include <macros.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
#include <advanced_config.h>
|
||||
#include <base_units.h>
|
||||
#include <trace_helpers.h>
|
||||
#include <class_board.h>
|
||||
|
@ -742,11 +744,20 @@ void PCB_IO::format( DRAWSEGMENT* aSegment, int aNestLevel ) const
|
|||
SHAPE_LINE_CHAIN& outline = poly.Outline( 0 );
|
||||
int pointsCount = outline.PointCount();
|
||||
|
||||
m_out->Print( aNestLevel, "(gr_poly (pts" );
|
||||
m_out->Print( aNestLevel, "(gr_poly (pts\n" );
|
||||
|
||||
for( int ii = 0; ii < pointsCount; ++ii )
|
||||
{
|
||||
m_out->Print( 0, " (xy %s)", FormatInternalUnits( outline.CPoint( ii ) ).c_str() );
|
||||
int nestLevel = 0;
|
||||
|
||||
if( ii && ( !( ii%4 ) || !ADVANCED_CFG::GetCfg().m_CompactSave ) ) // newline every 4 pts
|
||||
{
|
||||
nestLevel = aNestLevel + 1;
|
||||
m_out->Print( 0, "\n" );
|
||||
}
|
||||
|
||||
m_out->Print( nestLevel, "%s(xy %s)",
|
||||
nestLevel ? "" : " ", FormatInternalUnits( outline.CPoint( ii ) ).c_str() );
|
||||
}
|
||||
|
||||
m_out->Print( 0, ")" );
|
||||
|
@ -828,7 +839,7 @@ void PCB_IO::format( EDGE_MODULE* aModuleDrawing, int aNestLevel ) const
|
|||
{
|
||||
int nestLevel = 0;
|
||||
|
||||
if( ii && !( ii%4 ) ) // newline every 4 pts
|
||||
if( ii && ( !( ii%4 ) || !ADVANCED_CFG::GetCfg().m_CompactSave ) ) // newline every 4 pts
|
||||
{
|
||||
nestLevel = aNestLevel + 1;
|
||||
m_out->Print( 0, "\n" );
|
||||
|
@ -1420,13 +1431,13 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const
|
|||
for( const VECTOR2I &pt : primitive->GetPolyShape().COutline( 0 ).CPoints() )
|
||||
{
|
||||
if( newLine == 0 )
|
||||
m_out->Print( nested_level+1, " (xy %s)",
|
||||
m_out->Print( nested_level+1, "(xy %s)",
|
||||
FormatInternalUnits( (wxPoint) pt ).c_str() );
|
||||
else
|
||||
m_out->Print( 0, " (xy %s)",
|
||||
FormatInternalUnits( (wxPoint) pt ).c_str() );
|
||||
|
||||
if( ++newLine > 4 )
|
||||
if( ++newLine > 4 || !ADVANCED_CFG::GetCfg().m_CompactSave )
|
||||
{
|
||||
newLine = 0;
|
||||
m_out->Print( 0, "\n" );
|
||||
|
@ -1796,7 +1807,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
|
|||
FormatInternalUnits( iterator->x ).c_str(),
|
||||
FormatInternalUnits( iterator->y ).c_str() );
|
||||
|
||||
if( newLine < 4 )
|
||||
if( newLine < 4 && ADVANCED_CFG::GetCfg().m_CompactSave )
|
||||
{
|
||||
newLine += 1;
|
||||
}
|
||||
|
@ -1867,7 +1878,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
|
|||
m_out->Print( 0, " (xy %s %s)", FormatInternalUnits( it->x ).c_str(),
|
||||
FormatInternalUnits( it->y ).c_str() );
|
||||
|
||||
if( newLine < 4 )
|
||||
if( newLine < 4 && ADVANCED_CFG::GetCfg().m_CompactSave )
|
||||
{
|
||||
newLine += 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue