Qucs-GUI  0.0.18
 All Data Structures 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 #include <QtGui>
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(Qt::darkBlue,2)));
28  Lines.append(new Line(-30, 0,-12, 0,QPen(Qt::darkBlue,2)));
29  Lines.append(new Line( 30, 0, 12, 0,QPen(Qt::darkBlue,2)));
30  Lines.append(new Line( -7, 0, 7, 0,QPen(Qt::darkBlue,3)));
31  Lines.append(new Line( 6, 0, 0, -4,QPen(Qt::darkBlue,3)));
32  Lines.append(new Line( 6, 0, 0, 4,QPen(Qt::darkBlue,3)));
33 
34  Lines.append(new Line( -6,-17, -6,-21,QPen(Qt::darkBlue,1)));
35  Lines.append(new Line( -8,-17, -8,-21,QPen(Qt::darkBlue,1)));
36  Lines.append(new Line(-10,-17,-10,-21,QPen(Qt::darkBlue,1)));
37  Lines.append(new Line( -3,-15, -3,-23,QPen(Qt::darkBlue,2)));
38  Lines.append(new Line(-13,-15,-13,-23,QPen(Qt::darkBlue,2)));
39  Lines.append(new Line( -3,-23,-13,-23,QPen(Qt::darkBlue,2)));
40  Lines.append(new Line( -3,-15,-13,-15,QPen(Qt::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 }
Q3PtrList< Line > Lines
Definition: component.h:67
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
QString netlist()
Definition: ifile.cpp:92
Definition: element.h:72
int x1
Definition: element.h:153
Component * newOne()
Definition: ifile.cpp:69
Definitions and declarations for the main application.
int ty
Definition: component.h:78
static Element * info(QString &, char *&, bool getNewOne=false)
Definition: ifile.cpp:74
QString properAbsFileName(const QString &Name)
Definition: main.cpp:452
Q3PtrList< Property > Props
Definition: component.h:72
Definition: element.h:48
Superclass of all schematic drawing elements.
Definition: element.h:142
Q3PtrList< Port > Ports
Definition: component.h:70
void rotate()
Definition: component.cpp:390
QString Name
Definition: component.h:80
~iFile()
Definition: ifile.cpp:65
QString Model
Definition: component.h:80
QString Description
Definition: component.h:81
iFile()
Definition: ifile.cpp:23
int x2
Definition: element.h:153
QString getSubcircuitFile()
Definition: ifile.cpp:84