00001 #pragma ident "$Id: LinePlot.cpp 3140 2012-06-18 15:03:02Z susancummins $"
00002
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "LinePlot.hpp"
00028
00029 using namespace std;
00030 using namespace vdraw;
00031
00032 namespace vplot
00033 {
00034 void LinePlot::init(unsigned int issidx)
00035 {
00036 Color col [] = {Color::BLUE, Color::ORANGE, Color::GREEN, Color::DARK_PURPLE,
00037 Color::YELLOW, Color::PINK, Color::NAVY, Color::KHAKI, Color::CARDINAL,
00038 Color::CYAN, Color::MAGENTA, Color::BURNT_ORANGE, Color::CHARTREUSE,
00039 Color::FOREST_GREEN, Color::SKY_BLUE, Color::BROWN, Color::VIOLET,
00040 Color::GRAY, Color::TURQUOISE, Color::MAROON};
00041
00042 for (unsigned int c=0; c<sizeof(col)/sizeof(col[0]); c++)
00043 cvec.push_back(col[c]);
00044
00045 StrokeStyle::dashLengthList solid, ldash, sdash;
00046 dvec.push_back(solid);
00047 ldash.push_back(4);
00048 ldash.push_back(2);
00049 dvec.push_back(ldash);
00050 sdash.push_back(2);
00051 sdash.push_back(2);
00052 dvec.push_back(sdash);
00053
00054
00055 this->issidx = issidx % (cvec.size()*dvec.size());
00056 ssidx = issidx;
00057 }
00058
00059 StrokeStyle LinePlot::pickNextSS(void)
00060 {
00061 if(ssidx == (cvec.size()*dvec.size()))
00062 ssidx = 0;
00063
00064 if(ssidx == issidx);
00065
00066
00067 return pickNextSS(ssidx++);
00068 }
00069
00070 StrokeStyle LinePlot::pickNextSS(int idx)
00071 {
00072 int cid = idx % cvec.size();
00073 int did = idx / cvec.size();
00074
00075
00076
00077
00078
00079 return StrokeStyle(cvec[cid], .75, dvec[did]);
00080 }
00081
00082 void LinePlot::draw(Frame *frame, int dir)
00083 {
00084 HLayout hl(*frame,.9);
00085 Frame f = hl.getFrame(0);
00086 drawPlot(&f);
00087 f = hl.getFrame(1);
00088 BorderLayout bl(f,0,0,0,
00089 (ylabel.size()?label_style.getPointSize():0)+axis_bottom.label_style.getPointSize()+5);
00090 f = bl.getFrame(0);
00091 drawKey(&f);
00092 }
00093
00094 void LinePlot::drawPlot(Frame* frame)
00095 {
00096 Frame innerFrame = getPlotArea(frame);
00097
00098
00099 double minXdata, maxXdata, minYdata, maxYdata;
00100 sl.findMinMax(minXdata,maxXdata,minYdata,maxYdata);
00101
00102
00103 double minX=minXdata, maxX=maxXdata, minY=minYdata, maxY=maxYdata;
00104
00105
00106 if (fixedXaxis)
00107 {
00108 minX = minx;
00109 maxX = minx + width;
00110 }
00111
00112 if (fixedYaxis)
00113 {
00114 minY = miny;
00115 maxY = miny+height;
00116 }
00117
00118
00119 sl.drawInFrame(innerFrame,minX,maxX,minY,maxY);
00120
00121 setXAxis(minX, maxX);
00122 setYAxis(minY, maxY);
00123
00124 drawAxis(frame);
00125 }
00126 }