My Project  0.0.16
QUCS Mapping
 All Classes Namespaces 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 
18 #include "rfedd2p.h"
19 #include "main.h"
20 #include "schematic.h"
21 
22 #include <qfileinfo.h>
23 
24 extern QDir QucsWorkDir;
25 
26 
28 {
29  Description = QObject::tr("equation defined 2-port RF device");
30 
31  Model = "RFEDD2P";
32  Name = "RF";
33 
34  // first properties !!!
35  Props.append(new Property("Type", "Y", false,
36  QObject::tr("type of parameters")+" [Y, Z, S, H, G, A, T]"));
37  Props.append(new Property("duringDC", "open", false,
38  QObject::tr("representation during DC analysis")+
39  " [open, short, unspecified, zerofrequency]"));
40 
41  // last properties
42  Props.append(new Property("P11", "0", false,
43  QObject::tr("parameter equation") + " 11"));
44  Props.append(new Property("P12", "0", false,
45  QObject::tr("parameter equation") + " 12"));
46  Props.append(new Property("P21", "0", false,
47  QObject::tr("parameter equation") + " 21"));
48  Props.append(new Property("P22", "0", false,
49  QObject::tr("parameter equation") + " 22"));
50 
51  createSymbol();
52 }
53 
54 // -------------------------------------------------------
56 {
57  RFedd2P* p = new RFedd2P();
58  p->Props.at(0)->Value = Props.at(0)->Value;
59  p->recreate(0);
60  return p;
61 }
62 
63 // -------------------------------------------------------
64 Element* RFedd2P::info(QString& Name, char* &BitmapFile, bool getNewOne)
65 {
66  Name = QObject::tr("Equation Defined 2-port RF Device");
67  BitmapFile = (char *) "rfedd";
68 
69  if(getNewOne) {
70  RFedd2P* p = new RFedd2P();
71  p->Props.at(0)->Value = "Y";
72  p->recreate(0);
73  return p;
74  }
75  return 0;
76 }
77 
78 // -------------------------------------------------------
80 {
81  QString s = "RFEDD:"+Name;
82  QString e = "\n";
83  QString n, p;
84 
85  // output all node names
86  for(Port *p1 = Ports.first(); p1 != 0; p1 = Ports.next())
87  s += " "+p1->Connection->Name; // node names
88 
89  // output all properties
90  Property *p2;
91  p2 = Props.at(0);
92  s += " "+p2->Name+"=\""+p2->Value+"\"";
93  p = p2->Value;
94  p2 = Props.at(1);
95  s += " "+p2->Name+"=\""+p2->Value+"\"";
96  p2 = Props.at(2);
97  while(p2) {
98  n = p2->Name.mid(1);
99  s += " "+p2->Name+"=\""+Name+"."+p+n+"\"";
100  e += " Eqn:Eqn"+Name+p2->Name+" "+
101  Name+"."+p+n+"=\""+p2->Value+"\" Export=\"no\"\n";
102  p2 = Props.next();
103  }
104 
105  return s+e;
106 }
107 
108 // -------------------------------------------------------
110 {
111  QFontMetrics metrics(QucsSettings.font); // get size of text
112  int fHeight = metrics.lineSpacing();
113  int w, i;
114  QString tmp;
115 
116  // draw symbol
117  #define HALFWIDTH 17
118  int h = 15;
119  Lines.append(new Line(-HALFWIDTH, -h, HALFWIDTH, -h,QPen(QPen::darkBlue,2)));
120  Lines.append(new Line( HALFWIDTH, -h, HALFWIDTH, h,QPen(QPen::darkBlue,2)));
121  Lines.append(new Line(-HALFWIDTH, h, HALFWIDTH, h,QPen(QPen::darkBlue,2)));
122  Lines.append(new Line(-HALFWIDTH, -h,-HALFWIDTH, h,QPen(QPen::darkBlue,2)));
123 
124  i = fHeight/2;
125  tmp = Props.at(0)->Value;
126  w = metrics.width(tmp);
127  Texts.append(new Text(w/-2, -i, tmp));
128 
129  i = 0;
130  int y = 15-h;
131  Lines.append(new Line(-30, y,-HALFWIDTH, y,QPen(QPen::darkBlue,2)));
132  Ports.append(new Port(-30, y));
133  tmp = QString::number(i+1);
134  w = metrics.width(tmp);
135  Texts.append(new Text(-20-w, y-fHeight-2, tmp));
136  i++;
137 
138  Lines.append(new Line(HALFWIDTH, y, 30, y,QPen(QPen::darkBlue,2)));
139  Ports.append(new Port( 30, y));
140  tmp = QString::number(i+1);
141  Texts.append(new Text( 20, y-fHeight-2, tmp));
142  y += 60;
143  i++;
144 
145  x1 = -30; y1 = -h-2;
146  x2 = 30; y2 = h+2;
147 
148  tx = x1+4;
149  ty = y1 - fHeight - 4;
150 }