Move separation of model name from params earlier in the process.

We need just the model name when we look for a match in the library file.
This commit is contained in:
Jeff Young 2023-03-25 12:15:19 +00:00
parent e65a58b823
commit 60aadfee40
1 changed files with 17 additions and 4 deletions

View File

@ -1685,6 +1685,7 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject )
wxString spiceDeviceType = spiceDeviceInfo.m_Text.Trim( true ).Trim( false );
wxString spiceLib = spiceLibInfo.m_Text.Trim( true ).Trim( false );
wxString spiceModel = spiceModelInfo.m_Text.Trim( true ).Trim( false );
wxString modelLineParams;
bool libraryModel = false;
bool inferredModel = false;
@ -1697,6 +1698,10 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject )
SIM_LIB_MGR libMgr( aProject, &reporter );
std::vector<T_field> emptyFields;
// Pull out any following parameters from model name
spiceModel = spiceModel.BeforeFirst( ' ', &modelLineParams );
spiceModelInfo.m_Text = spiceModel;
SIM_LIBRARY::MODEL model = libMgr.CreateModel( spiceLib, spiceModel.ToStdString(),
emptyFields, sourcePins );
@ -1789,18 +1794,26 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject )
T_field libraryField = spiceLibInfo.CreateField( &aSymbol, SIM_LIBRARY_FIELD );
aSymbol.AddField( libraryField );
// Split library model name from any following parameters
wxString modelLineParams;
spiceModelInfo.m_Text = spiceModelInfo.m_Text.BeforeFirst( ' ', &modelLineParams );
T_field nameField = spiceModelInfo.CreateField( &aSymbol, SIM_NAME_FIELD );
aSymbol.AddField( nameField );
if( !modelLineParams.IsEmpty() )
{
spiceParamsInfo = spiceModelInfo;
spiceParamsInfo.m_Pos.x += nameField.GetBoundingBox().GetWidth();
spiceParamsInfo.m_Text = modelLineParams;
BOX2I nameBBox = nameField.GetBoundingBox();
int nameWidth = nameBBox.GetWidth();
// Add space between model name and additional parameters
nameWidth += KiROUND( nameBBox.GetHeight() * 1.25 );
if( nameField.GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
spiceParamsInfo.m_Pos.x -= nameWidth;
else
spiceParamsInfo.m_Pos.x += nameWidth;
T_field paramsField = spiceParamsInfo.CreateField( &aSymbol, SIM_PARAMS_FIELD );
aSymbol.AddField( paramsField );
}