bpp-core3  3.0.0
PgfGraphicDevice.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_LATEX_PGFGRAPHICDEVICE_H
6 #define BPP_GRAPHICS_LATEX_PGFGRAPHICDEVICE_H
7 
8 
9 #include "../AbstractGraphicDevice.h"
10 #include "../ColorTools.h"
11 
12 // From the STL:
13 #include <map>
14 #include <vector>
15 #include <string>
16 
17 namespace bpp
18 {
24 {
25 private:
26  std::ostream& out_;
27  std::string fgColorStr_;
28  std::string bgColorStr_;
29  std::vector<std::string> content_;
30  std::vector<int> layers_;
31  std::map<const RGBColor, std::string> colorIndex_;
32  unsigned int colorCount_;
33  bool useLayers_;
35  mutable std::map<short int, std::string> fontShapes_;
36  mutable std::map<short int, std::string> fontSeries_;
37 
38 public:
49  PgfGraphicDevice(std::ostream& out, double unit);
50 
51  virtual ~PgfGraphicDevice() {}
52 
53 public:
54  void begin();
55  void end();
56 
57  void setCurrentForegroundColor(const RGBColor& color);
58  void setCurrentBackgroundColor(const RGBColor& color);
59  void setCurrentFont(const Font& font);
60  void setCurrentPointSize(unsigned int size);
61  void setCurrentLineType(short type);
62  void setCurrentLayer(int layerIndex);
63 
64  void drawLine(double x1, double y1, double x2, double y2);
65  void drawRect(double x, double y, double width, double height, short fill = FILL_EMPTY);
66  void drawCircle(double x, double y, double radius, short fill = FILL_EMPTY);
67  void drawText(double x, double y, const std::string& text, short hpos = TEXT_HORIZONTAL_LEFT, short vpos = TEXT_VERTICAL_BOTTOM, double angle = 0);
68  void comment(const std::string& text)
69  {
70  content_.push_back("%" + text);
71  }
72 
73 public:
74  const std::string& getFontShape(const Font& font);
75 };
76 } // end of namespace bpp.
77 #endif // BPP_GRAPHICS_LATEX_PGFGRAPHICDEVICE_H
void drawText(double x, double y, const std::string &text, short hpos=TEXT_HORIZONTAL_LEFT, short vpos=TEXT_VERTICAL_BOTTOM, double angle=0)
Draw some characters.
const std::string & getFontShape(const Font &font)
void drawRect(double x, double y, double width, double height, short fill=FILL_EMPTY)
Draw a rectangle.
Data structure for fonts.
Definition: Font.h:21
void end()
End the painting.
std::map< const RGBColor, std::string > colorIndex_
void drawCircle(double x, double y, double radius, short fill=FILL_EMPTY)
Draw a circle.
std::map< short int, std::string > fontShapes_
void setCurrentFont(const Font &font)
void setCurrentBackgroundColor(const RGBColor &color)
Describe a color according to its red, green and blue componants.
Definition: RgbColor.h:21
void setCurrentLineType(short type)
std::vector< std::string > content_
void setCurrentLayer(int layerIndex)
void setCurrentForegroundColor(const RGBColor &color)
Partial implementation of the GraphicDevice interface.
static short FILL_EMPTY
std::map< short int, std::string > fontSeries_
void comment(const std::string &text)
Add a comment in the output.
static short TEXT_VERTICAL_BOTTOM
LaTeX Portable Graphic Format (Pgf) plotting format.
void begin()
Start the painting.
std::vector< int > layers_
void setCurrentPointSize(unsigned int size)
PgfGraphicDevice(std::ostream &out, double unit)
Build a new Pgf device object.
void drawLine(double x1, double y1, double x2, double y2)
Draw a line between two points.
static short TEXT_HORIZONTAL_LEFT