Qucs-GUI
0.0.19
|
00001 /*************************************************************************** 00002 vfile.cpp 00003 ----------- 00004 begin : Fri April 07 2007 00005 updated drawing : Wed October 03 2007 00006 copyright : (C) 2007 by Gunther Kraut 00007 email : gn.kraut@t-online.de 00008 ***************************************************************************/ 00009 00010 /*************************************************************************** 00011 * * 00012 * This program is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU General Public License as published by * 00014 * the Free Software Foundation; either version 2 of the License, or * 00015 * (at your option) any later version. * 00016 * * 00017 ***************************************************************************/ 00018 #include "vfile.h" 00019 #include "schematic.h" 00020 #include "misc.h" 00021 00022 vFile::vFile() 00023 { 00024 Description = QObject::tr("file based voltage source"); 00025 00026 Arcs.append(new Arc(-12,-12, 24, 24, 0, 16*360,QPen(Qt::darkBlue,2))); 00027 Arcs.append(new Arc( -3, -7, 7, 7,16*270, 16*180,QPen(Qt::darkBlue,2))); 00028 Arcs.append(new Arc( -3, 0, 7, 7, 16*90, 16*180,QPen(Qt::darkBlue,2))); 00029 Lines.append(new Line(-30, 0,-12, 0,QPen(Qt::darkBlue,2))); 00030 Lines.append(new Line( 30, 0, 12, 0,QPen(Qt::darkBlue,2))); 00031 Lines.append(new Line( 18, 5, 18, 11,QPen(Qt::red,1))); 00032 Lines.append(new Line( 21, 8, 15, 8,QPen(Qt::red,1))); 00033 Lines.append(new Line(-18, 5,-18, 11,QPen(Qt::black,1))); 00034 00035 Lines.append(new Line( -6,-17, -6,-21,QPen(Qt::darkBlue,1))); 00036 Lines.append(new Line( -8,-17, -8,-21,QPen(Qt::darkBlue,1))); 00037 Lines.append(new Line(-10,-17,-10,-21,QPen(Qt::darkBlue,1))); 00038 Lines.append(new Line( -3,-15, -3,-23,QPen(Qt::darkBlue,2))); 00039 Lines.append(new Line(-13,-15,-13,-23,QPen(Qt::darkBlue,2))); 00040 Lines.append(new Line( -3,-23,-13,-23,QPen(Qt::darkBlue,2))); 00041 Lines.append(new Line( -3,-15,-13,-15,QPen(Qt::darkBlue,2))); 00042 00043 Ports.append(new Port( 30, 0)); 00044 Ports.append(new Port(-30, 0)); 00045 00046 x1 = -30; y1 = -14; 00047 x2 = 30; y2 = 14; 00048 00049 tx = x1+4; 00050 ty = y2+4; 00051 Model = "Vfile"; 00052 Name = "V"; 00053 00054 Props.append(new Property("File", "vfile.dat", true, 00055 QObject::tr("name of the sample file"))); 00056 Props.append(new Property("Interpolator", "linear", false, 00057 QObject::tr("interpolation type")+" [hold, linear, cubic]")); 00058 Props.append(new Property("Repeat", "no", false, 00059 QObject::tr("repeat waveform")+" [no, yes]")); 00060 Props.append(new Property("G", "1", false, QObject::tr("voltage gain"))); 00061 Props.append(new Property("T", "0", false, QObject::tr("delay time"))); 00062 00063 rotate(); // fix historical flaw 00064 } 00065 00066 vFile::~vFile() 00067 { 00068 } 00069 00070 Component* vFile::newOne() 00071 { 00072 return new vFile(); 00073 } 00074 00075 Element* vFile::info(QString& Name, char* &BitmapFile, bool getNewOne) 00076 { 00077 Name = QObject::tr("File Based Voltage Source"); 00078 BitmapFile = (char *) "vfile"; 00079 00080 if(getNewOne) return new vFile(); 00081 return 0; 00082 } 00083 00084 // ------------------------------------------------------- 00085 QString vFile::getSubcircuitFile() 00086 { 00087 // construct full filename 00088 QString FileName = Props.getFirst()->Value; 00089 return misc::properAbsFileName(FileName); 00090 } 00091 00092 // ------------------------------------------------------- 00093 QString vFile::netlist() 00094 { 00095 QString s = Model+":"+Name; 00096 00097 // output all node names 00098 foreach(Port *p1, Ports) 00099 s += " "+p1->Connection->Name; // node names 00100 00101 // output file properties 00102 Property *p2 = Props.first(); 00103 s += " "+p2->Name+"=\"{"+getSubcircuitFile()+"}\""; 00104 00105 // output all remaining properties 00106 for(p2 = Props.next(); p2 != 0; p2 = Props.next()) 00107 s += " "+p2->Name+"=\""+p2->Value+"\""; 00108 00109 return s + "\n"; 00110 }