Make sure lines/wires/busses get default widths if not spec'ed.

Fixes https://gitlab.com/kicad/code/kicad/issues/4854
This commit is contained in:
Jeff Young 2020-08-09 21:51:40 +01:00
parent ec0d8dc5e5
commit e910dc0092
3 changed files with 37 additions and 7 deletions

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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 );