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