File indexing completed on 2023-10-03 06:50:25
0001 /************************************************************************************* 0002 * Copyright (C) 2007-2009 by Aleix Pol <aleixpol@kde.org> * 0003 * Copyright (C) 2010-2012 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com> * 0004 * * 0005 * This program is free software; you can redistribute it and/or * 0006 * modify it under the terms of the GNU General Public License * 0007 * as published by the Free Software Foundation; either version 2 * 0008 * of the License, or (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the Free Software * 0017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 0018 *************************************************************************************/ 0019 0020 0021 #include "planecurve.h" 0022 0023 #include "private/abstractplanecurve.h" 0024 #include "private/functiongraphfactory.h" 0025 0026 using namespace Analitza; 0027 0028 PlaneCurve::PlaneCurve(AbstractFunctionGraph* g ) 0029 : FunctionGraph(g) 0030 {} 0031 0032 PlaneCurve::~PlaneCurve() 0033 {} 0034 0035 const QVector<QPointF> & PlaneCurve::points() const 0036 { 0037 Q_ASSERT(backend()); 0038 return static_cast<AbstractPlaneCurve*>(backend())->points; 0039 } 0040 0041 QVector< int > PlaneCurve::jumps() const 0042 { 0043 Q_ASSERT(backend()); 0044 return static_cast<AbstractPlaneCurve*>(backend())->jumps; 0045 } 0046 0047 void PlaneCurve::update(const QRectF& viewport) 0048 { 0049 AbstractPlaneCurve* b = static_cast<AbstractPlaneCurve*>(backend()); 0050 Q_ASSERT(b); 0051 0052 //If we already have an interval and it's already calculated 0053 //we don't need to do it again 0054 if(b->hasIntervals() && !b->points.isEmpty()) 0055 return; 0056 0057 b->update(viewport); 0058 } 0059 0060 QPair< QPointF, QString > PlaneCurve::image(const QPointF &mousepos) 0061 { 0062 Q_ASSERT(backend()); 0063 return static_cast<AbstractPlaneCurve*>(backend())->image(mousepos); 0064 } 0065 0066 QLineF PlaneCurve::tangent(const QPointF &mousepos) 0067 { 0068 Q_ASSERT(backend()); 0069 return static_cast<AbstractPlaneCurve*>(backend())->tangent(mousepos); 0070 }