Qucs-GUI  0.0.19
/home/travis/build/Qucs/qucs/qucs/qucs/components/subcirport.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                                subcirport.cpp
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 "subcirport.h"
00018 #include "node.h"
00019 #include "schematic.h"
00020 
00021 
00022 SubCirPort::SubCirPort()
00023 {
00024   Type = isComponent;   // both analog and digital
00025   Description = QObject::tr("port of a subcircuit");
00026 
00027   // This property must be the first one !
00028   Props.append(new Property("Num", "1", true,
00029     QObject::tr("number of the port within the subcircuit")));
00030   // This property must be the second one !
00031   Props.append(new Property("Type", "analog", false,
00032     QObject::tr("type of the port (for digital simulation only)")
00033     +" [analog, in, out, inout]"));
00034 
00035   createSymbol();
00036   tx = x1+4;
00037   ty = y2+4;
00038   Model = "Port";
00039   Name  = "P";
00040 }
00041 
00042 // -------------------------------------------------------
00043 void SubCirPort::createSymbol()
00044 {
00045   x1 = -27; y1 = -8;
00046   x2 =   0; y2 =  8;
00047 
00048   if(Props.at(1)->Value.at(0) == 'a') {
00049     Arcs.append(new Arc(-25, -6, 12, 12,  0, 16*360,QPen(Qt::darkBlue,2)));
00050     Lines.append(new Line(-13,  0,  0,  0,QPen(Qt::darkBlue,2)));
00051   }
00052   else {
00053     Lines.append(new Line( -9,  0,  0,  0,QPen(Qt::darkBlue,2)));
00054     if(Props.at(1)->Value == "out") {
00055       Lines.append(new Line(-20, -5,-25,  0,QPen(Qt::red,2)));
00056       Lines.append(new Line(-20,  5,-25,  0,QPen(Qt::red,2)));
00057       Lines.append(new Line(-20, -5, -9, -5,QPen(Qt::red,2)));
00058       Lines.append(new Line(-20,  5, -9,  5,QPen(Qt::red,2)));
00059       Lines.append(new Line( -9, -5, -9,  5,QPen(Qt::red,2)));
00060     }
00061     else {
00062       Lines.append(new Line(-14, -5, -9,  0,QPen(Qt::darkGreen,2)));
00063       Lines.append(new Line(-14,  5, -9,  0,QPen(Qt::darkGreen,2)));
00064       if(Props.at(1)->Value == "in") {
00065         Lines.append(new Line(-25, -5,-14, -5,QPen(Qt::darkGreen,2)));
00066         Lines.append(new Line(-25,  5,-14,  5,QPen(Qt::darkGreen,2)));
00067         Lines.append(new Line(-25, -5,-25,  5,QPen(Qt::darkGreen,2)));
00068       }
00069       else {
00070         x1 = -30;
00071         Lines.append(new Line(-18, -5,-14, -5,QPen(Qt::darkGreen,2)));
00072         Lines.append(new Line(-18,  5,-14,  5,QPen(Qt::darkGreen,2)));
00073         Lines.append(new Line(-23, -5,-28,  0,QPen(Qt::red,2)));
00074         Lines.append(new Line(-23,  5,-28,  0,QPen(Qt::red,2)));
00075         Lines.append(new Line(-23, -5,-18, -5,QPen(Qt::red,2)));
00076         Lines.append(new Line(-23,  5,-18,  5,QPen(Qt::red,2)));
00077       }
00078     }
00079   }
00080 
00081   Ports.append(new Port(  0,  0));
00082 }
00083 
00084 // -------------------------------------------------------
00085 Component* SubCirPort::newOne()
00086 {
00087   return new SubCirPort();
00088 }
00089 
00090 // -------------------------------------------------------
00091 Element* SubCirPort::info(QString& Name, char* &BitmapFile, bool getNewOne)
00092 {
00093   Name = QObject::tr("Subcircuit Port");
00094   BitmapFile = (char *) "subport";
00095 
00096   if(getNewOne)  return new SubCirPort();
00097   return 0;
00098 }
00099 
00100 // -------------------------------------------------------
00101 QString SubCirPort::netlist()
00102 {
00103   return QString("");
00104 }
00105 
00106 // -------------------------------------------------------
00107 QString SubCirPort::vhdlCode(int)
00108 {
00109   if(Props.at(1)->Value != "out")
00110     return QString("");
00111 
00112   // Insert dummy buffer to avoid reading from an output port.
00113   QString s = "  net_out";
00114   Node *pn = Ports.first()->Connection;
00115   s += pn->Name + " <= ";
00116   s += pn->Name + ";\n";
00117   return s;
00118 }
00119 
00120 // -------------------------------------------------------
00121 QString SubCirPort::verilogCode(int)
00122 {
00123   return QString("");
00124 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines