Allow passing parameters for SPICE file

This commit is contained in:
Vadim Kuznetsov 2025-01-07 21:28:32 +03:00
parent 25df9f1a4b
commit f842cf2d7d
3 changed files with 23 additions and 7 deletions

View File

@ -81,20 +81,30 @@ SpiceDialog::SpiceDialog(QucsApp* App_, SpiceFile *c, Schematic *d)
topGrid->addWidget(FileEdit, 1,1);
topGrid->addWidget(ButtBrowse, 1,2);
ParamsEdit = new QLineEdit;
ParamsEdit->setText(Comp->getProperty("Params")->Value);
ParamsEdit->setToolTip(tr("Set SPICE parameters string as a plain text.\n"
"Example:\n"
"V0=1.0 I0=2.0"));
ParamCheck = new QCheckBox(tr("Show"));
ParamCheck->setChecked(Comp->getProperty("Params")->display);
topGrid->addWidget(new QLabel(tr("SPICE parameters:")), 2,0);
topGrid->addWidget(ParamsEdit, 2,1);
topGrid->addWidget(ParamCheck, 2,2);
FileCheck = new QCheckBox(tr("show file name in schematic"), myParent);
ButtEdit = new QPushButton(tr("Edit"), myParent);
connect(ButtEdit, SIGNAL(clicked()), SLOT(slotButtEdit()));
topGrid->addWidget(FileCheck, 2, 1);
topGrid->addWidget(ButtEdit, 2, 2);
topGrid->addWidget(FileCheck, 3, 1);
topGrid->addWidget(ButtEdit, 3, 2);
SimCheck = new QCheckBox(tr("include SPICE simulations"), myParent);
topGrid->addWidget(SimCheck, 3,1);
topGrid->addWidget(SimCheck, 4,1);
QHBoxLayout *hcenter = new QHBoxLayout;
topGrid->addLayout(hcenter, 4, 1);
topGrid->addLayout(hcenter, 5, 1);
hcenter->setSpacing(5);
PrepCombo = new QComboBox();
@ -269,6 +279,9 @@ void SpiceDialog::slotButtApply()
changed = true;
}
Comp->getProperty("Params")->Value = ParamsEdit->text();
Comp->getProperty("Params")->display = ParamCheck->isChecked();
if(changed || Comp->withSim) // because of "sim" text
{
Doc->recreateComponent(Comp); // to apply changes to the schematic symbol

View File

@ -73,8 +73,8 @@ private:
QRegularExpressionValidator *Validator, *ValRestrict;
QRegularExpression Expr;
QListWidget *NodesList, *PortsList;
QCheckBox *FileCheck, *SimCheck;
QLineEdit *FileEdit, *CompNameEdit;
QCheckBox *FileCheck, *SimCheck, *ParamCheck;
QLineEdit *FileEdit, *CompNameEdit, *ParamsEdit;
QPushButton *ButtBrowse, *ButtEdit, *ButtAdd, *ButtRemove,
*ButtOK, *ButtApply, *ButtCancel;
QComboBox *PrepCombo;

View File

@ -47,6 +47,7 @@ SpiceFile::SpiceFile()
Props.append(new Property("Ports", "", false, QStringLiteral("x")));
Props.append(new Property("Sim", "yes", false, QStringLiteral("x")));
Props.append(new Property("Preprocessor", "none", false, QStringLiteral("x")));
Props.append(new Property("Params", "", false, QStringLiteral("x")));
withSim = false;
Model = "SPICE";
@ -505,7 +506,9 @@ QString SpiceFile::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecom
s += " "+Ports.at(i)->Connection->Name; // node names
}
s += " " + spicecompat::getSubcktName(getSubcircuitFile()) + "\n";
s += " " + spicecompat::getSubcktName(getSubcircuitFile());
s += " " + getProperty("Params")->Value;
s += "\n";
return s;
}