From b1fd462d283a9ef85608728f71bf5e750cf6ab12 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 1 Aug 2021 11:44:45 +0200 Subject: [PATCH] Gerbview, Excellon reader: use Leading Zeros format when not specified in file. Some very poor files do not specify the coordinates format. In this case, the default is INCH,LZ that looks like the more usual. --- gerbview/excellon_image.h | 9 ++++----- gerbview/excellon_read_drill_file.cpp | 17 ++++++++++++++--- gerbview/gerber_file_image.h | 3 +++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/gerbview/excellon_image.h b/gerbview/excellon_image.h index 84bc736d4b..cb24e0c6ec 100644 --- a/gerbview/excellon_image.h +++ b/gerbview/excellon_image.h @@ -142,11 +142,10 @@ public: EXCELLON_IMAGE( int layer ) : ~EXCELLON_IMAGE() {}; - virtual void ResetDefaultValues() override - { - GERBER_FILE_IMAGE::ResetDefaultValues(); - SelectUnits( false ); - } + /** + * Set all parameters to a default value, before reading a file + */ + virtual void ResetDefaultValues() override; /** diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp index b9adc21159..4b1ce3ee3f 100644 --- a/gerbview/excellon_read_drill_file.cpp +++ b/gerbview/excellon_read_drill_file.cpp @@ -293,6 +293,19 @@ bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName ) return success; } + +void EXCELLON_IMAGE::ResetDefaultValues() +{ + GERBER_FILE_IMAGE::ResetDefaultValues(); + SelectUnits( false ); // Default unit = inch + + // Files using non decimal can use No Trailing zeros or No leading Zeros + // Unfortunately, the identifier (INCH,TZ or INCH,LZ for instance) is not + // always set in drill files. + // The option leading zeros looks like more frequent, so use this default + m_NoTrailingZeros = true; +} + /* * Read a EXCELLON file. * Gerber classes are used because there is likeness between Gerber files @@ -305,7 +318,6 @@ bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName ) * integer 2.4 format in imperial units, * integer 3.2 or 3.3 format (metric units). */ - bool EXCELLON_IMAGE::LoadFile( const wxString & aFullFileName ) { // Set the default parameter values: @@ -473,8 +485,7 @@ bool EXCELLON_IMAGE::Execute_HEADER_And_M_Command( char*& text ) if( *text != ',' ) { // No TZ or LZ specified. Should be a decimal format - // but this is not always the case. Use default TZ setting as default - m_NoTrailingZeros = false; + // but this is not always the case. Use our default setting break; } diff --git a/gerbview/gerber_file_image.h b/gerbview/gerber_file_image.h index 45d660b60c..348448a894 100644 --- a/gerbview/gerber_file_image.h +++ b/gerbview/gerber_file_image.h @@ -135,6 +135,9 @@ public: */ int GetDcodesCount(); + /** + * Set all parameters to a default value, before reading a file + */ virtual void ResetDefaultValues(); COLOR4D GetPositiveDrawColor() const { return m_PositiveDrawColor; }