Qucs-GUI
0.0.18
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
qucs
diagrams
smithdiagram.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
smithdiagram.cpp - description
3
-------------------
4
begin : Sat Oct 18 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
#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 "
smithdiagram.h
"
29
#include "
main.h
"
30
31
32
SmithDiagram::SmithDiagram
(
int
_cx,
int
_cy,
bool
ImpMode) :
Diagram
(_cx, _cy)
33
{
34
x1
= 10;
// position of label text
35
y1
= 2;
36
x2
= 200;
// initial size of diagram
37
y2
= 200;
38
y3
= 0;
39
x3
= 207;
// with some distance for right axes text
40
if
(ImpMode)
Name
=
"Smith"
;
// with impedance circles
41
else
Name
=
"ySmith"
;
// with admittance circles
42
43
Arcs
.append(
new
struct
Arc
(0,
y2
,
x2
,
y2
, 0, 16*360, QPen(Qt::black,0)));
44
// calcDiagram(); // calculate circles for smith chart with |r|=1
45
}
46
47
SmithDiagram::~SmithDiagram
()
48
{
49
}
50
51
// ------------------------------------------------------------
52
// calculate the screen coordinates for the graph data
53
void
SmithDiagram::calcCoordinate
(
double
* &,
double
* &yD,
double
* &,
54
float
*px,
float
*py,
Axis
*)
55
{
56
double
yr = *(yD++);
57
double
yi = *(yD++);
58
*px = float((yr/
yAxis
.
up
+ 1.0)*
double
(
x2
)/2.0);
59
*py = float((yi/
yAxis
.
up
+ 1.0)*
double
(
y2
)/2.0);
60
61
if
(isfinite(*px))
62
if
(isfinite(*py))
63
return
;
64
65
*px = *py = float(
cx
) / 2.0;
66
}
67
68
// ------------------------------------------------------------
69
void
SmithDiagram::calcLimits
()
70
{
71
int
a;
72
calcSmithAxisScale
(&
yAxis
, a, a);
73
yAxis
.
limit_min
= 0.0;
74
yAxis
.
step
= double(a);
75
yAxis
.
limit_max
=
yAxis
.
up
;
76
}
77
78
// ------------------------------------------------------------
79
// calculate the circles and arcs of the smith chart
80
int
SmithDiagram::calcDiagram
()
81
{
82
Lines
.clear();
83
Texts
.clear();
84
Arcs
.clear();
85
86
x3
=
x2
+ 7;
87
if
(
Name
.at(0) ==
'y'
)
createSmithChart
(&
yAxis
, 6);
88
else
createSmithChart
(&
yAxis
);
89
90
// outer most circle
91
Arcs
.append(
new
Arc
(0,
x2
,
x2
,
x2
, 0, 16*360, QPen(Qt::black,0)));
92
93
// horizontal line Im(r)=0
94
Lines
.append(
new
Line
(0,
x2
>>1,
x2
,
x2
>>1,
GridPen
));
95
96
return
3;
97
}
98
99
// ------------------------------------------------------------
100
Diagram
*
SmithDiagram::newOne
()
101
{
102
return
new
SmithDiagram
();
103
}
104
105
// ------------------------------------------------------------
106
Element
*
SmithDiagram::info
(QString& Name,
char
* &BitmapFile,
bool
getNewOne)
107
{
108
Name = QObject::tr(
"Smith Chart"
);
109
BitmapFile = (
char
*)
"smith"
;
110
111
if
(getNewOne)
return
new
SmithDiagram
();
112
return
0;
113
}
114
115
// ------------------------------------------------------------
116
Element
*
SmithDiagram::info_y
(QString& Name,
char
* &BitmapFile,
bool
getNewOne)
117
{
118
Name = QObject::tr(
"Admittance Smith"
);
119
BitmapFile = (
char
*)
"ysmith"
;
120
121
if
(getNewOne)
return
new
SmithDiagram
(0, 0,
false
);
122
return
0;
123
}
smithdiagram.h
Arc
Definition:
element.h:55
Element::y1
int y1
Definition:
element.h:153
Diagram::Name
QString Name
Definition:
diagram.h:92
Element::y2
int y2
Definition:
element.h:153
Element::x1
int x1
Definition:
element.h:153
SmithDiagram::SmithDiagram
SmithDiagram(int _cx=0, int _cy=0, bool ImpMode=true)
Definition:
smithdiagram.cpp:32
SmithDiagram::calcCoordinate
void calcCoordinate(double *&, double *&, double *&, float *, float *, Axis *)
Definition:
smithdiagram.cpp:53
Axis::limit_min
double limit_min
Definition:
diagram.h:56
main.h
Definitions and declarations for the main application.
Element::cx
int cx
Definition:
element.h:153
Diagram::GridPen
QPen GridPen
Definition:
diagram.h:93
SmithDiagram::info_y
static Element * info_y(QString &, char *&, bool getNewOne=false)
Definition:
smithdiagram.cpp:116
SmithDiagram::info
static Element * info(QString &, char *&, bool getNewOne=false)
Definition:
smithdiagram.cpp:106
Diagram::createSmithChart
void createSmithChart(Axis *, int Mode=7)
Definition:
diagram.cpp:1415
Diagram::Arcs
Q3PtrList< struct Arc > Arcs
Definition:
diagram.h:96
Axis
Definition:
diagram.h:47
SmithDiagram::~SmithDiagram
~SmithDiagram()
Definition:
smithdiagram.cpp:47
Diagram::x3
int x3
Definition:
diagram.h:100
Line
Definition:
element.h:48
Element
Superclass of all schematic drawing elements.
Definition:
element.h:142
SmithDiagram::newOne
Diagram * newOne()
Definition:
smithdiagram.cpp:100
Axis::limit_max
double limit_max
Definition:
diagram.h:56
Diagram::y3
int y3
Definition:
diagram.h:100
Diagram::Texts
Q3PtrList< Text > Texts
Definition:
diagram.h:98
SmithDiagram::calcLimits
void calcLimits()
Definition:
smithdiagram.cpp:69
Diagram
Definition:
diagram.h:60
Diagram::yAxis
Axis yAxis
Definition:
diagram.h:101
Axis::step
double step
Definition:
diagram.h:56
Diagram::calcSmithAxisScale
void calcSmithAxisScale(Axis *, int &, int &)
Definition:
diagram.cpp:1395
SmithDiagram::calcDiagram
int calcDiagram()
Definition:
smithdiagram.cpp:80
Axis::up
double up
Definition:
diagram.h:49
Element::x2
int x2
Definition:
element.h:153
Diagram::Lines
Q3PtrList< Line > Lines
Definition:
diagram.h:97
Generated on Mon Sep 1 2014 20:05:20 for Qucs-GUI by
1.8.6