Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
equation.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  equation.cpp - description
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 "equation.h"
19 #include "main.h"
20 
21 
23 {
24  Type = isComponent; // Analogue and digital component.
25  Description = QObject::tr("equation");
26 
27  QFont f = QucsSettings.font;
28  f.setWeight(QFont::Light);
29  f.setPointSizeFloat(12.0);
30  QFontMetrics metrics(f);
31  QSize r = metrics.size(0, QObject::tr("Equation"));
32  int xb = r.width() >> 1;
33  int yb = r.height() >> 1;
34 
35  Lines.append(new Line(-xb, -yb, -xb, yb,QPen(Qt::darkBlue,2)));
36  Lines.append(new Line(-xb, yb, xb+3,yb,QPen(Qt::darkBlue,2)));
37  Texts.append(new Text(-xb+4, -yb-3, QObject::tr("Equation"),
38  QColor(0,0,0), 12.0));
39 
40  x1 = -xb-3; y1 = -yb-5;
41  x2 = xb+9; y2 = yb+3;
42 
43  tx = x1+4;
44  ty = y2+4;
45  Model = "Eqn";
46  Name = "Eqn";
47 
48  Props.append(new Property("y", "1", true));
49  Props.append(new Property("Export", "yes", false,
50  QObject::tr("put result into dataset")+" [yes, no]"));
51 }
52 
54 {
55 }
56 
57 // -------------------------------------------------------
59 {
60  QString s;
61  // output all equations
62  for(Property *pr = Props.first(); pr != 0; pr = Props.next())
63  if(pr->Name != "Export")
64  s += " real "+pr->Name+"; initial "+pr->Name+" = "+pr->Value+";\n";
65  return s;
66 }
67 
68 // -------------------------------------------------------
69 QString Equation::vhdlCode(int)
70 {
71  QString s;
72  // output all equations
73  for(Property *pr = Props.first(); pr != 0; pr = Props.next())
74  if(pr->Name != "Export")
75  s += " constant "+pr->Name+" : time := "+pr->Value+";\n";
76  return s;
77 }
78 
80 {
81  return new Equation();
82 }
83 
84 Element* Equation::info(QString& Name, char* &BitmapFile, bool getNewOne)
85 {
86  Name = QObject::tr("Equation");
87  BitmapFile = (char *) "";
88 
89  if(getNewOne) return new Equation();
90  return 0;
91 }
Q3PtrList< Line > Lines
Definition: component.h:67
int Type
Definition: element.h:152
int y1
Definition: element.h:153
QFont font
Definition: main.h:46
Equation()
Definition: equation.cpp:22
tQucsSettings QucsSettings
Definition: main.cpp:52
int tx
Definition: component.h:78
int y2
Definition: element.h:153
int x1
Definition: element.h:153
QString verilogCode(int)
Definition: equation.cpp:58
Definitions and declarations for the main application.
int ty
Definition: component.h:78
QString vhdlCode(int)
Definition: equation.cpp:69
Q3PtrList< Property > Props
Definition: component.h:72
Definition: element.h:82
Definition: element.h:48
Superclass of all schematic drawing elements.
Definition: element.h:142
~Equation()
Definition: equation.cpp:53
QString Name
Definition: component.h:80
Q3PtrList< Text > Texts
Definition: component.h:71
QString Model
Definition: component.h:80
QString Description
Definition: component.h:81
static Element * info(QString &, char *&, bool getNewOne=false)
Definition: equation.cpp:84
#define isComponent
Definition: element.h:110
Component * newOne()
Definition: equation.cpp:79
int x2
Definition: element.h:153