bpp-core  2.2.0
XFigGraphicDevice.h
Go to the documentation of this file.
1 //
2 // File: XFigGraphicDevice.h
3 // Created by: Julien Dutheil
4 // Created on: Mon Mar 03 2008
5 //
6 
7 /*
8 Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
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 _XFIGGRAPHICDEVICE_H_
41 #define _XFIGGRAPHICDEVICE_H_
42 
43 #include "../AbstractGraphicDevice.h"
44 #include "../ColorManager.h"
45 #include "XFigLaTeXFontManager.h"
47 
48 // From the STL:
49 #include <map>
50 #include <iostream>
51 
52 namespace bpp
53 {
54 
60 {
61  private:
62  std::ostream& out_;
63  std::vector<std::string> content_;
67  unsigned int fgColorCode_;
68  unsigned int bgColorCode_;
69  int fontCode_;
70  unsigned int fontSize_;
71  unsigned int fontFlag_;
73 
74  public:
75  XFigGraphicDevice(std::ostream& out):
76  out_(out),
77  content_(),
78  colorManager_(),
81  fgColorCode_(0),
82  bgColorCode_(0),
83  fontCode_(-1),
84  fontSize_(12),
87  {
88  setCurrentLayer(0);
89  }
90 
91  virtual ~XFigGraphicDevice() {}
92 
93  public:
94  void begin();
95  void end();
96 
97  void setCurrentForegroundColor(const RGBColor& color);
98  void setCurrentBackgroundColor(const RGBColor& color);
99  void setCurrentFont(const Font& font);
100  void setCurrentLineType(short type) throw (Exception)
101  {
102  if(type == LINE_SOLID) lineTypeCode_ = 0;
103  else if(type == LINE_DASHED) lineTypeCode_ = 1;
104  else if(type == LINE_DOTTED) lineTypeCode_ = 2;
105  else throw Exception("XFigGraphicDevice::setCurrentLineType. Unknown line type: " + TextTools::toString(type));
107  }
108  void drawLine(double x1, double y1, double x2, double y2);
109  void drawRect(double x, double y, double width, double height, short fill = FILL_EMPTY);
110  void drawCircle(double x, double y, double radius, short fill = FILL_EMPTY);
111  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);
112  void comment(const std::string& text)
113  {
114  content_.push_back("#" + text);
115  }
116 
117  //Specific:
118  void setFontFlag(unsigned int flag) { fontFlag_ = flag; }
119 
120  protected:
121  int getFillCode(short fill);
122 
123  public:
124  static const unsigned int FONTFLAG_LATEX;
125  static const unsigned int FONTFLAG_POSTSCRIPT;
126 
127 };
128 
129 } // end of namespace bpp;
130 
131 #endif //_XFIGGRAPHICDEVICE_H_
132 
133 
void end()
End the painting.
void comment(const std::string &text)
Add a comment in the output.
void setCurrentLineType(short type)
Data structure for fonts.
Definition: Font.h:56
This class allows to perform a correspondence analysis.
void setCurrentBackgroundColor(const RGBColor &color)
static short LINE_SOLID
STL namespace.
Describe a color according to its red, green and blue componants.
Definition: RgbColor.h:56
static short LINE_DOTTED
static const unsigned int FONTFLAG_LATEX
static std::string toString(T t)
General template method to convert to a string.
Definition: TextTools.h:189
void drawCircle(double x, double y, double radius, short fill=FILL_EMPTY)
Draw a circle.
static const unsigned int FONTFLAG_POSTSCRIPT
LaTeX font manager for the XFig format.
static short LINE_DASHED
Color manager for the XFig format.
Definition: ColorManager.h:106
XFigGraphicDevice(std::ostream &out)
void drawLine(double x1, double y1, double x2, double y2)
Draw a line between two points.
void setCurrentForegroundColor(const RGBColor &color)
Partial implementation of the GraphicDevice interface.
void setFontFlag(unsigned int flag)
void setCurrentFont(const Font &font)
static short FILL_EMPTY
void begin()
Start the painting.
void setCurrentLayer(int layerIndex)
Postscript font manager for the XFig format.
Exception base class.
Definition: Exceptions.h:57
XFigLaTeXFontManager latexFontManager_
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.
static short TEXT_VERTICAL_BOTTOM
XFigColorManager colorManager_
XFigPostscriptFontManager postscriptFontManager_
std::vector< std::string > content_
void drawRect(double x, double y, double width, double height, short fill=FILL_EMPTY)
Draw a rectangle.
XFig plotting format.
static short TEXT_HORIZONTAL_LEFT