Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
psdiagram.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  psdiagram.cpp - description
3  -------------------
4  begin : Sat Nov 06 2004
5  copyright : (C) 2004 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 #if HAVE_CONFIG_H
19 # include <config.h>
20 #endif
21 #include <QtGui>
22 #include <math.h>
23 #include <float.h>
24 #if HAVE_IEEEFP_H
25 # include <ieeefp.h>
26 #endif
27 
28 #include "psdiagram.h"
29 #include "main.h"
30 
31 // mixed polar and smith diagram
32 PSDiagram::PSDiagram(int _cx, int _cy, bool _polarUp)
33  : Diagram(_cx, _cy)
34 {
35  x1 = 10; // position of label text
36  y1 = y3 = 2;
37  x2 = 200; // initial size of diagram
38  x3 = 207;
39  y2 = 200;
40  if(_polarUp) Name = "PS"; // polar diagram upper half ?
41  else Name = "SP";
42 
43  Arcs.append(new struct Arc(0, y2, x2, y2, 0, 16*360, QPen(Qt::black,0)));
44 // calcDiagram();
45 }
46 
48 {
49 }
50 
51 // ------------------------------------------------------------
52 void PSDiagram::calcCoordinate(double* &, double* &yD, double* &,
53  float *px, float *py, Axis *pa)
54 {
55  double yr = *(yD++);
56  double yi = *(yD++);
57  *px = float((yr/pa->up + 1.0)*double(x2)/2.0);
58  *py = float((yi/pa->up + 1.0)*double(y2)/2.0);
59 
60  if(isfinite(*px))
61  if(isfinite(*py))
62  return;
63 
64  *px = *py = float(cx) / 2.0;
65 }
66 
67 // --------------------------------------------------------------
69 {
70  int i;
71  double a, b;
72  Axis *polarAxis, *smithAxis;
73 
74  if(Name == "PS") {
75  smithAxis = &yAxis;
76  polarAxis = &zAxis;
77  }
78  else {
79  polarAxis = &yAxis;
80  smithAxis = &zAxis;
81  }
82 
83  calcSmithAxisScale(smithAxis, i, i);
84  smithAxis->limit_min = 0.0;
85  smithAxis->step = double(i);
86  smithAxis->limit_max = smithAxis->up;
87 
88  calcPolarAxisScale(polarAxis, a, polarAxis->step, b);
89  polarAxis->limit_min = 0.0;
90  polarAxis->limit_max = polarAxis->up;
91 
92 }
93 
94 // --------------------------------------------------------------
96 {
97  Lines.clear();
98  Texts.clear();
99  Arcs.clear();
100 
101  x3 = x2 + 7;
102  if(Name == "PS") { // if polar not in upper half -> mirror
103  createSmithChart(&yAxis, 5);
105  }
106  else {
107  createSmithChart(&zAxis, 3);
109  }
110 
111  // x line
112  Lines.append(new Line(0, y2>>1, x2, y2>>1, GridPen));
113  return 3;
114 }
115 
116 // ------------------------------------------------------------
118 {
119  return new PSDiagram();
120 }
121 
122 // ------------------------------------------------------------
123 Element* PSDiagram::info(QString& Name, char* &BitmapFile, bool getNewOne)
124 {
125  Name = QObject::tr("Polar-Smith Combi");
126  BitmapFile = (char *) "polarsmith";
127 
128  if(getNewOne) return new PSDiagram();
129  return 0;
130 }
131 
132 // ------------------------------------------------------------
133 Element* PSDiagram::info_sp(QString& Name, char* &BitmapFile, bool getNewOne)
134 {
135  Name = QObject::tr("Smith-Polar Combi");
136  BitmapFile = (char *) "smithpolar";
137 
138  if(getNewOne) return new PSDiagram(0, 0, false);
139  return 0;
140 }
Definition: element.h:55
int y1
Definition: element.h:153
QString Name
Definition: diagram.h:92
int y2
Definition: element.h:153
int x1
Definition: element.h:153
double limit_min
Definition: diagram.h:56
Definitions and declarations for the main application.
void calcCoordinate(double *&, double *&, double *&, float *, float *, Axis *)
Definition: psdiagram.cpp:52
int calcDiagram()
Definition: psdiagram.cpp:95
static Element * info(QString &, char *&, bool getNewOne=false)
Definition: psdiagram.cpp:123
int cx
Definition: element.h:153
QPen GridPen
Definition: diagram.h:93
PSDiagram(int _cx=0, int _cy=0, bool _polarUp=true)
Definition: psdiagram.cpp:32
Diagram * newOne()
Definition: psdiagram.cpp:117
void createSmithChart(Axis *, int Mode=7)
Definition: diagram.cpp:1415
void createPolarDiagram(Axis *, int Mode=3)
Definition: diagram.cpp:1589
Axis zAxis
Definition: diagram.h:101
Q3PtrList< struct Arc > Arcs
Definition: diagram.h:96
void calcLimits()
Definition: psdiagram.cpp:68
Definition: diagram.h:47
int x3
Definition: diagram.h:100
Definition: element.h:48
Superclass of all schematic drawing elements.
Definition: element.h:142
double limit_max
Definition: diagram.h:56
int y3
Definition: diagram.h:100
Q3PtrList< Text > Texts
Definition: diagram.h:98
Axis yAxis
Definition: diagram.h:101
double step
Definition: diagram.h:56
void calcSmithAxisScale(Axis *, int &, int &)
Definition: diagram.cpp:1395
static Element * info_sp(QString &, char *&, bool getNewOne=false)
Definition: psdiagram.cpp:133
double up
Definition: diagram.h:49
void calcPolarAxisScale(Axis *, double &, double &, double &)
Definition: diagram.cpp:1552
int x2
Definition: element.h:153
Q3PtrList< Line > Lines
Definition: diagram.h:97