29 #include <QStringList> 
   30 #include <QMessageBox> 
   31 #include <QTextStream> 
   48   Props.append(
new Property(
"Sim", 
"yes", 
false, QString(
"x")));
 
   49   Props.append(
new Property(
"Preprocessor", 
"none", 
false, QString(
"x")));
 
   71   Name = QObject::tr(
"SPICE netlist");
 
   72   BitmapFile = (
char *) 
"spicefile";
 
   86   int fHeight = metrics.lineSpacing();
 
   89   QString tmp, PortNames = 
Props.at(1)->Value;
 
   90   if(!PortNames.isEmpty())  No = PortNames.count(
',') + 1;
 
   93   int h = 30*((No-1)/2) + 15;
 
  102     tmp = QObject::tr(
"sim");
 
  103     w = metrics.width(tmp);
 
  104     Texts.append(
new Text(w/-2, 0, tmp, Qt::red));
 
  106   tmp = QObject::tr(
"spice");
 
  107   w = metrics.width(tmp);
 
  116     tmp = PortNames.section(
',', i, i).mid(4);
 
  117     w = metrics.width(tmp);
 
  118     Texts.append(
new Text(-20-w, y-fHeight-2, tmp));
 
  124     tmp = PortNames.section(
',', i, i).mid(4);
 
  125     Texts.append(
new Text( 20, y-fHeight-2, tmp));
 
  131     Lines.append(
new Line( 0, h, 0,h+15,QPen(Qt::darkBlue,2)));
 
  140   ty = 
y1 - fHeight - 4;
 
  141   if(
Props.first()->display) 
ty -= fHeight;
 
  148   if(
Props.at(1)->Value.isEmpty())
 
  151   QString s = 
"Sub:"+
Name;   
 
  153     s += 
" "+pp->Connection->Name;   
 
  164   QString FileName = 
