Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rfedd2p.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  rfedd2p.cpp
3  ----------------
4  begin : Sub Feb 17 2008
5  copyright : (C) 2008 by Stefan Jahn
6  email : stefan@lkcc.org
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #include <QtGui>
18 #include "rfedd2p.h"
19 #include "main.h"
20 #include "schematic.h"
21 
22 #include <QFileInfo>
23 
24 
25 
27 {
28  Description = QObject::tr("equation defined 2-port RF device");
29 
30  Model = "RFEDD2P";
31  Name = "RF";
32 
33  // first properties !!!
34  Props.append(new Property("Type", "Y", false,
35  QObject::tr("type of parameters")+" [Y, Z, S, H, G, A, T]"));
36  Props.append(new Property("duringDC", "open", false,
37  QObject::tr("representation during DC analysis")+
38  " [open, short, unspecified, zerofrequency]"));
39 
40  // last properties
41  Props.append(new Property("P11", "0", false,
42  QObject::tr("parameter equation") + " 11"));
43  Props.append(new Property("P12", "0", false,
44  QObject::tr("parameter equation") + " 12"));
45  Props.append(new Property("P21", "0", false,
46  QObject::tr("parameter equation") + " 21"));
47  Props.append(new Property("P22", "0", false,
48  QObject::tr("parameter equation") + " 22"));
49 
50  createSymbol();
51 }
52 
53 // -------------------------------------------------------
55 {
56  RFedd2P* p = new RFedd2P();
57  p->Props.at(0)->Value = Props.at(0)->Value;
58  p->recreate(0);
59  return p;
60 }
61 
62 // -------------------------------------------------------
63 Element* RFedd2P::info(QString& Name, char* &BitmapFile, bool getNewOne)
64 {
65  Name = QObject::tr("Equation Defined 2-port RF Device");
66  BitmapFile = (char *) "rfedd";
67 
68  if(getNewOne) {
69  RFedd2P* p = new RFedd2P();
70  p->Props.at(0)->Value = "Y";
71  p->recreate(0);
72  return p;
73  }
74  return 0;
75 }
76 
77 // -------------------------------------------------------
79 {
80  QString s = "RFEDD:"+Name;
81  QString e = "\n";
82  QString n, p;
83 
84  // output all node names
85  for(Port *p1 = Ports.first(); p1 != 0; p1 = Ports.next())
86  s += " "+p1->Connection->Name; // node names
87 
88  // output all properties
89  Property *p2;
90  p2 = Props.at(0);
91  s += " "+p2->Name+"=\""+p2->Value+"\"";
92  p = p2->Value;
93  p2 = Props.at(1);
94  s += " "+p2->Name+"=\""+p2->Value+"\"";
95  p2 = Props.at(2);
96  while(p2) {
97  n = p2->Name.mid(1);
98  s += " "+p2->Name+"=\""+Name+"."+p+n+"\"";
99  e += " Eqn:Eqn"+Name+p2->Name+" "+
100  Name+"."+p+n+"=\""+p2->Value+"\" Export=\"no\"\n";
101  p2 = Props.next();
102  }
103 
104  return s+e;
105 }
106 
107 // -------------------------------------------------------
109 {
110  QFontMetrics metrics(QucsSettings.font); // get size of text
111  int fHeight = metrics.lineSpacing();
112  int w, i;
113  QString tmp;
114 
115  // draw symbol
116  #define HALFWIDTH 17
117  int h = 15;
118  Lines.append(new Line(-HALFWIDTH, -h, HALFWIDTH, -h,QPen(Qt::darkBlue,2)));
119  Lines.append(new Line( HALFWIDTH, -h, HALFWIDTH, h,QPen(Qt::darkBlue,2)));
120  Lines.append(new Line(-HALFWIDTH, h, HALFWIDTH, h,QPen(Qt::darkBlue,2)));
121  Lines.append(new Line(-HALFWIDTH, -h,-HALFWIDTH, h,QPen(Qt::darkBlue,2)));
122 
123  i = fHeight/2;
124  tmp = Props.at(0)->Value;
125  w = metrics.width(tmp);
126  Texts.append(new Text(w/-2, -i, tmp));
127 
128  i = 0;
129  int y = 15-h;
130  Lines.append(new Line(-30, y,-HALFWIDTH, y,QPen(Qt::darkBlue,2)));
131  Ports.append(new Port(-30, y));
132  tmp = QString::number(i+1);
133  w = metrics.width(tmp);
134  Texts.append(new Text(-20-w, y-fHeight-2, tmp));
135  i++;
136 
137  Lines.append(new Line(HALFWIDTH, y, 30, y,QPen(Qt::darkBlue,2)));
138  Ports.append(new Port( 30, y));
139  tmp = QString::number(i+1);
140  Texts.append(new Text( 20, y-fHeight-2, tmp));
141  y += 60;
142  i++;
143 
144  x1 = -30; y1 = -h-2;
145  x2 = 30; y2 = h+2;
146 
147  tx = x1+4;
148  ty = y1 - fHeight - 4;
149 }
Q3PtrList< Line > Lines
Definition: component.h:67
#define HALFWIDTH
int y1
Definition: element.h:153
QFont font
Definition: main.h:46
void createSymbol()
Definition: rfedd2p.cpp:108
tQucsSettings QucsSettings
Definition: main.cpp:52
int tx
Definition: component.h:78
RFedd2P()
Definition: rfedd2p.cpp:26
int y2
Definition: element.h:153
Definition: element.h:72
int x1
Definition: element.h:153
Definitions and declarations for the main application.
int ty
Definition: component.h:78
Q3PtrList< Property > Props
Definition: component.h:72
Definition: element.h:82
Definition: element.h:48
Superclass of all schematic drawing elements.
Definition: element.h:142
void recreate(Schematic *)
Definition: component.cpp:1250
Q3PtrList< Port > Ports
Definition: component.h:70
Component * newOne()
Definition: rfedd2p.cpp:54
QString netlist()
Definition: rfedd2p.cpp:78
QString Name
Definition: component.h:80
Q3PtrList< Text > Texts
Definition: component.h:71
QString Model
Definition: component.h:80
QString Description
Definition: component.h:81
static Element * info(QString &, char *&, bool getNewOne=false)
Definition: rfedd2p.cpp:63
int x2
Definition: element.h:153