Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ecvs.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  ecvs.cpp
3  -----------
4  copyright : (C) 2013 by Richard Crozier
5  email : richard dot crozier at yahoo dot co dot uk
6  ***************************************************************************/
7 
8 /***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 #include <QtGui>
17 #include "ecvs.h"
18 #include "schematic.h"
19 #include "main.h"
20 
22 {
23  Description = QObject::tr("externally controlled voltage source");
24 
25 
26 // Arcs.append(new Arc( -3, -7, 7, 7,16*270, 16*180,QPen(Qt::darkBlue,2)));
27 // Arcs.append(new Arc( -3, 0, 7, 7, 16*90, 16*180,QPen(Qt::darkBlue,2)));
28 
29  // Circle in middle
30  Arcs.append(new Arc(-12,-12, 24, 24, 0, 16*360,QPen(Qt::darkBlue,2)));
31  // The 'E' symbol in middle of circle
32  // horizontal lines (actually drawn vertically here)
33  Lines.append(new Line(4, -3, 4, 3,QPen(Qt::darkGreen,2)));
34  Lines.append(new Line(0, -3, 0, 2,QPen(Qt::darkGreen,2)));
35  Lines.append(new Line(-4, -3, -4, 3,QPen(Qt::darkGreen,2)));
36  // Vertical Line
37  Lines.append(new Line(4, -3, -4, -3,QPen(Qt::darkGreen,2)));
38 
39  // Wires at top and bottom
40  Lines.append(new Line(-30, 0,-12, 0,QPen(Qt::darkBlue,2)));
41  Lines.append(new Line( 30, 0, 12, 0,QPen(Qt::darkBlue,2)));
42  // positive symbol
43  Lines.append(new Line( 18, 5, 18, 11,QPen(Qt::red,1)));
44  Lines.append(new Line( 21, 8, 15, 8,QPen(Qt::red,1)));
45  // negative symbol
46  Lines.append(new Line(-18, 5,-18, 11,QPen(Qt::black,1)));
47 
48 // Lines.append(new Line( -6,-17, -6,-21,QPen(Qt::darkBlue,1)));
49 // Lines.append(new Line( -8,-17, -8,-21,QPen(Qt::darkBlue,1)));
50 // Lines.append(new Line(-10,-17,-10,-21,QPen(Qt::darkBlue,1)));
51 // Lines.append(new Line( -3,-15, -3,-23,QPen(Qt::darkBlue,2)));
52 // Lines.append(new Line(-13,-15,-13,-23,QPen(Qt::darkBlue,2)));
53 // Lines.append(new Line( -3,-23,-13,-23,QPen(Qt::darkBlue,2)));
54 // Lines.append(new Line( -3,-15,-13,-15,QPen(Qt::darkBlue,2)));
55 
56  Ports.append(new Port( 30, 0));
57  Ports.append(new Port(-30, 0));
58 
59  x1 = -30; y1 = -14;
60  x2 = 30; y2 = 14;
61 
62  tx = x1+4;
63  ty = y2+4;
64  Model = "ECVS";
65  Name = "ECVS";
66 
67  Props.append(new Property("U", "0 V", true,
68  QObject::tr("voltage in Volts")));
69 // Props.append(new Property("Interpolator", "linear", false,
70 // QObject::tr("interpolation type")+" [hold, linear, cubic]"));
71 
72  rotate(); // fix historical flaw
73 }
74 
76 {
77 }
78 
80 {
81  return new ecvs();
82 }
83 
84 Element* ecvs::info(QString& Name, char* &BitmapFile, bool getNewOne)
85 {
86  Name = QObject::tr("Externally Controlled Voltage Source");
87  BitmapFile = (char *) "ecvs";
88 
89  if(getNewOne) return new ecvs();
90  return 0;
91 }
92 
93 
94 // -------------------------------------------------------
95 QString ecvs::netlist()
96 {
97  QString s = Model+":"+Name;
98 
99  // output all node names
100  for(Port *p1 = Ports.first(); p1 != 0; p1 = Ports.next())
101  s += " "+p1->Connection->Name; // node names
102 
103  // output all properties
104  for(Property *p2 = Props.first(); p2 != 0; p2 = Props.next())
105  s += " "+p2->Name+"=\""+p2->Value+"\"";
106 
107  return s + "\n";
108 }
109 
Q3PtrList< Line > Lines
Definition: component.h:67
The externally controlled voltage source component header file.
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
ecvs()
Definition: ecvs.cpp:21
~ecvs()
Definition: ecvs.cpp:75
Definitions and declarations for the main application.
int ty
Definition: component.h:78
Component * newOne()
Definition: ecvs.cpp:79
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
QString Model
Definition: component.h:80
QString Description
Definition: component.h:81
static Element * info(QString &, char *&, bool getNewOne=false)
Definition: ecvs.cpp:84
int x2
Definition: element.h:153
QString netlist()
Definition: ecvs.cpp:95