Qucs-GUI  0.0.19
/home/travis/build/Qucs/qucs/qucs/qucs/components/bjt.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                                 bjt.cpp
00003                                ---------
00004     begin                : Fri Jun 4 2004
00005     copyright            : (C) 2003 by Michael Margraf
00006     email                : michael.margraf@alumni.tu-berlin.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "bjt.h"
00019 #include "node.h"
00020 
00021 
00022 BJT::BJT()
00023 {
00024   // properties obtained from "Basic_BJT" in bjtsub.cpp
00025   Description = QObject::tr("bipolar junction transistor");
00026   createSymbol();
00027   tx = x2+4;
00028   ty = y1+4;
00029   Model = "_BJT";
00030 }
00031 
00032 // -------------------------------------------------------
00033 Component* BJT::newOne()
00034 {
00035   BJT* p = new BJT();
00036   p->Props.getFirst()->Value = Props.getFirst()->Value;
00037   p->recreate(0);
00038   return p;
00039 }
00040 
00041 // -------------------------------------------------------
00042 Element* BJT::info(QString& Name, char* &BitmapFile, bool getNewOne)
00043 {
00044   Name = QObject::tr("npn transistor");
00045   BitmapFile = (char *) "npn";
00046 
00047   if(getNewOne)  return new BJT();
00048   return 0;
00049 }
00050 
00051 // -------------------------------------------------------
00052 Element* BJT::info_pnp(QString& Name, char* &BitmapFile, bool getNewOne)
00053 {
00054   Name = QObject::tr("pnp transistor");
00055   BitmapFile = (char *) "pnp";
00056 
00057   if(getNewOne) {
00058     BJT* p = new BJT();
00059     p->Props.getFirst()->Value = "pnp";
00060     p->recreate(0);
00061     return p;
00062   }
00063   return 0;
00064 }
00065 
00066 // -------------------------------------------------------
00067 void BJT::createSymbol()
00068 {
00069   Lines.append(new Line(-10,-15,-10, 15,QPen(Qt::darkBlue,3)));
00070   Lines.append(new Line(-30,  0,-10,  0,QPen(Qt::darkBlue,2)));
00071   Lines.append(new Line(-10, -5,  0,-15,QPen(Qt::darkBlue,2)));
00072   Lines.append(new Line(  0,-15,  0,-30,QPen(Qt::darkBlue,2)));
00073   Lines.append(new Line(-10,  5,  0, 15,QPen(Qt::darkBlue,2)));
00074   Lines.append(new Line(  0, 15,  0, 30,QPen(Qt::darkBlue,2)));
00075 
00076   if(Props.getFirst()->Value == "npn") {
00077     Lines.append(new Line( -6, 15,  0, 15,QPen(Qt::darkBlue,2)));
00078     Lines.append(new Line(  0,  9,  0, 15,QPen(Qt::darkBlue,2)));
00079   }
00080   else {
00081     Lines.append(new Line( -5, 10, -5, 16,QPen(Qt::darkBlue,2)));
00082     Lines.append(new Line( -5, 10,  1, 10,QPen(Qt::darkBlue,2)));
00083   }
00084 
00085   Ports.append(new Port(-30,  0));
00086   Ports.append(new Port(  0,-30));
00087   Ports.append(new Port(  0, 30));
00088 
00089   x1 = -30; y1 = -30;
00090   x2 =   4; y2 =  30;
00091 }
00092 
00093 // -------------------------------------------------------
00094 QString BJT::netlist()
00095 {
00096   QString s = "BJT:"+Name;
00097 
00098   // output all node names
00099   foreach(Port *p1, Ports)
00100     s += " "+p1->Connection->Name;   // node names
00101   s += " "+Ports.at(1)->Connection->Name;  // connect substrate to collector
00102 
00103   // output all properties
00104   for(Property *p2 = Props.first(); p2 != 0; p2 = Props.next())
00105     s += " "+p2->Name+"=\""+p2->Value+"\"";
00106 
00107   return s + '\n';
00108 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines