bpp-core  2.2.0
PgfGraphicDevice.h
Go to the documentation of this file.
1 //
2 // File: PgfGraphicDevice.h
3 // Created by: Julien Dutheil
4 // Created on: Thu Jun 19 2008
5 //
6 
7 /*
8 Copyright or © or Copr. CNRS, (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 _PGFGRAPHICDEVICE_H_
41 #define _PGFGRAPHICDEVICE_H_
42 
43 #include "../AbstractGraphicDevice.h"
44 #include "../ColorTools.h"
45 
46 // From the STL:
47 #include <map>
48 #include <vector>
49 #include <string>
50 
51 namespace bpp
52 {
53 
59 {
60  private:
61  std::ostream& out_;
62  std::string fgColorStr_;
63  std::string bgColorStr_;
64  std::vector<std::string> content_;
65  std::vector<int> layers_;
66  std::map<const RGBColor, std::string> colorIndex_;
67  unsigned int colorCount_;
68  bool useLayers_;
70  mutable std::map<short int, std::string> fontShapes_;
71  mutable std::map<short int, std::string> fontSeries_;
72 
73  public:
84  PgfGraphicDevice(std::ostream& out, double unit);
85 
86  virtual ~PgfGraphicDevice() {}
87 
88  public:
89  void begin();
90  void end();
91 
92  void setCurrentForegroundColor(const RGBColor& color);
93  void setCurrentBackgroundColor(const RGBColor& color);
94  void setCurrentFont(const Font& font);
95  void setCurrentPointSize(unsigned int size);
96  void setCurrentLineType(short type) throw (Exception);
97  void setCurrentLayer(int layerIndex);
98 
99  void drawLine(double x1, double y1, double x2, double y2);
100  void drawRect(double x, double y, double width, double height, short fill = FILL_EMPTY);
101  void drawCircle(double x, double y, double radius, short fill = FILL_EMPTY);
102  void drawText(double x, double y, const std::string & text, short hpos = TEXT_HORIZONTAL_LEFT, short vpos = TEXT_VERTICAL_BOTTOM, double angle = 0) throw (UnvalidFlagException);
103  void comment(const std::string& text)
104  {
105  content_.push_back("%" + text);
106  }
107 
108  public:
109  const std::string& getFontShape(const Font& font);
110 
111 };
112 
113 } // end of namespace bpp.
114 
115 #endif //_PGFGRAPHICDEVICE_H_
116 
117 
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:56
void end()
End the painting.
std::map< const RGBColor, std::string > colorIndex_
This class allows to perform a correspondence analysis.
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)
STL namespace.
void setCurrentBackgroundColor(const RGBColor &color)
Describe a color according to its red, green and blue componants.
Definition: RgbColor.h:56
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_
Exception base class.
Definition: Exceptions.h:57
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