bpp-core  2.1.0
AbstractGraphicDevice.h
Go to the documentation of this file.
00001 //
00002 // File: AbstractGraphicDevice.h
00003 // Created by: Julien Dutheil
00004 // Created on: Fri Jul 24 2009
00005 //
00006 
00007 /*
00008 Copyright or © or Copr. CNRS, (November 16, 2006)
00009 
00010 This software is a computer program whose purpose is to provide utilitary
00011 classes. This file belongs to the Bio++ Project.
00012 
00013 This software is governed by the CeCILL  license under French law and
00014 abiding by the rules of distribution of free software.  You can  use, 
00015 modify and/ or redistribute the software under the terms of the CeCILL
00016 license as circulated by CEA, CNRS and INRIA at the following URL
00017 "http://www.cecill.info". 
00018 
00019 As a counterpart to the access to the source code and  rights to copy,
00020 modify and redistribute granted by the license, users are provided only
00021 with a limited warranty  and the software's author,  the holder of the
00022 economic rights,  and the successive licensors  have only  limited
00023 liability. 
00024 
00025 In this respect, the user's attention is drawn to the risks associated
00026 with loading,  using,  modifying and/or developing or reproducing the
00027 software by the user in light of its specific status of free software,
00028 that may mean  that it is complicated to manipulate,  and  that  also
00029 therefore means  that it is reserved for developers  and  experienced
00030 professionals having in-depth computer knowledge. Users are therefore
00031 encouraged to load and test the software's suitability as regards their
00032 requirements in conditions enabling the security of their systems and/or 
00033 data to be ensured and,  more generally, to use and operate it in the 
00034 same conditions as regards security. 
00035 
00036 The fact that you are presently reading this means that you have had
00037 knowledge of the CeCILL license and that you accept its terms.
00038 */
00039 
00040 #ifndef _ABSTRACTGRAPHICDEVICE_H_
00041 #define _ABSTRACTGRAPHICDEVICE_H_
00042 
00043 #include "GraphicDevice.h"
00044 
00045 namespace bpp
00046 {
00047 
00053 class AbstractGraphicDevice:
00054   public virtual GraphicDevice
00055 {
00056   private:
00057     double xUnit_;
00058     double yUnit_;
00059     RGBColor fgColor_;
00060     RGBColor bgColor_;
00061     Font font_;
00062     unsigned int pointSize_;
00063     short lineType_;
00064     int currentLayer_;
00065 
00066   public:
00067     AbstractGraphicDevice(): xUnit_(1.), yUnit_(1.),
00068         fgColor_(0, 0, 0), bgColor_(0, 0, 0), font_(), pointSize_(1), lineType_(LINE_SOLID), currentLayer_(-1) 
00069     {}
00070 
00071     virtual ~AbstractGraphicDevice() {}
00072 
00073   public:
00074     void setXUnit(double xu) { xUnit_ = xu; }
00075     void setYUnit(double yu) { yUnit_ = yu; }
00076     double getXUnit() const { return xUnit_; }
00077     double getYUnit() const { return yUnit_; }
00078 
00079     void setCurrentForegroundColor(const RGBColor& color) { fgColor_ = color; }
00080     void setCurrentBackgroundColor(const RGBColor& color) { bgColor_ = color; }
00081     void setCurrentFont(const Font& font) { font_ = font; }
00082     void setCurrentPointSize(unsigned int size) { pointSize_ = size; }
00083     void setCurrentLineType(short type) throw (Exception)
00084     { 
00085       if       (type == LINE_SOLID) lineType_ = type;
00086       else if (type == LINE_DASHED) lineType_ = type;
00087       else if (type == LINE_DOTTED) lineType_ = type;
00088       else throw Exception("AbstractGraphicDevice::setCurrentLineType. Unknown line type: " + TextTools::toString(type));
00089     }
00090     void setCurrentLayer(int layerIndex) { currentLayer_ = layerIndex; }
00091 
00092     const RGBColor& getCurrentForegroundColor() const { return fgColor_; }
00093     const RGBColor& getCurrentBackgroundColor() const { return bgColor_; }
00094     const Font& getCurrentFont() const { return font_; }
00095     unsigned int getCurrentPointSize() const { return pointSize_; }
00096     short getCurrentLineType() const { return lineType_; }
00097     int getCurrentLayer() const { return currentLayer_; }
00098  
00099 
00100   protected:
00101     double x_(double x) const { return x * xUnit_; }
00102     double y_(double y) const { return y * yUnit_; }
00103 
00104     double revx_(double x) const { return x / xUnit_; }
00105     double revy_(double y) const { return y / yUnit_; }
00106 
00107 };
00108 
00109 } //end of namespace bpp;
00110 
00111 #endif //_ABSTRACTGRAPHICDEVICE_H_
00112 
 All Classes Namespaces Files Functions Variables Typedefs Friends