00001 #pragma ident "$Id: SeriesList.hpp 1644 2009-01-27 19:26:14Z ckiesch $"
00002
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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