My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
polardiagram.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  polardiagram.cpp - description
3  -------------------
4  begin : Fri Oct 17 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 
22 #include <math.h>
23 #include <float.h>
24 #ifdef __MINGW32__
25 # define finite(x) _finite(x)
26 #endif
27 #if HAVE_IEEEFP_H
28 # include <ieeefp.h>
29 #endif
30 
31 #include "polardiagram.h"
32 #include "main.h"
33 
34 
35 PolarDiagram::PolarDiagram(int _cx, int _cy) : Diagram(_cx, _cy)
36 {
37  x1 = 10; // position of label text
38  y1 = 2;
39  x2 = 200; // initial size of diagram
40  y2 = 200;
41  x3 = 207; // with some distance for right axes text
42  Name = "Polar";
43 
44  Arcs.append(new struct Arc(0, y2, x2, y2, 0, 16*360, QPen(QPen::black,0)));
45 // calcDiagram();
46 }
47 
49 {
50 }
51 
52 // ------------------------------------------------------------
53 void PolarDiagram::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(finite(*px))
62  if(finite(*py))
63  return;
64 
65  *px = *py = float(cx) / 2.0;
66 }
67 
68 // --------------------------------------------------------------
70 {
71  double a, b;
73  yAxis.limit_min = 0.0;
75 }
76 
77 // --------------------------------------------------------------
79 {
80  Lines.clear();
81  Texts.clear();
82  Arcs.clear();
83 
84  // x line
85  Lines.append(new Line(0, y2>>1, x2, y2>>1, GridPen));
86 
87  x3 = x2 + 7;
89  return 3;
90 }
91 
92 // ------------------------------------------------------------
94 {
95  return new PolarDiagram();
96 }
97 
98 // ------------------------------------------------------------
99 Element* PolarDiagram::info(QString& Name, char* &BitmapFile, bool getNewOne)
100 {
101  Name = QObject::tr("Polar");
102  BitmapFile = (char *) "polar";
103 
104  if(getNewOne) return new PolarDiagram();
105  return 0;
106 }