From 5405c09b8191a7b37b5634249e070e585713e8bc Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 12 Apr 2020 19:50:33 +0200 Subject: [PATCH] Eeschema: avoid initializing default line thickness to 0: it can create issues. Some graphic line thickness were initialized to 0. The actual line thickness is set after reading config. But in some cases the config does not exist, and 0 line thickness creates draw issues. --- eeschema/eeschema_settings.cpp | 9 +++++---- eeschema/general.h | 15 ++++++++++++--- eeschema/sch_base_frame.cpp | 10 +++++----- eeschema/sch_painter.cpp | 6 +++--- eeschema/sch_sexpr_parser.cpp | 2 +- eeschema/sch_sexpr_parser.h | 2 +- eeschema/sch_sexpr_plugin.cpp | 10 +++++----- 7 files changed, 32 insertions(+), 22 deletions(-) diff --git a/eeschema/eeschema_settings.cpp b/eeschema/eeschema_settings.cpp index 2c76fceb05..9dbea6428a 100644 --- a/eeschema/eeschema_settings.cpp +++ b/eeschema/eeschema_settings.cpp @@ -30,6 +30,7 @@ #include #include #include +#include // For some default values ///! Update the schema version whenever a migration is required const int eeschemaSchemaVersion = 0; @@ -78,13 +79,13 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() : APP_SETTINGS_BASE( "eeschema", eeschema &m_AutoplaceFields.align_to_grid, true ) ); m_params.emplace_back( new PARAM( "drawing.default_bus_thickness", - &m_Drawing.default_bus_thickness, 12 ) ); + &m_Drawing.default_bus_thickness, DEFAULT_BUS_THICKNESS ) ); m_params.emplace_back( new PARAM( "drawing.default_junction_size", - &m_Drawing.default_junction_size, 40 ) ); + &m_Drawing.default_junction_size, DEFAULT_JUNCTION_DIAM ) ); m_params.emplace_back( new PARAM( "drawing.default_line_thickness", - &m_Drawing.default_line_thickness, 6 ) ); + &m_Drawing.default_line_thickness, DEFAULT_LINE_THICKNESS ) ); m_params.emplace_back( new PARAM( "drawing.default_repeat_offset_x", &m_Drawing.default_repeat_offset_x, 0 ) ); @@ -93,7 +94,7 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() : APP_SETTINGS_BASE( "eeschema", eeschema &m_Drawing.default_repeat_offset_y, 100 ) ); m_params.emplace_back( new PARAM( "drawing.default_wire_thickness", - &m_Drawing.default_wire_thickness, 6 ) ); + &m_Drawing.default_wire_thickness, DEFAULT_WIRE_THICKNESS ) ); m_params.emplace_back( new PARAM( "drawing.field_names", &m_Drawing.field_names, "" ) ); diff --git a/eeschema/general.h b/eeschema/general.h index cfcfebaf90..ab923b7029 100644 --- a/eeschema/general.h +++ b/eeschema/general.h @@ -54,11 +54,20 @@ class ERC_SETTINGS; ///< The default pin name size when creating pins(can be changed in preference menu) #define DEFAULTPINNAMESIZE 50 -///< The default selection highlight thickness +///< The default selection highlight thickness (can be changed in preference menu) #define DEFAULTSELECTIONTHICKNESS 3 -///< The default line width in mils. -#define DEFAULT_LINE_WIDTH 6 +///< The default line width in mils. (can be changed in preference menu) +#define DEFAULT_LINE_THICKNESS 6 + +///< The default wire width in mils. (can be changed in preference menu) +#define DEFAULT_WIRE_THICKNESS 6 + +///< The default bus width in mils. (can be changed in preference menu) +#define DEFAULT_BUS_THICKNESS 12 + +///< The default function diameter in mils. (can be changed in preference menu) +#define DEFAULT_JUNCTION_DIAM 40 /* Rotation, mirror of graphic items in components bodies are handled by a * transform matrix. The default matrix is useful to draw lib entries with diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index c733af22c4..fe94df0192 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -82,11 +82,11 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindo const wxString& aTitle, const wxPoint& aPosition, const wxSize& aSize, long aStyle, const wxString& aFrameName ) : EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition, aSize, aStyle, aFrameName ), - m_defaultLineWidth( 0 ), - m_defaultWireThickness( 0 ), - m_defaultBusThickness( 0 ), - m_defaultTextSize( 0 ), - m_repeatDeltaLabel( 0 ), + m_defaultLineWidth( DEFAULT_LINE_THICKNESS * IU_PER_MILS ), + m_defaultWireThickness( DEFAULT_WIRE_THICKNESS * IU_PER_MILS ), + m_defaultBusThickness( DEFAULT_BUS_THICKNESS * IU_PER_MILS ), + m_defaultTextSize( 50.0 * IU_PER_MILS ), + m_repeatDeltaLabel( 1 ), m_showPinElectricalTypeName( false ), m_dragActionIsMove( false ), m_repeatComponent( false ), diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index c225d56c56..081353c709 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -74,9 +74,9 @@ SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() : m_ShowDisabled( false ), m_ShowUmbilicals( true ), m_OverrideItemColors( false ), - m_DefaultLineWidth( 0 ), - m_DefaultWireThickness( 0 ), - m_DefaultBusThickness( 0 ) + m_DefaultLineWidth( DEFAULT_LINE_THICKNESS * IU_PER_MILS ), + m_DefaultWireThickness( DEFAULT_WIRE_THICKNESS * IU_PER_MILS ), + m_DefaultBusThickness( DEFAULT_BUS_THICKNESS * IU_PER_MILS ) { } diff --git a/eeschema/sch_sexpr_parser.cpp b/eeschema/sch_sexpr_parser.cpp index f687160835..7024eeb4a9 100644 --- a/eeschema/sch_sexpr_parser.cpp +++ b/eeschema/sch_sexpr_parser.cpp @@ -394,7 +394,7 @@ void SCH_SEXPR_PARSER::parseStroke( STROKE_PARAMS& aStroke ) wxCHECK_RET( CurTok() == T_stroke, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a stroke." ) ); - aStroke.m_Width = Mils2iu( DEFAULT_LINE_WIDTH ); + aStroke.m_Width = Mils2iu( DEFAULT_LINE_THICKNESS ); aStroke.m_Type = PLOT_DASH_TYPE::DEFAULT; aStroke.m_Color = COLOR4D::UNSPECIFIED; diff --git a/eeschema/sch_sexpr_parser.h b/eeschema/sch_sexpr_parser.h index d4f7cc6a02..29e8feb961 100644 --- a/eeschema/sch_sexpr_parser.h +++ b/eeschema/sch_sexpr_parser.h @@ -71,7 +71,7 @@ public: PLOT_DASH_TYPE m_Type; COLOR4D m_Color; - STROKE_PARAMS( int aWidth = Mils2iu( DEFAULT_LINE_WIDTH ), + STROKE_PARAMS( int aWidth = Mils2iu( DEFAULT_LINE_THICKNESS ), PLOT_DASH_TYPE aType = PLOT_DASH_TYPE::DEFAULT, const COLOR4D& aColor = COLOR4D::UNSPECIFIED ) : m_Width( aWidth ), diff --git a/eeschema/sch_sexpr_plugin.cpp b/eeschema/sch_sexpr_plugin.cpp index d8acc31cf7..819cf22300 100644 --- a/eeschema/sch_sexpr_plugin.cpp +++ b/eeschema/sch_sexpr_plugin.cpp @@ -1618,7 +1618,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveArc( LIB_ARC* aArc, bool needsSpace = false; bool onNewLine = false; - if( aArc->GetWidth() != 0 && aArc->GetWidth() != Mils2iu( DEFAULT_LINE_WIDTH ) ) + if( aArc->GetWidth() != 0 && aArc->GetWidth() != Mils2iu( DEFAULT_LINE_THICKNESS ) ) { aFormatter.Print( 0, "\n" ); aFormatter.Print( aNestLevel + 1, "(stroke (width %s))", @@ -1691,7 +1691,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveBezier( LIB_BEZIER* aBezier, bool needsSpace = false; - if( aBezier->GetWidth() != 0 && aBezier->GetWidth() != Mils2iu( DEFAULT_LINE_WIDTH ) ) + if( aBezier->GetWidth() != 0 && aBezier->GetWidth() != Mils2iu( DEFAULT_LINE_THICKNESS ) ) { aFormatter.Print( aNestLevel + 1, "(stroke (width %s))", FormatInternalUnits( aBezier->GetWidth() ).c_str() ); @@ -1731,7 +1731,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveCircle( LIB_CIRCLE* aCircle, FormatInternalUnits( aCircle->GetPosition().y ).c_str(), FormatInternalUnits( aCircle->GetRadius() ).c_str() ); - if( aCircle->GetWidth() != 0 && aCircle->GetWidth() != Mils2iu( DEFAULT_LINE_WIDTH ) ) + if( aCircle->GetWidth() != 0 && aCircle->GetWidth() != Mils2iu( DEFAULT_LINE_THICKNESS ) ) { aFormatter.Print( 0, " (stroke (width %s))", FormatInternalUnits( aCircle->GetWidth() ).c_str() ); @@ -1879,7 +1879,7 @@ void SCH_SEXPR_PLUGIN_CACHE::savePolyLine( LIB_POLYLINE* aPolyLine, bool needsSpace = false; - if( aPolyLine->GetWidth() != 0 && aPolyLine->GetWidth() != Mils2iu( DEFAULT_LINE_WIDTH ) ) + if( aPolyLine->GetWidth() != 0 && aPolyLine->GetWidth() != Mils2iu( DEFAULT_LINE_THICKNESS ) ) { aFormatter.Print( aNestLevel + 1, "(stroke (width %s))", FormatInternalUnits( aPolyLine->GetWidth() ).c_str() ); @@ -1923,7 +1923,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveRectangle( LIB_RECTANGLE* aRectangle, bool needsSpace = false; - if( aRectangle->GetWidth() != 0 && aRectangle->GetWidth() != Mils2iu( DEFAULT_LINE_WIDTH ) ) + if( aRectangle->GetWidth() != 0 && aRectangle->GetWidth() != Mils2iu( DEFAULT_LINE_THICKNESS ) ) { aFormatter.Print( 0, " (stroke (width %s))", FormatInternalUnits( aRectangle->GetWidth() ).c_str() );