Props.getFirst()->Value;
 
  166   if (FileName.isEmpty())
 
  171   QFileInfo FileInfo(FileName);
 
  173   if (FileInfo.exists())
 
  176      return FileInfo.absoluteFilePath();
 
  182     QString baseName = FileInfo.completeBaseName();
 
  186     if (FileInfo.fileName () == FileName)
 
  198                 QFileInfo localFIleInfo (schematicFileInfo.canonicalPath ()
 
  200                 if (localFIleInfo.exists ())
 
  204                     return localFIleInfo.absoluteFilePath();
 
  218     if (hashsearchresult.isEmpty())
 
  227         FileInfo.setFile(hashsearchresult);
 
  229         if (FileInfo.exists())
 
  232             return FileInfo.absoluteFilePath();
 
  250   QString FileName = 
Props.first()->Value;
 
  251   if(FileName.isEmpty()) {
 
  252     ErrText += QObject::tr(
"ERROR: No file name in SPICE component \"%1\".").
 
  260   SpiceFile.setName(FileName);
 
  261   if(!SpiceFile.open(QIODevice::ReadOnly)) {
 
  262     ErrText += QObject::tr(
"ERROR: Cannot open SPICE file \"%1\".").
 
  267   QString ConvName = SpiceFile.name() + 
".lst";
 
  268   ConvFile.setName(ConvName);
 
  269   QFileInfo Info(ConvName);
 
  272   if(
changed || !ConvFile.exists() ||
 
  274     if(!ConvFile.open(QIODevice::WriteOnly)) {
 
  275       ErrText += QObject::tr(
"ERROR: Cannot save converted SPICE file \"%1\".").
 
  276                           arg(FileName + 
".lst");
 
  281     QString SpiceName = SpiceFile.name();
 
  289   if(!ConvFile.open(QIODevice::ReadOnly)) {
 
  290     ErrText += QObject::tr(
"ERROR: Cannot open converted SPICE file \"%1\".").
 
  291                         arg(FileName + 
".lst");
 
  294   QByteArray FileContent = ConvFile.readAll();
 
  297   (*stream) << FileContent.data();
 
  311   if(
Props.at(1)->Value != 
"")
 
  315   if(
Props.at(2)->Value == 
"yes")
 
  321   QString preprocessor = 
Props.at(3)->Value;
 
  322   if (preprocessor != 
"none") {
 
  326     QString interpreter = 
"tinyperl.exe";
 
  328     QString interpreter = 
"perl";
 
  330     if (preprocessor == 
"ps2sp") {
 
  332     } 
else if (preprocessor == 
"spicepp") {
 
  333       script << 
"spicepp.pl";
 
  334     } 
else if (preprocessor == 
"spiceprm") {
 
  335       script << 
"spiceprm";
 
  339     script << interpreter;
 
  344     QString PrepName = *SpiceFile + 
".pre";
 
  355     QMessageBox *MBox = 
new QMessageBox(QObject::tr(
"Info"),
 
  356          QObject::tr(
"Preprocessing SPICE file \"%1\".").arg(*SpiceFile),
 
  357                QMessageBox::NoIcon, QMessageBox::Abort,
 
  358                QMessageBox::NoButton, QMessageBox::NoButton, 0, 0, 
true,
 
  359          Qt::WStyle_DialogBorder |  Qt::WDestructiveClose);
 
  360     connect(
SpicePrep, SIGNAL(finished(
int)), MBox, SLOT(close()));
 
  363       PrepFile.setName(PrepName);
 
  364       if(!PrepFile.open(QIODevice::WriteOnly)) {
 
  366     QObject::tr(
"ERROR: Cannot save preprocessed SPICE file \"%1\".").
 
  373     QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
 
  374     env.insert(
"PATH", env.value(
"PATH") );
 
  379     if(
SpicePrep->state()!=QProcess::Running&&
 
  380             SpicePrep->state()!=QProcess::Starting) {
 
  381       ErrText += QObject::tr(
"ERROR: Cannot execute \"%1\".").
 
  382               arg(interpreter + 
" " + script.join(
" ") + 
"\".");
 
  397     *SpiceFile = PrepName;
 
  402   executableSuffix = 
".exe";
 
  411   com << 
"-if" << 
"spice" << 
"-of" << 
"qucs";
 
  418     QString PortNames = 
Props.at(1)->Value;
 
  419     PortNames.replace(
',', 
' ');
 
  427   QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
 
  428   env.insert(
"PATH", env.value(
"PATH") );
 
  429   QucsConv->setProcessEnvironment(env);
 
  431   qDebug() << 
"Command:" << prog << com.join(
" ");
 
  440   if(
QucsConv->state()!=QProcess::Running&&
 
  441           QucsConv->state()!=QProcess::Starting) {
 
  442     ErrText += QObject::tr(
"COMP ERROR: Cannot start QucsConv!");
 
  449   QMessageBox *MBox = 
new QMessageBox(QObject::tr(
"Info"),
 
  450          QObject::tr(
"Converting SPICE file \"%1\".").arg(*SpiceFile),
 
  451                QMessageBox::NoIcon, QMessageBox::Abort,
 
  452                QMessageBox::NoButton, QMessageBox::NoButton, 0, 0, 
true,
 
  453          Qt::WStyle_DialogBorder | Qt::WDestructiveClose);
 
  454   connect(
QucsConv, SIGNAL(finished(
int)), MBox, SLOT(close()));
 
  484   (*prestream) << QString(
SpicePrep->readAllStandardOutput());
 
  500   while((i = 
NetLine.find(
'\n')) >= 0) {
 
  503     s = s.stripWhiteSpace();
 
  504     if(s.size()>0&&s.at(0) == 
'#') {
 
  506     } 
else if(s.isEmpty()) {
 
  508     } 
else if(s.size()>0&&s.at(0) == 
'.') {
 
  509       if(s.left(5) != 
".Def:") {
 
  518     (*outstream) << s << 
"\n";
 
  519     (*filstream) << s << 
"\n";
 
  526   if (
QucsConv->exitStatus() != QProcess::NormalExit) {
 
  531       (*outstream) << 
".Def:End\n\n";
 
  532       (*filstream) << 
".Def:End\n\n";
 
QString properFileName(const QString &Name)
bool createSubNetlist(QTextStream *)
tQucsSettings QucsSettings
QFileInfo getFileInfo(void)
Definitions and declarations for the main application. 
QString properAbsFileName(const QString &Name)
QStringList spiceExtensions
Q3PtrList< Property > Props
QHash< QString, QString > spiceNameHash
Superclass of all schematic drawing elements. 
void recreate(Schematic *)
Schematic * containingSchematic
QString properName(const QString &Name)
bool recreateSubNetlist(QString *, QString *)
static Element * info(QString &, char *&, bool getNewOne=false)
QString getSubcircuitFile()