// ------------------------------------------------------- void SPEmbed::createSymbol() { QFont Font(QucsSettings.font); // default application font // symbol text is smaller (10 pt default) Font.setPointSize(10 ); // get the small font size; use the screen-compatible metric QFontMetrics smallmetrics(Font, 0); int fHeight = smallmetrics.lineSpacing(); QString stmp; int w, PortDistance = 60; int Num = Props.getLast()->Value.toInt(); // adjust number of ports if(Num < 1) Num = 1; else if(Num > 8) { PortDistance = 20; if(Num > 40) Num = 40; } Props.getLast()->Value = QString::number(Num); // draw symbol outline int h = (PortDistance/2)*((Num-1)/2) + 15; Lines.append(new Line(-15, -h, 15, -h,QPen(Qt::darkBlue,2))); Lines.append(new Line( 15, -h, 15, h,QPen(Qt::darkBlue,2))); Lines.append(new Line(-15, h, 15, h,QPen(Qt::darkBlue,2))); Lines.append(new Line(-15, -h,-15, h,QPen(Qt::darkBlue,2))); stmp = QObject::tr("file"); w = smallmetrics.width(stmp); // compute text size to center it Texts.append(new Text(-w/2, -fHeight/2, stmp)); int i=0, y = 15-h; while(i<Num) { // add ports lines and numbers i++; Lines.append(new Line(-30, y,-15, y,QPen(Qt::darkBlue,2))); Ports.append(new Port(-30, y)); stmp = QString::number(i); w = smallmetrics.width(stmp); Texts.append(new Text(-25-w, y-fHeight-2, stmp)); // text right-aligned if(i == Num) break; // if odd number of ports there will be one port less on the right side i++; Lines.append(new Line( 15, y, 30, y,QPen(Qt::darkBlue,2))); Ports.append(new Port( 30, y)); stmp = QString::number(i); Texts.append(new Text(25, y-fHeight-2, stmp)); // text left-aligned y += PortDistance; } Lines.append(new Line( 0, h, 0,h+15,QPen(Qt::darkBlue,2))); Texts.append(new Text( 4, h,"Ref")); Ports.append(new Port( 0,h+15)); // 'Ref' port x1 = -30; y1 = -h-2; x2 = 30; y2 = h+15; // compute component name text position - normal size font QFontMetrics metrics(QucsSettings.font, 0); // use the screen-compatible metric tx = x1+4; ty = y1 - 2*metrics.lineSpacing() - 4; }
RLCG::RLCG() { Description = QObject::tr("RLCG transmission line"); Lines.append(new Line(-30, 0, 30, 0,QPen(Qt::darkBlue,2))); Lines.append(new Line(-28, 7, 28, 7,QPen(Qt::darkBlue,2))); Lines.append(new Line(-28, 14,-21, 7,QPen(Qt::darkBlue,2))); Lines.append(new Line(-21, 14,-14, 7,QPen(Qt::darkBlue,2))); Lines.append(new Line(-14, 14, -7, 7,QPen(Qt::darkBlue,2))); Lines.append(new Line( -7, 14, 0, 7,QPen(Qt::darkBlue,2))); Lines.append(new Line( 0, 14, 7, 7,QPen(Qt::darkBlue,2))); Lines.append(new Line( 7, 14, 14, 7,QPen(Qt::darkBlue,2))); Lines.append(new Line( 14, 14, 21, 7,QPen(Qt::darkBlue,2))); Lines.append(new Line( 21, 14, 28, 7,QPen(Qt::darkBlue,2))); QFont Font(QucsSettings.font); // default application font // symbol text is smaller (10 pt default) Font.setPointSize(10); // get the small font size; use the screen-compatible metric QFontMetrics smallmetrics(Font, 0); int fHeight = smallmetrics.lineSpacing(); QString tmp = QObject::tr("RLCG"); int w = smallmetrics.width(tmp); Texts.append(new Text(w/-2, -fHeight, tmp)); Ports.append(new Port(-30, 0)); Ports.append(new Port( 30, 0)); x1 = -30; y1 = -fHeight; x2 = 30; y2 = 16; tx = x1+4; ty = y2+4; Model = "RLCG"; Name = "Line"; Props.append(new Property("R", "0.0", false, QObject::tr("resistive load")+" ("+QObject::tr ("Ohm/m")+")")); Props.append(new Property("L", "0.6e-6", true, QObject::tr("inductive load")+" ("+QObject::tr ("H/m")+")")); Props.append(new Property("C", "240e-12", true, QObject::tr("capacitive load")+" ("+QObject::tr ("F/m")+")")); Props.append(new Property("G", "0.0", false, QObject::tr("conductive load")+" ("+QObject::tr ("S/m")+")")); Props.append(new Property("Length", "1 mm", true, QObject::tr("electrical length of the line"))); Props.append(new Property("Temp", "26.85", false, QObject::tr("simulation temperature in degree Celsius"))); }
// ------------------------------------------------------- void RFedd2P::createSymbol() { QFont Font(QucsSettings.font); // default application font // symbol text is smaller (10 pt default) Font.setPointSize(10); // get the small font size; use the screen-compatible metric QFontMetrics smallmetrics(Font, 0); int fHeight = smallmetrics.lineSpacing(); QString tmp; int w, i; // draw symbol #define HALFWIDTH 17 int h = 15; Lines.append(new Line(-HALFWIDTH, -h, HALFWIDTH, -h,QPen(Qt::darkBlue,2))); Lines.append(new Line( HALFWIDTH, -h, HALFWIDTH, h,QPen(Qt::darkBlue,2))); Lines.append(new Line(-HALFWIDTH, h, HALFWIDTH, h,QPen(Qt::darkBlue,2))); Lines.append(new Line(-HALFWIDTH, -h,-HALFWIDTH, h,QPen(Qt::darkBlue,2))); // component text name tmp = Props.at(0)->Value; w = smallmetrics.width(tmp); Texts.append(new Text(-w/2, -fHeight/2, tmp)); // text centered in the box // add port numbers text i = 0; int y = 15-h; Lines.append(new Line(-30, y,-HALFWIDTH, y,QPen(Qt::darkBlue,2))); Ports.append(new Port(-30, y)); tmp = QString::number(i+1); w = smallmetrics.width(tmp); Texts.append(new Text(-25-w, y-fHeight-2, tmp)); // text right-aligned i++; Lines.append(new Line(HALFWIDTH, y, 30, y,QPen(Qt::darkBlue,2))); Ports.append(new Port( 30, y)); tmp = QString::number(i+1); Texts.append(new Text(25, y-fHeight-2, tmp)); // text left-aligned y += 60; i++; x1 = -30; y1 = -h-2; x2 = 30; y2 = h+2; // compute component name text position - normal size font QFontMetrics metrics(QucsSettings.font, 0); // use the screen-compatible metric tx = x1+4; ty = y1 - metrics.lineSpacing() - 4; }
// ------------------------------------------------------- void SpiceFile::createSymbol() { QFont f = QucsSettings.font; // get the basic font // symbol text is smaller (10 pt default) f.setPointSize(10); // use the screen-compatible metric QFontMetrics smallmetrics(f, 0); // get size of text int fHeight = smallmetrics.lineSpacing(); int No = 0; QString tmp, PortNames = Props.at(1)->Value; if(!PortNames.isEmpty()) No = PortNames.count(',') + 1; // draw symbol outline #define HALFWIDTH 17 int h = 30*((No-1)/2) + 15; Lines.append(new Line(-HALFWIDTH, -h, HALFWIDTH, -h,QPen(Qt::darkBlue,2))); Lines.append(new Line( HALFWIDTH, -h, HALFWIDTH, h,QPen(Qt::darkBlue,2))); Lines.append(new Line(-HALFWIDTH, h, HALFWIDTH, h,QPen(Qt::darkBlue,2))); Lines.append(new Line(-HALFWIDTH, -h,-HALFWIDTH, h,QPen(Qt::darkBlue,2))); int w, i = fHeight/2; if(withSim) { i = fHeight - 2; tmp = QObject::tr("sim"); w = smallmetrics.width(tmp); Texts.append(new Text(w/-2, 0, tmp, Qt::red)); } tmp = QObject::tr("spice"); w = smallmetrics.boundingRect(tmp).width(); Texts.append(new Text(w/-2, -i, tmp)); i = 0; int y = 15-h; while(i<No) { // add ports lines and numbers Lines.append(new Line(-30, y,-HALFWIDTH, y,QPen(Qt::darkBlue,2))); Ports.append(new Port(-30, y)); tmp = PortNames.section(',', i, i).mid(4); w = smallmetrics.width(tmp); Texts.append(new Text(-20-w, y-fHeight-2, tmp)); // text right-aligned i++; if(i == No) break; // if odd number of ports there will be one port less on the right side Lines.append(new Line(HALFWIDTH, y, 30, y,QPen(Qt::darkBlue,2))); Ports.append(new Port( 30, y)); tmp = PortNames.section(',', i, i).mid(4); Texts.append(new Text( 20, y-fHeight-2, tmp)); // text left-aligned y += 60; i++; } if(No > 0) { Lines.append(new Line( 0, h, 0,h+15,QPen(Qt::darkBlue,2))); Texts.append(new Text( 4, h,"Ref")); Ports.append(new Port( 0, h+15)); // 'Ref' port } x1 = -30; y1 = -h-2; x2 = 30; y2 = h+15; // compute component name text position - normal size font QFontMetrics metrics(QucsSettings.font, 0); // use the screen-compatible metric fHeight = metrics.lineSpacing(); tx = x1+4; ty = y1 - fHeight - 4; if(Props.first()->display) ty -= fHeight; changed = true; }
Mutual2::Mutual2() { Description = QObject::tr("three mutual inductors"); QFont Font(QucsSettings.font); // default application font // symbol text is smaller (10 pt default) Font.setPointSize(10); // get the small font size; use the screen-compatible metric QFontMetrics smallmetrics(Font, 0); int w; QString stmp; Arcs.append(new Arc(-16,-58,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); Arcs.append(new Arc(-16,-46,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); Arcs.append(new Arc(-16,-34,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); Arcs.append(new Arc(-16, 46,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); Arcs.append(new Arc(-16, 34,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); Arcs.append(new Arc(-16, 22,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); Arcs.append(new Arc( 4,-18,12,12, 16*90,16*180, QPen(Qt::darkBlue,2))); Arcs.append(new Arc( 4, -6,12,12, 16*90,16*180, QPen(Qt::darkBlue,2))); Arcs.append(new Arc( 4, 6,12,12, 16*90,16*180, QPen(Qt::darkBlue,2))); Lines.append(new Line(-10,-58,-10,-70,QPen(Qt::darkBlue,2))); Lines.append(new Line(-10,-70,-30,-70,QPen(Qt::darkBlue,2))); Lines.append(new Line( 10,-18, 10,-30,QPen(Qt::darkBlue,2))); Lines.append(new Line( 10,-30, 30,-30,QPen(Qt::darkBlue,2))); Lines.append(new Line(-10, 58,-10, 70,QPen(Qt::darkBlue,2))); Lines.append(new Line(-10, 70,-30, 70,QPen(Qt::darkBlue,2))); Lines.append(new Line( 10, 18, 10, 30,QPen(Qt::darkBlue,2))); Lines.append(new Line( 10, 30, 30, 30,QPen(Qt::darkBlue,2))); Lines.append(new Line(-10,-10,-30,-10,QPen(Qt::darkBlue,2))); Lines.append(new Line(-10,-22,-10,-10,QPen(Qt::darkBlue,2))); Lines.append(new Line(-10, 10,-30, 10,QPen(Qt::darkBlue,2))); Lines.append(new Line(-10, 10,-10, 22,QPen(Qt::darkBlue,2))); stmp = "1"; w = smallmetrics.width(stmp); // compute width to right-align Texts.append(new Text(-13-w,-61,stmp)); stmp = "2"; w = smallmetrics.width(stmp); // compute width to right-align Texts.append(new Text(-13-w, 18,stmp)); Texts.append(new Text( 13,-22,"3")); // left-aligned, no need to compute width Lines.append(new Line( 0,-57, 0, 57,QPen(Qt::darkBlue,1,Qt::DashLine))); Ports.append(new Port(-30,-70)); Ports.append(new Port( 30,-30)); Ports.append(new Port( 30, 30)); Ports.append(new Port(-30, 70)); Ports.append(new Port(-30, 10)); Ports.append(new Port(-30,-10)); x1 = -33; y1 = -74; x2 = 33; y2 = 74; tx = x1+4; ty = y2+4; Model = "MUT2"; Name = "Tr"; Props.append(new Property("L1", "1 mH", false, QObject::tr("inductance of coil 1"))); Props.append(new Property("L2", "1 mH", false, QObject::tr("inductance of coil 2"))); Props.append(new Property("L3", "1 mH", false, QObject::tr("inductance of coil 3"))); Props.append(new Property("k12", "0.9", false, QObject::tr("coupling factor between coil 1 and 2"))); Props.append(new Property("k13", "0.9", false, QObject::tr("coupling factor between coil 1 and 3"))); Props.append(new Property("k23", "0.9", false, QObject::tr("coupling factor between coil 2 and 3"))); }
symTrafo::symTrafo() { Description = QObject::tr("ideal symmetrical transformer"); QFont Font(QucsSettings.font); // default application font // symbol text is smaller (10 pt default) Font.setPointSize(10); // get the small font size; use the screen-compatible metric QFontMetrics smallmetrics(Font, 0); int w; QString stmp; Arcs.append(new Arc(-16,-58,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); Arcs.append(new Arc(-16,-46,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); Arcs.append(new Arc(-16,-34,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); Arcs.append(new Arc(-16, 46,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); Arcs.append(new Arc(-16, 34,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); Arcs.append(new Arc(-16, 22,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); Arcs.append(new Arc( 4,-18,12,12, 16*90,16*180, QPen(Qt::darkBlue,2))); Arcs.append(new Arc( 4, -6,12,12, 16*90,16*180, QPen(Qt::darkBlue,2))); Arcs.append(new Arc( 4, 6,12,12, 16*90,16*180, QPen(Qt::darkBlue,2))); Lines.append(new Line(-10,-58,-10,-70,QPen(Qt::darkBlue,2))); Lines.append(new Line(-10,-70,-30,-70,QPen(Qt::darkBlue,2))); Lines.append(new Line( 10,-18, 10,-30,QPen(Qt::darkBlue,2))); Lines.append(new Line( 10,-30, 30,-30,QPen(Qt::darkBlue,2))); Lines.append(new Line(-10, 58,-10, 70,QPen(Qt::darkBlue,2))); Lines.append(new Line(-10, 70,-30, 70,QPen(Qt::darkBlue,2))); Lines.append(new Line( 10, 18, 10, 30,QPen(Qt::darkBlue,2))); Lines.append(new Line( 10, 30, 30, 30,QPen(Qt::darkBlue,2))); Lines.append(new Line(-10,-10,-30,-10,QPen(Qt::darkBlue,2))); Lines.append(new Line(-10,-22,-10,-10,QPen(Qt::darkBlue,2))); Lines.append(new Line(-10, 10,-30, 10,QPen(Qt::darkBlue,2))); Lines.append(new Line(-10, 10,-10, 22,QPen(Qt::darkBlue,2))); // core lines Lines.append(new Line( -1,-57, -1, 57,QPen(Qt::darkBlue,1))); Lines.append(new Line( 1,-57, 1, 57,QPen(Qt::darkBlue,1))); stmp = "T1"; w = smallmetrics.width(stmp); // compute width to right-align Texts.append(new Text(-13-w,-57,stmp)); stmp = "T2"; w = smallmetrics.width(stmp); // compute width to right-align Texts.append(new Text(-13-w, 22,stmp)); // mark the turn direction Arcs.append(new Arc(-21,-64, 5, 5, 0, 16*360,QPen(Qt::darkBlue,2))); Arcs.append(new Arc(-21, 15, 5, 5, 0, 16*360,QPen(Qt::darkBlue,2))); Arcs.append(new Arc( 15,-24, 5, 5, 0, 16*360,QPen(Qt::darkBlue,2))); Ports.append(new Port(-30,-70)); Ports.append(new Port( 30,-30)); Ports.append(new Port( 30, 30)); Ports.append(new Port(-30, 70)); Ports.append(new Port(-30, 10)); Ports.append(new Port(-30,-10)); x1 = -33; y1 = -74; x2 = 33; y2 = 74; tx = x1+4; ty = y2+4; Model = "sTr"; Name = "Tr"; Props.append(new Property("T1", "1", true, QObject::tr("voltage transformation ratio of coil 1"))); Props.append(new Property("T2", "1", true, QObject::tr("voltage transformation ratio of coil 2"))); }
// ------------------------------------------------------- void EqnDefined::createSymbol() { QFont Font(QucsSettings.font); // default application font // symbol text is smaller (10 pt default) //Font.setPointSizeF(Font.pointSizeF()/1.2); // symbol text size proportional to default font size Font.setPointSize(10); // symbol text size fixed at 10 pt // get the small font size; use the screen-compatible metric QFontMetrics smallmetrics(Font, 0); int fHeight = smallmetrics.lineSpacing(); QString tmp; int i, PortDistance = 60; // adjust branch number int Num = Props.at(1)->Value.toInt(); if(Num < 1) Num = 1; else if(Num > 4) { PortDistance = 40; if(Num > 20) Num = 20; } Props.at(1)->Value = QString::number(Num); // adjust actual number of properties int NumProps = (Props.count() - 2) / 2; // current number of properties if (NumProps < Num) { for(i = NumProps; i < Num; i++) { Props.append(new Property("I"+QString::number(i+1), "0", false, QObject::tr("current equation") + " " +QString::number(i+1))); Props.append(new Property("Q"+QString::number(i+1), "0", false, QObject::tr("charge equation") + " " +QString::number(i+1))); } } else { for(i = Num; i < NumProps; i++) { Props.removeLast(); Props.removeLast(); } } // adjust property names Property * p1 = Props.at(2); for(i = 1; i <= Num; i++) { p1->Name = "I"+QString::number(i); p1 = Props.next(); p1->Name = "Q"+QString::number(i); p1 = Props.next(); } // draw symbol int h = (PortDistance/2)*((Num-1)) + PortDistance/2; // total component half-height Lines.append(new Line(-15, -h, 15, -h,QPen(Qt::darkBlue,2))); // top side Lines.append(new Line( 15, -h, 15, h,QPen(Qt::darkBlue,2))); // right side Lines.append(new Line(-15, h, 15, h,QPen(Qt::darkBlue,2))); // bottom side Lines.append(new Line(-15, -h,-15, h,QPen(Qt::darkBlue,2))); // left side i=0; int y = PortDistance/2-h, yh; // y is the actual vertical center while(i<Num) { // for every branch i++; // left connection with port Lines.append(new Line(-30, y,-15, y,QPen(Qt::darkBlue,2))); Ports.append(new Port(-30, y)); // small black arrow inside the box Lines.append(new Line( 7,y-3, 10, y,QPen(Qt::black,1))); Lines.append(new Line( 7,y+3, 10, y,QPen(Qt::black,1))); Lines.append(new Line(-10, y, 10, y,QPen(Qt::black,1))); if (i > 1) { yh = y-PortDistance/2; // bottom of the branch box // draw horizontal separation between boxes Lines.append(new Line(-15, yh, 15, yh, QPen(Qt::darkBlue,2))); } // right connection with port Lines.append(new Line( 15, y, 30, y,QPen(Qt::darkBlue,2))); Ports.append(new Port( 30, y)); // add branch number near the right connection port Texts.append(new Text(25,y-fHeight-2,QString::number(i))); // left-aligned // move the vertical center down for the next branch y += PortDistance; } x1 = -30; y1 = -h-2; x2 = 30; y2 = h+2; // compute component name text position - normal size font QFontMetrics metrics(QucsSettings.font, 0); // use the screen-compatible metric tx = x1+4; ty = y1 - 2*metrics.lineSpacing() - 4; }