Qucs-GUI  0.0.19
/home/travis/build/Qucs/qucs/qucs/qucs/components/ifile.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                                 ifile.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 "ifile.h"
00019 #include "schematic.h"
00020 #include "misc.h"
00021 
00022 iFile::iFile()
00023 {
00024   Description = QObject::tr("file based current source");
00025 
00026   Arcs.append(new Arc(-12,-12, 24, 24,  0, 16*360,QPen(Qt::darkBlue,2)));
00027   Lines.append(new Line(-30,  0,-12,  0,QPen(Qt::darkBlue,2)));
00028   Lines.append(new Line( 30,  0, 12,  0,QPen(Qt::darkBlue,2)));
00029   Lines.append(new Line( -7,  0,  7,  0,QPen(Qt::darkBlue,3)));
00030   Lines.append(new Line(  6,  0,  0, -4,QPen(Qt::darkBlue,3)));
00031   Lines.append(new Line(  6,  0,  0,  4,QPen(Qt::darkBlue,3)));
00032 
00033   Lines.append(new Line( -6,-17, -6,-21,QPen(Qt::darkBlue,1)));
00034   Lines.append(new Line( -8,-17, -8,-21,QPen(Qt::darkBlue,1)));
00035   Lines.append(new Line(-10,-17,-10,-21,QPen(Qt::darkBlue,1)));
00036   Lines.append(new Line( -3,-15, -3,-23,QPen(Qt::darkBlue,2)));
00037   Lines.append(new Line(-13,-15,-13,-23,QPen(Qt::darkBlue,2)));
00038   Lines.append(new Line( -3,-23,-13,-23,QPen(Qt::darkBlue,2)));
00039   Lines.append(new Line( -3,-15,-13,-15,QPen(Qt::darkBlue,2)));
00040 
00041   Ports.append(new Port( 30,  0));
00042   Ports.append(new Port(-30,  0));
00043 
00044   x1 = -30; y1 = -14;
00045   x2 =  30; y2 =  14;
00046 
00047   tx = x1+4;
00048   ty = y2+4;
00049   Model = "Ifile";
00050   Name  = "I";
00051 
00052   Props.append(new Property("File", "ifile.dat", true,
00053     QObject::tr("name of the sample file")));
00054   Props.append(new Property("Interpolator", "linear", false,
00055     QObject::tr("interpolation type")+" [hold, linear, cubic]"));
00056   Props.append(new Property("Repeat", "no", false,
00057     QObject::tr("repeat waveform")+" [no, yes]"));
00058   Props.append(new Property("G", "1", false, QObject::tr("current gain")));
00059   Props.append(new Property("T", "0", false, QObject::tr("delay time")));
00060 
00061   rotate();  // fix historical flaw
00062 }
00063 
00064 iFile::~iFile()
00065 {
00066 }
00067 
00068 Component* iFile::newOne()
00069 {
00070   return new iFile();
00071 }
00072 
00073 Element* iFile::info(QString& Name, char* &BitmapFile, bool getNewOne)
00074 {
00075   Name = QObject::tr("File Based Current Source");
00076   BitmapFile = (char *) "ifile";
00077 
00078   if(getNewOne)  return new iFile();
00079   return 0;
00080 }
00081 
00082 // -------------------------------------------------------
00083 QString iFile::getSubcircuitFile()
00084 {
00085   // construct full filename
00086   QString FileName = Props.getFirst()->Value;
00087   return misc::properAbsFileName(FileName);
00088 }
00089 
00090 // -------------------------------------------------------
00091 QString iFile::netlist()
00092 {
00093   QString s = Model+":"+Name;
00094 
00095   // output all node names
00096   foreach(Port *p1, Ports)
00097     s += " "+p1->Connection->Name;   // node names
00098 
00099   // output file properties
00100   Property *p2 = Props.first();
00101   s += " "+p2->Name+"=\"{"+getSubcircuitFile()+"}\"";
00102 
00103   // output all remaining properties
00104   for(p2 = Props.next(); p2 != 0; p2 = Props.next())
00105     s += " "+p2->Name+"=\""+p2->Value+"\"";
00106 
00107   return s + "\n";
00108 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines