Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bjt.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  bjt.cpp
3  ---------
4  begin : Fri Jun 4 2004
5  copyright : (C) 2003 by Michael Margraf
6  email : michael.margraf@alumni.tu-berlin.de
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 "bjt.h"
19 #include "node.h"
20 
21 
23 {
24  // properties obtained from "Basic_BJT" in bjtsub.cpp
25  Description = QObject::tr("bipolar junction transistor");
26  createSymbol();
27  tx = x2+4;
28  ty = y1+4;
29  Model = "_BJT";
30 }
31 
32 // -------------------------------------------------------
34 {
35  BJT* p = new BJT();
36  p->Props.getFirst()->Value = Props.getFirst()->Value;
37  p->recreate(0);
38  return p;
39 }
40 
41 // -------------------------------------------------------
42 Element* BJT::info(QString& Name, char* &BitmapFile, bool getNewOne)
43 {
44  Name = QObject::tr("npn transistor");
45  BitmapFile = (char *) "npn";
46 
47  if(getNewOne) return new BJT();
48  return 0;
49 }
50 
51 // -------------------------------------------------------
52 Element* BJT::info_pnp(QString& Name, char* &BitmapFile, bool getNewOne)
53 {
54  Name = QObject::tr("pnp transistor");
55  BitmapFile = (char *) "pnp";
56 
57  if(getNewOne) {
58  BJT* p = new BJT();
59  p->Props.getFirst()->Value = "pnp";
60  p->recreate(0);
61  return p;
62  }
63  return 0;
64 }
65 
66 // -------------------------------------------------------
68 {
69  Lines.append(new Line(-10,-15,-10, 15,QPen(Qt::darkBlue,3)));
70  Lines.append(new Line(-30, 0,-10, 0,QPen(Qt::darkBlue,2)));
71  Lines.append(new Line(-10, -5, 0,-15,QPen(Qt::darkBlue,2)));
72  Lines.append(new Line( 0,-15, 0,-30,QPen(Qt::darkBlue,2)));
73  Lines.append(new Line(-10, 5, 0, 15,QPen(Qt::darkBlue,2)));
74  Lines.append(new Line( 0, 15, 0, 30,QPen(Qt::darkBlue,2)));
75 
76  if(Props.getFirst()->Value == "npn") {
77  Lines.append(new Line( -6, 15, 0, 15,QPen(Qt::darkBlue,2)));
78  Lines.append(new Line( 0, 9, 0, 15,QPen(Qt::darkBlue,2)));
79  }
80  else {
81  Lines.append(new Line( -5, 10, -5, 16,QPen(Qt::darkBlue,2)));
82  Lines.append(new Line( -5, 10, 1, 10,QPen(Qt::darkBlue,2)));
83  }
84 
85  Ports.append(new Port(-30, 0));
86  Ports.append(new Port( 0,-30));
87  Ports.append(new Port( 0, 30));
88 
89  x1 = -30; y1 = -30;
90  x2 = 4; y2 = 30;
91 }
92 
93 // -------------------------------------------------------
94 QString BJT::netlist()
95 {
96  QString s = "BJT:"+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  s += " "+Ports.at(1)->Connection->Name; // connect substrate to collector
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 }
Q3PtrList< Line > Lines
Definition: component.h:67
BJT()
Definition: bjt.cpp:22
int y1
Definition: element.h:153
void createSymbol()
Definition: bjt.cpp:67
int tx
Definition: component.h:78
int y2
Definition: element.h:153
Definition: element.h:72
int x1
Definition: element.h:153
Component * newOne()
Definition: bjt.cpp:33
int ty
Definition: component.h:78
Q3PtrList< Property > Props
Definition: component.h:72
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
QString Name
Definition: component.h:80
Definition: bjt.h:24
QString Model
Definition: component.h:80
QString Description
Definition: component.h:81
QString netlist()
Definition: bjt.cpp:94
static Element * info(QString &, char *&, bool getNewOne=false)
Definition: bjt.cpp:42
int x2
Definition: element.h:153
static Element * info_pnp(QString &, char *&, bool getNewOne=false)
Definition: bjt.cpp:52