LinePlot.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: LinePlot.cpp 3140 2012-06-18 15:03:02Z susancummins $"
00002 
00004 
00005 //============================================================================
00006 //
00007 //  This file is part of GPSTk, the GPS Toolkit.
00008 //
00009 //  The GPSTk is free software; you can redistribute it and/or modify
00010 //  it under the terms of the GNU Lesser General Public License as published
00011 //  by the Free Software Foundation; either version 2.1 of the License, or
00012 //  any later version.
00013 //
00014 //  The GPSTk is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 //  GNU Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with GPSTk; if not, write to the Free Software Foundation,
00021 //  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
00022 //  
00023 //  Copyright 2004, The University of Texas at Austin
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     // Initial index
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     //Throw an error...doing same stuff again
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     //throw an exception for did>dlist.size()
00076     //if possible try (ssidx/clist.size())%dlist.size()
00077     // FIXME See above problem.  Maybe allow manual dlist add.
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); // ,dir);
00092   }
00093 
00094   void LinePlot::drawPlot(Frame* frame)
00095   {
00096     Frame innerFrame = getPlotArea(frame);
00097 
00098     // Obtain mins and maxes from the data
00099     double minXdata, maxXdata, minYdata, maxYdata;
00100     sl.findMinMax(minXdata,maxXdata,minYdata,maxYdata);
00101 
00102     // Assume these will be used as boundaries of the plots
00103     double minX=minXdata, maxX=maxXdata, minY=minYdata, maxY=maxYdata;
00104     
00105     // See if the user overrode the axes limits
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     // Use default min/max
00119     sl.drawInFrame(innerFrame,minX,maxX,minY,maxY);
00120 
00121     setXAxis(minX, maxX);
00122     setYAxis(minY, maxY); 
00123 
00124     drawAxis(frame);
00125   }
00126 }

Generated on Mon May 20 03:31:07 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1