Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
resistor.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  resistor.cpp
3  --------------
4  begin : Sat Aug 23 2003
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 #include <QtGui>
18 #include "resistor.h"
19 #include "node.h"
20 #include "schematic.h"
21 
22 
23 Resistor::Resistor(bool european)
24 {
25  Description = QObject::tr("resistor");
26 
27  Props.append(new Property("R", "50 Ohm", true,
28  QObject::tr("ohmic resistance in Ohms")));
29  Props.append(new Property("Temp", "26.85", false,
30  QObject::tr("simulation temperature in degree Celsius")));
31  Props.append(new Property("Tc1", "0.0", false,
32  QObject::tr("first order temperature coefficient")));
33  Props.append(new Property("Tc2", "0.0", false,
34  QObject::tr("second order temperature coefficient")));
35  Props.append(new Property("Tnom", "26.85", false,
36  QObject::tr("temperature at which parameters were extracted")));
37 
38  // this must be the last property in the list !!!
39  Props.append(new Property("Symbol", "european", false,
40  QObject::tr("schematic symbol")+" [european, US]"));
41  if(!european) Props.getLast()->Value = "US";
42 
43  createSymbol();
44  tx = x1+4;
45  ty = y2+4;
46  Model = "R";
47  Name = "R";
48 }
49 
50 // -------------------------------------------------------
52 {
53  return new Resistor(Props.getLast()->Value != "US");
54 }
55 
56 // -------------------------------------------------------
58 {
59  if(Props.getLast()->Value != "US") {
60  Lines.append(new Line(-18, -9, 18, -9,QPen(Qt::darkBlue,2)));
61  Lines.append(new Line( 18, -9, 18, 9,QPen(Qt::darkBlue,2)));
62  Lines.append(new Line( 18, 9,-18, 9,QPen(Qt::darkBlue,2)));
63  Lines.append(new Line(-18, 9,-18, -9,QPen(Qt::darkBlue,2)));
64  Lines.append(new Line(-30, 0,-18, 0,QPen(Qt::darkBlue,2)));
65  Lines.append(new Line( 18, 0, 30, 0,QPen(Qt::darkBlue,2)));
66  }
67  else {
68  Lines.append(new Line(-30, 0,-18, 0,QPen(Qt::darkBlue,2)));
69  Lines.append(new Line(-18, 0,-15, -7,QPen(Qt::darkBlue,2)));
70  Lines.append(new Line(-15, -7, -9, 7,QPen(Qt::darkBlue,2)));
71  Lines.append(new Line( -9, 7, -3, -7,QPen(Qt::darkBlue,2)));
72  Lines.append(new Line( -3, -7, 3, 7,QPen(Qt::darkBlue,2)));
73  Lines.append(new Line( 3, 7, 9, -7,QPen(Qt::darkBlue,2)));
74  Lines.append(new Line( 9, -7, 15, 7,QPen(Qt::darkBlue,2)));
75  Lines.append(new Line( 15, 7, 18, 0,QPen(Qt::darkBlue,2)));
76  Lines.append(new Line( 18, 0, 30, 0,QPen(Qt::darkBlue,2)));
77  }
78 
79  Ports.append(new Port(-30, 0));
80  Ports.append(new Port( 30, 0));
81 
82  x1 = -30; y1 = -11;
83  x2 = 30; y2 = 11;
84 }
85 
86 // -------------------------------------------------------
87 Element* Resistor::info(QString& Name, char* &BitmapFile, bool getNewOne)
88 {
89  Name = QObject::tr("Resistor");
90  BitmapFile = (char *) "resistor";
91 
92  if(getNewOne) return new Resistor();
93  return 0;
94 }
95 
96 // -------------------------------------------------------
97 Element* Resistor::info_us(QString& Name, char* &BitmapFile, bool getNewOne)
98 {
99  Name = QObject::tr("Resistor US");
100  BitmapFile = (char *) "resistor_us";
101 
102  if(getNewOne) return new Resistor(false);
103  return 0;
104 }
Q3PtrList< Line > Lines
Definition: component.h:67
int y1
Definition: element.h:153
int tx
Definition: component.h:78
int y2
Definition: element.h:153
Definition: element.h:72
int x1
Definition: element.h:153
Resistor(bool european=true)
Definition: resistor.cpp:23
int ty
Definition: component.h:78
Q3PtrList< Property > Props
Definition: component.h:72
static Element * info_us(QString &, char *&, bool getNewOne=false)
Definition: resistor.cpp:97
static Element * info(QString &, char *&, bool getNewOne=false)
Definition: resistor.cpp:87
Definition: element.h:48
Superclass of all schematic drawing elements.
Definition: element.h:142
Q3PtrList< Port > Ports
Definition: component.h:70
QString Name
Definition: component.h:80
void createSymbol()
Definition: resistor.cpp:57
QString Model
Definition: component.h:80
Component * newOne()
Definition: resistor.cpp:51
QString Description
Definition: component.h:81
int x2
Definition: element.h:153