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  

glfunctiongraph.cpp

00001 /***************************************************************************
00002                           glfunctiongraph.cpp  -  description
00003                              -------------------
00004     begin                : Fri Oct 18 2002
00005     copyright            : (C) 2002-03 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 "glfunctiongraph.h"
00019 
00020 #include "fungparser.h"
00021 #include "fungmath.h"
00022 
00023 GLFunctionGraph::GLFunctionGraph(QWidget *parent, const char *name) : GLExpressionGraph(parent,name)
00024 {
00025 }
00026 
00027 GLFunctionGraph::~GLFunctionGraph()
00028 {
00029 }
00030 
00031 void GLFunctionGraph::trace(GLfloat mouseX, GLfloat mouseY, FungParser &parser, GLfloat *x, GLfloat *y, GLfloat *z)
00032 {
00033     double values[] = {mouseX,mouseY,animatorValue()};
00034     GLfloat _z = parser.Eval(values);
00035 
00036     emit activeCoordinateChanged(QString("x = %1").arg(mouseX),QString("y = %1").arg(mouseY),QString("z = %1").arg(_z));
00037         
00038     *x = mouseX;
00039     *y = mouseY;
00040     *z = _z;
00041 }
00042 
00043 std::vector< std::vector<Cartesian3DCoord> > GLFunctionGraph::getValues( FungParser &fp, GLfloat *min, GLfloat *max )
00044 {
00045     qDebug("GLFunctionGraph::getValues()");
00046     Cartesian3DCoord2DVector values;
00047 
00048     GLfloat x, y, z, current_min = 0.0, current_max = 0.0;
00049     int x_index, y_index;
00050     for (x = getXMin(), x_index = 0; x < getXMax() - xScale; x_index++, x+=xScale)
00051     {
00052         values.push_back( std::vector<Cartesian3DCoord>() );
00053         for (y = getYMin(), y_index = 0; y < getYMax() - yScale; y_index++, y+=yScale)
00054         {
00055             double d[] = {x,y,animatorValue()};
00056             z = fp.Eval(d);
00057             
00058             current_min = MIN(current_min,z);
00059             current_max = MAX(current_max,z);
00060 
00061             values[x_index].push_back( Cartesian3DCoord(x,y,z) );
00062         }
00063     }
00064 
00065     if ( min != 0 )
00066         *min = current_min;
00067     if ( max != 0 )
00068         *max = current_max;
00069 
00070     return values;
00071 }
00072 
00073