Qucs-GUI  0.0.19
/home/travis/build/Qucs/qucs/qucs/qucs/components/equation.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           equation.cpp  -  description
00003                              -------------------
00004     begin                : Sat Aug 23 2003
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 #include "equation.h"
00018 #include "main.h"
00019 
00020 #include <QFontMetrics>
00021 
00022 Equation::Equation()
00023 {
00024   Type = isComponent; // Analogue and digital component.
00025   Description = QObject::tr("equation");
00026 
00027   QFont f = QucsSettings.font;
00028   f.setWeight(QFont::Light);
00029   f.setPointSizeF(12.0);
00030   QFontMetrics  metrics(f, 0);  // use the the screen-compatible metric
00031   QSize r = metrics.size(0, QObject::tr("Equation"));
00032   int xb = r.width()  >> 1;
00033   int yb = r.height() >> 1;
00034 
00035   Lines.append(new Line(-xb, -yb, -xb,  yb,QPen(Qt::darkBlue,2)));
00036   Lines.append(new Line(-xb,  yb,  xb+3,yb,QPen(Qt::darkBlue,2)));
00037   Texts.append(new Text(-xb+4,  -yb-3, QObject::tr("Equation"),
00038       QColor(0,0,0), 12.0));
00039 
00040   x1 = -xb-3;  y1 = -yb-5;
00041   x2 =  xb+9; y2 =  yb+3;
00042 
00043   tx = x1+4;
00044   ty = y2+4;
00045   Model = "Eqn";
00046   Name  = "Eqn";
00047 
00048   Props.append(new Property("y", "1", true));
00049   Props.append(new Property("Export", "yes", false,
00050       QObject::tr("put result into dataset")+" [yes, no]"));
00051 }
00052 
00053 Equation::~Equation()
00054 {
00055 }
00056 
00057 // -------------------------------------------------------
00058 QString Equation::verilogCode(int)
00059 {
00060   QString s;
00061   // output all equations
00062   for(Property *pr = Props.first(); pr != 0; pr = Props.next())
00063     if(pr->Name != "Export")
00064       s += "  real "+pr->Name+"; initial "+pr->Name+" = "+pr->Value+";\n";
00065   return s;
00066 }
00067 
00068 // -------------------------------------------------------
00069 QString Equation::vhdlCode(int)
00070 {
00071   QString s;
00072   // output all equations
00073   for(Property *pr = Props.first(); pr != 0; pr = Props.next())
00074     if(pr->Name != "Export")
00075       s += "  constant "+pr->Name+" : time := "+pr->Value+";\n";
00076   return s;
00077 }
00078 
00079 Component* Equation::newOne()
00080 {
00081   return new Equation();
00082 }
00083 
00084 Element* Equation::info(QString& Name, char* &BitmapFile, bool getNewOne)
00085 {
00086   Name = QObject::tr("Equation");
00087   BitmapFile = (char *) "";
00088 
00089   if(getNewOne)  return new Equation();
00090   return 0;
00091 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines