Qucs-GUI  0.0.18
 All Data Structures 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 #include <QtGui>
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(Qt::darkBlue,2)));
28  Arcs.append(new Arc( -3, -7, 7, 7,16*270, 16*180,QPen(Qt::darkBlue,2)));
29  Arcs.append(new Arc( -3, 0, 7, 7, 16*90, 16*180,QPen(Qt::darkBlue,2)));
30  Lines.append(new Line(-30, 0,-12, 0,QPen(Qt::darkBlue,2)));
31  Lines.append(new Line( 30, 0, 12, 0,QPen(Qt::darkBlue,2)));
32  Lines.append(new Line( 18, 5, 18, 11,QPen(Qt::red,1)));
33  Lines.append(new Line( 21, 8, 15, 8,QPen(Qt::red,1)));
34  Lines.append(new Line(-18, 5,-18, 11,QPen(Qt::black,1)));
35 
36  Lines.append(new Line( -6,-17, -6,-21,QPen(Qt::darkBlue,1)));
37  Lines.append(new Line( -8,-17, -8,-21,QPen(Qt::darkBlue,1)));
38  Lines.append(new Line(-10,-17,-10,-21,QPen(Qt::darkBlue,1)));
39  Lines.append(new Line( -3,-15, -3,-23,QPen(Qt::darkBlue,2)));
40  Lines.append(new Line(-13,-15,-13,-23,QPen(Qt::darkBlue,2)));
41  Lines.append(new Line( -3,-23,-13,-23,QPen(Qt::darkBlue,2)));
42  Lines.append(new Line( -3,-15,-13,-15,QPen(Qt::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 }
Q3PtrList< Line > Lines
Definition: component.h:67
Component * newOne()
Definition: vfile.cpp:71
Definition: element.h:55
int y1
Definition: element.h:153
Q3PtrList< struct Arc > Arcs
Definition: component.h:68
int tx
Definition: component.h:78
int y2
Definition: element.h:153
Definition: element.h:72
int x1
Definition: element.h:153
QString netlist()
Definition: vfile.cpp:94
Definitions and declarations for the main application.
int ty
Definition: component.h:78
QString properAbsFileName(const QString &Name)
Definition: main.cpp:452
Q3PtrList< Property > Props
Definition: component.h:72
vFile()
Definition: vfile.cpp:23
QString getSubcircuitFile()
Definition: vfile.cpp:86
Definition: element.h:48
Superclass of all schematic drawing elements.
Definition: element.h:142
static Element * info(QString &, char *&, bool getNewOne=false)
Definition: vfile.cpp:76
Q3PtrList< Port > Ports
Definition: component.h:70
void rotate()
Definition: component.cpp:390
QString Name
Definition: component.h:80
QString Model
Definition: component.h:80
QString Description
Definition: component.h:81
~vFile()
Definition: vfile.cpp:67
int x2
Definition: element.h:153