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  

expression.cpp

00001 /***************************************************************************
00002                           expression.cpp  -  description
00003                              -------------------
00004     begin                : Wed Oct 9 2002
00005     copyright            : (C) 2002-2003 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 "expression.h"
00019 
00020 #include "fungparser.h"
00021 
00022 Expression::Expression(const Expression &e) :
00023     show(e.show),
00024     color(e.color),
00025     #ifdef GLGRAPH
00026     name(e.name),
00027     #endif //GLGRAPH
00028     deleteable(false),
00029     expression1(e.expression1),
00030     expression2(e.expression2),
00031     parsedExpression(e.parsedExpression),
00032     parsedExpression2(e.parsedExpression2)
00033 {}
00034 
00035 Expression::Expression(const char * _expression, bool _show, QColor _color) :
00036     show(_show), color(_color),
00037     deleteable(false),
00038     expression1(_expression),
00039     parsedExpression(0),
00040     parsedExpression2(0)
00041 {}
00042 
00043 Expression::Expression(const char * _expression2, const char * _expression1, bool _show, QColor _color) :
00044     show(_show),
00045     color(_color),  
00046     deleteable(false),
00047     expression1(_expression1), 
00048     expression2(_expression2),
00049     parsedExpression(0),
00050     parsedExpression2(0)
00051 {}
00052 
00053 #ifdef GLGRAPH
00054 Expression::Expression(std::string & expression, bool _show, QColor _color, GLuint _name) :
00055     show(_show),
00056     color(_color),
00057     name(_name),    
00058     deleteable(true),
00059     expression1(expression),
00060     parsedExpression(0),
00061     parsedExpression2(0)
00062 {}
00063 #endif //GLGRAPH
00064 
00065 Expression::~Expression()
00066 {
00067 
00068     if (deleteable)
00069     {
00070         if (parsedExpression)
00071             delete parsedExpression;
00072         if (parsedExpression2)
00073             delete parsedExpression2;
00074     }
00075 
00076 }
00077 
00078 std::string Expression::getExpression (const char * functionName) const
00079 {
00080     if ( functionName[0] == 'x' )
00081         return expression2;
00082     else
00083         return expression1;
00084 }
00085 
00086 void Expression::setParsedExpression( FungParser * fp, const char * functionName )
00087 {
00088     if ( functionName[0] == 'x' )
00089         parsedExpression2=fp;
00090     else
00091         parsedExpression=fp;
00092 }
00093 
00094 FungParser * Expression::getParsedExpression( const char * functionName ) const
00095 {
00096     if ( functionName[0] == 'x' )
00097         return parsedExpression2;
00098     else
00099         return parsedExpression;
00100 }
00101