bpp-core3  3.0.0
PgfGraphicDevice.h
Go to the documentation of this file.
1 //
2 // File: PgfGraphicDevice.h
3 // Authors:
4 // Julien Dutheil
5 // Created: 2008-06-19 00:00:00
6 //
7 
8 /*
9  Copyright or © or Copr. CNRS, (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_LATEX_PGFGRAPHICDEVICE_H
42 #define BPP_GRAPHICS_LATEX_PGFGRAPHICDEVICE_H
43 
44 
45 #include "../AbstractGraphicDevice.h"
46 #include "../ColorTools.h"
47 
48 // From the STL:
49 #include <map>
50 #include <vector>
51 #include <string>
52 
53 namespace bpp
54 {
60 {
61 private:
62  std::ostream& out_;
63  std::string fgColorStr_;
64  std::string bgColorStr_;
65  std::vector<std::string> content_;
66  std::vector<int> layers_;
67  std::map<const RGBColor, std::string> colorIndex_;
68  unsigned int colorCount_;
69  bool useLayers_;
71  mutable std::map<short int, std::string> fontShapes_;
72  mutable std::map<short int, std::string> fontSeries_;
73 
74 public:
85  PgfGraphicDevice(std::ostream& out, double unit);
86 
87  virtual ~PgfGraphicDevice() {}
88 
89 public:
90  void begin();
91  void end();
92 
93  void setCurrentForegroundColor(const RGBColor& color);
94  void setCurrentBackgroundColor(const RGBColor& color);
95  void setCurrentFont(const Font& font);
96  void setCurrentPointSize(unsigned int size);
97  void setCurrentLineType(short type);
98  void setCurrentLayer(int layerIndex);
99 
100  void drawLine(double x1, double y1, double x2, double y2);
101  void drawRect(double x, double y, double width, double height, short fill = FILL_EMPTY);
102  void drawCircle(double x, double y, double radius, short fill = FILL_EMPTY);
103  void drawText(double x, double y, const std::string& text, short hpos = TEXT_HORIZONTAL_LEFT, short vpos = TEXT_VERTICAL_BOTTOM, double angle = 0);
104  void comment(const std::string& text)
105  {
106  content_.push_back("%" + text);
107  }
108 
109 public:
110  const std::string& getFontShape(const Font& font);
111 };
112 } // end of namespace bpp.
113 #endif // BPP_GRAPHICS_LATEX_PGFGRAPHICDEVICE_H
Partial implementation of the GraphicDevice interface.
Data structure for fonts.
Definition: Font.h:59
static short TEXT_HORIZONTAL_LEFT
static short FILL_EMPTY
static short TEXT_VERTICAL_BOTTOM
LaTeX Portable Graphic Format (Pgf) plotting format.
void setCurrentBackgroundColor(const RGBColor &color)
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.
void end()
End the painting.
void drawRect(double x, double y, double width, double height, short fill=FILL_EMPTY)
Draw a rectangle.
void setCurrentLineType(short type)
void setCurrentLayer(int layerIndex)
void setCurrentFont(const Font &font)
std::map< const RGBColor, std::string > colorIndex_
std::map< short int, std::string > fontShapes_
std::map< short int, std::string > fontSeries_
void setCurrentForegroundColor(const RGBColor &color)
PgfGraphicDevice(std::ostream &out, double unit)
Build a new Pgf device object.
void comment(const std::string &text)
Add a comment in the output.
void drawLine(double x1, double y1, double x2, double y2)
Draw a line between two points.
void drawCircle(double x, double y, double radius, short fill=FILL_EMPTY)
Draw a circle.
const std::string & getFontShape(const Font &font)
void begin()
Start the painting.
void setCurrentPointSize(unsigned int size)
std::vector< std::string > content_
std::vector< int > layers_
Describe a color according to its red, green and blue componants.
Definition: RgbColor.h:60