Kicad2step: fix STEP export from Pcbnew, broken by changes in commit 8456d6c

also: DIALOG_EXPORT_STEP: remember tolerance option during a session.
This commit is contained in:
jean-pierre charras 2022-07-01 09:44:10 +02:00
parent 939313088e
commit 2ff2a6ffcd
2 changed files with 30 additions and 17 deletions

View File

@ -67,6 +67,7 @@ private:
double m_XOrg; // remember last User Origin X value
double m_YOrg; // remember last User Origin Y value
wxString m_boardPath; // path to the exported board file
static int m_toleranceLastChoice; // Store m_tolerance option during a session
protected:
void onUpdateUnits( wxUpdateUIEvent& aEvent ) override;
@ -111,6 +112,7 @@ public:
~DIALOG_EXPORT_STEP();
};
int DIALOG_EXPORT_STEP::m_toleranceLastChoice = -1; // Use default
DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString& aBoardPath ) :
DIALOG_EXPORT_STEP_BASE( aParent )
@ -220,6 +222,9 @@ DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString&
Pgm().GetCommonSettings()->m_DoNotShowAgain.scaled_3d_models_warning = true;
}
if( m_toleranceLastChoice >= 0 )
m_tolerance->SetSelection( m_toleranceLastChoice );
// Now all widgets have the size fixed, call FinishDialogSettings
finishDialogSettings();
}
@ -245,6 +250,8 @@ DIALOG_EXPORT_STEP::~DIALOG_EXPORT_STEP()
cfg->m_ExportStep.origin_y = val;
cfg->m_ExportStep.no_virtual = m_cbRemoveVirtual->GetValue();
m_toleranceLastChoice = m_tolerance->GetSelection();
}
@ -310,6 +317,7 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
m_parent->SetLastPath( LAST_PATH_STEP, m_filePickerSTEP->GetPath() );
double tolerance; // default value in mm
m_toleranceLastChoice = m_tolerance->GetSelection();
switch( m_tolerance->GetSelection() )
{
@ -414,7 +422,7 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
}
LOCALE_IO dummy;
cmdK2S.Append( wxString::Format( wxT( " --user-origin=%c%.6f x %.6f%c" ),
cmdK2S.Append( wxString::Format( wxT( " --user-origin=%c%.6fx%.6fmm%c" ),
quote, xOrg, yOrg, quote ) );
}
break;
@ -425,7 +433,7 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
xOrg = Iu2Millimeter( bbox.GetCenter().x );
yOrg = Iu2Millimeter( bbox.GetCenter().y );
LOCALE_IO dummy;
cmdK2S.Append( wxString::Format( wxT( " --user-origin=%c%.6f x %.6f%c" ),
cmdK2S.Append( wxString::Format( wxT( " --user-origin=%c%.6fx%.6fmm%c" ),
quote, xOrg, yOrg, quote ) );
}
break;

View File

@ -156,14 +156,18 @@ bool KICAD2MCAD_APP::OnCmdLineParsed( wxCmdLineParser& parser )
std::regex_search( str, sm, re_pattern );
m_params.m_xOrigin = atof( sm.str( 1 ).c_str() );
m_params.m_yOrigin = atof( sm.str( 2 ).c_str() );
std::string tunit( sm[3] );
if( tunit.size() > 0 ) // No unit accepted ( default = mm )
{
if( ( !sm.str( 1 ).compare( " " ) || !sm.str( 2 ).compare( " " ) ) || ( sm.size() != 4 ) )
{
parser.Usage();
return false;
}
// only in, inch and mm are valid:
if( !tunit.compare( "in" ) || !tunit.compare( "inch" ) )
{
m_params.m_xOrigin *= 25.4;
@ -175,6 +179,7 @@ bool KICAD2MCAD_APP::OnCmdLineParsed( wxCmdLineParser& parser )
return false;
}
}
}
if( parser.Found( wxT( "min-distance" ), &tstr ) )
{