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.
This commit is contained in:
jean-pierre charras 2020-04-12 19:50:33 +02:00
parent bcf31ef3d1
commit 5405c09b81
7 changed files with 32 additions and 22 deletions

View File

@ -30,6 +30,7 @@
#include <settings/settings_manager.h> #include <settings/settings_manager.h>
#include <wx/config.h> #include <wx/config.h>
#include <widgets/ui_common.h> #include <widgets/ui_common.h>
#include <general.h> // For some default values
///! Update the schema version whenever a migration is required ///! Update the schema version whenever a migration is required
const int eeschemaSchemaVersion = 0; const int eeschemaSchemaVersion = 0;
@ -78,13 +79,13 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() : APP_SETTINGS_BASE( "eeschema", eeschema
&m_AutoplaceFields.align_to_grid, true ) ); &m_AutoplaceFields.align_to_grid, true ) );
m_params.emplace_back( new PARAM<int>( "drawing.default_bus_thickness", m_params.emplace_back( new PARAM<int>( "drawing.default_bus_thickness",
&m_Drawing.default_bus_thickness, 12 ) ); &m_Drawing.default_bus_thickness, DEFAULT_BUS_THICKNESS ) );
m_params.emplace_back( new PARAM<int>( "drawing.default_junction_size", m_params.emplace_back( new PARAM<int>( "drawing.default_junction_size",
&m_Drawing.default_junction_size, 40 ) ); &m_Drawing.default_junction_size, DEFAULT_JUNCTION_DIAM ) );
m_params.emplace_back( new PARAM<int>( "drawing.default_line_thickness", m_params.emplace_back( new PARAM<int>( "drawing.default_line_thickness",
&m_Drawing.default_line_thickness, 6 ) ); &m_Drawing.default_line_thickness, DEFAULT_LINE_THICKNESS ) );
m_params.emplace_back( new PARAM<int>( "drawing.default_repeat_offset_x", m_params.emplace_back( new PARAM<int>( "drawing.default_repeat_offset_x",
&m_Drawing.default_repeat_offset_x, 0 ) ); &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_Drawing.default_repeat_offset_y, 100 ) );
m_params.emplace_back( new PARAM<int>( "drawing.default_wire_thickness", m_params.emplace_back( new PARAM<int>( "drawing.default_wire_thickness",
&m_Drawing.default_wire_thickness, 6 ) ); &m_Drawing.default_wire_thickness, DEFAULT_WIRE_THICKNESS ) );
m_params.emplace_back( m_params.emplace_back(
new PARAM<wxString>( "drawing.field_names", &m_Drawing.field_names, "" ) ); new PARAM<wxString>( "drawing.field_names", &m_Drawing.field_names, "" ) );

View File

@ -54,11 +54,20 @@ class ERC_SETTINGS;
///< The default pin name size when creating pins(can be changed in preference menu) ///< The default pin name size when creating pins(can be changed in preference menu)
#define DEFAULTPINNAMESIZE 50 #define DEFAULTPINNAMESIZE 50
///< The default selection highlight thickness ///< The default selection highlight thickness (can be changed in preference menu)
#define DEFAULTSELECTIONTHICKNESS 3 #define DEFAULTSELECTIONTHICKNESS 3
///< The default line width in mils. ///< The default line width in mils. (can be changed in preference menu)
#define DEFAULT_LINE_WIDTH 6 #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 /* Rotation, mirror of graphic items in components bodies are handled by a
* transform matrix. The default matrix is useful to draw lib entries with * transform matrix. The default matrix is useful to draw lib entries with

View File

