From c650d476268783fd8d4fc367020848a65d7bd52a Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 8 Jun 2021 16:33:06 -0700 Subject: [PATCH] Add warning message on non-unity scaling When exporting STEP model, warn the user if one of their footprints has a non-unity scaled model as this compromises the integrity of the STEP export. Fixes https://gitlab.com/kicad/code/kicad/issues/1781 --- pcbnew/dialogs/dialog_export_step.cpp | 49 +++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/pcbnew/dialogs/dialog_export_step.cpp b/pcbnew/dialogs/dialog_export_step.cpp index 5a88d15e38..c755c067a4 100644 --- a/pcbnew/dialogs/dialog_export_step.cpp +++ b/pcbnew/dialogs/dialog_export_step.cpp @@ -26,15 +26,18 @@ #include #include -#include "pcb_edit_frame.h" -#include "kiface_i.h" -#include "confirm.h" -#include "reporter.h" -#include "board.h" -#include "dialog_export_step_base.h" + +#include +#include +#include +#include +#include #include +#include +#include #include #include // LAST_PATH_TYPE +#include #include @@ -178,6 +181,40 @@ DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString& tmpStr << m_YOrg; m_STEP_Yorg->SetValue( tmpStr ); + wxString bad_scales; + size_t bad_count = 0; + + for( auto& fp : aParent->GetBoard()->Footprints() ) + { + for( auto& model : fp->Models() ) + { + + if( model.m_Scale.x != 1.0 || + model.m_Scale.y != 1.0 || + model.m_Scale.z != 1.0 ) + { + bad_scales.Append( wxS("\n") ); + bad_scales.Append( model.m_Filename ); + bad_count++; + } + } + + if( bad_count >= 5 ) + break; + } + + if( !bad_scales.empty() ) + { + wxString extendedMsg = _( "Non-unity scaled models:" ) + "\n" + bad_scales; + + KIDIALOG msgDlg( m_parent, _( "Scaled models detected. " + "Model scaling is not reliable for mechanical export." ), + _( "Model Scale Warning" ), wxOK | wxICON_WARNING ); + msgDlg.SetExtendedMessage( extendedMsg ); + msgDlg.DoNotShowCheckbox( __FILE__, __LINE__ ); + + msgDlg.ShowModal(); + } // Now all widgets have the size fixed, call FinishDialogSettings finishDialogSettings(); }