SeriesList.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: SeriesList.hpp 1644 2009-01-27 19:26:14Z ckiesch $"
00002 
00005 
00006 //============================================================================
00007 //
00008 //  This file is part of GPSTk, the GPS Toolkit.
00009 //
00010 //  The GPSTk is free software; you can redistribute it and/or modify
00011 //  it under the terms of the GNU Lesser General Public License as published
00012 //  by the Free Software Foundation; either version 2.1 of the License, or
00013 //  any later version.
00014 //
00015 //  The GPSTk is distributed in the hope that it will be useful,
00016 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 //  GNU Lesser General Public License for more details.
00019 //
00020 //  You should have received a copy of the GNU Lesser General Public
00021 //  License along with GPSTk; if not, write to the Free Software Foundation,
00022 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 //  
00024 //  Copyright 2004, The University of Texas at Austin
00025 //
00026 //============================================================================
00027 
00028 #ifndef VPLOT_SERIESLIST_H
00029 #define VPLOT_SERIESLIST_H
00030 
00031 #include <string>
00032 #include <vector>
00033 #include <cfloat>
00034 
00035 #include "Frame.hpp"
00036 #include "StrokeStyle.hpp"
00037 #include "Marker.hpp"
00038 #include "Text.hpp"
00039 #include "TextStyle.hpp"
00040 #include "Color.hpp"
00041 #include "Line.hpp"
00042 #include "GridLayout.hpp"
00043 
00044 using namespace std;
00045 using namespace vdraw;
00046 
00047 namespace vplot
00048 {
00054   class SeriesList
00055   {
00056     public:
00060       SeriesList() 
00061       {
00062       }
00063 
00065       ~SeriesList()
00066       {
00067       }
00068 
00074       void addSeries(std::string& title, vector< pair<double,double> >& points, StrokeStyle& ss)
00075       {
00076         Marker m = Marker::clear();
00077         addSeries(title,points,ss,m);
00078       }
00079 
00085       void addSeries(std::string& title, vector< pair<double,double> >& points, Marker& m)
00086       {
00087         StrokeStyle ss = StrokeStyle::clear();
00088         addSeries(title,points,ss,m);
00089       }
00090 
00097       void addSeries(std::string& title, vector< pair<double,double> >& points, StrokeStyle& ss, Marker& m)
00098       {
00099         titles.push_back(title);
00100         pointlists.push_back(points);
00101         styles.push_back(ss);
00102         markers.push_back(m);
00103       }
00104 
00106       bool setLastTitle(std::string& newtitle)
00107       {
00108         return setTitle(titles.size()-1,newtitle);
00109       }
00110 
00112       bool setTitle(unsigned int idx, std::string& newtitle)
00113       {
00114         if(idx>=titles.size())
00115           return false;          
00116         titles[idx]=newtitle;
00117         return true;
00118       }
00119 
00121       bool setLastStyle(StrokeStyle& ss)
00122       {
00123         return setStyle(styles.size()-1,ss);
00124       }
00125 
00127       bool setStyle(unsigned int idx, StrokeStyle& ss)
00128       {
00129         if(idx>=styles.size())
00130           return false; 
00131         styles[idx]=ss;
00132         return true;
00133       }
00134 
00136       bool setLastMarker(Marker& m)
00137       {
00138         return setMarker(markers.size()-1,m);
00139       }
00140 
00142       bool setMarker(unsigned int idx, Marker& m)
00143       {
00144         if(idx>=styles.size())
00145           return false; 
00146         markers[idx]=m;
00147         return true;
00148       }
00149 
00151       int getNumSeries() { return pointlists.size(); }
00152 
00154       std::string getTitle(int idx) { return titles[idx]; }
00155 
00157       StrokeStyle getStyle(int idx) { return styles[idx]; }
00158 
00160       Marker getMarker(int idx)     { return markers[idx]; }
00161 
00163       vector< pair<double,double> >& getPointList(int idx) { return pointlists[idx]; }
00164 
00166       void findMinMax(double& minX, double &maxX, double& minY, double& maxY);
00167 
00169       void drawInFrame(Frame& innerFrame, double minX, double maxX, double minY, double maxY);
00170 
00177       void drawLegend(Frame& frame, double pointsize, unsigned int columns = 1);
00178 
00179     protected:
00180 
00181 
00182     private:
00184       vector< string > titles;
00185 
00187       vector< vector< pair<double,double> > > pointlists;
00188 
00190       vector< StrokeStyle > styles;
00191 
00193       vector< Marker > markers;
00194 
00196       struct map_object
00197       {
00198         double multX,minX,multY,minY;
00199         map_object(double multX,double minX,double multY,double minY)
00200         {
00201           this->multX = multX;
00202           this->minX = minX;
00203           this->multY = multY;
00204           this->minY = minY;
00205         }
00206         void operator() (Point& p)
00207         {
00208           p.x() = multX*(p.x()-minX);
00209           p.y() = multY*(p.y()-minY);
00210         }
00211       };
00212 
00214       void drawLegendSegment(Frame& frame, double pointsize, 
00215           unsigned int begin, unsigned int n);
00216 
00217   };
00218 
00219 }
00220 
00221 #endif

Generated on Tue May 22 03:31:01 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1