@ -82,11 +82,11 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindo
const wxString& aTitle, const wxPoint& aPosition, const wxString& aTitle, const wxPoint& aPosition,
const wxSize& aSize, long aStyle, const wxString& aFrameName ) : const wxSize& aSize, long aStyle, const wxString& aFrameName ) :
EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition, aSize, aStyle, aFrameName ), EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition, aSize, aStyle, aFrameName ),
m_defaultLineWidth( 0 ), m_defaultLineWidth( DEFAULT_LINE_THICKNESS * IU_PER_MILS ),
m_defaultWireThickness( 0 ), m_defaultWireThickness( DEFAULT_WIRE_THICKNESS * IU_PER_MILS ),
m_defaultBusThickness( 0 ), m_defaultBusThickness( DEFAULT_BUS_THICKNESS * IU_PER_MILS ),
m_defaultTextSize( 0 ), m_defaultTextSize( 50.0 * IU_PER_MILS ),
m_repeatDeltaLabel( 0 ), m_repeatDeltaLabel( 1 ),
m_showPinElectricalTypeName( false ), m_showPinElectricalTypeName( false ),
m_dragActionIsMove( false ), m_dragActionIsMove( false ),
m_repeatComponent( false ), m_repeatComponent( false ),

View File

@ -74,9 +74,9 @@ SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() :
m_ShowDisabled( false ), m_ShowDisabled( false ),
m_ShowUmbilicals( true ), m_ShowUmbilicals( true ),
m_OverrideItemColors( false ), m_OverrideItemColors( false ),
m_DefaultLineWidth( 0 ), m_DefaultLineWidth( DEFAULT_LINE_THICKNESS * IU_PER_MILS ),
m_DefaultWireThickness( 0 ), m_DefaultWireThickness( DEFAULT_WIRE_THICKNESS * IU_PER_MILS ),
m_DefaultBusThickness( 0 ) m_DefaultBusThickness( DEFAULT_BUS_THICKNESS * IU_PER_MILS )
{ } { }

View File

@ -394,7 +394,7 @@ void SCH_SEXPR_PARSER::parseStroke( STROKE_PARAMS& aStroke )
wxCHECK_RET( CurTok() == T_stroke, wxCHECK_RET( CurTok() == T_stroke,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a 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_Type = PLOT_DASH_TYPE::DEFAULT;
aStroke.m_Color = COLOR4D::UNSPECIFIED; aStroke.m_Color = COLOR4D::UNSPECIFIED;

View File

@ -71,7 +71,7 @@ public:
PLOT_DASH_TYPE m_Type; PLOT_DASH_TYPE m_Type;
COLOR4D m_Color; 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, PLOT_DASH_TYPE aType = PLOT_DASH_TYPE::DEFAULT,
const COLOR4D& aColor = COLOR4D::UNSPECIFIED ) : const COLOR4D& aColor = COLOR4D::UNSPECIFIED ) :
m_Width( aWidth ), m_Width( aWidth ),

View File

@ -1618,7 +1618,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveArc( LIB_ARC* aArc,
bool needsSpace = false; bool needsSpace = false;
bool onNewLine = 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( 0, "\n" );
aFormatter.Print( aNestLevel + 1, "(stroke (width %s))", aFormatter.Print( aNestLevel + 1, "(stroke (width %s))",
@ -1691,7 +1691,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveBezier( LIB_BEZIER* aBezier,
bool needsSpace = false; 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))", aFormatter.Print( aNestLevel + 1, "(stroke (width %s))",
FormatInternalUnits( aBezier->GetWidth() ).c_str() ); 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->GetPosition().y ).c_str(),
FormatInternalUnits( aCircle->GetRadius() ).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))", aFormatter.Print( 0, " (stroke (width %s))",
FormatInternalUnits( aCircle->GetWidth() ).c_str() ); FormatInternalUnits( aCircle->GetWidth() ).c_str() );
@ -1879,7 +1879,7 @@ void SCH_SEXPR_PLUGIN_CACHE::savePolyLine( LIB_POLYLINE* aPolyLine,
bool needsSpace = false; 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))", aFormatter.Print( aNestLevel + 1, "(stroke (width %s))",
FormatInternalUnits( aPolyLine->GetWidth() ).c_str() ); FormatInternalUnits( aPolyLine->GetWidth() ).c_str() );
@ -1923,7 +1923,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveRectangle( LIB_RECTANGLE* aRectangle,
bool needsSpace = false; 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))", aFormatter.Print( 0, " (stroke (width %s))",
FormatInternalUnits( aRectangle->GetWidth() ).c_str() ); FormatInternalUnits( aRectangle->GetWidth() ).c_str() );