Qucs-GUI
0.0.19
|
00001 /*************************************************************************** 00002 symtrafo.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 00018 #include "main.h" 00019 #include "symtrafo.h" 00020 00021 #include<QFontMetrics> 00022 00023 00024 symTrafo::symTrafo() 00025 { 00026 Description = QObject::tr("ideal symmetrical transformer"); 00027 00028 QFont Font(QucsSettings.font); // default application font 00029 // symbol text is smaller (10 pt default) 00030 Font.setPointSize(10); 00031 // get the small font size; use the screen-compatible metric 00032 QFontMetrics smallmetrics(Font, 0); 00033 00034 int w; 00035 QString stmp; 00036 00037 Arcs.append(new Arc(-16,-58,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); 00038 Arcs.append(new Arc(-16,-46,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); 00039 Arcs.append(new Arc(-16,-34,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); 00040 Arcs.append(new Arc(-16, 46,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); 00041 Arcs.append(new Arc(-16, 34,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); 00042 Arcs.append(new Arc(-16, 22,12,12, 16*270,16*180, QPen(Qt::darkBlue,2))); 00043 Arcs.append(new Arc( 4,-18,12,12, 16*90,16*180, QPen(Qt::darkBlue,2))); 00044 Arcs.append(new Arc( 4, -6,12,12, 16*90,16*180, QPen(Qt::darkBlue,2))); 00045 Arcs.append(new Arc( 4, 6,12,12, 16*90,16*180, QPen(Qt::darkBlue,2))); 00046 Lines.append(new Line(-10,-58,-10,-70,QPen(Qt::darkBlue,2))); 00047 Lines.append(new Line(-10,-70,-30,-70,QPen(Qt::darkBlue,2))); 00048 Lines.append(new Line( 10,-18, 10,-30,QPen(Qt::darkBlue,2))); 00049 Lines.append(new Line( 10,-30, 30,-30,QPen(Qt::darkBlue,2))); 00050 Lines.append(new Line(-10, 58,-10, 70,QPen(Qt::darkBlue,2))); 00051 Lines.append(new Line(-10, 70,-30, 70,QPen(Qt::darkBlue,2))); 00052 Lines.append(new Line( 10, 18, 10, 30,QPen(Qt::darkBlue,2))); 00053 Lines.append(new Line( 10, 30, 30, 30,QPen(Qt::darkBlue,2))); 00054 Lines.append(new Line(-10,-10,-30,-10,QPen(Qt::darkBlue,2))); 00055 Lines.append(new Line(-10,-22,-10,-10,QPen(Qt::darkBlue,2))); 00056 Lines.append(new Line(-10, 10,-30, 10,QPen(Qt::darkBlue,2))); 00057 Lines.append(new Line(-10, 10,-10, 22,QPen(Qt::darkBlue,2))); 00058 00059 // core lines 00060 Lines.append(new Line( -1,-57, -1, 57,QPen(Qt::darkBlue,1))); 00061 Lines.append(new Line( 1,-57, 1, 57,QPen(Qt::darkBlue,1))); 00062 00063 stmp = "T1"; w = smallmetrics.width(stmp); // compute width to right-align 00064 Texts.append(new Text(-13-w,-57,stmp)); 00065 stmp = "T2"; w = smallmetrics.width(stmp); // compute width to right-align 00066 Texts.append(new Text(-13-w, 22,stmp)); 00067 00068 // mark the turn direction 00069 Arcs.append(new Arc(-21,-64, 5, 5, 0, 16*360,QPen(Qt::darkBlue,2))); 00070 Arcs.append(new Arc(-21, 15, 5, 5, 0, 16*360,QPen(Qt::darkBlue,2))); 00071 Arcs.append(new Arc( 15,-24, 5, 5, 0, 16*360,QPen(Qt::darkBlue,2))); 00072 00073 Ports.append(new Port(-30,-70)); 00074 Ports.append(new Port( 30,-30)); 00075 Ports.append(new Port( 30, 30)); 00076 Ports.append(new Port(-30, 70)); 00077 Ports.append(new Port(-30, 10)); 00078 Ports.append(new Port(-30,-10)); 00079 00080 x1 = -33; y1 = -74; 00081 x2 = 33; y2 = 74; 00082 00083 tx = x1+4; 00084 ty = y2+4; 00085 Model = "sTr"; 00086 Name = "Tr"; 00087 00088 Props.append(new Property("T1", "1", true, 00089 QObject::tr("voltage transformation ratio of coil 1"))); 00090 Props.append(new Property("T2", "1", true, 00091 QObject::tr("voltage transformation ratio of coil 2"))); 00092 } 00093 00094 symTrafo::~symTrafo() 00095 { 00096 } 00097 00098 Component* symTrafo::newOne() 00099 { 00100 return new symTrafo(); 00101 } 00102 00103 Element* symTrafo::info(QString& Name, char* &BitmapFile, bool getNewOne) 00104 { 00105 Name = QObject::tr("symmetric Transformer"); 00106 BitmapFile = (char *) "symtrans"; 00107 00108 if(getNewOne) return new symTrafo(); 00109 return 0; 00110 }