23 #include <QTextStream>
24 #include <Q3GridLayout>
25 #include <Q3VBoxLayout>
34 #include <QFileDialog>
35 #include <QPushButton>
39 #include <QMessageBox>
44 : QDialog(d, 0, TRUE, Qt::WDestructiveClose)
49 setCaption(tr(
"Edit SPICE Component Properties"));
53 all =
new Q3VBoxLayout(
this);
54 QWidget *myParent =
this;
56 Expr.setPattern(
"[^\"=]+");
58 Expr.setPattern(
"[\\w_]+");
63 Q3GridLayout *topGrid =
new Q3GridLayout(0, 4,3,3,3);
64 all->addLayout(topGrid);
66 topGrid->addWidget(
new QLabel(tr(
"Name:"), myParent), 0,0);
72 topGrid->addWidget(
new QLabel(tr(
"File:"), myParent), 1,0);
78 ButtBrowse =
new QPushButton(tr(
"Browse"), myParent);
82 ButtEdit =
new QPushButton(tr(
"Edit"), myParent);
86 FileCheck =
new QCheckBox(tr(
"show file name in schematic"), myParent);
89 SimCheck =
new QCheckBox(tr(
"include SPICE simulations"), myParent);
92 Q3HBox *h1 =
new Q3HBox(myParent);
99 QLabel * PrepLabel =
new QLabel(tr(
"preprocessor"), h1);
100 PrepLabel->setMargin(5);
101 topGrid->addWidget(h1, 4,1);
105 Q3GridLayout *midGrid =
new Q3GridLayout(0, 2,3,5,5);
106 all->addLayout(midGrid);
108 midGrid->addWidget(
new QLabel(tr(
"SPICE net nodes:"), myParent), 0,0);
111 connect(
NodesList, SIGNAL(doubleClicked(Q3ListBoxItem*)),
114 Q3VBox *v0 =
new Q3VBox(myParent);
116 midGrid->addWidget(v0, 1,1);
117 ButtAdd =
new QPushButton(tr(
"Add >>"), v0);
119 ButtRemove =
new QPushButton(tr(
"<< Remove"), v0);
121 v0->setStretchFactor(
new QWidget(v0), 5);
123 midGrid->addWidget(
new QLabel(tr(
"Component ports:"), myParent), 0,2);
126 connect(
PortsList, SIGNAL(doubleClicked(Q3ListBoxItem*)),
131 Q3HBox *h0 =
new Q3HBox(
this);
134 connect(
new QPushButton(tr(
"OK"),h0), SIGNAL(clicked()),
136 connect(
new QPushButton(tr(
"Apply"),h0), SIGNAL(clicked()),
138 connect(
new QPushButton(tr(
"Cancel"),h0), SIGNAL(clicked()),
226 for(
unsigned int i=0; i<
PortsList->count(); i++)
228 if(!tmp.isEmpty()) tmp +=
',';
241 else pp->
Value =
"no";
256 Doc->viewport()->repaint();
263 QString s = QFileDialog::getOpenFileName(
this,
267 + tr(
"All Files") +
" (*.*)");
269 if(s.isEmpty())
return;
298 if(s.isEmpty())
return false;
306 QString preprocessor =
PrepCombo->currentText();
307 if (preprocessor !=
"none")
309 qDebug() <<
"Run spice preprocessor (perl)";
313 QString interpreter =
"tinyperl.exe";
315 QString interpreter =
"perl";
317 if (preprocessor ==
"ps2sp")
321 else if (preprocessor ==
"spicepp")
323 script =
"spicepp.pl";
325 else if (preprocessor ==
"spiceprm")
331 QString spiceCommand;
333 spiceCommand+=interpreter +
" ";
334 spiceCommand+=script +
" ";
335 spiceCommand+=FileInfo.filePath() +
" ";
339 QString PrepName = PrepInfo.filePath();
343 spiceCommand += PrepName +
" ";
353 QMessageBox *MBox =
new QMessageBox(tr(
"Info"),
354 tr(
"Preprocessing SPICE file \"%1\".").arg(FileInfo.filePath()),
355 QMessageBox::NoIcon, QMessageBox::Abort,
356 QMessageBox::NoButton, QMessageBox::NoButton,
this, 0,
true,
357 Qt::WStyle_DialogBorder | Qt::WDestructiveClose);
359 connect(
SpicePrep, SIGNAL(finished(
int, QProcess::ExitStatus)), MBox, SLOT(close()));
363 PrepFile.setName(PrepName);
364 if(!PrepFile.open(QIODevice::WriteOnly))
366 QMessageBox::critical(
this, tr(
"Error"),
367 tr(
"Cannot save preprocessed SPICE file \"%1\".").
374 if ((
SpicePrep->state() != QProcess::Starting) && (
SpicePrep->state() != QProcess::Running))
376 QMessageBox::critical(
this, tr(
"Error"),
377 tr(
"Cannot execute \"%1\".").arg(interpreter +
" " + script));
397 QMessageBox::critical(
this, tr(
"SPICE Preprocessor Error"),
Error);
408 executableSuffix =
".exe";
412 QStringList Arguments;
414 Arguments <<
"-if" <<
"spice"
416 <<
"-i" << FileInfo.filePath();
418 qDebug() <<
"Command :" << Program << Arguments.join(
" ");
424 QMessageBox *MBox =
new QMessageBox(tr(
"Info"),
425 tr(
"Converting SPICE file \"%1\".").arg(FileInfo.filePath()),
426 QMessageBox::NoIcon, QMessageBox::Abort,
427 QMessageBox::NoButton, QMessageBox::NoButton,
this, 0,
true,
428 Qt::WStyle_DialogBorder | Qt::WDestructiveClose);
430 connect(
QucsConv, SIGNAL(finished(
int, QProcess::ExitStatus)), MBox, SLOT(close()));
432 QucsConv->start(Program, Arguments);
437 QMessageBox::critical(
this, tr(
"Error"),
438 tr(
"Cannot execute \"%1\".").arg(
QucsSettings.
BinDir +
"qucsconv" + executableSuffix));
445 QMessageBox::critical(
this, tr(
"QucsConv Error"),
Error);
448 if(!pp->
Value.isEmpty())
456 for(
unsigned int i=0; i<
PortsList->count(); i++)
461 pi =
NodesList->findItem(tmp, Qt::CaseSensitive | QKeySequence::ExactMatch);
489 (*prestream) << QString(
SpicePrep->readAllStandardOutput ());
501 qDebug() <<
"slotGetNetlist";
506 while((i =
Line.find(
'\n')) >= 0)
513 s = s.stripWhiteSpace();
518 if (s.left(5) !=
".Def:")
529 if (s ==
"### TOPLEVEL NODELIST BEGIN")
533 else if (s ==
"### SPICE OUTPUT NODELIST BEGIN")
540 if (s ==
"### TOPLEVEL NODELIST END")
546 if (s.left(2) !=
"# ")
552 if(s.left(4) ==
"_net")
559 if(s ==
"### SPICE OUTPUT NODELIST END")
564 if(s.left(2) !=
"# ")
570 if(s.left(4) ==
"_net")
void slotAddPort(Q3ListBoxItem *)
tQucsSettings QucsSettings
QRegExpValidator * Validator
Definitions and declarations for the main application.
Q3PtrList< Component > * Components
Q3PtrList< Property > Props
QString getSpiceFileFilter(void)
SpiceDialog(QucsApp *, SpiceFile *, Schematic *)
QRegExpValidator * ValRestrict
void editFile(const QString &)
bool loadSpiceNetList(const QString &)
void slotRemovePort(Q3ListBoxItem *)
void recreateComponent(Component *)
void slotPrepChanged(int)