My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
subcirport.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  subcirport.cpp
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 "subcirport.h"
19 #include "node.h"
20 #include "schematic.h"
21 
22 
24 {
25  Type = isComponent; // both analog and digital
26  Description = QObject::tr("port of a subcircuit");
27 
28  // This property must be the first one !
29  Props.append(new Property("Num", "1", true,
30  QObject::tr("number of the port within the subcircuit")));
31  // This property must be the second one !
32  Props.append(new Property("Type", "analog", false,
33  QObject::tr("type of the port (for digital simulation only)")
34  +" [analog, in, out, inout]"));
35 
36  createSymbol();
37  tx = x1+4;
38  ty = y2+4;
39  Model = "Port";
40  Name = "P";
41 }
42 
43 // -------------------------------------------------------
45 {
46  x1 = -27; y1 = -8;
47  x2 = 0; y2 = 8;
48 
49  if(Props.at(1)->Value.at(0) == 'a') {
50  Arcs.append(new Arc(-25, -6, 12, 12, 0, 16*360,QPen(QPen::darkBlue,2)));
51  Lines.append(new Line(-13, 0, 0, 0,QPen(QPen::darkBlue,2)));
52  }
53  else {
54  Lines.append(new Line( -9, 0, 0, 0,QPen(QPen::darkBlue,2)));
55  if(Props.at(1)->Value == "out") {
56  Lines.append(new Line(-20, -5,-25, 0,QPen(QPen::red,2)));
57  Lines.append(new Line(-20, 5,-25, 0,QPen(QPen::red,2)));
58  Lines.append(new Line(-20, -5, -9, -5,QPen(QPen::red,2)));
59  Lines.append(new Line(-20, 5, -9, 5,QPen(QPen::red,2)));
60  Lines.append(new Line( -9, -5, -9, 5,QPen(QPen::red,2)));
61  }
62  else {
63  Lines.append(new Line(-14, -5, -9, 0,QPen(QPen::darkGreen,2)));
64  Lines.append(new Line(-14, 5, -9, 0,QPen(QPen::darkGreen,2)));
65  if(Props.at(1)->Value == "in") {
66  Lines.append(new Line(-25, -5,-14, -5,QPen(QPen::darkGreen,2)));
67  Lines.append(new Line(-25, 5,-14, 5,QPen(QPen::darkGreen,2)));
68  Lines.append(new Line(-25, -5,-25, 5,QPen(QPen::darkGreen,2)));
69  }
70  else {
71  x1 = -30;
72  Lines.append(new Line(-18, -5,-14, -5,QPen(QPen::darkGreen,2)));
73  Lines.append(new Line(-18, 5,-14, 5,QPen(QPen::darkGreen,2)));
74  Lines.append(new Line(-23, -5,-28, 0,QPen(QPen::red,2)));
75  Lines.append(new Line(-23, 5,-28, 0,QPen(QPen::red,2)));
76  Lines.append(new Line(-23, -5,-18, -5,QPen(QPen::red,2)));
77  Lines.append(new Line(-23, 5,-18, 5,QPen(QPen::red,2)));
78  }
79  }
80  }
81 
82  Ports.append(new Port( 0, 0));
83 }
84 
85 // -------------------------------------------------------
87 {
88  return new SubCirPort();
89 }
90 
91 // -------------------------------------------------------
92 Element* SubCirPort::info(QString& Name, char* &BitmapFile, bool getNewOne)
93 {
94  Name = QObject::tr("Subcircuit Port");
95  BitmapFile = (char *) "subport";
96 
97  if(getNewOne) return new SubCirPort();
98  return 0;
99 }
100 
101 // -------------------------------------------------------
103 {
104  return QString("");
105 }
106 
107 // -------------------------------------------------------
109 {
110  if(Props.at(1)->Value != "out")
111  return QString("");
112 
113  // Insert dummy buffer to avoid reading from an output port.
114  QString s = " net_out";
115  Node *pn = Ports.getFirst()->Connection;
116  s += pn->Name + " <= ";
117  s += pn->Name + ";\n";
118  return s;
119 }
120 
121 // -------------------------------------------------------
123 {
124  return QString("");
125 }