forked from ra3xdh/qucs_s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponent.h
183 lines (150 loc) · 6.44 KB
/
component.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/***************************************************************************
component.h
-------------
begin : Sat Aug 23 2003
copyright : (C) 2003 by Michael Margraf
email : michael.margraf@alumni.tu-berlin.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef COMPONENT_H
#define COMPONENT_H
// QObject is needed here to be transitively included
// from component implementations. Some how non-Linux
// builds fail without explicit QObject inclusion
#include <QObject>
#include "extsimkernels/spicecompat.h"
#include <QList>
#include "element.h"
#include "main.h"
#include "muParser.h"
class Schematic;
class QString;
class QPen;
class Component : public Element {
public:
Component();
Component(const ComponentInfo& CI);
virtual ~Component() {};
virtual Component* newOne();
virtual void recreate(Schematic*) {};
QString getNetlist();
QString getSpiceNetlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
QString getVerilogACode();
virtual QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
virtual QString getEquations(QString sim, QStringList &dep_vars);
virtual QStringList getExtraVariables();
virtual QString getProbeVariable(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
virtual QString getSpiceModel();
virtual QString getSpiceLibrary() { return QString(); }
virtual QStringList getSpiceLibraryFiles() { return QStringList(); }
virtual QString getNgspiceBeforeSim(QString sim, int lvl=0);
virtual QString getNgspiceAfterSim(QString sim, int lvl=0);
virtual QString getVAvariables() {return QString();};
virtual QString getVAExpressions() {return QString();};
virtual void getExtraVANodes(QStringList& ) {};
QString get_VHDL_Code(int);
QString get_Verilog_Code(int);
void paint(QPainter* painter);
void paintScheme(Schematic*);
void setCenter(int, int, bool relative=false);
void getCenter(int&, int&);
int textSize(int&, int&);
void Bounding(int&, int&, int&, int&);
void entireBounds(int&, int&, int&, int&);
bool getSelected(int, int);
int getTextSelected(int, int);
void rotate();
void mirrorX(); // mirror about X axis
void mirrorY(); // mirror about Y axis
QString save();
bool load(const QString&);
void loadfromComponentInfo(ComponentInfo);
static void loadSymbol(SymbolDescription, QList<Port *>&, QList<qucs::Line *>&, QList<struct qucs::Arc *>&, QList<qucs::Polyline *>&);
double evaluateExpression(QString);
QString getValue(const Property* p);
// to hold track of the component appearance for saving and copying
bool mirroredX; // is it mirrored about X axis or not
int rotated; // rotation angle divided by 90 degrees
int icon_dx = 0; // used to adjust icon position
int icon_dy = 0;
virtual QString getSubcircuitFile() { return ""; }
// set the pointer scematic associated with the component
virtual void setSchematic (Schematic* p) { containingSchematic = p; }
virtual Schematic* getSchematic () {return containingSchematic; }
QList<qucs::Line *> Lines;
QList<qucs::Polyline *> Polylines;
QList<struct qucs::Arc *> Arcs;
QList<qucs::Rect *> Rects;
QList<qucs::Ellips *> Ellipses;
QList<Port *> Ports;
QList<Text *> Texts;
QList<Property*> Props;
#define COMP_IS_OPEN 0
#define COMP_IS_ACTIVE 1
#define COMP_IS_SHORTEN 2
int isActive; // should it be used in simulation or not ?
int tx, ty; // upper left corner of text (position)
bool showName;
bool isSimulation; // is it AC,DC,TR or other spice-compatible simulation?
bool isEquation;
bool XML_Defined; // Flag to identify externally defined component from hardcoded devices
int Simulator = spicecompat::simAll;;
QString Model; // This is the name it shows in the schematic (e.g. "C"). It does not contain the part counter.
QString Name;
QString Description;
QString Category;
QString SpiceModel;
QStringList SpiceModelcards; // one device may have two modelcards like NPN,PNP
QPen WrongSimulatorPen;
int PartCounter; // Counter. Used for schematic placing
QString ComponentName; // Convenitional name (e.g. "Capacitor"). It does not contain the part counter.
void paintIcon(QPixmap *pixmap);
Property * getProperty(const QString&);
QMap<QString, QString> Netlists;
protected:
virtual QString netlist();
virtual QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
virtual QString cdl_netlist();
virtual QString va_code();
virtual QString vhdlCode(int);
virtual QString verilogCode(int);
QString form_spice_param_list(QStringList& ignore_list, QStringList& convert_list);
int analyseLine(const QString&, int);
bool getIntegers(const QString&, int *i1=0, int *i2=0, int *i3=0,
int *i4=0, int *i5=0, int *i6=0);
bool getPen(const QString&, QPen&, int);
bool getBrush(const QString&, QBrush&, int);
void copyComponent(Component*);
Schematic* containingSchematic;
virtual void drawSymbol(QPainter* p);
QString extractValue(const QString &input);
};
class MultiViewComponent : public Component {
public:
MultiViewComponent() {};
virtual ~MultiViewComponent() {};
void recreate(Schematic*);
protected:
virtual void createSymbol() {};
};
class GateComponent : public MultiViewComponent {
public:
GateComponent();
QString netlist();
QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
QString vhdlCode(int);
QString verilogCode(int);
protected:
void createSymbol();
};
// prototype of independent function
Component* getComponentFromName(QString& Line, Schematic* p=NULL);
ComponentInfo* findComponentByModel(const QString&); // Gets a component from the QMap library
#endif