bpp-core  2.2.0
AbstractGraphicDevice.h
Go to the documentation of this file.
1 //
2 // File: AbstractGraphicDevice.h
3 // Created by: Julien Dutheil
4 // Created on: Fri Jul 24 2009
5 //
6 
7 /*
8 Copyright or © or Copr. Bio++ Development Team, (November 16, 2006)
9 
10 This software is a computer program whose purpose is to provide utilitary
11 classes. This file belongs to the Bio++ Project.
12 
13 This software is governed by the CeCILL license under French law and
14 abiding by the rules of distribution of free software. You can use,
15 modify and/ or redistribute the software under the terms of the CeCILL
16 license as circulated by CEA, CNRS and INRIA at the following URL
17 "http://www.cecill.info".
18 
19 As a counterpart to the access to the source code and rights to copy,
20 modify and redistribute granted by the license, users are provided only
21 with a limited warranty and the software's author, the holder of the
22 economic rights, and the successive licensors have only limited
23 liability.
24 
25 In this respect, the user's attention is drawn to the risks associated
26 with loading, using, modifying and/or developing or reproducing the
27 software by the user in light of its specific status of free software,
28 that may mean that it is complicated to manipulate, and that also
29 therefore means that it is reserved for developers and experienced
30 professionals having in-depth computer knowledge. Users are therefore
31 encouraged to load and test the software's suitability as regards their
32 requirements in conditions enabling the security of their systems and/or
33 data to be ensured and, more generally, to use and operate it in the
34 same conditions as regards security.
35 
36 The fact that you are presently reading this means that you have had
37 knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #ifndef _ABSTRACTGRAPHICDEVICE_H_
41 #define _ABSTRACTGRAPHICDEVICE_H_
42 
43 #include "GraphicDevice.h"
44 
45 namespace bpp
46 {
47 
54  public virtual GraphicDevice
55 {
56  private:
57  double xUnit_;
58  double yUnit_;
62  unsigned int pointSize_;
63  short lineType_;
65 
66  public:
68  fgColor_(0, 0, 0), bgColor_(0, 0, 0), font_(), pointSize_(1), lineType_(LINE_SOLID), currentLayer_(-1)
69  {}
70 
72 
73  public:
74  void setXUnit(double xu) { xUnit_ = xu; }
75  void setYUnit(double yu) { yUnit_ = yu; }
76  double getXUnit() const { return xUnit_; }
77  double getYUnit() const { return yUnit_; }
78 
79  void setCurrentForegroundColor(const RGBColor& color) { fgColor_ = color; }
80  void setCurrentBackgroundColor(const RGBColor& color) { bgColor_ = color; }
81  void setCurrentFont(const Font& font) { font_ = font; }
82  void setCurrentPointSize(unsigned int size) { pointSize_ = size; }
83  void setCurrentLineType(short type) throw (Exception)
84  {
85  if (type == LINE_SOLID) lineType_ = type;
86  else if (type == LINE_DASHED) lineType_ = type;
87  else if (type == LINE_DOTTED) lineType_ = type;
88  else throw Exception("AbstractGraphicDevice::setCurrentLineType. Unknown line type: " + TextTools::toString(type));
89  }
90  void setCurrentLayer(int layerIndex) { currentLayer_ = layerIndex; }
91 
92  const RGBColor& getCurrentForegroundColor() const { return fgColor_; }
93  const RGBColor& getCurrentBackgroundColor() const { return bgColor_; }
94  const Font& getCurrentFont() const { return font_; }
95  unsigned int getCurrentPointSize() const { return pointSize_; }
96  short getCurrentLineType() const { return lineType_; }
97  int getCurrentLayer() const { return currentLayer_; }
98 
99 
100  protected:
101  double x_(double x) const { return x * xUnit_; }
102  double y_(double y) const { return y * yUnit_; }
103 
104  double revx_(double x) const { return x / xUnit_; }
105  double revy_(double y) const { return y / yUnit_; }
106 
107 };
108 
109 } //end of namespace bpp;
110 
111 #endif //_ABSTRACTGRAPHICDEVICE_H_
112 
Data structure for fonts.
Definition: Font.h:56
double revx_(double x) const
This class allows to perform a correspondence analysis.
static short LINE_SOLID
void setCurrentForegroundColor(const RGBColor &color)
Describe a color according to its red, green and blue componants.
Definition: RgbColor.h:56
static short LINE_DOTTED
unsigned int getCurrentPointSize() const
const RGBColor & getCurrentForegroundColor() const
static std::string toString(T t)
General template method to convert to a string.
Definition: TextTools.h:189
Interface for all plotting devices.
Definition: GraphicDevice.h:62
double revy_(double y) const
static short LINE_DASHED
void setCurrentPointSize(unsigned int size)
const Font & getCurrentFont() const
Partial implementation of the GraphicDevice interface.
void setCurrentLayer(int layerIndex)
const RGBColor & getCurrentBackgroundColor() const
Exception base class.
Definition: Exceptions.h:57
void setCurrentBackgroundColor(const RGBColor &color)
void setCurrentFont(const Font &font)