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  

mathfunctionimplementor.cpp

00001 /***************************************************************************
00002                           mathfunctionimplementor.cpp  -  description
00003                              -------------------
00004     begin                : Thu Feb 27 2003
00005     copyright            : (C) 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 "mathfunctionimplementor.h"
00019 
00020 #include "mathfunction.h"
00021 
00022 MathFunctionImplementor::MathFunctionImplementor()
00023 {
00024 }
00025 
00026 
00027 MathFunctionImplementor::~MathFunctionImplementor()
00028 {
00029     for (MathFunctionMap::const_iterator it = math_functions.begin(); it != math_functions.end(); it++)
00030         delete it->second;
00031 }
00032 
00033 void MathFunctionImplementor::addMathFunction( MathFunction *function, const char * id )
00034 {
00035     math_functions.insert( math_functions.end(), MathFunctionPair(id,function) );
00036 }
00037 
00038 MathFunction * MathFunctionImplementor::getMathFunction( const char * id )
00039 {
00040 /*  MathFunctionMap::const_iterator pair = math_functions.find(id);
00041     if (pair != math_functions.end())
00042         return pair->second;
00043     else
00044         return 0;
00045 */
00046     for (MathFunctionMap::const_iterator it = math_functions.begin(); it != math_functions.end(); it++)
00047     {
00048         if ( it->first == id ) 
00049             return it->second;
00050     }
00051 
00052     return 0;
00053 }
00054 
00055 void MathFunctionImplementor::cancelMathFunctions()
00056 {
00057     for (MathFunctionMap::const_iterator it = math_functions.begin(); it != math_functions.end(); it++)
00058         if (it->second->active()){it->second->cancel();}
00059 }
00060 
00061 void MathFunctionImplementor::drawMathFunctions(QPainter *p)
00062 {
00063     for (MathFunctionMap::const_iterator it = math_functions.begin(); it != math_functions.end(); it++)
00064         if (it->second->active()){it->second->drawFunction(p);}
00065 }
00066 
00067 void MathFunctionImplementor::mathFunctionClick(QMouseEvent *e, double x, double y)
00068 {
00069     for (MathFunctionMap::const_iterator it = math_functions.begin(); it != math_functions.end(); it++)
00070         if (it->second->active()){sendCustomClick(e,it->second,x,y);}
00071 
00072 }
00073 
00074 void MathFunctionImplementor::sendCustomClick(QMouseEvent *e, MathFunction *m, double x, double y)
00075 {
00076     m->sendClick(e,x,y);
00077 }
00078 
00079