Qucs-GUI
0.0.19
|
00001 /*************************************************************************** 00002 psdiagram.cpp - description 00003 ------------------- 00004 begin : Sat Nov 06 2004 00005 copyright : (C) 2004 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 00023 #if HAVE_CONFIG_H 00024 # include <config.h> 00025 #endif 00026 #include <cmath> 00027 #include <float.h> 00028 #if HAVE_IEEEFP_H 00029 # include <ieeefp.h> 00030 #endif 00031 00032 #include "psdiagram.h" 00033 00034 // mixed polar and smith diagram 00035 PSDiagram::PSDiagram(int _cx, int _cy, bool _polarUp) 00036 : Diagram(_cx, _cy) 00037 { 00038 x1 = 10; // position of label text 00039 y1 = y3 = 2; 00040 x2 = 200; // initial size of diagram 00041 x3 = 207; 00042 y2 = 200; 00043 if(_polarUp) Name = "PS"; // polar diagram upper half ? 00044 else Name = "SP"; 00045 00046 Arcs.append(new struct Arc(0, y2, x2, y2, 0, 16*360, QPen(Qt::black,0))); 00047 // calcDiagram(); 00048 } 00049 00050 PSDiagram::~PSDiagram() 00051 { 00052 } 00053 00054 // ------------------------------------------------------------ 00055 void PSDiagram::calcCoordinate(const double*, const double* yD, const double*, 00056 float *px, float *py, Axis const*pa) const 00057 { 00058 double yr = yD[0]; 00059 double yi = yD[1]; 00060 *px = float((yr/pa->up + 1.0)*double(x2)/2.0); 00061 *py = float((yi/pa->up + 1.0)*double(y2)/2.0); 00062 00063 if(std::isfinite(*px)) 00064 if(std::isfinite(*py)) 00065 return; 00066 00067 *px = *py = float(cx) / 2.0; 00068 } 00069 00070 // -------------------------------------------------------------- 00071 void PSDiagram::calcLimits() 00072 { 00073 int i; 00074 double a, b; 00075 Axis *polarAxis, *smithAxis; 00076 00077 if(Name == "PS") { 00078 smithAxis = &yAxis; 00079 polarAxis = &zAxis; 00080 } 00081 else { 00082 polarAxis = &yAxis; 00083 smithAxis = &zAxis; 00084 } 00085 00086 calcSmithAxisScale(smithAxis, i, i); 00087 smithAxis->limit_min = 0.0; 00088 smithAxis->step = double(i); 00089 smithAxis->limit_max = smithAxis->up; 00090 00091 calcPolarAxisScale(polarAxis, a, polarAxis->step, b); 00092 polarAxis->limit_min = 0.0; 00093 polarAxis->limit_max = polarAxis->up; 00094 00095 } 00096 00097 // -------------------------------------------------------------- 00098 int PSDiagram::calcDiagram() 00099 { 00100 Lines.clear(); 00101 Texts.clear(); 00102 Arcs.clear(); 00103 00104 x3 = x2 + 7; 00105 if(Name == "PS") { // if polar not in upper half -> mirror 00106 createSmithChart(&yAxis, 5); 00107 createPolarDiagram(&zAxis, 1); 00108 } 00109 else { 00110 createSmithChart(&zAxis, 3); 00111 createPolarDiagram(&yAxis, 2); 00112 } 00113 00114 // x line 00115 Lines.append(new Line(0, y2>>1, x2, y2>>1, GridPen)); 00116 return 3; 00117 } 00118 00119 // ------------------------------------------------------------ 00120 Diagram* PSDiagram::newOne() 00121 { 00122 return new PSDiagram(); 00123 } 00124 00125 // ------------------------------------------------------------ 00126 Element* PSDiagram::info(QString& Name, char* &BitmapFile, bool getNewOne) 00127 { 00128 Name = QObject::tr("Polar-Smith Combi"); 00129 BitmapFile = (char *) "polarsmith"; 00130 00131 if(getNewOne) return new PSDiagram(); 00132 return 0; 00133 } 00134 00135 // ------------------------------------------------------------ 00136 Element* PSDiagram::info_sp(QString& Name, char* &BitmapFile, bool getNewOne) 00137 { 00138 Name = QObject::tr("Smith-Polar Combi"); 00139 BitmapFile = (char *) "smithpolar"; 00140 00141 if(getNewOne) return new PSDiagram(0, 0, false); 00142 return 0; 00143 }