Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members Related Pages Search
scatterplot.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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 }
|