Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members Related Pages Search
glpolargraph.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "glpolargraph.h"
00019
00020 #include <cmath>
00021
00022 #include "fungparser.h"
00023 #include "sphericalcoord.h"
00024 #include "cartesian3dcoord.h"
00025 #include "fungmath.h"
00026
00027 GLPolarGraph::GLPolarGraph(QWidget *parent, const char *name) : GLExpressionGraph(parent,name)
00028 {
00029 tMin = 0.0f;
00030 tMax = 6.30f;
00031
00032 aMin = 0.0f;
00033 aMax = 6.30f;
00034 }
00035
00036 GLPolarGraph::~GLPolarGraph()
00037 {
00038 }
00039
00040 void GLPolarGraph::load_key( const char *key, const char *value )
00041 {
00042 GLExpressionGraph::load_key(key,value);
00043
00044 if (strcmp(key,"aMin=") == 0)
00045 {
00046 setAzimuthalMin(QString(value).toDouble());
00047 }
00048 else if (strcmp(key,"aMax=") == 0)
00049 {
00050 setAzimuthalMax(QString(value).toDouble());
00051 }
00052 else if (strcmp(key,"tMin=") == 0)
00053 {
00054 setPolarMin(QString(value).toDouble());
00055 }
00056 else if (strcmp(key,"tMax=") == 0)
00057 {
00058 setPolarMax(QString(value).toDouble());
00059 }
00060 }
00061
00062 int GLPolarGraph::setPolarMin(GLfloat d)
00063 {
00064 if (d < tMax)
00065 {
00066 tMin = d;
00067 recompileLists();
00068 updateGL();
00069 return 0;
00070 }
00071 else
00072 return 1;
00073 }
00074
00075 int GLPolarGraph::setPolarMax(GLfloat d)
00076 {
00077 if (d > tMin)
00078 {
00079 tMax = d;
00080 recompileLists();
00081 updateGL();
00082 return 0;
00083 }
00084 else
00085 return 1;
00086 }
00087
00088 int GLPolarGraph::setAzimuthalMin(GLfloat d)
00089 {
00090 if (d < aMax)
00091 {
00092 aMin = d;
00093 recompileLists();
00094 updateGL();
00095 return 0;
00096 }
00097 else
00098 return 1;
00099 }
00100
00101 int GLPolarGraph::setAzimuthalMax(GLfloat d)
00102 {
00103 if (d > aMin)
00104 {
00105 aMax = d;
00106 recompileLists();
00107 updateGL();
00108 return 0;
00109 }
00110 else
00111 return 1;
00112 }
00113
00114 void GLPolarGraph::trace(GLfloat _a, GLfloat _p, FungParser &parser, GLfloat *x, GLfloat *y, GLfloat *z)
00115 {
00116 double d[] = {_a,_p,animatorValue()};
00117 GLfloat _r = parser.Eval(d);
00118
00119 SphericalCoord s(_a,_p,_r);
00120 Cartesian3DCoord c = s.toCartesianCoord();
00121
00122 emit activeCoordinateChanged(QString("azimuthal = %1").arg(_a),QString("polar = %1").arg(_p),QString("radial = %1").arg(_r));
00123
00124 *x = c.x();
00125 *y = c.y();
00126 *z = c.z();
00127 }
00128
00129 std::vector< std::vector<Cartesian3DCoord> > GLPolarGraph::getValues( FungParser &fp, GLfloat *min, GLfloat *max )
00130 {
00131 qDebug("GLPolarGraph::getValues()");
00132 Cartesian3DCoord2DVector values;
00133
00134 GLfloat azimuthal, polar, radial, current_min = 0.0, current_max = 0.0;
00135 int x_index, y_index;
00136 for (azimuthal = aMin, x_index=0; azimuthal < aMax - xScale; azimuthal+=xScale, x_index++)
00137 {
00138 values.push_back( std::vector<Cartesian3DCoord>() );
00139 for (polar = tMin, y_index=0; polar < tMax - yScale; polar+=yScale, y_index++)
00140 {
00141 double d1[] = {azimuthal,polar,animatorValue()};
00142 radial = fp.Eval(d1);
00143
00144 SphericalCoord v1(azimuthal,polar,radial);
00145
00146 float z = v1.toCartesianCoord().z();
00147
00148 current_min = MIN(current_min,z);
00149 current_max = MAX(current_max,z);
00150
00151 values[x_index].push_back( v1.toCartesianCoord() );
00152 }
00153 }
00154
00155 if ( min != 0 )
00156 *min = current_min;
00157 if ( max != 0 )
00158 *max = current_max;
00159
00160 return values;
00161 }
00162
00163
00164
00165
00166
|