Home

Download

Features

Screenshots

Handbook

Browse Source

Authors

SourceForge.net Logo
Hosted by SourceForge.net

OSI Certified


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages   Search  

glcylindricalgraph.cpp

00001 /***************************************************************************
00002                           glcylindricalgraph.cpp  -  description
00003                              -------------------
00004     begin                : Mon Dec 2 2002
00005     copyright            : (C) 2002 by Fungmeista
00006     email                : mizunoami44@users.sourceforge.net
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 
00018 #include "glcylindricalgraph.h"
00019 
00020 #include "fungparser.h"
00021 #include "cartesian3dcoord.h"
00022 #include "cylindricalcoord.h"
00023 #include "fungmath.h"
00024 
00025 GLCylindricalGraph::GLCylindricalGraph(QWidget *parent, const char *name ) : GLExpressionGraph(parent,name),
00026     thetaMin(0.0),
00027     thetaMax(6.0),
00028     radiusMin(0.0),
00029     radiusMax(10.0)
00030 {
00031 }
00032 
00033 GLCylindricalGraph::~GLCylindricalGraph()
00034 {
00035 }
00036 
00037 void GLCylindricalGraph::load_key( const char *key, const char *value )
00038 {
00039     GLExpressionGraph::load_key(key,value);
00040 
00041     if (strcmp(key,"tMin=") == 0)
00042     {
00043         setThetaMin(QString(value).toDouble());
00044     }
00045     else if (strcmp(key,"tMax=") == 0)
00046     {
00047         setThetaMax(QString(value).toDouble());
00048     }
00049     else if (strcmp(key,"rMin=") == 0)
00050     {
00051         setRadiusMin(QString(value).toDouble());
00052     }
00053     else if (strcmp(key,"rMax=") == 0)
00054     {
00055         setRadiusMax(QString(value).toDouble());
00056     }
00057 }
00058 
00059 int GLCylindricalGraph::setThetaMin(double d)
00060 {
00061     if (d < thetaMax)
00062     {
00063         thetaMin = d;
00064         recompileLists();
00065         updateGL();
00066         return 0;
00067     }
00068     else
00069         return 1;
00070 }
00071 
00072 int GLCylindricalGraph::setThetaMax(double d)
00073 {
00074     if (d > thetaMin)
00075     {
00076         thetaMax = d;
00077         recompileLists();
00078         updateGL();
00079         return 0;
00080     }
00081     else
00082         return 1;
00083 }
00084 
00085 int GLCylindricalGraph::setRadiusMin(double d)
00086 {
00087     if (d < radiusMax)
00088     {
00089         radiusMin = d;
00090         recompileLists();
00091         updateGL();
00092         return 0;
00093     }
00094     else
00095         return 1;
00096 }
00097 
00098 int GLCylindricalGraph::setRadiusMax(double d)
00099 {
00100     if (d > radiusMin)
00101     {
00102         radiusMax = d;
00103         recompileLists();
00104         updateGL();
00105         return 0;
00106     }
00107     else
00108         return 1;
00109 }
00110 
00111 void GLCylindricalGraph::trace(GLfloat _r, GLfloat _t, FungParser &parser, GLfloat *x, GLfloat *y, GLfloat *z)
00112 {
00113     double d[] = {_r,_t,animatorValue()};
00114     GLfloat _z = parser.Eval(d);
00115     
00116     CylindricalCoord s(_r,_t,_z);
00117     Cartesian3DCoord c = s.toCartesianCoord();
00118 
00119     emit activeCoordinateChanged(QString("radius = %1").arg(_r),QString("theta = %1").arg(_t),QString("z = %1").arg(_z));
00120 
00121     *x = c.x();
00122     *y = c.y();
00123     *z = c.z();
00124 }
00125 
00126 std::vector< std::vector<Cartesian3DCoord> > GLCylindricalGraph::getValues( FungParser &fp, GLfloat *min, GLfloat *max )
00127 {
00128     qDebug("GLCylindricalGraph::getValues()");
00129     Cartesian3DCoord2DVector values;
00130 
00131     GLfloat radius, theta, z, current_min = 0.0, current_max = 0.0;
00132     int x_index, y_index;
00133     for (radius = radiusMin, x_index=0; radius < radiusMax-xScale; radius+=xScale, x_index++)
00134     {
00135         values.push_back( std::vector<Cartesian3DCoord>() );
00136         for (theta = thetaMin, y_index=0; theta<thetaMax-yScale; theta+=yScale, y_index++)
00137         {
00138             double d[] = {radius,theta,animatorValue()};
00139             z = fp.Eval(d);
00140 
00141             CylindricalCoord v1(radius,theta,z);
00142 
00143             current_min = MIN(current_min,z);
00144             current_max = MAX(current_max,z);
00145 
00146             values[x_index].push_back( Cartesian3DCoord(v1.toCartesianCoord()) );
00147         }
00148     }
00149 
00150     if ( min != 0 )
00151         *min = current_min;
00152     if ( max != 0 )
00153         *max = current_max;
00154 
00155     return values;
00156 }
00157