Helper.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: Helper.hpp 1644 2009-01-27 19:26:14Z ckiesch $"
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //  
00023 //  Copyright 2004, The University of Texas at Austin
00024 //
00025 //============================================================================
00026 
00027 
00028 #ifndef VDRAW_HELPER_H
00029 #define VDRAW_HELPER_H
00030 
00031 #include "VGImage.hpp"
00032 #include "SVGImage.hpp"
00033 #include "PSImage.hpp"
00034 #include "EPSImage.hpp"
00035 
00036 namespace vdraw
00037 {
00040 
00045   class Helper
00046   {
00047     public:
00060     static VGImage* create(std::string fname,
00061         double width=VGImage::US_LETTER_WIDTH_PTS,
00062         double height=VGImage::US_LETTER_HEIGHT_PTS,
00063         VGImage::ORIGIN_LOCATION iloc=VGImage::LOWER_LEFT) throw (VDrawException)
00064     {
00065       using namespace std;
00066       size_t i = fname.find_last_of('.');
00067       if ((string::npos != i) && (i != fname.length()-1))
00068       {
00069         string ext = fname.substr(i+1);
00070         if( ext == "ps" )
00071           return new PSImage(fname.c_str(),width,height,iloc);
00072         else if( ext == "eps" )
00073           return new EPSImage(fname.c_str(),0,0,width,height,iloc);
00074         else if( ext == "svg" )
00075           return new SVGImage(fname.c_str(),width,height,iloc);
00076       }
00077       throw VDrawException("Non-supported file name...");
00078     }
00079 
00080   }; // class Helper
00081 
00083 
00084 } // namespace vplo
00085 
00086 #endif //VDRAW_HELPER_H

Generated on Wed Feb 8 03:31:00 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1