Qucs-GUI  0.0.19
/home/travis/build/Qucs/qucs/qucs/qucs/diagrams/polardiagram.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           polardiagram.cpp  -  description
00003                              -------------------
00004     begin                : Fri Oct 17 2003
00005     copyright            : (C) 2003 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 "polardiagram.h"
00033 
00034 
00035 PolarDiagram::PolarDiagram(int _cx, int _cy) : Diagram(_cx, _cy)
00036 {
00037   x1 = 10;     // position of label text
00038   y1 = 2;
00039   x2 = 200;    // initial size of diagram
00040   y2 = 200;
00041   x3 = 207;    // with some distance for right axes text
00042   Name = "Polar";
00043 
00044   Arcs.append(new struct Arc(0, y2, x2, y2, 0, 16*360, QPen(Qt::black,0)));
00045 //  calcDiagram();
00046 }
00047 
00048 PolarDiagram::~PolarDiagram()
00049 {
00050 }
00051 
00052 // ------------------------------------------------------------
00053 void PolarDiagram::calcCoordinate(const double*, const double* yD, const double*,
00054           float *px, float *py, Axis const*) const
00055 {
00056   double yr = yD[0];
00057   double yi = yD[1];
00058   *px = float((yr/yAxis.up + 1.0)*double(x2)/2.0);
00059   *py = float((yi/yAxis.up + 1.0)*double(y2)/2.0);
00060 
00061   if(std::isfinite(*px))
00062     if(std::isfinite(*py))
00063       return;
00064 
00065   *px = *py = float(cx) / 2.0;
00066 }
00067 
00068 // --------------------------------------------------------------
00069 void PolarDiagram::calcLimits()
00070 {
00071   double a, b;
00072   calcPolarAxisScale(&yAxis, a, yAxis.step, b);
00073   yAxis.limit_min = 0.0;
00074   yAxis.limit_max = yAxis.up;
00075 }
00076 
00077 // --------------------------------------------------------------
00078 int PolarDiagram::calcDiagram()
00079 {
00080   Lines.clear();
00081   Texts.clear();
00082   Arcs.clear();
00083 
00084   // x line
00085   Lines.append(new Line(0, y2>>1, x2, y2>>1, GridPen));
00086 
00087   x3 = x2 + 7;
00088   createPolarDiagram(&yAxis);
00089   return 3;
00090 }
00091 
00092 // ------------------------------------------------------------
00093 Diagram* PolarDiagram::newOne()
00094 {
00095   return new PolarDiagram();
00096 }
00097 
00098 // ------------------------------------------------------------
00099 Element* PolarDiagram::info(QString& Name, char* &BitmapFile, bool getNewOne)
00100 {
00101   Name = QObject::tr("Polar");
00102   BitmapFile = (char *) "polar";
00103 
00104   if(getNewOne)  return new PolarDiagram();
00105   return 0;
00106 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines