From 48bbde65b36997d3c89620aac209f66e7a9c7e1e Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 5 Sep 2018 16:30:48 -0700 Subject: [PATCH] pcbnew: Set default line width for invalids Invalid graphical items that cannot be created in pcbnew may still be created by external tools. This synchronizes the pcbnew view display with the gerber output and 3d viewer line widths for these types of lines. Only filled polygons are permitted 0-width lines. Fixes: lp:1790534 * https://bugs.launchpad.net/kicad/+bug/1790534 --- include/board_design_settings.h | 1 + pcbnew/pcb_parser.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/board_design_settings.h b/include/board_design_settings.h index 2d7cc9ec93..1368717836 100644 --- a/include/board_design_settings.h +++ b/include/board_design_settings.h @@ -33,6 +33,7 @@ // Some default values for the board editor and the fp editor (given in mm) #define DEFAULT_TEXT_MODULE_SIZE 1.0 #define DEFAULT_GR_MODULE_THICKNESS 0.15 // given in mm +#define DEFAULT_LINE_WIDTH 0.10 // Board thickness, mainly for 3D view: #define DEFAULT_BOARD_THICKNESS_MM 1.6 diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index d9ecfa8829..9dba0bdec6 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -1531,6 +1531,12 @@ DRAWSEGMENT* PCB_PARSER::parseDRAWSEGMENT() NeedRIGHT(); } + // Only filled polygons may have a zero-line width + // This is not permitted in KiCad but some external tools generate invalid + // files. + if( segment->GetShape() != S_POLYGON && segment->GetWidth() == 0 ) + segment->SetWidth( Millimeter2iu( DEFAULT_LINE_WIDTH ) ); + return segment.release(); } @@ -2282,6 +2288,12 @@ EDGE_MODULE* PCB_PARSER::parseEDGE_MODULE() NeedRIGHT(); } + // Only filled polygons may have a zero-line width + // This is not permitted in KiCad but some external tools generate invalid + // files. + if( segment->GetShape() != S_POLYGON && segment->GetWidth() == 0 ) + segment->SetWidth( Millimeter2iu( DEFAULT_LINE_WIDTH ) ); + return segment.release(); }