bpp-core3  3.0.0
AbstractGraphicDevice.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_GRAPHICS_ABSTRACTGRAPHICDEVICE_H
6 #define BPP_GRAPHICS_ABSTRACTGRAPHICDEVICE_H
7 
8 
9 #include "GraphicDevice.h"
10 
11 namespace bpp
12 {
19  public virtual GraphicDevice
20 {
21 private:
22  double xUnit_;
23  double yUnit_;
27  unsigned int pointSize_;
28  short lineType_;
30 
31 public:
32  AbstractGraphicDevice() : xUnit_(1.), yUnit_(1.),
33  fgColor_(0, 0, 0), bgColor_(0, 0, 0), font_(), pointSize_(1), lineType_(LINE_SOLID), currentLayer_(-1)
34  {}
35 
37 
38 public:
39  void setXUnit(double xu) { xUnit_ = xu; }
40  void setYUnit(double yu) { yUnit_ = yu; }
41  double getXUnit() const { return xUnit_; }
42  double getYUnit() const { return yUnit_; }
43 
44  void setCurrentForegroundColor(const RGBColor& color) { fgColor_ = color; }
45  void setCurrentBackgroundColor(const RGBColor& color) { bgColor_ = color; }
46  void setCurrentFont(const Font& font) { font_ = font; }
47  void setCurrentPointSize(unsigned int size) { pointSize_ = size; }
48  void setCurrentLineType(short type)
49  {
50  if (type == LINE_SOLID) lineType_ = type;
51  else if (type == LINE_DASHED) lineType_ = type;
52  else if (type == LINE_DOTTED) lineType_ = type;
53  else throw Exception("AbstractGraphicDevice::setCurrentLineType. Unknown line type: " + TextTools::toString(type));
54  }
55  void setCurrentLayer(int layerIndex) { currentLayer_ = layerIndex; }
56 
57  const RGBColor& getCurrentForegroundColor() const { return fgColor_; }
58  const RGBColor& getCurrentBackgroundColor() const { return bgColor_; }
59  const Font& getCurrentFont() const { return font_; }
60  unsigned int getCurrentPointSize() const { return pointSize_; }
61  short getCurrentLineType() const { return lineType_; }
62  int getCurrentLayer() const { return currentLayer_; }
63 
64 protected:
65  double x_(double x) const { return x * xUnit_; }
66  double y_(double y) const { return y * yUnit_; }
67 
68  double revx_(double x) const { return x / xUnit_; }
69  double revy_(double y) const { return y / yUnit_; }
70 };
71 } // end of namespace bpp;
72 #endif // BPP_GRAPHICS_ABSTRACTGRAPHICDEVICE_H
Data structure for fonts.
Definition: Font.h:21
double revx_(double x) const
static short LINE_SOLID
void setCurrentForegroundColor(const RGBColor &color)
Describe a color according to its red, green and blue componants.
Definition: RgbColor.h:21
static short LINE_DOTTED
unsigned int getCurrentPointSize() const
const RGBColor & getCurrentForegroundColor() const
Interface for all plotting devices.
Definition: GraphicDevice.h:26
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. Overload exception constructor (to control the exceptions mechanism). Destructor is already virtual (from std::exception)
Definition: Exceptions.h:20
std::string toString(T t)
General template method to convert to a string.
Definition: TextTools.h:115
void setCurrentBackgroundColor(const RGBColor &color)
void setCurrentFont(const Font &font)