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_XOrg; // remember last User Origin X value
double m_YOrg; // remember last User Origin Y value double m_YOrg; // remember last User Origin Y value
wxString m_boardPath; // path to the exported board file wxString m_boardPath; // path to the exported board file
static int m_toleranceLastChoice; // Store m_tolerance option during a session
protected: protected:
void onUpdateUnits( wxUpdateUIEvent& aEvent ) override; void onUpdateUnits( wxUpdateUIEvent& aEvent ) override;
@ -111,6 +112,7 @@ public:
~DIALOG_EXPORT_STEP(); ~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::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString& aBoardPath ) :
DIALOG_EXPORT_STEP_BASE( aParent ) 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; 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 // Now all widgets have the size fixed, call FinishDialogSettings
finishDialogSettings(); finishDialogSettings();
} }
@ -245,6 +250,8 @@ DIALOG_EXPORT_STEP::~DIALOG_EXPORT_STEP()
cfg->m_ExportStep.origin_y = val; cfg->m_ExportStep.origin_y = val;
cfg->m_ExportStep.no_virtual = m_cbRemoveVirtual->GetValue(); 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() ); m_parent->SetLastPath( LAST_PATH_STEP, m_filePickerSTEP->GetPath() );
double tolerance; // default value in mm double tolerance; // default value in mm
m_toleranceLastChoice = m_tolerance->GetSelection();
switch( m_tolerance->GetSelection() ) switch( m_tolerance->GetSelection() )
{ {
@ -414,7 +422,7 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
} }
LOCALE_IO dummy; 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 ) ); quote, xOrg, yOrg, quote ) );
} }
break; break;
@ -425,7 +433,7 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
xOrg = Iu2Millimeter( bbox.GetCenter().x ); xOrg = Iu2Millimeter( bbox.GetCenter().x );
yOrg = Iu2Millimeter( bbox.GetCenter().y ); yOrg = Iu2Millimeter( bbox.GetCenter().y );
LOCALE_IO dummy; 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 ) ); quote, xOrg, yOrg, quote ) );
} }
break; break;
@ -433,7 +441,7 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
{ {
LOCALE_IO dummy; LOCALE_IO dummy;
cmdK2S.Append( wxString::Format( wxT( " --min-distance=%c%.3f mm%c" ), cmdK2S.Append( wxString::Format( wxT( " --min-distance=%c%.3fmm%c" ),
quote, tolerance, quote ) ); quote, tolerance, quote ) );
} }

View File

@ -86,7 +86,7 @@ static const wxCmdLineEntryDesc cmdLineDesc[] = {
_( "Substitute STEP or IGS models with the same name in place of VRML models" ).mb_str(), _( "Substitute STEP or IGS models with the same name in place of VRML models" ).mb_str(),
wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_OPTION, NULL, "min-distance", { wxCMD_LINE_OPTION, NULL, "min-distance",
_( "Minimum distance between points to treat them as separate ones (default 0.01 mm)" ) _( "Minimum distance between points to treat them as separate ones (default 0.01mm)" )
.mb_str(), .mb_str(),
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_SWITCH, "h", NULL, _( "display this message" ).mb_str(), wxCMD_LINE_VAL_NONE, { wxCMD_LINE_SWITCH, "h", NULL, _( "display this message" ).mb_str(), wxCMD_LINE_VAL_NONE,
@ -156,23 +156,28 @@ bool KICAD2MCAD_APP::OnCmdLineParsed( wxCmdLineParser& parser )
std::regex_search( str, sm, re_pattern ); std::regex_search( str, sm, re_pattern );
m_params.m_xOrigin = atof( sm.str( 1 ).c_str() ); m_params.m_xOrigin = atof( sm.str( 1 ).c_str() );
m_params.m_yOrigin = atof( sm.str( 2 ).c_str() ); m_params.m_yOrigin = atof( sm.str( 2 ).c_str() );
std::string tunit( sm[3] ); std::string tunit( sm[3] );
if( ( !sm.str( 1 ).compare( " " ) || !sm.str( 2 ).compare( " " ) ) || ( sm.size() != 4 ) ) if( tunit.size() > 0 ) // No unit accepted ( default = mm )
{ {
parser.Usage(); if( ( !sm.str( 1 ).compare( " " ) || !sm.str( 2 ).compare( " " ) ) || ( sm.size() != 4 ) )
return false; {
} parser.Usage();
return false;
}
if( !tunit.compare( "in" ) || !tunit.compare( "inch" ) ) // only in, inch and mm are valid:
{ if( !tunit.compare( "in" ) || !tunit.compare( "inch" ) )
m_params.m_xOrigin *= 25.4; {
m_params.m_yOrigin *= 25.4; m_params.m_xOrigin *= 25.4;
} m_params.m_yOrigin *= 25.4;
else if( tunit.compare( "mm" ) ) }
{ else if( tunit.compare( "mm" ) )
parser.Usage(); {
return false; parser.Usage();
return false;
}
} }
} }