My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ifile.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  ifile.cpp
3  -----------
4  begin : Fri April 07 2007
5  updated drawing : Wed October 03 2007
6  copyright : (C) 2007 by Gunther Kraut
7  email : gn.kraut@t-online.de
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #include "ifile.h"
20 #include "schematic.h"
21 #include "main.h"
22 
24 {
25  Description = QObject::tr("file based current source");
26 
27  Arcs.append(new Arc(-12,-12, 24, 24, 0, 16*360,QPen(QPen::darkBlue,2)));
28  Lines.append(new Line(-30, 0,-12, 0,QPen(QPen::darkBlue,2)));
29  Lines.append(new Line( 30, 0, 12, 0,QPen(QPen::darkBlue,2)));
30  Lines.append(new Line( -7, 0, 7, 0,QPen(QPen::darkBlue,3)));
31  Lines.append(new Line( 6, 0, 0, -4,QPen(QPen::darkBlue,3)));
32  Lines.append(new Line( 6, 0, 0, 4,QPen(QPen::darkBlue,3)));
33 
34  Lines.append(new Line( -6,-17, -6,-21,QPen(QPen::darkBlue,1)));
35  Lines.append(new Line( -8,-17, -8,-21,QPen(QPen::darkBlue,1)));
36  Lines.append(new Line(-10,-17,-10,-21,QPen(QPen::darkBlue,1)));
37  Lines.append(new Line( -3,-15, -3,-23,QPen(QPen::darkBlue,2)));
38  Lines.append(new Line(-13,-15,-13,-23,QPen(QPen::darkBlue,2)));
39  Lines.append(new Line( -3,-23,-13,-23,QPen(QPen::darkBlue,2)));
40  Lines.append(new Line( -3,-15,-13,-15,QPen(QPen::darkBlue,2)));
41 
42  Ports.append(new Port( 30, 0));
43  Ports.append(new Port(-30, 0));
44 
45  x1 = -30; y1 = -14;
46  x2 = 30; y2 = 14;
47 
48  tx = x1+4;
49  ty = y2+4;
50  Model = "Ifile";
51  Name = "I";
52 
53  Props.append(new Property("File", "ifile.dat", true,
54  QObject::tr("name of the sample file")));
55  Props.append(new Property("Interpolator", "linear", false,
56  QObject::tr("interpolation type")+" [hold, linear, cubic]"));
57  Props.append(new Property("Repeat", "no", false,
58  QObject::tr("repeat waveform")+" [no, yes]"));
59  Props.append(new Property("G", "1", false, QObject::tr("current gain")));
60  Props.append(new Property("T", "0", false, QObject::tr("delay time")));
61 
62  rotate(); // fix historical flaw
63 }
64 
66 {
67 }
68 
70 {
71  return new iFile();
72 }
73 
74 Element* iFile::info(QString& Name, char* &BitmapFile, bool getNewOne)
75 {
76  Name = QObject::tr("File Based Current Source");
77  BitmapFile = (char *) "ifile";
78 
79  if(getNewOne) return new iFile();
80  return 0;
81 }
82 
83 // -------------------------------------------------------
85 {
86  // construct full filename
87  QString FileName = Props.getFirst()->Value;
88  return properAbsFileName(FileName);
89 }
90 
91 // -------------------------------------------------------
92 QString iFile::netlist()
93 {
94  QString s = Model+":"+Name;
95 
96  // output all node names
97  for(Port *p1 = Ports.first(); p1 != 0; p1 = Ports.next())
98  s += " "+p1->Connection->Name; // node names
99 
100  // output file properties
101  Property *p2 = Props.first();
102  s += " "+p2->Name+"=\"{"+getSubcircuitFile()+"}\"";
103 
104  // output all remaining properties
105  for(p2 = Props.next(); p2 != 0; p2 = Props.next())
106  s += " "+p2->Name+"=\""+p2->Value+"\"";
107 
108  return s + "\n";
109 }