From e910dc0092f1f4b3c6a2eca2e092de6e7e5b1b27 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 9 Aug 2020 21:51:40 +0100 Subject: [PATCH] Make sure lines/wires/busses get default widths if not spec'ed. Fixes https://gitlab.com/kicad/code/kicad/issues/4854 --- eeschema/sch_junction.cpp | 4 +-- eeschema/sch_line.cpp | 38 ++++++++++++++++++++--- eeschema/tools/sch_line_wire_bus_tool.cpp | 2 ++ 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index 7fe1a3b7ed..35cf09bfd0 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -83,8 +83,8 @@ const EDA_RECT SCH_JUNCTION::GetBoundingBox() const { EDA_RECT rect; - int size = - Schematic() ? Schematic()->Settings().m_JunctionSize : Mils2iu( DEFAULT_JUNCTION_DIAM ); + int size = Schematic() ? Schematic()->Settings().m_JunctionSize + : Mils2iu( DEFAULT_JUNCTION_DIAM ); if( m_diameter != 0 ) size = m_diameter; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 4bc45a834e..5567c32fcb 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -271,13 +271,41 @@ int SCH_LINE::GetPenWidth() const { NETCLASSPTR netclass = NetClass(); - if( netclass ) - return ( m_Layer == LAYER_BUS ) ? netclass->GetBusWidth() : netclass->GetWireWidth(); + switch ( m_Layer ) + { + default: + if( m_stroke.GetWidth() > 0 ) + return m_stroke.GetWidth(); - if( m_stroke.GetWidth() == 0 && Schematic() ) - return std::max( Schematic()->Settings().m_DefaultLineWidth, 1 ); + if( Schematic() ) + return Schematic()->Settings().m_DefaultLineWidth; - return std::max( m_stroke.GetWidth(), 1 ); + return DEFAULT_LINE_THICKNESS; + + case LAYER_WIRE: + if( netclass ) + return netclass->GetWireWidth(); + + if( m_stroke.GetWidth() > 0 ) + return m_stroke.GetWidth(); + + if( Schematic() ) + return Schematic()->Settings().m_DefaultWireThickness; + + return DEFAULT_WIRE_THICKNESS; + + case LAYER_BUS: + if( netclass ) + return netclass->GetBusWidth(); + + if( m_stroke.GetWidth() > 0 ) + return m_stroke.GetWidth(); + + if( Schematic() ) + return Schematic()->Settings().m_DefaultBusThickness; + + return DEFAULT_BUS_THICKNESS; + } } diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index 4ac25199b0..c004f2bee7 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -731,6 +731,8 @@ SCH_LINE* SCH_LINE_WIRE_BUS_TOOL::startSegments( int aType, const VECTOR2D& aPos break; } + // Give segments a parent so they find the default line/wire/bus widths + segment->SetParent( &m_frame->Schematic() ); segment->SetFlags( IS_NEW | IS_MOVED ); m_wires.push_back( segment );