From ad29a2f3b44a692ff92d0f1fa3006f9f2ba309ec Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sun, 4 Oct 2020 00:56:42 +0100 Subject: [PATCH] Update more places to properly display mils --- gerbview/gerber_file_image.cpp | 19 ++++++++++-- gerbview/gerbview_frame.cpp | 29 ++++++++++++++++--- gerbview/toolbars_gerber.cpp | 26 +++++++++++++++-- pcbnew/dialogs/dialog_board_statistics.cpp | 17 +++++++++-- pcbnew/exporters/gen_footprints_placefile.cpp | 2 +- 5 files changed, 82 insertions(+), 11 deletions(-) diff --git a/gerbview/gerber_file_image.cpp b/gerbview/gerber_file_image.cpp index f43f064eb3..119864fdec 100644 --- a/gerbview/gerber_file_image.cpp +++ b/gerbview/gerber_file_image.cpp @@ -357,12 +357,27 @@ void GERBER_FILE_IMAGE::DisplayImageInfo( GERBVIEW_FRAME* aMainFrame ) msg = m_ImageJustifyYCenter ? _("Center") : _("Normal"); aMainFrame->AppendMsgPanel( _( "Y Justify" ), msg, DARKRED ); - if( aMainFrame->GetUserUnits() == EDA_UNITS::INCHES ) + switch( aMainFrame->GetUserUnits() ) + { + case EDA_UNITS::MILS: + msg.Printf( wxT( "X=%f Y=%f" ), Iu2Mils( m_ImageJustifyOffset.x ), + Iu2Mils( m_ImageJustifyOffset.y ) ); + break; + + case EDA_UNITS::INCHES: msg.Printf( wxT( "X=%f Y=%f" ), Iu2Mils( m_ImageJustifyOffset.x ) / 1000.0, Iu2Mils( m_ImageJustifyOffset.y ) / 1000.0 ); - else + break; + + case EDA_UNITS::MILLIMETRES: msg.Printf( wxT( "X=%f Y=%f" ), Iu2Millimeter( m_ImageJustifyOffset.x ), Iu2Millimeter( m_ImageJustifyOffset.y ) ); + break; + + default: + wxASSERT_MSG( false, "Invalid unit" ); + } + aMainFrame->AppendMsgPanel( _( "Image Justify Offset" ), msg, DARKRED ); } diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 817a4df7cc..b0cb0a9bfc 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -540,8 +540,31 @@ void GERBVIEW_FRAME::Liste_D_Codes() int ii, jj; wxString Line; wxArrayString list; - double scale = GetUserUnits() == EDA_UNITS::INCHES ? IU_PER_MILS * 1000 : IU_PER_MM; - int curr_layer = GetActiveLayer(); + int curr_layer = GetActiveLayer(); + + double scale = 1.0; + wxString units; + + switch( GetUserUnits() ) + { + case EDA_UNITS::MILLIMETRES: + scale = IU_PER_MM; + units = "mm"; + break; + + case EDA_UNITS::INCHES: + scale = IU_PER_MILS * 1000; + units = "in"; + break; + + case EDA_UNITS::MILS: + scale = IU_PER_MILS; + units = "mil"; + break; + + default: + wxASSERT_MSG( false, "Invalid units" ); + } for( int layer = 0; layer < (int)ImagesMaxCount(); ++layer ) { @@ -560,8 +583,6 @@ void GERBVIEW_FRAME::Liste_D_Codes() list.Add( Line ); - const char* units = GetUserUnits() == EDA_UNITS::INCHES ? "\"" : "mm"; - for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ ) { D_CODE* pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE ); diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index 43cb26e724..275d7b124d 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -299,8 +299,30 @@ void GERBVIEW_FRAME::updateDCodeSelectBox() // Build the aperture list of the current layer, and add it to the combo box: wxArrayString dcode_list; wxString msg; - const char* units = GetUserUnits() == EDA_UNITS::INCHES ? "mils" : "mm"; - double scale = GetUserUnits() == EDA_UNITS::INCHES ? IU_PER_MILS : IU_PER_MM; + + double scale = 1.0; + wxString units; + + switch( GetUserUnits() ) + { + case EDA_UNITS::MILLIMETRES: + scale = IU_PER_MM; + units = "mm"; + break; + + case EDA_UNITS::INCHES: + scale = IU_PER_MILS * 1000; + units = "in"; + break; + + case EDA_UNITS::MILS: + scale = IU_PER_MILS; + units = "mil"; + break; + + default: + wxASSERT_MSG( false, "Invalid units" ); + } for( int ii = 0; ii < TOOLS_MAX_COUNT; ii++ ) { diff --git a/pcbnew/dialogs/dialog_board_statistics.cpp b/pcbnew/dialogs/dialog_board_statistics.cpp index 310c6df4e7..8627b4c19c 100644 --- a/pcbnew/dialogs/dialog_board_statistics.cpp +++ b/pcbnew/dialogs/dialog_board_statistics.cpp @@ -337,10 +337,23 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB() } } - if( GetUserUnits() == EDA_UNITS::INCHES ) + switch( GetUserUnits() ) + { + case EDA_UNITS::INCHES: m_boardArea /= ( IU_PER_MILS * IU_PER_MILS * 1000000 ); - else + break; + + case EDA_UNITS::MILS: + m_boardArea /= ( IU_PER_MILS * IU_PER_MILS ); + break; + + case EDA_UNITS::MILLIMETRES: m_boardArea /= ( IU_PER_MM * IU_PER_MM ); + break; + + default: + wxASSERT_MSG( false, "Invalid unit" ); + } m_boardWidth = bbox.GetWidth(); m_boardHeight = bbox.GetHeight(); diff --git a/pcbnew/exporters/gen_footprints_placefile.cpp b/pcbnew/exporters/gen_footprints_placefile.cpp index 054daf7086..9acfd569c5 100644 --- a/pcbnew/exporters/gen_footprints_placefile.cpp +++ b/pcbnew/exporters/gen_footprints_placefile.cpp @@ -513,7 +513,7 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event ) fn.SetPath( dirDialog.GetPath() ); fn.SetExt( wxT( "rpt" ) ); - bool unitMM = GetUserUnits() != EDA_UNITS::INCHES; + bool unitMM = GetUserUnits() == EDA_UNITS::MILLIMETRES; bool success = DoGenFootprintsReport( fn.GetFullPath(), unitMM ); wxString msg;