My Project  0.0.16
QUCS Mapping
 All Classes Namespaces 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 
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(QPen::darkBlue,2)));
36  Lines.append(new Line(-xb, yb, xb+3,yb,QPen(QPen::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 }