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  

scatterplot.cpp

00001 /***************************************************************************
00002                           scatterplot.cpp  -  description
00003                              -------------------
00004     begin                : Sun May 11 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 "scatterplot.h"
00019 
00020 #include <qpainter.h>
00021 
00022 #include "fungmath.h"
00023 #include "statinfo.h"
00024 
00025 ScatterPlot::ScatterPlot(std::vector<double> & xlist, std::vector<double> & ylist, bool show, const QColor & color) :
00026     PlotModule(show,color),
00027     _xlist(xlist),
00028     _ylist(ylist)
00029 {}
00030 
00031 void ScatterPlot::drawPlot( QPainter *painter, int *, StatPlotGraph *graph, double, double )
00032 {
00033     int min = (int)StatInfo::smaller(_xlist.size(),_ylist.size());
00034 
00035     for (int i=0; i<min; i++)
00036     {
00037         painter->drawRect(
00038             toPixelXCoord(graph,_xlist[i])-SCATTERWIDTH/2,
00039             toPixelYCoord(graph,_ylist[i])-SCATTERHEIGHT/2,
00040             SCATTERWIDTH,
00041             SCATTERHEIGHT
00042         );
00043     }
00044 }
00045 
00046 void ScatterPlot::trace( double, double, double *, double * )
00047 {
00048     qDebug("Trace not implemented");
00049 }
00050 
00051 std::string ScatterPlot::updateCoords( double, double )
00052 {
00053     return std::string("");
00054 }
00055 
00056 void ScatterPlot::zoomStat( double *xmin, double *xmax, double *ymin, double *ymax )
00057 {
00058     int points = (int)StatInfo::smaller(_xlist.size(),_ylist.size());
00059     if (points == 0) return;
00060 
00061     double xMin = _xlist[0];
00062     double xMax = _xlist[0];
00063     double yMin = _ylist[0];
00064     double yMax = _ylist[0];
00065 
00066     for (int i=1; i<points; i++)
00067     {
00068         xMin = StatInfo::smaller(xMin,_xlist[i]);
00069         xMax = StatInfo::bigger(xMax,_xlist[i]);
00070         yMin = StatInfo::smaller(yMin,_ylist[i]);
00071         yMax = StatInfo::bigger(yMax,_ylist[i]);
00072     }
00073 
00074     *xmin = xMin-1;
00075     *xmax = xMax+1;
00076     *ymin = yMin-1;
00077     *ymax = yMax+1;
00078 }