Qucs-GUI  0.0.18
 All Data Structures 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 #include <QtGui>
22 #include <math.h>
23 #include <float.h>
24 #if HAVE_IEEEFP_H
25 # include <ieeefp.h>
26 #endif
27 
28 #include "polardiagram.h"
29 #include "main.h"
30 
31 
32 PolarDiagram::PolarDiagram(int _cx, int _cy) : 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  x3 = 207; // with some distance for right axes text
39  Name = "Polar";
40 
41  Arcs.append(new struct Arc(0, y2, x2, y2, 0, 16*360, QPen(Qt::black,0)));
42 // calcDiagram();
43 }
44 
46 {
47 }
48 
49 // ------------------------------------------------------------
50 void PolarDiagram::calcCoordinate(double* &, double* &yD, double* &,
51  float *px, float *py, Axis*)
52 {
53  double yr = *(yD++);
54  double yi = *(yD++);
55  *px = float((yr/yAxis.up + 1.0)*double(x2)/2.0);
56  *py = float((yi/yAxis.up + 1.0)*double(y2)/2.0);
57 
58  if(isfinite(*px))
59  if(isfinite(*py))
60  return;
61 
62  *px = *py = float(cx) / 2.0;
63 }
64 
65 // --------------------------------------------------------------
67 {
68  double a, b;
70  yAxis.limit_min = 0.0;
72 }
73 
74 // --------------------------------------------------------------
76 {
77  Lines.clear();
78  Texts.clear();
79  Arcs.clear();
80 
81  // x line
82  Lines.append(new Line(0, y2>>1, x2, y2>>1, GridPen));
83 
84  x3 = x2 + 7;
86  return 3;
87 }
88 
89 // ------------------------------------------------------------
91 {
92  return new PolarDiagram();
93 }
94 
95 // ------------------------------------------------------------
96 Element* PolarDiagram::info(QString& Name, char* &BitmapFile, bool getNewOne)
97 {
98  Name = QObject::tr("Polar");
99  BitmapFile = (char *) "polar";
100 
101  if(getNewOne) return new PolarDiagram();
102  return 0;
103 }
void calcLimits()
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
void calcCoordinate(double *&, double *&, double *&, float *, float *, Axis *)
double limit_min
Definition: diagram.h:56
Definitions and declarations for the main application.
PolarDiagram(int _cx=0, int _cy=0)
int cx
Definition: element.h:153
QPen GridPen
Definition: diagram.h:93
void createPolarDiagram(Axis *, int Mode=3)
Definition: diagram.cpp:1589
Q3PtrList< struct Arc > Arcs
Definition: diagram.h:96
Definition: diagram.h:47
int x3
Definition: diagram.h:100
static Element * info(QString &, char *&, bool getNewOne=false)
Definition: element.h:48
Superclass of all schematic drawing elements.
Definition: element.h:142
double limit_max
Definition: diagram.h:56
Q3PtrList< Text > Texts
Definition: diagram.h:98
Axis yAxis
Definition: diagram.h:101
double step
Definition: diagram.h:56
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
Diagram * newOne()