My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vfile.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  vfile.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 "vfile.h"
20 #include "schematic.h"
21 #include "main.h"
22 
24 {
25  Description = QObject::tr("file based voltage source");
26 
27  Arcs.append(new Arc(-12,-12, 24, 24, 0, 16*360,QPen(QPen::darkBlue,2)));
28  Arcs.append(new Arc( -3, -7, 7, 7,16*270, 16*180,QPen(QPen::darkBlue,2)));
29  Arcs.append(new Arc( -3, 0, 7, 7, 16*90, 16*180,QPen(QPen::darkBlue,2)));
30  Lines.append(new Line(-30, 0,-12, 0,QPen(QPen::darkBlue,2)));
31  Lines.append(new Line( 30, 0, 12, 0,QPen(QPen::darkBlue,2)));
32  Lines.append(new Line( 18, 5, 18, 11,QPen(QPen::red,1)));
33  Lines.append(new Line( 21, 8, 15, 8,QPen(QPen::red,1)));
34  Lines.append(new Line(-18, 5,-18, 11,QPen(QPen::black,1)));
35 
36  Lines.append(new Line( -6,-17, -6,-21,QPen(QPen::darkBlue,1)));
37  Lines.append(new Line( -8,-17, -8,-21,QPen(QPen::darkBlue,1)));
38  Lines.append(new Line(-10,-17,-10,-21,QPen(QPen::darkBlue,1)));
39  Lines.append(new Line( -3,-15, -3,-23,QPen(QPen::darkBlue,2)));
40  Lines.append(new Line(-13,-15,-13,-23,QPen(QPen::darkBlue,2)));
41  Lines.append(new Line( -3,-23,-13,-23,QPen(QPen::darkBlue,2)));
42  Lines.append(new Line( -3,-15,-13,-15,QPen(QPen::darkBlue,2)));
43 
44  Ports.append(new Port( 30, 0));
45  Ports.append(new Port(-30, 0));
46 
47  x1 = -30; y1 = -14;
48  x2 = 30; y2 = 14;
49 
50  tx = x1+4;
51  ty = y2+4;
52  Model = "Vfile";
53  Name = "V";
54 
55  Props.append(new Property("File", "vfile.dat", true,
56  QObject::tr("name of the sample file")));
57  Props.append(new Property("Interpolator", "linear", false,
58  QObject::tr("interpolation type")+" [hold, linear, cubic]"));
59  Props.append(new Property("Repeat", "no", false,
60  QObject::tr("repeat waveform")+" [no, yes]"));
61  Props.append(new Property("G", "1", false, QObject::tr("voltage gain")));
62  Props.append(new Property("T", "0", false, QObject::tr("delay time")));
63 
64  rotate(); // fix historical flaw
65 }
66 
68 {
69 }
70 
72 {
73  return new vFile();
74 }
75 
76 Element* vFile::info(QString& Name, char* &BitmapFile, bool getNewOne)
77 {
78  Name = QObject::tr("File Based Voltage Source");
79  BitmapFile = (char *) "vfile";
80 
81  if(getNewOne) return new vFile();
82  return 0;
83 }
84 
85 // -------------------------------------------------------
87 {
88  // construct full filename
89  QString FileName = Props.getFirst()->Value;
90  return properAbsFileName(FileName);
91 }
92 
93 // -------------------------------------------------------
94 QString vFile::netlist()
95 {
96  QString s = Model+":"+Name;
97 
98  // output all node names
99  for(Port *p1 = Ports.first(); p1 != 0; p1 = Ports.next())
100  s += " "+p1->Connection->Name; // node names
101 
102  // output file properties
103  Property *p2 = Props.first();
104  s += " "+p2->Name+"=\"{"+getSubcircuitFile()+"}\"";
105 
106  // output all remaining properties
107  for(p2 = Props.next(); p2 != 0; p2 = Props.next())
108  s += " "+p2->Name+"=\""+p2->Value+"\"";
109 
110  return s + "\n";
111 }